private void EndAllSend() { this.dtStart = DateTime.Now; if (this.isProcessing) { return; } this.tmrSend.Stop(); if (formCloudGroupSendingSingle.screenSendGroup != null) { for (int i = formCloudGroupSendingSingle.screenSendGroup.Count - 1; i > -1; i--) { Screen_Display_Class screen_Display_Class = formCloudGroupSendingSingle.screenSendGroup[i]; if (!screen_Display_Class.SendCompleted) { screen_Display_Class.SendCompleted = true; screen_Display_Class.State_Message = formMain.ML.GetStr("Prompt_CommFaileder"); this.StateColor = 2; this.dgvSendState.Rows[i].Cells[4].Value = screen_Display_Class.State_Message; this.dgvSendState.Rows[i].Cells[4].Style.ForeColor = this.StateOfColor(this.StateColor); } } } MessageBox.Show(this, formMain.ML.GetStr("Display_SendData") + formMain.ML.GetStr("Display_Completed") + "," + formMain.ML.GetStr("formGroupSending_CommunicationMessage_Partialdeliveryfailed")); this.btnResend.Enabled = true; this.needtoClose = true; this.isThread = false; }
private void Resend() { string[] array = new string[] { formMain.ML.GetStr("Prompt_MemoryOverSize"), formMain.ML.GetStr("formGroupSending_CommunicationMessage_FailedToGenerateData") }; int num = 0; while (num < formCloudGroupSending.screenSendGroup.Count && this.isThread) { Screen_Display_Class screen_Display_Class = formCloudGroupSending.screenSendGroup[num]; if (Array.IndexOf <string>(array, screen_Display_Class.State_Message) < 0 && screen_Display_Class.Send_Progress != 100) { screen_Display_Class.Send_Progress = 0; screen_Display_Class.ResendCount = 0; screen_Display_Class.SendCompleted = false; screen_Display_Class.Send_State = 0; Thread.Sleep(50); } num++; } base.Invoke(new MethodInvoker(delegate { if (this.isThread) { this.dtStart = DateTime.Now; this.tmrSend.Start(); } })); bool arg_AB_0 = this.isThread; }
private bool IsAllSendCompleted() { bool result = true; if (formCloudGroupSendingSingle.screenSendGroup != null) { int i; for (i = formCloudGroupSendingSingle.screenSendGroup.Count - 1; i > -1; i--) { Screen_Display_Class sdc = formCloudGroupSendingSingle.screenSendGroup[i]; DateTime now = DateTime.Now; if (!sdc.SendCompleted) { DateTime arg_80_0 = sdc.LastRecvTime; if ((now - sdc.LastRecvTime).TotalSeconds <= (double)this.RecvTimeout) { result = false; break; } this.failureCount++; string str = formMain.ML.GetStr("Display_CommunicationFailed"); this.StateColor = 2; sdc.Fault_Message = str; sdc.State_Message = str; sdc.SendCompleted = true; base.Invoke(new MethodInvoker(delegate { this.dgvSendState.Rows[i].Cells[4].Value = sdc.State_Message; this.dgvSendState.Rows[i].Cells[4].Style.ForeColor = this.StateOfColor(this.StateColor); })); } } } return(result); }
private void Resend() { string[] array = new string[] { formMain.ML.GetStr("Prompt_MemoryOverSize"), formMain.ML.GetStr("formGroupSending_CommunicationMessage_FailedToGenerateData") }; base.Invoke(new MethodInvoker(delegate { if (this.isThread) { this.dtStart = DateTime.Now; this.tmrSend.Start(); } })); if (!this.isThread) { return; } this.isThreadReceiveEvent = true; this.thrReceiveEvent = new Thread(new ThreadStart(this.ReceiveEvent)); this.thrReceiveEvent.IsBackground = true; this.thrReceiveEvent.Start(); for (int i = 0; i < formGroupSendingSingle.screenSendGroup.Count; i++) { if (!this.isThread) { return; } Screen_Display_Class screen_Display_Class = formGroupSendingSingle.screenSendGroup[i]; if (Array.IndexOf <string>(array, screen_Display_Class.State_Message) < 0 && screen_Display_Class.Send_Progress != 100) { screen_Display_Class.Send_Progress = 0; screen_Display_Class.ResendCount = 0; screen_Display_Class.SendCompleted = false; screen_Display_Class.Send_State = 0; ParameterizedThreadStart start = new ParameterizedThreadStart(this.SingleSend); Thread thread = new Thread(start); object parameter = i; thread.Start(parameter); this.thrCount++; Thread.Sleep(50); } } }
private bool IsAllSended(ref List <int> indexList) { bool result = true; if (formCloudGroupSendingSingle.screenSendGroup != null) { for (int i = 0; i < formCloudGroupSendingSingle.screenSendGroup.Count; i++) { Screen_Display_Class screen_Display_Class = formCloudGroupSendingSingle.screenSendGroup[i]; if (screen_Display_Class.Send_State != 3) { if (screen_Display_Class.Send_State == 1) { indexList.Add(i); } result = false; } } } return(result); }
private void SingleSend(object obj) { int num = (int)obj; if (num < 0) { this.thrCount--; return; } Screen_Display_Class sdc = formCloudGroupSendingSingle.screenSendGroup[num]; LedPanel panel_NO = sdc.Panel_NO; DataGridViewCell dgvcState = this.dgvSendState.Rows[num].Cells[4]; DataGridViewCell dgvcProgress = this.dgvSendState.Rows[num].Cells[5]; string empty = string.Empty; bool flag = false; for (int i = 0; i < LedCommunicationConst.ProtocolSendVersionList.Length; i++) { if (panel_NO.ProtocolVersion == LedCommunicationConst.ProtocolSendVersionList[i]) { flag = true; break; } } if (!flag) { sdc.Send_State = 3; sdc.SendCompleted = true; sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_protocolVersionNumberInconsistent"); this.StateColor = 2; base.Invoke(new MethodInvoker(delegate { dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); this.thrCount--; return; } sdc.State_Message = formMain.ML.GetStr("Prompt_NowIsGeneratingData"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvcProgress.Value = 0; dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); dgvcState.ToolTipText = string.Empty; this.dgvSendState.Refresh(); })); Thread.Sleep(800); IList <byte[]> list = protocol_single_cmd.Send_Pack(0, 0, this.command, this.commData, false, null, "", panel_NO.ProtocolVersion); if (list == null || list.Count == 0) { sdc.Send_State = 3; sdc.SendCompleted = true; sdc.State_Message = formMain.ML.GetStr("Message_Generate_Data_Failed"); this.StateColor = 2; base.Invoke(new MethodInvoker(delegate { dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); this.thrCount--; return; } sdc.State_Message = formMain.ML.GetStr("Message_Generate_Data_Complete"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvcProgress.Value = 100; dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); dgvcState.ToolTipText = string.Empty; this.dgvSendState.Refresh(); })); Thread.Sleep(800); sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_StartSending"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvcProgress.Value = 0; dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); dgvcState.ToolTipText = string.Empty; this.dgvSendState.Refresh(); })); Thread.Sleep(800); int j = 0; bool flag2 = false; while (j < 5) { j++; empty = string.Empty; bool flag3 = new SingleCommandService().Send(LedGlobal.CloudAccount.SessionID, panel_NO.CloudID, list[0], this.operation, ref empty); if (flag3) { flag2 = true; break; } } if (!flag2) { this.failureCount++; sdc.Send_State = 3; sdc.SendCompleted = true; sdc.State_Message = formMain.ML.GetStr("Display_CommunicationFailed"); this.StateColor = 2; } else { bool flag4 = panel_NO.State != LedPanelState.Online || this.GetResponse(panel_NO, empty); if (flag4) { sdc.Send_State = 3; sdc.SendCompleted = true; sdc.State_Message = this.Text.Replace(formMain.ML.GetStr("formMain_Menu_Group"), "") + formMain.ML.GetStr("Display_Successed"); this.StateColor = 1; dgvcProgress.Value = 100; } else { this.failureCount++; sdc.Send_State = 3; sdc.SendCompleted = true; sdc.State_Message = formMain.ML.GetStr("Display_CommunicationFailed"); this.StateColor = 2; } } base.Invoke(new MethodInvoker(delegate { dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); this.thrCount--; }
private void button_Sure_Click(object sender, EventArgs e) { try { int num = 0; int num2 = 0; bool flag = false; bool flag2 = false; if (this.isCloud) { if (this.isSingleCommand) { if (formCloudGroupSendingSingle.screenSendGroup == null) { formCloudGroupSendingSingle.screenSendGroup = new List <Screen_Display_Class>(); } formCloudGroupSendingSingle.screenSendGroup.Clear(); } else { if (formCloudGroupSending.screenSendGroup == null) { formCloudGroupSending.screenSendGroup = new List <Screen_Display_Class>(); } formCloudGroupSending.screenSendGroup.Clear(); } } else if (this.isSingleCommand) { if (formGroupSendingSingle.screenSendGroup == null) { formGroupSendingSingle.screenSendGroup = new List <Screen_Display_Class>(); } formGroupSendingSingle.screenSendGroup.Clear(); } else { if (formGroupSending.screen_send_group == null) { formGroupSending.screen_send_group = new List <Screen_Display_Class>(); } formGroupSending.screen_send_group.Clear(); } foreach (TreeNode treeNode in this.tvwPanel.Nodes) { if (treeNode.Nodes != null) { foreach (TreeNode treeNode2 in treeNode.Nodes) { if (treeNode2 != null && treeNode2.Checked && (treeNode2.Tag.GetType() == typeof(LedPanel) || treeNode2.Tag.GetType() == typeof(LedPanelCloud))) { LedPanel ledPanel = (LedPanel)treeNode2.Tag; Screen_Display_Class screen_Display_Class = new Screen_Display_Class(); num = (screen_Display_Class.Screen_Num = num + 1); screen_Display_Class.Panel_NO = ledPanel; screen_Display_Class.Send_Progress = 0; screen_Display_Class.State_Message = formMain.ML.GetStr("formPanelSelectForGroupSending_message_ReadyToStart"); if (ledPanel.PortType == LedPortType.Ethernet && ledPanel.EthernetCommunicaitonMode == LedEthernetCommunicationMode.Directly) { flag = true; } if (this.isCloud) { if (this.isSingleCommand) { formCloudGroupSendingSingle.screenSendGroup.Add(screen_Display_Class); if (ledPanel.State == LedPanelState.Offline) { flag2 = true; } } else { screen_Display_Class.Send_State = 1; formCloudGroupSending.screenSendGroup.Add(screen_Display_Class); } } else if (this.isSingleCommand) { formGroupSendingSingle.screenSendGroup.Add(screen_Display_Class); } else { formGroupSending.screen_send_group.Add(screen_Display_Class); } num2++; } } } } if (num2 == 0) { MessageBox.Show(this, formMain.ML.GetStr("Message_Please_Select_One_Panel_At_Least")); } else if (!flag || MessageBox.Show(this, formMain.ML.GetStr("NETCARD_message_Prompt_Send_SingleCard"), formMain.ML.GetStr("NETCARD_message_prompt"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { if (!flag2 || MessageBox.Show(this, formMain.ML.GetStr("Message_Selected_Terminal_Is_Offline_And_Continue_Sending_May_Not_Send_To_Terminal"), formMain.ML.GetStr("NETCARD_message_prompt"), MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation) == DialogResult.OK) { base.DialogResult = DialogResult.OK; base.Close(); } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private void SendData(int index) { if (index < 0) { return; } Screen_Display_Class sdc = formCloudGroupSending.screenSendGroup[index]; LedPanel panel_NO = sdc.Panel_NO; new DataOperating(); DataGridViewCell dgvc = this.dgvSendState.Rows[index].Cells[4]; DataGridViewCell dgvcProgress = this.dgvSendState.Rows[index].Cells[5]; sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_ReadyToSend"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvc.Value = sdc.State_Message; dgvc.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); bool flag = false; if (sdc.Send_Data != null) { if (sdc.Send_Data.GetBytesLength() > panel_NO.GetFlashCapacity() && !formMain.IsforeignTradeMode) { sdc.Fault_Message = formMain.ML.GetStr("Prompt_MemoryOverSize"); sdc.State_Message = formMain.ML.GetStr("Prompt_MemoryOverSize"); this.StateColor = 2; sdc.SendCompleted = true; base.Invoke(new MethodInvoker(delegate { dgvc.Value = sdc.State_Message; dgvc.Style.ForeColor = this.StateOfColor(this.StateColor); })); return; } flag = true; } if (flag) { sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_StartSending"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvc.Value = sdc.State_Message; dgvc.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); IList <byte[]> list = new protocol_data_integration().Program_Packaging_data_L(sdc.Send_Data, panel_NO.CardAddress, panel_NO.ProtocolVersion, true); if (list == null || list.Count == 0) { this.failureCount++; string str = formMain.ML.GetStr("Display_CommunicationFailed"); this.StateColor = 2; sdc.Fault_Message = str; sdc.State_Message = str; sdc.SendCompleted = true; } else { int i = 0; bool flag2 = false; bool flag3 = false; sdc.State_Message = formMain.ML.GetStr("Prompt_NowIsSendingData"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvc.Value = sdc.State_Message; dgvc.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); string dataFilePath = string.Format("{0}\\Cloud\\{1}\\{2}", LedCommonConst.ProjectSaveDirectory, LedGlobal.CloudAccount.UserName, panel_NO.ID); while (i < 5) { i++; flag2 = new TransDataService().Send(LedGlobal.CloudAccount.SessionID, panel_NO.CloudID, list, dataFilePath, formMain.ML.GetStr("Message_Send_Item_Data"), ref flag3); if (flag2) { break; } } if (!flag2) { this.failureCount++; string str2 = formMain.ML.GetStr("Display_CommunicationFailed"); this.StateColor = 2; sdc.Fault_Message = str2; sdc.State_Message = str2; sdc.SendCompleted = true; } else { sdc.State_Message = formMain.ML.GetStr("Message_Upload_To_Cloud_Success"); if (flag3) { Screen_Display_Class expr_366 = sdc; expr_366.State_Message = expr_366.State_Message + "," + formMain.ML.GetStr("Message_Send_Complete_By_Reviewing"); } sdc.SendCompleted = true; this.StateColor = 1; if (sdc.Send_Data != null) { sdc.Send_Data.Dispose(); sdc.Send_Data = null; } } } base.Invoke(new MethodInvoker(delegate { if (this.StateColor == 1) { dgvcProgress.Value = 100; } dgvc.Value = sdc.State_Message; dgvc.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); } }
private void SingleSend(object obj) { int index = (int)obj; Screen_Display_Class sdc = formCloudGroupSending.screenSendGroup[index]; sdc.Send_State = 2; bool bFlg = false; if (sdc.Send_Data == null) { LedPanel panel = sdc.Panel_NO; Process process = new Process(); DataOperating dataOpt = new DataOperating(); string toolTip = string.Empty; bFlg = dataOpt.CheckData(panel); if (bFlg) { bFlg = dataOpt.CheckAnimationAndBackground(panel); if (bFlg) { lock (this.thisLock) { this.isProcessing = true; base.Invoke(new MethodInvoker(delegate { bFlg = dataOpt.GenerateData(panel, ref process); this.isProcessing = false; })); DateTime now = DateTime.Now; DateTime now2 = DateTime.Now; TimeSpan timeSpan = now2 - now; while (this.isProcessing && timeSpan.TotalSeconds < 120.0) { Thread.Sleep(1000); now2 = DateTime.Now; timeSpan = now2 - now; } goto IL_1BC; } } lock (this.thisLock) { bFlg = dataOpt.GenerateData(panel, ref process); } IL_1BC: if (bFlg) { sdc.Send_Data = process; sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_GenerateDataSuccessfully"); this.StateColor = 1; } } if (!bFlg) { this.generateDataErrorCount++; sdc.Send_State = 3; sdc.SendCompleted = true; if (sdc.Send_Data != null) { sdc.Send_Data.Dispose(); sdc.Send_Data = null; } sdc.Fault_Message = dataOpt.faultMessage; sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_FailedToGenerateData"); this.StateColor = 2; toolTip = dataOpt.faultMessage; } base.Invoke(new MethodInvoker(delegate { DataGridViewCell dataGridViewCell = this.dgvSendState.Rows[index].Cells[4]; dataGridViewCell.Value = sdc.State_Message; dataGridViewCell.ToolTipText = toolTip; dataGridViewCell.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); } else { bFlg = true; } if (bFlg) { this.SendData(index); sdc.Send_State = 3; } this.thrCount--; }
private void SingleSend(object obj) { int num = (int)obj; if (num < 0) { this.thrCount--; return; } Screen_Display_Class sdc = formGroupSendingSingle.screenSendGroup[num]; LedPanel panel_NO = sdc.Panel_NO; DataGridViewCell dgvcState = this.dgvSendState.Rows[num].Cells[4]; DataGridViewCell dgvcProgress = this.dgvSendState.Rows[num].Cells[5]; bool flag = false; for (int i = 0; i < LedCommunicationConst.ProtocolSendVersionList.Length; i++) { if (panel_NO.ProtocolVersion == LedCommunicationConst.ProtocolSendVersionList[i]) { flag = true; break; } } if (!flag) { sdc.Send_State = 3; sdc.SendCompleted = true; sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_protocolVersionNumberInconsistent"); this.StateColor = 2; base.Invoke(new MethodInvoker(delegate { dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); this.thrCount--; return; } if (sdc.ResendCount == 0) { sdc.State_Message = formMain.ML.GetStr("formGroupSending_CommunicationMessage_StartSending"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvcProgress.Value = 0; dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); dgvcState.ToolTipText = string.Empty; this.dgvSendState.Refresh(); })); Thread.Sleep(800); } int j = 0; bool flag2 = false; while (j < 5) { j++; SEND_CMD_RET_VALUE sEND_CMD_RET_VALUE = SEND_CMD_RET_VALUE.ER_NONE_INIT; if (formMain.IServer != null) { sEND_CMD_RET_VALUE = formMain.IServer.send_cmd_to_device_async((byte)this.command, this.commData, panel_NO.ProductID); } if (sEND_CMD_RET_VALUE == SEND_CMD_RET_VALUE.POST_TO_RS_SERVER_OK) { flag2 = true; break; } if (sEND_CMD_RET_VALUE != SEND_CMD_RET_VALUE.IPC_communication_FAILED || sEND_CMD_RET_VALUE != SEND_CMD_RET_VALUE.IPC_communication_FAILED) { break; } if (!this.isRestarting) { this.RestartIPCServer(); } DateTime now = DateTime.Now; DateTime now2 = DateTime.Now; TimeSpan timeSpan = now2 - now; while (this.isRestarting) { if (timeSpan.TotalSeconds >= 120.0) { break; } Thread.Sleep(200); now2 = DateTime.Now; timeSpan = now2 - now; } } if (!flag2) { this.failureCount++; sdc.Send_State = 3; sdc.SendCompleted = true; sdc.State_Message = formMain.ML.GetStr("Display_CommunicationFailed"); this.StateColor = 2; base.Invoke(new MethodInvoker(delegate { dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); } else { sdc.State_Message = formMain.ML.GetStr("Prompt_NowIsSendingData"); this.StateColor = 0; base.Invoke(new MethodInvoker(delegate { dgvcState.Value = sdc.State_Message; dgvcState.Style.ForeColor = this.StateOfColor(this.StateColor); })); Thread.Sleep(500); } this.thrCount--; }