Example #1
0
        /// <summary>
        /// Clear Qty
        /// </summary>
        /// <param name="line"></param>
        /// <param name="qty"></param>
        /// <returns></returns>
        public void ClearQty(string line, string qty)
        {
            DateTime dt = Convert.ToDateTime("1900-01-01 00:00:00.000");
            PcaIctCountInfo pcaIctInfo = new PcaIctCountInfo();
            try
            {
                pcaIctInfo.cdt = DateTime.Now;
                pcaIctInfo.pdLine = line;
                pcaIctInfo.qty = Convert.ToInt32(qty);

                SqlTransactionManager.Begin();

                IMBRepository mbRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository>();
                mbRepository.UpdateQtyFromPcaIctCountByCdtAndPdLine(0, dt, line);
                mbRepository.InsertPcaIctCountInfo(pcaIctInfo);

                SqlTransactionManager.Commit();
            }
            catch (Exception)
            {
                SqlTransactionManager.Rollback();
                throw;
            }
            finally
            {
                SqlTransactionManager.Dispose();
                SqlTransactionManager.End();
            }

        }
Example #2
0
        /// <summary>
        /// 检查ECR是否存在
        /// </summary>
        /// <param name="executionContext"></param>
        /// <returns></returns>
        protected internal override ActivityExecutionStatus DoExecute(ActivityExecutionContext executionContext)
        {
            IMBRepository CurrentMBRepository = RepositoryFactory.GetInstance().GetRepository<IMBRepository, IMB>();
            lock (_syncRoot_GetSeq)
            {
                IList<int> resultList = CurrentMBRepository.GetQtyListFromPcaIctCountByCdtAndPdLine(new DateTime(1900, 1, 1, 0, 0, 0, 0), Line);
                if (resultList == null || resultList.Count == 0)
                {
                    PcaIctCountInfo newCount = new PcaIctCountInfo();
                    newCount.pdLine = Line;
                    newCount.qty = 1;
                    newCount.cdt = new DateTime(1900, 1, 1, 0, 0, 0, 0);
                    CurrentMBRepository.InsertPcaIctCountInfoDefered(CurrentSession.UnitOfWork, newCount);
                    CurrentSession.AddValue(Session.SessionKeys.Qty, 1);
                }
                else
                {
                    CurrentMBRepository.UpdateQtyFromPcaIctCountByCdtAndPdLineDefered(CurrentSession.UnitOfWork, resultList[0] + 1, new DateTime(1900, 1, 1, 0, 0, 0, 0), Line);
                    CurrentSession.AddValue(Session.SessionKeys.Qty, resultList[0] + 1);
                }

            }


            return base.DoExecute(executionContext);
        }