Exemple #1
0
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            var MORepository = RepositoryFactory.GetInstance().GetRepository<IMORepository, MO>();
            IProductRepository prodRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

            var oldMONO = CurrentSession.GetValue(Session.SessionKeys.OldMONO).ToString();
            var newMONO = CurrentSession.GetValue(Session.SessionKeys.NewMONO).ToString();
            
            var prodNoList = (IList<string>)CurrentSession.GetValue(Session.SessionKeys.ProdNoList);

            var oldMO = MORepository.Find(oldMONO);
            var newMO = MORepository.Find(newMONO);

            short qty = (short)0;
            short.TryParse(CurrentSession.GetValue(Session.SessionKeys.Qty).ToString(), out qty);

            if (oldMO == null)
            {
                var ex = new FisException("CHK037", new string[] { oldMONO });
                throw ex;
            }
            if (newMO == null)
            {
                var ex = new FisException("CHK037", new string[] { newMONO });
                throw ex;
            }
            
            //数量检查
            if (newMO.Qty - newMO.PrtQty < qty)
            {
                var ex = new FisException("CHK072", new string[] { });
                throw ex;
            }

            oldMO.PrtQty = (short)(oldMO.PrtQty - qty);
            MORepository.Update(oldMO, CurrentSession.UnitOfWork);
            newMO.PrtQty = (short)(newMO.PrtQty + qty);
            MORepository.Update(newMO, CurrentSession.UnitOfWork);

            //2010-03-01   207006     ITC-1122-0160
            //2010-03-01   207006     ITC-1122-0170

            System.DateTime cdt = DateTime.Now;

            foreach (string item in prodNoList)
            {
                IProduct prod = prodRepository.Find(item);
                               
                              
                if (prod == null)
                {
                    var ex = new FisException("SFC002", new string[] { item });
                    throw ex;
                }
                prod.MO = newMONO;


                ProductChangeLog itemLog = new ProductChangeLog();
                itemLog.Editor = this.Editor;
                itemLog.Mo = oldMONO;
                itemLog.ProductID = item;
                itemLog.Station = prod.Status.StationId;
                itemLog.Cdt = cdt;

                prod.AddChangeLog(itemLog);
                prodRepository.Update(prod, CurrentSession.UnitOfWork);
            }

            
            return base.DoExecute(executionContext);
        }
Exemple #2
0
        /// <summary>
        /// Change Model
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
        {
            IMORepository imr = RepositoryFactory.GetInstance().GetRepository<IMORepository, MO>();
            IProductRepository ipr = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            IProduct product = (IProduct)CurrentSession.GetValue(Session.SessionKeys.Product);
            IBOMRepository ibr = RepositoryFactory.GetInstance().GetRepository<IBOMRepository, BOM>();
            string newModel = CurrentSession.GetValue(Session.SessionKeys.ModelName).ToString();
            MO newMO = null;
            MO oldMO = null;
            ProductChangeLog changeLog = null;

            //get min new MO
            //newMO = imr.GetMinUsableMO(newModel);
            //Change Model 选用MO 的方法修改为选用StartDate 最靠前的可用MO 2010-03-29
            newMO = imr.GetUsableMOOrderByStartDate(newModel);

            if (newMO == null)
            {
                //該MO已經投完,請換機型改投其他MO !!
                List<string> errpara = new List<string>();
                FisException ex = new FisException("CHK044", errpara);
                throw ex;
            }

            oldMO = imr.Find(product.MO);

            if (oldMO == null)
            {
                List<string> errpara = new List<string>();
                errpara.Add(product.MO);
                FisException ex = new FisException("CHK045", errpara);
                throw ex;
            }

            imr.IncreaseMOPrintedQtyDefered(CurrentSession.UnitOfWork, newMO, 1);
            imr.DecreaseMOPrintedQtyDefered(CurrentSession.UnitOfWork, oldMO, 1);

            //imr.Update(newMO, CurrentSession.UnitOfWork);
            //imr.Update(oldMO, CurrentSession.UnitOfWork);

            product.Model = newModel;
            product.MO = newMO.MONO;

            changeLog = new ProductChangeLog();
            changeLog.ProductID = product.ProId;
            changeLog.Mo = oldMO.MONO;
            changeLog.Station = Station;
            changeLog.Editor = Editor;
            changeLog.Cdt = DateTime.Now;

            product.AddChangeLog(changeLog);
            
            ipr.Update(product, CurrentSession.UnitOfWork);

            return base.DoExecute(executionContext);
        }
Exemple #3
0
        /// <summary>
        /// 记录Product修改记录
        /// </summary>
        /// <param name="log">Product修改记录</param>
        public void AddChangeLog(ProductChangeLog log)
        {
            if (log == null)
                return;

            lock (_syncObj_chngLogs)
            {
                if (_chngLogs == null)
                {
                    _chngLogs = new List<ProductChangeLog>();
                }

                //object naught = ChangeLogs;
                if (_chngLogs.Contains(log))
                    return;

                log.Tracker = _tracker.Merge(log.Tracker);
                _chngLogs.Add(log);
                //ProductLogs.Add(log);
                _tracker.MarkAsAdded(log);
                _tracker.MarkAsModified(this);
            }
        }