123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225 |
- using LYFZ.ComponentLibrary;
- using LYFZ.Network.FTPOperation;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.MultipleFileImport
- {
- public partial class frmFTPFileImprot : LYFZ.ComponentLibrary.BaseContentsFormMain
- {
- Timer timer;
- public frmFTPFileImprot()
- {
- InitializeComponent();
- this.Shown += frmFTPFileImprot_Shown;
- this.btn_Refresh.Click += btn_Refresh_Click;
- radio_None.Click += radio_Click;
- radio_fiveRef.Click += radio_Click;
- radio_thirdRef.Click += radio_Click;
- btn_Start.Click += btn_StartOrStop_Click;
- btn_Stop.Click += btn_StartOrStop_Click;
- timer = new Timer();
- timer.Tick += timer_Tick;
-
- }
- void btn_StartOrStop_Click(object sender, EventArgs e)
- {
- if(this.lv_StatusList.SelectedItems.Count>0)
- {
- ListViewItem lvi = this.lv_StatusList.SelectedItems[0];
- UpFTPServiceFileGroup group = lvi.Tag as UpFTPServiceFileGroup;
- CommandData command = new CommandData();
- command.CommandType = "S";
- command.bUpfileCode = Convert.ToInt32(((ButtonEx)sender).Tag);
- command.dirTypeData = group.GuidKey;
- HPSocketCS.Extended.RequestData requestData = new HPSocketCS.Extended.RequestData((int)LYFZ.Network.TCPNetworkServer.SerializerRequestCommand.FTPCommand);
- requestData.AttachedMessage = Json.JsonTool.ObjectToJson(command);
- HPSocketCS.Extended.ReturnData returnData = HPSocketCS.Extended.SerializerDataProcessed.HP_SendSerializerCommandToServer(requestData);
- if (returnData.ReturnStatus)
- {
- }
- }
-
- }
- void BindCompleteData()
- {
- try
- {
- CommandData command = new CommandData();
- command.CommandType = "O";
- HPSocketCS.Extended.RequestData requestData = new HPSocketCS.Extended.RequestData((int)LYFZ.Network.TCPNetworkServer.SerializerRequestCommand.FTPCommand);
- requestData.AttachedMessage = Json.JsonTool.ObjectToJson(command);
- HPSocketCS.Extended.ReturnData returnData = HPSocketCS.Extended.SerializerDataProcessed.HP_SendSerializerCommandToServer(requestData);
- if (returnData.ReturnStatus)
- {
- List<dynamic> shopList = new List<dynamic>();
- shopList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(returnData.AttachedMessage);
- this.lvComplete.Items.Clear();
- shopList = shopList.FindAll(p => Convert.ToString(p.localShopInfo) == CommonLogical.SuccessfulLogin.CompanyName);
- foreach (dynamic dyObj in shopList)
- {
- ListViewGroup group = new ListViewGroup(Convert.ToString(dyObj.localShopInfo));
- this.lvComplete.Groups.Add(group);
- foreach (var mod in dyObj.Item)
- {
- ListViewItem item = new ListViewItem(new string[] { mod.Text + "", mod.StartTime + "", mod.EndTime + "" });
- item.Group = group;
- this.lvComplete.Items.Add(item);
- }
- }
- }
- }
- catch { }
- }
-
- void timer_Tick(object sender, EventArgs e)
- {
- bool b = this.Visible;
- if (b)
- {
- btn_Refresh_Click(null, null);
- }
- else
- {
- timer.Stop();
- }
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- void radio_Click(object sender, EventArgs e)
- {
- RadioButtonEx radio = (RadioButtonEx)sender;
- if (radio.Name == "radio_None")
- {
- timer.Stop();
- }
- else if (radio.Name == "radio_fiveRef")
- {
- timer.Interval = 5000;
- timer.Start();
- }
- else if (radio.Name == "radio_thirdRef")
- {
- timer.Interval = 3000;
- timer.Start();
- }
- }
- int nullDataTick = 0;
- void btn_Refresh_Click(object sender, EventArgs e)
- {
- CommandData command = new CommandData();
- command.CommandType = "P";
- HPSocketCS.Extended.RequestData requestData = new HPSocketCS.Extended.RequestData((int)LYFZ.Network.TCPNetworkServer.SerializerRequestCommand.FTPCommand);
- requestData.AttachedMessage = Json.JsonTool.ObjectToJson(command);
- HPSocketCS.Extended.ReturnData returnData = HPSocketCS.Extended.SerializerDataProcessed.HP_SendSerializerCommandToServer(requestData);
- if (returnData.ReturnStatus)
- {
- List<UpFTPServiceFileShop> shopList = new List<UpFTPServiceFileShop>();
- shopList = (List<UpFTPServiceFileShop>)Json.JsonTool.JsonToObject(returnData.AttachedMessage, shopList);
- if(shopList.Count>0)
- {
- lv_StatusList.Items.Clear();
- lv_StatusList.Groups.Clear();
- nullDataTick = 0;
- }
- else
- {
- nullDataTick++;
- if(nullDataTick>3)
- {
- lv_StatusList.Items.Clear();
- lv_StatusList.Groups.Clear();
- }
- }
- bool bFirstStartUp = false;
- foreach (var shop in shopList)
- {
- ListViewGroup group = new ListViewGroup(shop.localShopInfo);
- lv_StatusList.Groups.Add(group);
- foreach (var mod in shop.items)
- {
- string statusText = "";
- List<UpFTPServiceFileItem> items = mod.items.FindAll(p => p.statusCode == 0 || p.statusCode == -1);
- if (mod.bOpenStatus == 1&&items.Count > 0)
- {
- statusText = "待上传";
- if (!bFirstStartUp)
- {
- statusText = "正在上传";
- bFirstStartUp = true;
- }
-
- UpFTPServiceFileItem upItem = (mod.items.Find(p => p.statusCode == 99));
- if (upItem != null)
- {
- statusText = "正在上传";
- }
- }
- else if (mod.bOpenStatus == 1 &&
- items.Count == 0)
- {
- statusText = "完成";
- }
- else if (mod.bOpenStatus == 0)
- {
- statusText = "暂停";
- }
-
- ListViewItem item = new ListViewItem(new string[] {"" + mod.OrderNumber + "(" + mod.DirFileType + "上传到——" +
- shop.upShopText + "(" + shop.hostPath + ":" + shop.ftpName + ")" + ")",Convert.ToSingle(mod.processValue*100/mod.totalSize).ToString("0.00")+"%",
- statusText});
- item.Group = group;
- item.Tag = mod;
- this.lv_StatusList.Items.Add(item);
- }
- }
- if(shopList.Count>0)
- {
- radio_Click(new RadioButtonEx() {
- Name = "radio_thirdRef"
- }, null);
- }
- else
- {
- radio_Click(new RadioButtonEx()
- {
- Name = "radio_None"
- }, null);
- }
- }
- }
- void frmFTPFileImprot_Shown(object sender, EventArgs e)
- {
- btn_Refresh_Click(null, null);
- }
- private void tabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
- {
-
- if ((tabControlEx1.TabPages[tabControlEx1.SelectedIndex]).Tag==null&&(tabControlEx1.TabPages[tabControlEx1.SelectedIndex]).Text=="已完成")
- {
- (tabControlEx1.TabPages[tabControlEx1.SelectedIndex]).Tag = true;
- BindCompleteData();
- }
- }
- }
- }
|