// 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);
        }
Пример #2
0
        public virtual void Modify(ref ValidationErrors errors, Apps.Models.SCV.Sys.ITEM_MODEL model, params string[] updateProperties)
        {
            Apps.Models.ITEM entity = m_Rep.GetById(model.INTERNAL_ITEM_NUM);
            if (entity == null)
            {
                errors.Add(Resource.Disable);
                return;
            }
            if (updateProperties.Count() <= 0)
            {
                entity.INTERNAL_ITEM_NUM        = model.INTERNAL_ITEM_NUM;
                entity.ITEM1                    = model.ITEM1;
                entity.COMPANY                  = model.COMPANY;
                entity.ITEM_DESC                = model.ITEM_DESC;
                entity.STORAGE_TEMPLATE         = model.STORAGE_TEMPLATE;
                entity.ITEM_CLASS               = model.ITEM_CLASS;
                entity.PACKING_CLASS            = model.PACKING_CLASS;
                entity.ATTRIBUTE_TRACK          = model.ATTRIBUTE_TRACK;
                entity.DAYS_TO_EXPIRE           = model.DAYS_TO_EXPIRE;
                entity.LOCATING_RULE            = model.LOCATING_RULE;
                entity.ALLOCATION_RULE          = model.ALLOCATION_RULE;
                entity.REPLENISHMENT_RULE       = model.REPLENISHMENT_RULE;
                entity.EMPTY_LOC_RULE           = model.EMPTY_LOC_RULE;
                entity.ITEM_CATEGORY1           = model.ITEM_CATEGORY1;
                entity.ITEM_CATEGORY2           = model.ITEM_CATEGORY2;
                entity.ITEM_CATEGORY3           = model.ITEM_CATEGORY3;
                entity.ITEM_CATEGORY4           = model.ITEM_CATEGORY4;
                entity.ITEM_CATEGORY5           = model.ITEM_CATEGORY5;
                entity.ITEM_CATEGORY6           = model.ITEM_CATEGORY6;
                entity.ITEM_CATEGORY7           = model.ITEM_CATEGORY7;
                entity.ITEM_CATEGORY8           = model.ITEM_CATEGORY8;
                entity.USER_STAMP               = model.USER_STAMP;
                entity.DATE_TIME_STAMP          = model.DATE_TIME_STAMP;
                entity.ACTIVE                   = model.ACTIVE;
                entity.ATTRIBUTE_TEMPLATE_NAME  = model.ATTRIBUTE_TEMPLATE_NAME;
                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;
                entity.SERIAL_NUM_TRACK         = model.SERIAL_NUM_TRACK;
                entity.SERIAL_NUM_TEMPLATE_NAME = model.SERIAL_NUM_TEMPLATE_NAME;
                entity.BRAND                    = model.BRAND;
                entity.DIVISION                 = model.DIVISION;
                entity.DEPARTMENT               = model.DEPARTMENT;
                entity.COST            = model.COST;
                entity.ITEM_SIZE       = model.ITEM_SIZE;
                entity.ITEM_COLOR      = model.ITEM_COLOR;
                entity.ITEM_STYLE      = model.ITEM_STYLE;
                entity.LIST_PRICE      = model.LIST_PRICE;
                entity.NET_PRICE       = model.NET_PRICE;
                entity.PLACE_OF_ORIGIN = model.PLACE_OF_ORIGIN;
                entity.ITEM_ATTRIBUTE1 = model.ITEM_ATTRIBUTE1;
                entity.ITEM_ATTRIBUTE2 = model.ITEM_ATTRIBUTE2;
                entity.ITEM_ATTRIBUTE3 = model.ITEM_ATTRIBUTE3;
                entity.ITEM_ATTRIBUTE4 = model.ITEM_ATTRIBUTE4;
                entity.ITEM_ATTRIBUTE5 = model.ITEM_ATTRIBUTE5;
                entity.ITEM_ATTRIBUTE6 = model.ITEM_ATTRIBUTE6;
                entity.ITEM_ATTRIBUTE7 = model.ITEM_ATTRIBUTE7;
                entity.ITEM_ATTRIBUTE8 = model.ITEM_ATTRIBUTE8;
                entity.MAINTAIN_STS    = model.MAINTAIN_STS;
            }
            else
            {
                Type type  = typeof(Apps.Models.SCV.Sys.ITEM_MODEL);
                Type typeE = typeof(Apps.Models.ITEM);
                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);
        }
