private void b_SearchFile_Click(object sender, EventArgs e) { Command_info c = new Command_info(); c.type = 2; c.msg = "D:\\,.,E:\\"; c.msg2 = str_search; string str_c = Helper_Json.Encode(c); long r_l = h_redis.RedisPub(str_r_rep, str_c); SetrichTextBox(str_r_rep + ":" + str_c); }
private void b_Sender_Click(object sender, EventArgs e) { Command_info c = new Command_info(); c.type = 1; c.msg = ""; c.msg2 = ""; string str_c = Helper_Json.Encode(c); SetrichTextBox("刷新所有硬盘信息....."); long r_l = h_redis.RedisPub(str_r_rep, str_c); Helper_log.Write_log(str_r_rep + ":" + str_c); }
private void button5_Click(object sender, EventArgs e) { if (lb_Files.Tag != null && cb_disk.Tag != null) { List <T_Video> lts = (List <T_Video>)lb_Files.Tag; List <T_DISK_INFO> dis = (List <T_DISK_INFO>)cb_disk.Tag; T_DISK_INFO di = dis[cb_disk.SelectedIndex]; double d_source_size = 0; if (lb_Total_Size.Tag != null) { d_source_size = Math.Round((double)lb_Total_Size.Tag, 4); } Task_Info ti = new Task_Info(); ti.id = Guid.NewGuid().ToString(); List <string> arr_file_path = new List <string>(); List <string> arr_copy_type = new List <string>(); foreach (var v in lts) { arr_file_path.Add(v.FILE_FULLPATH); if (v.FILE_INDEX == "1") { arr_copy_type.Add(v.FILE_INDEX); } else { arr_copy_type.Add("0"); } } ti.arr_source = arr_file_path.ToArray(); ti.copy_type = string.Join(",.,", arr_copy_type); ti.source_size = d_source_size; ti.target = di.LOGICAL_NAME; if (di.LOGICAL_TOTALSIZE.HasValue) { ti.target_size = Math.Round(di.LOGICAL_TOTALSIZE.Value, 4); } if (di.LOGICAL_FREESPACE.HasValue) { ti.target_free_size = di.LOGICAL_FREESPACE.Value; } int i_exists = -1; //是否存在相同的硬盘拷贝 for (int i = 0; i < lts.Count; i++) { if (lts[i].FILE_ROOT == ti.target) { i_exists = i; break; } } //此处应该增加排除相同任务的判定,待到重构时增加 if (i_exists > -1) { if (MessageBox.Show("拷贝任务中拷贝文件【" + (i_exists + 1) + "】存在源硬盘与目标硬盘名称相同【" + ti.target + "】,是否继续?", "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) != DialogResult.OK) { return; } } //待添加硬盘剩余空间的判定 DataGridViewRow dr = new DataGridViewRow(); dr.CreateCells(dgv_Task); dr.Cells[0].Value = "0"; dr.Cells[1].Value = ti.source_size; dr.Cells[2].Value = ti.target; dr.Cells[3].Value = ti.target_size; dr.Tag = ti; //添加的行作为第一行 dgv_Task.Rows.Insert(0, dr); int i_count = Convert.ToInt16(lb_Task_count.Tag); i_count++; string str_format = "数量:{0}"; lb_Task_count.Tag = i_count; lb_Task_count.Text = string.Format(str_format, i_count); Command_info c = new Command_info(); c.type = 4; c.msg = string.Join(",.,", ti.arr_source); c.msg2 = ti.copy_type; c.tag = Helper_Json.Encode(ti); //c.tag = ti.id; string str_c = Helper_Json.Encode(c); int i_success = MyVideoBussiness.Add_Task_Info(ti, lts); if (i_success > 0) { long r_l = h_redis.RedisPub(str_r_rep, str_c); SetrichTextBox("拷贝任务....." + ti.arr_source.Length + "..." + i_success); } else { SetrichTextBox("记录失败....." + i_success + "..."); } } }
private void button3_Click(object sender, EventArgs e) { List <string> arr_disklist = new List <string>(); List <int> arr_disk_id_list = new List <int>(); List <string> arr_disk_list_offline = new List <string>(); int i_count_disk_online = 0, i_count_disk_offline = 0; List <T_DISK_INFO> l_tdi = Get_Selected_DISK_INFO(); if (l_tdi.Count > 0) { foreach (var di in l_tdi) { if (di.IS_ONLINE == 1) { i_count_disk_online++; arr_disklist.Add(di.LOGICAL_NAME); arr_disk_id_list.Add(Convert.ToInt32(di.ID)); } else { i_count_disk_offline++; arr_disk_list_offline.Add(di.LOGICAL_NAME); } } //if (i_count_disk_online > 0) //{ // str_disklist = str_disklist.Substring(0, str_disklist.Length - 3); // str_disk_id_list = str_disk_id_list.Substring(0, str_disk_id_list.Length - 3); //} if (i_count_disk_online == 0) { SetrichTextBox("请选择待扫描的在线硬盘"); return; } if (i_count_disk_offline > 0) { SetrichTextBox("以下硬盘离线,系统将不扫描。" + string.Join(",", arr_disk_list_offline)); } //删除影片表中对应盘符下的影片,以备重新扫描 foreach (var id in arr_disk_id_list) { MyVideoBussiness.Delete_Video_Info(id); } Command_info c = new Command_info(); c.type = 2; for (int i = 0; i < arr_disklist.Count; i++) { if (i == arr_disklist.Count - 1) { c.msg += arr_disklist[i] + "\\"; } else { c.msg += arr_disklist[i] + "\\,.,"; } } //c.msg = @"D:\chao\工作\电影程序\Data"; c.msg2 = str_search; c.tag = string.Join(",.,", arr_disk_id_list); string str_c = Helper_Json.Encode(c); SetrichTextBox("开始扫描....." + i_count_disk_online + "..." + string.Join(",", arr_disklist)); str_Scan_dir = ""; long r_l = h_redis.RedisPub(str_r_rep, str_c); } }
private void H_redis_RedisSubMessageEvent(string str) { //Add_Text_Value(str); Result_Info r = (Result_Info)Helper_Json.Decode(str, typeof(Result_Info)); if (r.type > 0) { Helper_log.Write_log(str); if (r.type == 1) { if (r.code > 0) { List <Disk_Info> ds = (List <Disk_Info>)Helper_Json.Decode(r.msg, typeof(List <Disk_Info>)); SetrichTextBox("更新成功数量:" + MyVideoBussiness.Update_Disk_Info(ds)); Refresh_DataGridView(); SetrichTextBox("更新硬盘成功"); } } else if (r.type == 2) { if (r.code == 1) { File_Info fi = (File_Info)Helper_Json.Decode(r.msg, typeof(File_Info)); MyVideoBussiness.Add_Video_Info(fi); SetrichTextBox("扫描:" + fi.fileFullPath); } } else if (r.type == 3) { string str_total_size = string.Format(str_match_file_size, Math.Round(r.code, 4)); SetMyTextBoxValue(lb_Total_Size, str_total_size); lb_Total_Size.Tag = r.code; } else if (r.type == 4) { string str_msg = ""; string[] arr_msg = Regex.Split(r.msg, ",.,", RegexOptions.IgnoreCase); if (r.flag) { str_msg = "拷贝完成:"; if (arr_msg.Length > 2) { for (int i = 0; i < dgv_Task.RowCount; i++) { Task_Info ti = dgv_Task.Rows[i].Tag as Task_Info; if (ti.id == arr_msg[0]) { ti.count_copy_files += Convert.ToInt16(arr_msg[2]); //判断是否拷贝完成 if (r.code == 0) //0单文件拷贝 { if (ti.arr_source.Length == ti.count_copy_files) { dgv_Task.Rows[i].Cells[0].Value = 1; } } else if (r.code == 1) //1目录拷贝 { //拷贝目录待判定是否拷贝完成 } MyVideoBussiness.Update_Task_Info(ti.id, ti.count_copy_files); break; } } } //待完成目录拷贝的判定 } else { str_msg = "拷贝失败:"; } str_msg += r.msg; SetrichTextBox(str_msg); } } }