Beispiel #1
0
 // HANDLING EXCEPTION
 private void HandlingException(Exception ex)
 {
     try
     {
         using (EurofarStockEntities context = new EurofarStockEntities(Library.Helper.CreateEntityConnectionString("EurofarStockModel")))
         {
             SystemLogging logItem = new SystemLogging();
             logItem.LogDate = System.DateTime.Now;
             logItem.RequestUD = requestUD;
             logItem.ProcessDescription = GetDescription();
             logItem.DetailMessage = Library.Helper.GetInnerException(ex).Message;
             context.SystemLogging.Add(logItem);
             context.SaveChanges();
         }
     }
     catch { }
 }
Beispiel #2
0
        // TILSOFT
        private bool getTilsoftData(out List<DTO.ProductDTO> data)
        {
            data = new List<DTO.ProductDTO>();
            try
            {
                //List<DTO.WEX.Article> jsonAllData;
                //List<DTO.WEX.Article> jsonData;
                //if (!getWEXData(out jsonAllData))
                //{
                //    return false;
                //}
                //if (getWEXFreeToSaleData(out jsonData))
                //{
                //    return false;
                //}

                using (EurofarStockEntities context = new EurofarStockEntities(Library.Helper.CreateEntityConnectionString("EurofarStockModel")))
                {
                    using (DbContextTransaction scope = context.Database.BeginTransaction())
                    {
                        //context.Database.ExecuteSqlCommand("SELECT * FROM WexItem WITH (TABLOCKX, HOLDLOCK)");
                        //if (jsonAllData.Count() > 0)
                        //{
                        //    context.Database.ExecuteSqlCommand("DELETE FROM WexItem");
                        //    context.Database.ExecuteSqlCommand("DBCC CHECKIDENT('WexItem', RESEED, 1)");
                        //}

                        //try
                        //{
                        //    // delete wex item which is not in jsonAll
                        //    List<string> articleCodes = jsonAllData.Select(o => o.out_item_no).ToList();
                        //    context.WexItem.Where(o => !articleCodes.Contains(o.ArticleCode)).ToList().ForEach(o => context.WexItem.Remove(o));

                        //    foreach (DTO.WEX.Article wexItem in jsonAllData)
                        //    {
                        //        WexItem dbItem = context.WexItem.FirstOrDefault(o => o.ArticleCode == wexItem.out_item_no);
                        //        if (dbItem == null)
                        //        {
                        //            dbItem = new WexItem();
                        //            dbItem.ArticleCode = wexItem.out_item_no;
                        //            dbItem.SubEANCode = wexItem.out_barcode_base;
                        //            context.WexItem.Add(dbItem);
                        //        }
                        //        dbItem.StockQnt = 0;
                        //        dbItem.TotalStockQnt = Convert.ToInt32(wexItem.out_stock);
                        //        dbItem.IsEnabled = true;
                        //        if (jsonData.FirstOrDefault(o => o.out_item_no == wexItem.out_item_no) != null)
                        //        {
                        //            dbItem.StockQnt = Convert.ToInt32(jsonData.FirstOrDefault(o => o.out_item_no == wexItem.out_item_no).out_available_stock);
                        //        }

                        //        //if (wexItem.out_available_stock > 0)
                        //        //{
                        //        //    WexItem nItem = new WexItem()
                        //        //    {
                        //        //        ArticleCode = wexItem.out_item_no
                        //        //        , SubEANCode = wexItem.out_barcode_base
                        //        //        , StockQnt = 0
                        //        //        , TotalStockQnt = Convert.ToInt32(wexItem.out_stock)
                        //        //        , IsEnabled = true
                        //        //    };
                        //        //    if (jsonData.FirstOrDefault(o => o.out_item_no == wexItem.out_item_no) != null)
                        //        //    {
                        //        //        nItem.StockQnt = Convert.ToInt32(jsonData.FirstOrDefault(o => o.out_item_no == wexItem.out_item_no).out_available_stock);
                        //        //    }
                        //        //    context.WexItem.Add(nItem);
                        //        //}
                        //    }
                        //    context.SaveChanges();
                        //}
                        //catch (Exception ex)
                        //{
                        //    throw ex;
                        //}
                        //finally
                        //{
                        //    scope.Commit();
                        //}
                        // update price table
                        context.EurofarStockSync_function_UpdatePriceTable();

                        data = converter.DB2DTO_Product(context.WarehouseConnectMng_Product_View.ToList());
                    }
                }
            }
            catch (Exception ex)
            {
                HandlingException(ex);
                data = new List<DTO.ProductDTO>();
                return false;
            }

            return true;
        }