private void btnLoginLength_Click(object sender, EventArgs e) { DateTime start = dtStart.Value; DateTime end = dtEnd.Value; BaseResultInfo res = DataHelper.GetLogins(start, end); List <LogItem> items = res.GetResult <List <LogItem> >(); BaseResultInfo resLength = DataHelper.GetLoginsLength(start, end); List <LoginLengthInfo> itemsLength = resLength.GetResult <List <LoginLengthInfo> >(); if (items != null) { var clearItems = (from a in items join b in itemsLength on a.SiteId equals b.SiteId where a.AccountId != -23 select new LoginLengthGridData() { SiteId = a.SiteId, AccountId = a.AccountId, Message = a.Message, StartDate = b.StartDate, EndDate = b.EndDate, Length = b.Length }).ToList(); double dbl = clearItems.Average(x => TimeSpan.Parse(x.Length).Ticks); lblResult.Text = "NUMBER OF ITEMS {0} AVERAGE {1}".StringFormat(clearItems.Count, new TimeSpan((long)dbl)); dgGrid.DataSource = clearItems; dgGrid.Update(); } }
private void btnSearch_Click(object sender, EventArgs e) { LogItemRequest request = new LogItemRequest(); request.StartDate = dtStart.Value; request.EndDate = dtEnd.Value; if (!string.IsNullOrEmpty(cbLogType.Text)) { request.logType = (LOGTYPE?)Enum.Parse(typeof(LOGTYPE), cbLogType.Text); } if (!string.IsNullOrEmpty(txtSiteId.Text)) { request.SiteId = txtSiteId.Text; } if (!string.IsNullOrEmpty(txtAccountId.Text)) { request.AccountId = int.Parse(txtAccountId.Text); } BaseResultInfo res = DataHelper.SearchItems(request); List <LogItem> items = res.GetResult <List <LogItem> >(); lblResult.Text = "NUMBER OF ITEMS {0}".StringFormat(items.Count); dgGrid.DataSource = items; dgGrid.Update(); }
public static BaseResultInfo FileToNewDB(string fileName, LOGTYPE logType, bool isUnified) { SiteLogger.ILogger logger = SiteLogger.LoggingFactory.GetLogger; List <string> file = LogReader.LogFileReader.ReadFile(fileName); if (isUnified) { file = LogReader.LogFileReader.UnifiedLogLines(file); } List <LogItem> items = LogReader.LogFileReader.LinesToLogs(file.ToArray(), logType); LogItemRepository repository = new LogItemRepository(); BaseResultInfo res = repository.GetLastLogItem(logType.ToString(), null); LogItem last = res.GetResult <LogItem>(); int itemsSentToDB = items.Count; LogItem lastFound = last == null? null: items.FirstOrDefault(l => l.InsertDate == last.InsertDate); if (lastFound == null) { res = repository.InsertLogItem(items); } else { List <LogItem> itemsToSend = items.FindAll(l => l.Index > lastFound.Index); itemsSentToDB = itemsToSend.Count; res = repository.InsertLogItem(itemsToSend); } logger.Debug(string.Format("FILE NAME = {0} , TOTAL ITEMS = {1} , ITEM TRY INSERT = {2}, TOTAL SUCCESS = {3}, TOTAL FAILD = {4}", fileName, items.Count, itemsSentToDB, res.ReturnValue, itemsSentToDB - res.ReturnValue)); return(res); }
public void TEST_GET_UNIQ_LOGINS() { DateTime start = DateTime.Now.AddHours(-DateTime.Now.Hour).AddMinutes(-DateTime.Now.Minute);; DateTime end = DateTime.Now; BaseResultInfo res = TestDataHelper.GetLogins(start, end); List <LogItem> items = res.GetResult <List <LogItem> >(); Assert.IsTrue(res != null); }
public void TEST_JOIN_LOGINS_WITH_LENGTH() { DateTime start = DateTime.Now.AddHours(-DateTime.Now.Hour).AddMinutes(-DateTime.Now.Minute);; DateTime end = DateTime.Now; BaseResultInfo res = TestDataHelper.GetLogins(start, end); List <LogItem> items = res.GetResult <List <LogItem> >(); BaseResultInfo resLength = TestDataHelper.GetLoginsLength(start, end); List <LoginLengthInfo> itemsLength = resLength.GetResult <List <LoginLengthInfo> >(); var list = from a in items join b in itemsLength on a.SiteId equals b.SiteId where a.AccountId != -23 select new { a.SiteId, a.AccountId, a.Message, b.StartDate, b.EndDate, b.Length }; int v = list.Count(); Assert.IsTrue(res != null); }
public static List <LoginLengthGridData> GetLoginsUsers(DateTime start, DateTime end) { BaseResultInfo res = DataHelper.GetLogins(start, end); List <LogItem> items = res.GetResult <List <LogItem> >(); BaseResultInfo resLength = DataHelper.GetLoginsLength(start, end); List <LoginLengthInfo> itemsLength = resLength.GetResult <List <LoginLengthInfo> >(); List <LoginLengthGridData> resData = new List <LoginLengthGridData>(); if (items != null) { resData = (from a in items join b in itemsLength on a.SiteId equals b.SiteId where a.AccountId != -23 select new LoginLengthGridData() { SiteId = a.SiteId, AccountId = a.AccountId, Message = a.Message, StartDate = b.StartDate, EndDate = b.EndDate, Length = b.Length }).ToList(); } return(resData); }
private void btnGetUniq_Click(object sender, EventArgs e) { DateTime start = dtStart.Value; DateTime end = dtEnd.Value; BaseResultInfo res = DataHelper.GetLogins(start, end); List <LogItem> items = res.GetResult <List <LogItem> >(); BaseResultInfo resLength = DataHelper.GetLoginsLength(start, end); List <LoginLengthInfo> itemsLength = resLength.GetResult <List <LoginLengthInfo> >(); if (items != null) { var clearItems = (from a in items where a.AccountId != -23 orderby a.AccountId select new LoginGridData { InsertDate = a.InsertDate, AccountId = a.AccountId, SiteId = a.SiteId, Message = a.Message }).ToList(); lblResult.Text = "NUMBER OF ITEMS {0}".StringFormat(clearItems.Count); dgGrid.DataSource = clearItems; dgGrid.Update(); } }