Ejemplo n.º 1
0
 public void UpdateJobHistoy(JobHistory j)
 {
     _jobHistoyRepository.Update(j);
 }
Ejemplo n.º 2
0
 public void RemoveJobHistory(JobHistory jobHistory)
 {
     context.Remove(context.JobHistories.Single(d => d.Id == jobHistory.Id));
     context.SaveChanges();
 }
Ejemplo n.º 3
0
 public void AddJobHistoy(JobHistory j)
 {
     _jobHistoyRepository.Insert(j);
 }
Ejemplo n.º 4
0
 public static void saveJobHistory(DataTable dt, ref JobHistory mo)
 {
     foreach (DataRow dr in dt.Rows) {
         saveJobHistory(dr, ref mo);
     }
 }
Ejemplo n.º 5
0
 public _HSAdminServer_119(TestHSAdminServer _enclosing, AggregatedLogDeletionService
                           baseArg1, JobHistory baseArg2)
     : base(baseArg1, baseArg2)
 {
     this._enclosing = _enclosing;
 }
Ejemplo n.º 6
0
 public static void deleteJobHistory(JobHistory JobHistoryObj)
 {
     JobHistoryDBMapper dbm = new JobHistoryDBMapper();
     dbm.delete(JobHistoryObj);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Reload the JobHistory from the database
        /// </summary>
        /// <remarks>
        /// use this method when you want to relad the JobHistory 
        /// from the database, discarding any changes
        /// </remarks>
        public static void reload(ref JobHistory mo)
        {
            if (mo == null) {
                throw new System.ArgumentNullException("null object past to reload function");
            }

            mo = (JobHistory)new JobHistoryDBMapper().findByKey(mo.Id);
        }
Ejemplo n.º 8
0
 public virtual JobHistory Put(JobHistory jobHistory)
 {
     _jobHistorysController.ActiveUser = Models.ApiContext.ActiveUser;
     return(_jobHistorysController.Put(jobHistory));
 }
Ejemplo n.º 9
0
        public override void load(IModelObject mo)
        {
            const int DATAREADER_FLD_JOB_HISTORY_ID = 0;
            const int DATAREADER_FLD_EMPLOYEE_ID    = 1;
            const int DATAREADER_FLD_START_DATE     = 2;
            const int DATAREADER_FLD_END_DATE       = 3;
            const int DATAREADER_FLD_JOB_ID         = 4;
            const int DATAREADER_FLD_DEPARTMENT_ID  = 5;
            const int DATAREADER_FLD_CREATE_DATE    = 6;
            const int DATAREADER_FLD_UPDATE_DATE    = 7;
            const int DATAREADER_FLD_CREATE_USER    = 8;
            const int DATAREADER_FLD_UPDATE_USER    = 9;

            JobHistory obj = (JobHistory)mo;

            obj.IsObjectLoading = true;

            if (!this.reader.IsDBNull(DATAREADER_FLD_JOB_HISTORY_ID))
            {
                obj.PrJobHistoryId = Convert.ToInt64(this.reader.GetDecimal(DATAREADER_FLD_JOB_HISTORY_ID));
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_EMPLOYEE_ID))
            {
                obj.PrEmployeeId = Convert.ToInt64(this.reader.GetDecimal(DATAREADER_FLD_EMPLOYEE_ID));
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_START_DATE))
            {
                obj.PrStartDate = this.reader.GetDateTime(DATAREADER_FLD_START_DATE);
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_END_DATE))
            {
                obj.PrEndDate = this.reader.GetDateTime(DATAREADER_FLD_END_DATE);
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_JOB_ID))
            {
                obj.PrJobId = this.reader.GetString(DATAREADER_FLD_JOB_ID);
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_DEPARTMENT_ID))
            {
                obj.PrDepartmentId = Convert.ToInt64(this.reader.GetDecimal(DATAREADER_FLD_DEPARTMENT_ID));
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_CREATE_DATE))
            {
                obj.CreateDate = this.reader.GetDateTime(DATAREADER_FLD_CREATE_DATE);
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_UPDATE_DATE))
            {
                obj.UpdateDate = this.reader.GetDateTime(DATAREADER_FLD_UPDATE_DATE);
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_CREATE_USER))
            {
                obj.CreateUser = this.reader.GetString(DATAREADER_FLD_CREATE_USER);
            }
            if (!this.reader.IsDBNull(DATAREADER_FLD_UPDATE_USER))
            {
                obj.UpdateUser = this.reader.GetString(DATAREADER_FLD_UPDATE_USER);
            }


            obj.isNew = false;
            // since we've just loaded from database, we mark as "old"
            obj.isDirty         = false;
            obj.IsObjectLoading = false;
            obj.afterLoad();

            return;
        }
