Пример #1
0
 private static NaccsData createInstanceFromByteArray(byte[] byteArray, Encoding encoding)
 {
     if ((byteArray == null) || (byteArray.Length < 400))
     {
         return null;
     }
     NaccsData data = new NaccsData();
     data.NaccsHeader.SetBytesData(byteArray, encoding, true);
     if (data.Header.Length > 400)
     {
         int length = data.Header.Length;
         if (length > byteArray.Length)
         {
             length = byteArray.Length;
         }
         length -= 400;
         data.JobData = NaccsHeader.ByteDataToString(byteArray, 400, length, encoding);
         return data;
     }
     if (data.Header.Length == 0)
     {
         data.JobData = NaccsHeader.ByteDataToString(byteArray, 400, byteArray.Length - 400, encoding);
     }
     return data;
 }
Пример #2
0
 public IData CreateLinkData()
 {
     IData data = null;
     try
     {
         if (!this.IsLinkData())
         {
             return data;
         }
         XmlDocument document = new XmlDocument();
         document.Load(this.LinkFile);
         XmlElement element = (XmlElement) document.SelectSingleNode("link/destination");
         if (element == null)
         {
             return data;
         }
         data = new NaccsData {
             Header = { JobCode = element.GetAttribute("jobcode"), DispCode = element.GetAttribute("displaycode") }
         };
         foreach (XmlElement element2 in element.ChildNodes)
         {
             int num;
             if (int.TryParse(element2.GetAttribute("from"), out num))
             {
                 if (num < this.mRecvData.ResultData.Items.Count)
                 {
                     data.Items.Add(this.mRecvData.ResultData.Items[num]);
                 }
                 else
                 {
                     data.Items.Add("");
                 }
             }
             else
             {
                 data.Items.Add("");
             }
         }
     }
     catch
     {
         data = null;
     }
     return data;
 }
Пример #3
0
 protected IData ExecGetLinkData(XmlElement linkDst)
 {
     CommonJobPanel commonJobPanel = this.GetCommonJobPanel();
     if (commonJobPanel == null)
     {
         return null;
     }
     IData data = new NaccsData();
     int page = 0;
     string rep = null;
     commonJobPanel.GetRepPage(out rep, out page);
     data.Header.JobCode = linkDst.GetAttribute("jobcode");
     data.Header.DispCode = linkDst.GetAttribute("displaycode");
     for (int i = 0; i < linkDst.ChildNodes.Count; i++)
     {
         XmlElement element = (XmlElement) linkDst.ChildNodes[i];
         string attribute = element.GetAttribute("from");
         string str3 = element.GetAttribute("from_source");
         string item = null;
         if (!Naccs.Common.Generator.ItemInfo.tblComName.Equals(str3))
         {
             if (!string.Equals(str3, rep))
             {
                 using (MessageDialog dialog = new MessageDialog())
                 {
                     dialog.ShowMessage("W501", "");
                 }
                 return null;
             }
             item = this.GetIdData(str3, attribute, page);
         }
         else
         {
             item = this.GetIdData(str3, attribute, 0);
         }
         data.Items.Add(item);
     }
     return data;
 }
Пример #4
0
 private IData MakePrtExNaccsData()
 {
     int activePanel = this.GetActivePanel();
     if (activePanel == -1)
     {
         activePanel = 0;
     }
     IData data = new NaccsData {
         JobData = this.JPList[activePanel].JP.GetData(Naccs.Common.Generator.ItemInfo.JobDataStatus.jdNone)
     };
     data.Header.JobCode = this.JPList[activePanel].JCode;
     data.Header.DispCode = this.JPList[activePanel].DCode;
     if ((!string.IsNullOrEmpty(base.ExNaccsData.Header.OutCode.Trim()) && !this.JPList[activePanel].Code.Contains(".")) && (this.JPList[activePanel].Code.Length == 7))
     {
         data.Header.OutCode = this.JPList[activePanel].Code;
     }
     data.Header.InputInfo = base.txtInputInfo.Text;
     data.Header.IndexInfo = base.ExNaccsData.Header.IndexInfo;
     return data;
 }
