private async Task Send(LetterDTO letter) { using (var client = new HttpClient()) { HttpResponseMessage response = await client.PostAsJsonAsync(_pathToServer + "api/values", letter); } }
public void ShowMessage(LetterDTO letter) { message = letter; txtTitle.Text = message.Title; txtNumber.Text = message.LetterNumber; txtDate.SelectedDate = message.LetterDate; txtDesc.Text = message.Desc; txtCreateDate.SelectedDate = message.CreationDate; txtCreateUser.Text = message.vwUser; txtExternalCode.Text = message.ExternalCode; cmbType.SelectedValue = message.LetterTypeID; //lokRelatedLetter.SelectedValue = message.RelatedLetterID; if (message.IsExternalOrInternal) { optExternal.IsChecked = true; } else { optInternal.IsChecked = true; } if (message.IsGeneratedOrSelected == true) { optGenerate.IsChecked = true; } else if (message.IsGeneratedOrSelected == false) { optSelective.IsChecked = true; } else { optGenerate.IsChecked = false; optSelective.IsChecked = false; } }
private LetterDTO ToLetterDTO(DR_Requester requester, Letter item, bool withDetails, MyProjectEntities projectContext) { LetterDTO result = new LetterDTO(); result.ID = item.ID; result.LetterNumber = item.LetterNumber; result.CreationDate = item.CreationDate; result.Desc = item.Desc; result.IsGeneratedOrSelected = item.IsGeneratedOrSelected; result.LetterDate = item.LetterDate; result.LetterNumber = item.LetterNumber; result.IsExternalOrInternal = item.FromExternalSource; result.ExternalCode = item.ExternalSourceKey; result.LetterTemplateID = item.LetterTemplateID == null ? 0 : item.LetterTemplateID.Value; result.LetterTypeID = item.LetterTypeID; result.vwLetterType = projectContext.LetterType.First(x => x.ID == result.LetterTypeID).Name; result.RelatedLetterID = item.RelatedLetterID == null ? 0 : item.RelatedLetterID.Value; // result.DatItemID = item.MyDataItemID; //روش خوبی نیست که برای هر دیتا آیتم اطلاعات داده گرفته شود result.DataItem = bizDataItem.ToDataViewDTO(requester, item.MyDataItem, true); //////foreach (var dataitem in item.MyDataItem_Letter) ////// result.RelatedDataItems.Add(bizDataItem.ToDataItemDTO(dataitem.MyDataItem)); result.Title = item.Title; result.UserID = item.UserID; result.AttechedFileID = item.FileRepositoryID == null ? 0 : item.FileRepositoryID.Value; result.HasAttechedFile = result.AttechedFileID != 0; if (withDetails) { if (item.FileRepository != null) { result.AttechedFile = bizFileRepository.ToFileRepository(item.FileRepository); } } return(result); }
public LetterDTO GetLetterById(int letterId) { var letter = _letterRepository.Get(letterId); LetterDTO resultLetter = new LetterDTO(letter); return(resultLetter); }
public void Post(LetterDTO value) { if (value == null) { throw new NullReferenceException(); } _messagesService.AddLetter(value); }
public void AddLetter(LetterDTO letter) { if (letter == null) { throw new NullReferenceException(); } _letterRepository.Create(new Letter(letter.Id, letter.LetterTheme, letter.SenderId, letter.RecieverId, letter.LetterDate, letter.Content)); }
private void EditMenu_Clicked(object sender, EventArgs e, LetterDTO letter) { var initializer = new LetterAreaInitializer(); initializer.LetterID = letter.ID; var editLetterArea = new EditLetterArea(initializer); editLetterArea.LetterUpdated += EditLetterArea_LetterUpdated; AgentUICoreMediator.GetAgentUICoreMediator.UIManager.GetDialogWindow().ShowDialog(editLetterArea.View, "نامه", Enum_WindowSize.Big); }
private void View_ExternalInfoRequested(object sender, LetterExternalInfoRequestedArg e) { if (LetterSetting != null && LetterSetting.LetterExternalInfoCodeID != 0) { View.UpdateMessage(); LetterDTO sendingLetter = new LetterDTO(); sendingLetter.ExternalCode = e.ExternalCode; var result = codeFunctionHandler.GetCodeFunctionResult(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), LetterSetting.LetterExternalInfoCodeID, sendingLetter); if (result.Exception == null) { if (!string.IsNullOrEmpty(sendingLetter.Title)) { LetterMessage.Title = sendingLetter.Title; } LetterMessage.LetterDate = sendingLetter.LetterDate; if (string.IsNullOrEmpty(LetterMessage.Desc) && !string.IsNullOrEmpty(sendingLetter.Desc)) { LetterMessage.Desc = sendingLetter.Desc; } LetterMessage.AttechedFile = sendingLetter.AttechedFile; if (LetterMessage.AttechedFile != null && LetterMessage.AttechedFile.Content != null) { if (LetterMessage.AttechedFile.FileName == null) { LetterMessage.AttechedFile.FileName = "فایل ضمیمه دارد"; } if (LetterMessage.AttechedFile.FileExtension == null) { LetterMessage.AttechedFile.FileExtension = "???"; } View.ViewExternalFileInfo(LetterMessage.AttechedFile.FileName + "." + LetterMessage.AttechedFile.FileExtension); View.ViewExternalFilePanelVisibility = true; } else { View.ViewExternalFilePanelVisibility = false; LetterMessage.AttechedFile = null; } //اگر فایل از منبع خارجی کلا حذف شده بود چی؟ //LetterMessage.IsExternalOrInternal = true; View.ShowMessage(LetterMessage); } else { } } else { AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowMessage("رویه ای به منظور دربافت اطلاعات نامه خارجی موجود نمی باشد"); return; } }
private DataLogDTO GetAfterUpdateExceptionLog(LetterDTO message, Exception Exception, DataLogType logType) { var dataLog = new DataLogDTO(); dataLog.LocationInfo = ""; dataLog.Duration = 0; dataLog.MinorException = true; dataLog.MainType = logType; dataLog.DatItem = message.DataItem; dataLog.LetterItemLog.AfterUpdateException = Exception.Message; return(dataLog); }
public EditLetterArea(LetterAreaInitializer areaInitializer) { AreaInitializer = areaInitializer; //EntityID = entityId; if (AreaInitializer.LetterID != 0) { LetterMessage = AgentUICoreMediator.GetAgentUICoreMediator.LetterManager.GetLetter(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), AreaInitializer.LetterID, true); AreaInitializer.DataInstance = LetterMessage.DataItem; } else { LetterMessage = new LetterDTO(); } var permissions = AgentUICoreMediator.GetAgentUICoreMediator.tableDrivedEntityManagerService.GetEntityAssignedPermissions(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), areaInitializer.DataInstance.TargetEntityID, false); if (!permissions.GrantedActions.Any(x => x == SecurityAction.LetterEdit)) { return; } View = AgentUICoreMediator.GetAgentUICoreMediator.UIManager.GenerateViewOfLetterArea(); SetExtensions(); View.GenerateFileClicked += View_GenerateFileClicked; View.LetterConfirmed += View_LetterConfirmed; View.NewClicked += View_NewClicked; View.ShowExternalFileClicked += View_ShowExternalFileClicked; View.ShowFileClicked += View_ShowFileClicked; View.DownloadFileClicked += View_DownloadFileClicked; View.ConvertToExternalClicked += View_ConvertToExternalClicked; View.GenerateOrSelectClicked += View_GenerateOrSelectClicked; View.ExternalOrInternalClicked += View_ExternalOrInternalClicked; View.ExternalInfoRequested += View_ExternalInfoRequested; View.ShowGeneratedFileClicked += View_ShowGeneratedFileClicked; relatedLetterSearchLookup = new MySearchLookup(); relatedLetterSearchLookup.DisplayMember = "Title"; relatedLetterSearchLookup.SelectedValueMember = "ID"; relatedLetterSearchLookup.SearchFilterChanged += RelatedLetterSearchLookup_SearchFilterChanged; relatedLetterSearchLookup.SelectionChanged += RelatedLetterSearchLookup_SelectionChanged; View.AddRelatedLetterSelector(relatedLetterSearchLookup); ShowLetter(); var letterTemplates = AgentUICoreMediator.GetAgentUICoreMediator.LetterManager.GetMainLetterTemplates(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), AreaInitializer.DataInstance.TargetEntityID); View.LetterTemplates = letterTemplates; View.LetterTypes = AgentUICoreMediator.GetAgentUICoreMediator.LetterManager.GetLetterTypes(); LetterSetting = AgentUICoreMediator.GetAgentUICoreMediator.LetterManager.GetLetterSettings(); //if(LetterSetting==null||LetterSetting.LetterExternalInfoCode==null) }
private void DeleteMenu_Clicked1(object sender, EventArgs e, LetterDTO letter) { var text = "آیا از حذف نامه مطمئین هستید؟"; var ask = AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowConfirm("تایید", text, UserPromptMode.YesNo); if (ask == Temp.ConfirmResul.Yes) { var result = AgentUICoreMediator.GetAgentUICoreMediator.LetterManager.DeleteLetter(AgentUICoreMediator.GetAgentUICoreMediator.GetRequester(), letter.ID); AgentUICoreMediator.GetAgentUICoreMediator.UIManager.ShowMessage("پیام", result.Message, result.Details); if (result.Result) { ShowLetters(); } } }
private DataLogDTO GetUpdateLetterDataLog(LetterDTO message, string exceptionMessage, DataLogType logType) { var dataLog = new DataLogDTO(); dataLog.LocationInfo = ""; dataLog.Duration = 0; dataLog.DatItem = message.DataItem; dataLog.MainType = logType; dataLog.RelatedItemID = message.ID; if (!string.IsNullOrEmpty(exceptionMessage)) { dataLog.MajorException = true; dataLog.MajorFunctionExceptionMessage = exceptionMessage; //dataLog.ArchiveItemLog = new ArchiveItemLogDTO(); //dataLog.ArchiveItemLog.Exception = exceptionMessage; } return(dataLog); }
private void Button_Click(object sender, RoutedEventArgs e) { LetterDTO letterToSend = new LetterDTO(messageTheme.Text, (int?)Int32.Parse(senderId.Text), (int?)Int32.Parse(recieverId.Text), DateTime.Now, messageContent.Text); Send(letterToSend); }
public FunctionResult GetCodeFunctionResult(DR_Requester resuester, int codeFunctionID, LetterDTO letter) { var codeFunction = bizCodeFunction.GetCodeFunction(resuester, codeFunctionID); if (codeFunction.ParamType == ModelEntites.Enum_CodeFunctionParamType.LetterFunction) { var parameters = new List <object>(); parameters.Add(new LetterFunctionParam(letter, resuester)); return(GetCodeFunctionResult(codeFunction, parameters)); } else { return(null); } }
public LetterResult UpdateLetter(LetterDTO message, DR_Requester requester) { BizTableDrivedEntity bizTableDrivedEntity = new BizTableDrivedEntity(); if (!bizTableDrivedEntity.DataIsAccessable(requester, message.DataItem.TargetEntityID, new List <SecurityAction>() { SecurityAction.LetterEdit })) { throw new Exception("عدم دسترسی ثبت نامه"); } LetterResult result = new LetterResult(); bool isNew = message.ID == 0; var letterSetting = GetLetterSetting(); if (letterSetting != null) { if (letterSetting.BeforeLetterSaveCodeID != 0) { var resultFunction = codeFunctionHandler.GetCodeFunctionResult(requester, letterSetting.BeforeLetterSaveCodeID, message); if (resultFunction.Exception != null) { var logResult = bizLogManager.AddLog(GetBeforeUpdateExceptionLog(message, resultFunction.Exception, isNew ? DataLogType.LetterInsert : DataLogType.LetterUpdate), requester); if (!string.IsNullOrEmpty(logResult)) { ResultDetail logException = new ResultDetail(); logException.Title = "خطای ثبت لاگ"; logException.Description = "خطای لاگ برای اقدام قبل از ثبت نامه"; logException.TechnicalDescription = logResult; result.Details.Add(logException); } result.Message = "اقدامات مرتبط قبل از ثبت نامه با خطا همراه بود"; return(result); } } } using (var letterModel = new MyIdeaDataDBEntities()) { try { var dbLetter = letterModel.Letter.FirstOrDefault(x => x.ID == message.ID); if (dbLetter == null) { dbLetter = new Letter(); dbLetter.CreationDate = DateTime.Now; dbLetter.UserID = requester.Identity; //var dataItemID = bizDataItem.GetOrCreateDataItem(message.DataItem); if (message.DataItem.DataItemID == 0) { dbLetter.MyDataItemID = bizDataItem.GetOrCreateDataItem(message.DataItem); message.DataItem.DataItemID = dbLetter.MyDataItemID; } else { dbLetter.MyDataItemID = message.DataItem.DataItemID; } } dbLetter.ID = message.ID; dbLetter.Desc = message.Desc; dbLetter.LetterNumber = message.LetterNumber; dbLetter.IsGeneratedOrSelected = message.IsGeneratedOrSelected; dbLetter.FromExternalSource = message.IsExternalOrInternal; dbLetter.ExternalSourceKey = message.ExternalCode; dbLetter.LetterNumber = message.LetterNumber; dbLetter.LetterDate = message.LetterDate; dbLetter.LetterTemplateID = message.LetterTemplateID == 0 ? (int?)null : message.LetterTemplateID; dbLetter.LetterTypeID = message.LetterTypeID; dbLetter.RelatedLetterID = message.RelatedLetterID == 0 ? (int?)null : message.RelatedLetterID; dbLetter.Title = message.Title; if (dbLetter.FileRepository == null) { if (message.AttechedFile != null && message.AttechedFile.Content != null) { dbLetter.FileRepository = bizFileRepository.ToFileRepository(letterModel, message.AttechedFile); } } if (dbLetter.ID == 0) { letterModel.Letter.Add(dbLetter); } letterModel.SaveChanges(); message.ID = dbLetter.ID; result.SavedID = dbLetter.ID; result.Result = true; } catch (Exception ex) { result.Result = false; result.Message = ex.Message; } finally { var logResult = bizLogManager.AddLog(GetUpdateLetterDataLog(message, result.Message, isNew ? DataLogType.LetterInsert : DataLogType.LetterUpdate), requester); if (!string.IsNullOrEmpty(logResult)) { ResultDetail logException = new ResultDetail(); logException.Title = "خطای ثبت لاگ"; logException.Description = "خطای لاگ برای ثبت نامه"; logException.TechnicalDescription = logResult; result.Details.Add(logException); } } } if (result.Result == false) { result.Message = "عملیات ثبت با خطا همراه بود"; return(result); } else { bool afterSaveException = false; if (letterSetting != null) { if (letterSetting.AfterLetterSaveCodeID != 0) { var resultFunction = codeFunctionHandler.GetCodeFunctionResult(requester, letterSetting.AfterLetterSaveCodeID, message); if (resultFunction.Exception != null) { afterSaveException = true; var logResult = bizLogManager.AddLog(GetAfterUpdateExceptionLog(message, resultFunction.Exception, isNew ? DataLogType.LetterInsert : DataLogType.LetterUpdate), requester); if (!string.IsNullOrEmpty(logResult)) { ResultDetail logException = new ResultDetail(); logException.Title = "خطای ثبت لاگ"; logException.Description = "خطای لاگ برای اقدام بعد از ثبت نامه"; logException.TechnicalDescription = logResult; result.Details.Add(logException); } return(result); } } } if (afterSaveException) { result.Message = "عملیات ثبت با موفقیت انجام شد اما اقدامات بعد از ثبت با خطا همراه بود"; } else { result.Message = "عملیات ثبت با موفقیت انجام شد"; } return(result); } }
private void View_NewClicked(object sender, EventArgs e) { LetterMessage = new LetterDTO(); ShowLetter(); }
public LetterFunctionParam(LetterDTO letter, DR_Requester requester) : base(requester) { Letter = letter; }
public LetterResult UpdateLetter(LetterDTO letter, DR_Requester requester) { return(bizLetter.UpdateLetter(letter, requester)); }