Ejemplo n.º 10
0
 public IActionResult Edit(JobHistory model)
 {
     GetHistroy.Update(model);
     return(RedirectToAction("Index"));
 }
Ejemplo n.º 11
0
        public void Execute()
        {
            var         startTime = DateTime.Now;
            ReturnValue result;
            var         jobHistory = new JobHistory
            {
                StartTime  = startTime,
                SensorId   = sensor.Id,
                SensorName = sensor.Name
            };

            try
            {
                log.Debug($"Started executing sensor - {sensor.Name} with Id - {sensor.Id}");
                result = sensor.Execute(appConfig, log);

                jobHistory.EndTime = DateTime.Now;

                if (result == null)
                {
                    result = ReturnValue.False($"Unexpected error when executing sensor - {sensor.Name} with Id - {sensor.Id}");
                }

                var str = "";
                if (result.Result)
                {
                    str = $"Completed executing sensor - {sensor.Name} with Id - {sensor.Id}";
                    log.Debug(str);
                }
                else
                {
                    str = $"Completed executing sensor with error - {sensor.Name} with Id - {sensor.Id} - error - {result?.ErrorAndWarningMessageForReporing()}";
                    log.Error(str);
                }

                jobHistory.IsSuccess = result.Result;
                jobHistory.Message   = str;
            }
            catch (Exception ex)
            {
                var str = $"Error executing sensor - {sensor.Name} with Id - {sensor.Id}, Exception - {ex.RecursivelyGetExceptionMessage()}";
                log.Error(ex, $"Error executing sensor - {sensor.Name} with Id - {sensor.Id}");
                result             = ReturnValue.False(str);
                jobHistory.Message = str;
            }
            finally
            {
                sensor.LastExecutedDateTime    = startTime;
                sensor.LastExecutionTimeInSecs = (DateTime.Now - startTime).TotalSeconds;
            }

            if (result.Result)
            {
                sensor.ContinousErrorOccurenceCount = 0;
            }
            else
            {
                sensor.ContinousErrorOccurenceCount++;
                jobHistory.Notified = false;

                if (sensor.ContinousErrorOccurenceCount >= sensor.NotifyIfHappensAfterTimes)
                {
                    log.Debug($"{sensor.Name} with Id - {sensor.Id}, Continous error occured.");
                    sensor.ContinousErrorOccurenceCount = 0;
                    if (sensor.NotifyByEmail)
                    {
                        log.Debug($"Sending mail for failed sensor - {sensor.Name} (Id - {sensor.Id}) .");
                        var param = new TemplateParameters
                        {
                            MachineName           = Environment.MachineName,
                            SensorName            = sensor.Name,
                            SensorId              = sensor.Id.ToString(),
                            SensorType            = sensor.SensorType.ToString(),
                            ErrorMessageList      = result.ErrorMessages,
                            MessagePrefix         = appConfig.EmailTemplateSettings.MessagePrefix,
                            MessageSuffix         = appConfig.EmailTemplateSettings.MessageSuffix,
                            SensorAllErrorMessage = result.ErrorMessages.ToString(""),
                        };

                        var emailResult = emailService.SendMail(ApplyAndGetTemplate(param, appConfig.EmailTemplateSettings.DefaultSubject),
                                                                ApplyAndGetTemplate(param, appConfig.EmailTemplateSettings.DefaultTextBody),
                                                                ApplyAndGetTemplate(param, appConfig.EmailTemplateSettings.DefaultHtmlBody));

                        jobHistory.Notified = !ReturnValue.IsNullOrFalse(emailResult);
                    }
                }
                else
                {
                    log.Debug($"Ignoring the Notification as the Thresold ({sensor.ContinousErrorOccurenceCount} / {sensor.NotifyIfHappensAfterTimes}) did not reach for Sensor - {sensor.Name} - {sensor.SensorType} - {sensor.Id}");
                }
            }

            try
            {
                using (var db = new LiteDatabase(appConfig.GetOrCreateHistoryDbPath()))
                {
                    var history = db.GetCollection <JobHistory>("jobhistory");
                    history.Insert(jobHistory);
                }
            }
            catch (Exception ex)
            {
                log.Error(ex, "Error writing to the history table");
            }
        }
