示例#1
0
 private void AddApplePoTbToDB(ApplePoTb applePoTb)
 {
     try
     {
         OleDbConnection con = applePoTbDao.Begin();
         applePoTbDao.AddApplePoTbItemDAO(con, applePoTb);
         applePoTbDao.Commit();
     }
     catch (Exception)
     {
         applePoTbDao.RollBack();
         throw;
     }
     finally
     {
         applePoTbDao.Close();
     }
 }
示例#2
0
        /// <summary>
        /// 将信息添加到数据库
        /// </summary>
        /// <param name="myItem"></param>
        /// <param name="attachmentsList"></param>
        private void AddMailToDB(Outlook.MailItem myItem, List <String> attachmentsList, string saveMailNamePath)
        {
            if (attachmentsList.Count > 0)
            {
                foreach (String attachFilePath in attachmentsList)
                {
                    HawbTb hawbTb = new HawbTb();

                    if (myItem.Subject != null)
                    {
                        hawbTb.MailSubject = myItem.Subject.Trim();//邮件主题
                    }


                    hawbTb.MailIncomeTime = Convert.ToDateTime(myItem.ReceivedTime.ToString("G"));


                    hawbTb.FilePath = saveMailNamePath;

                    string strFiles = File.ReadAllText(attachFilePath);

                    strFiles = strFiles.Replace("<k>", "").Replace("<BR>", "\n").Replace("&nbsp;", " ");

                    hawbTb.HAWBNo = Path.GetFileNameWithoutExtension(attachFilePath);


                    hawbTb.HAWBTitle = RegexHelper.GetGroupStrByReg(strFiles, @"<B>(.*?)</B>", 1);

                    hawbTb.AppleId = RegexHelper.GetGroupStrByReg(strFiles, @"APPLE ID :(.*?)</TD>", 1);

                    hawbTb.Shipper = RegexHelper.GetGroupStrByReg(strFiles, @"Shipper :(.*?)</TD>", 1);

                    hawbTb.SapPlantCode = RegexHelper.GetGroupStrByReg(strFiles, @"SAP Plant Code :(.*?)</TD>", 1);

                    hawbTb.Org = RegexHelper.GetGroupStrByReg(strFiles, @"ORG :(.*?)</TD>", 1);

                    hawbTb.Coc = RegexHelper.GetGroupStrByReg(strFiles, @"COC :(.*?)</TD>", 1);

                    hawbTb.Poe = RegexHelper.GetGroupStrByReg(strFiles, @"POE :(.*?)</TD>", 1);

                    hawbTb.TotalCtn = RegexHelper.GetGroupStrByReg(strFiles, @"Total CTN :(.*?)</TD>", 1);

                    hawbTb.TotalPlt = RegexHelper.GetGroupStrByReg(strFiles, @"Total PLT :(.*?)</TD>", 1);

                    hawbTb.TotalWeigth = RegexHelper.GetGroupStrByReg(strFiles, @"Total Weight (KG) :(.*?)</TD>", 1);

                    hawbTb.TotalVolumn = RegexHelper.GetGroupStrByReg(strFiles, @"Total Volume (CBM) :(.*?)</TD>", 1);

                    AddHawbTbToDB(hawbTb);

                    string tableMain = RegexHelper.GetFirstStrByRegex("<TABLE Border.+?</TABLE>", strFiles);

                    XmlDocument doc = new XmlDocument();
                    doc.LoadXml(tableMain);
                    XmlNodeList trs = doc.GetElementsByTagName("TR");

                    List <ApplePoTb> applePoTbLists = new List <ApplePoTb>();

                    for (int i = 1; i < trs.Count; i++)
                    {
                        ApplePoTb   applePoTb = new ApplePoTb();
                        XmlNodeList tds       = trs[i].ChildNodes;
                        applePoTb.ApplePo      = tds[0].InnerText.Trim();
                        applePoTb.ShipTo       = tds[1].InnerText.Trim();
                        applePoTb.Ctn          = tds[2].InnerText.Trim();
                        applePoTb.Plt          = tds[3].InnerText.Trim();
                        applePoTb.Weight       = tds[4].InnerText.Trim();
                        applePoTb.Volume       = tds[5].InnerText.Trim();
                        applePoTb.PNContained  = tds[6].InnerText.Trim();
                        applePoTb.CustomerPoid = tds[7].InnerText.Trim();

                        applePoTbLists.Add(applePoTb);
                    }

                    BathAddApplePoTbToDB(applePoTbLists);
                }
            }
            else
            {
                HawbTb hawbTb = new HawbTb();

                if (myItem.Subject != null)
                {
                    hawbTb.MailSubject = myItem.Subject.Trim();//邮件主题
                }



                hawbTb.MailIncomeTime = Convert.ToDateTime(myItem.ReceivedTime.ToString("G"));


                hawbTb.FilePath = saveMailNamePath;

                //将邮件记录添加到DB中
                AddHawbTbToDB(hawbTb);
            }
        }