/// <summary>
        /// Construct
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="management"></param>
        /// <param name="id"></param>
        /// <param name="descp"></param>
        /// <exception cref="ArgumentNullException">argument is null</exception>
        protected MasterDataBase(CoreDriver coreDriver,
                                 MasterDataManagement management, MasterDataIdentity id, String descp)
        {
            if (id == null)
            {
                throw new ArgumentNullException("Identity");
            }
            if (coreDriver == null)
            {
                throw new ArgumentNullException("CoreDriver");
            }
            if (management == null)
            {
                throw new ArgumentNullException("Management");
            }
            if (descp == null)
            {
                throw new ArgumentNullException("Description");
            }
            _coreDriver = coreDriver;
            _management = management;
            _identity   = id;

            _descp = descp;
        }
Exemple #2
0
        /// <summary>
        /// get master data
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public MasterDataBase GetMasterData(MasterDataIdentity id,
                                            MasterDataType type)
        {
            MasterDataFactoryBase factory = this.GetMasterDataFactory(type);

            return(factory.GetEntity(id));
        }
Exemple #3
0
        /// <summary>
        /// get master data with identity
        /// </summary>
        /// <param name="idStr"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        /// <exception cref="IdentityInvalidChar"></exception>
        /// <exception cref="IdentityNoData"></exception>
        /// <exception cref="IdentityTooLong"></exception>
        public MasterDataBase GetMasterData(char[] idStr, MasterDataType type)
        {
            MasterDataFactoryBase factory = this.GetMasterDataFactory(type);
            MasterDataIdentity    id      = new MasterDataIdentity(idStr);

            return(factory.GetEntity(id));
        }
Exemple #4
0
        /// <summary>
        /// Parse master data from XML
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="elem"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master Data file exception</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase ParseMasterData(CoreDriver coreDriver, XElement elem)
        {
            XAttribute id            = elem.Attribute(MasterDataUtils.XML_ID);
            XAttribute descp         = elem.Attribute(MasterDataUtils.XML_DESCP);
            XAttribute criticalLevel = elem
                                       .Attribute(MasterDataUtils.XML_CRITICAL_LEVEL);

            // check attribute
            if (criticalLevel == null)
            {
                throw new MasterDataFileFormatException(
                          MasterDataType.BUSINESS_AREA);
            }
            if (criticalLevel.Value.Length != 1 ||
                (criticalLevel.Value[0] != (char)CriticalLevel.HIGH &&
                 criticalLevel.Value[0] != (char)CriticalLevel.MEDIUM &&
                 criticalLevel.Value[0] != (char)CriticalLevel.LOW))
            {
                _coreDriver
                .logDebugInfo(this.GetType(), 154,
                              "Format of critical level is error",
                              MessageType.ERRO);
                throw new MasterDataFileFormatException(
                          MasterDataType.BUSINESS_AREA);
            }
            CriticalLevel l = (CriticalLevel)criticalLevel.Value[0];

            MasterDataIdentity identity;

            try
            {
                identity = new MasterDataIdentity(id.Value);
            }
            catch (Exception e)
            {
                _coreDriver
                .logDebugInfo(this.GetType(), 154,
                              e.Message,
                              MessageType.ERRO);
                throw new MasterDataFileFormatException(
                          MasterDataType.BUSINESS_AREA);
            }

            try
            {
                BusinessAreaMasterData businessArea = (BusinessAreaMasterData)this
                                                      .CreateNewMasterDataBase(identity, descp.Value, l);

                _coreDriver.logDebugInfo(
                    this.GetType(),
                    130,
                    String.Format("Parse business area ({0}).",
                                  businessArea.Identity.ToString()), MessageType.INFO);
                return(businessArea);
            }
            catch (Exception e)
            {
                throw new SystemException(e);
            }
        }
