Ejemplo n.º 1
0
 public void Run(JobContext context)
 {
     Console.WriteLine("库存监测job已启动。");
     try
     {
         Console.WriteLine("正在进行数据检测,请稍后……");
         BIZ            biz            = new BIZ();
         MailDataEntity mailDataEntity = new MailDataEntity();
         int            mappingCount   = biz.ThirdPartInventoryEntityList == null ? 0 : biz.ThirdPartInventoryEntityList.Count;
         int            taobaoCount    = biz.TaobaoProductList == null ? 0 : biz.TaobaoProductList.Count;
         Console.WriteLine("数据检测完毕,本地Mapping数据量({0}),淘宝商品数量({1})", mappingCount, taobaoCount);
         Console.WriteLine("正在进行数据分析处理……");
         mailDataEntity.InventoryQtyNotEquels     = biz.GetInventoryQtyNotEquels();
         mailDataEntity.TaobaoProductNotExists    = biz.GetTaobaoProductNotExists();
         mailDataEntity.ThirdPartMappingNotExists = biz.GetThirdPartMappingNotExists();
         Console.WriteLine("数据分析完毕:");
         Console.WriteLine("\t本地Mapping有记录,淘宝已售完或无此商品({0})", mailDataEntity.TaobaoProductNotExists == null ? 0 : mailDataEntity.TaobaoProductNotExists.Count);
         Console.WriteLine("\t淘宝有商品,本地Mapping无记录({0})", mailDataEntity.ThirdPartMappingNotExists == null ? 0 : mailDataEntity.ThirdPartMappingNotExists.Count);
         Console.WriteLine("\t库存不同步({0})", mailDataEntity.InventoryQtyNotEquels == null ? 0 : mailDataEntity.InventoryQtyNotEquels.Count);
         Console.WriteLine("邮件发送中……");
         SendMailBiz.SendMail(mailDataEntity);
         Console.WriteLine("邮件发送成功。");
     }
     catch (Exception ex)
     {
         ExceptionHelper.HandleException(ex, Config.MailSubject + "_异常信息", new object[] { });
         Console.WriteLine("{0}\r\n{1}", ex.Message, ex.StackTrace);
     }
     Console.WriteLine("本次Job监测完毕。");
 }
Ejemplo n.º 2
0
        public static void SendMail(MailDataEntity mailDataEntity)
        {
            SendMailDelegate <List <TaobaoProduct> >            ThirdPartMappingNotExists = new SendMailDelegate <List <TaobaoProduct> >(SendMail);
            SendMailDelegate <List <ThirdPartInventoryEntity> > TaobaoProductNotExists    = new SendMailDelegate <List <ThirdPartInventoryEntity> >(SendMail);
            SendMailDelegate <Dictionary <ThirdPartInventoryEntity, TaobaoProduct> > InventoryQtyNotEquels = new SendMailDelegate <Dictionary <ThirdPartInventoryEntity, TaobaoProduct> >(SendMail);

            IAsyncResult ThirdPartMappingNotExists_Result = ThirdPartMappingNotExists.BeginInvoke(mailDataEntity.ThirdPartMappingNotExists, null, null);
            IAsyncResult TaobaoProductNotExists_Result    = TaobaoProductNotExists.BeginInvoke(mailDataEntity.TaobaoProductNotExists, null, null);
            IAsyncResult InventoryQtyNotEquels_Result     = InventoryQtyNotEquels.BeginInvoke(mailDataEntity.InventoryQtyNotEquels, null, null);

            ThirdPartMappingNotExists.EndInvoke(ThirdPartMappingNotExists_Result);
            TaobaoProductNotExists.EndInvoke(TaobaoProductNotExists_Result);
            InventoryQtyNotEquels.EndInvoke(InventoryQtyNotEquels_Result);
        }
Ejemplo n.º 3
0
        public static void BuildAttachmentData(MailDataEntity entity, string itemString)
        {
            if (entity.Mails.Count <= 0)
            {
                return;
            }
            int start = 0;
            int end   = 0;

            foreach (var item in entity.Mails)
            {
                if (item.MailAttachment == null || item.MailAttachment.Attachments == null)
                {
                    continue;
                }
                int count = item.MailAttachment.Attachments.Count;
                item.MailAttachment.Attachments = new List <AttachmentEntity>(count);
                start      = itemString.IndexOf("Attachments") + 14;
                itemString = itemString.Substring(start);
                for (int i = 0; i < count; i++)
                {
                    //{"AttachmentType":2,"Count":150},{"AttachmentType":1,"Count":150}
                    start = itemString.IndexOf("AttachmentType") + 16;
                    var iType = Convert.ToInt32(GetSS(itemString, start, ",", out end));

                    start = itemString.IndexOf("{");
                    end   = itemString.IndexOf("}") + 1;
                    var ss = itemString.Substring(start, end);
                    switch (iType)
                    {
                    case (int)EnumAttachmentType.Coin:
                        item.MailAttachment.Attachments.Add(JsonConvert.DeserializeObject <AttachmentEntity>(ss));
                        break;

                    case (int)EnumAttachmentType.Point:
                        item.MailAttachment.Attachments.Add(JsonConvert.DeserializeObject <AttachmentEntity>(ss));
                        break;

                    case (int)EnumAttachmentType.NewItem:
                        item.MailAttachment.Attachments.Add(JsonConvert.DeserializeObject <AttachmentItemEntity>(ss));
                        break;

                    case (int)EnumAttachmentType.UsedPlayerCard:
                        var propertyString  = GetAttachmentProperty(itemString, out end);
                        var attachmentCount = GetAttachmentCount(itemString, end);
                        end = itemString.IndexOf("\"Count\"") + 8 + attachmentCount.Length + 1;
                        ss  = itemString.Substring(start, end - start);
                        var usedItem = JsonConvert.DeserializeObject <AttachmentUsedItemEntity>(ss);
                        usedItem.ItemProperty = JsonConvert.DeserializeObject <PlayerCardUsedEntity>(propertyString);
                        item.MailAttachment.Attachments.Add(usedItem);
                        break;

                    case (int)EnumAttachmentType.UsedEquipment:
                        var propertyString1  = GetAttachmentProperty(itemString, out end);
                        var attachmentCount1 = GetAttachmentCount(itemString, end);
                        end = itemString.IndexOf("\"Count\"") + 8 + attachmentCount1.Length + 1;
                        ss  = itemString.Substring(start, end - start);
                        var usedItem1 = JsonConvert.DeserializeObject <AttachmentUsedItemEntity>(ss);
                        usedItem1.ItemProperty = JsonConvert.DeserializeObject <EquipmentUsedEntity>(propertyString1);
                        item.MailAttachment.Attachments.Add(usedItem1);
                        break;

                    case (int)EnumAttachmentType.Equipment:
                        var propertyString2 = GetEquipmentProperty(itemString, out end);
                        end = itemString.IndexOf("AttachmentType") - 2;
                        var attachmentCount2 = GetAttachmentCount(itemString, end);
                        end = itemString.IndexOf("\"Count\"") + 8 + attachmentCount2.Length + 1;
                        ss  = itemString.Substring(start, end - start);
                        var equipmentItem = JsonConvert.DeserializeObject <AttachmentEquipmentEntity>(ss);
                        equipmentItem.EquipmentProperty = JsonConvert.DeserializeObject <EquipmentProperty>(propertyString2);
                        item.MailAttachment.Attachments.Add(equipmentItem);
                        break;
                    }
                    itemString = itemString.Substring(end + 1);
                }
            }
        }