示例#1
0
        public bool WHS_Lot_Attribute_Update(IEnumerable <WHS_Lot_Attribute> items, string ModifiedBy)
        {
            string WHS_Lot_Attribute_List             = string.Empty;
            string WHS_Lot_Attribute_List_Serialized  = string.Empty;
            string WHS_Lot_Attribute_Items_Serialized = string.Empty;

            string result = string.Empty;
            bool   flag   = true;

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (WHS_Lot_Attribute item in items)
                {
                    WHS_Lot_Attribute dbItem = model.DBSet_WHS_Lot_Attribute.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        WHS_Lot_Attribute_List += "[" + item.ID + "] ";
                        item.ModifiedBy         = ModifiedBy;
                        item.ModifiedDate       = Common.getUTCDate();
                        if (item.CreatedDate == DateTime.MinValue)
                        {
                            item.CreatedDate = dbItem.CreatedDate;
                        }
                        dbItem.IsSelected    = item.IsSelected;
                        dbItem.TagStr        = item.TagStr;
                        dbItem.ASN_Detail_ID = item.ASN_Detail_ID;
                        dbItem.CreatedBy     = item.CreatedBy;
                        dbItem.CreatedDate   = item.CreatedDate;
                        dbItem.ID            = item.ID;
                        dbItem.IsDeleted     = item.IsDeleted;
                        dbItem.Item_ID       = item.Item_ID;
                        dbItem.Lottable_1    = item.Lottable_1;
                        dbItem.Lottable_10   = item.Lottable_10;
                        dbItem.Lottable_11   = item.Lottable_11;
                        dbItem.Lottable_12   = item.Lottable_12;
                        dbItem.Lottable_2    = item.Lottable_2;
                        dbItem.Lottable_3    = item.Lottable_3;
                        dbItem.Lottable_4    = item.Lottable_4;
                        dbItem.Lottable_5    = item.Lottable_5;
                        dbItem.Lottable_6    = item.Lottable_6;
                        dbItem.Lottable_7    = item.Lottable_7;
                        dbItem.Lottable_8    = item.Lottable_8;
                        dbItem.Lottable_9    = item.Lottable_9;
                        dbItem.ModifiedBy    = item.ModifiedBy;
                        dbItem.ModifiedDate  = item.ModifiedDate;
                        dbItem.Owner_ID      = item.Owner_ID;


                        WHS_Lot_Attribute_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        WHS_Lot_Attribute_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(WHS_Lot_Attribute_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + WHS_Lot_Attribute_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_Lot_Attribute_Update: {1} - {2}", ModifiedBy, WHS_Lot_Attribute_List, WHS_Lot_Attribute_List_Serialized));
            }
            return(flag);
        }
示例#2
0
        public DataSourceResult WHS_Lot_Attribute_Create(WHS_Lot_Attribute item, string CreatedBy)
        {
            string WHS_Lot_Attribute_List             = string.Empty;
            string WHS_Lot_Attribute_List_Serialized  = string.Empty;
            string WHS_Lot_Attribute_Items_Serialized = string.Empty;

            string message = string.Empty;
            List <WHS_Lot_Attribute> result = new List <WHS_Lot_Attribute>();

            try
            {
                WMS.Models.DBContext model = new DBContext();

                WHS_Lot_Attribute dbItem = new WHS_Lot_Attribute();

                item.CreatedBy       = item.ModifiedBy = CreatedBy;
                item.CreatedDate     = item.ModifiedDate = Common.getUTCDate();
                dbItem.IsSelected    = item.IsSelected;
                dbItem.TagStr        = item.TagStr;
                dbItem.ASN_Detail_ID = item.ASN_Detail_ID;
                dbItem.CreatedBy     = item.CreatedBy;
                dbItem.CreatedDate   = item.CreatedDate;
                dbItem.ID            = item.ID;
                dbItem.IsDeleted     = item.IsDeleted;
                dbItem.Item_ID       = item.Item_ID;
                dbItem.Lottable_1    = item.Lottable_1;
                dbItem.Lottable_10   = item.Lottable_10;
                dbItem.Lottable_11   = item.Lottable_11;
                dbItem.Lottable_12   = item.Lottable_12;
                dbItem.Lottable_2    = item.Lottable_2;
                dbItem.Lottable_3    = item.Lottable_3;
                dbItem.Lottable_4    = item.Lottable_4;
                dbItem.Lottable_5    = item.Lottable_5;
                dbItem.Lottable_6    = item.Lottable_6;
                dbItem.Lottable_7    = item.Lottable_7;
                dbItem.Lottable_8    = item.Lottable_8;
                dbItem.Lottable_9    = item.Lottable_9;
                dbItem.ModifiedBy    = item.ModifiedBy;
                dbItem.ModifiedDate  = item.ModifiedDate;
                dbItem.Owner_ID      = item.Owner_ID;
                WHS_Lot_Attribute_Items_Serialized += Common.SerializeObject(item);
                model.DBSet_WHS_Lot_Attribute.Add(dbItem);
                Common.SaveChanges(model);

                item.ID = dbItem.ID;
                WHS_Lot_Attribute_List += "[" + item.ID + "] ";

                result.Add(item);
                WHS_Lot_Attribute_List_Serialized += Common.SerializeObject(item);
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Common.log.Error(WHS_Lot_Attribute_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(message))
                {
                    Common.log.Warn(CreatedBy + " => " + WHS_Lot_Attribute_Items_Serialized, new Exception(message));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_Lot_Attribute_Create: {1} - {2}", CreatedBy, WHS_Lot_Attribute_List, WHS_Lot_Attribute_List_Serialized));
            }
            return(result.ToDataSourceResult(new DataSourceRequest()));
        }