Exemple #5
0
        /// <summary>
        /// Create new master data
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="descp"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        /// <exception cref="ParametersException">Parameters Exception</exception>
        /// <exception cref="MasterDataIdentityExists">Duplicated master data identity exists </exception>
        /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase CreateNewMasterDataBase(MasterDataIdentity id
                                                               , string descp, params object[] objects)
        {
            if (id == null ||
                descp == null)
            {
                throw new ArgumentNullException();
            }
            if (objects.Length > 0)
            {
                throw new ParametersException(0, objects.Length);
            }

            // check identity is duplicated
            if (_list.ContainsKey(id))
            {
                throw new MasterDataIdentityExists();
            }

            BankKeyMasterData bankKey = new BankKeyMasterData(_coreDriver, _management, id, descp);

            this._containDirtyData = true;
            this._list.Add(id, bankKey);

            // raise create master data
            _coreDriver.ListenerMgmt.CreateMasterData(this, bankKey);
            _coreDriver.logDebugInfo(this.GetType(), 47,
                                     String.Format("Create bank key ({0}).", bankKey.Identity.ToString()),
                                     MessageType.INFO);
            return(bankKey);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="id"></param>
        /// <param name="descp"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        /// <exception cref="ParametersException">Parameters Exception</exception>
        /// <exception cref="MasterDataIdentityExists">Duplicated master data identity exists </exception>
        /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase CreateNewMasterDataBase(MasterDataIdentity id,
                                                               String descp, params Object[] objects)
        {
            // check parameters
            if (id == null ||
                descp == null)
            {
                throw new ArgumentNullException();
            }
            if (objects.Length != 0)
            {
                throw new ParametersException(0, objects.Length);
            }

            // check identity is duplicated
            if (_list.ContainsKey(id))
            {
                throw new MasterDataIdentityExists();
            }

            CustomerMasterData customer = new CustomerMasterData(_coreDriver, _management, id, descp);

            this._containDirtyData = true;
            this._list.Add(id, customer);

            // raise create master data
            _coreDriver.ListenerMgmt.CreateMasterData(this, customer);
            _coreDriver.logDebugInfo(this.GetType(), 84,
                                     String.Format("Create customer (%s).", customer.Identity.ToString()),
                                     MessageType.INFO);
            return(customer);
        }
        /// <summary>
        /// Parse master data from XElement
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="elem"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master Data file exception</exception>
        /// <exception cref="SystemException">Bug</exception>
        /// <exception cref="ArgumentNullException">Argument is null.</exception>
        public override MasterDataBase ParseMasterData(CoreDriver coreDriver, XElement elem)
        {
            if (coreDriver == null ||
                elem == null)
            {
                throw new ArgumentNullException();
            }
            XAttribute idAttr    = elem.Attribute(MasterDataUtils.XML_ID);
            XAttribute descpAttr = elem.Attribute(MasterDataUtils.XML_DESCP);

            try
            {
                MasterDataIdentity identity = new MasterDataIdentity(
                    idAttr.Value);
                VendorMasterData vendor = (VendorMasterData)this
                                          .CreateNewMasterDataBase(identity, descpAttr.Value);

                _coreDriver.logDebugInfo(this.GetType(), 62,
                                         String.Format("Parse vendor ({0}).", vendor.Identity.ToString()),
                                         MessageType.INFO);
                return(vendor);
            }
            catch (IdentityTooLong e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 150, e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.VENDOR);
            }
            catch (IdentityNoData e)
            {
                _coreDriver
                .logDebugInfo(this.GetType(), 154,
                              e.Message,
                              MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.VENDOR);
            }
            catch (IdentityInvalidChar e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 160,
                                         e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.VENDOR);
            }
            catch (ParametersException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 164,
                                         e.Message,
                                         MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityExists e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 168,
                                         e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.VENDOR);
            }
        }
Exemple #8
0
        /// <summary>
        /// Get entity
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">Argument is null.</exception>
        public MasterDataBase GetEntity(MasterDataIdentity id)
        {
            if (!Contains(id))
            {
                return(null);
            }

            MasterDataBase md;

            _list.TryGetValue(id, out md);
            return(md);
        }
Exemple #9
0
        /// <summary>
        /// Parse master data from XML
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="elem"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master Data file exception</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase ParseMasterData(CoreDriver coreDriver, XElement elem)
        {
            XAttribute idAttr    = elem.Attribute(MasterDataUtils.XML_ID);
            XAttribute descpAttr = elem.Attribute(MasterDataUtils.XML_DESCP);

            MasterDataIdentity identity;

            try
            {
                identity = new MasterDataIdentity(idAttr.Value);
                BankKeyMasterData bankKey = (BankKeyMasterData)this
                                            .CreateNewMasterDataBase(identity, descpAttr.Value);

                _coreDriver.logDebugInfo(this.GetType(), 61,
                                         String.Format("Parse bank key ({0}).", bankKey.Identity.ToString()),
                                         MessageType.INFO);
                return(bankKey);
            }
            catch (IdentityTooLong e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 150, e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_KEY);
            }
            catch (IdentityNoData e)
            {
                _coreDriver
                .logDebugInfo(this.GetType(), 154,
                              e.Message,
                              MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_KEY);
            }
            catch (IdentityInvalidChar e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 160, e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_KEY);
            }
            catch (ParametersException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 164,
                                         "Function parameter set error: " + e.Message,
                                         MessageType.ERRO);
                throw new SystemException(e);
            }
            catch (MasterDataIdentityExists e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 168, e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_KEY);
            }
        }
