예제 #1
0
        public void Deletes(int[] ids)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    foreach (int id in ids)
                    {
                        PartBorrowReturn       pbr     = this.m_UnitOfWork.GetRepositoryBase <PartBorrowReturn>().Get(id);
                        IList <PartBorrowItem> pbiList = this.m_UnitOfWork.GetRepositoryBase <PartBorrowItem>().Query().Where(p => p.BorrowID == pbr.BorrowID && p.PartID == pbr.PartID).ToList();
                        if (pbiList.Count > 0)
                        {
                            PartBorrowItem pbi = pbiList[0];
                            pbi.ReturnNum = pbi.ReturnNum - pbr.ReturnNum;
                            this.m_UnitOfWork.GetRepositoryBase <PartBorrowItem>().Update(pbi, null);
                        }

                        PartInfo part = this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Get(pbr.PartID);
                        part.Inventory -= pbr.ReturnNum;
                        this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Update(part, null);
                        tx.Commit();
                        base.Delete(pbr);
                    }
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #2
0
 public override void Delete(object[] ids)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             CarLendItem carLendItem = null;
             CarService  carService  = new CarService(this.m_UnitOfWork);
             foreach (object id in ids)
             {
                 carLendItem = this.Get(id);
                 if (carLendItem != null)
                 {
                     if (carLendItem.BackTime != null)
                     {
                         throw new Exception("已回厂记录不能删除");
                     }
                     carService.ChangeCarStatus(carLendItem.CarID, CarStatus.AllowShipCar);
                 }
                 this.Delete(carLendItem);
             }
             tx.Commit();
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
예제 #3
0
        public void UpdateSettlement(Settlement settlement, IList <SettlementItem> items)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    this.Update(settlement, HttpContext.Current.Request.Form);

                    if (settlement.SettlementItems == null || settlement.SettlementItems.Count == 0)
                    {
                        settlement = this.Get(settlement.ID);
                    }
                    SettlementItem submitedItem;
                    //子项只更新价格字段
                    foreach (var item in settlement.SettlementItems)
                    {
                        submitedItem = items.Where(i => i.ID == item.ID).FirstOrDefault();
                        if (submitedItem != null)
                        {
                            item.UnitPrice     = submitedItem.UnitPrice;
                            item.PumpPrice     = submitedItem.PumpPrice ?? 0;
                            item.SlurryPrice   = submitedItem.SlurryPrice ?? 0;
                            item.IdentityPrice = submitedItem.IdentityPrice ?? 0;
                        }
                    }
                    this.Update(settlement, null);
                    tx.Commit();
                }
                catch
                {
                    tx.Rollback();
                    throw;
                }
            }
        }
예제 #4
0
 public void AddSettlement(Settlement settlement, IList <SettlementItem> items)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             //var itemRepo = this.m_UnitOfWork.GetRepositoryBase<SettlementItem>();
             IRepositoryBase <SettlementItem> SettlementItem = this.m_UnitOfWork.GetRepositoryBase <SettlementItem>();
             //settlement.SettlementItems = items;
             Settlement tmp = this.Add(settlement);
             foreach (SettlementItem item in items)
             {
                 item.SettlementId = tmp.ID;
                 SettlementItem.Add(item);
                 this.m_UnitOfWork.Flush();
             }
             tx.Commit();
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
예제 #5
0
        /// <summary>
        /// 增加物资借用记录时修改物资库存、借用数量
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override GoodsBorrow Add(GoodsBorrow entity)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    IRepositoryBase <GoodsInfo> GoodsInfoResp = this.m_UnitOfWork.GetRepositoryBase <GoodsInfo>();
                    GoodsInfo goodsInfo = GoodsInfoResp.Get(entity.GoodsID);

                    goodsInfo.BorrowNum  += entity.BorrowNum;
                    goodsInfo.ContentNum -= entity.BorrowNum;
                    goodsInfo.tPrice      = goodsInfo.uPrice * goodsInfo.ContentNum;

                    GoodsInfoResp.Update(goodsInfo, null);
                    GoodsBorrow obj = base.Add(entity);
                    tx.Commit();
                    return(obj);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #6