Пример #3
0
        public virtual Apps.Models.SCV.Sys.ITEM_MODEL GetById(string id)
        {
            Apps.Models.ITEM entity = m_Rep.GetById(id);
            if (entity != null)
            {
                //ITEM entity = m_Rep.GetById(id);
                Apps.Models.SCV.Sys.ITEM_MODEL model = new Apps.Models.SCV.Sys.ITEM_MODEL();
                model.INTERNAL_ITEM_NUM        = entity.INTERNAL_ITEM_NUM;
                model.ITEM1                    = entity.ITEM1;
                model.COMPANY                  = entity.COMPANY;
                model.ITEM_DESC                = entity.ITEM_DESC;
                model.STORAGE_TEMPLATE         = entity.STORAGE_TEMPLATE;
                model.ITEM_CLASS               = entity.ITEM_CLASS;
                model.PACKING_CLASS            = entity.PACKING_CLASS;
                model.ATTRIBUTE_TRACK          = entity.ATTRIBUTE_TRACK;
                model.DAYS_TO_EXPIRE           = entity.DAYS_TO_EXPIRE;
                model.LOCATING_RULE            = entity.LOCATING_RULE;
                model.ALLOCATION_RULE          = entity.ALLOCATION_RULE;
                model.REPLENISHMENT_RULE       = entity.REPLENISHMENT_RULE;
                model.EMPTY_LOC_RULE           = entity.EMPTY_LOC_RULE;
                model.ITEM_CATEGORY1           = entity.ITEM_CATEGORY1;
                model.ITEM_CATEGORY2           = entity.ITEM_CATEGORY2;
                model.ITEM_CATEGORY3           = entity.ITEM_CATEGORY3;
                model.ITEM_CATEGORY4           = entity.ITEM_CATEGORY4;
                model.ITEM_CATEGORY5           = entity.ITEM_CATEGORY5;
                model.ITEM_CATEGORY6           = entity.ITEM_CATEGORY6;
                model.ITEM_CATEGORY7           = entity.ITEM_CATEGORY7;
                model.ITEM_CATEGORY8           = entity.ITEM_CATEGORY8;
                model.USER_STAMP               = entity.USER_STAMP;
                model.DATE_TIME_STAMP          = entity.DATE_TIME_STAMP;
                model.ACTIVE                   = entity.ACTIVE;
                model.ATTRIBUTE_TEMPLATE_NAME  = entity.ATTRIBUTE_TEMPLATE_NAME;
                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;
                model.SERIAL_NUM_TRACK         = entity.SERIAL_NUM_TRACK;
                model.SERIAL_NUM_TEMPLATE_NAME = entity.SERIAL_NUM_TEMPLATE_NAME;
                model.BRAND                    = entity.BRAND;
                model.DIVISION                 = entity.DIVISION;
                model.DEPARTMENT               = entity.DEPARTMENT;
                model.COST            = entity.COST;
                model.ITEM_SIZE       = entity.ITEM_SIZE;
                model.ITEM_COLOR      = entity.ITEM_COLOR;
                model.ITEM_STYLE      = entity.ITEM_STYLE;
                model.LIST_PRICE      = entity.LIST_PRICE;
                model.NET_PRICE       = entity.NET_PRICE;
                model.PLACE_OF_ORIGIN = entity.PLACE_OF_ORIGIN;
                model.ITEM_ATTRIBUTE1 = entity.ITEM_ATTRIBUTE1;
                model.ITEM_ATTRIBUTE2 = entity.ITEM_ATTRIBUTE2;
                model.ITEM_ATTRIBUTE3 = entity.ITEM_ATTRIBUTE3;
                model.ITEM_ATTRIBUTE4 = entity.ITEM_ATTRIBUTE4;
                model.ITEM_ATTRIBUTE5 = entity.ITEM_ATTRIBUTE5;
                model.ITEM_ATTRIBUTE6 = entity.ITEM_ATTRIBUTE6;
                model.ITEM_ATTRIBUTE7 = entity.ITEM_ATTRIBUTE7;
                model.ITEM_ATTRIBUTE8 = entity.ITEM_ATTRIBUTE8;
                model.MAINTAIN_STS    = entity.MAINTAIN_STS;

                return(model);
            }
            else
            {
                return(null);
            }
        }