Exemple #10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="management"></param>
        /// <param name="id"></param>
        /// <param name="descp"></param>
        /// <param name="level"></param>
        /// <exception cref="ArgumentNullException">argument is null</exception>
        public override MasterDataBase CreateNewMasterDataBase(MasterDataIdentity identity,
                                                               String descp, params Object[] objects)
        {
            if (objects.Length != 1)
            {
                throw new ParametersException(1, objects.Length);
            }

            // check identity is duplicated
            if (_list.ContainsKey(identity))
            {
                throw new MasterDataIdentityExists();
            }

            if (!(objects[0] is CriticalLevel))
            {
                throw new ParametersException();
            }
            CriticalLevel l = (CriticalLevel)objects[0];

            BusinessAreaMasterData businessArea;

            try
            {
                businessArea = new BusinessAreaMasterData(_coreDriver, _management, identity,
                                                          descp, l);
            }
            catch (ArgumentNullException e)
            {
                throw new SystemException(e);
            }

            this._containDirtyData = true;
            this._list.Add(identity, businessArea);

            // raise create master data
            _coreDriver.ListenerMgmt.CreateMasterData(this,
                                                      businessArea);
            _coreDriver.logDebugInfo(
                this.GetType(),
                59,
                String.Format("Create business area (%s).",
                              businessArea.Identity.ToString()), MessageType.INFO);
            return(businessArea);
        }
        /// <summary>
        /// Construct
        /// </summary>
        /// <param name="coreDriver">Core Driver</param>
        /// <param name="management">Matadata management</param>
        /// <param name="id"></param>
        /// <param name="descp"></param>
        /// <param name="accNumber"></param>
        /// <param name="bankKey"></param>
        /// <param name="type"></param>
        /// <exception cref="ArgumentNullException">Arguments null</exception>
        /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined.</exception>
        public BankAccountMasterData(CoreDriver coreDriver, MasterDataManagement management,
                                     MasterDataIdentity id, String descp, BankAccountNumber accNumber,
                                     MasterDataIdentity bankKey, BankAccountType type)
            : base(coreDriver, management, id, descp)
        {
            _accNumber   = accNumber;
            _bankAccType = type;

            MasterDataBase bankKeyId = management.GetMasterData(bankKey,
                                                                MasterDataType.BANK_KEY);

            if (bankKeyId == null)
            {
                throw new MasterDataIdentityNotDefined(bankKey,
                                                       MasterDataType.BANK_KEY);
            }
            _bankKey = bankKeyId.GetIdentity();
        }
Exemple #12
0
        /// <summary>
        /// Set bank account
        /// </summary>
        /// <param name="bankAccount"></param>
        /// <exception cref="MasterDataIdentityNotDefined"></exception>
        public void SetBankAccount(MasterDataIdentity bankAccount)
        {
            if (bankAccount == null)
            {
                // clear
                _bankAccount = null;
                return;
            }
            MasterDataBase bankAccountId = this._management.GetMasterData(bankAccount,
                                                                          MasterDataType.BANK_ACCOUNT);

            if (bankAccountId == null)
            {
                throw new MasterDataIdentityNotDefined(bankAccount,
                                                       MasterDataType.BANK_ACCOUNT);
            }
            this.SetDirtyData();
            _bankAccount = bankAccountId.Identity;
        }
        /// <summary>
        /// set bank key
        /// </summary>
        /// <param name="bankKey"></param>
        /// <exception cref="ArgumentNullException">Arguments null</exception>
        /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined.</exception>
        public void SetBankKey(MasterDataIdentity bankKey)
        {
            if (bankKey == null)
            {
                throw new ArgumentNullException("Bank Key");
            }

            MasterDataManagement management = this._management;
            MasterDataBase       bankKeyId  = management.GetMasterData(bankKey,
                                                                       MasterDataType.BANK_KEY);

            if (bankKeyId == null)
            {
                throw new MasterDataIdentityNotDefined(bankKey,
                                                       MasterDataType.BANK_KEY);
            }

            this.SetDirtyData();
            _bankKey = bankKeyId.GetIdentity();
        }