0
 public static void Transaction(IsolationLevel level, Action transactional)
 {
     using (UnitOfWork.Start())
     {
         // If we are already in a transaction, don't start a new one
         if (UnitOfWork.Current.IsInActiveTransaction)
         {
             transactional();
         }
         else
         {
             IGenericTransaction tx = UnitOfWork.Current.BeginTransaction(level);
             try
             {
                 transactional();
                 tx.Commit();
             }
             catch
             {
                 tx.Rollback();
                 throw;
             }
             finally
             {
                 tx.Dispose();
             }
         }
     }
 }
예제 #7
0
        public bool ChangeSilo(string S_SiloID, string D_SiloID, string[] ids)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    foreach (string id in ids)
                    {
                        ConsMixprop     obj  = this.m_UnitOfWork.GetRepositoryBase <ConsMixprop>().Get(id);
                        ConsMixpropItem tmp1 = this.Query().Where(p => p.ConsMixpropID == id && p.SiloID == S_SiloID).First();
                        decimal         val1 = tmp1.Amount;
                        ConsMixpropItem tmp2 = this.Query().Where(p => p.ConsMixpropID == id && p.SiloID == D_SiloID).First();
                        decimal         val2 = tmp2.Amount;

                        tmp1.Amount = val2;
                        tmp2.Amount = val1;
                        this.Update(tmp1);
                        this.Update(tmp2);
                    }
                    tx.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #8
0
        public override void Delete(object[] ids)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    ThreadID      tid;
                    PublicService ps = new PublicService();

                    foreach (string id in ids)
                    {
                        IList <ProductRecordItem> items = this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Query().Where(m => m.ProductRecordID == id).ToList();
                        foreach (ProductRecordItem iitem in items)
                        {
                            this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Delete(iitem);

                            tid             = new ThreadID();
                            tid.currentDate = DateTime.Now;
                            tid.typeID      = iitem.StuffID; //主材id
                            tid.typename    = "0";           //主材
                            ps.ThreadID.Add(tid);
                        }
                    }

                    base.Delete(ids);
                    //tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw new Exception(ex.Message);
                }
            }
        }
