public Handlers.Jobs.IJobRunner GetRunnerFor(Model.Job job)
        {
            var jt      = job.GetType();
            var generic = typeof(IJobRunner <>);
            var runner  = generic.MakeGenericType(jt);

            return(( IJobRunner )this.container.GetService(runner));
        }
        public IJobWorker GetWorkerFor(Model.Job job)
        {
            var jt      = job.GetType();
            var generic = typeof(IJobWorker <>);
            var worker  = generic.MakeGenericType(jt);

            return(( IJobWorker )this.container.GetService(worker));
        }
        public static void UpdateJob(Model.Job job)
        {
            string query =
                "BEGIN " +
                "job_pkg.update_job(" + job.Id + ", '" + job.Job_Title + "', " + job.Salary + ", '" + job.Description + "'); " +
                "END;";

            DB_Handler.ExecuteQuery(query);
        }
        public static void InsertJob(Model.Job job)
        {
            string query =
                "BEGIN " +
                "job_pkg.insert_job('" + job.Job_Title + "', " + job.Salary + ", '" + job.Description + "'); " +
                "END;";

            DB_Handler.ExecuteQuery(query);
        }
 public static Model.Job RowToEntity(DataRow row)
 {
     Model.Job job = new Model.Job
     {
         Id          = Int32.Parse(row["Id"].ToString()),
         Job_Title   = row["Job_Title"].ToString(),
         Salary      = Int32.Parse(row["Salary"].ToString()),
         Description = row["Description"].ToString()
     };
     return(job);
 }
예제 #6
0
        public ServiceJob GetJobByID(int ID)
        {
            using (var db = new CoordinationDbContext())
            {
                Model.Job job = db.Jobs.FirstOrDefault(jb => jb.ID == ID);
                return(ConvertJob(job));

                /*if (job != null)
                 * {
                 *
                 * }*/
            }
        }
예제 #7
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Model.Job job = db.Jobs.FirstOrDefault(x => x.ID == id);
            if (job == null)
            {
                return(HttpNotFound());
            }
            return(View(job));
        }
예제 #8
0
 public int JobComplete(int jobID)
 {
     using (var db = new CoordinationDbContext())
     {
         Model.Job job = db.Jobs.FirstOrDefault(jb => jb.ID == jobID);
         if (job != null)
         {
             job.Completed       = true;
             db.Entry(job).State = System.Data.Entity.EntityState.Modified;
             db.SaveChanges();
             return(0);
         }
         return(1);
     }
 }
예제 #9
0
        private ServiceJob ConvertJob(Model.Job job)
        {
            ServiceJob serviceJob = new ServiceJob();

            serviceJob.completed   = job.Completed == true;
            serviceJob.description = job.Description;
            serviceJob.ID          = job.ID;
            serviceJob.jobName     = job.JobName;
            serviceJob.latitude    = job.Latitude;
            serviceJob.longitude   = job.Longitude;
            foreach (Model.JobAssignment assignment in job.JobAssignments)
            {
                serviceJob.jobAssignments.Add(ConvertJobAssignment(assignment));
            }

            return(serviceJob);
        }
예제 #10
0
        public int JobAssign(int jobID, int userID)
        {
            using (var db = new CoordinationDbContext())
            {
                //Write the UserID and jobID on the db
                Model.Job  job  = db.Jobs.FirstOrDefault(jb => jb.ID == jobID);
                Model.User user = db.Users.FirstOrDefault(usr => usr.ID == userID);
                if (job != null && user != null)
                {
                    //user.Jobs.Add(job);
                    Coordination.Model.JobAssignment assignment = new Coordination.Model.JobAssignment();


                    assignment.Job  = job;
                    assignment.User = user;
                    db.JobAssignments.Add(assignment);
                    db.SaveChanges();
                    return(0);
                }
                //Steile ston Android User oti tin pire
                return(1);
            }
        }
예제 #11
0
 public SamePremiseAddressCommand(JobVM ViewModel)
 {
     this.ViewModel = ViewModel;
     Job            = ViewModel.Job;
 }
예제 #12
0
 public Model.Job GetJob(long orgId, Model.Job job)
 {
     return(GetJob(orgId, job.Id));
 }
예제 #13
0
 public Model.Job GetJob(Model.Organization org, Model.Job job)
 {
     return(GetJob(org.Id, job.Id));
 }
예제 #14
0
 public FindContractor(Model.Job job)
 {
     InitializeComponent();
     this.DataContext = new FindContractorViewModel(job);
 }
