예제 #1
0
        /// <summary>
        /// get entity
        /// </summary>
        /// <param name="docId"></param>
        /// <returns></returns>
        public HeadEntity GetEntity(DocumentIdentity docId)
        {
            MonthLedger ledger = this.GetLedger(docId._monthIdentity);

            if (ledger == null)
            {
                return(null);
            }
            return(ledger.GetEntity(docId));
        }
 /// <summary>
 /// get head entity based on document identity
 /// </summary>
 /// <param name="docId"></param>
 /// <returns></returns>
 public HeadEntity GetEntity(DocumentIdentity docId)
 {
     if (!_list.ContainsKey(docId))
     {
         return null;
     }
     HeadEntity entity;
     _list.TryGetValue(docId, out entity);
     return entity;
 }
        /// <summary>
        /// get head entity based on document identity
        /// </summary>
        /// <param name="docId"></param>
        /// <returns></returns>
        public HeadEntity GetEntity(DocumentIdentity docId)
        {
            if (!_list.ContainsKey(docId))
            {
                return(null);
            }
            HeadEntity entity;

            _list.TryGetValue(docId, out entity);
            return(entity);
        }
예제 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(Object obj)
        {
            DocumentIdentity id = obj as DocumentIdentity;

            if (id == null)
            {
                return(false);
            }
            return(id._docNumber.Equals(_docNumber) &&
                   id._monthIdentity.Equals(_monthIdentity));
        }
예제 #5
0
        /// <summary>
        /// Reverse Document
        /// </summary>
        /// <param name="docId"></param>
        /// <exception cref="SystemException"></exception>
        /// <exception cref="ReverseOrgDocNotExistException"></exception>
        /// <exception cref="DocReservedException"></exception>
        public void ReverseDocument(DocumentIdentity docId)
        {
            _coreDriver.logDebugInfo(this.GetType(), 348,
                                     "Start reversing document " + docId.ToString(),
                                     MessageType.INFO);

            // ------------------------------------------
            // check document
            HeadEntity orgHead = this.GetEntity(docId);

            if (orgHead == null)
            {
                _coreDriver.logDebugInfo(this.GetType(), 348, "No such document",
                                         MessageType.ERRO);
                throw new ReverseOrgDocNotExistException();
            }
            if (orgHead.IsReversed)
            {
                _coreDriver.logDebugInfo(this.GetType(), 348,
                                         "Document has been reserved before", MessageType.ERRO);
                throw new DocReservedException();
            }

            _coreDriver.logDebugInfo(this.GetType(), 399,
                                     "Update reverse document information", MessageType.INFO);
            // update reverse information
            orgHead._isReversed = true;

            // raise event to update balance
            _coreDriver.ListenerMgmt.ReverseDoc(orgHead);

            _coreDriver.logDebugInfo(this.GetType(), 399,
                                     "Store memory to disk during reverse document",
                                     MessageType.INFO);

            // store to file system
            this.Store(orgHead.MonthID);


            String info = String.Format("Document {0} is reversed.",
                                        orgHead.DocNumber);

            _coreDriver.logDebugInfo(this.GetType(), 416, info, MessageType.INFO);
        }
        /// <summary>
        /// Add new entity
        /// </summary>
        /// <param name="head"></param>
        internal void Add(HeadEntity head)
        {
            DocumentIdentity id = head.DocIdentity;

            _list.Add(id, head);
        }
 public void TestDocumentIdentity()
 {
     DocumentNumber docNum = new DocumentNumber(
         TestUtilities.TEST_DOC_NUM.ToCharArray());
     DocumentIdentity id = new DocumentIdentity(docNum, 2012, 07);
     String idStr = id.ToString();
     Assert.AreEqual(TestUtilities.TEST_DOC_ID, idStr);
     DocumentIdentity newId = DocumentIdentity.Parse(idStr);
     Assert.AreEqual(newId, id);
 }
 /// <summary>
 /// get entity
 /// </summary>
 /// <param name="docId"></param>
 /// <returns></returns>
 public HeadEntity GetEntity(DocumentIdentity docId)
 {
     MonthLedger ledger = this.GetLedger(docId._monthIdentity);
     if (ledger == null)
     {
         return null;
     }
     return ledger.GetEntity(docId);
 }
        /// <summary>
        /// Reverse Document
        /// </summary>
        /// <param name="docId"></param>
        /// <exception cref="SystemException"></exception>
        /// <exception cref="ReverseOrgDocNotExistException"></exception>
        /// <exception cref="DocReservedException"></exception>
        public void ReverseDocument(DocumentIdentity docId)
        {
            _coreDriver.logDebugInfo(this.GetType(), 348,
                    "Start reversing document " + docId.ToString(),
                    MessageType.INFO);

            // ------------------------------------------
            // check document
            HeadEntity orgHead = this.GetEntity(docId);
            if (orgHead == null)
            {
                _coreDriver.logDebugInfo(this.GetType(), 348, "No such document",
                        MessageType.ERRO);
                throw new ReverseOrgDocNotExistException();
            }
            if (orgHead.IsReversed)
            {
                _coreDriver.logDebugInfo(this.GetType(), 348,
                        "Document has been reserved before", MessageType.ERRO);
                throw new DocReservedException();
            }

            _coreDriver.logDebugInfo(this.GetType(), 399,
                    "Update reverse document information", MessageType.INFO);
            // update reverse information
            orgHead._isReversed = true;

            // raise event to update balance
            _coreDriver.ListenerMgmt.ReverseDoc(orgHead);

            _coreDriver.logDebugInfo(this.GetType(), 399,
                    "Store memory to disk during reverse document",
                    MessageType.INFO);

            // store to file system
            this.Store(orgHead.MonthID);


            String info = String.Format("Document {0} is reversed.",
                    orgHead.DocNumber);

            _coreDriver.logDebugInfo(this.GetType(), 416, info, MessageType.INFO);

        }