예제 #9
0
        /// <summary>
        /// CustMixprop表数据导入到ConsMixprop表
        /// </summary>
        /// <param name="sid">CustMixprop表主键ID</param>
        /// <returns></returns>
        public bool CU2CO(string sid, string did)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    CustMixprop            obj    = this.m_UnitOfWork.GetRepositoryBase <CustMixprop>().Get(sid);
                    IConsMixpropRepository m_cons = this.m_UnitOfWork.ConsMixpropRepository;
                    IList <ProductLine>    plList = this.m_UnitOfWork.GetRepositoryBase <ProductLine>()
                                                    .Query()
                                                    .Where(m => m.IsUsed)
                                                    .ToList();
                    ConsMixprop newobj = new ConsMixprop();
                    foreach (ProductLine pl in plList)
                    {
                        ConsMixprop tempobj = new ConsMixprop();
                        if (did.Length > 0)
                        {
                            tempobj.ID = did;
                        }
                        tempobj.ConStrength   = obj.ConStrength;
                        tempobj.FormulaID     = obj.ID;
                        tempobj.IsSlurry      = obj.CementType == "混凝土" ? false : true;
                        tempobj.ImpGrade      = obj.ImpGrade;
                        tempobj.SCRate        = obj.SCRate;
                        tempobj.ProductLineID = pl.ID;

                        newobj = m_cons.Add(tempobj);

                        IList <CustMixpropItem> list = obj.CustMixpropItems;
                        foreach (CustMixpropItem item in list)
                        {
                            foreach (SiloProductLine sp in pl.SiloProductLines)
                            {
                                ConsMixpropItem temp = new ConsMixpropItem();
                                temp.ConsMixprop   = tempobj;
                                temp.ConsMixpropID = tempobj.ID;
                                if (sp.Silo.StuffInfo.StuffType.ID == item.StuffInfo.StuffType.ID)
                                {
                                    temp.Amount = (decimal)item.Amount * (decimal)sp.Rate;
                                    temp.Silo   = sp.Silo;
                                    temp.SiloID = sp.Silo.ID;
                                    this.m_UnitOfWork.GetRepositoryBase <ConsMixpropItem>().Add(temp);
                                }
                            }
                        }
                    }
                    tx.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Formula表数据导入到CustMixprop表
        /// </summary>
        /// <param name="sid">Formula表主键ID</param>
        /// <returns></returns>
        public bool FO2CU(string sid, string did)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    Formula     obj    = this.Get(sid);
                    CustMixprop newobj = new CustMixprop();
                    if (did.Length > 0)
                    {
                        newobj.ID = did;
                    }
                    newobj.CarpRadii   = obj.CarpRadii;
                    newobj.CementType  = obj.CementType;
                    newobj.ConStrength = obj.ConStrength;
                    newobj.ImpGrade    = obj.ImpGrade;
                    newobj.Mesh        = obj.Mesh;
                    newobj.MixpropCode = obj.FormulaName;
                    newobj.SCRate      = obj.SCRate;
                    newobj.Slump       = obj.Slump;
                    newobj.WCRate      = obj.WCRate;
                    newobj.Weight      = obj.Weight;

                    newobj = this.m_UnitOfWork.GetRepositoryBase <CustMixprop>().Add(newobj);

                    IList <FormulaItem> list  = obj.FormulaItems;
                    IList <StuffInfo>   slist = this.m_UnitOfWork.GetRepositoryBase <StuffInfo>().Query().Where(m => m.IsUsed).ToList();
                    foreach (FormulaItem item in list)
                    {
                        foreach (StuffInfo stuff in slist)
                        {
                            if (stuff.StuffTypeID.ToString() == item.StuffTypeID.ToString())
                            {
                                CustMixpropItem temp = new CustMixpropItem();
                                temp.Amount         = item.StuffAmount;
                                temp.StandardAmount = item.StandardAmount;
                                temp.CustMixprop    = newobj;
                                temp.CustMixpropID  = newobj.ID;
                                temp.StuffInfo      = stuff;
                                temp.StuffID        = stuff.ID;
                                this.m_UnitOfWork.GetRepositoryBase <CustMixpropItem>().Add(temp);
                            }
                        }
                    }
                    tx.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #11
0
        /// <summary>
        /// CustMixprop表数据导入到Formula表
        /// </summary>
        /// <param name="sid">CustMixprop表主键ID</param>
        /// <returns></returns>
        public bool CU2FO(string sid, string did)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    CustMixprop obj    = this.m_UnitOfWork.GetRepositoryBase <CustMixprop>().Get(sid);
                    Formula     newobj = new Formula();
                    if (did.Length > 0)
                    {
                        newobj.ID = did;
                    }
                    newobj.CarpRadii   = obj.CarpRadii;
                    newobj.CementType  = obj.CementType;
                    newobj.ConStrength = obj.ConStrength;
                    newobj.ImpGrade    = obj.ImpGrade;
                    newobj.Mesh        = obj.Mesh;
                    newobj.FormulaName = obj.MixpropCode;
                    newobj.SCRate      = obj.SCRate;
                    newobj.Slump       = obj.Slump;
                    newobj.WCRate      = obj.WCRate;
                    newobj.Weight      = obj.Weight;
                    newobj             = this.m_UnitOfWork.GetRepositoryBase <Formula>().Add(newobj);

                    IList <CustMixpropItem> list = obj.CustMixpropItems;
                    foreach (CustMixpropItem item in list)
                    {
                        IList <StuffType> slist = this.m_UnitOfWork.GetRepositoryBase <StuffType>().All();
                        foreach (StuffType stype in slist)
                        {
                            if (item.StuffInfo.StuffType.ID == stype.ID)
                            {
                                FormulaItem temp = new FormulaItem();
                                temp.StandardAmount = item.StandardAmount ?? 0;
                                temp.StuffAmount    = item.Amount ?? 0;
                                temp.StuffType      = stype;
                                temp.StuffTypeID    = stype.ID;
                                temp.Formula        = newobj;
                                temp.FormulaID      = newobj.ID;
                                this.m_UnitOfWork.GetRepositoryBase <FormulaItem>().Add(temp);
                            }
                        }
                    }
                    tx.Commit();
                    return(true);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #12