Exemple #14
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="management"></param>
        /// <param name="id"></param>
        /// <param name="descp"></param>
        /// <param name="bankAccount"></param>
        /// <exception cref="ArgumentNullException">Argument is null.</exception>
        /// <exception cref="NoGLAccountGroupException">No such G\L account group exception</exception>
        public GLAccountMasterData(CoreDriver coreDriver,
                                   MasterDataManagement management, MasterDataIdentity_GLAccount id,
                                   String descp, MasterDataIdentity bankAccount)
            : base(coreDriver, management, id, descp)
        {
            // check id and get group
            String groupId = id.ToString().Substring(0, 4);

            try
            {
                _group = GLAccountGroup.Parse(groupId);
            }
            catch (GLAccountGroupFormatException)
            {
                throw new NoGLAccountGroupException(groupId);
            }

            if (bankAccount == null)
            {
                _bankAccount = null;
            }
            else
            {
                MasterDataBase bankAccountId = _management.GetMasterData(
                    bankAccount, MasterDataType.BANK_ACCOUNT);
                if (bankAccountId == null)
                {
                    throw new MasterDataIdentityNotDefined(bankAccount,
                                                           MasterDataType.BANK_ACCOUNT);
                }
                _bankAccount = bankAccountId.GetIdentity();
            }

            // init amount
            _initAmount = new CurrencyAmount();
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="coreDriver"></param>
 /// <param name="management"></param>
 /// <param name="id"></param>
 /// <param name="descp"></param>
 /// <param name="level"></param>
 /// <exception cref="ArgumentNullException">argument is null</exception>
 public BusinessAreaMasterData(CoreDriver coreDriver, MasterDataManagement management, MasterDataIdentity id,
                               String descp, CriticalLevel level)
     : base(coreDriver, management, id, descp)
 {
     _criticalLevel = level;
 }
Exemple #16
0
        /// <summary>
        /// Create new master data
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="descp"></param>
        /// <param name="BankAccountNumber">Bank Account Number</param>
        /// <param name="MasterDataIdentity">Bank Key</param>
        /// <returns></returns>
        /// <exception cref="ParametersException">Parameters Exception</exception>
        /// <exception cref="MasterDataIdentityExists">Duplicated master data identity exists </exception>
        /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase CreateNewMasterDataBase(
            MasterDataIdentity identity, String descp, params Object[] objects)
        {
            if (identity == null || descp == null)
            {
                throw new ArgumentNullException();
            }
            if (objects.Length != 3)
            {
                throw new ParametersException(3, objects.Length);
            }

            // check identity is duplicated
            if (_list.ContainsKey(identity))
            {
                throw new MasterDataIdentityExists();
            }

            BankAccountNumber  accNumber = null;
            MasterDataIdentity bankKey   = null;
            BankAccountType    type;

            accNumber = objects[0] as BankAccountNumber;
            if (accNumber == null)
            {
                throw new ParametersException();
            }

            bankKey = objects[1] as MasterDataIdentity;
            if (bankKey == null)
            {
                throw new ParametersException();
            }

            if (!(objects[2] is BankAccountType))
            {
                throw new ParametersException();
            }
            type = (BankAccountType)objects[2];

            try
            {
                BankAccountMasterData bankAccount = new BankAccountMasterData(_coreDriver, _management,
                                                                              identity, descp, accNumber, bankKey, type);

                // add to list
                this._list.Add(identity, bankAccount);

                this._containDirtyData = true;

                // raise create master data
                _coreDriver.ListenerMgmt
                .CreateMasterData(this, bankAccount);

                _coreDriver
                .logDebugInfo(
                    this.GetType(),
                    84,
                    String.Format("Create bank account ({0}).",
                                  bankAccount.Identity.ToString()), MessageType.INFO);
                return(bankAccount);
            }
            catch (Exception e)
            {// bug
                throw new SystemException(e);
            }
        }
Exemple #17
0
        /// <summary>
        /// Parse master data from XML
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="elem"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master Data file exception</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase ParseMasterData(CoreDriver coreDriver,
                                                       XElement elem)
        {
            XAttribute id      = elem.Attribute(MasterDataUtils.XML_ID);
            XAttribute descp   = elem.Attribute(MasterDataUtils.XML_DESCP);
            XAttribute bankKey = elem.Attribute(MasterDataUtils.XML_BANK_KEY);
            XAttribute bankAcc = elem.Attribute(MasterDataUtils.XML_BANK_ACCOUNT);
            XAttribute typeStr = elem.Attribute(MasterDataUtils.XML_TYPE);

            // check attribute
            if (bankKey == null)
            {
                _coreDriver.logDebugInfo(this.GetType(), 93, String.Format(
                                             "Mandatory Field %s with no value",
                                             MasterDataUtils.XML_BANK_KEY), MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_ACCOUNT);
            }

            if (bankAcc == null)
            {
                _coreDriver.logDebugInfo(this.GetType(), 100, String.Format(
                                             "Mandatory Field %s with no value",
                                             MasterDataUtils.XML_BANK_ACCOUNT), MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_ACCOUNT);
            }

            if (typeStr == null)
            {
                _coreDriver.logDebugInfo(this.GetType(), 114, String.Format(
                                             "Mandatory Field %s with no value",
                                             MasterDataUtils.XML_TYPE), MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_ACCOUNT);
            }

            MasterDataIdentity identity;
            MasterDataIdentity bankKeyId;
            BankAccountNumber  accNum;
            BankAccountType    type;

            if (typeStr.Value.Length != 1 ||
                (typeStr.Value[0] != (char)BankAccountType.CREDIT_CARD &&
                 typeStr.Value[0] != (char)BankAccountType.SAVING_ACCOUNT))
            {
                _coreDriver.logDebugInfo(this.GetType(), 150,
                                         "Format of bank account type is error.", MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_ACCOUNT);
            }
            type = (BankAccountType)typeStr.Value[0];

            try
            {
                identity = new MasterDataIdentity(id.Value);
                // bank key
                bankKeyId = new MasterDataIdentity(
                    bankKey.Value);
                // bank account
                accNum = new BankAccountNumber(
                    bankAcc.Value);
            }
            catch (Exception e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 150,
                                         e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.BANK_ACCOUNT);
            }


            try
            {
                BankAccountMasterData bankAccount = (BankAccountMasterData)this
                                                    .CreateNewMasterDataBase(identity, descp.Value, accNum,
                                                                             bankKeyId, type);
                _coreDriver.logDebugInfo(
                    this.GetType(),
                    130,
                    String.Format("Parse bank account (%s).",
                                  bankAccount.Identity.ToString()), MessageType.INFO);
                return(bankAccount);
            }
            catch (Exception e)
            {
                // bug
                throw new SystemException(e);
            }
        }
        /// <summary>
        /// Create new master data
        /// </summary>
        /// <param name="identity"></param>
        /// <param name="descp"></param>
        /// <param name="?"></param>
        /// <returns></returns>
        /// <exception cref="ParametersException">Parameters Exception</exception>
        /// <exception cref="MasterDataIdentityExists">Duplicated master data identity exists </exception>
        /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase CreateNewMasterDataBase(MasterDataIdentity identity,
                                                               String descp, params Object[] objects)
        {
            // check id is G/L identity
            MasterDataIdentity_GLAccount identity_gl = identity as MasterDataIdentity_GLAccount;

            if (identity_gl == null)
            {
                throw new ParametersException();
            }
            // check duplicated
            if (_list.ContainsKey(identity))
            {
                throw new MasterDataIdentityExists();
            }

            MasterDataIdentity bankAccount = null;

            if (objects.Length == 0 || objects.Length == 1)
            {
            }
            else
            {
                throw new ParametersException(1, objects.Length);
            }

            if (objects.Length == 1)
            {
                // contain bank account
                bankAccount = objects[0] as MasterDataIdentity;
                if (bankAccount == null)
                {
                    throw new ParametersException();
                }
            }

            GLAccountMasterData glAccount;

            try
            {
                glAccount = new GLAccountMasterData(_coreDriver, _management,
                                                    identity_gl, descp, bankAccount);
            }
            catch (ArgumentNullException e)
            {
                throw new SystemException(e);
            }
            catch (NoGLAccountGroupException)
            {
                throw new ParametersException();
            }

            this._containDirtyData = true;
            this._list.Add(identity_gl, glAccount);

            // raise create master data
            _coreDriver.ListenerMgmt.CreateMasterData(this, glAccount);
            _coreDriver.logDebugInfo(this.GetType(), 84,
                                     String.Format("Create G/L account ({0}).", glAccount.Identity.ToString()),
                                     MessageType.INFO);
            return(glAccount);
        }
        /// <summary>
        /// Parse master data from XML
        /// </summary>
        /// <param name="coreDriver"></param>
        /// <param name="elem"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master Data file exception</exception>
        /// <exception cref="ArgumentNullException">Argument is null</exception>
        /// <exception cref="SystemException">Bug</exception>
        public override MasterDataBase ParseMasterData(CoreDriver coreDriver, XElement elem)
        {
            XAttribute id             = elem.Attribute(MasterDataUtils.XML_ID);
            XAttribute descp          = elem.Attribute(MasterDataUtils.XML_DESCP);
            XAttribute bankAccStr     = elem.Attribute(MasterDataUtils.XML_BANK_ACCOUNT);
            XAttribute initAmountAttr = elem.Attribute(MasterDataUtils.XML_INIT_AMOUNT);

            MasterDataIdentity_GLAccount identity;
            MasterDataIdentity           bankAccId = null;

            try
            {
                identity = new MasterDataIdentity_GLAccount(
                    id.Value);

                // bank account
                if (bankAccStr != null)
                {
                    bankAccId = new MasterDataIdentity(
                        bankAccStr.Value);
                }
            }
            catch (Exception e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 150, e.Message, MessageType.ERRO);
                throw new MasterDataFileFormatException(MasterDataType.GL_ACCOUNT);
            }

            CurrencyAmount initAmount = new CurrencyAmount();

            if (initAmountAttr != null)
            {
                try
                {
                    initAmount = CurrencyAmount.Parse(initAmountAttr.Value);
                }
                catch (CurrencyAmountFormatException e)
                {
                    _coreDriver.logDebugInfo(this.GetType(), 150, e.Message, MessageType.ERRO);
                    throw new MasterDataFileFormatException(MasterDataType.GL_ACCOUNT);
                }
            }
            try
            {
                GLAccountMasterData glAccount;
                if (bankAccId == null)
                {
                    glAccount = (GLAccountMasterData)this.CreateNewMasterDataBase(
                        identity, descp.Value);
                }
                else
                {
                    glAccount = (GLAccountMasterData)this.CreateNewMasterDataBase(
                        identity, descp.Value, bankAccId);
                }
                glAccount.setInitAmountInternal(initAmount);
                _coreDriver
                .logDebugInfo(
                    this.GetType(),
                    167,
                    String.Format("Parse G/L account ({0}).",
                                  glAccount.Identity.ToString()), MessageType.INFO);
                return(glAccount);
            }
            catch (Exception e)
            {
                throw new SystemException(e);
            }
        }
