C# FTP常规方法
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Threading;
using System.Collections;
using System.Diagnostics;
using Dare.DN.Services.EntityServices;
using Dare.DN.Components;
using Dare.DN.Components.Entities;
using Dare.DN.Components.Entities.Media;
using System.Net;
using System.IO;
using System.Web;
using Dare.Utilities.Model;
using Dare.Utilities;
using Dare.Utilities.IO;
using SevenZip;
using System.Xml;
using Dare.Utilities.Net.Ftp;
namespace DareTrayTool
{
/// <summary>
/// 网络多媒体导入导出工具
/// </summary>
public partial class MainFrm : Form
{
#region 初始化变量
UriBuilder uribuilder = null;
Dare.DN.Services.Application app;
Dare.DN.Services.EntityServices.TerminalGroupInfoService groupService;
Dare.DN.Services.EntityServices.MediaInfoService mediaService;
Dare.DN.Services.EntityServices.MediaFolderInfoService folderService;
Dare.DN.Services.EntityServices.PlaybillScheduleService scheduleService;
//--------------------计划单导出----------------------//
private const bool USE_FILE_ENCRYPT = false; //是否使用加密
private const bool CHANGE_PLAY_FILE_NAME = true; //是否改变文件名和路径
private bool isAbort = false;//是否终止导出计划单任务
//--------------------节目单导出----------------------//
private string tabName = string.Empty;
private string desPath = string.Empty;
private string pmTolProcess = string.Empty;
private string exTolProcess = string.Empty;
//-------------------------节目单导入--------------------//
OpenFileDialog ofd = null;
#endregion
#region 初始化方法
private void IntPublic()
{
app = Dare.DN.Services.Application.Instance;
groupService = app.GetDbService<TerminalGroupInfoService>();
mediaService = app.GetDbService<MediaInfoService>();
folderService = app.GetDbService<MediaFolderInfoService>();
scheduleService = app.GetDbService<PlaybillScheduleService>();
uribuilder = new UriBuilder();
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Path.Combine(Application.StartupPath, "sysfig.xml"));
XmlNode xn = null;
xn = xmlDoc.SelectSingleNode("sys/host");
uribuilder.Host = DES.Decode(xn.InnerText.Trim(), "da@^@re");
xn = xmlDoc.SelectSingleNode("sys/user");
uribuilder.UserName = DES.Decode(xn.InnerText.Trim(), "da@^@re");
xn = xmlDoc.SelectSingleNode("sys/pwd");
uribuilder.Password = DES.Decode(xn.InnerText.Trim(), "da@^@re");
}
#endregion
#region 终端组与计划单UI绑定
/// <summary>
/// 计划单终端数绑定
/// </summary>
private void PlayTrViewInt()
{
this.PlayTrView.Nodes.Clear();
this.PlayTrView.ImageList = this.imageList1;
this.PlayTrView.ImageIndex = 0;
this.PlayTrView.SelectedImageIndex = 0;
TerminalGroupDataInit();
//展开父节点
this.PlayTrView.Nodes[0].Expand();
//默认选中父节点
//this.PlayTrView.SelectedNode = this.TrView.Nodes[0];
this.PlayTrView.Select();
//初始化节目单列表排序
this.lvPlayFile.ListViewItemSorter = new ListViewSort();
}
/// <summary>
/// 终端关联计划单列表绑定
/// </summary>
private void TerminalGroupDataInit()
{
List<TerminalGroupInfo> groups;
if (AppContext.Current.CurrentUser.HasPrivilegeOf(Dare.DN.Components.Entities.PrivilegeType.AllPrivileges))
{
groups = groupService.GetAll();
}
else
{
groups = groupService.GetAllByUserId(true, true, AppContext.Current.CurrentUser.Id);
}
TreeNode terminalroot = new TreeNode("所有节目终端");
PlayTrView.Nodes.Add(terminalroot);
bool top = true;
foreach (TerminalGroupInfo group in groups)
{
if (group.ParentId == null)
{
break;
}
top = false;
}
if (top == false)
{
foreach (TerminalGroupInfo group in groups)
{
bool b = false;
foreach (TerminalGroupInfo sgroup in groups)
{
if (sgroup.Id == group.ParentId)
{
b = true;
break;
}
}
if (b == false)group.ParentId = null;
}
}
TerminalGroupTreeDataBind(terminalroot.Nodes, null, groups);
}
private void TerminalGroupTreeDataBind(TreeNodeCollection nodes, int? parentId, List<TerminalGroupInfo> groups)
{
foreach (TerminalGroupInfo group in groups)
{
if (group.ParentId == parentId)
{
TreeNode tn = new TreeNode();
tn.Text = group.Name;
tn.Tag = group.Id;
nodes.Add(tn);
if (group.HasChildren != false)
{
TerminalGroupTreeDataBind(tn.Nodes, group.Id, groups);
}
}
}
}
private void TemTrView_AfterSelect(object sender, TreeViewEventArgs e)
{
if (e.Node.Tag != null)
{
int terminalId=0;
int.TryParse(e.Node.Tag.ToString(), out terminalId);
ScheduleDataInit(terminalId);
}
}
private void ScheduleDataInit(int?groupId)
{
List<PlaybillScheduleInfo> scheduleList=null;
int totalCount = 0;
if (groupId == null && !AppContext.Current.CurrentUser.HasPrivilegeOf(PrivilegeType.AllPrivileges))
{
scheduleList = scheduleService.Search(null, AppContext.Current.CurrentUser.Id, true, false, null, null, -1, -1, out totalCount);
}
else
{
scheduleList = scheduleService.Search(groupId, null, true, false, null, null, -1, -1, out totalCount);
}
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/66676.html