コード例 #1
0
        /// <summary>
        /// </summary>		
        protected override SequencialNumberRanges getSequence(Session sess, string preSeqStr, int quantity, bool seqRestart, ISequenceConverter seqCvt)
        {
            SequencialNumberRanges ret = new SequencialNumberRanges();

            //IProductRepository pdtRepository = RepositoryFactory.GetInstance().GetRepository<IProductRepository, IProduct>();
            INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();

            string type = GetClass();
            //string subruleName = GetClass();
            
            lock (_syncRoot_GetSeq)
            {
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
                {
                    try
                    {
                        SqlTransactionManager.Begin();

                        bool insOrUpd = true;
                        //string maxMo = pdtRepository.GetMaxProductId(preSeqStr);
                        string maxMo = numCtrlRepository.GetMaxNumber(GeneratesConstants.MappingToStandard(type), preSeqStr, this.Customer);
                        string seq = string.Empty;
                        SequencialNumberSegment cnbs = new SequencialNumberSegment();
                        if (string.IsNullOrEmpty(maxMo))
                        {
                            seq = seqCvt.NumberRule.MinNumber;
                            insOrUpd = true;
                        }
                        else
                        {
                            seq = this.CutOutSeq(preSeqStr, maxMo);
                            insOrUpd = false;
                        }

                        cnbs.NumberBegin = seqCvt.Convert(string.Format(preSeqStr, seqCvt.NumberRule.IncreaseToNumber(seq, 1)));
                        cnbs.NumberEnd = seqCvt.Convert(string.Format(preSeqStr, seqCvt.NumberRule.IncreaseToNumber(seq, quantity)));

                        //pdtRepository.SetMaxProductId((string)sess.GetValue(Session.SessionKeys.SMTMONO), cnbs.NumberEnd);
                        numCtrlRepository.SaveMaxNumber(GetANumControl(GeneratesConstants.MappingToStandard(type), string.Empty/*subruleName*/, cnbs.NumberEnd, this.Customer), insOrUpd, preSeqStr);
                        ret.Ranges = new SequencialNumberSegment[] { (SequencialNumberSegment)cnbs };

                        SqlTransactionManager.Commit();
                    }
                    catch (Exception)
                    {
                        SqlTransactionManager.Rollback();
                        throw;
                    }
                    finally
                    {
                        SqlTransactionManager.Dispose();
                        SqlTransactionManager.End();
                    }
                }
            }
            return ret;
        }
コード例 #2
0
ファイル: BaseAcquireActivity.cs プロジェクト: wra222/testgit
        //protected string GetClassStr()
        //{
        //    return Enum.GetName(typeof(GeneratesConstants), GetClass());
        //}

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sess"></param>
        /// <param name="preSeqStr"></param>
        /// <param name="quantity"></param>
        /// <param name="seqRestart"></param>
        /// <param name="seqCvt"></param>
        /// <returns></returns>
        protected abstract SequencialNumberRanges getSequence(Session sess, string preSeqStr, int quantity, bool seqRestart, ISequenceConverter seqCvt);
コード例 #3
0
ファイル: BaseAcquireActivity.cs プロジェクト: wra222/testgit
 /// <summary>
 /// 
 /// </summary>
 /// <param name="snrs"></param>
 /// <param name="seqCvt"></param>
 /// <param name="qty"></param>
 /// <param name="preSeqStr"></param>
 /// <returns></returns>
 protected List<string> GetAllNumbersInRange(SequencialNumberRanges snrs, ISequenceConverter seqCvt, int qty, string preSeqStr)
 {
     List<string> ret = new List<string>();
     ret.Add(snrs.Ranges[0].NumberBegin);
     for (int i = 0; i < qty - 2; i++)
     {
         ret.Add(string.Format(preSeqStr, seqCvt.NumberRule.IncreaseToNumber(this.CutOutSeq(preSeqStr, ret.Last<string>()), 1)));// 2010-01-07 Liu Dong(eB1-4)         Modify ITC-1103-0058
     }
     if (qty > 1)// 2010-01-07 Liu Dong(eB1-4)         Modify ITC-1103-0040
         ret.Add(snrs.Ranges[0].NumberEnd);
     return ret;
 }
