Beispiel #1
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);
        }
Beispiel #2
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);
        }
Beispiel #3
0
        private PFList <PFTask> GetTaskListDatabase()
        {
            PFList <PFTask> taskList = new PFList <PFTask>();
            PFDatabase      db       = null;

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

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

                while (rdr.Read())
                {
                    string str  = rdr["TaskObject"].ToString();
                    PFTask task = PFTask.LoadFromXmlString(str);
                    taskList.Add(task);
                }
            }
            catch (System.Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (db != null)
                {
                    if (db.IsConnected)
                    {
                        db.CloseConnection();
                    }
                }
            }



            return(taskList);
        }
Beispiel #4
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="taskName">Name of the task to retrieve.</param>
        /// <returns>Task object.</returns>
        public static PFTask LoadFromDatabase(string connectionString, string taskName)
        {
            string       sqlStmt            = string.Empty;
            PFTask       objectInstance     = null;
            PFTask       tempObjectInstance = new PFTask();
            PFDatabase   db         = new PFDatabase(DatabasePlatform.SQLServerCE35);
            DbDataReader rdr        = null;
            string       taskDefXml = string.Empty;

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

            sqlStmt = tempObjectInstance._taskDefinitionsSelectTaskSQL.Replace("<taskname>", taskName);
            rdr     = db.RunQueryDataReader(sqlStmt, CommandType.Text);
            while (rdr.Read())
            {
                taskDefXml     = rdr.GetString(0);
                objectInstance = PFTask.LoadFromXmlString(taskDefXml);
                break;  //should be only one record
            }


            return(objectInstance);
        }
Beispiel #5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="taskToRun">Task object containing task to run.</param>
 public PFTaskProcessor(PFTask taskToRun)
 {
     _taskToRun = taskToRun;
     InitializeInstance();
 }