Example #1
0
        public bool WHS_Location_Update(IEnumerable <WHS_Location> items, string ModifiedBy)
        {
            string WHS_Location_List             = string.Empty;
            string WHS_Location_List_Serialized  = string.Empty;
            string WHS_Location_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (WHS_Location item in items)
                {
                    WHS_Location dbItem = model.DBSet_WHS_Location.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        WHS_Location_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.C_System_MovingspeedDetail_ID = item.C_System_MovingspeedDetail_ID;
                        dbItem.Category_ID               = item.Category_ID;
                        dbItem.Comingleitems             = item.Comingleitems;
                        dbItem.Cominglelots              = item.Cominglelots;
                        dbItem.CreatedBy                 = item.CreatedBy;
                        dbItem.CreatedDate               = item.CreatedDate;
                        dbItem.Cubic_Capacity            = item.Cubic_Capacity;
                        dbItem.Flag_ID                   = item.Flag_ID;
                        dbItem.Foot_Print                = item.Foot_Print;
                        dbItem.Height                    = item.Height;
                        dbItem.ID                        = item.ID;
                        dbItem.IsDeleted                 = item.IsDeleted;
                        dbItem.Length                    = item.Length;
                        dbItem.Level                     = item.Level;
                        dbItem.Location_Code             = item.Location_Code;
                        dbItem.Location_StatusDetail_ID  = item.Location_StatusDetail_ID;
                        dbItem.Location_Type_ID          = item.Location_Type_ID;
                        dbItem.LocationhandlingDetail_ID = item.LocationhandlingDetail_ID;
                        dbItem.ModifiedBy                = item.ModifiedBy;
                        dbItem.ModifiedDate              = item.ModifiedDate;
                        dbItem.Movingspeed_ID            = item.Movingspeed_ID;
                        dbItem.Orientation               = item.Orientation;
                        dbItem.Stack_Limit               = item.Stack_Limit;
                        dbItem.Status                    = item.Status;
                        dbItem.Weight_Capacity           = item.Weight_Capacity;
                        dbItem.Width                     = item.Width;
                        dbItem.X_coordinate              = item.X_coordinate;
                        dbItem.Y_coordinate              = item.Y_coordinate;
                        dbItem.Z_coordinate              = item.Z_coordinate;
                        dbItem.Zone_ID                   = item.Zone_ID;


                        WHS_Location_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        WHS_Location_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(WHS_Location_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + WHS_Location_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - WHS_Location_Update: {1} - {2}", ModifiedBy, WHS_Location_List, WHS_Location_List_Serialized));
            }
            return(flag);
        }
Example #2
0
        public DataSourceResult WHS_Location_Create(WHS_Location item, string CreatedBy)
        {
            string WHS_Location_List             = string.Empty;
            string WHS_Location_List_Serialized  = string.Empty;
            string WHS_Location_Items_Serialized = string.Empty;

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

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

                WHS_Location dbItem = new WHS_Location();

                item.CreatedBy    = item.ModifiedBy = CreatedBy;
                item.CreatedDate  = item.ModifiedDate = Common.getUTCDate();
                dbItem.IsSelected = item.IsSelected;
                dbItem.TagStr     = item.TagStr;
                dbItem.C_System_MovingspeedDetail_ID = item.C_System_MovingspeedDetail_ID;
                dbItem.Category_ID               = item.Category_ID;
                dbItem.Comingleitems             = item.Comingleitems;
                dbItem.Cominglelots              = item.Cominglelots;
                dbItem.CreatedBy                 = item.CreatedBy;
                dbItem.CreatedDate               = item.CreatedDate;
                dbItem.Cubic_Capacity            = item.Cubic_Capacity;
                dbItem.Flag_ID                   = item.Flag_ID;
                dbItem.Foot_Print                = item.Foot_Print;
                dbItem.Height                    = item.Height;
                dbItem.ID                        = item.ID;
                dbItem.IsDeleted                 = item.IsDeleted;
                dbItem.Length                    = item.Length;
                dbItem.Level                     = item.Level;
                dbItem.Location_Code             = item.Location_Code;
                dbItem.Location_StatusDetail_ID  = item.Location_StatusDetail_ID;
                dbItem.Location_Type_ID          = item.Location_Type_ID;
                dbItem.LocationhandlingDetail_ID = item.LocationhandlingDetail_ID;
                dbItem.ModifiedBy                = item.ModifiedBy;
                dbItem.ModifiedDate              = item.ModifiedDate;
                dbItem.Movingspeed_ID            = item.Movingspeed_ID;
                dbItem.Orientation               = item.Orientation;
                dbItem.Stack_Limit               = item.Stack_Limit;
                dbItem.Status                    = item.Status;
                dbItem.Weight_Capacity           = item.Weight_Capacity;
                dbItem.Width                     = item.Width;
                dbItem.X_coordinate              = item.X_coordinate;
                dbItem.Y_coordinate              = item.Y_coordinate;
                dbItem.Z_coordinate              = item.Z_coordinate;
                dbItem.Zone_ID                   = item.Zone_ID;
                WHS_Location_Items_Serialized   += Common.SerializeObject(item);
                model.DBSet_WHS_Location.Add(dbItem);
                Common.SaveChanges(model);

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

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