コード例 #4
0
        protected override SequencialNumberRanges getSequence(Session sess, string preSeqStr, int quantity, bool seqRestart, ISequenceConverter seqCvt)
        {
            SequencialNumberRanges ret = new SequencialNumberRanges();

            //IMBMORepository mbmoRepository = RepositoryFactory.GetInstance().GetRepository<IMBMORepository, IMBMO>();
            INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();
          
            string type = GetClass();
            //string subruleName = GetClass();

            lock (_syncRoot_GetSeq)
            {
              
                using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Suppress))
                {
                    try
                    {
                        SqlConnectionManager.Begin();

                        bool insOrUpd = true;
                        //string maxMo = mbmoRepository.GetMaxMO(preSeqStr);//((bool)Session.GetValue(Session.SessionKeys.IsExperiment));
                        string maxMo = numCtrlRepository.GetMaxNumber(GeneratesConstants.MappingToStandard(type), preSeqStr);//, this.Customer);//2011-09-27 不考虑Customer
                    
                        string seq = string.Empty;
                        SequencialNumberSegment cnbs = new SequencialNumberSegment();
                        if (string.IsNullOrEmpty(maxMo))
                        {
                            seq = seqCvt.NumberRule.MinNumber;
                            cnbs.NumberBegin = seqCvt.Convert(string.Format(preSeqStr, seqCvt.NumberRule.IncreaseToNumber(seq, 0)));
                            cnbs.NumberEnd = seqCvt.Convert(string.Format(preSeqStr, seqCvt.NumberRule.IncreaseToNumber(seq, quantity - 1)));
                            insOrUpd = true;
                       //     NumControl a = new NumControl(0,,,,,,);
                        //    numCtrlRepository.Add(a,CurrentSession.UnitOfWork); 
                        }
                        else
                        {
                            seq = this.CutOutSeq(preSeqStr, maxMo);
                            cnbs.NumberBegin = seqCvt.Convert(string.Format(preSeqStr, seqCvt.NumberRule.IncreaseToNumber(seq, 1)));
                            cnbs.NumberEnd = seqCvt.Convert(string.Format(preSeqStr, seqCvt.NumberRule.IncreaseToNumber(seq, quantity)));
                            insOrUpd = false;
                            //get data
                            //numCtrlRepository.Find(
                        }

                        //mbmoRepository.SetMaxMO((bool)CurrentSession.GetValue(Session.SessionKeys.IsExperiment), GetAMBMO(sess, cnbs.NumberEnd, this.Editor, quantity));
                        //Model _MInfo = (Model)CurrentSession.GetValue(Session.SessionKeys.ModelObj);
                       // numCtrlRepository.SaveMaxNumber(GetANumControl(GeneratesConstants.MappingToStandard(type), _MInfo.ModelName /*subruleName*/, cnbs.NumberEnd, this.Customer), insOrUpd, preSeqStr);

                        numCtrlRepository.SaveMaxNumberWithOutByCustomer(GetANumControl(GeneratesConstants.MappingToStandard(type), string.Empty/*subruleName*/, cnbs.NumberEnd, this.Customer), insOrUpd, preSeqStr);//2011-09-27 不考虑Customer
                        ret.Ranges = new SequencialNumberSegment[] { (SequencialNumberSegment)cnbs };
                         
                        // Check Customer SN Range By Model

                        //Model modelObj = (Model)CurrentSession.GetValue(Session.SessionKeys.ModelObj);
                        //string strSeqNo = cnbs.NumberEnd.Substring(6, 6);
                        //string strBeginCustSnNo = modelObj.GetAttribute("StartUnitID’ ");
                        //string strEndCustSnNo = modelObj.GetAttribute("EndUnitID");
                        //if (strBeginCustSnNo == null | strEndCustSnNo == null)
                        //{
                         
                        //    throw new Exception(" The Customer SN range by MODEL not define!");
                        //}
                        //if (int.Parse(strSeqNo) < int.Parse(strBeginCustSnNo) | int.Parse(strSeqNo) > int.Parse(strEndCustSnNo))
                        //{
                        //    throw new Exception(" The Customer SN out of range of this MODEL!");
                        
                        //}
                        // Check Customer SN Range By Model

                        SqlConnectionManager.Commit();
                    }
                    catch (Exception)
                    {
                        SqlConnectionManager.Rollback();
                        throw;
                    }
                    finally
                    {
                        SqlConnectionManager.Dispose();
                        SqlConnectionManager.End();
                        scope.Complete();
                    }
             
            }
            }
            return ret;
        }