ATUL_v1.Atul_v1Data.GetProcessScheduleByProcessID C# (CSharp) Method

GetProcessScheduleByProcessID() public method

public GetProcessScheduleByProcessID ( long ProcessID ) : Schedule
ProcessID long
return Schedule
        public Schedule GetProcessScheduleByProcessID(long ProcessID)
        {
            Schedule s = new Schedule();
            SqlCommand cmd = new SqlCommand("exec dbo.Atul_ProcessScheduleGetByProcessId_sp @AtulProcessID", this._connection);
            cmd.Parameters.Add(new SqlParameter("@AtulProcessID", ProcessID));
            SqlDataAdapter da = new SqlDataAdapter();
            da.SelectCommand = cmd;
            DataTable returnTable = new DataTable(); //returnTable.TableName = "schedule";
            da.Fill(returnTable);
            if (returnTable.Rows.Count > 0)
            {
                DataRow r = returnTable.Rows[0];
                s.AtulProcessID = Convert.ToInt64(r["AtulProcessScheduleID"]);
                s.AtulProcessScheduleID = Convert.ToInt64(r["AtulProcessScheduleID"]);
                s.InstantiatedUserList = r["InstantiatedUserList"].ToString();
                if (r["LastInstantiated"] != DBNull.Value)
                {
                    s.LastInstantiated = Convert.ToDateTime(r["LastInstantiated"]);
                }
                s.NextScheduledDate = Convert.ToDateTime(r["NextScheduledDate"]);
                s.RepeatSchedule = r["RepeatSchedule"].ToString();
                s.ScheduleVersion = r["ScheduleVersion"].ToString();
                return s;
            }
            return null;
        }

Usage Example

Beispiel #1
0
 public bool CreateScheduledProcessInstance(long ProcessID, string scheduleVersion)
 {
     bool success = true;
     Atul_v1Data adb = new Atul_v1Data();
     // get schedule record from db
     Schedule s = adb.GetProcessScheduleByProcessID(ProcessID);
     if (s.ScheduleVersion == scheduleVersion)
     {
         DataTable processStatusTable = adb.GetAllProcessStatus();
         int processStatusID = 0;
         foreach (DataRow processStatusRow in processStatusTable.Rows)
         {
             if (processStatusRow["ProcessStatus"].ToString().ToLower() == "open")
             {
                 processStatusID = Convert.ToInt32(processStatusRow["AtulProcessStatusID"]);
             }
         }
         // instantiate process
         foreach (string u in s.InstantiatedUserList.Split(','))
         {
             if (u != null)
             {
                 this.CreateInstanceProcess(s.AtulProcessID, Convert.ToInt32(u), Convert.ToInt32(u), processStatusID, "", "");
             }
         }
         // if there's a repeat schedule involved, schedule the next fire
         if (s.RepeatSchedule != null && s.RepeatSchedule != string.Empty)
         {
             // calculate next date from cronstring.
             DateTime next = s.GetNextScheduled();
             // update process schedule, passing NextScheduledDate as last run, since that should represent this one
             UpdateProcessSchedule(s.AtulProcessScheduleID, s.ScheduleVersion, s.NextScheduledDate, next, s.RepeatSchedule, s.InstantiatedUserList);
             // send new scheduled message to queue
             this.PushNextScheduleToAdminQueue(s, next);
         }
         else
         {
             this.DeleteProcessSchedule(s.AtulProcessScheduleID);
         }
     }
     return success;
 }
All Usage Examples Of ATUL_v1.Atul_v1Data::GetProcessScheduleByProcessID
Atul_v1Data