private bool ExtractLicenceObjectAndFillReportsTest(Licence.Model.SafeCentralLicenceDetail licenceObj) { Dictionary <string, int> deviceOsDictionary = new Dictionary <string, int>(); Dictionary <string, int> deviceManuFacturerDictionary = new Dictionary <string, int>(); Dictionary <string, int> deviceTypeDictionary = new Dictionary <string, int>(); DeviceOsReportDataModel deviceOsReportModel = new DeviceOsReportDataModel(); DeviceManufacturerReportDataModel deviceManufacturerReportModel = new DeviceManufacturerReportDataModel(); DeviceTypeReportDataModel deviceTypeReportModel = new DeviceTypeReportDataModel(); var userDataEnumerable = _userDataService.GetAll(); var isReportCounted = false; if (licenceObj != null) { foreach (var item in licenceObj.ComputersCurrentlyInstalled) { SeatDetailsReport seatDetailsReportLine = new SeatDetailsReport(); //gather device OS data for - DeviceOsReport if (deviceOsDictionary.ContainsKey(item.OperatingSystem)) { deviceOsDictionary[item.OperatingSystem] += 1; } else { deviceOsDictionary.Add(item.OperatingSystem, 1); } if (item.Seats.Count > 0) { UserData userDataRecord = new UserData();; LicenceProductComputerSeat activeseat = new LicenceProductComputerSeat();; var activeseats = item.Seats.Where(x => x.IsBlocked == false).OrderByDescending(x => x.ActivationDate); foreach (var licenceActiveSeat in activeseats) { var _tmp = userDataEnumerable.Where(x => x.SeatKey == licenceActiveSeat.SeatKey).OrderByDescending(x => x.CreationTime).FirstOrDefault(); if (_tmp != null) { userDataRecord = _tmp; activeseat = licenceActiveSeat; } } if (!string.IsNullOrEmpty(activeseat.SeatKey)) { // the following can be gathered from the licence details seatDetailsReportLine.ActivationDate = activeseat.ActivationDate; seatDetailsReportLine.LastUpdateDate = activeseat.LastUpdate; seatDetailsReportLine.ReportId = -1; seatDetailsReportLine.CreationTime = DateTime.UtcNow; seatDetailsReportLine.OsVersion = item.OperatingSystem; seatDetailsReportLine.DeviceName = item.Name; seatDetailsReportLine.SeatKey = activeseat.SeatKey; if (!string.IsNullOrEmpty(userDataRecord.SeatKey)) //corresponding user data found { //gather device mode data for - DevManufacturerReport if (deviceManuFacturerDictionary.ContainsKey(userDataRecord.DeviceModel)) { deviceManuFacturerDictionary[userDataRecord.DeviceModel] += 1; } else { deviceManuFacturerDictionary.Add(userDataRecord.DeviceModel, 1); } //gather device type data for - DeviceTypeReport if (deviceTypeDictionary.ContainsKey(userDataRecord.DeviceType)) { deviceTypeDictionary[userDataRecord.DeviceType] += 1; } else { deviceTypeDictionary.Add(userDataRecord.DeviceType, 1); } seatDetailsReportLine.DeviceType = userDataRecord.DeviceType; seatDetailsReportLine.FirstName = Convert.ToBase64String(userDataRecord.FirstName); seatDetailsReportLine.LastName = Convert.ToBase64String(userDataRecord.LastName); seatDetailsReportLine.DeviceModel = userDataRecord.DeviceModel; seatDetailsReportLine.OptionalData = userDataRecord.OptionalData == null ? string.Empty : Convert.ToBase64String(userDataRecord.OptionalData); } else // corresponding user data not found { seatDetailsReportLine.DeviceType = ""; seatDetailsReportLine.FirstName = ""; seatDetailsReportLine.LastName = ""; seatDetailsReportLine.DeviceModel = ""; seatDetailsReportLine.OptionalData = ""; } // insert seat details report record //_seatDetailsReportService.Add(seatDetailsReportLine); //if (!isReportCounted) { reportsGeneratedForThisSubscription++; isReportCounted = true; } } } } } //Insert Device OS Report foreach (var item in deviceOsDictionary) { deviceOsReportModel.result.Add(new ReportGroupItemModel() { name = item.Key, count = item.Value }); } var deviceosdata = JsonConvert.SerializeObject(deviceOsReportModel.result); //_deviceOSReportService.Add(new Entity.Model.Reporting.DeviceOsReport() { CreationTime = DateTime.UtcNow, ReportId = -1, Data = deviceosdata }); reportsGeneratedForThisSubscription++; //Insert Device Manufacturer Report foreach (var item in deviceManuFacturerDictionary) { deviceManufacturerReportModel.result.Add(new ReportGroupItemModel() { name = item.Key, count = item.Value }); } var devicemanufacturerdata = JsonConvert.SerializeObject(deviceManufacturerReportModel.result); //_deviceManufacturerReportService.Add(new Entity.Model.Reporting.DeviceManufacturerReport() { CreationTime = DateTime.UtcNow, ReportId = reportId, Data = devicemanufacturerdata }); reportsGeneratedForThisSubscription++; //Insert Device Type Report foreach (var item in deviceTypeDictionary) { deviceTypeReportModel.result.Add(new ReportGroupItemModel() { name = item.Key, count = item.Value }); } var devicetypedata = JsonConvert.SerializeObject(deviceTypeReportModel.result); //_deviceTypeReportService.Add(new Entity.Model.Reporting.DeviceTypeReport() { CreationTime = DateTime.UtcNow, ReportId = reportId, Data = devicetypedata }); reportsGeneratedForThisSubscription++; return(true); }
private IQueryable <SeatLine> GetSeats(Licence.Model.SafeCentralLicenceDetail licenceObj) { var userDataEnumerable = _userDataService.GetAll(); List <SeatLine> result = new List <SeatLine>(); if (licenceObj != null) { foreach (var item in licenceObj.ComputersCurrentlyInstalled) { SeatLine seatDetailsReportLine = new SeatLine(); if (item.Seats.Count > 0) { var activeseatslist = from lseat in item.Seats.Where(x => x.IsBlocked == false).OrderByDescending(x => x.ActivationDate) join udseat in userDataEnumerable.OrderByDescending(x => x.CreationTime) on lseat.SeatKey equals udseat.SeatKey select lseat; var activeseat = activeseatslist.FirstOrDefault(); if (activeseat != null) { var userDataRecord = userDataEnumerable.Where(x => x.SeatKey == activeseat.SeatKey).OrderByDescending(x => x.CreationTime).FirstOrDefault(); // the following can be gathered from the licence details seatDetailsReportLine.ActivationDate = activeseat.ActivationDate; seatDetailsReportLine.LastUpdateDate = activeseat.LastUpdate; seatDetailsReportLine.OsVersion = item.OperatingSystem; seatDetailsReportLine.DeviceName = item.Name; seatDetailsReportLine.SeatKey = activeseat.SeatKey; seatDetailsReportLine.VersionNumber = activeseat.Version; if (userDataRecord != null) //corresponding user data found { seatDetailsReportLine.DeviceType = userDataRecord.DeviceType; seatDetailsReportLine.FirstName = Convert.ToBase64String(userDataRecord.FirstName); seatDetailsReportLine.LastName = Convert.ToBase64String(userDataRecord.LastName); seatDetailsReportLine.DeviceModel = userDataRecord.DeviceModel; seatDetailsReportLine.OptionalData = userDataRecord.OptionalData == null?string.Empty : Convert.ToBase64String(userDataRecord.OptionalData); } else // corresponding user data not found { seatDetailsReportLine.DeviceType = ""; seatDetailsReportLine.FirstName = ""; seatDetailsReportLine.LastName = ""; seatDetailsReportLine.DeviceModel = ""; seatDetailsReportLine.OptionalData = ""; } result.Add(seatDetailsReportLine); } } } } return(result.ToList().AsQueryable()); }