Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IList vendorCTList = new ArrayList();
            vendorCTList = (IList)CurrentSession.GetValue(Session.SessionKeys.VCodeInfoLst);

            string iecPn = (string)CurrentSession.GetValue(Session.SessionKeys.PartNo);
            string partType = "DDR";
            string dateCode = (string)CurrentSession.GetValue(Session.SessionKeys.DCode);
            string vendorDCode = null;
            string vCode = null;
            string pn151 = null;
            string editor = Editor;

            var repository = RepositoryFactory.GetInstance().GetRepository<IPartSnRepository, PartSn>();
            foreach (string vendorCT in vendorCTList)
            {
                PartSn item = new PartSn(vendorCT, iecPn, partType, vendorCT, vendorDCode, vCode, pn151, editor, dateCode);
                repository.Add(item, CurrentSession.UnitOfWork);
            }
            return base.DoExecute(executionContext);
        }
Пример #2
0
        /// <summary>
        /// 產生CT號相关逻辑
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            PartSn partSNObj = null;
            IPartSnRepository ipsr = RepositoryFactory.GetInstance().GetRepository<IPartSnRepository, PartSn>();
            List<string> lstCT = (List<string>)CurrentSession.GetValue(Session.SessionKeys.CTList);
            string iecSn = string.Empty;
            string iecPn = string.Empty;
            string partType = string.Empty;
            string vendorSN = (string)CurrentSession.GetValue(Session.SessionKeys.VendorSN);
            string vendorDCCode = (string)CurrentSession.GetValue(Session.SessionKeys.VendorDCode);
            string vCode = string.Empty;
            string pn151 = string.Empty;
            string dateCode = (string)CurrentSession.GetValue(Session.SessionKeys.DCode);//(string)CurrentSession.GetValue(Session.SessionKeys.DateCode);
            string assemblyCode = (string)CurrentSession.GetValue(Session.SessionKeys.AssemblyCode);

            vendorSN = (vendorSN == null ? string.Empty : vendorSN);
            iecPn = getIecPNByAssemblyCode(assemblyCode);
            partType = getPartTypeByPn(iecPn);

            dateCode = adjustDateCode(dateCode, partType, iecPn);

            CurrentSession.AddValue(Session.SessionKeys.PN111, iecPn);

            if (lstCT != null && lstCT.Count != 0)
            {
                foreach (string temp in lstCT)
                {
                    iecSn = temp;
                    partSNObj = new PartSn(iecSn, iecPn, partType, vendorSN, vendorDCCode, vCode, pn151, Editor, dateCode);

                    ipsr.Add(partSNObj, CurrentSession.UnitOfWork);
                }
            }

            return base.DoExecute(executionContext);
        }