Ejemplo n.º 12
0
 public IActionResult Create(JobHistory model)
 {
     GetHistroy.Insert(model);
     return(RedirectToAction("Index"));
 }
 public async Task<ActionResult> Index(List<JobHistoryModel> model)
 {
     if (ModelState.IsValid)
     {
         bool historyStored = false;
         using (var client = new DataServiceClient())
         {
             client.Open();
             var history = new List<JobHistory>();
             foreach (var jobHistory in model)
             {
                 int tempYear;
                 int tempMonth;
                 var jobHist = new JobHistory();
                 jobHist.street = jobHistory.street;
                 jobHist.city = jobHistory.city;
                 jobHist.stateAbrev = jobHistory.state;
                 jobHist.zip = jobHistory.zip;
                 jobHist.applicantId = Convert.ToInt32(this.Session["ApplicantId"]);
                 jobHist.duties = jobHistory.responsibilities;
                 jobHist.employer = jobHistory.employer;
                 jobHist.endSalary = jobHistory.salary_end;
                 jobHist.startSalary = jobHistory.salary_start;
                 if (jobHistory.from_year != null && jobHistory.from_month != null)
                 {
                     tempYear = Convert.ToInt32(jobHistory.from_year);  
                     tempMonth = Convert.ToInt32(jobHistory.from_month); 
                     jobHist.fromDate = new DateTime(tempYear, tempMonth, 1);
                     tempYear = Convert.ToInt32(jobHistory.to_year);  
                     tempMonth = Convert.ToInt32(jobHistory.to_month); 
                     jobHist.toDate = new DateTime(tempYear, tempMonth, 1);
                 }
                 else
                 {
                     jobHist.toDate = null;
                     jobHist.fromDate = null;
                 }
                 jobHist.phone = jobHistory.phone;
                 jobHist.position = jobHistory.position;
                 jobHist.reasonLeave = jobHistory.reason_for_leaving;
                 jobHist.supervisor = jobHistory.supervisor;
                 jobHist.applicantId = jobHistory.applicantId;
                 jobHist.jobHistoryId = jobHistory.historyId;
                 history.Add(jobHist);
             }
             historyStored = await client.updateJobHistoryAsync(history.ToArray());
             client.Close();
         }
         if (historyStored/**true**/)
         {
             this.Session["JobHistory"] = "Done";
             return RedirectToAction("Index", "Education");
         }
         else
         {
             //error in storing history... add error view or determine action??
         }
     }
     return View(model);
 }
Ejemplo n.º 14
0
 public JobHistoryTest()
 {
     _jobHistory = new JobHistory();
 }
Ejemplo n.º 15
0
 public void DeleteJobHistoy(JobHistory j)
 {
     _jobHistoyRepository.Delete(j);
 }
Ejemplo n.º 16
0
        public static void deleteJobHistory(JobHistory JobHistoryObj)
        {
            JobHistoryDBMapper dbm = new JobHistoryDBMapper();

            dbm.delete(JobHistoryObj);
        }
Ejemplo n.º 17
0
 public void Display(JobHistory jobHistory)
 {
     jobHistoryNameTextView.Text = $"{jobHistory}";
     resultTextView.Text         = $"{jobHistory.GetLastResult()}.";
 }
Ejemplo n.º 18
0
 public void saveJobHistory(JobHistory mo)
 {
     base.save(mo);
 }
Ejemplo n.º 19
0
 public static JobHistory loadFromDataRow(DataRow r)
 {
     DataRowLoader a = new DataRowLoader();
     IModelObject mo = new JobHistory();
     a.DataSource = r;
     a.load(mo);
     return (JobHistory)mo;
 }
 private void InitTest()
 {
     _jobHistory = CreateEntity();
 }
Ejemplo n.º 21
0
        public static void saveJobHistory(DataRow dr, ref JobHistory mo)
        {
            if (mo == null) {
                mo = new JobHistory();
            }

            foreach (DataColumn dc in dr.Table.Columns) {
                mo.setAttribute(dc.ColumnName, dr[dc.ColumnName]);
            }

            saveJobHistory(mo);
        }
Ejemplo n.º 22
0
 public JobHistory AddJobHistory(JobHistory jobHistory)
 {
     context.JobHistories.Add(jobHistory);
     context.SaveChanges();
     return(jobHistory);
 }