0
        public override ProductRecordItem Add(ProductRecordItem entity)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    var ProductRecord = this.m_UnitOfWork.GetRepositoryBase <ProductRecord>().Get(entity.ProductRecordID);
                    var consMixpropID = this.m_UnitOfWork.GetRepositoryBase <ShippingDocument>().Get(ProductRecord.ShipDocID).ConsMixpropID;
                    var amount        = this.m_UnitOfWork.GetRepositoryBase <ConsMixpropItem>().Query().
                                        Where(a => a.ConsMixpropID == consMixpropID && a.SiloID == entity.SiloID).Select(a => a.Amount).FirstOrDefault();

                    entity.TheoreticalAmount = amount * ProductRecord.ProduceCube;
                    decimal tempActualAmount = entity.ActualAmount != null?Convert.ToDecimal(entity.ActualAmount) : 0;

                    decimal tempTheoreticalAmount = entity.TheoreticalAmount != null?Convert.ToDecimal(entity.TheoreticalAmount) : 0;

                    if (tempTheoreticalAmount != 0)
                    {
                        entity.ErrorValue = Math.Round(((tempActualAmount - tempTheoreticalAmount) / tempTheoreticalAmount * 100), 2);
                    }
                    else
                    {
                        entity.ErrorValue = 0;
                    }
                    IRepositoryBase <StuffInfo> stuffinfoRepository = this.m_UnitOfWork.GetRepositoryBase <StuffInfo>();
                    Silo      silo      = this.m_UnitOfWork.GetRepositoryBase <Silo>().Get(entity.SiloID);
                    StuffInfo stuffinfo = stuffinfoRepository.Get(entity.StuffID);
                    silo.Content        -= tempActualAmount;
                    stuffinfo.Inventory -= tempActualAmount;
                    this.m_UnitOfWork.GetRepositoryBase <Silo>().Update(silo, null);
                    stuffinfoRepository.Update(stuffinfo, null);
                    //this.m_UnitOfWork.Flush();
                    ProductRecordItem obj = base.Add(entity);

                    ThreadID      tid;
                    PublicService ps = new PublicService();
                    tid             = new ThreadID();
                    tid.currentDate = DateTime.Now;
                    tid.typeID      = entity.StuffID; //主材id
                    tid.typename    = "0";            //主材
                    ps.ThreadID.Add(tid);

                    tx.Commit();

                    return(obj);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #13
0
        /// <summary>
        /// 分装
        /// </summary>
        /// <param name="sourceShipDocID"></param>
        /// <param name="sourceCube"></param>
        /// <param name="returnType"></param>
        /// <param name="returnReason"></param>
        /// <param name="carIDArr"></param>
        /// <param name="carCubeArr"></param>
        /// <returns></returns>
        public bool Split(string sourceShipDocID, decimal sourceCube, string returnType, string returnReason, string[] carIDArr, string[] carCubeArr, string[] actionTypeArr)
        {
            lock (obj)
            {
                using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
                {
                    try
                    {
                        DateTime ts = DateTime.Now;
                        for (int i = 0; i < carIDArr.Length; ++i)
                        {
                            if (!string.IsNullOrEmpty(carIDArr[i]) && !string.IsNullOrEmpty(carCubeArr[i]) && !string.IsNullOrEmpty(actionTypeArr[i]))
                            {
                                TZRalation tz = new TZRalation();
                                tz.SourceShipDocID = sourceShipDocID;
                                tz.SourceCube      = sourceCube;
                                tz.ReturnType      = returnType;
                                tz.CarID           = carIDArr[i];
                                tz.Cube            = Decimal.Parse(carCubeArr[i]);
                                tz.ActionType      = actionTypeArr[i];

                                if (tz.ActionType == Model.Enums.ActionType.Reject)
                                {
                                    tz.IsCompleted = true;
                                }
                                else
                                {
                                    tz.IsCompleted = false;
                                }
                                tz.AH           = Model.Enums.Consts.Handle;
                                tz.ReturnReason = returnReason;

                                tz.ActionTime = ts;
                                tz.ActionCube = tz.Cube;
                                tz.IsLock     = "1";//锁定

                                base.Add(tz);
                            }
                        }

                        tx.Commit();
                        return(true);
                    }
                    catch (Exception e)
                    {
                        tx.Rollback();
                        logger.Error(e.Message, e);;
                    }
                }
                return(false);
            }
        }
