コード例 #1
0
        private void WriteDataLog(object sender, ThirdPartInventoryArgs args)
        {
            if (args.ThirdPartInventoryList.Count == 0)
            {
                ThirdPartInventoryBPBase bp = sender as ThirdPartInventoryBPBase;
                if (bp != null)
                {
                    bp.Abort();
                    return;
                }
            }
            p++;
            WriteLog(string.Format("正在同步第{0}批数据,本批次数据量:{1}条……", p, args.ThirdPartInventoryList.Count), true);
            StringBuilder sb = new StringBuilder();

            sb.Append("ProductMappingSysno_ProductSysNo_AlamQty[");
            foreach (ThirdPartInventoryEntity entity in args.ThirdPartInventoryList)
            {
                sb.AppendFormat("{0}_{1}_{2} ", entity.ProductMappingSysno, entity.ProductSysNo, entity.InventoryAlamQty ?? Common.InventoryAlarmQty);
            }
            sb.Append("]\r\n");
            WriteLog(sb.ToString());
        }
コード例 #2
0
        private void WriteErrorLog(object sender, ThirdPartInventoryErrorArgs args)
        {
            ExceptionHelper.HandleException(args.Exception);
            string error = string.Format("{0} \r\n {1}", args.Exception.Message, args.Exception.StackTrace);
            List <ThirdPartInventoryEntity> list = args.ThirdPartInventoryList;
            XmlSerializer ser    = new XmlSerializer(typeof(List <ThirdPartInventoryEntity>));
            MemoryStream  stream = new MemoryStream();

            ser.Serialize(stream, list);
            string xmlString = Encoding.UTF8.GetString(stream.GetBuffer());

            stream.Dispose();
            WriteLog(string.Format("出错数据:\r\n{0}", xmlString));
            WriteLog(string.Format("{0}\r\n", error), true);
            if (Common.ThirdPartSynType == SynType.Queue)
            {
                ThirdPartInventoryBPBase bp = sender as ThirdPartInventoryBPBase;
                if (bp != null)
                {
                    bp.Abort();
                }
            }
        }