public cNetworkManager(string address, int port, enRole role) { Adress = address; Port = port; Role = role; Initilaize(); }
public List <PlantModel> FilterPlantsByRole(enRole userRole, List <PlantModel> plants) { List <string> userCustomers = _context.Set <Roles_Customer>() .Include("Roles").Include("Users") .Where(w => (int)w.Roles.IdRole == (int)userRole).Select(c => c.Users.Username).ToList(); return(plants.Where(u => userCustomers.Contains(u.CustomerName)).ToList()); }
public List <UserModel> FilterRoleUsers(enRole userRole, List <UserModel> users) { List <string> userCustomers = _fomMonitoringEntities.Set <Roles_Customer>() .Include("Roles").Include("Users") .Where(w => (int)w.Roles.IdRole == (int)userRole).Select(c => c.Users.Username).ToList(); return(users.Where(u => userCustomers.Contains(u.CustomerName)).ToList()); }
public List <PlantModel> GetAllPlantsRole(enRole role) { var result = new List <PlantModel>(); try { var idUsers = _context.Set <Roles_Customer>().Where(e => e.Roles.IdRole == (int)role).Select(e => e.CustomerID) .ToList(); var query = _context.Set <UserMachineMapping>().Where(w => idUsers.Contains(w.UserId) && w.Machine.PlantId != null).Select(s => s.Machine.Plant).Distinct().ToList(); result = query.Adapt <List <PlantModel> >(); } catch (Exception ex) { var errMessage = string.Format(ex.GetStringLog()); LogService.WriteLog(errMessage, LogService.TypeLevel.Error, ex); } return(result); }
private ChartViewModel GetHistoricalOptions(MachineInfoModel machine, PeriodModel period, enRole role, string actualMachineGroup = null) { var options = new ChartViewModel(); var granularity = Common.GetAggregationType(period.StartDate, period.EndDate); var startDateTrend = Common.GetStartDateTrend(period.EndDate, period.StartDate, granularity); var periodTrend = new PeriodModel(); periodTrend.StartDate = startDateTrend.ToUniversalTime().Date; periodTrend.EndDate = period.EndDate.ToUniversalTime().Date.AddDays(1).AddTicks(-1); periodTrend.Aggregation = granularity; var data = _messageService.GetAggregationMessages(machine, periodTrend, enDataType.Historical, actualMachineGroup)?.OrderBy(o => o.Day).ToList() ?? new List <HistoryMessageModel>(); if (data.Count == 0) { return(null); } options.yTitle = $"{Resource.Quantity} (n)"; var days = data.Where(w => w.Day != null && (w.Type == (int)enTypeAlarm.Warning || w.Type == (int)enTypeAlarm.Error)).Select(s => s.Day.Value).Distinct().ToList(); if (role == enRole.Administrator || role == enRole.RandD || role == enRole.Assistance) { days = data.Where(w => w.Day != null && (w.Type == (int)enTypeAlarm.Warning || w.Type == (int)enTypeAlarm.Error || w.Type == (int)enTypeAlarm.CN)).Select(s => s.Day.Value).Distinct().ToList(); } options.categories = CommonViewService.GetTimeCategories(days, granularity); var series = new List <SerieViewModel>(); var serieOperator = new SerieViewModel(); serieOperator.name = enTypeAlarm.Warning.ToLocalizedString(_contextService.GetContext().ActualLanguage.InitialsLanguage); serieOperator.color = CommonViewService.GetColorAlarm(enTypeAlarm.Warning); var serieError = new SerieViewModel(); serieError.name = enTypeAlarm.Error.ToLocalizedString(_contextService.GetContext().ActualLanguage.InitialsLanguage); serieError.color = CommonViewService.GetColorAlarm(enTypeAlarm.Error); var serieCN = new SerieViewModel(); serieCN.name = enTypeAlarm.CN.ToLocalizedString(_contextService.GetContext().ActualLanguage.InitialsLanguage); serieCN.color = CommonViewService.GetColorAlarm(enTypeAlarm.CN); serieOperator.data = new List <int>(); serieError.data = new List <int>(); serieCN.data = new List <int>(); foreach (string cat in options.categories) { var catVal = data.Where(w => w.Type == (int)enTypeAlarm.Warning && CommonViewService.GetTimeCategory((DateTime)w.Day, granularity) == cat).Select(s => s.Count ?? 0).FirstOrDefault(); serieOperator.data.Add(catVal); var catVal2 = data.Where(w => w.Type == (int)enTypeAlarm.Error && CommonViewService.GetTimeCategory((DateTime)w.Day, granularity) == cat).Select(s => s.Count ?? 0).FirstOrDefault(); serieError.data.Add(catVal2); var catVal3 = data.Where(w => w.Type == (int)enTypeAlarm.CN && CommonViewService.GetTimeCategory((DateTime)w.Day, granularity) == cat).Select(s => s.Count ?? 0).FirstOrDefault(); serieCN.data.Add(catVal3); } series.Add(serieOperator); series.Add(serieError); if (role == enRole.Administrator || role == enRole.RandD || role == enRole.Assistance) { series.Add(serieCN); } options.series = series; return(options); }