예제 #14
0
 /// <summary>
 /// 批量审核
 /// </summary>
 /// <param name="ids"></param>
 public virtual void BatchAudit(object[] ids)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             TEntity entity = null;
             Type    type   = null;
             foreach (object id in ids)
             {
                 entity = this.Get(id);
                 if (entity != null)
                 {
                     type = entity.GetType();
                     if (null != type.GetProperty("IsAudit"))
                     {
                         type.GetProperty("IsAudit").SetValue(entity, true, null);
                     }
                     if (null != type.GetProperty("AuditStatus"))
                     {
                         if (type.GetProperty("AuditStatus").PropertyType.FullName == "System.Int32")
                         {
                             type.GetProperty("AuditStatus").SetValue(entity, AuditStatus.Pass, null);
                         }
                         else if (type.GetProperty("AuditStatus").PropertyType.FullName == "System.Boolean")
                         {
                             type.GetProperty("AuditStatus").SetValue(entity, true, null);
                         }
                     }
                     if (null != type.GetProperty("AuditTime"))
                     {
                         type.GetProperty("AuditTime").SetValue(entity, DateTime.Now, null);
                     }
                     if (null != type.GetProperty("Auditor"))
                     {
                         type.GetProperty("Auditor").SetValue(entity, AuthorizationService.CurrentUserID, null);
                     }
                     this.Update(entity, null);
                 }
             }
             tx.Commit();
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
예제 #15
0
        /// <summary>
        /// 审核
        /// </summary>
        /// <param name="id"></param>
        /// <param name="sp"></param>
        /// <param name="price"></param>
        /// <param name="Guige"></param>
        /// <param name="supplyNum"></param>
        /// <param name="stuffid"></param>
        public void Audit(string id, StockPact sp, decimal price, string Guige, decimal supplyNum, string stuffid)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    StuffIn obj = this.Get(id);
                    if (obj.Lifecycle == 0)
                    {
                        //if (obj.StuffID == sp.StuffID && obj.SupplyID == sp.SupplyID)
                        if (obj.StuffID == stuffid && obj.SupplyID == sp.SupplyID)
                        {
                            if (Guige != "")
                            {
                                obj.Guige = Guige;
                            }
                            obj.Proportion = (obj.Proportion == 0 ? 1 : obj.Proportion);
                            obj.FootNum    = obj.InNum / obj.Proportion;
                            obj.SupplyNum  = supplyNum * 1000;
                            decimal bc = obj.SupplyNum - Convert.ToDecimal(obj.FootNum);
                            obj.Bangcha      = bc;
                            obj.FinalFootNum = obj.FootNum;
                            if (sp.BangchaRate > 0)
                            {
                                if (sp.BangchaRate * obj.FootNum >= bc)
                                {
                                    obj.FinalFootNum = obj.SupplyNum;
                                }
                            }
                            obj.UnitPrice   = price;
                            obj.TotalPrice  = price * obj.FinalFootNum / 1000;
                            obj.StockPactID = sp.ID;
                            obj.Lifecycle   = 1;
                            base.Update(obj, null);
                        }
                    }

                    tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #16
0
        /// <summary>
        /// Flush the transaction by trying to commit and if nothing goes wrong then you're good.
        /// If commit goes wrong, the transaction will rollback the database
        /// </summary>
        /// <param name="isolationLevel">level of isolation for the transaction to flush</param>
        public void TransactionalFlush(IsolationLevel isolationLevel)
        {
            IGenericTransaction tx = BeginTransaction(isolationLevel);

            try
            {
                tx.Commit();
            }
            catch
            {
                tx.Rollback();
                throw;
            }
            finally
            {
                tx.Dispose();
            }
        }