Пример #3
0
        /// <summary>
        /// 產生Carton NO號相关逻辑
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override System.Workflow.ComponentModel.ActivityExecutionStatus DoExecute(System.Workflow.ComponentModel.ActivityExecutionContext executionContext)
        { 
            string ctno = (string)CurrentSession.GetValue("CTNO");
            int qty = (int)CurrentSession.GetValue("QTY");
            IProductRepository productRep = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();

            //获取Part.PartNo 和 Part.Descr
            //条件:Part.PartNo = PartInfo.PartNo and PartInfo.InfoValue=Left([CT No],5)
            //限制:Top 1
            //若Part.PartNo不存在,则报错:“错误的CT No”

            IPartRepository partRep = RepositoryFactory.GetInstance().GetRepository<IPartRepository, IPart>();
            PartInfo cond = new PartInfo();
            cond.PN = ctno.Substring(0, 5);
            IList<PartInfo> partList = partRep .GetPartInfoList(cond);                 
            PartInfo partinfo = partList[0];
            IPart part = partRep.Find(partinfo.PN);
                

            //Generate New CT No
            //方法:原[CT No] + 流水码
            //数量:Qty
            //流水码规则:
            //3位
            //31进制:0123456789BCDFGHJKLMNPQRSTVWXYZ
            //从000开始
            // 若为’ZZZ’,则报错:“流水号已用完”
            //[CT No]为前缀,若[CT No]改变,则流水码从000开始
            try
            {
                string newCtno = "";
                string maxnum = "";
                string prestr = "";
                bool addflag = false;
    
                prestr = ctno;
                // 自己管理事务开始
                //SqlTransactionManager.Begin();
                //IUnitOfWork uof = new UnitOfWork();//使用自己的UnitOfWork

                //从NumControl中获取流水号
                //GetMaxNumber
                INumControlRepository numControl = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();
                MathSequenceWithCarryNumberRule marc = new MathSequenceWithCarryNumberRule(3, "0123456789BCDFGHJKLMNPQRSTVWXYZ");

                NumControl maxObj = numControl.GetMaxNumberObj("CTNO", prestr + "{0}");
                if (maxObj != null)
                    maxnum = maxObj.Value;

                if (string.IsNullOrEmpty(maxnum))
                {
                    maxnum = "000";
                    addflag = true;
                }
                else
                {

                    string numstr = maxnum.Substring(maxnum.Length - 3);
                    long diff = marc.CalculateDifference(numstr,"ZZZ");
                    if (numstr.ToUpper() == "ZZZ" || diff < qty)
                    {
                        FisException fe = new FisException("CHK867", new string[] { });   //流水号已满!
                        throw fe;
                    }

                    numstr = marc.IncreaseToNumber(numstr, 1);
                    maxnum = numstr;
                }

                newCtno = ctno + maxnum.ToUpper();

                NumControl item = null;// new NumControl();
                if (addflag)
                {
                    item = new NumControl();
                    item.NOType = "CTNO";
                    item.Value = newCtno;
                    item.NOName = "";
                    item.Customer = "HP";
                }
                else
                {
                    item = maxObj;
                    item.Value = newCtno;
                }

                int count = 1;
                IPrintLogRepository printRep = RepositoryFactory.GetInstance().GetRepository<IPrintLogRepository, PrintLog>();
                IList<string> ctnoList = new List<string>(); 
                while(count <= qty)
                {
                    ctnoList.Add(item.Value);
                    numControl.SaveMaxNumber(item, addflag);

                    //Insert PartSN
                    //IECSN:产生的18位CT No
                    //IECPn:Step2中获取的Part.PartNo
                    //PartType:Step2中获取的Part.Descr
                    //VendorSN:输入的15码的[CT No]
                    IPartSnRepository partsnRep = RepositoryFactory.GetInstance().GetRepository<IPartSnRepository, PartSn>();
                    //PartSn(string iecSn, string iecPn, string type, string vendorSn, string vendorDCode, string vCode, string pn151, string editor, string dateCode);
                    PartSn partSn = new PartSn(newCtno, part.PN, part.Descr,ctno,"","","",this.Editor,"");
                    partsnRep.Add(partSn,CurrentSession.UnitOfWork);

                    //Insert PrintLog
                    //Name=’RCTO CT Label’
                    //BegNo=Begin [CT No]
                    //EndNo=End [CT No]
                    //Descr=[Qty]
                    var log = new PrintLog
                    {
                        Name = "RCTO CT Label",
                        BeginNo = newCtno,
                        EndNo = newCtno,
                        Descr = Convert.ToString(qty),
                        Editor = this.Editor
                    };
                    printRep.Add(log, CurrentSession.UnitOfWork);

                    //get next
                    count++;
                    addflag = false;
                    maxnum = marc.IncreaseToNumber(maxnum, 1);
                    newCtno = ctno + maxnum.ToUpper();
                    item = maxObj;
                    item.Value = newCtno;
                }             
                //uof.Commit();  //立即提交UnitOfWork更新NumControl里面的最大值
                //SqlTransactionManager.Commit();//提交事物,释放行级更新锁 
             
                CurrentSession.AddValue("CTNOList", ctnoList);
                
            }
            catch (Exception)
            {
                //SqlTransactionManager.Rollback();
                throw;
            }
            finally
            {
                //SqlTransactionManager.Dispose();
                //SqlTransactionManager.End();
            }
            
            return base.DoExecute(executionContext);
        }