Exemplo n.º 1
0
        /// <summary>
        /// Generates necessary htm,xml and scripts
        /// </summary>
        /// <returns></returns>
        private bool GenerateHtmXmlAndScripts(DataPrepartion dataPreparation, UserInputs userInputs, ref ECRLevelOptions ecrOptions, Logger logger)
        {
            bool bStatus = false;

            try
            {
                //if (userInputs.DataMode == DataMode.Model)
                //{
                this._progress.Report(string.Format("Generating xml(s) from {0}...", ecrOptions.Ecrno));
                XmlGenerator xmlGenerator = new XmlGenerator(this._guid, ecrOptions, dataPreparation._dbManager);
                xmlGenerator.Generate();

                this._progress.Report(string.Format("Generating 3rd party deliverables for {0}...", ecrOptions.Ecrno));
                ThirdPartyGenerator thirdPartyGenerator = new ThirdPartyGenerator(this._guid, ecrOptions, dataPreparation._dbManager);
                thirdPartyGenerator.Generate();

                this._progress.Report(string.Format("Generating scripts for {0}...", ecrOptions.Ecrno));
                ScriptGenerator scriptGenerator = new ScriptGenerator(this._guid, ecrOptions, dataPreparation._dbManager);
                scriptGenerator.Generate();
                //}

                bStatus = true;
            }
            catch (Exception ex)
            {
                logger.WriteLogToFile("CodegenWrapper.GenerateHtmXmlAndScripts", string.Format("GenerateHtmXmlAndScripts->{0}", ex.InnerException != null ? ex.InnerException.Message : ex.Message));
            }
            return(bStatus);
        }
Exemplo n.º 2
0
        /// <summary>
        /// starts actual generation for an ecr those info has been previously saved in globalvar from setoptions function.
        /// It Finally rollbacks transaction
        /// </summary>
        /// <returns></returns>
        public bool GenerateECRDeliverables(ECRLevelOptions ecrOptions, Logger logger)
        {
            DBManager      dbManager       = null;
            DataPrepartion dataPreparation = null;

            try
            {
                dbManager       = new DBManager(this._connectionString);
                dataPreparation = new DataPrepartion(this._guid, dbManager, ref ecrOptions);

                if (this._userInputs.DataMode.Equals(DataMode.Model))
                {
                    _progress.Report("Populating Hashtables for " + ecrOptions.Ecrno + "...");
                    dataPreparation.PrepareHashTables();
                }

                List <Task> consolidatedTasks = new List <Task>();
                Task        task1             = Task.Run(() =>
                {
                    GenerateCode generateCode = new GenerateCode(dataPreparation, ref ecrOptions, this._progress);
                    generateCode.Generate(_userInputs);
                });
                consolidatedTasks.Add(task1);

                Task task2 = Task.Run(() =>
                {
                    this.GenerateHtmXmlAndScripts(dataPreparation, this._userInputs, ref ecrOptions, logger);
                });
                consolidatedTasks.Add(task2);
                Task.WaitAll(consolidatedTasks.ToArray());


                return(ecrOptions.ErrorCollection != null ? ecrOptions.ErrorCollection.Count == 0 : true);
            }
            catch (Exception ex)
            {
                Logger.WriteLogToTraceListener("Codegenwrapper->Generate->", string.Format("{0}", ex.InnerException != null ? ex.InnerException.Message : ex.Message));
                return(false);
            }
            finally
            {
                Logger.WriteLogToTraceListener("CodegenWrapper->Generate", string.Format("Rollback Transaction..."));
                if (dbManager != null && dbManager.Connection != null)
                {
                    dbManager.RollbackTransaction();
                    dbManager.Close();
                }
            }
        }