Пример #5
0
 protected override IData MakeExNaccsData(Naccs.Common.Generator.ItemInfo.JobDataStatus jds)
 {
     if (jds == Naccs.Common.Generator.ItemInfo.JobDataStatus.jdNone)
     {
         return this.MakePrtExNaccsData();
     }
     NaccsData data = new NaccsData {
         Style = JobStyle.combi
     };
     for (int i = 0; i < this.JPList.Count; i++)
     {
         data.JobIndex = i;
         data.SetSubJobData(this.JPList[i].JP.Items.GetDataList(jds), this.JPList[i].JCode);
     }
     CombiConfig jobConfig = (CombiConfig) base.JobConfig;
     if (base.JobConfig.jobStyle == JobStyle.combi)
     {
         data.Header.JobCode = jobConfig.jobcode;
         data.Header.DispCode = jobConfig.dispcode;
     }
     data.Header.System = jobConfig.system.ToString();
     data.Header.InputInfo = base.txtInputInfo.Text;
     data.Header.IndexInfo = base.ExNaccsData.Header.IndexInfo;
     if (jds == Naccs.Common.Generator.ItemInfo.JobDataStatus.jdSend)
     {
         for (int j = 0; j < this.JPList.Count; j++)
         {
             for (int k = 0; k < this.JPList[j].AuCtrlInfoList.Count; k++)
             {
                 List<string> idData = this.JPList[j].JP.Items.GetIdData(this.JPList[j].AuCtrlInfoList[k].ID);
                 for (int m = 0; m < idData.Count; m++)
                 {
                     string str = idData[m].Trim();
                     if (!string.IsNullOrEmpty(str) && !this.JPList[j].AuCtrlInfoList[k].AuList.Contains(str))
                     {
                         this.JPList[j].AuCtrlInfoList[k].AuList.Add(str);
                     }
                 }
             }
             this.SaveHistoryFile(this.JPList[j].HistoryFile, j);
         }
     }
     return data;
 }
Пример #6
0
 protected override IData MakeExNaccsData(Naccs.Common.Generator.ItemInfo.JobDataStatus jds)
 {
     IData data = new NaccsData {
         JobData = this.JP.GetData(jds)
     };
     NormalConfig jobConfig = (NormalConfig) base.JobConfig;
     if (base.JobConfig.jobStyle == JobStyle.normal)
     {
         data.Header.JobCode = jobConfig.record.jobcode;
         data.Header.DispCode = jobConfig.record.dispcode;
     }
     if (jds == Naccs.Common.Generator.ItemInfo.JobDataStatus.jdNone)
     {
         data.Header.OutCode = base.ExNaccsData.Header.OutCode;
     }
     data.Header.System = jobConfig.system.ToString();
     data.Header.InputInfo = base.txtInputInfo.Text;
     data.Header.IndexInfo = base.ExNaccsData.Header.IndexInfo;
     if (jds == Naccs.Common.Generator.ItemInfo.JobDataStatus.jdSend)
     {
         for (int i = 0; i < this.AuCtrlList.Count; i++)
         {
             Naccs.Common.CustomControls.IAutoComplete complete = (Naccs.Common.CustomControls.IAutoComplete) this.AuCtrlList[i];
             string str = complete.Text.Trim();
             if (!string.IsNullOrEmpty(str) && !complete.AutoCompleteCustomSource.Contains(str))
             {
                 complete.AutoCompleteCustomSource.Add(str);
             }
         }
     }
     this.SaveHistoryFile(this.stHistoryFile);
     return data;
 }
