Beispiel #1
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);
        }
Beispiel #2
0
        /// <summary>
        /// 删除Part属性
        /// </summary>
        /// <param name="attr"></param>
        public void DeleteAttribute(PartInfo attr)
        {
            if (attr == null)
                return;

            lock (_syncObj_attributes)
            {
                object naught = this.Attributes;
                if (this._attributes == null)
                    return;
                int idx = 0;
                bool find = false;
                foreach (PartInfo entry in this._attributes)
                {
                    if (entry.Key.Equals(attr.Key))
                    {
                        find = true;
                        break;
                    }
                    idx++;
                }
                if (find)
                {
                    attr = this._attributes[idx];
                    attr.Tracker = null;
                    this._tracker.MarkAsDeleted(attr);
                    this._tracker.MarkAsModified(this);
                }
            }
        }
Beispiel #3
0
        public ArrayList checkCTNO(string ctno)
        {
            try
            {
                //获取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);                 
                string partno ="";
                if (partList.Count > 0)
                {
                    partno = partList[0].PN;
                }

                ArrayList retList = new ArrayList();
                retList.Add(partno);
                return retList;
            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw e;
            }
        }
Beispiel #4
0
        /// <summary>
        /// 增加Part属性
        /// </summary>
        /// <param name="attr">Part属性</param>
        public void AddAttribute(PartInfo attr)
        {
            if (attr == null)
                return;

            lock (_syncObj_attributes)
            {
                object naught = this.Attributes;
                if (this._attributes.Contains(attr))
                    return;

                attr.Tracker = this._tracker.Merge(attr.Tracker);
                this._attributes.Add(attr);
                this._tracker.MarkAsAdded(attr);
                this._tracker.MarkAsModified(this);
            }
        }
Beispiel #5
0
 /// <summary>
 /// 删除Part属性
 /// </summary>
 /// <param name="attr"></param>
 public void DeleteAttribute(PartInfo attr)
 {
     throw new NotImplementedException();
 }
Beispiel #6
0
 /// <summary>
 /// 修改partinfo数据
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="partno"></param>
 public void updatePartInfo(PartInfoMaintainInfo obj, string partno, string infoType, string infoValue)
 {
     try
     {
         PartInfo pinfo = new PartInfo();
         pinfo.PN = obj.PartNo;
         pinfo.InfoValue = obj.InfoValue;
         pinfo.InfoType = obj.InfoType;
         pinfo.Editor = obj.Editor;
         pinfo.Cdt = obj.Cdt;
         pinfo.Udt = obj.Udt;
         partRepository.UpdatePartInfo(pinfo, partno, infoType, infoValue);
     }
     catch (FisException e)
     {
         logger.Error(e.mErrmsg);
         throw e;
     }
     catch (Exception e)
     {
         logger.Error(e.Message);
         throw;
     }
 }
Beispiel #7
0
        /// <summary>
        /// 写入PartInfo表一条数据
        /// </summary>
        /// <param name="obj"></param>
        public void addPartInfo(PartInfoMaintainInfo obj)
        {
            IList<PartInfo> lstPartTypePartInfo = new List<PartInfo>();
            try
            {
                lstPartTypePartInfo = partRepository.GetLstPartInfo(obj.PartNo, obj.InfoType, obj.InfoValue);
                if (lstPartTypePartInfo != null && lstPartTypePartInfo.Count > 0)
                {
                    //已经存在具有相同infovalue的记录
                    List<string> erpara = new List<string>();
                    FisException ex;
                    ex = new FisException("DMT098", erpara);
                    throw ex;
                }
                else
                {
                    PartInfo partInfo = new PartInfo();
                    partInfo.PN = obj.PartNo;
                    partInfo.InfoType = obj.InfoType;
                    partInfo.InfoValue = obj.InfoValue;
                    partInfo.Editor = obj.Editor;
                    partInfo.Cdt = obj.Cdt;
                    partInfo.Udt = obj.Udt;
                    partRepository.AddPartInfo(partInfo);
                }


            }
            catch (FisException e)
            {
                logger.Error(e.mErrmsg);
                throw e;
            }
            catch (Exception e)
            {
                logger.Error(e.Message);
                throw;
            }
        }
Beispiel #8
0
 public void AddPartInfoForVendorCode(PartInfoMaintainInfo obj)
 {
     IList<PartInfo> lstPartTypePartInfo = new List<PartInfo>();
     try
     {
             PartInfo partInfo = new PartInfo();
             partInfo.PN = obj.PartNo;
             partInfo.InfoType = obj.InfoType;
             partInfo.InfoValue = obj.InfoValue;
             partInfo.Editor = obj.Editor;
             partInfo.Cdt = obj.Cdt;
             partInfo.Udt = obj.Udt;
             partRepository.AddPartInfo(partInfo);
        
     }
     catch (FisException e)
     {
         logger.Error(e.mErrmsg);
         throw e;
     }
     catch (Exception e)
     {
         logger.Error(e.Message);
         throw;
     }
 }