/// <summary> /// Saves a call log /// </summary> public void SaveCallLog() { try { CS_CallLog callEntry = _view.CallEntryEntity; if (_view.DynamicFieldsControls.Count > 0) { callEntry.Xml = DynamicFieldsParser.CreateXmlFromControls(_view.DynamicFieldsControls, _view.DynamicControlXmlString); if (string.IsNullOrEmpty(callEntry.Note) && !string.IsNullOrEmpty(callEntry.Xml)) { callEntry.Note = "Job #:<Text>"; if (_view.JobId != (int)Globals.GeneralLog.ID) callEntry.Note += _view.PrefixedJobNumber + "<BL>"; else callEntry.Note += "PA99999 - General Log<BL>"; callEntry.Note += DynamicFieldsParser.FormatDynamicFieldsData(DynamicFieldsParser.GetDynamicFieldControlsProperties(callEntry.Xml)); callEntry.Note += _viewModel.FormatResourcesOrPersonsData(); } } if (_view.CopyToShiftTransferLog) callEntry.ShiftTransferLog = true; if (_view.CopyToGeneralLog) callEntry.HasGeneralLog = true; IList<CS_CallLog_LocalEquipmentType> callLogEqTypeList = new List<CS_CallLog_LocalEquipmentType>(); for (int i = 0; i < _view.SelectedEquipmentTypes.Count; i++) { if (!_view.CallID.HasValue) callLogEqTypeList.Add(_viewModel.ParseVOToCallLogEquipmentTypeEntity(callEntry.ID, _view.SelectedEquipmentTypes[i], false)); else callLogEqTypeList.Add(_viewModel.ParseVOToCallLogEquipmentTypeEntity(callEntry.ID, _view.SelectedEquipmentTypes[i], true)); } using (_callLogModel = new CallLogModel()) { _callLogModel.SaveCallLogData(callEntry, _view.SelectedPersons.ToList(), _view.SelectedResources.ToList(), callLogEqTypeList, callEntry.ID != 0, _view.CopyToGeneralLog); IList<int> callLogHistory = _view.CallLogHistoryList; callLogHistory.Add(callEntry.ID); _view.CallLogHistoryList = callLogHistory; //IList<CS_CallLog_LocalEquipmentType> callLogEqTypeList = new List<CS_CallLog_LocalEquipmentType>(); //for (int i = 0; i < _view.SelectedEquipmentTypes.Count; i++) //{ // callLogEqTypeList.Add(_viewModel.ParseVOToCallLogEquipmentTypeEntity(callEntry.ID, _view.SelectedEquipmentTypes[i])); //} //if (callLogEqTypeList.Count > 0) // _callLogModel.SaveCallLogEquipmentTypeList(callLogEqTypeList); if (!_view.SaveAndContinue) { CS_CallType calltype = _callLogModel.GetCallType(callEntry.CallTypeID); _view.OpenEmailPage = calltype.SendEmail; } } _view.SavedSuccessfuly = true; } catch (Exception ex) { Logger.Write(string.Format("An Error has ocurred while trying to save the call log.\n{0}\n{1}", ex.Message, ex.StackTrace)); _view.DisplayMessage("An Internal Error has ocurred while trying to save the Information. Please try again.", false); _view.SavedSuccessfuly = false; } }