예제 #17
0
 /// <summary>
 /// 根据消息实体发送消息(非系统消息,手动发送)
 /// </summary>
 /// <param name="MsgObj">组合的消息实体</param>
 /// <param name="UserList">指定的用户列表,数组(此列表的用户必须是系统中的用户,否则无法打开)</param>
 /// <returns></returns>
 public bool SendMsg(SystemMsg MsgObj, string[] UserList)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             SystemMsg sm = this.Add(MsgObj);
             DispatchMsg(sm, UserList);
             tx.Commit();
             return(true);
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
예제 #18
0
        public bool Import(string id)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    bool result = true;

                    ProductRecord          obj     = this.Get(id);
                    ShippingDocument       shipdoc = this.m_UnitOfWork.ShippingDocumentRepository.Get(obj.ShipDocID);
                    ConsMixprop            cm      = this.m_UnitOfWork.ConsMixpropRepository.Get(shipdoc.ConsMixpropID);
                    List <ConsMixpropItem> list    = this.m_UnitOfWork.ConsMixpropItemRepository.Query().Where(m => m.ConsMixpropID == cm.ID && m.Amount > 0).ToList();

                    ThreadID      tid;
                    PublicService ps = new PublicService();
                    foreach (ConsMixpropItem c in list)
                    {
                        ProductRecordItem tmp = new ProductRecordItem();
                        tmp.ActualAmount      = obj.ProduceCube * c.Amount;
                        tmp.TheoreticalAmount = obj.ProduceCube * c.Amount;
                        tmp.SiloID            = c.SiloID;
                        tmp.StuffID           = c.Silo.StuffInfo.ID;
                        tmp.ProductRecordID   = id;
                        tmp.ErrorValue        = 0;
                        tmp.ProductLineID     = obj.ProductLineID;
                        this.m_UnitOfWork.GetRepositoryBase <ProductRecordItem>().Add(tmp);

                        tid             = new ThreadID();
                        tid.currentDate = DateTime.Now;
                        tid.typeID      = tmp.StuffID; //主材id
                        tid.typename    = "0";         //主材
                        ps.ThreadID.Add(tid);
                    }
                    tx.Commit();
                    return(result);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw new Exception(ex.Message);
                }
            }
        }
예제 #19
0
        public void Audit(string id)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    StuffIn obj = this.Get(id);
                    if (obj.Lifecycle == 0)
                    {
                        //Silo silo = this.m_UnitOfWork.GetRepositoryBase<Silo>().Get(obj.SiloID);
                        //decimal baseStore = silo.Content;
                        //silo.Content += obj.InNum;
                        //this.m_UnitOfWork.GetRepositoryBase<Silo>().Update(silo,null);
                        //StuffInfo stuff = this.m_UnitOfWork.GetRepositoryBase<StuffInfo>().Get(obj.StuffID);
                        //stuff.Inventory += obj.InNum;
                        //this.m_UnitOfWork.GetRepositoryBase<StuffInfo>().Update(stuff, null);
                        //this.m_UnitOfWork.Flush();
                        obj.TotalPrice = obj.SupplyNum * obj.UnitPrice / 1000;
                        obj.Lifecycle  = 1;
                        base.Update(obj, null);

                        //添加入库记录
                        //SiloLedgerContent_InAndCheck slc = new SiloLedgerContent_InAndCheck();
                        //slc.SiloID = obj.SiloID;
                        //slc.StuffID = obj.StuffID;
                        //slc.Action = "手动入库";
                        //slc.BaseStore = baseStore;
                        //slc.Num = obj.InNum;
                        //slc.Remaining = silo.Content;
                        //slc.ActionTime = DateTime.Now;
                        //slc.UserName = AuthorizationService.CurrentUserName;
                        //this.m_UnitOfWork.GetRepositoryBase<SiloLedgerContent_InAndCheck>().Add(slc);
                    }

                    tx.Commit();
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
        public void Commit(System.Data.IsolationLevel isolationLevel)
        {
            IGenericTransaction tx = BeginTransaction(isolationLevel);

            try
            {
                //forces a flush of the current unit of work
                tx.Commit();
            }
            catch
            {
                tx.Rollback();
                throw;
            }
            finally
            {
                tx.Dispose();
            }
        }
