private static void CreateOblicForOneSubject(Workbook book, Group group, string subjectName, int pivricha) { Log.Info(LoggerConstants.ENTER); Workbook bookOfOblic = null; try { var subjectFind = group.Subjects.Find(subject => subject.Name.Equals(subjectName)); var nameOfOblic = ""; if (subjectFind != null) { var semestrFindSemestr = pivricha == 1 ? subjectFind.FirstSemestr : subjectFind.SecondSemestr; if (semestrFindSemestr != null) { nameOfOblic = semestrFindSemestr.CursovaRobota > 0 ? CreateSheetName("КП" + subjectName) : CreateSheetName(subjectName); } else { Log.Info(LoggerConstants.EXIT); return; } } else { Log.Warn("For group `" + group.Name + "` don`t find any subjects"); Log.Info(LoggerConstants.EXIT); return; } bookOfOblic = App.OpenBook(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name + PathsFile.PathsDto.ExcelExtensial); Worksheet sheetOfOblic; if (bookOfOblic == null) { if (!File.Exists(PathsFile.PathsDto.PathToFileWithMacros)) { Log.Error(LoggerConstants.FILE_NOT_EXIST + ": " + PathsFile.PathsDto.PathToFileWithMacros); Log.Info(LoggerConstants.EXIT); return; } File.Copy(PathsFile.PathsDto.PathToFileWithMacros, PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name + PathsFile.PathsDto.ExcelExtensial); bookOfOblic = App.OpenBook(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name + PathsFile.PathsDto.ExcelExtensial); sheetOfOblic = App.OpenWorksheet(bookOfOblic, 1); sheetOfOblic.Name = nameOfOblic; } else { var exist = bookOfOblic.Worksheets.Cast<object>() .Any(sheet => ((Worksheet) sheet).Name.Equals(nameOfOblic)); if (exist) { if (!Control.IfShow) { var control = new Control("Група [" + group.Name + "]. Уже існує облік успішності для предмету:\n" + subjectName); control.ShowDialog(); if (Control.ButtonClick == 1) { var newApp = new Application { Visible = true }; ((Worksheet) newApp.Workbooks.Open(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name + PathsFile.PathsDto.ExcelExtensial).Worksheets[nameOfOblic]) .Select(); Control.ButtonClick = 0; control.SetButtonReseachEnabled(false); control.ShowDialog(); newApp.Quit(); ExcelApplication.ExcelApplication.Kill(newApp); } if (Control.ButtonClick == 2) return; sheetOfOblic = bookOfOblic.Worksheets[nameOfOblic]; sheetOfOblic.Cells.Delete(); Control.ButtonClick = 0; } else { if (Control.ButtonClick == 2) { Log.Info(LoggerConstants.EXIT); return; } sheetOfOblic = bookOfOblic.Worksheets[nameOfOblic]; sheetOfOblic.Cells.Delete(); } } else { sheetOfOblic = App.CreateNewSheet(bookOfOblic, nameOfOblic); } } foreach (var subject in @group.Subjects) { var semestr = pivricha == 1 ? subject.FirstSemestr : subject.SecondSemestr; if (semestr != null && subject.Name.Equals(subjectName)) { if (semestr.DyfZalik > 0 || semestr.Zalic > 0 || semestr.Isput > 0) { CreateZalicExamenAndDufZalic(book.Worksheets["Залік - ДифЗалік - Екзамен"], sheetOfOblic, group, subject, semestr, pivricha); } else if (semestr.StateExamination > 0) { CreateStateExamen(book.Worksheets["Державний екзамен"], sheetOfOblic, group, subject, semestr, pivricha); } else if (semestr.CursovaRobota > 0 || !string.IsNullOrWhiteSpace(semestr.PracticeFormOfControl)) { CreateKpOrPractice(book.Worksheets["КП - Технологічна практика"], sheetOfOblic, group, subject, semestr, pivricha); } break; } } } catch (Exception e) { Log.Warn("Something wrong while reading obliks uspishnosti", e); } finally { App.CloseBook(bookOfOblic, true); Log.Info(LoggerConstants.EXIT); } }
private static void CreateKpOrPractice(Worksheet sheetTamplate, Worksheet sheet, Group group, Subject subject, Semestr semestr, int pivricha) { Log.Info(LoggerConstants.ENTER); sheet.Cells.PasteSpecial(sheetTamplate.Cells.Copy()); sheet.Cells[13, "E"].Value = group.TrainingDirection.Equals("Програмна інженерія") ? "Програмної інженерії" : "Метрології та інформаційно-вимірювальної технології"; sheet.Cells[15, "F"].Value = group.Speciality; sheet.Cells[17, "D"].Value = group.Course; sheet.Cells[17, "G"].Value = group.Name; sheet.Cells[19, "I"].Value = group.Year + "-" + (int.Parse(group.Year.Trim()) + 1); sheet.Cells[26, "F"].Value = subject.Name; sheet.Cells[28, "D"].Value = pivricha == 1 ? group.FirstRomeSemestr : ArabToRome(FromRomeToArab(group.FirstRomeSemestr) + 1); sheet.Cells[22, "M"].Value = CreateNumberOfOblic(subject.NumberOfOlic, pivricha == 1 ? group.Year : int.Parse(@group.Year.Trim()) + 1 + ""); sheet.Cells[30, "Q"].Value = semestr.CountOfHours; sheet.Cells[30, "F"].Value = FormaZdachi(semestr); // sheet.Cells[32, "K"].Value = subject.Teacher + "_____"; // sheet.Cells[100, "N"].Value = subject.Teacher; var n = 45; foreach (var student in @group.Students) { sheet.Cells[n, "C"].Value = string.IsNullOrWhiteSpace(student.PibChanged) ? student.Pib : student.PibChanged; sheet.Cells[n, "H"].Value = student.NumberOfBook; n++; } if (n != 75) sheet.Range["B" + n, "Q" + 74].Delete(); Log.Info(LoggerConstants.EXIT); }
public static List<Record> GetPidsumkovaOcinka(List<SemestrForAtestat> semestrs, Group group) { CalculationsDto sum = new CalculationsDto(); List<SemestrForAtestat> list = semestrs.Where(newSemestr => newSemestr.Marks.Count > 0 && !newSemestr.StateExamenExist).ToList(); foreach (SemestrForAtestat atestat in list) sum.CountOfHour += atestat.CountOfHours; if (sum.CountOfHour <= 0) return new List<Record>(); foreach (Student student in @group.Students) { sum.Studmarks.Add(new Record { StudentName = student.Pib, StudentNameChanged = student.PibChanged }); } foreach (SemestrForAtestat semestr in list) { foreach (RecordStudmark studMark in semestr.Marks) { Record studentExist = sum.Studmarks.Find(record => ComparePibs(record.StudentName, studMark.StudentName)) ?? sum.Studmarks.Find(record => ComparePibs(record.StudentNameChanged, studMark.StudentName)); if (studentExist == null) continue; double mark; mark = double.TryParse(studMark.Mark.Trim(), out mark) ? mark : 0; if (mark <= 0) { studentExist.IfMarkCanParse = false; studentExist.Mark = studMark.Mark; continue; } if (studentExist.IfMarkCanParse) continue; studentExist.IfMarkCanParse = true; if (string.IsNullOrWhiteSpace(studentExist.Mark)) studentExist.Mark = semestr.CountOfHours*mark + ""; else { double mark2; mark2 = double.TryParse(studMark.Mark.Trim(), out mark2) ? mark2 : 0; studentExist.Mark = mark2 <= 0 ? mark2 + "" : mark2 + semestr.CountOfHours*mark + ""; } } } foreach (Record studmark in sum.Studmarks) { if (studmark.IfMarkCanParse) { studmark.Mark = Math.Round(double.Parse(studmark.Mark) / sum.CountOfHour, 0) + ""; } } return sum.Studmarks; }
private static Group ReadSheetFromRobPlan(Worksheet sheet) { Log.Info(LoggerConstants.ENTER); var group = new Group(); group.Name = sheet.Name; //Read "Напряму підготовки" string s = sheet.Cells[6, "R"].Value; var exist = true; if (string.IsNullOrWhiteSpace(s) || s.Count(c => c.Equals('"')) < 2) exist = false; else { var beginSlash = s.IndexOf("\"", StringComparison.Ordinal); var lastSlash = s.LastIndexOf("\"", StringComparison.Ordinal); s = s.Substring(beginSlash + 1, lastSlash - beginSlash - 1); if (string.IsNullOrWhiteSpace(s)) exist = false; } if (!exist) { sheet.Cells[6, "R"].Interior.Color = ColorTranslator.ToOle(Color.Red); s = "ВВЕДІТЬ НАПРЯМ ПІДГОТОВКИ"; Log.Error("Expected direction of training in sheet '" + sheet.Name + "'"); } exist = true; group.TrainingDirection = s; //Read "Спеціальність" s = sheet.Cells[7, "R"].Value; if (string.IsNullOrWhiteSpace(s) || s.Count(c => c.Equals('"')) != 2) exist = false; else { var beginSlash = s.IndexOf("\"", StringComparison.Ordinal); var lastSlash = s.LastIndexOf("\"", StringComparison.Ordinal); s = s.Substring(beginSlash + 1, lastSlash - beginSlash - 1); if (string.IsNullOrWhiteSpace(s)) exist = false; } if (!exist) { sheet.Cells[7, "R"].Interior.Color = ColorTranslator.ToOle(Color.Red); s = "ВВЕДІТЬ НАЗВУ СПЕЦІАЛЬНОСТІ"; Log.Error("Expected spesiality in sheet '" + sheet.Name + "'"); } group.Speciality = s; s = sheet.Cells[7, "R"].Value; //Код спеціальності if (exist) { s = s.Trim().Substring(0, s.Trim().IndexOf(" \"", StringComparison.Ordinal)); if (!s.Contains(" ")) { sheet.Cells[7, "R"].Interior.Color = ColorTranslator.ToOle(Color.Red); s = "КОД"; Log.Error("Code of spesiality is incorrect in sheet '" + sheet.Name + "'"); } else s = s.Substring(s.IndexOf(" ", StringComparison.Ordinal)).Trim(); } exist = true; group.CodeOfSpeciality = s; //read "Курс" s = sheet.Cells[9, "R"].Value; if (string.IsNullOrWhiteSpace(s) || !s.Trim().StartsWith("Курс")) exist = false; else { var coursePosition = GetPositionForCellCource(s.Trim()); if (coursePosition == -1) exist = false; else { s = s.Trim().Substring(coursePosition); if (!s.Contains("_")) exist = false; else { s = s.Remove(s.IndexOf("_", StringComparison.Ordinal)); } } } if (!exist) { s = "ВВЕДІТЬ КУРС"; sheet.Cells[9, "R"].Interior.Color = ColorTranslator.ToOle(Color.Red); Log.Error("Course is incorrect in sheet '" + sheet.Name + "'"); } exist = true; group.Course = s; //Read "Рік" s = sheet.Cells[6, "B"].Value; if (string.IsNullOrWhiteSpace(s)) exist = false; else { try { s = s.Substring(s.Length - 9, 4); } catch (IndexOutOfRangeException e) { exist = false; Log.Warn("IndexOutOfRangeException when try to find year", e); } } if (!exist) { s = "ВВЕДІТЬ РІК"; sheet.Cells[6, "B"].Interior.Color = ColorTranslator.ToOle(Color.Red); Log.Error("Year is incorrect in sheet '" + sheet.Name + "'"); } exist = true; group.Year = s; //Read "Семестр для першого півріччя" s = sheet.Cells[15, "Y"].Value; if (string.IsNullOrWhiteSpace(s)) exist = false; else { try { if (!s.Contains(' ')) exist = false; else s = s.Trim().Substring(0, s.Trim().IndexOf(' ')); } catch (IndexOutOfRangeException e) { exist = false; Log.Warn("IndexOutOfRangeException when try to get semestr", e); } } if (!exist) { s = "ВВЕДІТЬ СЕМЕСТР"; sheet.Cells[15, "Y"].Interior.Color = ColorTranslator.ToOle(Color.Red); Log.Error("Semestr is incorrect in sheet '" + sheet.Name + "'"); } group.FirstRomeSemestr = s; group.Subjects = ReadSubject(sheet); group.Practice = ReadPractice(sheet); group.StateExamination = ReadStateExamination(sheet); Log.Info(LoggerConstants.EXIT); return group; }
private static bool GetMarkByStudentName(SubjectForAtestat subjectForAtestat, int semestr, string studentName, Group @group, out RecordStudmark markWithStudName) { markWithStudName = subjectForAtestat.Semestrs[semestr].Marks.Find(studmark => ComparePibs(studentName, studmark.StudentName)); if (markWithStudName != null) return false; Student student = @group.Students.Find(student1 => ComparePibs(student1.Pib, studentName) || ComparePibs(student1.PibChanged, studentName)); if (student == null) return true; markWithStudName = subjectForAtestat.Semestrs[semestr].Marks.Find(studmark => ComparePibs(studmark.StudentName, student.Pib) || ComparePibs(studmark.StudentName, student.PibChanged)); return markWithStudName == null; }
private static void CreateZvedeniaVidomist(Group @group, int pivricha, string mount) { Log.Info(LoggerConstants.ENTER); Workbook bookTamplate = null; Workbook book = null; try { var stringPivricha = pivricha == 1 ? "1-ше півріччя.xls" : "2-ге півріччя.xls"; var pathToVidomist = PathsFile.PathsDto.PathToFolderWithZvedeniaVidomistUspishnosti + "Зведена відомість успішності за " + (string.IsNullOrWhiteSpace(mount) ? stringPivricha : mount + PathsFile.PathsDto.ExcelExtensial); if (!File.Exists(PathsFile.PathsDto.PathToExcelDataForProgram)) { Log.Error(LoggerConstants.FILE_NOT_EXIST + ": DataToProgram"); Log.Info(LoggerConstants.EXIT); return; } bookTamplate = App.OpenBook(PathsFile.PathsDto.PathToExcelDataForProgram); var sheetTamplate = App.OpenWorksheet(bookTamplate, "Зведена відомість"); if (sheetTamplate == null) { Log.Error("DataToProgram must contains sheet with name `Зведена відомість`"); Log.Info(LoggerConstants.EXIT); return; } Worksheet sheet; if (!File.Exists(pathToVidomist)) { if (!File.Exists(PathsFile.PathsDto.PathToFileWithMacros)) { Log.Warn("Empty Excel file with macros not find"); Log.Info(LoggerConstants.EXIT); return; } File.Copy(PathsFile.PathsDto.PathToFileWithMacros, pathToVidomist); book = App.OpenBook(pathToVidomist); sheet = App.OpenWorksheet(book, 1); sheet.Cells.Delete(); sheet.Name = group.Name; } else { book = App.OpenBook(pathToVidomist); var exist = book.Worksheets.Cast<object>() .Any(sheet2 => ((Worksheet) sheet2).Name.Equals(group.Name)); if (exist) { if (!Control.IfShow) { var control = new Control("Уже існує зведена відомість для групи:\n" + group.Name); control.ShowDialog(); if (Control.ButtonClick == 1) { var newApp = new Application {Visible = true}; ((Worksheet) newApp.Workbooks.Open(pathToVidomist).Worksheets[group.Name]).Select(); Control.ButtonClick = 0; control.SetButtonReseachEnabled(false); control.ShowDialog(); newApp.Quit(); ExcelApplication.ExcelApplication.Kill(newApp); } if (Control.ButtonClick == 2) { Log.Info(LoggerConstants.EXIT); return; } sheet = App.OpenWorksheet(book, group.Name); if (sheet != null) sheet.Cells.Delete(); else { Log.Warn("Some sheet == null"); } } else { if (Control.ButtonClick == 2) { Log.Info(LoggerConstants.EXIT); return; } sheet = App.OpenWorksheet(book, group.Name); if (sheet != null) sheet.Cells.Delete(); else { Log.Warn("Some sheet == null"); } } } else { sheet = App.CreateNewSheet(book, group.Name); } } var semestrCurrent = pivricha == 1 ? group.FirstRomeSemestr : ArabToRome(FromRomeToArab(group.FirstRomeSemestr) + 1); var yearCurrent = string.IsNullOrWhiteSpace(group.Year) ? 0 : int.Parse(group.Year.Trim()) + 1; sheet.Cells.PasteSpecial(sheetTamplate.Cells.Copy()); sheet.Cells[4, "C"].Value = "спеціальності \"" + group.Speciality + "\""; sheet.Cells[5, "D"].Value = "групи " + group.Name + " за " + semestrCurrent + " семестр " + group.Year + "-" + yearCurrent + " навчального року"; sheet.Cells[46, "K"].Value = "/ " + group.Curator + " /"; var subjects = pivricha == 1 ? @group.Subjects.FindAll(subject => subject.FirstSemestr != null) : @group.Subjects.FindAll(subject => subject.SecondSemestr != null); if (subjects.Count == 0) { Log.Info(LoggerConstants.EXIT); return; } var subjectList = new Dictionary<string, List<Subject>>(); foreach (Subject subject in @group.Subjects) { subject.Ocinka.Clear(); } List<Ocinka> ocinkas = new List<Ocinka>(); foreach (Student student in @group.Students) { ocinkas.AddRange(student.Ocinkas); } SortSubject(pivricha, mount, subjects, subjectList, ocinkas, group.Students); var count = -1; char[] c = { 'F', 'F' }; if (subjectList.Count(pair => pair.Value.Count > 0) > 0) { foreach (var keyValuePair in subjectList.Where(pair => pair.Value.Count != 0)) { foreach (var subject in keyValuePair.Value) { count++; sheet.Cells[9, c[1].ToString()] = subject.Name; sheet.Cells[9, c[1].ToString()].ColumnWidth = ColumnWidth(subject.Name); sheet.Cells[43, c[1].ToString()] = subject.Teacher; sheet.Cells[44, c[1].ToString()] = pivricha == 1 ? subject.FirstSemestr.CountOfHours : subject.SecondSemestr.CountOfHours; var n = 10; if (subject.Ocinka != null) { foreach (var ocinka in subject.Ocinka) { n++; sheet.Cells[n, c[1].ToString()].Value = ocinka.Mark; } } if (group.Students != null && group.Students.Count != 0) { sheet.Cells[41, c[1].ToString()].Value = "=Uspishnist(" + count + "," + group.Students.Count + ")"; sheet.Cells[42, c[1].ToString()].Value = "=Quality(" + count + "," + group.Students.Count + ")"; } c[1]++; } CaseForMergingSubject(keyValuePair, sheet, c); if (!keyValuePair.Key.Equals(ConstantExcel.Practice)) { sheet.Cells[7, "F"].Value = "Предмети"; sheet.Range["F" + 7, ((char)(c[1] - (char)1)).ToString() + 7].Merge(); sheet.Range["F" + 7, ((char)(c[1] - (char)1)).ToString() + 7].HorizontalAlignment = XlHAlign.xlHAlignCenter; } c[0] = c[1]; } } var row = 10; sheet.Cells[9, c[1].ToString()].Value = "Середній бал"; var cBenefics = c[1]; c[0] = c[1]; c[0]--; cBenefics++; cBenefics++; foreach (var student in @group.Students) { row++; sheet.Cells[row, "D"].Value = string.IsNullOrWhiteSpace(student.PibChanged) ? student.Pib : student.PibChanged; sheet.Cells[row, "E"].Value = student.FormaTeaching; sheet.Cells[row, cBenefics.ToString()].Value = student.Benefits; sheet.Cells[row, c[1].ToString()].Formula = "=AVERAGE(" + "F" + row + ":" + c[0] + row + ") - 0.5"; sheet.Cells[row, c[1].ToString()].NumberFormatLocal = "##"; var hight = true; var sum = 0; var countOf = 0; if (student.Ocinkas.Count >= 1 && string.IsNullOrWhiteSpace(mount)) { foreach (var ocinka in student.Ocinkas) { if (string.IsNullOrWhiteSpace(ocinka.Mark)) { countOf++; } int number; if (!int.TryParse(ocinka.Mark, out number)) { continue; } if (number < 10) { hight = false; } sum += number; } if (student.FormaTeaching.Equals("п")) { hight = false; } var stupendiaColumnPosution = c[1]; stupendiaColumnPosution++; if (group.Students[0].Ocinkas.Count - countOf == 0) { hight = false; } else if (sum/(group.Students[0].Ocinkas.Count - countOf) >= 7 && !student.FormaTeaching.Equals("п")) { sheet.Cells[row, stupendiaColumnPosution.ToString()].Value = 1; } if (hight) { sheet.Cells[row, stupendiaColumnPosution.ToString()].Interior.Color = ColorTranslator.ToOle(Color.Yellow); } } if (string.IsNullOrWhiteSpace(mount)) { sheet.Cells[row, cBenefics].Value = student.Benefits; } } sheet.Range["C7", c[1].ToString() + 45].Borders.LineStyle = XlLineStyle.xlContinuous; if (group.Students.Count < 30) sheet.Range["A" + (group.Students.Count + 11), "IV" + 40].Delete( XlDeleteShiftDirection.xlShiftUp); // Add vidomist to arhive if (string.IsNullOrWhiteSpace(mount)) ArhiveZvedVidomist(sheet, semestrCurrent); else sheet.Cells[6, "D"].Value = "Зведена відомість успішності за " + mount; } catch (Exception e) { Log.Warn(LoggerConstants.SOMETHING_WRONG, e); } finally { App.CloseBook(book, true); App.CloseBook(bookTamplate, true); } }
// if type == 1 than DufZalicZalic else if == 2 than PracticeOrKP else StateExamen private static void ReadOcinkaFromOblics(Group @group, Worksheet sheet, int pivricha, int type) { Log.Info(LoggerConstants.ENTER); try { string subjectName; var currentSemestr = pivricha == 1 ? group.FirstRomeSemestr : ArabToRome(FromRomeToArab(ArabNormalize(group.FirstRomeSemestr.Trim())) + 1); if (type <= 2) { var subjectNameV = sheet.Cells[26, "F"].Value; if (subjectNameV == null || string.IsNullOrWhiteSpace(subjectNameV.ToString())) { Log.Info(LoggerConstants.EXIT); return; } subjectName = subjectNameV.ToString(); var semestr = sheet.Cells[28, "D"].Value; if (semestr == null || string.IsNullOrWhiteSpace(semestr.ToString())) { Log.Info(LoggerConstants.EXIT); return; } if (!currentSemestr.Equals(semestr.ToString())) { Log.Info(LoggerConstants.EXIT); return; } } else { var protocol = sheet.Cells[3, "H"].Value; if (protocol == null || string.IsNullOrWhiteSpace(protocol.ToString())) { Log.Info(LoggerConstants.EXIT); return; } var subjectNameV = sheet.Cells[4, "H"].Value; if (subjectNameV == null || string.IsNullOrWhiteSpace(subjectNameV.ToString())) { Log.Info(LoggerConstants.EXIT); return; } subjectName = subjectNameV.ToString(); var subjectT = group.Subjects.Find(subject1 => subject1.Name.Equals(subjectName)); if (subjectT == null) { Log.Info(LoggerConstants.EXIT); return; } var semestr = pivricha == 1 ? subjectT.FirstSemestr : subjectT.SecondSemestr; if (semestr == null) { Log.Info(LoggerConstants.EXIT); return; } if (semestr.StateExamination <= 0) { Log.Info(LoggerConstants.EXIT); return; } } int n; switch (type) { case 1: n = 38; break; case 2: n = 44; break; default: n = 45; break; } var ocinkaPositio = type <= 2 ? "L" : "J"; byte counter = 0; while (true) { n++; var studentName = sheet.Cells[n, "C"].Value; if (studentName == null || string.IsNullOrWhiteSpace(studentName.ToString())) { break; } var pas = sheet.Cells[n, ocinkaPositio].Value ?? ""; Student student = group.Students.Find(student1 => student1.Pib.Equals(studentName.ToString().Trim())); if (student == null) { foreach (Student student1 in @group.Students.Where(student1 => !string.IsNullOrWhiteSpace(student1.PibChanged) && student1.PibChanged.Equals(studentName.ToString().Trim()))) { student = student1; break; } if (counter >= 10) { break; } if (student == null) { counter++; continue; } } counter = 0; student.Ocinkas.Add(new Ocinka { SubjectName = subjectName, StudentName = student.Pib, Mark = pas + "" }); } } catch (Exception e) { Log.Warn(LoggerConstants.SOMETHING_WRONG, e); } Log.Info(LoggerConstants.EXIT); }
// Creating ZvedVidomist // Read Oblics Uspisnosti public static void CreateVidomist(Group group, int pivricha, string month) { Log.Info(LoggerConstants.ENTER); if ( !File.Exists(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name + PathsFile.PathsDto.ExcelExtensial)) { Log.Warn("Don`t find any obliks uspishnosti"); //TODOO enter path to folder with ObLisk Uspishnosti } else { foreach (Student student in @group.Students) { student.Ocinkas.Clear(); } try { var book = App.OpenBook(PathsFile.PathsDto.PathToFolderWithOblicUspishnosti + group.Name + PathsFile.PathsDto.ExcelExtensial); foreach (var sheetO in book.Worksheets) { var sheet = (Worksheet) sheetO; var protocol = sheet.Cells[3, "H"].Value; if (protocol == null || string.IsNullOrWhiteSpace(protocol)) { var formaZdachi = sheet.Cells[30, "F"].Value; if (formaZdachi == null || string.IsNullOrWhiteSpace(formaZdachi.ToString())) continue; if (formaZdachi.ToString().Equals(ConstantExcel.DyfZalik) || formaZdachi.ToString().Equals(ConstantExcel.Examen) || formaZdachi.ToString().Equals(ConstantExcel.Zalik)) ReadOcinkaFromOblics(group, sheet, pivricha, 1); else if (string.IsNullOrWhiteSpace(month)) { ReadOcinkaFromOblics(group, sheet, pivricha, 2); } } else { ReadOcinkaFromOblics(group, sheet, pivricha, 3); } } App.CloseBook(book, false); } catch (Exception e) { Log.Warn(LoggerConstants.SOMETHING_WRONG, e); } } CreateZvedeniaVidomist(group, pivricha, month); Control.IfShow = false; Log.Info(LoggerConstants.EXIT); }
private static void CreateStateExamen(Worksheet sheetTamplate, Worksheet sheet, Group group, Subject subject, Semestr semestr, int pivricha) { Log.Info(LoggerConstants.ENTER); sheet.Cells.PasteSpecial(sheetTamplate.Cells.Copy()); sheet.Cells[4, "H"].Value = subject.Name; sheet.Cells[9, "C"].Value = group.Name; sheet.Cells[20, "G"].Value = subject.Teacher + "_________________________________"; sheet.Cells[84, "H"].Value = subject.Teacher + "__"; var n = 46; foreach (var student in @group.Students) { sheet.Cells[n, "C"].Value = string.IsNullOrWhiteSpace(student.PibChanged) ? student.Pib : student.PibChanged; n++; } if (n != 76) sheet.Range["B" + n, "Q" + 75].Delete(); // Count of students in group sheet.Cells[12, "G"] = "__" + (n - 46) + "__"; Log.Info(LoggerConstants.EXIT); }