Beispiel #1
0
        /// <summary>
        /// establish master data files
        /// </summary>
        /// <returns></returns>
        public override async Task EstablishFilesAsync()
        {
            StorageFolder masterFolder = await _coreDriver.RootFolder.CreateFolderAsync(MASTER_DATA_FOLDER
                                                                                        , CreationCollisionOption.OpenIfExists);

            // establish master data files
            foreach (MasterDataType type in Enum.GetValues(typeof(MasterDataType)))
            {
                MasterDataFactoryBase newFactory;
                #region Create new factory with contructor
                switch (type)
                {
                case MasterDataType.BANK_ACCOUNT:
                    newFactory = new BankAccountMasterDataFactory(_coreDriver, this);
                    break;

                case MasterDataType.BANK_KEY:
                    newFactory = new BankKeyMasterDataFactory(_coreDriver, this);
                    break;

                case MasterDataType.BUSINESS_AREA:
                    newFactory = new BusinessAreaMasterDataFactory(_coreDriver, this);
                    break;

                case MasterDataType.CUSTOMER:
                    newFactory = new CustomerMasterDataFactory(_coreDriver, this);
                    break;

                case MasterDataType.GL_ACCOUNT:
                    newFactory = new GLAccountMasterDataFactory(_coreDriver, this);
                    break;

                case MasterDataType.VENDOR:
                    newFactory = new VendorMasterDataFactory(_coreDriver, this);
                    break;

                default:
                    throw new SystemException(new NoMasterDataFactoryClass(type));
                }
                _factoryList.Add(type, newFactory);
                #endregion

                XDocument   xdoc = newFactory.ToXmlDocument();
                StorageFile file = await getMasterFileAsync(type);

                await FileIO.WriteTextAsync(file, xdoc.ToString());
            }
        }
        /// <summary>
        /// establish master data files
        /// </summary>
        /// <returns></returns>
        public override async Task EstablishFilesAsync()
        {
            StorageFolder masterFolder = await _coreDriver.RootFolder.CreateFolderAsync(MASTER_DATA_FOLDER
                , CreationCollisionOption.OpenIfExists);

            // establish master data files
            foreach (MasterDataType type in Enum.GetValues(typeof(MasterDataType)))
            {
                MasterDataFactoryBase newFactory;
                #region Create new factory with contructor
                switch (type)
                {
                    case MasterDataType.BANK_ACCOUNT:
                        newFactory = new BankAccountMasterDataFactory(_coreDriver, this);
                        break;
                    case MasterDataType.BANK_KEY:
                        newFactory = new BankKeyMasterDataFactory(_coreDriver, this);
                        break;
                    case MasterDataType.BUSINESS_AREA:
                        newFactory = new BusinessAreaMasterDataFactory(_coreDriver, this);
                        break;
                    case MasterDataType.CUSTOMER:
                        newFactory = new CustomerMasterDataFactory(_coreDriver, this);
                        break;
                    case MasterDataType.GL_ACCOUNT:
                        newFactory = new GLAccountMasterDataFactory(_coreDriver, this);
                        break;
                    case MasterDataType.VENDOR:
                        newFactory = new VendorMasterDataFactory(_coreDriver, this);
                        break;
                    default:
                        throw new SystemException(new NoMasterDataFactoryClass(type));
                }
                _factoryList.Add(type, newFactory);
                #endregion

                XDocument xdoc = newFactory.ToXmlDocument();
                StorageFile file = await getMasterFileAsync(type);
                await FileIO.WriteTextAsync(file, xdoc.ToString());
            }
        }
        /// <summary>
        /// parse XDocument to master data factory
        /// </summary>
        /// <param name="constructor"></param>
        /// <param name="type"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master data file format Exception</exception>
        /// <exception cref="SystemException">Bug</exception>
        private MasterDataFactoryBase factoryParser(
            MasterDataType type, XDocument doc)
        {
            _coreDriver.logDebugInfo(this.GetType(), 88,
                    String.Format("Parsing XML {0}...", type), MessageType.INFO);

            // get root element
            XElement rootElem = doc.Element(MasterDataUtils.XML_ROOT);
            if (rootElem == null)
            {
                _coreDriver.logDebugInfo(this.GetType(), 112,
                        String.Format("No root element for master data {0}", type), MessageType.ERRO);
                throw new MasterDataFileFormatException(type);
            }

            MasterDataFactoryBase newFactory;
            #region Create new factory with contructor
            switch (type)
            {
                case MasterDataType.BANK_ACCOUNT:
                    newFactory = new BankAccountMasterDataFactory(_coreDriver, this);
                    break;
                case MasterDataType.BANK_KEY:
                    newFactory = new BankKeyMasterDataFactory(_coreDriver, this);
                    break;
                case MasterDataType.BUSINESS_AREA:
                    newFactory = new BusinessAreaMasterDataFactory(_coreDriver, this);
                    break;
                case MasterDataType.CUSTOMER:
                    newFactory = new CustomerMasterDataFactory(_coreDriver, this);
                    break;
                case MasterDataType.GL_ACCOUNT:
                    newFactory = new GLAccountMasterDataFactory(_coreDriver, this);
                    break;
                case MasterDataType.VENDOR:
                    newFactory = new VendorMasterDataFactory(_coreDriver, this);
                    break;
                default:
                    throw new SystemException(new NoMasterDataFactoryClass(type));
            }

            #endregion

            try
            {
                foreach (XElement xelem in rootElem.Elements())
                {
                    if (xelem.Name.LocalName.Equals(MasterDataUtils.XML_ENTITY))
                    {
                        // parse master data entity
                        MasterDataBase masterData = newFactory.ParseMasterData(
                                _coreDriver, xelem);

                        // raise load master data
                        _coreDriver.ListenerMgmt.LoadMasterData(
                                this, masterData);
                    }
                }
            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 133, e.Message,
                        MessageType.ERRO);
                throw new SystemException(e);
            }

            _coreDriver.logDebugInfo(this.GetType(), 88,
                    String.Format("Parsing XML {0} complete.", type),
                    MessageType.INFO);
            return newFactory;
        }
