Exemple #1
0
 public AscmContainer(AscmContainer ascmContainer, string supplierName, string deadline, double extendedTime)
 {
     this.sn             = ascmContainer.sn;
     this.organizationId = ascmContainer.organizationId;
     this.createUser     = ascmContainer.createUser;
     this.createTime     = ascmContainer.createTime;
     this.modifyUser     = ascmContainer.modifyUser;
     this.modifyTime     = ascmContainer.modifyTime;
     this.rfid           = ascmContainer.rfid;
     this.specId         = ascmContainer.specId;
     this.supplierId     = ascmContainer.supplierId;
     this.place          = ascmContainer.place;
     this.status         = ascmContainer.status;
     this.description    = ascmContainer.description;
     this.storeInTime    = ascmContainer.storeInTime;
     this.isCheck        = ascmContainer.isCheck;
     this.containerSpec  = ascmContainer.containerSpec;
     this.deadline       = deadline;
     this.startSn        = ascmContainer.startSn;
     this.endSn          = ascmContainer.endSn;
     this.supplier       = ascmContainer.supplier;
     this.extendedTime   = extendedTime;
     this.SpecName       = ascmContainer.SpecName;
     this.SpecCount      = ascmContainer.SpecCount;
     this._supplierName  = supplierName;
 }
