private PFList <RandomName> GetCurrentRandomNames(PFList <DataTableRandomizerColumnSpec> colSpecs, PFList <PFList <RandomName> > randomNameLists)
        {
            PFList <RandomName> currentRandomNames = new PFList <RandomName>();

            currentRandomNames.Clear();

            for (int nameInx = 0; nameInx < randomNameLists.Count; nameInx++)
            {
                PFList <RandomName> randNames = randomNameLists[nameInx];
                int        randNum            = _randNumber.GenerateRandomInt(0, randNames.Count - 1);
                RandomName randName           = randNames[randNum];
                currentRandomNames.Add(randName);
            }

            for (int specInx = 0; specInx < colSpecs.Count; specInx++)
            {
                DataTableRandomizerColumnSpec spec = colSpecs[specInx];
                //if (spec.RandomDataType == enRandomDataType.RandomNamesAndLocationsFile)
                //{
                //    spec.CurrentValueIndex = spec.RandomDataListIndex;
                //}
            }

            return(currentRandomNames);
        }
        private PFList <string> GetCurrentRandomDataValues(PFList <DataTableRandomizerColumnSpec> colSpecs, PFList <PFList <string> > randomDataValueLists)
        {
            PFList <string> currentRandomDataValues = new PFList <string>();

            currentRandomDataValues.Clear();

            for (int valInx = 0; valInx < randomDataValueLists.Count; valInx++)
            {
                PFList <string> randDataValues  = randomDataValueLists[valInx];
                int             randNum         = _randNumber.GenerateRandomInt(0, randDataValues.Count - 1);
                string          randStringValue = randDataValues[randNum];
                currentRandomDataValues.Add(randStringValue);
            }

            for (int specInx = 0; specInx < colSpecs.Count; specInx++)
            {
                DataTableRandomizerColumnSpec spec = colSpecs[specInx];
                if (spec.RandomDataType == enRandomDataType.CustomRandomValues)
                {
                    spec.CurrentValueIndex = spec.RandomDataListIndex;
                }
            }

            return(currentRandomDataValues);
        }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="dt">DataTable object containing data to be randomized.</param>
 /// <param name="randomizerRequests">List of specifications for which columns to randomize and values to use in the randomizing.</param>
 /// <param name="randomizerNameSpecs">Object containing various criteria for determining types of random names and locations to include.</param>
 public TEST_DataTableRandomizer(DataTable dt, PFList <DataTableRandomizerColumnSpec> randomizerRequests, RandomNamesAndLocationsDataRequest randomizerNameSpecs)
 {
     _dt = dt;
     _randomizerColumnSpecs = randomizerRequests;
     _randomizerNameSpecs   = randomizerNameSpecs;
     DllMessageLogExt.WriteLine("TEST_DataTableRandomizer allocated ...");
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Method to convert table definitions from another database format to the data format supported by the destination database class.
        /// </summary>
        /// <param name="tableDefs">Object containing the list of table definitions to be converted.</param>
        /// <param name="destinationDatabase">Database object pointing to database that will define converted table definitions.</param>
        /// <param name="newSchemaName">Specify a new schema (owner) name for the tables when they are recreated in the database managed by the current instance.</param>
        /// <returns>Object containing the list of table definitions after they have been converted to match the data formats of the current instance.</returns>
        public PFList <PFTableDef> ConvertTableDefs(PFList <PFTableDef> tableDefs, IDatabaseProvider destinationDatabase, string newSchemaName)
        {
            PFList <PFTableDef> newTableDefs = new PFList <PFTableDef>();
            PFTableDef          tabDef       = null;
            string tabName            = string.Empty;
            string schemaName         = string.Empty;
            string tabCreateStatement = string.Empty;

            tableDefs.SetToBOF();

            while ((tabDef = tableDefs.NextItem) != null)
            {
                string     tabDefXmlString = tabDef.ToXmlString();
                PFTableDef newTabDef       = PFTableDef.LoadFromXmlString(tabDefXmlString);

                tabName    = destinationDatabase.RebuildFullTableName(tabDef, newSchemaName);
                schemaName = String.IsNullOrEmpty(newSchemaName) == false ? newSchemaName : tabDef.TableOwner;
                newTabDef.TableObject.TableName = tabName;
                tabCreateStatement             = destinationDatabase.BuildTableCreateStatement(newTabDef.TableObject);
                newTabDef.DbPlatform           = destinationDatabase.DbPlatform;
                newTabDef.DbConnectionString   = destinationDatabase.ConnectionString;
                newTabDef.TableOwner           = schemaName;
                newTabDef.TableFullName        = tabName;
                newTabDef.TableCreateStatement = tabCreateStatement;
                newTableDefs.Add(newTabDef);
            }

            return(newTableDefs);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates and initializes an instance of the class by loading a serialized version of the instance from a database record.
        /// </summary>
        /// <param name="connectionString">Connection parameters for the database.</param>
        /// <param name="listName">Name of the list in the database.</param>
        /// <returns>PFListEx object.</returns>
        public PFList <T> LoadFromDatabase(string connectionString, string listName)
        {
            string       sqlStmt        = string.Empty;
            PFList <T>   objectInstance = null;
            PFDatabase   db             = new PFDatabase(DatabasePlatform.SQLServerCE35);
            DbDataReader rdr            = null;
            string       pfKeyListExXml = string.Empty;

            db.ConnectionString = connectionString;
            db.OpenConnection();

            sqlStmt = _listsSelectSQL.Replace("<listname>", listName);
            rdr     = db.RunQueryDataReader(sqlStmt, CommandType.Text);
            while (rdr.Read())
            {
                pfKeyListExXml = rdr.GetString(0);
                objectInstance = PFList <T> .LoadFromXmlString(pfKeyListExXml);

                break;  //should be only one record
            }

            db.CloseConnection();
            db = null;


            if (objectInstance == null)
            {
                objectInstance = new PFList <T>();
            }

            return(objectInstance);
        }
        private void GenerateSyntaxArrayCode(string arrayName, PFList <string> syntaxDefsList, int modulusNum)
        {
            _str.Length = 0;
            _str.Append(_declareArrayBegin.Replace("<array_name>", arrayName));
            _str.Append(_declareArraryBegin2);
            int maxListInx = syntaxDefsList.Count - 1;

            for (int listInx = 0; listInx <= maxListInx; listInx++)
            {
                if ((listInx % modulusNum) == 0)
                {
                    if (listInx > 0)
                    {
                        _str.Append(Environment.NewLine);
                    }
                    _str.Append(_declareArrayIndent);
                }
                string template = RemoveDiacritics(syntaxDefsList[listInx]);
                template = template.TrimEnd();
                if (listInx < maxListInx)
                {
                    _str.Append(_declareArrayNode.Replace("<node_value>", template));
                }
                else
                {
                    _str.Append(_declareArrayNode.Replace("<node_value>", template).Replace(",", ""));
                }
            }
            _str.Append(Environment.NewLine);
            _str.Append(_declareArrayEnd);
            _str.Append(Environment.NewLine);
            _str.Append(Environment.NewLine);
            WriteMessageToLog(_str.ToString());
            //File.AppendAllText(outputFile, _str.ToString());
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Retrieves the object for a specific schedule.
        /// </summary>
        /// <param name="scheduleName">Name of the schedule to get.</param>
        /// <returns>Schedule object.</returns>
        public PFSchedule GetScheduleByName(string scheduleName)
        {
            PFList <PFSchedule> scheduleList = null;
            PFSchedule          schedule     = null;

            if (this.ScheduleStorageType == enScheduleStorageType.XMLFiles)
            {
                scheduleList = GetScheduleListXML();
            }
            else if (this.ScheduleStorageType == enScheduleStorageType.Database)
            {
                scheduleList = GetScheduleListDatabase();
            }
            else
            {
                _msg.Length = 0;
                _msg.Append("Invalid or missing ScheduleStorageType: ");
                _msg.Append(this.ScheduleStorageType.ToString());
                throw new System.Exception(_msg.ToString());
            }

            _scheduleList = scheduleList;

            for (int i = 0; i < scheduleList.Count; i++)
            {
                if (scheduleName.ToUpper() == scheduleList[i].Name.ToUpper())
                {
                    schedule = scheduleList[i];
                    break;
                }
            }

            return(schedule);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Retrieves the object for a specific task.
        /// </summary>
        /// <param name="taskName">Name of task the to get.</param>
        /// <returns>Task object.</returns>
        public PFTask GetTaskByName(string taskName)
        {
            PFList <PFTask> taskList = null;
            PFTask          task     = null;

            if (this.TaskStorageType == enTaskStorageType.XMLFiles)
            {
                taskList = GetTaskListXML();
            }
            else if (this.TaskStorageType == enTaskStorageType.Database)
            {
                taskList = GetTaskListDatabase();
            }
            else
            {
                _msg.Length = 0;
                _msg.Append("Invalid or missing TaskStorageType: ");
                _msg.Append(this.TaskStorageType.ToString());
                throw new System.Exception(_msg.ToString());
            }

            _taskList = taskList;

            for (int i = 0; i < taskList.Count; i++)
            {
                if (taskName.ToUpper() == taskList[i].TaskName.ToUpper())
                {
                    task = taskList[i];
                    break;
                }
            }

            return(task);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Runs the table create statements contained in the provided tableDefs object.
        /// </summary>
        /// <param name="destinationDatabase">Database object pointing to database where tables will be created.</param>
        /// <param name="tableDefs">Object containing list of table definitions.</param>
        /// <param name="dropBeforeCreate">If true and table already exists, table will be dropped and then recreated using the table definition in the supplied PFTableDefs list. If false, table create step is bypassed if table already exists.</param>
        /// <returns>Number of tables created.</returns>
        public int CreateTablesFromTableDefs(IDatabaseProvider destinationDatabase, PFList <PFTableDef> tableDefs, bool dropBeforeCreate)
        {
            int        numTablesCreated = 0;
            PFTableDef td           = null;
            string     sqlStatement = string.Empty;

            tableDefs.SetToBOF();

            while ((td = tableDefs.NextItem) != null)
            {
                if (destinationDatabase.TableExists(td) && dropBeforeCreate)
                {
                    destinationDatabase.DropTable(td);
                }

                if (destinationDatabase.TableExists(td) == false)
                {
                    sqlStatement = td.TableCreateStatement;
                    destinationDatabase.RunNonQuery(sqlStatement, CommandType.Text);
                    numTablesCreated++;
                }
            }

            return(numTablesCreated);
        }
Ejemplo n.º 10
0
        //properties

        //methods

        /// <summary>
        /// Saves the public property values contained in the current instance to the database specified by the connection string.
        /// </summary>
        /// <param name="list">List object that will be saved to the database.</param>
        /// <param name="connectionString">Contains information needed to open the database.</param>
        /// <param name="listName">Name of the list in the database.</param>
        public void SaveToDatabase(PFList <T> list, string connectionString, string listName)
        {
            string     sqlStmt         = string.Empty;
            PFDatabase db              = new PFDatabase(DatabasePlatform.SQLServerCE35);
            int        numRecsAffected = 0;
            DateTime   currdate        = DateTime.Now;
            string     currBatchId     = string.Empty;
            string     listObject      = string.Empty;

            db.ConnectionString = connectionString;
            db.OpenConnection();

            //create batch id for this list
            currBatchId = "'" + Guid.NewGuid().ToString().Trim() + "'";

            listObject = list.ToXmlString().Replace("'", "");   //get rid of any single quotes in the object. they will mess up the sql syntax e.g. values(1, 'two' ,'this is the 'object'')

            //insert current list to the database
            sqlStmt         = _listsInsertSQL.Replace("<listname>", listName).Replace("<id>", currBatchId).Replace("<listobject>", listObject);
            numRecsAffected = db.RunNonQuery(sqlStmt, CommandType.Text);

            //get rid of any previous PFListEx objects in the database
            sqlStmt         = _listsDeleteOldSQL.Replace("<listname>", listName).Replace("<id>", currBatchId);
            numRecsAffected = db.RunNonQuery(sqlStmt, CommandType.Text);


            db.CloseConnection();
            db = null;
        }
Ejemplo n.º 11
0
        public static void GetScheduleListDatabase(MainForm frm)
        {
            PFList <PFSchedule> scheduleList = null;
            PFScheduleManager   sm           = null;
            string connectionString          = string.Empty;

            try
            {
                _msg.Length = 0;
                _msg.Append("GetScheduleListDatabase started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                InitFolderPaths();

                connectionString = _taskDefsDbConnectionString;

                sm = new PFScheduleManager(enScheduleStorageType.Database, connectionString);

                scheduleList = sm.GetScheduleList();

                if (scheduleList == null)
                {
                    _msg.Length = 0;
                    _msg.Append("No schedules found in ");
                    _msg.Append(connectionString);
                    throw new System.Exception(_msg.ToString());
                }

                _msg.Length = 0;
                _msg.Append("Number of schedule definitions found: ");
                _msg.Append(scheduleList.Count.ToString("#,##0"));
                _msg.Append("\r\n");
                _msg.Append("Database: ");
                _msg.Append(connectionString);
                _msg.Append("\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                for (int i = 0; i < scheduleList.Count; i++)
                {
                    _msg.Length = 0;
                    _msg.Append(scheduleList[i].Name);
                    Program._messageLog.WriteLine(_msg.ToString());
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... GetScheduleListDatabase finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
Ejemplo n.º 12
0
        public static void GetTaskListXml(MainForm frm)
        {
            PFList <PFTask> taskList         = null;
            PFTaskManager   tm               = null;
            string          connectionString = string.Empty;

            try
            {
                _msg.Length = 0;
                _msg.Append("GetTaskListXml started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                InitFolderPaths();

                connectionString = _taskDefinitionsFolder;

                tm = new PFTaskManager(enTaskStorageType.XMLFiles, connectionString);

                taskList = tm.GetTaskList();

                if (taskList == null)
                {
                    _msg.Length = 0;
                    _msg.Append("No tasks found in ");
                    _msg.Append(connectionString);
                    throw new System.Exception(_msg.ToString());
                }

                _msg.Length = 0;
                _msg.Append("Number of sked definitions found: ");
                _msg.Append(taskList.Count.ToString("#,##0"));
                _msg.Append("\r\n");
                _msg.Append("Folder: ");
                _msg.Append(connectionString);
                _msg.Append("\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                for (int i = 0; i < taskList.Count; i++)
                {
                    _msg.Length = 0;
                    _msg.Append(taskList[i].TaskName + ".xml");
                    Program._messageLog.WriteLine(_msg.ToString());
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... GetTaskListXml finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Writes data contained in ADO.NET DataTable object to path stored in OutputFileName property.
        /// </summary>
        /// <param name="dtList">List of temp file names containing data tables with grid rows to be output.</param>
        /// <param name="fxlDataLine">Object containing column definitions for the line.</param>
        /// <returns>True if output operation is successful. False if write fails.</returns>
        /// <remarks> fxlDataLine object can be used to override column lengths in data table.</remarks>
        public bool WriteDataToOutput(PFList <string> dtList, PFFixedLengthDataLine fxlDataLine)
        {
            bool      success = true;
            DataTable dt      = new DataTable();

            try
            {
                if (File.Exists(_outputFileName))
                {
                    if (_replaceExistingFile)
                    {
                        File.SetAttributes(_outputFileName, FileAttributes.Normal);
                        File.Delete(_outputFileName);
                    }
                    else
                    {
                        _msg.Length = 0;
                        _msg.Append("File exists and ReplaceExistingFile set to False. Write to Output has failed.");
                        throw new System.Exception(_msg.ToString());
                    }
                }
                _textOutFile.OpenFile(_outputFileName, PFFileOpenOperation.OpenFileForWrite);
                _exporter.returnResultAsString += WriteFixedLengthFileOutputLine;

                for (int dtInx = 0; dtInx < dtList.Count; dtInx++)
                {
                    dt.Rows.Clear();
                    dt.ReadXml(dtList[dtInx]);
                    _exporter.DefaultStringColumnLength = this.ColumnWidthForStringData;
                    _exporter.MaxColumnLengthOverride   = this.MaximumAllowedColumnWidth;
                    if (dtInx == 0)
                    {
                        _exporter.ExtractFixedLengthDataFromTable(fxlDataLine, dt, _useLineTerminator, _columnNamesOnFirstLine, _allowDataTruncation, (int)0, _lineTerminatorChars);
                    }
                    else
                    {
                        _exporter.ExtractFixedLengthDataFromTable(fxlDataLine, dt, _useLineTerminator, false, _allowDataTruncation, (int)0, _lineTerminatorChars);
                    }
                }
            }
            catch (System.Exception ex)
            {
                success     = false;
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                throw new System.Exception(_msg.ToString());
            }
            finally
            {
                if (_textOutFile.FileIsOpen)
                {
                    _textOutFile.CloseFile();
                }
            }

            return(success);
        }
        /// <summary>
        /// Writes data contained in ADO.NET DataTable object to path stored in OutputFileName property.
        /// </summary>
        /// <param name="dtList">List of temp file names pointing to XML files containing data table data to be output.</param>
        /// <returns>True if output operation is successful. False if write fails.</returns>
        public bool WriteDataToOutput(PFList <string> dtList)
        {
            bool      success = true;
            DataTable dt      = new DataTable();

            try
            {
                if (File.Exists(_outputFileName))
                {
                    if (_replaceExistingFile)
                    {
                        File.SetAttributes(_outputFileName, FileAttributes.Normal);
                        File.Delete(_outputFileName);
                    }
                    else
                    {
                        _msg.Length = 0;
                        _msg.Append("File exists and ReplaceExistingFile set to False. Write to Output has failed.");
                        throw new System.Exception(_msg.ToString());
                    }
                }

                //_textOutFile.OpenFile(_outputFileName, PFFileOpenOperation.OpenFileForAppend);
                _textOutFile.OpenFile(_outputFileName, PFFileOpenOperation.OpenFileForWrite);
                _exporter.returnResultAsString += WriteDelimitedFileOutputLine;

                for (int dtInx = 0; dtInx < dtList.Count; dtInx++)
                {
                    dt.Rows.Clear();
                    dt.ReadXml(dtList[dtInx]);
                    if (dtInx == 0)
                    {
                        _exporter.ExtractDelimitedDataFromTable(dt, _columnDelimiter, _lineTerminator, _columnNamesOnFirstLine, (int)0, _stringValuesSurroundedWithQuotationMarks);
                    }
                    else
                    {
                        _exporter.ExtractDelimitedDataFromTable(dt, _columnDelimiter, _lineTerminator, false, (int)0, _stringValuesSurroundedWithQuotationMarks);
                    }
                }
            }
            catch (System.Exception ex)
            {
                success     = false;
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessageWithStackTrace(ex));
                throw new System.Exception(_msg.ToString());
            }
            finally
            {
                if (_textOutFile.FileIsOpen)
                {
                    _textOutFile.CloseFile();
                }
            }

            return(success);
        }
        private void InitInstance(PFList <DataTableRandomizerColumnSpec> colSpecs)
        {
            if (colSpecs == null)
            {
                _colSpecs = new PFList <DataTableRandomizerColumnSpec>();
            }
            else
            {
                _colSpecs = colSpecs;
            }

            _randomizer.InitRandomizerFolders();
        }
Ejemplo n.º 16
0
        //methods

        /// <summary>
        /// Routine to return a list of table names for the database pointed to by the current connection string.
        /// </summary>
        /// <returns>Object containing list of table definitions.</returns>
        public PFList <PFTableDef> GetTableList(string tablesToIncludePattern, string tablesToExcludePattern)
        {
            PFList <PFTableDef> tableList = null;
            PFDatabase          db        = null;

            string[] includePatterns = { string.Empty };
            string[] excludePatterns = { string.Empty };

            if (this.DbPlatform == DatabasePlatform.Unknown)
            {
                return(null);
            }
            if (this.ConnectionString.Length == 0)
            {
                return(null);
            }


            try
            {
                includePatterns[0] = tablesToIncludePattern.Trim();
                excludePatterns[0] = tablesToExcludePattern.Trim();
                db = new PFDatabase(this.DbPlatform, this.DbDllPath, this.DbNamespace + "." + this.DbClassName);
                db.ConnectionString = this.ConnectionString;
                db.OpenConnection();
                tableList = db.GetTableList(includePatterns, excludePatterns);
                db.CloseConnection();
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append("Attempt to retrieve list of table names failed: ");
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                throw new System.Exception(_msg.ToString());
            }
            finally
            {
                if (db != null)
                {
                    if (db.IsConnected)
                    {
                        db.CloseConnection();
                    }
                    db = null;
                }
            }



            return(tableList);
        }
Ejemplo n.º 17
0
        private void LoadWordList()
        {
            try
            {
                _words = PFList <string> .LoadFromXmlFile(_wordListFile, _fileXlatKey, _fileXlatIV);

                _minListInx = 0;
                _maxListInx = _words.Count - 1;
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append("Unable to find word list file: ");
                _msg.Append(_wordListFile);
                _msg.Append(Environment.NewLine);
                _msg.Append(PFTextProcessor.FormatErrorMessage(ex));
                throw new System.Exception(_msg.ToString());
            }
        }
Ejemplo n.º 18
0
        public void ToXmlTest()
        {
            PFList <string> testList = new PFList <string>();

            try
            {
                _msg.Length = 0;
                _msg.Append("ToXmlTest started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                testList.Add("First item");
                testList.Add("Second item");
                testList.Add("Third item");

                string          xmlString = testList.ToXmlString();
                XmlDocument     xmlDoc    = testList.ToXmlDocument();
                PFList <string> testList2 = PFList <string> .LoadFromXmlString(xmlString);

                _msg.Length = 0;
                _msg.Append("\r\n\r\n");
                _msg.Append(xmlString);
                _msg.Append("\r\n\r\n");
                _msg.Append(xmlDoc.OuterXml);
                _msg.Append("\r\n\r\n");
                _msg.Append(testList2.ToString());
                _msg.Append("\r\n\r\n");
                Program._messageLog.WriteLine(_msg.ToString());
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... ToXmlTest finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
Ejemplo n.º 19
0
        private PFList <PFTask> GetTaskListXML()
        {
            PFList <PFTask> taskList = new PFList <PFTask>();

            string[] taskFiles = null;


            taskFiles = Directory.GetFiles(this.ConnectionString, "*.xml", SearchOption.TopDirectoryOnly);

            if (taskFiles != null)
            {
                for (int i = 0; i < taskFiles.Length; i++)
                {
                    PFTask task = PFTask.LoadFromXmlFile(taskFiles[i]);
                    taskList.Add(task);
                }
            }

            return(taskList);
        }
Ejemplo n.º 20
0
        private PFList <PFSchedule> GetScheduleListXML()
        {
            PFList <PFSchedule> scheduleList = new PFList <PFSchedule>();

            string[] scheduleFiles = null;


            scheduleFiles = Directory.GetFiles(this.ConnectionString, "*.xml", SearchOption.TopDirectoryOnly);

            if (scheduleFiles != null)
            {
                for (int i = 0; i < scheduleFiles.Length; i++)
                {
                    PFSchedule schedule = PFSchedule.LoadFromXmlFile(scheduleFiles[i]);
                    scheduleList.Add(schedule);
                }
            }

            return(scheduleList);
        }
Ejemplo n.º 21
0
        private PFList <PFTaskHistoryEntry> GetTaskListDatabase(string taskName)
        {
            PFList <PFTaskHistoryEntry> taskHistoryEntryList = new PFList <PFTaskHistoryEntry>();
            PFDatabase db      = null;
            string     sqlStmt = string.Empty;

            try
            {
                db = new PFDatabase(DatabasePlatform.SQLServerCE35);
                db.ConnectionString = this.ConnectionString;
                db.OpenConnection();

                sqlStmt = _taskHistoryDefinitionsSelectTaskSQL.Replace("<taskname>", taskName);
                DbDataReader rdr = db.RunQueryDataReader(sqlStmt, System.Data.CommandType.Text);

                while (rdr.Read())
                {
                    string             str = rdr["TaskHistoryObject"].ToString();
                    PFTaskHistoryEntry the = PFTaskHistoryEntry.LoadFromXmlString(str);
                    taskHistoryEntryList.Add(the);
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    if (db.IsConnected)
                    {
                        db.CloseConnection();
                    }
                }
            }



            return(taskHistoryEntryList);
        }
Ejemplo n.º 22
0
        private PFList <PFTaskHistoryEntry> GetTaskListXML(string taskName)
        {
            PFList <PFTaskHistoryEntry> taskHistoryEntryList = new PFList <PFTaskHistoryEntry>();

            string[] taskHistoryEntryFiles = null;
            string   searchPattern         = taskName + "*.xml";


            taskHistoryEntryFiles = Directory.GetFiles(this.ConnectionString, searchPattern, SearchOption.TopDirectoryOnly);

            if (taskHistoryEntryFiles != null)
            {
                for (int i = 0; i < taskHistoryEntryFiles.Length; i++)
                {
                    PFTaskHistoryEntry the = PFTaskHistoryEntry.LoadFromXmlFile(taskHistoryEntryFiles[i]);
                    taskHistoryEntryList.Add(the);
                }
            }

            return(taskHistoryEntryList);
        }
Ejemplo n.º 23
0
        public static void GetSupportedDatabasesList(MainForm frm)
        {
            PFList <string> dblist = null;

            try
            {
                _msg.Length = 0;
                _msg.Append("GetSupportedDatabasesList started ...\r\n");
                Program._messageLog.WriteLine(_msg.ToString());

                dblist = PFDatabase.GetListOfSupportedDatabases();

                string tab = null;

                dblist.SetToBOF();

                while ((tab = dblist.NextItem) != null)
                {
                    if (tab.ToUpper() != "UNKNOWN")
                    {
                        _msg.Length = 0;
                        _msg.Append(tab);
                        Program._messageLog.WriteLine(_msg.ToString());
                    }
                }
            }
            catch (System.Exception ex)
            {
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                Program._messageLog.WriteLine(_msg.ToString());
                AppMessages.DisplayErrorMessage(_msg.ToString(), _saveErrorMessagesToAppLog);
            }
            finally
            {
                _msg.Length = 0;
                _msg.Append("\r\n... GetSupportedDatabasesList finished.");
                Program._messageLog.WriteLine(_msg.ToString());
            }
        }
        private void InitInstance(enLogFileStorageType logFileStorageType, string logFileConnectionString,
                                  enLogRetryQueueStorageType logRetryQueueStorageType, string logRetryQueueConnectionString)
        {
            _logFileStorageType            = logFileStorageType;
            _logFileConnectionString       = logFileConnectionString;
            _logRetryQueueStorageType      = logRetryQueueStorageType;
            _logRetryQueueConnectionString = logRetryQueueConnectionString;

            if (File.Exists(_logFileConnectionString) == false)
            {
                FileStream fs = File.Create(_logFileConnectionString);
                fs.Close();
            }

            if (File.Exists(_logRetryQueueConnectionString) == false)
            {
                //create the retry queue
                _logRetryQueue.SaveToXmlFile(_logRetryQueueConnectionString);
            }

            _logRetryQueue = PFList <PFLogMessage> .LoadFromXmlFile(_logRetryQueueConnectionString);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Synchronizes the saved randomizer specifications in a query definition file with the current column specifications.
        /// </summary>
        /// <param name="queryDef">File containing the query definition.</param>
        /// <param name="colSpecs">List containing the column specifications for the query.</param>
        public void SyncColSpecsWithSavedValues(pfQueryDef queryDef, PFList <DataTableRandomizerColumnSpec> colSpecs)
        {
            if (colSpecs == null || queryDef.RandomizerColSpecs == null)
            {
                return;
            }

            for (int cs = 0; cs < colSpecs.Count; cs++)
            {
                for (int qd = 0; qd < queryDef.RandomizerColSpecs.Count; qd++)
                {
                    if (queryDef.RandomizerColSpecs[qd].DataTableColumnName == colSpecs[cs].DataTableColumnName)
                    {
                        colSpecs[cs].RandomDataType   = queryDef.RandomizerColSpecs[qd].RandomDataType;
                        colSpecs[cs].RandomDataSource = queryDef.RandomizerColSpecs[qd].RandomDataSource;
                        colSpecs[cs].RandomNamesAndLocationsNumber = queryDef.RandomizerColSpecs[qd].RandomNamesAndLocationsNumber;
                        colSpecs[cs].RandomDataFieldName           = queryDef.RandomizerColSpecs[qd].RandomDataFieldName;
                        break;
                    }
                }
            }
        }
Ejemplo n.º 26
0
        private PFList <PFSchedule> GetScheduleListDatabase()
        {
            PFList <PFSchedule> scheduleList = new PFList <PFSchedule>();
            PFDatabase          db           = null;

            try
            {
                db = new PFDatabase(DatabasePlatform.SQLServerCE35);
                db.ConnectionString = this.ConnectionString;
                db.OpenConnection();

                DbDataReader rdr = db.RunQueryDataReader(_scheduleDefinitionsSelectAllSQL, System.Data.CommandType.Text);

                while (rdr.Read())
                {
                    string     str      = rdr["ScheduleObject"].ToString();
                    PFSchedule schedule = PFSchedule.LoadFromXmlString(str);
                    scheduleList.Add(schedule);
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    if (db.IsConnected)
                    {
                        db.CloseConnection();
                    }
                }
            }



            return(scheduleList);
        }
        /// <summary>
        /// Routine to use column definitions in a DataTable to initialize a DataTableRandomizerColumnSpec list.
        /// </summary>
        /// <param name="dt">DataTable object containing columns to include in the column specification list.</param>
        /// <returns>List of DataTableRandomizerColumnSpec objects.</returns>
        public PFList <DataTableRandomizerColumnSpec> GetInitColSpecListFromDataTable(DataTable dt)
        {
            PFList <DataTableRandomizerColumnSpec> colSpecs = new PFList <DataTableRandomizerColumnSpec>();

            if (dt == null)
            {
                _msg.Length = 0;
                _msg.Append("DataTable is null. You must specify an instance of a DataTable in order to get a list of column specs.");
                throw new System.Exception(_msg.ToString());
            }

            for (int colInx = 0; colInx < dt.Columns.Count; colInx++)
            {
                DataColumn dc = dt.Columns[colInx];
                DataTableRandomizerColumnSpec colSpec = new DataTableRandomizerColumnSpec();
                colSpec.DataTableColumnName     = dc.ColumnName;
                colSpec.DataTableColumnDataType = dc.DataType.FullName;
                //remainder of properties are left at their default values: to be filled in by application using the column specs.
                colSpecs.Add(colSpec);
            }

            return(colSpecs);
        }
        /// <summary>
        /// Writes data contained in list of ADO.NET data tables to path stored in OutputFileName property.
        /// </summary>
        /// <param name="dtList">List of temp file names pointing to XML files containing data table data to be output.</param>
        /// <returns>True if output operation is successful. False if write fails.</returns>
        public bool WriteDataToOutput(PFList <string> dtList)
        {
            bool      success = true;
            DataTable dt      = new DataTable();

            try
            {
                for (int dtInx = 0; dtInx < dtList.Count; dtInx++)
                {
                    dt.Rows.Clear();
                    dt.ReadXml(dtList[dtInx]);
                    if (dtInx == 0)
                    {
                        WriteDataToOutput(dt);
                    }
                    else
                    {
                        AppendDataToOutput(dt);
                    }
                }
            }
            catch (System.Exception ex)
            {
                success     = false;
                _msg.Length = 0;
                _msg.Append(AppGlobals.AppMessages.FormatErrorMessage(ex));
                throw new System.Exception(_msg.ToString());
            }
            finally
            {
                ;
            }



            return(success);
        }
Ejemplo n.º 29
0
        //methods

        /// <summary>
        /// Retrieves list of stored the objects.
        /// </summary>
        /// <returns>List of PFTask objects.</returns>
        public PFList <PFTask> GetTaskList()
        {
            PFList <PFTask> taskList = null;

            if (this.TaskStorageType == enTaskStorageType.XMLFiles)
            {
                taskList = GetTaskListXML();
            }
            else if (this.TaskStorageType == enTaskStorageType.Database)
            {
                taskList = GetTaskListDatabase();
            }
            else
            {
                _msg.Length = 0;
                _msg.Append("Invalid or missing TaskStorageType: ");
                _msg.Append(this.TaskStorageType.ToString());
                throw new System.Exception(_msg.ToString());
            }

            _taskList = taskList;

            return(taskList);
        }
Ejemplo n.º 30
0
        //methods

        /// <summary>
        /// Retrieves list of stored the objects.
        /// </summary>
        /// <returns>List of PFSchedule objects.</returns>
        public PFList <PFSchedule> GetScheduleList()
        {
            PFList <PFSchedule> scheduleList = null;

            if (this.ScheduleStorageType == enScheduleStorageType.XMLFiles)
            {
                scheduleList = GetScheduleListXML();
            }
            else if (this.ScheduleStorageType == enScheduleStorageType.Database)
            {
                scheduleList = GetScheduleListDatabase();
            }
            else
            {
                _msg.Length = 0;
                _msg.Append("Invalid or missing ScheduleStorageType: ");
                _msg.Append(this.ScheduleStorageType.ToString());
                throw new System.Exception(_msg.ToString());
            }

            _scheduleList = scheduleList;

            return(scheduleList);
        }