Example #1
0
 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;
 }
Example #2
0
 public string PushNextScheduleToAdminQueue(Schedule s, DateTime next)
 {
     string correlationid = "";
     string env = ConfigurationManager.AppSettings.Get("Environment");
     string queue = ConfigurationManager.AppSettings.Get(env.ToUpper() + ".AtulAdminQueue");
     XmlDocument doc = s.GetScheduleMessageBodyXML();
     string body = doc.InnerXml;
     List<KeyValuePair<string, string>> headerList = new List<KeyValuePair<string, string>>();
     headerList.Add(new KeyValuePair<string, string>("VERB", "INITINSTANCE"));
     // scale tells how much to multiply the delay by, since the ESB system is passing the delay header from one queue to the next, thus doubling it.
     // when it's fixed, we can push config change to set scale to 1 and thus delay is intact.
     double timescale = Convert.ToDouble(ConfigurationManager.AppSettings.Get("MsgTimeScale"));
     // calculate delay by subtracting now from next scheduled date
     long delay = Convert.ToInt64(Math.Floor(next.Subtract(DateTime.Now).TotalMilliseconds * timescale));
     // if they're scheduled for the next couple minutes, just push it now with no delay so that it doesn't get
     // caught in lag
     if (delay >= 100000)
     {
         headerList.Add(new KeyValuePair<string, string>("AMQ_SCHEDULED_DELAY", delay.ToString()));
     }
     correlationid = this.PushToQueue(queue, body, headerList);
     return correlationid;
 }