public CExportToExcelWnd(long CompId, ObservableDictionary <long, CKeyValuePairEx <long, CCompSettings> > CompGroups) { InitializeComponent(); OnPropertyChanged(MaxSheetNameLenPropertyName); m_CompDesc = DBManagerApp.m_Entities.descriptions.Where(arg => arg.id_desc == CompId).FirstOrDefault(); tbctrlTabs.Items.Add(new TabItem() { Header = Properties.Resources.resMainExportTab, Content = new CMainExportTab(this, CompGroups) }); tbctrlTabs.Items.Add(new TabItem() { Header = Properties.Resources.resTeamExportTab, Content = new CTeamExportTab(this, CompGroups) }); tbctrlTabs.Items.Add(new TabItem() { Header = Properties.Resources.resPersonalExportTab, Content = new CPersonalExportTab(this, CompGroups) }); tbctrlTabs.Items.Add(new TabItem() { Header = Properties.Resources.resLeadReportInfoTab, Content = new CLeadReportInfoTab(this, CompGroups) }); }
public bool DescriptionPropsEquals(descriptions rhs) { return(CompName == rhs.name); }
private bool HandleFile(string FullFilePath) { CGroupItem GroupChanged = null; CCompItem Comp = null; long id = -1; string FileDir = System.IO.Path.GetDirectoryName(FullFilePath); int LastSlash = FileDir.LastIndexOf('\\'); if (long.TryParse(FileDir.Right(FileDir.Length - LastSlash - 1), out id)) { Comp = Comps.FirstOrDefault(arg => arg.id == id); if (Comp == null) { // Такого соревнования нет => его нужно добавить Comp = new CCompItem(id) { FolderName = id.ToString() + "\\" }; descriptions desc = DBManagerApp.m_Entities.descriptions.FirstOrDefault(arg => arg.id_desc == id); if (desc == null) { return(false); } else { Comp.CompName = desc.name; } if (long.TryParse(System.IO.Path.GetFileNameWithoutExtension(FullFilePath), out id)) { GroupChanged = AddNewGroup(Comp, id); if (GroupChanged == null) { return(false); } } else { // неверное название файла return(false); } Comps.Add(Comp); } else { if (long.TryParse(System.IO.Path.GetFileNameWithoutExtension(FullFilePath), out id)) { GroupChanged = Comp.Groups.FirstOrDefault(arg => arg.id == id); if (GroupChanged == null) { // Группы нет => добавляем GroupChanged = AddNewGroup(Comp, id); if (GroupChanged == null) { return(false); } } } } } else { // неверное название файла return(false); } GroupChanged.Items.Clear(); GlobalDefines.CheckPublishingDirExists(); List <CLogItem> lstItems = new List <CLogItem>(); try { using (TextReader tr = new StreamReader(string.Format("{0}{1}\\{2}{3}", GlobalDefines.STD_PUBLISHING_LOG_DIR, Comp.id, GroupChanged.id, GlobalDefines.PUBLISHING_LOG_FILE_EXTENSION))) { string line = null; CLogItem CurLogItem = null; DateTime ItemDateTime = DateTime.Now; enOnlineResultsLogItemType ItemType = enOnlineResultsLogItemType.None; do { line = tr.ReadLine(); if (line == null) { // Файл закончился break; } else { string[] Fields = line.Split(GlobalDefines.PUBLISHING_LOG_FIELDS_SEPARATOR); // Переносы строк не используем в логе для удобства, поэтому добавляем их там, где они нужны for (int i = 0; i < Fields.Length; i++) { Fields[i] = Fields[i].Replace(GlobalDefines.PUBLISHING_LOG_LFCR_SYMBOL, '\n'); } int Index = 0; if (Enum.TryParse <enOnlineResultsLogItemType>(Fields[Index++], out ItemType) && DateTime.TryParse(Fields[Index++], out ItemDateTime)) { CurLogItem = new CLogItem() { Type = ItemType, CreationDate = ItemDateTime, }; if (Fields.Length > Index) { CurLogItem.PCWbkName = Fields[Index].Trim(); } Index++; if (Fields.Length > Index) { CurLogItem.Text = Fields[Index].Trim(); } Index++; lstItems.Add(CurLogItem); } } }while (line != null); } } catch { } lstItems.Sort((lhs, rhs) => - lhs.CreationDate.CompareTo(rhs.CreationDate)); GroupChanged.Items.AddRange(lstItems); return(true); }