private StaffBranch GetClassAnalysis(StaffUnit Teacher, StaffUnit Subject, StaffUnit Class, bool IsVirtual) { int StanKlasy, StanKlasyWirtualnej; if (!IsVirtual) { StanKlasy = lstLiczbaUczniow.Where(x => x.ClassID == Class.ID).Select(x => x.Count).FirstOrDefault(); StanKlasyWirtualnej = lstLiczbaUczniowNI.Where(x => x.SubjectID == Subject.ID).Where(x => x.ClassID == Class.ID).Select(x => x.Count).FirstOrDefault(); StanKlasy -= StanKlasyWirtualnej; if (lstLiczbaUczniowGrupa.Where(x => x.ClassID == Class.ID).Where(x => x.SubjectID == Subject.ID).Count() > 0) { var SubtractList = lstObsada.Where(T => T.Teacher.ID == Teacher.ID).Where(S => S.Subject.ID == Subject.ID).Where(C => C.Class.ID == Class.ID).Select(x => x.Subject.IdSzkolaPrzedmiot); StanKlasy -= lstLiczbaUczniowGrupa.Where(x => x.ClassID == Class.ID).Where(x => x.SubjectID == Subject.ID).Where(x => !SubtractList.Contains(x.SubjectIdBySchool)).Sum(x => x.Count); } } else { StanKlasy = lstLiczbaUczniowNI.Where(x => x.SubjectID == Subject.ID).Where(x => x.VirtualClassID == Class.ID).Select(x => x.Count).FirstOrDefault(); } var ClassNode = new StaffBranch(); ClassNode.Label = Class.Nazwa; ClassNode.StudentCount = StanKlasy; ClassNode.ScoreCount = ComputeScore(Teacher, Subject, Class, ClassNode.ScoreCount.Count()); SetAnalysisType += ClassNode.SetOption; return(ClassNode); }
private int[] ComputeScore(StaffUnit Teacher, StaffUnit Subject, StaffUnit Class, int ScoreArraySize) { int[] ScoreCount = new int[ScoreArraySize]; List <ScoreInfo> lstScoreCount = lstLiczbaOcen.Where(SI => SI.TeacherID == Teacher.ID).Where(SI => SI.SubjectID == Subject.ID).Where(SI => SI.ClassID == Class.ID).ToList(); for (int i = 0; i < ScoreCount.Count(); i++) { ScoreCount[i] = lstScoreCount.Where(W => W.ScoreWeight == i).Sum(x => x.ScoreCount); } return(ScoreCount); }
private void CollectUnits(List <StaffUnit> staffUnits, StaffUnit currentStaffUnit) { if (currentStaffUnit.Type == StaffUnitType.Organization) { staffUnits.Add(currentStaffUnit); foreach (var unit in currentStaffUnit.Units) { CollectUnits(staffUnits, unit); } } }
private List <StaffBranch> GetAnalysisByClass(StaffUnit Teacher, StaffUnit Subject) { List <StaffBranch> ClassNode = new List <StaffBranch>(); var lstClass = lstObsada.Where(T => T.Teacher.ID == Teacher.ID).Where(S => S.Subject.ID == Subject.ID).Select(x => new { x.Class.ID, x.Class.Nazwa, x.IsVirtual }).Distinct().OrderBy(K => K.Nazwa).ToList(); foreach (var Klasa in lstClass) { ClassNode.Add(GetClassAnalysis(Teacher, Subject, new StaffUnit { ID = Klasa.ID, Nazwa = Klasa.Nazwa }, Klasa.IsVirtual)); } return(ClassNode); }
private void Автор_ControlValueChanged(System.Object sender, System.EventArgs e) { BaseCardSectionRow row = (BaseCardSectionRow)Document.GetSection(new System.Guid("30EB9B87-822B-4753-9A50-A1825DCA1B74"))[0]; if (this.Document.MainInfo.Author != null) { StaffUnit unit = getOrganisation(this.Document.MainInfo.Author.Unit); if (unit != null) { row["ResponsDepartment"] = CardControl.ObjectContext.GetObjectRef(unit).Id; } } }
/// <summary> /// Get analysis by teacher for pointed subject /// </summary> /// <param name="Subject">Subject's data consists of ID and Name</param> /// <returns>List of teacher nodes for pointed subject</returns> private List <StaffBranch> GetAnalysisByTeacher(StaffUnit Subject) { var lstTeacher = lstObsada.Where(x => x.Subject.ID == Subject.ID).Select(x => new { x.Teacher.ID, x.Teacher.Nazwa }).OrderBy(x => x.Nazwa).Distinct().ToList(); List <StaffBranch> AnalysisTree = new List <StaffBranch>(); foreach (var Belfer in lstTeacher) { StaffUnit Teacher = new StaffUnit { ID = Belfer.ID, Nazwa = Belfer.Nazwa }; var TeacherNode = new StaffBranch(); SetAnalysisType += TeacherNode.SetOption; TeacherNode.Children = GetAnalysisByClass(Teacher, Subject); ComputeScore(TeacherNode, Belfer.Nazwa); AnalysisTree.Add(TeacherNode); } return(AnalysisTree); }
/// <summary> /// Get analysis by subject for pointed teacher /// </summary> /// <param name="Teacher">Teacher's data consists of ID and Name</param> /// <returns>List of subject nodes for pointed teacher</returns> private List <StaffBranch> GetAnalysisBySubject(StaffUnit Teacher) { var lstSubject = lstObsada.Where(x => x.Teacher.ID == Teacher.ID).Select(x => new { x.Subject.ID, x.Subject.Nazwa }).Distinct().ToList(); List <StaffBranch> AnalysisTree = new List <StaffBranch>(); foreach (var Przedmiot in lstSubject) { StaffUnit Subject = new StaffUnit { ID = Przedmiot.ID, Nazwa = Przedmiot.Nazwa }; var SubjectNode = new StaffBranch(); SetAnalysisType += SubjectNode.SetOption; SubjectNode.Children = GetAnalysisByClass(Teacher, Subject); ComputeScore(SubjectNode, Przedmiot.Nazwa); AnalysisTree.Add(SubjectNode); } return(AnalysisTree); }
private void printApproval_ItemClick(System.Object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DocsVision.BackOffice.ObjectModel.Document FileCardDocument = this.Context.GetObject <DocsVision.BackOffice.ObjectModel.Document>(new System.Guid("224D391A-B7ED-E511-9414-E4115BB03AEA")); //MessageBox.Show("Документ нашли"); string oTempPath = System.IO.Path.GetTempPath(); string oFilePath = oTempPath + FileCardDocument.MainInfo.MainFileName; this.DocumentService.DownloadMainFile(FileCardDocument, oFilePath); //MessageBox.Show("Документ скачали"); //получаем объект word Microsoft.Office.Interop.Word.ApplicationClass oApplication = new Microsoft.Office.Interop.Word.ApplicationClass(); oApplication.Visible = true; object oMissing = Type.Missing; object oFileNameMain = (object)oFilePath; object oFalse = false; object oTrue = true; try{ Microsoft.Office.Interop.Word.Document oMainFileWord = oApplication.Documents.Open(ref oFileNameMain, ref oMissing, ref oFalse, ref oFalse, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oTrue, ref oMissing, ref oMissing, ref oTrue, ref oMissing); //MessageBox.Show("Открыли"); object replaceAll = Microsoft.Office.Interop.Word.WdReplace.wdReplaceAll; string temp = String.Empty; BaseCardSectionRow row = (BaseCardSectionRow)Document.GetSection(new System.Guid("30EB9B87-822B-4753-9A50-A1825DCA1B74"))[0]; Guid tempId = new System.Guid(row["ResponsDepartment"].ToString()); StaffUnit unit = Context.GetObject <StaffUnit>(tempId); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Организация."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = unit.Name; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Состояние."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = Document.SystemInfo.State.LocalizedName; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); BaseCardSectionRow docPartnerRow = (BaseCardSectionRow)Document.GetSection(new System.Guid("6E976D72-3EA7-4708-A2C2-2A1499141301"))[0]; CardData PartnerDictionary = Session.CardManager.GetCardData(new System.Guid("65FF9382-17DC-4E9F-8E93-84D6D3D8FE8C")); //Справочник контрагентов RowData PartnerRow = PartnerDictionary.Sections[new System.Guid("C78ABDED-DB1C-4217-AE0D-51A400546923")].GetRow(new System.Guid(docPartnerRow["SenderOrg"].ToString())); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Контрагент."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = PartnerRow.GetString("Name"); oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); if (row["StatusId"] != null) { CardData dictionaryCard = this.Session.CardManager.GetCardData(new System.Guid("4538149D-1FC7-4D41-A104-890342C6B4F8")); SectionData dictionarySection = dictionaryCard.Sections[new System.Guid("A1DCE6C1-DB96-4666-B418-5A075CDB02C9")]; RowData rdItemTypesNuno = dictionarySection.GetRow(new System.Guid("10630364-D63F-4249-83E8-5DE95B2CD385")); //виды бухгалтерских документов foreach (RowData rdItems in rdItemTypesNuno.ChildSections[new System.Guid("1B1A44FB-1FB1-4876-83AA-95AD38907E24")].Rows) { if (row["StatusId"].ToString().ToUpper() == "{" + rdItems.Id.ToString().ToUpper() + "}") { temp = rdItems.GetString("Name"); } } } else { temp = String.Empty; } oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Вид документа."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); BaseCardSectionRow contractRow = (BaseCardSectionRow)Document.GetSection(new System.Guid("3997861D-4FF5-496A-B8A2-D16617DE91D7"))[0]; temp = contractRow["AddAgreementNumber"] + ""; oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Номер."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Дата."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = Convert.ToDateTime(contractRow["AttachmentDate"] + "").ToShortDateString(); oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Сумма."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = contractRow["MySum"] + ""; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); string partially; if (row["WasSent"] + "" == "False") { temp = contractRow["MySum"] + ""; partially = "Нет"; } else { temp = row["Sum"] + ""; partially = "Да"; } oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&К оплате."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); if (row["SLA"] != null) { //MessageBox.Show("якобы условия оплаты заполнены"+row["SLA"]); CardData dictionaryCard = this.Session.CardManager.GetCardData(new System.Guid("4538149D-1FC7-4D41-A104-890342C6B4F8")); SectionData dictionarySection = dictionaryCard.Sections[new System.Guid("A1DCE6C1-DB96-4666-B418-5A075CDB02C9")]; RowData rdItemTypesNuno = dictionarySection.GetRow(new System.Guid("305EF160-0CBA-41B7-8187-E6383A471849")); //условия оплаты foreach (RowData rdItems in rdItemTypesNuno.ChildSections[new System.Guid("1B1A44FB-1FB1-4876-83AA-95AD38907E24")].Rows) { if (row["StatusId"].ToString().ToUpper() == "{" + rdItems.Id.ToString().ToUpper() + "}") { temp = rdItems.GetString("Name"); } } } else { //MessageBox.Show("условия оплаты не заполнены"); temp = String.Empty; } oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Условия."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = temp; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Валюта."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = contractRow["ContractCurrency"] + ""; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); oApplication.Selection.Find.ClearFormatting(); oApplication.Selection.Find.Text = "&Частично."; oApplication.Selection.Find.Replacement.ClearFormatting(); oApplication.Selection.Find.Replacement.Text = partially; oApplication.Selection.Find.Execute(ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref replaceAll, ref oMissing, ref oMissing, ref oMissing, ref oMissing); Microsoft.Office.Interop.Word.Table newTable; Microsoft.Office.Interop.Word.Range myRange = oMainFileWord.Range(); //object startOfRange = myRange.Text.IndexOf("&Таблица."); //object endOfRange = myRange.Text.IndexOf("&Таблица.") + 9; //Microsoft.Office.Interop.Word.Range wrdRng = oMainFileWord.Range(ref startOfRange, ref endOfRange); object oEndOfDoc = "\\endofdoc"; Microsoft.Office.Interop.Word.Range wrdRng = oMainFileWord.Bookmarks.get_Item(ref oEndOfDoc).Range; //MessageBox.Show("range is determined"); newTable = oMainFileWord.Tables.Add(wrdRng, 1, 4, ref oMissing, ref oMissing); //MessageBox.Show("table added"); newTable.Borders.InsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle; newTable.Borders.OutsideLineStyle = Microsoft.Office.Interop.Word.WdLineStyle.wdLineStyleSingle; newTable.AllowAutoFit = true; newTable.Cell(1, 1).Range.Text = "Сотрудник"; newTable.Cell(1, 1).Range.Font.Bold = 1; newTable.Cell(1, 2).Range.Text = "Дата согласования"; newTable.Cell(1, 2).Range.Bold = 1; newTable.Cell(1, 3).Range.Text = "Результат"; newTable.Cell(1, 3).Range.Bold = 1; newTable.Cell(1, 4).Range.Text = "Комментарий"; newTable.Cell(1, 4).Range.Bold = 1; int i = 1; while (i <= Document.GetSection(new System.Guid("AACEF937-EAD2-4AFD-A64C-DC42D7846B80")).Count) { newTable.Rows.Add(); BaseCardSectionRow commentTable = (BaseCardSectionRow)Document.GetSection(new System.Guid("AACEF937-EAD2-4AFD-A64C-DC42D7846B80"))[i - 1]; string employeeId = commentTable["Employee"].ToString(); StaffEmployee employee = Context.GetObject <StaffEmployee>(new System.Guid(employeeId)); newTable.Cell(i + 1, 1).Range.Text = employee.DisplayString; newTable.Cell(i + 1, 1).Range.Bold = 0; newTable.Cell(i + 1, 2).Range.Text = Convert.ToDateTime(commentTable["Date"] + "").ToShortDateString(); if (commentTable["Result"] + "" == "0") { temp = "Согласовано"; } else { temp = "Не согласовано"; } newTable.Cell(i + 1, 2).Range.Bold = 0; newTable.Cell(i + 1, 3).Range.Text = temp; newTable.Cell(i + 1, 3).Range.Bold = 0; newTable.Cell(i + 1, 4).Range.Text = commentTable["Comment"] + ""; newTable.Cell(i + 1, 4).Range.Bold = 0; i++; } } catch (Exception ex) { UIService.ShowError(ex, "Во время создания файла произошла ошибка"); } /*удал¤ем временный файл * if (System.IO.File.Exists(oFilePath)) * System.IO.File.Delete(oFilePath);*/ //закрываем ворд //oApplication.Quit(ref oMissing, ref oMissing, ref oMissing); }