Пример #7
0
        public IData GetDivData(string DataInf, int Flag, string JCode, string OCode)
        {
            DataRow[] rowArray = this.dtsDataView.Tables["NACCS"].Select("clStatus = 'r' AND clDataInfo = '" + DataInf + "'");
            for (int i = 0; i < rowArray.Length; i++)
            {
                if ((OCode == "") || rowArray[i]["clOutCode"].ToString().Trim().StartsWith(OCode))
                {
                    switch (Flag)
                    {
                        case 0:
                            if (!(rowArray[i]["clSyu"].ToString() == "R"))
                            {
                                break;
                            }
                            return this.GetData(int.Parse(rowArray[i]["clID"].ToString()));

                        case 1:
                            if (!(rowArray[i]["clSyu"].ToString() == "C"))
                            {
                                break;
                            }
                            return this.GetData(int.Parse(rowArray[i]["clID"].ToString()));
                    }
                }
            }
            if (Flag == 1)
            {
                rowArray = this.dtsDataView.Tables["NACCS"].Select("clStatus = 'a' AND clDataInfo = '" + DataInf + "'");
                if (rowArray.Length > 0)
                {
                    string str = JCode;
                    string str2 = "";
                    if (str.IndexOf('.') > -1)
                    {
                        str2 = str;
                        str = str.Remove(str.IndexOf('.'));
                        str2 = str2.Remove(0, str2.IndexOf('.') + 1);
                    }
                    if (JCode == "")
                    {
                        return this.GetData(int.Parse(rowArray[0]["clID"].ToString()));
                    }
                    IData data = new NaccsData();
                    IData data2 = this.GetData(int.Parse(rowArray[0]["clID"].ToString()));
                    data2.Style = JobStyle.combi;
                    if (data2.JobCode.Trim() == str)
                    {
                        return data2;
                    }
                    for (int j = 0; j < data2.JobCount; j++)
                    {
                        data2.JobIndex = j;
                        if (data2.SubCode.Trim() == str)
                        {
                            data.Header.JobCode = str;
                            data.Header.DispCode = str2;
                            data.Header.InputInfo = data2.Header.InputInfo;
                            StringBuilder builder = new StringBuilder();
                            for (int k = 0; k < data2.SubItems.Count; k++)
                            {
                                builder.Append(data2.SubItems[k]).Append(Environment.NewLine);
                            }
                            string str3 = builder.ToString();
                            if (str3.LastIndexOf(Environment.NewLine) > 0)
                            {
                                str3 = str3.Remove(str3.LastIndexOf(Environment.NewLine));
                            }
                            data.JobData = str3;
                            return data;
                        }
                    }
                }
            }
            return null;
        }
Пример #8
0
 private string CreateRequestData(RequestCommand command, string outcode)
 {
     string str2;
     this.mSendCount = 0;
     string str = this.JobCode();
     IData data = new NaccsData {
         Header = { Control = DataControl.GetControl(), JobCode = str, UserId = this.mUser, Password = this.mPass, Path = this.mTermLogicalName, DataInfo = string.Format("{0}{1}{2:D6}", str, this.DateTimeString(), this.mSendCount) }
     };
     if (command == RequestCommand.GET)
     {
         str2 = outcode;
     }
     else
     {
         str2 = command.ToString();
     }
     string str3 = string.Format("{0}{1}", str2.PadRight(7, ' '), "\r\n");
     data.JobData = str3;
     this.mFirstRequest = data;
     return data.GetDataString();
 }
Пример #9
0
        public IData CreateRequestData()
        {
            string mTermLogicalName = st.fTerminalID;
            string mTermAccessKey = st.fTerminalAccessKey;
            string mUser = st.fUserIDVNACCS;
            string mPass = st.fPasswordVNACCS;
            int mSendCount = 0;
            string str = this.jobCode;

            mTermLogicalName = mTermLogicalName.PadRight(6, ' ');
            mTermAccessKey = mTermAccessKey.PadRight(0x10, ' ');
            IData data = new NaccsData
            {
                Header =
                {
                    Control = DataControl.GetControl(),
                    JobCode = str,
                    UserId = mUser,
                    Password = mPass,
                    Path = mTermLogicalName,
                    DataInfo = string.Format("{0}{1}{2:D6}", str.PadRight(5, ' '), this.DateTimeString(), mSendCount)
                }
            };


            bool mLogon = false;//mLogon để chỉ ra rằng header này dùng để logon chứ ko phải là header của của nghiệp vụ khác
            if (mLogon)
            {
                data.Header.SendGuard = "*";
            }


            Naccs.Core.Job.JobPanel JP = new Naccs.Core.Job.JobPanel();
            JP.CreatePanel(this.strDisplayFile);
            //JP.Items.DsItems.Tables[0].Rows[0][ICN.ID] = ICN.Text;
            //JP.Items.DsItems.Tables[0].Rows[0][HAB.ID] = HAB.Text;
            //JP.Items.DsItems.Tables[0].Rows[0][BLN.ID] = BLN.Text;
            //JP.Items.DsItems.Tables[0].Rows[0][IVU.ID] = IVU.Text;
            foreach (Control c in this.CONTENT.Controls)
            {
                if (c is TextBoxX)
                {
                    TextBoxX txt = c as TextBoxX;
                    JP.Items.DsItems.Tables[0].Rows[0][txt.Name] = txt.Text;
                }
            }
            string strJobData = JP.GetData(Naccs.Common.Generator.ItemInfo.JobDataStatus.jdSend);
            data.JobData = strJobData;

            return data;
        }