예제 #21
0
 /// <summary>
 /// 移至回收站(单个)
 /// </summary>
 /// <param name="id">消息编号</param>
 /// <returns></returns>
 public bool Trash(Int32 id)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             MyMsg mm = this.Get(id);
             mm.DealStatus = -1;
             base.Update(mm, null);
             tx.Commit();
             return(true);
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
예제 #22
0
 /// <summary>
 /// 标记为已读
 /// </summary>
 /// <param name="id">消息编号</param>
 /// <returns></returns>
 public bool SetRead(Int32 id, bool isRead = true)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             MyMsg mm = this.Get(id);
             mm.IsRead = isRead;
             base.Update(mm, null);
             tx.Commit();
             return(true);
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
예제 #23
0
        public void TransactionalFlush(IsolationLevel isolationLevel)
        {
            IGenericTransaction tx = BeginTransaction(isolationLevel);

            try
            {
                //forces a flush of the current unit of work
                tx.Commit();
            }
            catch (Exception ex)
            {
                tx.Rollback();
                throw;
            }
            finally
            {
                tx.Dispose();
            }
        }
예제 #24
0
 public override PartBorrowItem Add(PartBorrowItem entity)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             PartInfo part = this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Get(entity.PartID);
             part.Inventory -= entity.BorrowNum;
             this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Update(part, null);
             tx.Commit();
             return(base.Add(entity));
         }
         catch (Exception ex)
         {
             tx.Rollback();
             logger.Error(ex.Message);
             throw;
         }
     }
 }
예제 #25
0
 /// <summary>
 /// 删除对象组
 /// </summary>
 /// <param name="ids"></param>
 public virtual void Delete(object[] ids)
 {
     using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
     {
         try
         {
             TEntity entity = null;
             foreach (object id in ids)
             {
                 entity = this.Get(id);
                 this.Delete(entity);
             }
             tx.Commit();
         }
         catch
         {
             tx.Rollback();
             throw;
         }
     }
 }
예제 #26
0
        /// <summary>
        /// 车辆加油--修改
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="form"></param>
        public override void Update(CarOil entity, System.Collections.Specialized.NameValueCollection form)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    //获取油料密度值
                    PublicService ps     = new PublicService();
                    SysConfig     config = ps.SysConfig.GetSysConfig(Model.Enums.SysConfigEnum.OilDensity);
                    if (config == null)
                    {
                        config.ConfigValue = "0";
                    }

                    //entity.TotalPrice = entity.Amount * entity.UnitPrice;
                    entity.KiloMeter = entity.ThisKM - entity.LastKM;

                    decimal newAmount = entity.Amount;
                    var     obj       = this.Get(entity.ID);
                    decimal subAmount = newAmount - obj.Amount * Convert.ToDecimal(config.ConfigValue);

                    base.Update(entity, form);

                    obj.StuffInfo.Inventory -= subAmount;
                    StuffInfoService stuffService = new StuffInfoService(this.m_UnitOfWork);
                    stuffService.Update(obj.StuffInfo, null);

                    obj.Silo.Content -= subAmount;

                    SiloService siloService = new SiloService(this.m_UnitOfWork);
                    siloService.Update(obj.Silo, null);
                    tx.Commit();
                }
                catch
                {
                    tx.Rollback();
                    throw;
                }
            }
        }
예제 #27
0
        public bool SetUnComplete(string contractID)
        {
            Contract contract = this.Get(contractID);

            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    contract.ContractStatus = "2";
                    this.Update(contract, null);
                    tx.Commit();
                    return(true);
                }
                catch
                {
                    tx.Rollback();
                    return(false);

                    throw;
                }
            }
        }