Beispiel #4
0
        /// <summary>
        /// parse XDocument to master data factory
        /// </summary>
        /// <param name="constructor"></param>
        /// <param name="type"></param>
        /// <param name="doc"></param>
        /// <returns></returns>
        /// <exception cref="MasterDataFileFormatException">Master data file format Exception</exception>
        /// <exception cref="SystemException">Bug</exception>
        private MasterDataFactoryBase factoryParser(
            MasterDataType type, XDocument doc)
        {
            _coreDriver.logDebugInfo(this.GetType(), 88,
                                     String.Format("Parsing XML {0}...", type), MessageType.INFO);

            // get root element
            XElement rootElem = doc.Element(MasterDataUtils.XML_ROOT);

            if (rootElem == null)
            {
                _coreDriver.logDebugInfo(this.GetType(), 112,
                                         String.Format("No root element for master data {0}", type), MessageType.ERRO);
                throw new MasterDataFileFormatException(type);
            }

            MasterDataFactoryBase newFactory;

            #region Create new factory with contructor
            switch (type)
            {
            case MasterDataType.BANK_ACCOUNT:
                newFactory = new BankAccountMasterDataFactory(_coreDriver, this);
                break;

            case MasterDataType.BANK_KEY:
                newFactory = new BankKeyMasterDataFactory(_coreDriver, this);
                break;

            case MasterDataType.BUSINESS_AREA:
                newFactory = new BusinessAreaMasterDataFactory(_coreDriver, this);
                break;

            case MasterDataType.CUSTOMER:
                newFactory = new CustomerMasterDataFactory(_coreDriver, this);
                break;

            case MasterDataType.GL_ACCOUNT:
                newFactory = new GLAccountMasterDataFactory(_coreDriver, this);
                break;

            case MasterDataType.VENDOR:
                newFactory = new VendorMasterDataFactory(_coreDriver, this);
                break;

            default:
                throw new SystemException(new NoMasterDataFactoryClass(type));
            }

            #endregion

            try
            {
                foreach (XElement xelem in rootElem.Elements())
                {
                    if (xelem.Name.LocalName.Equals(MasterDataUtils.XML_ENTITY))
                    {
                        // parse master data entity
                        MasterDataBase masterData = newFactory.ParseMasterData(
                            _coreDriver, xelem);

                        // raise load master data
                        _coreDriver.ListenerMgmt.LoadMasterData(
                            this, masterData);
                    }
                }
            }
            catch (ArgumentNullException e)
            {
                _coreDriver.logDebugInfo(this.GetType(), 133, e.Message,
                                         MessageType.ERRO);
                throw new SystemException(e);
            }

            _coreDriver.logDebugInfo(this.GetType(), 88,
                                     String.Format("Parsing XML {0} complete.", type),
                                     MessageType.INFO);
            return(newFactory);
        }