Beispiel #1
0
        public DataSourceResult ENT_Wave_Create(IEnumerable <ENT_Wave> items, string CreatedBy)
        {
            string ENT_Wave_List             = string.Empty;
            string ENT_Wave_List_Serialized  = string.Empty;
            string ENT_Wave_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (ENT_Wave item in items)
                {
                    ENT_Wave dbItem = new ENT_Wave();

                    item.CreatedBy        = item.ModifiedBy = CreatedBy;
                    item.CreatedDate      = item.ModifiedDate = Common.getUTCDate();
                    dbItem.IsSelected     = item.IsSelected;
                    dbItem.TagStr         = item.TagStr;
                    dbItem.Create_On      = item.Create_On;
                    dbItem.CreatedBy      = item.CreatedBy;
                    dbItem.CreatedDate    = item.CreatedDate;
                    dbItem.Description    = item.Description;
                    dbItem.ID             = item.ID;
                    dbItem.IsDelete       = item.IsDelete;
                    dbItem.ModifiedBy     = item.ModifiedBy;
                    dbItem.ModifiedDate   = item.ModifiedDate;
                    dbItem.SO_ID          = item.SO_ID;
                    dbItem.User_ID        = item.User_ID;
                    dbItem.Wave_Code      = item.Wave_Code;
                    dbItem.Wave_Status_ID = item.Wave_Status_ID;

                    ENT_Wave_Items_Serialized += Common.SerializeObject(item);
                    model.DBSet_ENT_Wave.Add(dbItem);
                    Common.SaveChanges(model);

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

                    result.Add(item);
                    ENT_Wave_List_Serialized += Common.SerializeObject(item);
                }
            }
            catch (Exception ex)
            {
                message = ex.Message;
                Common.log.Error(ENT_Wave_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(message))
                {
                    Common.log.Warn(CreatedBy + " => " + ENT_Wave_Items_Serialized, new Exception(message));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_Wave_Create: {1} - {2}", CreatedBy, ENT_Wave_List, ENT_Wave_List_Serialized));
            }
            return(result.ToDataSourceResult(new DataSourceRequest()));
        }
Beispiel #2
0
        public bool ENT_Wave_Update(IEnumerable <ENT_Wave> items, string ModifiedBy)
        {
            string ENT_Wave_List             = string.Empty;
            string ENT_Wave_List_Serialized  = string.Empty;
            string ENT_Wave_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (ENT_Wave item in items)
                {
                    ENT_Wave dbItem = model.DBSet_ENT_Wave.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        ENT_Wave_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.Create_On      = item.Create_On;
                        dbItem.CreatedBy      = item.CreatedBy;
                        dbItem.CreatedDate    = item.CreatedDate;
                        dbItem.Description    = item.Description;
                        dbItem.ID             = item.ID;
                        dbItem.IsDelete       = item.IsDelete;
                        dbItem.ModifiedBy     = item.ModifiedBy;
                        dbItem.ModifiedDate   = item.ModifiedDate;
                        dbItem.SO_ID          = item.SO_ID;
                        dbItem.User_ID        = item.User_ID;
                        dbItem.Wave_Code      = item.Wave_Code;
                        dbItem.Wave_Status_ID = item.Wave_Status_ID;


                        ENT_Wave_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        ENT_Wave_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(ENT_Wave_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + ENT_Wave_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_Wave_Update: {1} - {2}", ModifiedBy, ENT_Wave_List, ENT_Wave_List_Serialized));
            }
            return(flag);
        }