public static int Add_Task_Info(Task_Info task, List <T_Video> vs) { using (var ctx = new myVideoEntities()) { try { T_WORKS w = new T_WORKS(); DateTime dt_now = DateTime.Now; w.CREATETIME = dt_now; w.NAME = task.id; w.SOURCE_SIZE = task.source_size; w.TARGET_HD_SIZE = task.target_size; w.TARGET_LOCATION = task.target; w.TARGET_FREE_SIZE = task.target_free_size; w.VIDEO_COUNT = vs.Count; w.COPY_COUNT = 0; w.MEMO = task.copy_type; ctx.T_WORKS.Add(w); int row = ctx.SaveChanges(); if (row > 0) { foreach (var v in vs) { T_WORKS_SUB ws = new T_WORKS_SUB(); ws.CREATE_TIME = dt_now; ws.FILESIZE = v.FILESIZE; ws.FILE_DIR = v.FILE_DIR; ws.FILE_EXTENSION = v.FILE_EXTENSION; ws.FILE_FULLPATH = v.FILE_FULLPATH; ws.FILE_NAME = v.FILE_NAME; ws.FILE_ROOT = v.FILE_ROOT; ws.ID_VIDEO = v.ID; ws.PID = w.ID; ctx.T_WORKS_SUB.Add(ws); } } return(ctx.SaveChanges()); } catch (Exception ex) { Helper_log.Write_Error(ex.InnerException.Message + ";" + ex.Message); return(0); } } }
public void onInitSet() { try { //grid clear groupBox_jobitem.Enabled = false; dataGridView_reg.Rows.Clear(); //task list read mainform.dbBridge.onDBRead_Tasklist(); //컨트롤 clear onCtrlClear(); //로봇 작업그룹 읽기 -> 콤보박스 표시 cboRobotGroup.Items.Clear(); mainform.dbBridge.onDBRead_RobotGrouplist(); //grid dp int cnt = Data.Instance.Task_list.Count(); for (int i = 0; i < cnt; i++) { string strtmp = ""; Task_Info taskinfo = Data.Instance.Task_list.ElementAt(i).Value; string task_status = taskinfo.task_status; if (task_status == "") { task_status = "wait"; } string task_id = taskinfo.task_id; string task_name = taskinfo.task_name; string task_missionlist = taskinfo.mission_id_list; string task_robotlist = taskinfo.robot_id_list; string taskloopflag = taskinfo.taskloopflag; string robotgroupid = taskinfo.robot_group_id; string strgroupname = ""; if (robotgroupid == "All") { strgroupname = "All"; } else { int cnt2 = Data.Instance.robotgroup_list.robotgroup.Count; for (int i2 = 0; i2 < cnt; i2++) { if (Data.Instance.robotgroup_list.robotgroup[i2].robot_group_id == robotgroupid) { strgroupname = Data.Instance.robotgroup_list.robotgroup[i2].robot_group_name; break; } } } dataGridView_reg.Rows.Add(new string[] { task_status, task_id, task_name, task_missionlist, task_robotlist, taskloopflag, strgroupname }); } groupBox_jobitem.Visible = false; } catch (Exception ex) { Console.WriteLine("TaskEdit_Ctrl ..onInitSet err" + ex.Message.ToString()); } }
private void onTaskSave() { try { Task_Info task = new Task_Info(); string strjobid = txtTaskID.Text.ToString(); task.task_id = strjobid; if (txtTaskName.Text == "") { MessageBox.Show("작업명을 입력하세요."); return; } string strjobname = txtTaskName.Text.ToString(); task.task_name = strjobname; if (cboRobotGroup.SelectedIndex < 0) { MessageBox.Show("로봇그룹을 선택하세요."); return; } if (listBox_selectedrobotlist.Items.Count < 0) { MessageBox.Show("로봇을 선택하세요."); return; } if (listBox_selectedmissionlist.Items.Count < 0) { MessageBox.Show("미션을 선택하세요."); return; } string strrobotgroup = cboRobotGroup.SelectedItem.ToString(); string strmissionlist = ""; string strrobotlist = ""; string strgroupid = ""; if (strrobotgroup == "All") { strgroupid = "All"; } else { int cnt = Data.Instance.robotgroup_list.robotgroup.Count; for (int i = 0; i < cnt; i++) { if (Data.Instance.robotgroup_list.robotgroup[i].robot_group_name == strrobotgroup) { strgroupid = Data.Instance.robotgroup_list.robotgroup[i].robot_group_id; break; } } } for (int i = 0; i < listBox_selectedmissionlist.Items.Count; i++) { string strmissionlist2 = listBox_selectedmissionlist.Items[i].ToString(); int idx = strmissionlist2.IndexOf("("); int idx2 = strmissionlist2.IndexOf(")"); strmissionlist2 = strmissionlist2.Substring(idx + 1, idx2 - idx - 1); if (i < listBox_selectedmissionlist.Items.Count - 1) { strmissionlist += strmissionlist2 + ","; } else { strmissionlist += strmissionlist2; } } for (int i = 0; i < listBox_selectedrobotlist.Items.Count; i++) { string strrobotlist2 = listBox_selectedrobotlist.Items[i].ToString(); int idx = strrobotlist2.IndexOf("("); int idx2 = strrobotlist2.IndexOf(")"); strrobotlist2 = strrobotlist2.Substring(idx + 1, idx2 - idx - 1); if (i < listBox_selectedrobotlist.Items.Count - 1) { strrobotlist += strrobotlist2 + ","; } else { strrobotlist += strrobotlist2; } } task.mission_id_list = strmissionlist; task.robot_id_list = strrobotlist; task.task_status = "wait"; task.start_idx = "0"; task.taskloopflag = "1"; task.robot_group_id = strgroupid; mainform.dbBridge.onDBSave_Task(strTaskSavekind, task); //Thread.Sleep(1000); onInitSet(); groupBox_btn.Enabled = true; groupBox_jobitem.Visible = false; strTaskSavekind = ""; } catch (Exception ex) { Console.WriteLine("onTaskSave err" + ex.Message.ToString()); } }
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 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); } } }