Exemplo n.º 1
0
        public bool ENT_V_DateFormatDetail_Update(IEnumerable <ENT_V_DateFormatDetail> items, string ModifiedBy)
        {
            string ENT_V_DateFormatDetail_List             = string.Empty;
            string ENT_V_DateFormatDetail_List_Serialized  = string.Empty;
            string ENT_V_DateFormatDetail_Items_Serialized = string.Empty;

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

            try
            {
                WMS.Models.DBContext model = new DBContext();
                foreach (ENT_V_DateFormatDetail item in items)
                {
                    ENT_V_DateFormatDetail dbItem = model.DBSet_ENT_V_DateFormatDetail.Where(d => d.ID == item.ID).FirstOrDefault();
                    if (dbItem != null)
                    {
                        ENT_V_DateFormatDetail_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.Begin                  = item.Begin;
                        dbItem.Code_Date_element_ID   = item.Code_Date_element_ID;
                        dbItem.Code_date_field_ID     = item.Code_date_field_ID;
                        dbItem.Code_Date_type_ID      = item.Code_Date_type_ID;
                        dbItem.Code_how_to_process_ID = item.Code_how_to_process_ID;
                        dbItem.CreatedBy              = item.CreatedBy;
                        dbItem.CreatedDate            = item.CreatedDate;
                        dbItem.Date_element           = item.Date_element;
                        dbItem.Date_type              = item.Date_type;
                        dbItem.End              = item.End;
                        dbItem.Field_type       = item.Field_type;
                        dbItem.How_to_process   = item.How_to_process;
                        dbItem.ID               = item.ID;
                        dbItem.IsDeleted        = item.IsDeleted;
                        dbItem.ModifiedBy       = item.ModifiedBy;
                        dbItem.ModifiedDate     = item.ModifiedDate;
                        dbItem.V_date_format_ID = item.V_date_format_ID;


                        ENT_V_DateFormatDetail_Items_Serialized += Common.SerializeObject(item);
                        Common.SaveChanges(model);
                        ENT_V_DateFormatDetail_List_Serialized += Common.SerializeObject(item);
                    }
                }
            }
            catch (Exception ex)
            {
                flag   = false;
                result = ex.Message;
                Common.log.Error(ENT_V_DateFormatDetail_Items_Serialized, ex);
            }
            finally
            {
                if (!string.IsNullOrEmpty(result))
                {
                    Common.log.Warn(ModifiedBy + " => " + ENT_V_DateFormatDetail_Items_Serialized, new Exception(result));
                }
                Common.log.Info(string.Format("User: {0} - [end] - ENT_V_DateFormatDetail_Update: {1} - {2}", ModifiedBy, ENT_V_DateFormatDetail_List, ENT_V_DateFormatDetail_List_Serialized));
            }
            return(flag);
        }
Exemplo n.º 2
0
        public DataSourceResult ENT_V_DateFormatDetail_Create(ENT_V_DateFormatDetail item, string CreatedBy)
        {
            string ENT_V_DateFormatDetail_List             = string.Empty;
            string ENT_V_DateFormatDetail_List_Serialized  = string.Empty;
            string ENT_V_DateFormatDetail_Items_Serialized = string.Empty;

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

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

                ENT_V_DateFormatDetail dbItem = new ENT_V_DateFormatDetail();

                item.CreatedBy                = item.ModifiedBy = CreatedBy;
                item.CreatedDate              = item.ModifiedDate = Common.getUTCDate();
                dbItem.IsSelected             = item.IsSelected;
                dbItem.TagStr                 = item.TagStr;
                dbItem.Begin                  = item.Begin;
                dbItem.Code_Date_element_ID   = item.Code_Date_element_ID;
                dbItem.Code_date_field_ID     = item.Code_date_field_ID;
                dbItem.Code_Date_type_ID      = item.Code_Date_type_ID;
                dbItem.Code_how_to_process_ID = item.Code_how_to_process_ID;
                dbItem.CreatedBy              = item.CreatedBy;
                dbItem.CreatedDate            = item.CreatedDate;
                dbItem.Date_element           = item.Date_element;
                dbItem.Date_type              = item.Date_type;
                dbItem.End              = item.End;
                dbItem.Field_type       = item.Field_type;
                dbItem.How_to_process   = item.How_to_process;
                dbItem.ID               = item.ID;
                dbItem.IsDeleted        = item.IsDeleted;
                dbItem.ModifiedBy       = item.ModifiedBy;
                dbItem.ModifiedDate     = item.ModifiedDate;
                dbItem.V_date_format_ID = item.V_date_format_ID;
                ENT_V_DateFormatDetail_Items_Serialized += Common.SerializeObject(item);
                model.DBSet_ENT_V_DateFormatDetail.Add(dbItem);
                Common.SaveChanges(model);

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

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