Exemple #2
0
 public AscmContainer(AscmContainer ascmContainer, string supplierName, string deadline, double extendedTime)
 {
     this.sn = ascmContainer.sn;
     this.organizationId = ascmContainer.organizationId;
     this.createUser = ascmContainer.createUser;
     this.createTime = ascmContainer.createTime;
     this.modifyUser = ascmContainer.modifyUser;
     this.modifyTime = ascmContainer.modifyTime;
     this.rfid = ascmContainer.rfid;
     this.specId = ascmContainer.specId;
     this.supplierId = ascmContainer.supplierId;
     this.place = ascmContainer.place;
     this.status = ascmContainer.status;
     this.description = ascmContainer.description;
     this.storeInTime = ascmContainer.storeInTime;
     this.isCheck = ascmContainer.isCheck;
     this.containerSpec = ascmContainer.containerSpec;
     this.deadline = deadline;
     this.startSn = ascmContainer.startSn;
     this.endSn = ascmContainer.endSn;
     this.supplier = ascmContainer.supplier;
     this.extendedTime = extendedTime;
     this.SpecName = ascmContainer.SpecName;
     this.SpecCount = ascmContainer.SpecCount;
     this._supplierName = supplierName;
 }
 public void Delete(AscmContainer ascmContainer)
 {
     try
     {
         YnDaoHelper.GetInstance().nHibernateHelper.Delete<AscmContainer>(ascmContainer);
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("删除失败(Delete AscmContainer)", ex);
         throw ex;
     }
 }
 public void Update(AscmContainer ascmContainer)
 {
     try
     {
         using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
         {
             try
             {
                 YnDaoHelper.GetInstance().nHibernateHelper.Update<AscmContainer>(ascmContainer);
                 tx.Commit();//正确执行提交
             }
             catch (Exception ex)
             {
                 tx.Rollback();//回滚
                 YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Update AscmContainer)", ex);
                 throw ex;
             }
         }
     }
     catch (Exception ex)
     {
         YnBaseClass2.Helper.LogHelper.GetLog().Error("修改失败(Save AscmContainer)", ex);
         throw ex;
     }
 }
 public string GetContainerAllInfo(string ticket, string containerSn, ref string message)
 {
     try
     {
         message = "";
         if (!IsTicketValid(ticket))
             throw new Exception("票证验证失败!");
         AscmContainer ascmContainer = MideaAscm.Services.ContainerManage.AscmContainerInfoService.GetInstance().GetAllInfo(containerSn);
         if (ascmContainer == null)
             ascmContainer = new AscmContainer();
         return YnBaseClass2.Helper.ObjectHelper.Serialize(ascmContainer);
     }
     catch (Exception ex)
     {
         message = ex.Message;
     }
     return null;
 }
        public ContentResult ContainerSave(AscmContainer ascmContainer_Model, string id)
        {
            JsonObjectResult jsonObjectResult = new JsonObjectResult();
            try
            {
                string userName = string.Empty;
                if (User.Identity.IsAuthenticated)
                {
                    userName = User.Identity.Name;
                }

                if (id != null && id.Trim() != "")
                {
                    AscmContainer ascmContainer = AscmContainerService.GetInstance().Get(id);
                    if (ascmContainer == null)
                        throw new Exception("保存容器失败!");
                    if (!string.IsNullOrEmpty(ascmContainer_Model.description))
                        ascmContainer.description = ascmContainer_Model.description.Trim();
                    ascmContainer.modifyUser = userName;
                    ascmContainer.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");

                    AscmContainerService.GetInstance().Update(ascmContainer);
                    jsonObjectResult.id = ascmContainer.sn;
                    jsonObjectResult.entity = ascmContainer;
                }
                else
                {
                    AscmContainerSpec ascmContainerSpec = AscmContainerSpecService.GetInstance().Get(ascmContainer_Model.specId);
                    if (ascmContainerSpec == null)
                        throw new Exception("容器规格不能为空!");

                    if (ascmContainer_Model.startSn == null || ascmContainer_Model.startSn.Trim() == "")
                        throw new Exception("开始编号不能为空");
                    if (ascmContainer_Model.endSn == null || ascmContainer_Model.endSn.Trim() == "")
                        throw new Exception("结束编号不能为空");
                    if (ascmContainer_Model.startSn.Trim().Length != ascmContainer_Model.endSn.Trim().Length)
                        throw new Exception("开始编号和结束编号长度不一致");
                    long startSn = 0, endSn = 0;
                    long.TryParse(ascmContainer_Model.startSn, out startSn);
                    long.TryParse(ascmContainer_Model.endSn, out endSn);
                    if (startSn == 0 || endSn == 0 || startSn > endSn)
                        throw new Exception("容器编号输入错误");
                    if (endSn - startSn + 1 > 500)
                        throw new Exception("单次添加不能超过500");
                    object object1 = YnDaoHelper.GetInstance().nHibernateHelper.GetObject("select count(*) from AscmRfid where id between '" + ascmContainer_Model.startSn.Trim() + "' and '" + ascmContainer_Model.endSn.Trim() + "'");
                    if (object1 == null)
                        throw new Exception("查询异常!");
                    int count = 0;
                    if (int.TryParse(object1.ToString(), out count) && count > 0)
                        throw new Exception("已存在编号");

                    List<AscmContainer> listAscmContainer = new List<AscmContainer>();
                    List<AscmRfid> listAscmRfid = new List<AscmRfid>();
                    for (; startSn <= endSn; startSn++)
                    {
                        AscmContainer ascmContainer = new AscmContainer();
                        string sn = string.Format("{0:000000}", startSn);//生成六位数的ID
                        ascmContainer.sn = sn;
                        ascmContainer.specId = ascmContainer_Model.specId;
                        ascmContainer.rfid = ascmContainer.sn + "000000000000000000";
                        ascmContainer.supplierId = ascmContainer_Model.supplierId;
                        if (!string.IsNullOrEmpty(ascmContainer_Model.description))
                            ascmContainer.description = ascmContainer_Model.description.Trim();
                        ascmContainer.status = ascmContainer_Model.status;
                        ascmContainer.createUser = userName;
                        ascmContainer.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        ascmContainer.modifyUser = userName;
                        ascmContainer.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        listAscmContainer.Add(ascmContainer);

                        AscmRfid ascmRfid = new AscmRfid();
                        ascmRfid.id = ascmContainer.sn;
                        ascmRfid.epcId = ascmContainer.rfid;
                        ascmRfid.createUser = userName;
                        ascmRfid.createTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        ascmRfid.modifyUser = userName;
                        ascmRfid.modifyTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm");
                        ascmRfid.bindType = AscmRfid.BindTypeDefine.container;
                        ascmRfid.bindId = ascmContainer.sn;
                        //ascmRfid.bindType = AscmRfid.BindTypeDefine.container;
                        ascmRfid.status = AscmRfid.StatusDefine.inUse;
                        listAscmRfid.Add(ascmRfid);
                    }

                    using (ITransaction tx = YnDaoHelper.GetInstance().nHibernateHelper.GetCurrentSession().BeginTransaction())
                    {
                        try
                        {
                            if (listAscmContainer.Count > 0)
                                YnDaoHelper.GetInstance().nHibernateHelper.SaveList(listAscmContainer);

                            if (listAscmRfid.Count > 0)
                                YnDaoHelper.GetInstance().nHibernateHelper.SaveOrUpdateList(listAscmRfid);

                            tx.Commit();//正确执行提交
                        }
                        catch (Exception ex)
                        {
                            tx.Rollback();//回滚
                            throw ex;
                        }
                    }
                }
                jsonObjectResult.result = true;
                jsonObjectResult.message = "";
            }
            catch (Exception ex)
            {
                jsonObjectResult.message = ex.Message;
            }
            string sReturn = JsonConvert.SerializeObject(jsonObjectResult);
            return Content(sReturn);
        }