示例#1
0
文件: ENT_User.cs 项目: lhthai/WMS
        public bool ENT_User_Update(IEnumerable <ENT_User> items, string ModifiedBy)
        {
            string ENT_User_List             = string.Empty;
            string ENT_User_List_Serialized  = string.Empty;
            string ENT_User_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (ENT_User item in items)
                {
                    ENT_User dbItem = model.DBSet_ENT_User.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        ENT_User_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.CreatedBy    = item.CreatedBy;
                        dbItem.CreatedDate  = item.CreatedDate;
                        dbItem.Encrypt      = item.Encrypt;
                        dbItem.Full_Name    = item.Full_Name;
                        dbItem.ID           = item.ID;
                        dbItem.IsDeleted    = item.IsDeleted;
                        dbItem.ModifiedBy   = item.ModifiedBy;
                        dbItem.ModifiedDate = item.ModifiedDate;
                        dbItem.Name         = item.Name;
                        dbItem.Password     = item.Password;


                        ENT_User_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        ENT_User_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(ENT_User_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + ENT_User_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_User_Update: {1} - {2}", ModifiedBy, ENT_User_List, ENT_User_List_Serialized));
            }
            return(flag);
        }
示例#2
0
文件: ENT_User.cs 项目: lhthai/WMS
        public DataSourceResult ENT_User_Create(IEnumerable <ENT_User> items, string CreatedBy)
        {
            string ENT_User_List             = string.Empty;
            string ENT_User_List_Serialized  = string.Empty;
            string ENT_User_Items_Serialized = string.Empty;

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

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

                    item.CreatedBy      = item.ModifiedBy = CreatedBy;
                    item.CreatedDate    = item.ModifiedDate = Common.getUTCDate();
                    dbItem.IsSelected   = item.IsSelected;
                    dbItem.TagStr       = item.TagStr;
                    dbItem.CreatedBy    = item.CreatedBy;
                    dbItem.CreatedDate  = item.CreatedDate;
                    dbItem.Encrypt      = item.Encrypt;
                    dbItem.Full_Name    = item.Full_Name;
                    dbItem.ID           = item.ID;
                    dbItem.IsDeleted    = item.IsDeleted;
                    dbItem.ModifiedBy   = item.ModifiedBy;
                    dbItem.ModifiedDate = item.ModifiedDate;
                    dbItem.Name         = item.Name;
                    dbItem.Password     = item.Password;

                    ENT_User_Items_Serialized += Common.SerializeObject(item);
                    model.DBSet_ENT_User.Add(dbItem);
                    Common.SaveChanges(model);

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

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