/// <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="taskName">Name of the the to retrieve.</param>
        /// <param name="actualStartTime">Actual start time for the history entry to be retrieved.</param>
        /// <returns>TaskHistoryEntry object.</returns>
        public static PFTaskHistoryEntry LoadFromDatabase(string connectionString, string taskName, DateTime actualStartTime)
        {
            string             sqlStmt            = string.Empty;
            PFTaskHistoryEntry objectInstance     = null;
            PFTaskHistoryEntry tempObjectInstance = new PFTaskHistoryEntry();
            PFDatabase         db  = new PFDatabase(DatabasePlatform.SQLServerCE35);
            DbDataReader       rdr = null;
            string             taskHistoryDefXml = string.Empty;

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

            sqlStmt = tempObjectInstance._taskHistoryDefinitionsSelectTaskEntrySQL.Replace("<taskname>", taskName);
            sqlStmt = sqlStmt.Replace("<rundate>", actualStartTime.ToString("MM/dd/yyyy HH:mm:ss"));
            rdr     = db.RunQueryDataReader(sqlStmt, CommandType.Text);
            while (rdr.Read())
            {
                taskHistoryDefXml = rdr.GetString(0);
                objectInstance    = PFTaskHistoryEntry.LoadFromXmlString(taskHistoryDefXml);
                break;  //should be only one record
            }


            return(objectInstance);
        }
Exemple #2
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);
        }
Exemple #3
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);
        }