/// <summary> /// Method for populating the DataSource with all Call Logs for a specific Job, /// filtered accordingly to a User inputed Parameter /// </summary> public void ListFilteredCallLogs() { if (null != _view.JobId) { try { using (_callLogModel = new CallLogModel()) { if (string.Empty == _view.FilterValue) { _view.DataSource = _callLogModel.ListAllJobCallLogs(_view.JobId.Value).OrderBy(e => e.CallDate).ToList(); } else { _view.DataSource = _callLogModel.ListFilteredCallLogs(_view.FilterType, _view.FilterValue, _view.JobId.Value).OrderBy(e => e.CallDate).ToList(); } } } catch (Exception ex) { Logger.Write(string.Format("There was an error loading the Filtered Call Log List!\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("There was an error loading the Filtered Call Log List", false); } } }
public void Dispose() { _view = null; _callLogModel = null; _callCriteriaModel = null; _emailModel = null; }
public EmailViewModel(IEmailView view) { _view = view; _callLogModel = new CallLogModel(); _callCriteriaModel = new CallCriteriaModel(); _emailModel = new EmailModel(); }
public ManagersLocationViewModel(IManagersLocationView view) { _view = view; _employeeModel = new EmployeeModel(new EFUnitOfWork()); _callLogModel = new CallLogModel(); }
// GET: CallLog public ActionResult Index() { if (!isEdit) { ViewBag.StudentModel = TempData["studentModel"] as Repository.StudentModel; TempData.Keep("studentModel"); CallLogModel clm = new CallLogModel(); if (ViewBag.StudentModel != null) { // callLogModel.CallID = 0; clm.StudentID = ViewBag.StudentModel.StudentID; clm.LanguageSpokenID = ViewBag.StudentModel.HomeLanguageID != null ? ViewBag.StudentModel.HomeLanguageID : 0; clm = CreateCallLog(clm); clm.PrizeStudentName = ViewBag.StudentModel.StudentFirstName; } else { return(RedirectToAction("Index", "Timesheet"));//Page was navigated to without selecting/creating a student - send back to timesheets } GetDropDownData(); ViewBag.IsEdit = false; return(View(clm)); } // GetDropDownData(); return(View()); }
public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CallLogModel callLog = await context.CallLogs.FindAsync(id); if (callLog == null) { return(HttpNotFound()); } isEdit = true; Student student = await context.Students.FindAsync(callLog.StudentID); if (student != null) { StudentController sc = new StudentController(); ViewBag.StudentModel = sc.MapStudentToModel(student); } ViewBag.IsEdit = isEdit; GetDropDownData(); return(View("Index", callLog)); }
public void BindJobCallLog() { using (_callLogModel = new CallLogModel()) { if (_view.JobId.HasValue) _view.JobCallLogGridDataSource = _callLogModel.ListAllJobCallLogs(_view.JobId.Value); } }
public void Dispose() { _callLogModel.Dispose(); _callLogModel = null; _jobModel.Dispose(); _jobModel = null; }
public void ParseNoteField() { //Arrange string xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"><Name>txtNote</Name><Label><Text>Note:</Text><Css>dynamicLabel</Css><Style /></Label><Css>input</Css><Style /><Visible>true</Visible><MaxChars>255</MaxChars><MaxCharsWarning>250</MaxCharsWarning><Text>testsdavdgvasdvaghcdhacsdhgacsdgd</Text><IsRequired>false</IsRequired><ErrorMessage /><ValidationGroup /><TextMode>MultiLine</TextMode><Width>300</Width><Height>150</Height></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>"; CallLogModel model = new CallLogModel(new FakeUnitOfWork()); //Act string note = model.GetDynamicFieldValueByName<DynamicCountableTextBoxXml>(xml, "txtNote", "Text"); //Assert Assert.AreEqual("testsdavdgvasdvaghcdhacsdhgacsdgd", note); }
/// <summary> /// Method to load all jobcalllogs and set it to the property CallLogListDataSource /// </summary> public void LoadJobCallLogByResources() { using (_callLogModel = new CallLogModel()) { IList<CS_CallLog> lstCallLogs = _callLogModel.GetCallLogByResource( _view.ResourceRepeaterDataItem.JobID, _view.ResourceRepeaterDataItem.EmployeeID, _view.ResourceRepeaterDataItem.EquipmentID); if (null != lstCallLogs) { _view.CallLogListDataSource = lstCallLogs; } } }
public ResourceAllocationViewModel(IResourceAllocationView view) { _view = view; _equipmentModel = new EquipmentModel(); _divisionModel = new DivisionModel(); _employeeModel = new EmployeeModel(); _resourceAllocationModel = new ResourceAllocationModel(); _locationModel = new LocationModel(); _jobModel = new JobModel(); _callLogModel = new CallLogModel(); _divisionNumber = string.Empty; _name = string.Empty; _type = Globals.ResourceAllocation.Type.AddEmployee; }
public void ShouldReturnCallLogListFilteredByCallTime() { //Arrange FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>(); fakeCallLogList.AddObject(new CS_CallLog() { ID = 1, JobID = 1, Active = true, CallDate = new DateTime(2011, 05, 1) }); fakeCallLogList.AddObject(new CS_CallLog() { ID = 2, JobID = 1, Active = true, CallDate = new DateTime(2011, 05, 10, 13, 45, 0) }); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList); CallLogModel model = new CallLogModel(mockUnitOfWork.Object); //Act IList<CS_CallLog> callLogList = model.ListFilteredCallLogs(Core.Globals.JobRecord.FilterType.Time, "5/11/2011 13:45", 1); //Assert Assert.AreEqual(1, callLogList.Count); Assert.AreEqual(2, callLogList[0].ID); }
private CallLogModel CreateCallLog(CallLogModel clm) { CallLog callLog = new CallLog(); callLog.StudentID = clm.StudentID; callLog.LanguageSpokenID = clm.LanguageSpokenID == 0 ? 1 : clm.LanguageSpokenID; callLog.CallStart = RoundToNearestMinute(DateTime.Now); callLog.UserID = User.Identity.GetUserId(); context.CallLogs.Add(callLog); context.SaveChanges(); clm.CallID = callLog.CallID; clm.CallStart = callLog.CallStart; clm.UserID = callLog.UserID; return(clm); }
public ActionResult Update(CallLogModel clm) { CallLog callLog = clm; if (!isEdit && clm.CallEnd == null) { DateTime endTime = RoundToNearestMinute(DateTime.Now); if (endTime == clm.CallStart) { endTime = endTime.AddMinutes(1); } callLog.CallEnd = endTime; } context.Entry(callLog).State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); return(RedirectToAction("Index", "Timesheet")); }
public IEnumerable <CallLogModel> GetCallLogs() { var phoneContacts = new List <CallLogModel>(); // filter in desc order limit by no string querySorter = String.Format("{0} desc ", CallLog.Calls.Date); using (var phones = Android.App.Application.Context.ContentResolver.Query(CallLog.Calls.ContentUri, null, null, null, querySorter)) { if (phones != null) { while (phones.MoveToNext()) { try { string callNumber = phones.GetString(phones.GetColumnIndex(CallLog.Calls.Number)); string callDuration = phones.GetString(phones.GetColumnIndex(CallLog.Calls.Duration)); long callDate = phones.GetLong(phones.GetColumnIndex(CallLog.Calls.Date)); string callName = phones.GetString(phones.GetColumnIndex(CallLog.Calls.CachedName)); int callTypeInt = phones.GetInt(phones.GetColumnIndex(CallLog.Calls.Type)); string callType = Enum.GetName(typeof(CallType), callTypeInt); var log = new CallLogModel(); log.CallName = callName; log.CallNumber = callNumber; log.CallDuration = callDuration; log.CallDateTick = callDate; log.CallType = callType; phoneContacts.Add(log); } catch (Exception ex) { //something wrong with one contact, may be display name is completely empty, decide what to do } } phones.Close(); } // if we get here, we can't access the contacts. Consider throwing an exception to display to the user } return(phoneContacts); }
private void Calls_ItemClick(object sender, ItemClickEventArgs e) { if (Calls.SelectionMode != ListViewSelectionMode.Multiple) { CallLogModel log = e.ClickedItem as CallLogModel; CallLog nativeLog = (CallLog)log.NativeLog; String address; if (log.IsIncoming) { address = nativeLog.FromAddress.AsStringUriOnly(); } else { address = nativeLog.ToAddress.AsStringUriOnly(); } SetAddressGoToDialerAndCall(address); } }
public JobCallLogPresenter(IJobCallLogView view) { this._view = view; _callLogModel = new CallLogModel(); }
public void VerifyDPICalculateParked() { //Arrange #region [ Variables ] DateTime now = DateTime.Now; DateTime startDateTime = new DateTime(2011, 08, 01, 12, 0, 0); DateTime startDateTime2 = startDateTime.AddDays(1); #endregion #region [ CallType Repository ] FakeObjectSet<CS_CallType> fakeCallTypeRepository = new FakeObjectSet<CS_CallType>(); fakeCallTypeRepository.AddObject ( new CS_CallType() { ID = (int)Globals.CallEntry.CallType.Parked, Description = "Parked", Xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?> <DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"> <Controls> <DynamicControls xsi:type=\"DynamicDatePickerXml\"> <Name>dtpDate</Name> <IsValidEmpty>false</IsValidEmpty> <EmptyValueMessage>The Parked Date field is required</EmptyValueMessage> <InvalidValueMessage>Invalid Parked Date format</InvalidValueMessage> <DateTimeFormat>Default</DateTimeFormat> <ShowOn>Both</ShowOn> <ValidationGroup>CallEntry</ValidationGroup> <Label> <Text>Parked Date:</Text> <Css>dynamicLabel</Css> </Label> </DynamicControls> <DynamicControls xsi:type=\"DynamicTimeXml\"> <Name>txtTime</Name> <IsValidEmpty>false</IsValidEmpty> <ValidationGroup>CallEntry</ValidationGroup> <EmptyValueMessage>The Parked Time field is required.</EmptyValueMessage> <InvalidValueMessage>The Parked Time field is invalid</InvalidValueMessage> <MaskedType>Time</MaskedType> <Mask>99:99</Mask> <Label> <Text>Parked Time:</Text> <Css>dynamicLabel</Css> </Label> </DynamicControls> <DynamicControls xsi:type=\"DynamicCountableTextBoxXml\"> <Name>txtNote</Name> <IsRequired>false</IsRequired> <MaxChars>255</MaxChars> <MaxCharsWarning>250</MaxCharsWarning> <TextMode>MultiLine</TextMode> <Width>300</Width> <Height>150</Height> <Label> <Text>Note:</Text> <Css>dynamicLabel</Css> </Label> </DynamicControls> </Controls> </DynamicFieldsAggregator>", CallCriteria = false, IsAutomaticProcess = false, DpiStatus = 2, Active = true } ); #endregion #region [ Resource Repository ] FakeObjectSet<CS_Resource> fakeResourceRepository = new FakeObjectSet<CS_Resource>(); fakeResourceRepository.AddObject(new CS_Resource() { ID = 1, EmployeeID = 1, EquipmentID = null, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true }); fakeResourceRepository.AddObject(new CS_Resource() { ID = 2, EmployeeID = null, EquipmentID = 1, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true }); fakeResourceRepository.AddObject(new CS_Resource() { ID = 3, EmployeeID = null, EquipmentID = 2, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true }); fakeResourceRepository.AddObject(new CS_Resource() { ID = 4, EmployeeID = null, EquipmentID = 3, JobID = 1, Duration = 1, StartDateTime = startDateTime2, Active = true }); #endregion #region [ DPI Repository ] FakeObjectSet<CS_DPI> fakeDPIRepository = new FakeObjectSet<CS_DPI>(); fakeDPIRepository.AddObject(new CS_DPI() { ID = 1, Date = startDateTime.Date, Calculate = false, ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved, JobID = 1, IsContinuing = true, ProcessStatusDate = DateTime.Now, CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF, Total = 1000, CreatedBy = "System", //CreationID =, CreationDate = DateTime.Now, ModifiedBy = "System", //ModificationID, ModificationDate = DateTime.Now, Active = true, CS_DPIResource = new EntityCollection<CS_DPIResource>() { new CS_DPIResource() { ID = 1, DPIID = 1, EmployeeID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 2, Active = true, } } }); fakeDPIRepository.AddObject(new CS_DPI() { ID = 2, Date = startDateTime2.Date, Calculate = false, ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved, JobID = 1, IsContinuing = true, ProcessStatusDate = DateTime.Now, CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF, Total = 1000, CreatedBy = "System", //CreationID =, CreationDate = DateTime.Now, ModifiedBy = "System", //ModificationID, ModificationDate = DateTime.Now, Active = true, CS_DPIResource = new EntityCollection<CS_DPIResource>() { new CS_DPIResource() { ID = 1, DPIID = 1, EmployeeID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 2, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 3, Active = true } } }); #endregion #region [ Parameters ] CS_CallLog callLog = new CS_CallLog() { CallTypeID = (int)Globals.CallEntry.CallType.Parked, Xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><DynamicFieldsAggregator xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"><Controls><DynamicControls xsi:type=\"DynamicDatePickerXml\"><Name>dtpDate</Name><Label><Text>Release Date:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>2011-08-01T00:00:00</Text><IsValidEmpty>false</IsValidEmpty><EmptyValueMessage>The Release Date field is required</EmptyValueMessage><InvalidValueMessage>Invalid Release Date format</InvalidValueMessage><DateTimeFormat>Default</DateTimeFormat><ShowOn>Both</ShowOn><ValidationGroup>CallEntry</ValidationGroup></DynamicControls><DynamicControls xsi:type=\"DynamicTimeXml\"><Name>txtTime</Name><Label><Text>Release Time:</Text><Css>dynamicLabel</Css><Style /></Label><Css /><Style /><Visible>true</Visible><Text>12:00</Text><Mask>99:99</Mask><MaskedType>Time</MaskedType><InputDirection>LeftToRight</InputDirection><IsValidEmpty>false</IsValidEmpty><ValidationGroup>CallEntry</ValidationGroup><InvalidValueMessage>The Release Time field is invalid</InvalidValueMessage><EmptyValueMessage>The Release Time field is required.</EmptyValueMessage></DynamicControls></Controls><Extenders /></DynamicFieldsAggregator>", CreationDate = now, CallDate = now, JobID = 1 }; List<int> employeeIDList = new List<int>() { 1 }; List<int> equipmentIDList = new List<int>() { 1, 2, 3 }; #endregion #region [ Mock ] Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallType>()).Returns(fakeCallTypeRepository); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Resource>()).Returns(fakeResourceRepository); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPI>()).Returns(fakeDPIRepository); CallLogModel model = new CallLogModel(mockUnitOfWork.Object); #endregion //Act model.VerifyDPICalculate(callLog, employeeIDList, equipmentIDList); //Assert CS_DPI dpi = fakeDPIRepository.FirstOrDefault(e => e.ID == 1); CS_DPI dpi2 = fakeDPIRepository.FirstOrDefault(e => e.ID == 2); Assert.IsTrue(dpi.Calculate, "Fail at Calculate True"); Assert.IsFalse(dpi2.Calculate, "Fail at Calculate False"); }
public void ShouldReturnCallLogListFilteredByCallTypeDescription() { //Arrange FakeObjectSet<CS_CallLog> fakeCallLogList = new FakeObjectSet<CS_CallLog>(); fakeCallLogList.AddObject(new CS_CallLog() { ID = 1, JobID = 1, Active = true, CS_CallType = new CS_CallType() { Description = "CallTypeDescriptionTest" } }); fakeCallLogList.AddObject(new CS_CallLog() { ID = 2, JobID = 2, Active = true, CS_CallType = new CS_CallType() { Description = "CallTypeDescriptionTest2" } }); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallLog>()).Returns(fakeCallLogList); CallLogModel model = new CallLogModel(mockUnitOfWork.Object); //Act IList<CS_CallLog> callLogList = model.ListFilteredCallLogs(Core.Globals.JobRecord.FilterType.Type, "CallTypeDescriptionTest2", 2); //Assert Assert.AreEqual(1, callLogList.Count); Assert.AreEqual(2, callLogList[0].ID); }
public void TestListFilteredJobCallLogInfoByModificationDate() { // Arrange CallLogModel model = new CallLogModel(new FakeUnitOfWork()); // Act IList<CS_View_JobCallLog> result = model.ListFilteredJobCallLogInfo(null, null, "", null, new DateTime(2011, 2, 6), DateTime.Now, false, false, ""); // Assert Assert.IsNotNull(result); Assert.AreEqual(1, result.Count); }
public void TestIfListAllPrimaryCallTypesIsReturningJobRelatedRows() { // Arrange FakeObjectSet<CS_PrimaryCallType> fakePrimaryCallTypeList = new FakeObjectSet<CS_PrimaryCallType>(); fakePrimaryCallTypeList.AddObject( new CS_PrimaryCallType() { ID = 1, Type = "Job Related Primary Call Type", Active = true, JobRelated = true } ); fakePrimaryCallTypeList.AddObject( new CS_PrimaryCallType() { ID = 2, Type = "Non-Job Related Primary Call Type", Active = true, JobRelated = false } ); Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_PrimaryCallType>()).Returns(fakePrimaryCallTypeList); CallLogModel model = new CallLogModel(mockUnitOfWork.Object); // Act IList<CS_PrimaryCallType> primaryCallTypeList = model.ListAllPrimaryCallTypes(true); // Assert Assert.AreEqual(1, primaryCallTypeList.Count); Assert.AreEqual(1, primaryCallTypeList[0].ID); }
public void TestListFilteredJobCallLogInfoByStatus() { // Arrange CallLogModel model = new CallLogModel(new FakeUnitOfWork()); // Act IList<CS_View_JobCallLog> result = model.ListFilteredJobCallLogInfo(1, null, "", null, DateTime.MinValue, DateTime.Now, false, false, ""); // Assert Assert.IsNotNull(result); Assert.AreEqual(3, result.Count); }
public void ListReceiptsByCallLog() { using (_callLogModel = new CallLogModel()) { _view.Receipts = _callLogModel.ListCallCriteriaEmails(_view.CallLogListId); } }
private void SaveCloningCallLog(int cloningId, int newJobId) { CallLogModel model = new CallLogModel(_unitOfWork); CS_CallType callType = model.GetCallTypeByDescription("Job Cloning"); CS_Job oldJob = _jobRepository.Get(e => e.ID == cloningId); CS_CallLog oldJobLog = new CS_CallLog() { JobID = cloningId, CallTypeID = callType.ID, PrimaryCallTypeId = callType.CS_PrimaryCallType_CallType.First(e => e.CallTypeID == callType.ID).PrimaryCallTypeID, CallDate = NewJob.CreationDate, Note = string.Format("Job # {0} has been cloned to Job # {1}", oldJob.NumberOrInternalTracking, NewJob.NumberOrInternalTracking), CreatedBy = NewJob.CreatedBy, CreationDate = NewJob.CreationDate, ModifiedBy = NewJob.ModifiedBy, ModificationDate = NewJob.ModificationDate, Active = true, ShiftTransferLog = false }; _callLogRepository.Add(oldJobLog); CS_CallLog newJobLog = new CS_CallLog() { JobID = newJobId, CallTypeID = oldJobLog.CallTypeID, PrimaryCallTypeId = oldJobLog.PrimaryCallTypeId, CallDate = oldJobLog.CreationDate, Note = oldJobLog.Note, CreatedBy = oldJobLog.CreatedBy, CreationDate = oldJobLog.CreationDate, ModifiedBy = oldJobLog.ModifiedBy, ModificationDate = oldJobLog.ModificationDate, Active = true, ShiftTransferLog = false }; _callLogRepository.Add(newJobLog); }
public void DoStuff(object sender, EventArgs e) { bool mustEnter = true; if (_targetControl is DynamicTextBox) { if (!string.IsNullOrEmpty(((DynamicTextBox)_targetControl).Text)) mustEnter = false; } else if (_targetControl is DynamicCountableTextBox) { if (!string.IsNullOrEmpty(((DynamicCountableTextBox)_targetControl).Text)) mustEnter = false; } else if (_targetControl is DynamicDropDownList) { if (((DynamicDropDownList)_targetControl).SelectedIndex != 0) mustEnter = false; } if (mustEnter) { switch (_type) { case Globals.CallEntry.AutoFillType.JobCity: using (JobModel model = new JobModel()) { CS_LocationInfo locationInfo = model.GetLocationInfoByJobId(Convert.ToInt32(_filterId)); if (null != locationInfo && null != locationInfo.CS_City) { if (_targetControl is DynamicTextBox) ((DynamicTextBox)_targetControl).Text = locationInfo.CS_City.Name; else if (_targetControl is DynamicCountableTextBox) ((DynamicCountableTextBox)_targetControl).Text = locationInfo.CS_City.Name; else if (_targetControl is DynamicDropDownList) { if (null != ((DynamicDropDownList)_targetControl).Items.FindByValue(locationInfo.CityID.ToString())) ((DynamicDropDownList)_targetControl).SelectedValue = locationInfo.CityID.ToString(); } } } break; case Globals.CallEntry.AutoFillType.JobState: using (JobModel model = new JobModel()) { CS_LocationInfo locationInfo = model.GetLocationInfoByJobId(Convert.ToInt32(_filterId)); if (null != locationInfo && null != locationInfo.CS_State) { if (_targetControl is DynamicTextBox) ((DynamicTextBox)_targetControl).Text = locationInfo.CS_State.Name; else if (_targetControl is DynamicCountableTextBox) ((DynamicCountableTextBox)_targetControl).Text = locationInfo.CS_State.Name; else if (_targetControl is DynamicDropDownList) { if (null != ((DynamicDropDownList)_targetControl).Items.FindByValue(locationInfo.StateID.ToString())) ((DynamicDropDownList)_targetControl).SelectedValue = locationInfo.StateID.ToString(); if (null != ((DynamicDropDownList)_targetControl)._cascadeExtender) ((DynamicDropDownList)_targetControl)._cascadeExtender.DoStuff(null, null); } } } break; case Globals.CallEntry.AutoFillType.JobCountry: using (JobModel model = new JobModel()) { CS_LocationInfo locationInfo = model.GetLocationInfoByJobId(Convert.ToInt32(_filterId)); if (null != locationInfo && null != locationInfo.CS_Country) { if (_targetControl is DynamicTextBox) ((DynamicTextBox)_targetControl).Text = locationInfo.CS_Country.Name; else if (_targetControl is DynamicCountableTextBox) ((DynamicCountableTextBox)_targetControl).Text = locationInfo.CS_Country.Name; else if (_targetControl is DynamicDropDownList) { if (null != ((DynamicDropDownList)_targetControl).Items.FindByValue(locationInfo.CountryID.ToString())) ((DynamicDropDownList)_targetControl).SelectedValue = locationInfo.CountryID.ToString(); if (null != ((DynamicDropDownList)_targetControl)._cascadeExtender) ((DynamicDropDownList)_targetControl)._cascadeExtender.DoStuff(null, null); } } } break; case Globals.CallEntry.AutoFillType.PreviousCallType: using (CallLogModel model = new CallLogModel()) { CS_CallLog callLog = model.GetLastCallEntryByFilter(Convert.ToInt32(_filterId), string.Empty); if (null != callLog && !string.IsNullOrEmpty(callLog.CS_CallType.Description) && !string.IsNullOrEmpty(callLog.Xml)) { DynamicFieldsSerialize serializer = new DynamicFieldsSerialize(); DynamicFieldsAggregator aggregator = serializer.DeserializeObject(callLog.Xml); DynamicControls control = aggregator.Controls.Find(delegate(DynamicControls match) { return match.Name == _conditionalControlName; }); ((DynamicTextBox)_targetControl).Text = ((DynamicTextBoxXml)control).Text; } } break; default: break; } } }
public void DeleteCallLog() { try { using (_callLogModel = new CallLogModel()) { CS_CallLog callLogToRemove = CreateDeleteCallLogEntity(); IList<CS_CallLogResource> callLogResourceListToRemove = CreateDeleteCallLogResourceEntity(); IList<CS_CallLogCallCriteriaEmail> callLogCallCriteriaEmail = CreateDeleteCallLogCallCriteriaEmailEntity(); _callLogModel.UpdateCallLogAndReferences(callLogToRemove, callLogResourceListToRemove, callLogCallCriteriaEmail); } } catch (Exception ex) { Logger.Write(string.Format("There was an error while trying to delete the Call Log!\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("There was an error while trying to delete the Call Log.", false); } }
public void UpdateDpiTimeArrival(CS_CallLog callLog, Globals.CallEntry.CallType type) { CallLogModel model; DateTime actionDate = new DateTime(); using (model = new CallLogModel()) { actionDate = model.GetCallLogActionDateTime(callLog.Xml).Value; } if (!actionDate.Equals(new DateTime())) { DateTime date = actionDate.Date; CS_DPI datedDPI = _dpiRepository.Get(e => e.Date == date && e.JobID == callLog.JobID); CS_DPI newDPI; if (null != datedDPI) { newDPI = new CS_DPI() { ApprovedBy = datedDPI.ApprovedBy, Calculate = datedDPI.Calculate, CalculationStatus = datedDPI.CalculationStatus, CreatedBy = datedDPI.CreatedBy, CreationDate = datedDPI.CreationDate, CreationID = datedDPI.CreationID, Date = datedDPI.Date, FirstATA = datedDPI.FirstATA, FirstETA = datedDPI.FirstETA, ID = datedDPI.ID, IsContinuing = datedDPI.IsContinuing, JobID = datedDPI.JobID, ModificationDate = datedDPI.ModificationDate, ModificationID = datedDPI.ModificationID, ModifiedBy = datedDPI.ModifiedBy, ProcessStatus = datedDPI.ProcessStatus, ProcessStatusDate = datedDPI.ProcessStatusDate, Total = datedDPI.Total }; if (type == Globals.CallEntry.CallType.ETA) { if (!newDPI.FirstETA.HasValue || actionDate < newDPI.FirstETA.Value) { newDPI.FirstETA = actionDate; _dpiRepository.Update(newDPI); } } else { if (!newDPI.FirstATA.HasValue || actionDate < newDPI.FirstATA.Value) { newDPI.FirstATA = actionDate; _dpiRepository.Update(newDPI); } } } } }
public void TestListInitialAdiviseCallLogsByJob() { //Arrange CallLogModel model = new CallLogModel(new FakeUnitOfWork()); //Act IList<CS_CallLog> result = model.ListInitialAdiviseCallLogsByJob(1); //Assert Assert.AreEqual(1, result.Count); }
/// <summary> /// Updates the Email status /// </summary> /// <param name="email">Email row</param> /// <param name="status">New Status</param> public CS_Email UpdateStatusEmail(CS_Email email, Globals.EmailService.Status status) { using (TransactionScope scope = new TransactionScope()) { email.Status = (short)status; email.StatusDate = DateTime.Now; CS_Email emailReturn = _emailRepository.Update(email); Globals.CallCriteria.CallCriteriaEmailStatus callCriteriaStatus = Globals.CallCriteria.CallCriteriaEmailStatus.Sent; switch (status) { case Globals.EmailService.Status.Pending: callCriteriaStatus = Globals.CallCriteria.CallCriteriaEmailStatus.Pending; break; case Globals.EmailService.Status.Sent: callCriteriaStatus = Globals.CallCriteria.CallCriteriaEmailStatus.Sent; break; case Globals.EmailService.Status.Error: callCriteriaStatus = Globals.CallCriteria.CallCriteriaEmailStatus.Error; break; case Globals.EmailService.Status.ConfirmationReceived: callCriteriaStatus = Globals.CallCriteria.CallCriteriaEmailStatus.ConfirmationReceived; break; case Globals.EmailService.Status.ConfirmedAndRead: callCriteriaStatus = Globals.CallCriteria.CallCriteriaEmailStatus.ReadConfirmationReceived; break; default: callCriteriaStatus = Globals.CallCriteria.CallCriteriaEmailStatus.Sent; break; } CallLogModel model = new CallLogModel(_unitOfWork); model.UpdateEmailStatusByEmailId(emailReturn.ID, callCriteriaStatus); scope.Complete(); return emailReturn; } }
/// <summary> /// List all Active Call Types /// </summary> public void ListCallTypes() { try { using (_callLogModel = new CallLogModel()) { _view.CallTypeList = _callLogModel.ListCallTypeFilteredByDescription(_view.PrefixText); } } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to load the Call Type Information!\n{0}\n{1}", ex.Message, ex.StackTrace)); } }
/// <summary> /// Class Constructor /// </summary> /// <param name="view">Instance of View Interface</param> public EquipmentMaintenanceViewModel(IEquipmentMaintenanceView view) { _view = view; _equipmentModel = new EquipmentModel(); _callLogModel = new CallLogModel(); }
public JobCallLogPresenter(IJobCallLogView view, IUnitOfWork unitOfWork) { this._view = view; this._callLogModel = new CallLogModel(unitOfWork); }
/// <summary> /// Generates Email Recordr with a status of Pending to be sent by the Email Service for all receipts /// </summary> /// <param name="receipts">Receipt email address list</param> /// <param name="receiptsIds">Receipt email id list (if it is an employee, for call criteria)</param> /// <param name="subject">Email subject</param> /// <param name="body">Email body (HTML)</param> /// <param name="username">Username that requested the email creation</param> /// <param name="employeeId">EmployeeId of the Username that requested the email creation</param> public void SaveEmailList(string[] receipts, List<int> receiptsIds, string subject, string body, string username, int? employeeId) { using (TransactionScope scope = new TransactionScope()) { using (CallLogModel _callLogModel = new CallLogModel(_unitOfWork)) { for (int i = 0; i < receipts.Length; i++) { CS_Email email = SaveEmail(receipts[i], subject, body, username, employeeId); if (i < receiptsIds.Count) _callLogModel.AttachEmailToCallCriteria(receiptsIds[i], email.ID); } } scope.Complete(); } }
public void VerifyDPICalculateAdded() { //Arrange #region [ Variables ] DateTime now = DateTime.Now; DateTime startDateTime = new DateTime(2011, 08, 01, 12, 0, 0); DateTime startDateTime2 = startDateTime.AddDays(1); #endregion #region [ CallType Repository ] FakeObjectSet<CS_CallType> fakeCallTypeRepository = new FakeObjectSet<CS_CallType>(); fakeCallTypeRepository.AddObject ( new CS_CallType() { ID = 27, Description = "Added Resource", Xml = string.Empty, CallCriteria = true, IsAutomaticProcess = true, DpiStatus = 1, Active = true } ); #endregion #region [ Resource Repository ] FakeObjectSet<CS_Resource> fakeResourceRepository = new FakeObjectSet<CS_Resource>(); fakeResourceRepository.AddObject(new CS_Resource() { ID = 1, EmployeeID = 1, EquipmentID = null, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true }); fakeResourceRepository.AddObject(new CS_Resource() { ID = 2, EmployeeID = null, EquipmentID = 1, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true }); fakeResourceRepository.AddObject(new CS_Resource() { ID = 3, EmployeeID = null, EquipmentID = 2, JobID = 1, Duration = 1, StartDateTime = startDateTime, Active = true }); fakeResourceRepository.AddObject(new CS_Resource() { ID = 4, EmployeeID = null, EquipmentID = 3, JobID = 1, Duration = 1, StartDateTime = startDateTime2, Active = true }); #endregion #region [ DPI Repository ] FakeObjectSet<CS_DPI> fakeDPIRepository = new FakeObjectSet<CS_DPI>(); fakeDPIRepository.AddObject(new CS_DPI() { ID = 1, Date = startDateTime.Date, Calculate = false, ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved, JobID = 1, IsContinuing = true, ProcessStatusDate = DateTime.Now, CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF, Total = 1000, CreatedBy = "System", //CreationID =, CreationDate = DateTime.Now, ModifiedBy = "System", //ModificationID, ModificationDate = DateTime.Now, Active = true, CS_DPIResource = new EntityCollection<CS_DPIResource>() { new CS_DPIResource() { ID = 1, DPIID = 1, EmployeeID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 2, Active = true, } } }); fakeDPIRepository.AddObject(new CS_DPI() { ID = 2, Date = startDateTime2.Date, Calculate = false, ProcessStatus = (int)Globals.DPI.DpiStatus.DraftSaved, JobID = 1, IsContinuing = true, ProcessStatusDate = DateTime.Now, CalculationStatus = (short)Globals.DPI.CalculationStatus.INSF, Total = 1000, CreatedBy = "System", //CreationID =, CreationDate = DateTime.Now, ModifiedBy = "System", //ModificationID, ModificationDate = DateTime.Now, Active = true, CS_DPIResource = new EntityCollection<CS_DPIResource>() { new CS_DPIResource() { ID = 1, DPIID = 1, EmployeeID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 1, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 2, Active = true }, new CS_DPIResource() { ID = 1, DPIID = 1, EquipmentID = 3, Active = true } } }); #endregion #region [ Parameters ] CS_CallLog callLog = new CS_CallLog() { CallTypeID = (int)Globals.CallEntry.CallType.AddedResource, CreationDate = now, CallDate = now, JobID = 1 }; List<int> employeeIDList = new List<int>() { 1 }; List<int> equipmentIDList = new List<int>() { 1, 2 }; #endregion #region [ Mock ] Mock<IUnitOfWork> mockUnitOfWork = new Mock<IUnitOfWork>(); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_CallType>()).Returns(fakeCallTypeRepository); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_Resource>()).Returns(fakeResourceRepository); mockUnitOfWork.Setup(e => e.CreateObjectSet<CS_DPI>()).Returns(fakeDPIRepository); CallLogModel model = new CallLogModel(mockUnitOfWork.Object); #endregion //Act model.VerifyDPICalculate(callLog, employeeIDList, equipmentIDList); //Assert CS_DPI dpi = fakeDPIRepository.FirstOrDefault(e => e.ID == 1); CS_DPI dpi2 = fakeDPIRepository.FirstOrDefault(e => e.ID == 2); Assert.IsTrue(dpi.Calculate, "Fail at Calculate True"); Assert.IsFalse(dpi2.Calculate, "Fail at Calculate False"); }
/// <summary> /// List all call types separated by primary call type /// </summary> public void ListAllCallTypes() { try { using (_callLogModel = new CallLogModel()) { _view.PrimaryCallTypeList = _callLogModel.ListAllPrimaryCallTypesForCallCriteria(); } } catch (Exception ex) { Logger.Write(string.Format("An Error has occurred while trying to list Call Types.\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Internal Error has occurred while trying to list Call Types.", false); } }
private List<DPICallLogVO> GetDPICallLogTimesFromList(List<CS_CallLogResource> originalCallLogs, DateTime calculationDate) { List<DPICallLogVO> returnList = new List<DPICallLogVO>(); CallLogModel model = new CallLogModel(); for (int i = 0; i < originalCallLogs.Count; i++) { DPICallLogVO newVO = new DPICallLogVO() { ID = originalCallLogs[i].CallLogID }; if (originalCallLogs[i].ActionDate.HasValue) newVO.ActionTime = originalCallLogs[i].ActionDate.Value; else { // Only for old records if (originalCallLogs[i].CS_CallLog.CS_CallType.ID == (int)Globals.CallEntry.CallType.AddedResource) { int jobID = originalCallLogs[i].JobID; int? employeeID = originalCallLogs[i].EmployeeID; int? equipmentID = originalCallLogs[i].EquipmentID; CS_Resource addedResource = _resourceRepository.Get(e => e.Active && e.JobID == jobID && ((employeeID.HasValue && e.EmployeeID == employeeID.Value) || (equipmentID.HasValue && e.EquipmentID == equipmentID.Value))); if (null != addedResource) newVO.ActionTime = addedResource.StartDateTime; else newVO.ActionTime = new DateTime(); } else if (originalCallLogs[i].CS_CallLog.CS_CallType.IsAutomaticProcess) { newVO.ActionTime = originalCallLogs[i].CS_CallLog.CreationDate; } else { newVO.ActionTime = model.GetCallLogActionDateTime(originalCallLogs[i].CS_CallLog.Xml).Value; } } if (newVO.ActionTime.Date == calculationDate.Date) returnList.Add(newVO); } returnList.Sort(); return returnList; }