Exemple #1
0
        public string AddAssetRangeItem(IMES.DataModel.AssetRangeDef item)
        {
           
            //Exception e = null;
            string id="";
            try 
            {

                //IList<AssetRangeCodeInfo> lst = itemRepository.GetDuplicateAssetRange(item.code, item.begin, item.end);
                //string msg = "";
                //foreach (AssetRangeCodeInfo check in lst)
                //{
                //    if (item.begin.Length == check.Begin.Length)
                //    {
                //        msg += check.Begin.ToString() + "~" + check.End.ToString() + Environment.NewLine; 
                //    }
                //}
                //if (msg != "")
                //{
                //    e = new Exception("重複範圍:" + msg);
                //    throw e; 
                //}

                AssetRangeInfo newInfo = new AssetRangeInfo();

                newInfo.code = item.code; //item.code.ToUpper();
                newInfo.begin = item.begin;// item.begin.ToUpper();
                newInfo.end = item.end;// item.end.ToUpper();
                newInfo.remark = item.remark;
                newInfo.editor = item.editor;
                newInfo.cdt = DateTime.Now;
                newInfo.udt = DateTime.Now;
                newInfo.status = "R";
                itemRepository.AddAssetRangeItem(newInfo);
                id = newInfo.id.ToString();
            }
            catch(Exception ee)
            {
                logger.Error(ee.Message);
                throw;
            }
            return id;

        }
Exemple #2
0
        public void UpdateAssetRangeItem(IMES.DataModel.AssetRangeDef item)
        {
            //Exception e = null;
            try
            {
                //IList<AssetRangeCodeInfo> lst = itemRepository.GetDuplicateAssetRange(item.code, item.begin, item.end);

                //if (lst.Count > 1 && item.begin.Length == lst[0].Begin.Length)
                //{
                //    string msg = "";
                //    foreach (AssetRangeCodeInfo errorrange in lst)
                //    {
                //        msg += errorrange.Begin.ToString() + "~" + errorrange.End.ToString() + Environment.NewLine;
                //    }
                //    e = new Exception("重複範圍:" + msg);
                //    throw e;
                //}
                //else if (lst.Count == 1)
                //{
                //    if (lst[0].ID != item.id && item.begin.Length == lst[0].Begin.Length)
                //    {
                //        string msg = lst[0].Begin.ToString() + "~" + lst[0].End.ToString();
                //        e = new Exception("重複範圍:" + msg);
                //        throw e;
                //    }
                //}

                AssetRangeInfo updatePo = new AssetRangeInfo();
                
                updatePo.udt = DateTime.Now;
                updatePo.id = item.id;
                updatePo.editor = item.editor;
                updatePo.code = item.code; //item.code.ToUpper();
                updatePo.begin = item.begin; //item.begin.ToUpper();
                updatePo.end = item.end; //item.end.ToUpper();
                updatePo.status = "R";
                updatePo.remark = item.remark;
                itemRepository.UpdateAssetRangeItem(updatePo);
            }
            catch (Exception ee)
            {
                logger.Error(ee.Message);
                throw;
            }

        }
Exemple #3
0
        public void CloseActiveRange(AssetRangeDef item)
        {
            if (item.status != "A")
            {
                throw new Exception("Status is not Active Status!!");
            }
            INumControlRepository numCtrlRepository = RepositoryFactory.GetInstance().GetRepository<INumControlRepository, NumControl>();
            NumControl currentMaxNum = numCtrlRepository.GetMaxValue("AST", item.code);
            if (currentMaxNum == null)
            {
                throw new Exception("No max Asset Number!!"); 
            }

            CheckAssetRange(item.code, item.begin, item.end);

            if (checkNewRange(currentMaxNum.Value, item.begin, item.end))
            {
                throw new Exception(string.Format("max number:{0}  is not between begin number:{2} and end number:{3)", currentMaxNum.Value, item.begin, item.end));
            }


            // update Asset Rnage number
            AssetRangeInfo updatePo = new AssetRangeInfo();

            updatePo.udt = DateTime.Now;
            updatePo.id = item.id;
            updatePo.editor = item.editor;
            updatePo.code = item.code; //item.code.ToUpper();
            updatePo.begin = item.begin; //item.begin.ToUpper();
            updatePo.end = currentMaxNum.Value;
            updatePo.status = "C";
            updatePo.remark = item.remark;
            itemRepository.UpdateAssetRangeItem(updatePo);
        }