Exemple #20
0
 /// <summary>
 /// Create new master data
 /// </summary>
 /// <param name="identity"></param>
 /// <param name="descp"></param>
 /// <param name="?"></param>
 /// <returns></returns>
 /// <exception cref="ParametersException">Parameters Exception</exception>
 /// <exception cref="MasterDataIdentityExists">Duplicated master data identity exists </exception>
 /// <exception cref="MasterDataIdentityNotDefined">Master data identity is not defined</exception>
 /// <exception cref="ArgumentNullException">Argument is null</exception>
 /// <exception cref="SystemException">Bug</exception>
 public abstract MasterDataBase CreateNewMasterDataBase(
     MasterDataIdentity identity, String descp, params Object[] objects);
Exemple #21
0
 /// <summary>
 /// constains key
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 /// <exception cref="ArgumentNullException">Argument is null.</exception>
 public bool Contains(MasterDataIdentity id)
 {
     return(_list.ContainsKey(id));
 }
Exemple #22
0
        /// <summary>
        /// constain master data
        /// </summary>
        /// <param name="id"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public bool ContainsMasterData(MasterDataIdentity id, MasterDataType type)
        {
            MasterDataFactoryBase factory = this.GetMasterDataFactory(type);

            return(factory.Contains(id));
        }
Exemple #23
0
 /// <summary>
 /// Construct
 /// </summary>
 /// <param name="coreDriver">Core Driver</param>
 /// <param name="management">Master Data management</param>
 /// <param name="id">Identity</param>
 /// <param name="descp">Description</param>
 /// <exception cref="ArgumentNullException">Arguments null</exception>
 public BankKeyMasterData(CoreDriver coreDriver, MasterDataManagement management, MasterDataIdentity id,
                          String descp)
     : base(coreDriver, management, id, descp)
 {
 }