Ejemplo n.º 1
0
        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);
            }
        }