Пример #4
0
        public virtual void Create(ref ValidationErrors errors, Apps.Models.SCV.Sys.ITEM_MODEL model)
        {
            Apps.Models.ITEM entity = m_Rep.GetById(model.INTERNAL_ITEM_NUM);
            if (entity != null)
            {
                errors.Add(Resource.PrimaryRepeat);
                return;
            }
            entity = new Apps.Models.ITEM();
            entity.INTERNAL_ITEM_NUM        = model.INTERNAL_ITEM_NUM;
            entity.ITEM1                    = model.ITEM1;
            entity.COMPANY                  = model.COMPANY;
            entity.ITEM_DESC                = model.ITEM_DESC;
            entity.STORAGE_TEMPLATE         = model.STORAGE_TEMPLATE;
            entity.ITEM_CLASS               = model.ITEM_CLASS;
            entity.PACKING_CLASS            = model.PACKING_CLASS;
            entity.ATTRIBUTE_TRACK          = model.ATTRIBUTE_TRACK;
            entity.DAYS_TO_EXPIRE           = model.DAYS_TO_EXPIRE;
            entity.LOCATING_RULE            = model.LOCATING_RULE;
            entity.ALLOCATION_RULE          = model.ALLOCATION_RULE;
            entity.REPLENISHMENT_RULE       = model.REPLENISHMENT_RULE;
            entity.EMPTY_LOC_RULE           = model.EMPTY_LOC_RULE;
            entity.ITEM_CATEGORY1           = model.ITEM_CATEGORY1;
            entity.ITEM_CATEGORY2           = model.ITEM_CATEGORY2;
            entity.ITEM_CATEGORY3           = model.ITEM_CATEGORY3;
            entity.ITEM_CATEGORY4           = model.ITEM_CATEGORY4;
            entity.ITEM_CATEGORY5           = model.ITEM_CATEGORY5;
            entity.ITEM_CATEGORY6           = model.ITEM_CATEGORY6;
            entity.ITEM_CATEGORY7           = model.ITEM_CATEGORY7;
            entity.ITEM_CATEGORY8           = model.ITEM_CATEGORY8;
            entity.USER_STAMP               = model.USER_STAMP;
            entity.DATE_TIME_STAMP          = model.DATE_TIME_STAMP;
            entity.ACTIVE                   = model.ACTIVE;
            entity.ATTRIBUTE_TEMPLATE_NAME  = model.ATTRIBUTE_TEMPLATE_NAME;
            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;
            entity.SERIAL_NUM_TRACK         = model.SERIAL_NUM_TRACK;
            entity.SERIAL_NUM_TEMPLATE_NAME = model.SERIAL_NUM_TEMPLATE_NAME;
            entity.BRAND                    = model.BRAND;
            entity.DIVISION                 = model.DIVISION;
            entity.DEPARTMENT               = model.DEPARTMENT;
            entity.COST            = model.COST;
            entity.ITEM_SIZE       = model.ITEM_SIZE;
            entity.ITEM_COLOR      = model.ITEM_COLOR;
            entity.ITEM_STYLE      = model.ITEM_STYLE;
            entity.LIST_PRICE      = model.LIST_PRICE;
            entity.NET_PRICE       = model.NET_PRICE;
            entity.PLACE_OF_ORIGIN = model.PLACE_OF_ORIGIN;
            entity.ITEM_ATTRIBUTE1 = model.ITEM_ATTRIBUTE1;
            entity.ITEM_ATTRIBUTE2 = model.ITEM_ATTRIBUTE2;
            entity.ITEM_ATTRIBUTE3 = model.ITEM_ATTRIBUTE3;
            entity.ITEM_ATTRIBUTE4 = model.ITEM_ATTRIBUTE4;
            entity.ITEM_ATTRIBUTE5 = model.ITEM_ATTRIBUTE5;
            entity.ITEM_ATTRIBUTE6 = model.ITEM_ATTRIBUTE6;
            entity.ITEM_ATTRIBUTE7 = model.ITEM_ATTRIBUTE7;
            entity.ITEM_ATTRIBUTE8 = model.ITEM_ATTRIBUTE8;
            entity.MAINTAIN_STS    = model.MAINTAIN_STS;

            m_Rep.Create(entity);
        }