예제 #15
0
        public static void Run(Model.Monitor monitor)
        {
            var db = new PetaPoco.Database("LocalSQLite");

            // check the monitor should run
            if (monitor.State == Model.MonitorState.Running.ToString() && monitor.RunMultiple == 0)
            {
                log.InfoFormat("Monitor [{0}] is in a running state - not running a multiple version", monitor.MonitorID);
                return;
            }

            monitor.State = Model.MonitorState.Running.ToString();
            db.Update(monitor);

            log.InfoFormat("Monitor (ID: {2}) running on Thread Id {0} with the sql {1}", Thread.CurrentThread.ManagedThreadId.ToString(), monitor.SQL, monitor.MonitorID);

            // Sleeping to test the web interface update
            //Thread.Sleep(10000);

            // start the job
            var job = new Model.Job();

            job.MonitorID = monitor.MonitorID;
            job.StartTime = DateTime.Now.ToString();
            db.Insert(job);

            // set the local directory
            string monitorFolder = System.AppDomain.CurrentDomain.BaseDirectory + "\\" + monitor.MonitorID;

            try
            {
                if (File.Exists(monitorFolder))
                {
                    log.InfoFormat("Folder ({0}) exists, setting current location to that", monitorFolder);
                    Directory.SetCurrentDirectory(monitorFolder);
                }
                else
                {
                    log.InfoFormat("Folder ({0}) doesn't exist, creating the folder", monitorFolder);
                    DirectoryInfo di = Directory.CreateDirectory(monitorFolder);
                    log.InfoFormat("setting current location to that {0}", monitorFolder);
                    Directory.SetCurrentDirectory(monitorFolder);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat(@"Unable to create and\or set directory {0}", monitorFolder);
                log.Error(ex.ToString());
            }


            int RowCount = 0;

            try
            {
                DataTable dt;
                // switch on the type of monitor
                switch (monitor.Type.ToUpper())
                {
                case "EVENTVWR":
                    //case Model.MonitorType.Eventvwr:
                    if (monitor.isBathStatement())
                    {
                        if (monitor.intoFileName() == null)
                        {
                            throw new Exception("filename (as parsed from the SQL) is null - shouldn't be");
                        }

                        string fileName    = @".\" + monitor.intoFileName();
                        string newFileName = @".\" + job.JobID + "." + monitor.intoFileName();
                        try
                        {
                            if (String.IsNullOrEmpty(monitor.Checkpoint))
                            {
                                LogParser.BatchEventLog(monitor.SQL);
                            }
                            else
                            {
                                LogParser.BatchEventLog(monitor.SQL, monitor.Checkpoint);
                            }
                            //rename the output to include the jobId

                            if (File.Exists(fileName))
                            {
                                File.Move(fileName, newFileName);
                                RowCount = -1;
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error running batch execute against Event Log", ex);
                        }
                        job.Batch      = 1;
                        job.Info       = newFileName;
                        job.FinalState = "Complete";
                    }
                    else
                    {
                        try
                        {
                            if (String.IsNullOrEmpty(monitor.Checkpoint))
                            {
                                dt = LogParser.ParseEventLog(monitor.SQL);
                            }
                            else
                            {
                                dt = LogParser.ParseEventLog(monitor.SQL, monitor.Checkpoint);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error parsing Event Log", ex);
                        }
                        RowCount = dt.Rows.Count;
                        // convert the DataTable into a list of Model.Eventvwr (with the JobId) and insert into the DB
                        try
                        {
                            foreach (DataRow row in dt.Rows)
                            {
                                db.Insert(new Model.Eventvwr(row, job.JobID));
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error saving Event Viewer data", ex);
                        }
                        job.Info       = "Job returned " + RowCount.ToString() + " rows";
                        job.FinalState = "Complete";
                    }
                    break;

                case "IIS":
                    if (monitor.isBathStatement())
                    {
                        if (monitor.intoFileName() == null)
                        {
                            throw new Exception("filename (as parsed from the SQL) is null - shouldn't be");
                        }

                        string fileName    = @".\" + monitor.intoFileName();
                        string newFileName = @".\" + job.JobID + "." + monitor.intoFileName();
                        try
                        {
                            if (String.IsNullOrEmpty(monitor.Checkpoint))
                            {
                                LogParser.BatchIISLog(monitor.SQL);
                            }
                            else
                            {
                                LogParser.BatchIISLog(monitor.SQL, monitor.Checkpoint);
                            }
                            //rename the output to include the jobId

                            if (File.Exists(fileName))
                            {
                                File.Move(fileName, newFileName);
                                RowCount = -1;
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error running batch execute against Event Log", ex);
                        }
                        job.Batch      = 1;
                        job.Info       = newFileName;
                        job.FinalState = "Complete";
                    }
                    else
                    {
                        try
                        {
                            if (String.IsNullOrEmpty(monitor.Checkpoint))
                            {
                                dt = LogParser.ParseIISLog(monitor.SQL);
                            }
                            else
                            {
                                dt = LogParser.ParseIISLog(monitor.SQL, monitor.Checkpoint);
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error parsing IIS Log", ex);
                        }
                        RowCount = dt.Rows.Count;
                        // convert the DataTable into a list of Model.Eventvwr (with the JobId) and insert into the DB
                        try
                        {
                            foreach (DataRow row in dt.Rows)
                            {
                                db.Insert(new Model.IIS(row, job.JobID));
                            }
                        }
                        catch (Exception ex)
                        {
                            throw new Exception("Error saving IIS Log data", ex);
                        }
                        job.Info       = "Job returned " + RowCount.ToString() + " rows";
                        job.FinalState = "Complete";
                    }
                    break;

                default:
                    job.Info       = "Monitor type [" + monitor.Type + "] not implemented";
                    job.FinalState = "Error";
                    db.Update(job);
                    throw new Exception(job.Info);
                }
            }
            catch (Exception ex)
            {
                job.Info       = ex.ToString();
                job.FinalState = "Error";
            }
            finally
            {
                if (monitor.Alert == 1)
                {
                    if (job.FinalState == "Error")
                    {
                        log.Error("Sending error email");
                        log.ErrorFormat("{0}", job.Info);
                        // send email saying job errored
                        Helpers.Email.Send("*****@*****.**", monitor.EmailAddresses, "Error on Monitor [" + monitor.Name + "] ", job.Info);
                        monitor.State = Model.MonitorState.Alert.ToString();
                    }
                    else if (RowCount > 0)
                    {
                        log.Info("Sending alert email");
                        monitor.State = Model.MonitorState.Alert.ToString();
                        // send email saying rowcount is greater than 0, include link to data
                        Helpers.Email.Send("*****@*****.**", monitor.EmailAddresses, "Alert on Monitor [" + monitor.Name + "] ", "The monitor returned " + RowCount.ToString() + " rows. </br> More information here: <a href='http://*****:*****@".\" + job.JobID + "." + monitor.intoFileName()
                        log.Info("Sending alert email");
                        monitor.State = Model.MonitorState.Alert.ToString();
                        // send email saying rowcount is greater than 0, include link to data
                        Helpers.Email.AttachAndSend("*****@*****.**", monitor.EmailAddresses, "Alert on Monitor [" + monitor.Name + "] ", "The monitor returned the attached file. </br> More information here: <a href='http://*****:*****@".\" + job.JobID + "." + monitor.intoFileName());
                    }
                }
                else
                {
                    monitor.State = Model.MonitorState.Idle.ToString();
                }
            }

            // catch monitor state still in running
            if (monitor.State == Model.MonitorState.Running.ToString())
            {
                monitor.State = Model.MonitorState.Idle.ToString();
            }

            job.EndTime = DateTime.Now.ToString();
            db.Update(job);
            db.Update(monitor);
        }
예제 #16
0
 public UpdateJob(Model.Job job)
 {
     InitializeComponent();
     this.DataContext = new UpdateJobViewModel(job);
 }
예제 #17
0
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>
        public MainViewModel(Services.IDataService dataService,Services.IDialogService dialogService)
        {
            _jobs = new System.Collections.ObjectModel.ObservableCollection<Model.Job>();
            _favorites = new System.Collections.ObjectModel.ObservableCollection<string>();
            _recents = new System.Collections.ObjectModel.ObservableCollection<string>();
            _systemFolders = new System.Collections.ObjectModel.ObservableCollection<string>();

            GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<Messaging.FilesDropped>(this, files_Dropped);
            GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<Messaging.FilesDroppedOnJob>(this, files_DroppedOnJob);
            GalaSoft.MvvmLight.Messaging.Messenger.Default.Register<Messaging.FilesDroppedOnFolder>(this, files_DroppedOnFolder);

            _dataService = dataService;
            _dialogService = dialogService;

            _dataService.GetData(
                (item, error) =>
                {
                    if (item == null || error != null)
                    {
                        // Report error here
                        return;
                    }
                    if (item.Jobs != null) item.Jobs.ToList().ForEach(j => _jobs.Add(j));
                    if (item.Favorites != null) item.Favorites.ToList().ForEach(f => _favorites.Add(f));
                    if (item.Recents != null) item.Recents.ToList().ForEach(r => _recents.Add(r));
                    if (item.SystemFolders != null) item.SystemFolders.ToList().ForEach(sf => _systemFolders.Add(sf));

                    if (_jobs.Count > 0) _selectedJob = _jobs[0];
                });

            //select the "favorites"
            _selectedTabIndex = 1;

            this.PropertyChanged += MainViewModel_PropertyChanged;
        }
예제 #18
0
 public CreateJobCommand(JobVM ViewModel)
 {
     this.ViewModel = ViewModel;
     Job            = this.ViewModel.Job;
 }