public Form1() { InitializeComponent(); journalPath = setl.set.JournalFolder; namemapPath = setl.set.NamemapPath; namemap = new Journal.namemap(namemapPath); pcmap = new Journal.pcmap(pcmapPath); pcmapPath = setl.set.PCPath; reinit(); }
public static List <JournalItem_View> ItemToView(List <JournalItem> jis, namemap namemap, pcmap pcmap) { var tmp = new Dictionary <string, JournalItem>(); jis.Sort(); var res = new List <JournalItem_View>(); //var tmp = new List<JournalItem_View>(); foreach (var item in jis) { try { var key = item.machineName; if (item.eventType == JournalItem.EventType.ВХОД) { tmp.Add(key, item); } else if (item.eventType == JournalItem.EventType.ВЫХОД) { if (tmp.ContainsKey(key)) { res.Add(ItemsToView(tmp[key], item, namemap, pcmap)); tmp.Remove(key); } else { //res.Add(ItemToToView(item)); } } } catch (Exception e) { var key = item.machineName; if (item.eventType == JournalItem.EventType.ВХОД) { tmp.Add(key, item); } else if (item.eventType == JournalItem.EventType.ВЫХОД) { if (tmp.ContainsKey(key)) { res.Add(ItemsToView(tmp[key], item)); tmp.Remove(key); } else { //res.Add(ItemToToView(item)); } } } } return(res); }
private void reinitMapAndItems() { namemap = new Journal.namemap(namemapPath); pcmap = new Journal.pcmap(pcmapPath); var viewer = new Journal.JournalViewer(journalPath); items = viewer.GetAllJournals(); try { viewItems = Journal.JournalViewer.ItemToView(items, namemap, pcmap); } catch (Exception e) { viewItems = Journal.JournalViewer.ItemToView(items); } }
public static JournalItem_View ItemsToView(JournalItem from, JournalItem to, namemap namemap, pcmap pcmap) { var ret = new JournalItem_View(); try { ret = new JournalItem_View() { from = from.date, to = to.date, duration = to.date - from.date, machineName = pcmap.GetViewName(from.machineName), username = namemap.GetName(from.username), RealName = "", purpose = from.purpose, isValid = from.isValid && to.isValid }; } catch (Exception e) { } return(ret); }