public async Task <IActionResult> OnPostDeleteAsync(Guid titleId, Guid documentTypeId) { try { if (_getAccountDataService.IsSystemAdmin()) { DocumentTitle deletingTitle = await db.DocumentTitle .Where(dt => dt.DocumentTypeId.Equals(documentTypeId)) .FirstOrDefaultAsync(r => r.Id.Equals(titleId)); if (deletingTitle != null) { db.DocumentTitle.Remove(deletingTitle); await db.SaveChangesAsync(); } return(RedirectToPage("Index", new { documentTypeId })); } else { return(NotFound()); } } catch (Exception e) { _logger.LogError(e, "Error while deleting document title"); return(NotFound()); } }
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e) { base.OnPropertyChanged(e); if (e.Property.Name != nameof(DocumentTitle) || StateFullDocument is null || _documentTitle == DocumentTitle) { return; } _documentTitle = DocumentTitle; if (DocumentTitle.Contains(Constants.TempFileExtension)) { return; } CacheChanges(); DocumentStyles.Update(Document.Styles); StateFullDocument.NewDocument(TemporalFilePath); var args = new DocumentUpdatedEventArgs(StateFullDocument.State, ViewDocumentTitle); DocumentStateChanged?.Invoke(this, args); }
public async System.Threading.Tasks.Task AfterOpen() { CanvasCase canvasCase = currentController.CurrentCanvasCase; DocumentTitle.SetBinding(TextBlock.TextProperty, new Binding() { Path = new PropertyPath("Name"), Source = canvasCase, Mode = BindingMode.TwoWay }); DCUI_Canvas.SetCanvasCase(canvasCase); LayoutsPanel.SetCanvasCase(canvasCase); BrushPanel.SetCanvasCase(canvasCase); ColorAndOtherPanel.SetCanvasCase(canvasCase); BlendModePanel.SetCanvasCase(canvasCase); LayoutInfoPanel.SetCanvasCase(canvasCase); foreach (Core.Brush brush in canvasCase.PaintAgent.brushes) { if (!string.IsNullOrEmpty(brush.ImagePath)) { try { StorageFile f = await currentController.CurrentDCDocument.brushesFolder.GetFileAsync(brush.ImagePath); BitmapImage image = new BitmapImage(); image.SetSource(await f.OpenReadAsync()); ImageBrush imageBrush = new ImageBrush { ImageSource = image }; brush.UIBrush = imageBrush; } catch { brush.UIBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(0xFF, 0xC0, 0xC0, 0xC0)); } } else { brush.UIBrush = new SolidColorBrush(Windows.UI.Color.FromArgb(0xFF, 0xC0, 0xC0, 0xC0)); } for (int i = 0; i < Core.Brush.c_refTextureCount; i++) { if (!string.IsNullOrEmpty(brush.RefTexturePath[i])) { try { StorageFile f = await currentController.CurrentDCDocument.brushesFolder.GetFileAsync(brush.RefTexturePath[i]); var stream = await f.OpenReadAsync(); byte[] array = new byte[stream.Size]; DataReader dataReader = new DataReader(stream); await dataReader.LoadAsync((uint)stream.Size); dataReader.ReadBytes(array); brush.refTexture[i] = RenderTexture.LoadFromBytes(canvasCase.DeviceResources, array, currentController.CImport); } catch { } } } } }
public async Task <IActionResult> OnPostAsync(Guid titleId, string titleName, string titleDescription) { try { if (_getAccountDataService.IsSystemAdmin()) { selectedDocumentTitle = await db.DocumentTitle .Include(dt => dt.DocumentType) .FirstOrDefaultAsync(dt => dt.Id == titleId); if (selectedDocumentTitle != null) { if (selectedDocumentTitle.Description != titleDescription || selectedDocumentTitle.Name != titleName) { if (selectedDocumentTitle.Name != titleName) { selectedDocumentTitle.Name = titleName; } if (selectedDocumentTitle.Description != titleDescription) { selectedDocumentTitle.Description = titleDescription; } if (await TryUpdateModelAsync <DocumentTitle>(selectedDocumentTitle)) { if (await db.SaveChangesAsync() > 0) { return(RedirectToPage("Index", new { documentTypeId = selectedDocumentTitle.DocumentType.Id })); } } } else { return(RedirectToPage("Index", new { documentTypeId = selectedDocumentTitle.DocumentType.Id })); } _logger.LogError("Error while saving changed on page of Editing document title.\nFailed to save changes"); return(NotFound()); } else { _logger.LogError("Error while saving changed on page of Editing document title.\nFailed to load document title"); return(NotFound()); } } else { return(NotFound()); } } catch (Exception e) { _logger.LogError(e, "Error while saving changed on page of Editing document title"); return(NotFound()); } }
public async Task <IActionResult> OnGetAsync(Guid yearId, Guid departmentId, Guid documentTypeId, Guid documentTitleId) { try { if (!await _getAccountDataService.UserIsHaveAnyRoleOnDepartment(departmentId)) { return(NotFound()); } selectedReportingYearId = yearId; selectedDepartmentId = departmentId; selectedDocumentTypeId = documentTypeId; selectedDocumentTitleId = documentTitleId; user = await _getAccountDataService.GetCurrentUser(); DocumentsTitle = await db.DocumentTitle.FirstOrDefaultAsync(dt => dt.Id.Equals(documentTitleId)); IsUserTheChecker = await _getAccountDataService.UserIsCheckerOnDepartment(departmentId); AllAvailabledocumentStatuses = await db.DocumentStatus.ToListAsync(); departmentsDocument = await _documentManagerService .GetDepartmentsDocument(departmentId, await _documentManagerService.GetCurrentReportingYearDocumentTitleId(yearId, documentTitleId)); DocumentStatusHistories = await db.DocumentStatusHistory .Include(dsh => dsh.DocumentStatus) .Where(dd => dd.DepartmentsDocumentId == departmentsDocument.Id) .OrderBy(dd => dd.SettingDateTime) .Include(dsh => dsh.User) .ToListAsync(); UploadedDocuments = await db.DepartmentsDocumentsVersion .Where(ddv => ddv.DepartmentDocumentId == departmentsDocument.Id) .OrderByDescending(ddv => ddv.UploadedDateTime) .Include(ddv => ddv.User) .ToListAsync(); var CurrentBreadCrumb = await _breadcrumbService.GetDocumentBreadCrumbNodeAsync( yearId, departmentId, documentTypeId, documentTitleId); ViewData["BreadcrumbNode"] = CurrentBreadCrumb; ViewData["Title"] = CurrentBreadCrumb.Title; return(Page()); } catch (Exception ex) { _logger.LogError(ex, "Error while getting document page"); return(NotFound()); } }
public async Task <IActionResult> OnGetAsync(Guid titleId) { try { if (_getAccountDataService.IsSystemAdmin()) { selectedDocumentTitle = await db.DocumentTitle .FirstOrDefaultAsync(dt => dt.Id == titleId); return(Page()); } else { return(NotFound()); } } catch (Exception e) { _logger.LogError(e, "Error while getting page of Editing document title"); return(NotFound()); } }
public async Task SaveTitleToSoup(string title, string docId, CancellationToken token = default(CancellationToken)) { await Task.Factory.StartNew(() => { if (string.IsNullOrWhiteSpace(title)) { return; } SetupSoupIfNotExistsNeeded(); var querySpec = QuerySpec.BuildExactQuerySpec(SoupName, "Title", title, 1); var results = Store?.Query(querySpec, 0) .Select(item => CustomPrefixJsonConvert.DeserializeObject <DocumentTitle>(item.ToString())) .FirstOrDefault(); var docTitle = new DocumentTitle { Title = title, DocumentIds = new List <string> { docId } }; if (results != null) { if (results.DocumentIds.Contains(docId)) { return; } results.DocumentIds.Add(docId); docTitle.DocumentIds = results.DocumentIds; } var jTag = JObject.FromObject(docTitle); Store?.Upsert(SoupName, jTag, "Title"); }, token); }
public JsonResult CreateDocument(SecondClassDocument SCD) { try { var Doc = SCD; string dateDocument; dateDocument = Doc.Year + "-" + Doc.Month + "-" + Doc.Day; Documents document = new Documents() { DocumentNumber = Doc.numberDocument, Date = DateTime.Parse(dateDocument), NDS = Doc.NDS }; Contracts contract = dbModel.Contracts.FirstOrDefault(c => c.IdContract == Doc.contractID); document.Contracts.Add(contract); var DocumentNew = dbModel.Documents.Add(document); dbModel.SaveChanges(); var DocumentNewID = DocumentNew.IdDocument; /// Id нового документа для таблицы наименований // 5 полей ввода Doc.ArrayDocTitle.Count() 10/5=2; int CountArray = Doc.ArrayDocTitle.Count(); int max = (CountArray / 5); int t = 0; for (int i = 1; i < max; i++) { DocumentTitle docTitle = new DocumentTitle() { Title = Doc.ArrayDocTitle[t], UnitMeasurements = Doc.ArrayDocTitle[t + 1], Amount = double.Parse(Doc.ArrayDocTitle[t + 2]), PriceWithoutNDS = double.Parse(Doc.ArrayDocTitle[t + 3]), SumWithoutNDS = double.Parse(Doc.ArrayDocTitle[t + 4]) }; Documents doc = dbModel.Documents.FirstOrDefault(d => d.IdDocument == DocumentNewID); docTitle.Documents.Add(doc); dbModel.DocumentTitle.Add(docTitle); t = t + 5; } // for dbModel.SaveChanges(); return(Json("{status: '200'}")); } catch (Exception ex) { return(Json($"{{status: '500', message: '{ex.Message} {ex.StackTrace}'}}")); /*501 Not Implemented («не реализовано»); * 500 Internal Server Error («внутренняя ошибка сервера») */ } }//CreateDocumen
/// <summary> /// Determines whether the specified <see cref="DocumentTitle" />, is equal to this instance. /// </summary> /// <param name="other">The other.</param> /// <returns>true if equal; otherwise, false</returns> protected bool Equals(DocumentTitle other) { return(Equals(Attributes, other.Attributes) && string.Equals(Subtitle, other.Subtitle) && string.Equals(Title, other.Title)); }
public int CompareTo(DocumentTitle compareDocument) { return(this.DocumentID.CompareTo(this.DocumentID)); }
//Modify Existing Code on Main App //207 Lines of Code private void Search(string query) { int docCount = 1; bool truncate = false; Log.Info("Search()", String.Format("Search Begins" + "")); searchFragmentActivity = new SearchFragmentActivity(); // RadioButton radio = FindViewById<RadioButton>(Resource.Id.viewAllRadio); using (var conn = new SQLite.SQLiteConnection(dbPath)) { var cmd = new SQLite.SQLiteCommand(conn); var searchStr = new SQLite.SQLiteCommand(conn); bool proofs = true, answers = true, searchAll = false, viewDocs = false; CheckBox answerCheck = FindViewById <CheckBox>(Resource.Id.AnswerBox), proofCheck = FindViewById <CheckBox>(Resource.Id.proofBox), searchCheck = FindViewById <CheckBox>(Resource.Id.searchAllCheckBox); RadioButton viewRadio = FindViewById <RadioButton>(Resource.Id.viewAllRadio); Spinner spinner = FindViewById <Spinner>(Resource.Id.spinner1), spinner2 = FindViewById <Spinner>(Resource.Id.spinner2); spinner.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Spinner1_ItemSelected); spinner2.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(Spinner2_ItemSelected); string fileString = "", accessString = ""; accessString = TableAccess(""); if (searchCheck.Checked) { searchAll = true; } else { searchAll = false; accessString = TableAccess(string.Format(" where documentname = '{0}' ", fileName)); } //Data filters if (allOpen) { if (searchAll) { fileString = TableAccess("");//"select * from Documenttitlelist"; } else { fileString = TableAccess(string.Format("Where Documentname='{0}'", fileName));//String.Format("select * from DocumentTableList where DocumentName='{0}'", fileName); } } if (catechismOpen) { if (searchAll) { fileString = TableAccess("Where documentTypeName='CATECHISM'"); //"and DocumentTypeName='CATECHISM'"); } else { fileString = TableAccess(String.Format("where DocumentTypeName='CATECHISM' and DocumentName='{0}' ", fileName)); } } if (confessionOpen) { if (searchAll) { fileString = TableAccess("where DocumentTypeName='CONFESSION' "); } else { fileString = TableAccess(String.Format("where DocumentTypeName='CONFESSION' and DocumentName='{0}' ", fileName)); } } if (creedOpen) { if (searchAll) { fileString = TableAccess("where DocumentTypeName='CREED' "); } else { fileString = TableAccess(string.Format("where DocumentTypeName='CREED' and DocumentName='{0}' ", fileName)); } } //Proofs enabled if (proofCheck.Checked) { proofs = true; } else { proofs = false; } //Read Document if (viewRadio.Checked) { viewDocs = true; } else { viewDocs = false; } cmd.CommandText = fileString; searchStr.CommandText = accessString; var r = cmd.ExecuteQuery <DocumentTitle>(); var searchFields = searchStr.ExecuteQuery <Document>(); documentList = new DocumentList(); //Add Entries to DocumentList for (int x = 0; x < searchFields.Count; x++) { DocumentTitle docTitle = new DocumentTitle(); docTitle.DocumentID = searchFields[x].DocumentID; for (int y = 0; y < r.Count; y++) { if (!r[y].DocumentID.Equals(docTitle.DocumentID)) { foreach (DocumentTitle doc in r) { if (doc.DocumentID == docTitle.DocumentID) { docTitle.Title = doc.Title; } else { continue; } } } else { docTitle.Title = r[y].CompareIDs(docTitle.DocumentID); } } searchFields[x].DocumentName = docTitle.Title; Document document = new Document(); document.ChName = searchFields[x].ChName; document.DocDetailID = searchFields[x].DocDetailID; document.DocumentText = Formatter(searchFields[x].DocumentText); document.DocumentName = searchFields[x].DocumentName; document.ChNumber = searchFields[x].ChNumber; document.ChProofs = Formatter(searchFields[x].ChProofs); document.Tags = searchFields[x].Tags; documentList.Add(document); } if (FindViewById <CheckBox>(Resource.Id.truncateCheck).Checked) { truncate = true; } if (viewRadio.Checked != true && query != "" && FindViewById <RadioButton>(Resource.Id.topicRadio).Checked) { if (FindViewById <RadioButton>(Resource.Id.topicRadio).Checked) { stopwatch.Start(); FilterResults(documentList, truncate, true, proofs, searchAll, query); documentList.Reverse(); stopwatch.Stop(); } } else if (FindViewById <RadioButton>(Resource.Id.chapterRadio).Checked & query != "") { int searchInt = Int32.Parse(query); FilterResults(this.documentList, truncate, answers, proofs, searchAll, searchInt); } else if (viewDocs) { if (!FindViewById <CheckBox>(Resource.Id.searchAllCheckBox).Checked) { query = "Results for All"; } else { query = "View All"; } } if (documentList.Count > 1) { SetContentView(Resource.Layout.search_results); ViewPager viewPager = FindViewById <ViewPager>(Resource.Id.viewpager); SearchAdapter adapter = new SearchAdapter(SupportFragmentManager, documentList, query, truncate); searchFragmentActivity.DisplayResults(documentList, viewPager, adapter, query, 0, truncate); } else { stopwatch.Stop(); if (this.documentList.Count == 0) { #region Error Logging Log.Info("Search()", String.Format("No Results were found for {0}", query)); Toast.MakeText(this, String.Format("No results were found for {0}", query), ToastLength.Long).Show(); #endregion #region Variable Declaration and Assignment SetContentView(Resource.Layout.errorLayout); TextView errorMsg = FindViewById <TextView>(Resource.Id.errorTV); errorMsg.Text = String.Format("No Search Results were found for {0}\r\n\r\n" + "Go back to home page to search for another topic", query); #endregion #region Dialog Box Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle("No Results Found"); alert.SetMessage(String.Format("No Results were found for {0}.\r\n\r\n" + "Do you want to go back and search for another topic?", query)); alert.SetPositiveButton("Yes", (senderAlert, args) => { intent = new Intent(this, Class); searchFragmentActivity = null; this.OnStop(); this.Finish(); StartActivity(intent); }); alert.SetNegativeButton("No", (senderAlert, args) => { alert.Dispose(); }); Dialog dialog = alert.Create(); dialog.Show(); #endregion } else { //SetTitle(); Document document = this.documentList[this.documentList.Count - 1]; SetContentView(Resource.Layout.confession_results); TextView chapterBox = FindViewById <TextView>(Resource.Id.chapterText); TextView proofBox = FindViewById <TextView>(Resource.Id.proofText); TextView chNumbBox = FindViewById <TextView>(Resource.Id.confessionChLabel); TextView docTitleBox = FindViewById <TextView>(Resource.Id.documentTitleLabel); chapterBox.Text = document.DocumentText; chNumbBox.Text = String.Format("Chapter {0} : {1}", document.ChNumber.ToString(), document.ChName); proofBox.Text = document.ChProofs; docTitleBox.Text = document.DocumentName; TextView proofView = FindViewById <TextView>(Resource.Id.proofLabel); ChangeColor(true, Android.Graphics.Color.Black, chapterBox, proofBox, chNumbBox, docTitleBox); ChangeColor(proofView, false, Android.Graphics.Color.Black); shareList = docTitleBox.Text + newLine + chNumbBox.Text + newLine + chapterBox.Text + newLine + "Proofs" + newLine + proofBox.Text; FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.shareActionButton); ChangeColor(fab, Android.Graphics.Color.Black); fab.Click += ShareContent; } } } }