예제 #28
0
        public override void Update(PartBorrowReturn entity, System.Collections.Specialized.NameValueCollection form)
        {
            using (IGenericTransaction tx = this.m_UnitOfWork.BeginTransaction())
            {
                try
                {
                    IList <PartBorrowReturn> pbrList = this.m_UnitOfWork.GetRepositoryBase <PartBorrowReturn>().Query().Where(p => p.ID == entity.ID).ToList();
                    PartBorrowReturn         pbr     = pbrList[0];
                    if (pbr.ReturnNum != entity.ReturnNum)
                    {
                        decimal count = entity.ReturnNum - pbr.ReturnNum;
                        IList <PartBorrowItem> pbiList = this.m_UnitOfWork.GetRepositoryBase <PartBorrowItem>().Query().Where(p => p.BorrowID == pbr.BorrowID && p.PartID == pbr.PartID).ToList();
                        if (pbiList.Count > 0)
                        {
                            PartBorrowItem pbi = pbiList[0];
                            pbi.ReturnNum = pbi.ReturnNum + count;
                            this.m_UnitOfWork.GetRepositoryBase <PartBorrowItem>().Update(pbi, null);
                        }



                        PartInfo part = this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Get(pbr.PartID);
                        part.Inventory += count;
                        this.m_UnitOfWork.GetRepositoryBase <PartInfo>().Update(part, null);
                    }



                    tx.Commit();
                    base.Update(entity, form);
                }
                catch (Exception ex)
                {
                    tx.Rollback();
                    logger.Error(ex.Message);
                    throw;
                }
            }
        }
예제 #29
0
        public void TransactionalFlush(IsolationLevel isolationLevel)
        {
            // $$$$$$$$$$$$$$$$ gns: take this, when making thread safe! $$$$$$$$$$$$$$
            //IUoWTransaction tx = UnitOfWork.Current.BeginTransaction(isolationLevel);

            IGenericTransaction tx = BeginTransaction(isolationLevel);

            try
            {
                //forces a flush of the current unit of work
                tx.Commit();
            }
            catch
            {
                tx.Rollback();
                throw;
            }
            finally
            {
                tx.Dispose();
            }
        }
예제 #30
0
        public int UpdateStatus(string DispatchID)
        {
            IGenericTransaction transaction = base.m_UnitOfWork.BeginTransaction();

            try
            {
                Remindinfo[] objs = this.Query().Where(m => m.DispatchID == DispatchID).ToArray();
                //设置状态
                foreach (Remindinfo obj in objs)
                {
                    obj.Status = "1";
                    base.Update(obj);
                }
                transaction.Commit();
                return(1);
            }
            catch
            {
                transaction.Rollback();
                return(0);
            }
        }
예제 #31
0
 void transaction_TransactionCommitted(object sender, EventArgs e)
 {
     currentTransaction = null;
 }
예제 #32
0
        /// <summary>
        /// Begins a new storage-transaction
        /// </summary>
        public IGenericTransaction BeginTransaction()
        {
            if (TheresAnActiveTransaction()) { throw new InvalidOperationException(ErrorMessages.TransactionAlreadyStarted); };

            var transaction = new NHibernateTransaction(Session.BeginTransaction());
            transaction.TransactionRolledBack += transaction_TransactionRolledBack;
            transaction.TransactionCommitted += transaction_TransactionCommitted;

            currentTransaction = transaction;

            MakeActive();
            return currentTransaction;
        }
예제 #33
0
 /// <summary>
 /// Ends the NHibernate session.
 /// </summary>
 protected virtual void EndSession()
 {
     if (TheresAnActiveTransaction()) { currentTransaction.Dispose(); }
     if (Session != null) { Session.Dispose(); }
     currentTransaction = null;
     Session = null;
 }
예제 #34
0
        /// <summary>
        /// Ends the current active storage-transaction committing the changes
        /// </summary>
        public void CommitTransaction()
        {
            if (!TheresAnActiveTransaction()) { throw new InvalidOperationException(ErrorMessages.TransactionNotStarted); };

            currentTransaction.Commit();
            currentTransaction = null;
        }