Пример #10
0
 private void CallbackOnGetReceived(object sender, string sendkey, ComParameter recvdata)
 {
     bool flag = false;
     bool flag2 = false;
     if (recvdata.DataString.Length < 400)
     {
         ULogClass.LogWrite(string.Format("{0}_RECV", this.JobCode()), recvdata.DataString, false);
         this.mTurnRtpinfo = "";
         this.mNextStop = false;
     }
     else
     {
         IData data = new NaccsData {
             Header = { DataString = recvdata.DataString.Substring(0, 400) }
         };
         this.mTurnRtpinfo = data.Header.RtpInfo;
         flag2 = data.Header.Control.EndsWith("P");
         flag = !flag2 && (data.Header.DataType == "R");
     }
     Stopwatch stopwatch = new Stopwatch();
     try
     {
         stopwatch.Start();
         this.mRecvOK = this.OnReceived(recvdata);
         stopwatch.Stop();
         if (flag2)
         {
             if (this.mRecvOK)
             {
                 if ((this.mA2Timeout == 0) || (stopwatch.ElapsedMilliseconds < ((this.mA2Timeout - this.mA2Delay) * 0x3e8)))
                 {
                     this.mA2tm = new System.Windows.Forms.Timer();
                     this.mA2tm.Tick += new EventHandler(this.A2Send_Tick);
                     this.mA2tm.Interval = 1;
                     if (this.mA2Delay > 0)
                     {
                         this.mA2tm.Interval = this.mA2Delay * 0x3e8;
                     }
                     this.mA2tm.Enabled = true;
                 }
                 else
                 {
                     flag2 = false;
                     ComParameter parameter = new ComParameter {
                         DataString = "A2Timeout"
                     };
                     this.OnReceived(parameter);
                     new MessageDialog().ShowMessage("E121", null);
                 }
             }
             else
             {
                 flag2 = false;
                 this.mNextStop = false;
             }
         }
         else if (flag)
         {
             flag2 = false;
             this.mNextStop = false;
             RecvData data2 = DataFactory.CreateRecvData(recvdata.DataString);
             HttpErrorDlg dlg = new HttpErrorDlg();
             dlg.ShowJobError(this.JobCode(), data2.ResultData);
             dlg.Dispose();
         }
     }
     finally
     {
         stopwatch.Reset();
         this.mIsExcute = flag2;
         this.ButtonLock(false);
     }
 }
Пример #11
0
 public static void LoadFromEdiFile(string fileName, IData data)
 {
     byte[] bytes = null;
     using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read))
     {
         using (StreamReader reader = new StreamReader(stream, FileEncoding))
         {
             string s = reader.ReadToEnd();
             bytes = FileEncoding.GetBytes(s);
         }
     }
     if (FileEncoding.GetString(bytes).IndexOf(Environment.NewLine) != 0x18e)
     {
         throw new Exception(Resources.ResourceManager.GetString("CORE72"));
     }
     NaccsData data2 = data as NaccsData;
     if (data2 == null)
     {
         data2 = new NaccsData();
     }
     (data2.Header as NaccsHeader).SetBytesData(bytes, FileEncoding, true);
     data2.JobData = NaccsHeader.ByteDataToString(bytes, 400, bytes.Length - 400, FileEncoding);
 }
Пример #12
0
 public static IData LoadFromEdiFile(string fileName)
 {
     NaccsData data = new NaccsData();
     LoadFromEdiFile(fileName, data);
     return data;
 }