Ejemplo n.º 23
0
 public void saveJobHistory(JobHistory mo)
 {
     base.save(mo);
 }
    [TestMethod()] public void TestLoadAndSaveJobHistory()
    {
        ModelContext.beginTrans();
        try {
            OracleMappers.JobHistoryDBMapper pdb = new OracleMappers.JobHistoryDBMapper();

            long count = pdb.RecordCount();

            if (pdb.SelectFromObjectName != pdb.ManagedTableName)
            {
                long countFromSelectObject = pdb.dbConn.getLngValue("select count(*) from " + pdb.SelectFromObjectName);
                Assert.AreEqual(count, countFromSelectObject,
                                "Count of records in managedTableName {0} and SelectFromObjectName {1} should be equal, as there needs to be exactly 1 to 1 match between records in managed table and selectFromObject.",
                                pdb.ManagedTableName, pdb.SelectFromObjectName);
            }

            if (count == 0)
            {
                Assert.Inconclusive("No JobHistory in database, table is empty");
            }
            else
            {
                /**
                 * using (DataContext ctx = DBUtils.Current().dbContext()) {
                 *
                 *      var query = ctx.ExecuteQuery<JobHistory>(@"SELECT * FROM " + pdb.SelectFromObjectName ).Skip(1).Take(1);
                 *      var lst = query.ToList();
                 *
                 *      Assert.AreEqual(lst.Count, 1, "Expected to receive 1 record, got: " + lst.Count);
                 *
                 * }
                 * todo: fix boolean fields by generating properties of original fields
                 **/
                object pid = ModelContext.CurrentDBUtils.getObjectValue("select top 1 " + pdb.pkFieldName + " from " + pdb.ManagedTableName);

                JobHistory p  = pdb.findByKey(pid);
                JobHistory p2 = (JobHistory)p.copy();

                //Test equality and hash codes
                Assert.AreEqual(p.GetHashCode(), p2.GetHashCode());
                Assert.AreEqual(p, p2);

                p.isDirty = true;                  // force save
                pdb.save(p);

                // now reload object from database
                p = null;
                p = pdb.findByKey(pid);

                //test fields to be equal before and after save
                Assert.IsTrue(p.PrJobHistoryId == p2.PrJobHistoryId, "Expected Field JobHistoryId to be equal");
                Assert.IsTrue(p.PrEmployeeId.GetValueOrDefault() == p2.PrEmployeeId.GetValueOrDefault(), "Expected Field EmployeeId to be equal");
                Assert.IsTrue(p.PrStartDate.GetValueOrDefault() == p2.PrStartDate.GetValueOrDefault(), "Expected Field StartDate to be equal");
                Assert.IsTrue(p.PrEndDate.GetValueOrDefault() == p2.PrEndDate.GetValueOrDefault(), "Expected Field EndDate to be equal");
                Assert.IsTrue(p.PrJobId == p2.PrJobId, "Expected Field JobId to be equal");
                Assert.IsTrue(p.PrDepartmentId.GetValueOrDefault() == p2.PrDepartmentId.GetValueOrDefault(), "Expected Field DepartmentId to be equal");
                Assert.IsTrue(p.CreateDate.GetValueOrDefault().ToString("MM/dd/yy H:mm:ss zzz") == p2.CreateDate.GetValueOrDefault().ToString("MM/dd/yy H:mm:ss zzz"), "Expected Field CreateDate to be equal");
                Assert.IsFalse(p.UpdateDate.GetValueOrDefault() == p2.UpdateDate.GetValueOrDefault(), "Expected Field UpdateDate NOT to be equal");
                Assert.IsTrue(p.CreateUser == p2.CreateUser, "Expected Field CreateUser to be equal");
                //skip update user!

                p.isDirty = true;                 //to force save
                ModelContext.Current.saveModelObject(p);

                p = ModelContext.Current.loadModelObject <JobHistory>(p.Id);
                p.loadObjectHierarchy();

                string json = JsonConvert.SerializeObject(p, Formatting.Indented,
                                                          new JsonSerializerSettings()
                {
                    ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                });
                System.IO.FileInfo jf = new System.IO.FileInfo(".\\JobHistory.json");
                System.IO.File.WriteAllText(jf.FullName, json);

                if (pdb.isPrimaryKeyAutogenerated)
                {
                    p.isNew   = true;
                    p.isDirty = true;

                    try {
                        pdb.save(p);
                    } catch (System.Exception e) {
                        Assert.IsTrue(e.Message.ToUpper().Contains("UNIQUE INDEX") || e.Message.Contains("Violation of UNIQUE KEY constraint"),
                                      "Insert statement produced error other than violation of unique key:" + e.Message);
                    }
                }
            }
        } finally {
            ModelContext.rollbackTrans(); // 'Nothing should be saved to the database!
        }
    }