Example #1
0
        static private void LoadStartUpJob(T1.Shared.Classes.ObjectCron objCron)
        {
            try
            {
                IJobDetail _Job = JobBuilder.Create <StartUpJob>()
                                  .WithIdentity(objCron.JobId, objCron.GroupId)
                                  .Build();

                ITrigger _Trigger = TriggerBuilder.Create()
                                    .WithIdentity(objCron.TriggerId, objCron.GroupId)
                                    .StartNow()
                                    .WithCronSchedule(objCron.Cron)
                                    .Build();

                if (!T1.Cron.isJobRegistered(_Job.Key))
                {
                    T1.Cron.addJob(_Job, _Trigger);
                    _Logger.Debug("B1Connection cron job added. Refreshing based on cron string " + objCron.Cron);
                }
                else
                {
                    _Logger.Debug("Job Already created. Ignoring creation");
                }
            }
            catch (Exception er)
            {
                _Logger.Fatal("", er);
            }
        }
Example #2
0
        public static bool upsertObjectCron(T1.Shared.Classes.ObjectCron objCron, DateTime oDate, string Key, string DateTimeColumn, string KeyColumn)
        {
            bool            blResult   = false;
            DataTable       objDT      = null;
            OdbcDataAdapter objAdapter = null;
            DataRow         objRow     = null;
            string          strSql     = "";

            try
            {
                if (_Instance == null)
                {
                    _Instance = new Instance();
                }
                if (objConnection == null)
                {
                    getConnection();
                }
                if (objConnection != null && objConnection.State == ConnectionState.Open)
                {
                    strSql     = Settings._SQL.getObjectControlQuery.Replace("[--ObjectCronId--]", objCron.Id.ToString());
                    objAdapter = new OdbcDataAdapter(strSql, objConnection);
                    objAdapter.Fill(objDT);
                    if (objDT.Rows.Count > 0)
                    {
                        objDT.Rows[0][KeyColumn]      = Key;
                        objDT.Rows[0][DateTimeColumn] = oDate;
                    }
                    else
                    {
                        objRow = objDT.NewRow();
                        objRow["OBJECTCRONID"] = objCron.Id;
                        objRow[KeyColumn]      = Key;
                        objRow[DateTimeColumn] = oDate;
                        objDT.Rows.Add(objRow);
                    }
                    objAdapter.Update(objDT);
                    blResult = true;
                }
            }
            catch (Exception er)
            {
                _Logger.Error("", er);
            }
            return(blResult);
        }