Пример #13
0
 private string CreateRequestData()
 {
     string mTermLogicalName;
     string mTermAccessKey;
     this.mSendCount = 0;
     string str = this.JobCode();
     if (this.mIsTTM)
     {
         mTermLogicalName = this.txTerminal.Text.Trim();
         mTermAccessKey = this.txAccessKey.Text.Trim();
     }
     else
     {
         mTermLogicalName = this.mTermLogicalName;
         mTermAccessKey = this.mTermAccessKey;
     }
     mTermLogicalName = mTermLogicalName.PadRight(6, ' ');
     mTermAccessKey = mTermAccessKey.PadRight(0x10, ' ');
     IData data = new NaccsData {
         Header = { Control = DataControl.GetControl(), JobCode = str, UserId = this.mUser, Password = this.mPass, Path = this.mTermLogicalName, DataInfo = string.Format("{0}{1}{2:D6}", str.PadRight(5, ' '), this.DateTimeString(), this.mSendCount) }
     };
     if (this.mLogon)
     {
         data.Header.SendGuard = "*";
     }
     string str4 = "0";
     if (this.mIsExcuteMode != 0)
     {
         str4 = "1";
     }
     string str5 = string.Format("{0}{3}{1}{3}{2}{3}", new object[] { mTermLogicalName, mTermAccessKey, str4, "\r\n" });
     data.JobData = str5;
     this.mFirstRequest = data;
     return data.GetDataString();
 }
Пример #14
0
 private string CreateRequestData(RequestCommand command, string body)
 {
     IData data = new NaccsData {
         Header = { JobCode = "?" + command.ToString(), UserId = this.mUser, Password = this.mPass },
         JobData = body
     };
     return data.GetDataString();
 }
Пример #15
0
        private void XuLyTraVe(ComParameter recvdata)
        {
            bool flag = false;
            bool flag2 = false;
            if (recvdata.DataString.Length < 400)
            {
                if (recvdata.DataString.Equals("LOGON OK"))
                {
                    ////LOGON OK
                    //lblMSG.Text = string.Format("Đăng nhập thành công. Hệ thống thông báo: {0}", recvdata.DataString);
                    
                }
                else//case này Chưa xác định được nội dung là gì
                {
                    //lblMSG.Text = string.Format("Hệ thống thông báo: {0}", recvdata.DataString);
                    //ModalPopupExtender.Show();
                }
            }
            else
            {
                IData data = new NaccsData
                {
                    Header = { DataString = recvdata.DataString.Substring(0, 400) }
                };

                flag = data.Header.Control.EndsWith("P");
                flag2 = (!flag) && (data.Header.DataType == "R");
            }

            try
            {
                if (flag)
                {

                }
                else if (flag2)
                {
                    flag = false;

                    RecvData data2 = DataFactory.CreateRecvData(recvdata.DataString);
                    //HttpErrorDlg dlg = new HttpErrorDlg();
                    //dlg.ShowJobError(this.JobCode(), data2.ResultData);
                    IData resultData = data2.ResultData;
                    int length = 15;
                    if (resultData.Items[0].Length < 15)
                    {
                        length = resultData.Items[0].Length;
                    }
                    string resultCode = resultData.Items[0].Substring(0, length).ToUpper();
                    string jobCodeForReturn = this.jobCode;
                    string messageCode = resultCode.Substring(0, 5);

                    XmlDocument document = new XmlDocument();

                    if (messageCode.IndexOf('A') == 0)//Kiểu lỗi hệ thống thì sử dụng file help kiểu hệ thống
                    {
                        jobCodeForReturn = "SYS";
                        string strSysHelpFile = Path.Combine(Application.StartupPath, string.Format(@"App_LocalResources\Help\gym_err\{0}_err.xml", jobCodeForReturn));
                        document.Load(strSysHelpFile);
                    }
                    else
                    {
                        document.Load(strHelpFile);
                    }                   
                    
                    XmlNode node = document.SelectSingleNode("//response[@code='" + messageCode + "']");

                    string strName = node.Attributes["name"].Value;
                    string strID = node.Attributes["id"].Value;
                    //this.txbMessageCode.Text = messageCode;
                    string strDesc = node.SelectSingleNode("description").InnerText;
                    
                    string strDisposition = node.SelectSingleNode("disposition").InnerText;//cách khắc phục


                    #region Lưu thông điệp trả về
                    THONGDIEP receiveTD = new THONGDIEP();
                    receiveTD.TD_CACHKHACPHUC = strDisposition;
                    receiveTD.TD_COKETTHUC = resultData.Header.EndFlag.Trim();
                    receiveTD.TD_DINHDANG = resultData.Header.Pattern.Trim();
                    receiveTD.TD_LOAITD = resultData.Header.DataType.Trim();
                    receiveTD.TD_MANV = resultData.JobCode.Trim();
                    receiveTD.TD_MATD = resultData.OutCode.Trim();
                    receiveTD.TD_MESSSAGECODE = messageCode;
                    receiveTD.TD_MOTALOI = strDesc;
                    receiveTD.TD_RETURNCODE = resultCode;
                    receiveTD.TD_TENCHITIEU = strName;
                    receiveTD.TD_TENNV = this.jobTitle;
                    receiveTD.TD_THOIGIAN = DateTime.Now;
                    if (((resultData.Header.DataType == "R") || (resultData.Header.DataType == "M")) || (resultData.Header.DataType == "U"))
                    {
                        receiveTD.TD_TIEUDE = resultData.Header.Subject.Remove(0, 0x10).Trim();
                    }
                    else
                    {
                        receiveTD.TD_TIEUDE = resultData.Header.Subject.Trim();
                    }                   
                    receiveTD.TD_TRANGTHAI = (int)TrangThaiThongDiep.Nhan;
                    receiveTD.TD_CONTENT = recvdata.DataString;
                    using (tDBContext mainDB = new tDBContext())
                    {
                        string strMaxID = mainDB.THONGDIEPs.Max("TD_ID");
                        if(string.IsNullOrEmpty(strMaxID))strMaxID="0";
                        receiveTD.TD_ID = Convert.ToInt32(strMaxID) + 1;
                        mainDB.THONGDIEPs.InsertOnSubmit(receiveTD);
                        mainDB.SubmitAllChange();
                    }
                    #endregion
                    
                    this.Show1(strDesc, strDisposition);
                }
            }
            finally
            {

            }
        }
