Example #1
0
 partial void DeleteTRN_Incremental(TRN_Incremental instance);
Example #2
0
 partial void InsertTRN_Incremental(TRN_Incremental instance);
Example #3
0
 partial void UpdateTRN_Incremental(TRN_Incremental instance);
Example #4
0
        public static void InsertIncremental()
        {
            try
            {
                int totalQuere = 0;
                totalQuere = CountMessageInQuere(ShareRules.Queue_Incremental);
                if (totalQuere != 0)
                {
                    for (int row = 0; row < totalQuere; row++)
                    {
                        String message = string.Empty;
                        message = GetDatainRabbitMQ(ShareRules.Queue_Incremental);
                        if (!string.IsNullOrEmpty(message))
                        {
                            Incremental data = new Incremental();
                            data = Newtonsoft.Json.JsonConvert.DeserializeObject <Incremental>(message);
                            List <TRN_Incremental> ListSaveData = new List <TRN_Incremental>();
                            if (data != null)
                            {
                                foreach (var items in data.items)
                                {
                                    foreach (var itemstocks in items.stocks)
                                    {
                                        TRN_Incremental dataSave = new TRN_Incremental();
                                        dataSave.CreateDate = DateTime.Now;
                                        if (!ShareRules.CheckEmpty(data.updated))
                                        {
                                            dataSave.UpdateDate = Convert.ToDateTime(data.updated);
                                        }

                                        if (!ShareRules.CheckEmpty(data.seq))
                                        {
                                            dataSave.Seq = Convert.ToInt32(data.seq);
                                        }

                                        dataSave.bu = data.bu;

                                        dataSave.@interface   = "online_stock_incre";
                                        dataSave.barcode      = items.barcode;
                                        dataSave.SKU          = items.sku;
                                        dataSave.Status       = items.status;
                                        dataSave.Itemize      = items.itemize;
                                        dataSave.Loc          = itemstocks.loc;
                                        dataSave.AvailStock   = itemstocks.availStock;
                                        dataSave.ReserveStock = itemstocks.reserveStock;
                                        ListSaveData.Add(dataSave);
                                    }
                                }

                                if (ListSaveData.Count > 0)
                                {
                                    DBRealTimeDataContext db = ShareRules.ConnectDB(true);
                                    db.TRN_Incrementals.InsertAllOnSubmit(ListSaveData);

                                    db.SubmitChanges();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ShareRules.WriteLog(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString());
            }
        }