public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.ITEM.ITEM_UNIT_OF_MEASURE_MODEL model, params string[] updateProperties)
        {
            Apps.Models.ITEM_UNIT_OF_MEASURE entity = m_Rep.GetById(model.INTERNAL_ITEM_UM);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERNAL_ITEM_UM     = model.INTERNAL_ITEM_UM;
                entity.ITEM                 = model.ITEM;
                entity.COMPANY              = model.COMPANY;
                entity.SEQUENCE             = model.SEQUENCE;
                entity.QUANTITY_UM          = model.QUANTITY_UM;
                entity.CONVERSION_QTY       = model.CONVERSION_QTY;
                entity.LENGTH               = model.LENGTH;
                entity.WIDTH                = model.WIDTH;
                entity.HEIGHT               = model.HEIGHT;
                entity.DIMENSION_UM         = model.DIMENSION_UM;
                entity.WEIGHT               = model.WEIGHT;
                entity.WEIGHT_UM            = model.WEIGHT_UM;
                entity.USER_STAMP           = model.USER_STAMP;
                entity.PROCESS_STAMP        = model.PROCESS_STAMP;
                entity.DATE_TIME_STAMP      = model.DATE_TIME_STAMP;
                entity.TREAT_FULL_PCT       = model.TREAT_FULL_PCT;
                entity.MOVEMENT_CLS         = model.MOVEMENT_CLS;
                entity.ITEM_CLASS           = model.ITEM_CLASS;
                entity.TREAT_AS_LOOSE       = model.TREAT_AS_LOOSE;
                entity.GROUP_DURING_CHECKIN = model.GROUP_DURING_CHECKIN;
                entity.USER_DEF1            = model.USER_DEF1;
                entity.USER_DEF2            = model.USER_DEF2;
                entity.USER_DEF3            = model.USER_DEF3;
                entity.USER_DEF4            = model.USER_DEF4;
                entity.USER_DEF5            = model.USER_DEF5;
                entity.USER_DEF6            = model.USER_DEF6;
                entity.USER_DEF7            = model.USER_DEF7;
                entity.USER_DEF8            = model.USER_DEF8;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.ITEM.ITEM_UNIT_OF_MEASURE_MODEL);
                Type typeE = typeof(Apps.Models.ITEM_UNIT_OF_MEASURE);
                foreach (var item in updateProperties)
                {
                    System.Reflection.PropertyInfo pi  = type.GetProperty(item);
                    System.Reflection.PropertyInfo piE = typeE.GetProperty(item);
                    piE.SetValue(entity, pi.GetValue(model), null);
                }
            }


            m_Rep.Modify(entity, updateProperties);
        }
        public virtual Apps.Models.SCV.ITEM.ITEM_UNIT_OF_MEASURE_MODEL GetById(string id)
        {
            Apps.Models.ITEM_UNIT_OF_MEASURE entity = m_Rep.GetById(id);
            if (entity != null)
            {
                //ITEM_UNIT_OF_MEASURE entity = m_Rep.GetById(id);
                Apps.Models.SCV.ITEM.ITEM_UNIT_OF_MEASURE_MODEL model = new Apps.Models.SCV.ITEM.ITEM_UNIT_OF_MEASURE_MODEL();
                model.INTERNAL_ITEM_UM     = entity.INTERNAL_ITEM_UM;
                model.ITEM                 = entity.ITEM;
                model.COMPANY              = entity.COMPANY;
                model.SEQUENCE             = entity.SEQUENCE;
                model.QUANTITY_UM          = entity.QUANTITY_UM;
                model.CONVERSION_QTY       = entity.CONVERSION_QTY;
                model.LENGTH               = entity.LENGTH;
                model.WIDTH                = entity.WIDTH;
                model.HEIGHT               = entity.HEIGHT;
                model.DIMENSION_UM         = entity.DIMENSION_UM;
                model.WEIGHT               = entity.WEIGHT;
                model.WEIGHT_UM            = entity.WEIGHT_UM;
                model.USER_STAMP           = entity.USER_STAMP;
                model.PROCESS_STAMP        = entity.PROCESS_STAMP;
                model.DATE_TIME_STAMP      = entity.DATE_TIME_STAMP;
                model.TREAT_FULL_PCT       = entity.TREAT_FULL_PCT;
                model.MOVEMENT_CLS         = entity.MOVEMENT_CLS;
                model.ITEM_CLASS           = entity.ITEM_CLASS;
                model.TREAT_AS_LOOSE       = entity.TREAT_AS_LOOSE;
                model.GROUP_DURING_CHECKIN = entity.GROUP_DURING_CHECKIN;
                model.USER_DEF1            = entity.USER_DEF1;
                model.USER_DEF2            = entity.USER_DEF2;
                model.USER_DEF3            = entity.USER_DEF3;
                model.USER_DEF4            = entity.USER_DEF4;
                model.USER_DEF5            = entity.USER_DEF5;
                model.USER_DEF6            = entity.USER_DEF6;
                model.USER_DEF7            = entity.USER_DEF7;
                model.USER_DEF8            = entity.USER_DEF8;

                return(model);
            }
            else
            {
                return(null);
            }
        }
        public virtual void Create(ref ValidationErrors errors, Apps.Models.SCV.ITEM.ITEM_UNIT_OF_MEASURE_MODEL model)
        {
            Apps.Models.ITEM_UNIT_OF_MEASURE entity = m_Rep.GetById(model.INTERNAL_ITEM_UM);
            if (entity != null)
            {
                errors.Add(Resource.PrimaryRepeat);
                return;
            }
            entity = new Apps.Models.ITEM_UNIT_OF_MEASURE();
            entity.INTERNAL_ITEM_UM     = model.INTERNAL_ITEM_UM;
            entity.ITEM                 = model.ITEM;
            entity.COMPANY              = model.COMPANY;
            entity.SEQUENCE             = model.SEQUENCE;
            entity.QUANTITY_UM          = model.QUANTITY_UM;
            entity.CONVERSION_QTY       = model.CONVERSION_QTY;
            entity.LENGTH               = model.LENGTH;
            entity.WIDTH                = model.WIDTH;
            entity.HEIGHT               = model.HEIGHT;
            entity.DIMENSION_UM         = model.DIMENSION_UM;
            entity.WEIGHT               = model.WEIGHT;
            entity.WEIGHT_UM            = model.WEIGHT_UM;
            entity.USER_STAMP           = model.USER_STAMP;
            entity.PROCESS_STAMP        = model.PROCESS_STAMP;
            entity.DATE_TIME_STAMP      = model.DATE_TIME_STAMP;
            entity.TREAT_FULL_PCT       = model.TREAT_FULL_PCT;
            entity.MOVEMENT_CLS         = model.MOVEMENT_CLS;
            entity.ITEM_CLASS           = model.ITEM_CLASS;
            entity.TREAT_AS_LOOSE       = model.TREAT_AS_LOOSE;
            entity.GROUP_DURING_CHECKIN = model.GROUP_DURING_CHECKIN;
            entity.USER_DEF1            = model.USER_DEF1;
            entity.USER_DEF2            = model.USER_DEF2;
            entity.USER_DEF3            = model.USER_DEF3;
            entity.USER_DEF4            = model.USER_DEF4;
            entity.USER_DEF5            = model.USER_DEF5;
            entity.USER_DEF6            = model.USER_DEF6;
            entity.USER_DEF7            = model.USER_DEF7;
            entity.USER_DEF8            = model.USER_DEF8;

            m_Rep.Create(entity);
        }
        // POST: api/SingleitemSynchronize
        public SingleitemSynchronizeResponseModel Post([FromBody] SingleitemSynchronizeRequestModel model, string customerId)
        {
            //测试相关
            //if (customerId == "c1515046170643")
            //{
            //    customerId = "HPH";
            //}
            //---------------------------------
            if (customerId == "CH1")
            {
                customerId = "CH";
            }
            SingleitemSynchronizeResponseModel response = new SingleitemSynchronizeResponseModel();

            using (DBContainer context = new DBContainer())
            {
                QiMen_RequestLog log  = new QiMen_RequestLog();
                HttpContextBase  ctx  = (HttpContextBase)Request.Properties["MS_HttpContext"];
                string           body = ApiUtils.GetStreamAsString(ctx.Request.InputStream, new UTF8Encoding(false));
                string           ip   = ctx.Request.UserHostAddress;

                log.Interface   = "SingleitemSynchronize";
                log.Url         = Request.RequestUri.AbsoluteUri;
                log.Ip          = ip;
                log.CustomerId  = customerId;
                log.RequestBody = body;
                context.QiMen_RequestLog.Add(log);
                context.SaveChanges();
            }

            using (SCVDBContainer dbContext = new SCVDBContainer())
            {
                DbSet <ITEM> dbSet = dbContext.Set <ITEM>();
                DbSet <ITEM_UNIT_OF_MEASURE> dbSet1  = dbContext.Set <ITEM_UNIT_OF_MEASURE>();
                Apps.Models.ITEM             scvItem = null;
                if (model.ActionType == "update")
                {
                    scvItem = dbSet.FirstOrDefault(i => i.ITEM1 == model.Item.ItemCode && i.COMPANY == customerId);

                    if (scvItem != null)
                    {
                        scvItem.COMPANY          = model.OwnerCode;
                        scvItem.ITEM1            = model.Item.ItemCode;
                        scvItem.ITEM_DESC        = model.Item.ItemName;
                        scvItem.STORAGE_TEMPLATE = "三层模板";
                        scvItem.ACTIVE           = "Y";
                        scvItem.DATE_TIME_STAMP  = DateTime.Now;
                        scvItem.ATTRIBUTE_TRACK  = "N";
                        scvItem.ITEM_SIZE        = model.Item.SkuProperty;
                        scvItem.ITEM_COLOR       = model.Item.Color;
                        scvItem.ITEM_STYLE       = model.Item.GoodsCode;
                    }
                }
                if (model.ActionType == "add")
                {
                    scvItem                  = new Apps.Models.ITEM();
                    scvItem.COMPANY          = model.OwnerCode;
                    scvItem.ITEM1            = model.Item.ItemCode;
                    scvItem.ITEM_DESC        = model.Item.ItemName;
                    scvItem.STORAGE_TEMPLATE = "三层模板";
                    scvItem.ACTIVE           = "Y";
                    scvItem.DATE_TIME_STAMP  = DateTime.Now;
                    scvItem.ATTRIBUTE_TRACK  = "N";
                    scvItem.ITEM_SIZE        = model.Item.SkuProperty;
                    scvItem.ITEM_COLOR       = model.Item.Color;
                    scvItem.ITEM_STYLE       = model.Item.GoodsCode;
                    var scvItemUnit = dbSet1.FirstOrDefault(u => u.ITEM == model.Item.ItemCode && u.COMPANY == customerId);
                    if (scvItemUnit == null)
                    {
                        scvItemUnit                      = new Apps.Models.ITEM_UNIT_OF_MEASURE();
                        scvItemUnit.ITEM                 = model.Item.ItemCode;
                        scvItemUnit.COMPANY              = customerId;
                        scvItemUnit.SEQUENCE             = 1;
                        scvItemUnit.QUANTITY_UM          = "EA";
                        scvItemUnit.CONVERSION_QTY       = 1;
                        scvItemUnit.LENGTH               = model.Item.Length;
                        scvItemUnit.WIDTH                = model.Item.Width;
                        scvItemUnit.HEIGHT               = model.Item.Height;
                        scvItemUnit.DIMENSION_UM         = "CM";
                        scvItemUnit.WEIGHT               = model.Item.GrossWeight;
                        scvItemUnit.WEIGHT_UM            = "KG";
                        scvItemUnit.USER_STAMP           = "Interface";
                        scvItemUnit.DATE_TIME_STAMP      = DateTime.Now;
                        scvItemUnit.TREAT_FULL_PCT       = 100;
                        scvItemUnit.TREAT_AS_LOOSE       = "Y";
                        scvItemUnit.GROUP_DURING_CHECKIN = "Y";
                        scvItemUnit.USER_DEF7            = "0";
                        scvItemUnit.USER_DEF8            = "0";
                        dbSet1.Add(scvItemUnit);
                    }

                    dbSet.Add(scvItem);
                }

                if (dbContext.SaveChanges() >= 0)
                {
                    response.Code    = "0";
                    response.Flag    = "success";
                    response.Message = "商品同步成功";
                    response.ItemId  = scvItem.INTERNAL_ITEM_NUM.ToString();
                }
                else
                {
                    response.Code    = "-1";
                    response.Flag    = "failure";
                    response.Message = "商品同步失败,请重试";
                }
            }


            return(response);
        }