Пример #16
0
 protected override IData MakeExNaccsData(Naccs.Common.Generator.ItemInfo.JobDataStatus jds)
 {
     IData data = new NaccsData {
         JobData = this.Items.GetDataList(jds)
     };
     DivideConfig jobConfig = (DivideConfig) base.JobConfig;
     if (base.JobConfig.jobStyle == JobStyle.divide)
     {
         data.Header.JobCode = jobConfig.record.jobcode;
         data.Header.DispCode = jobConfig.record.dispcode;
     }
     if (jds == Naccs.Common.Generator.ItemInfo.JobDataStatus.jdNone)
     {
         data.Header.OutCode = base.ExNaccsData.Header.OutCode;
     }
     data.Header.System = jobConfig.system.ToString();
     data.Header.InputInfo = base.txtInputInfo.Text;
     data.Header.IndexInfo = base.ExNaccsData.Header.IndexInfo;
     if (jds == Naccs.Common.Generator.ItemInfo.JobDataStatus.jdSend)
     {
         for (int i = 0; i < this.AuCtrlInfoList.Count; i++)
         {
             List<string> idData = this.Items.GetIdData(this.AuCtrlInfoList[i].ID);
             for (int j = 0; j < idData.Count; j++)
             {
                 string str = idData[j].Trim();
                 if (!string.IsNullOrEmpty(str) && !this.AuCtrlInfoList[i].AuList.Contains(str))
                 {
                     this.AuCtrlInfoList[i].AuList.Add(str);
                 }
             }
         }
     }
     this.SaveHistoryFile(this.stHistoryFile);
     return data;
 }
Пример #17
0
 private string CreateA2Data()
 {
     this.mSendCount++;
     IData data = new NaccsData();
     if (this.mRecvOK)
     {
         data.Header.JobCode = "?A2";
     }
     else
     {
         data.Header.JobCode = "?A3";
     }
     data.Header.Control = this.mFirstRequest.Header.Control;
     data.Header.UserId = this.mFirstRequest.Header.UserId;
     data.Header.Password = this.mFirstRequest.Header.Password;
     data.Header.Path = this.mFirstRequest.Header.Path;
     data.Header.DataInfo = string.Format("{0}{1}{2:D6}", data.Header.Path, this.DateTimeString(), this.mSendCount);
     data.Header.RtpInfo = this.mTurnRtpinfo;
     if (this.mNextStop)
     {
         data.Header.SendGuard = "*";
     }
     else
     {
         data.Header.SendGuard = " ";
     }
     return data.GetDataString();
 }