private Logic GetAppTileLogic(AppTile appTile) { if (!appTile.IsCustomized) { #region Generate logic for SystemDefined Tile switch (appTile.Id) { case 1: appTile = GetMyReport_SubscriptionTile(); break; case 2: appTile = GetMyReport_MyReportTile(); break; case 3: appTile = GetMyReport_RecommendedTile(); break; default: break; } #endregion } else { appTile.BasicLogic = GenerateTileLogic(appTile); } return(appTile.BasicLogic); }
private void ModifyTile(AppTile aTile) { var t = aTile.ToTile(); var queryLogicList = this.GenerateQueryLogicFromAppTile(aTile); switch (aTile.Status) { case Enums.ChangeStatus.Add: t.TileQueryLogics = _tileQueryLogicRepository.AddBatchTileQueryLogics(queryLogicList); _tileRepository.AddTile(t); break; case Enums.ChangeStatus.Change: var logics = _tileQueryLogicRepository.AddBatchTileQueryLogics(queryLogicList); t.TileQueryLogics = _tileQueryLogicRepository.ModifyTileQueryLogic(aTile.Id.Value, logics); _tileRepository.ModifyTile(t); break; case Enums.ChangeStatus.Delete: _tileRepository.DeleteTile(t); break; default: throw new ArgumentException("The tile status shall be in Add, Change and Delete"); } }
public override void Execute(object parameter) { Logging.DebugLogger.WriteLine($"{GetType().Name}.{nameof(Execute)}({parameter})"); var result = MessageBox.Show("Are you sure you want to transform this tile?", "Warning!", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.No) { return; } if (!(parameter is ITile tile)) { MessageBox.Show($"Could not transform to {nameof(AppTile)}, parameter was of type {parameter.GetType()}."); return; } if (tile.Button == null) { MessageBox.Show($"Could not transform to {nameof(AppTile)}, not connected to a button yet."); return; } var newTile = new AppTile(tile.Id, tile.Column, tile.Row, tile.Text, tile.Background, tile.Foreground, "", ""); tile.Button.Update(newTile); Settings.ReplaceTile(tile, newTile); new EditTileCommand().Execute(newTile); }
private void DoDragDropFromWebBrowser(DragEventArgs e, AppTile newTile) { var url = e.Data.GetData(DataFormats.Text) as string ?? ""; var resolver = new PathResolver(url); if (resolver.Type != PathType.Web && resolver.Type != PathType.UnknownProtocol) { return; } var host = new Uri(url).Host; _window.Activate(); var result = MessageBox.Show($"Do you want to replace the current path '{newTile.Path}' with '{url}'?", $"Replacing '{_tile.Text}'", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.No) { return; } var text = newTile.Text == "-" ? host : newTile.Text; newTile.Path = url; newTile.Text = text; Settings.SetChanged(); MouseDrag.ResetAll(); }
private void CreateWindow(TileCollection tiles) { Width = tiles.Width; Height = tiles.Height; for (var i = 0; i < tiles.Columns; i++) { MainGrid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); } for (var i = 0; i < tiles.Rows; i++) { MainGrid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); } for (var row = 0; row < tiles.Rows; row++) { for (var col = 0; col < tiles.Columns; col++) { var tile = tiles.FirstOrDefault(t => t.Column == col && t.Row == row); if (tile == null) { var id = tiles.Count > 0 ? tiles.Max(t => t.Id) + 1 : 0; tile = new AppTile(id, col, row); tiles.Add(tile); } var button = new TileButton(tile, this); MainGrid.Children.Add(button); } } }
private List <TileQueryLogic> GenerateQueryLogicFromAppTile(AppTile appTile) { List <TileQueryLogic> logicList = new List <TileQueryLogic>(); TileQueryLogic logic = null; #region switch switch (appTile.logicType) { case LogicType.Selected: logic = SetTileQueryLogic(appTile.BasicLogic, appTile); logicList.Add(logic); break; case LogicType.Filtered: foreach (var item in (appTile.BasicLogic as AND).LogicElements) { logic = SetTileQueryLogic(item, appTile); logicList.Add(logic); } break; case LogicType.Tagged: logic = SetTileQueryLogic(appTile.BasicLogic, appTile); logicList.Add(logic); break; default: break; } #endregion return(logicList); }
public static List <AppTile> AddTransactionData(List <Encounter> encounters, int maxTransactionsPerEncounter, DateTime startDate, DateTime endDate) { var appTiles = new List <AppTile>(); var random = new Random(Guid.NewGuid().GetHashCode()); var personData = PartyDataFactory.CreatePersonData(100); var medicationData = MedDataFactory.CreateMedicationData(); for (var i = 0; i < encounters.Count; i++) { var dateString = DataUtility.FormatCurrentDateTime(); var transactionsPerEncounter = random.Next(1, maxTransactionsPerEncounter); var appTile = new AppTile { Id = Guid.NewGuid().ToString(), BatchId = string.Empty, RunId = string.Empty, TimestampLocal = DateTime.Now, TimestampUtc = DateTime.UtcNow, ClientKey = 0, SourceId = random.Next(1, 40).ToString(), DispenseTransactionKey = 0, EncounterId = encounters[i].EncounterId, MedId = random.Next(1, 8).ToString(), StationName = string.Empty, OrderAmount = null, OrderUnits = null, }; appTile.AppTransactions = new List <AppTileTransaction>(); for (var j = 0; j < transactionsPerEncounter; j++) { var transaction = new AppTileTransaction(); transaction.RelatedTransactionKey = 0; var encounterStartDate = DataUtility.GetRandomDateTime(random, startDate, endDate); transaction.TransactionDateTime = encounterStartDate; transaction.TransactionType = ((TransactionTypeEnum)random.Next(1, 5)).ToString(); transaction.TransactionAmount = random.Next(1, 10000); transaction.TransactionUnits = string.Empty; transaction.PartyId = random.Next(1, 99).ToString(); appTile.AppTransactions.Add(transaction); } appTiles.Add(appTile); } return(appTiles); }
/// <summary> /// Convert a tile type to apptile type /// </summary> /// <param name="tile"></param> /// <returns></returns> public static AppTile ToAppTile(this Tile tile) { AppTile appTile = null; #region Initial if (tile.Id <= 3) { if (tile.Id == SystemDefinedTile.MyReports_MySubscriptions.SystemDefinedTileId) { appTile = new AppMySubscriptionsTile(); } else if (tile.Id == SystemDefinedTile.MyReports_MyReports.SystemDefinedTileId) { appTile = new AppMyReportsTile(); } else if (tile.Id == SystemDefinedTile.MyReports_MySubscriptions.SystemDefinedTileId) { appTile = new AppMySubscriptionsTile(); } //else //{ // throw new Exception(String.Format("DO NOT support the {0}", tile.Id.ToString())); //} } else { appTile = new AppTeamSiteCustomizedTile(); } #endregion appTile.Id = tile.Id; appTile.Title = tile.Title; appTile.IsCustomized = tile.IsCustomized; appTile.Top = tile.Top; appTile.Left = tile.Left; appTile.Width = tile.Width; appTile.Height = tile.Height; appTile.BackgroundColor = tile.BackgroundColor; appTile.Icon = tile.Icon; appTile.BackgroundImage = tile.BackgroundImage; appTile.ImageOverlayColor = tile.ImageOverlayColor; appTile.ReportCountStyle = tile.ReportCountStyle; appTile.OwnerTeamSiteId = tile.OwnerTeamSiteId; appTile.Status = ChangeStatus.Normal; appTile.TileType = (TileType)(tile.TileType); appTile.logicType = (LogicType)tile.LogicStringType; return(appTile); }
public ICollection <Statistics> GetTeamSiteReportsStatistics(Int32 tileId, String userAlias, String teamSiteGuid, Boolean isCurrentSiteAdmin) { bool hasAdminSite = isCurrentSiteAdmin; TileServices tService = new TileServices(_tileRepository, _teamRepository, _reportRepository, _userRepository, _tagRepository, _categoryRepository, _tileQueryRepository); AppTile at = tService.GetTileById(tileId); ParameterProvider pp = new ParameterProvider(); //if (userAlias != "") //{ //pp.AddParameter(ContextVariable.CurrentUser.ToString(), userAlias); //} pp.AddParameter(ContextVariable.CurrentTeamSiteGuid.ToString(), new Guid(teamSiteGuid)); //pp.AddParameter(ContextVariable.CurrentUserGroup.ToString(), appUserGroupList); //if (hasAdminSite) //{ pp.AddParameter(ContextVariable.TeamSiteGuidUnderControl.ToString(), new List <Guid>() { new Guid(teamSiteGuid) }); //} Logic logic = at.GetCombinedLogic(hasAdminSite, tileId).And((new TeamSiteGUID()).Equal(Guid.Parse(teamSiteGuid))); var reports = _reportRepository.GetReportByLogic(logic, pp).ToArray().Select(_ => _.ToAppReport()).ToList(); foreach (var report in reports) { foreach (var cat in report.Categories) { if (cat.ParentId != null) { cat.ParentCategory = _categoryRepository.Get(cat.ParentId.GetValueOrDefault()).ToAppCategory(); //cat.Reports.Add(report); } } } return(GetStatistics(reports)); }
private List <AppReport> GetReportsByTeam(Guid teamSiteGuid, Int32 tileId, ReportFilter filter, Boolean isCurrentUserTeamSiteAdmin, String userAlias, Int32 pageNum, Int32 pageSize, SortField sortField, SortOrder sortOrder) { #region Get the logic TileServices tService = new TileServices(_tileRepository, _teamRepository, _reportRepository, null, null, null, _tileQueryRepository); AppTile ap = null; bool hasAdminTeamSite = isCurrentUserTeamSiteAdmin; ap = tService.GetTileById(tileId); #endregion #region Combine the logic var topLevelLogic = (new TeamSiteGUID()).Equal(teamSiteGuid).And(ap.GetCombinedLogic(hasAdminTeamSite, tileId)); var logic = GenerateLogicByFilter(filter); if (logic != null) { topLevelLogic.AddElement(logic); } #endregion #region Compose the logic parameter ParameterProvider pp = new ParameterProvider(); //if (userAlias != "") //{ //pp.AddParameter(ContextVariable.CurrentUser.ToString(), userAlias); //} pp.AddParameter(ContextVariable.CurrentTeamSiteGuid.ToString(), teamSiteGuid); //if (isCurrentUserTeamSiteAdmin) //{ pp.AddParameter(ContextVariable.TeamSiteGuidUnderControl.ToString(), (new List <Guid>() { teamSiteGuid })); //} #endregion #region generate the result return(GetReportsByLogic(topLevelLogic, sortField, sortOrder, pp, pageNum, pageSize).ToArray().Select(_ => _.ToAppReport()).ToList()); #endregion }
private void DoDragDropFromFileExplorer(DragEventArgs e, AppTile newTile) { var paths = e.Data.GetData(DataFormats.FileDrop) as string[]; var path = paths?.FirstOrDefault() ?? ""; _window.Activate(); var result = MessageBox.Show($"Do you want to replace the current path '{newTile.Path}' with '{path}'?", $"Replacing '{_tile.Text}'", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.No) { return; } var text = newTile.Text == "-" ? System.IO.Path.GetFileNameWithoutExtension(path) : newTile.Text; newTile.Path = path; newTile.Text = text; Settings.SetChanged(); MouseDrag.ResetAll(); }
private TileQueryLogic SetTileQueryLogic(Logic logic, AppTile appTile) { TileQueryLogic qc = new TileQueryLogic(); if ((logic as IN <string>) != null) { qc.FiledName = (logic as IN <string>).Field.Name; qc.FiledValue = string.Join(",", (logic as IN <string>).FieldValue.GetValue()); } else { qc.FiledName = (logic as IN <Int32>).Field.Name; qc.FiledValue = string.Join(",", (logic as IN <Int32>).FieldValue.GetValue()); } if (appTile.Id != null) { qc.TileId = appTile.Id.Value; } return(qc); }
/// <summary> /// Convert from an AppTile type to Tile /// </summary> /// <param name="apptile"></param> /// <returns></returns> public static Tile ToTile(this AppTile apptile) { return(new Tile() { Id = apptile.Id != null ? apptile.Id.Value : 0, BackgroundColor = apptile.BackgroundColor, BackgroundImage = apptile.BackgroundImage, Height = apptile.Height, Icon = apptile.Icon, ImageOverlayColor = apptile.ImageOverlayColor, IsCustomized = apptile.IsCustomized, Left = apptile.Left, LogicStringType = (Int16)apptile.logicType, OwnerTeamSiteId = apptile.OwnerTeamSiteId, ReportCountStyle = apptile.ReportCountStyle, TileType = (Int32)apptile.TileType, Title = apptile.Title, Top = apptile.Top, Width = apptile.Width }); }
public static TileViewModel ToTileViewModel(this AppTile appTile) { TileViewModel tile = new TileViewModel(); tile.id = appTile.Id.Value; tile.title = appTile.Title; tile.TileType = (Int32)appTile.TileType; tile.coordinateY = appTile.Top; tile.coordinateX = appTile.Left; tile.demensionX = appTile.Width; tile.demensionY = appTile.Height; tile.icon = appTile.Icon; tile.backgroundColor = appTile.BackgroundColor; tile.backgroundImage = appTile.BackgroundImage; tile.overlayColor = appTile.ImageOverlayColor; tile.shownCount = appTile.ReportCountStyle; tile.countNum = appTile.ReportCount.ToString(); tile.IsCustomized = appTile.IsCustomized; tile.OwnerTeamSiteId = appTile.OwnerTeamSiteId; tile.LogicType = appTile.logicType.ToString(); tile.LogicString = GetlogicStringFromLogic(appTile); return(tile); }
public IEnumerable <AppReport> GetReportsByTileId(AppTile appTile, string userAlias, bool isAdmin, string teamSiteGuid, SortField sortField, SortOrder sortOrder) { Guid guid = new Guid(teamSiteGuid); ParameterProvider pp = new ParameterProvider(); //if (userAlias != "") //{ //pp.AddParameter(ContextVariable.CurrentUser.ToString(), userAlias); //} pp.AddParameter(ContextVariable.CurrentTeamSiteGuid.ToString(), new Guid(teamSiteGuid)); //if (isAdmin) //{ pp.AddParameter(ContextVariable.TeamSiteGuidUnderControl.ToString(), new List <Guid>() { new Guid(teamSiteGuid) }); //} appTile.BasicLogic = appTile.BasicLogic.And((new TeamSiteGUID()).Equal(guid)); return(_reportRepository.GetReportsByExpression(appTile.GetCombinedLogic(true, appTile.Id).GetExpression(pp)).ToArray().Select(_ => _.ToAppReport())); }
private Logic GenerateTileLogic(AppTile appTile) { if (appTile.logicType == LogicType.AllReports) { return(GetTeamSite_AllReportsTile().BasicLogic); } else { List <TileQueryLogic> tileLogicList = _tileQueryLogicRepository.GetTileQueryLogicsByTileId(appTile.Id.Value); #region Generate the Logic #region Set up the dictionary of type var tagId = new TagId(); var reportOwnerId = new ReportOwnerId(); var subCategoryId = new SubCategoryId(); var reportDataId = new ReportDataId(); Dictionary <string, IIN <Int32> > dc = new Dictionary <string, IIN <int> >(); dc.Add(tagId.Name, tagId); //dc.Add(reportOwnerId.Name, reportOwnerId); dc.Add(subCategoryId.Name, subCategoryId); dc.Add(reportDataId.Name, reportDataId); Dictionary <string, IIN <String> > dcString = new Dictionary <string, IIN <string> >(); dcString.Add(reportOwnerId.Name, reportOwnerId); #endregion Logic resultLogic = null; if (appTile.logicType == LogicType.Selected) { resultLogic = dc[reportDataId.Name].In(tileLogicList[0].FiledValue.Split(',').Select(_ => int.Parse(_))); } if (appTile.logicType == LogicType.Filtered) { var logic = new AND(); foreach (var item in tileLogicList) { Logic l = null; if (item.FiledValue.GetType() == typeof(string) && dcString.Keys.Contains <string>(item.FiledName)) { l = dcString[item.FiledName].In(item.FiledValue.Split(',').Select(_ => _.ToString())); } else { l = dc[item.FiledName].In(item.FiledValue.Split(',').Select(_ => int.Parse(_))); } logic.AddElement(l); } resultLogic = logic; } if (appTile.logicType == LogicType.Tagged) { Logic logic = dc[tagId.Name].In(tileLogicList[0].FiledValue.Split(',').Select(_ => int.Parse(_))); resultLogic = logic; } #endregion return(resultLogic); } }
public async Task <ActionResult> Index() { var conn = new InforConnection(reportServerAddress: $"{SettingsManager.GetSettingValueAsString("rpurl")}", tu: _tu, tup: _tup); if (AppUserState == null || AppUserState.Connected == false) { return(RedirectToAction("LogOff", "Auth")); } var result = await conn.GetSearchesWeb(AppUserState.UserName, AppUserState.Wgs, AppUserState.Ds, AppUserState.ReportingUserName); if (result.Faults.Any()) { ErrorDisplay.ShowError(result.Faults[0].Message); return(PartialView(_viewModel)); } var allsearches = (InforSearches)result.ReturnObject; var distinctApps = allsearches.GroupBy(search => search.App).Select(group => group.First()); _viewModel.User = AppUserState; _viewModel.AppTiles = new AppTiles(); _viewModel.UserTiles = new AppTiles(); _viewModel.ShowSearch = false; var displayOrder = 99; foreach (var app in distinctApps) { var imgurl = ""; switch (app.App) { case "Search": imgurl = $"/Content/Images/Apps/inReachIcon2.ico"; displayOrder = 0; _viewModel.ShowSearch = true; break; case "inScribe": imgurl = $"/Content/Images/Apps/inScribe.ico"; break; case "Process": imgurl = $"/Content/Images/Apps/eTick.jpg"; displayOrder = 1; break; case "Reporting": imgurl = $"/Content/Images/Apps/eTick.jpg"; displayOrder = 2; break; case "Administration": imgurl = $"/Content/Images/Apps/eTick.jpg"; displayOrder = 3; break; default: imgurl = $"/Content/Images/Apps/inReachIcon2.jpg"; break; } var apptile = new AppTile { Title = app.App, IconUrl = imgurl, AppTiles = new Tiles(), DisplayOrder = displayOrder }; foreach (var search in allsearches.Where(search => search.App == app.App)) { apptile.AppTiles.Add(new Tile { Title = search.Name, IconUrl = search.GetImageUrl(), Search = search, AppTitle = search.App, DisplayOrder = search.DisplayOrder }); } apptile.UserTiles = new Tiles(); //{ // new Tile {Title = $"User Tile Test 1 for app {app.App}", IconUrl = $"/Content/Images/LoggedIn.png"} //}; _viewModel.AppTiles.Add(apptile); } var usertile = new AppTile { Title = "UserTiles", IconUrl = "", AppTiles = new Tiles() }; //var usertilestCookie = Request.Cookies["usertiles"]; //if (usertilestCookie != null) //{ // var usertilesString = usertilestCookie.Value; // var usertilesList = usertilesString.Split('|'); // foreach (var s in usertilesList) // { // var searchTile = allsearches.FirstOrDefault(search => search.Name == s); // if (searchTile != null) usertile.AppTiles.Add(new Tile { Title = searchTile.Name, IconUrl = searchTile.Imageurl, Search = searchTile, AppTitle = searchTile.App}); // } //} _viewModel.UserTiles.Add(usertile); if (!System.IO.File.Exists(Path.Combine(LocalStorageContainer, $"{AppUserState.Wgs}{AppUserState.Ds}{AppUserState.UserId}"))) { return(View(_viewModel)); } var serhvm = JsonConvert.DeserializeObject <HomePageViewModel>(System.IO.File.ReadAllText( Path.Combine(LocalStorageContainer, $"{AppUserState.Wgs}{AppUserState.Ds}{AppUserState.UserId}"))); _viewModel.AutoCloseCharms = serhvm.AutoCloseCharms; _viewModel.AutoScrollCaro = serhvm.AutoScrollCaro; _viewModel.VerticalTrees = serhvm.VerticalTrees; _viewModel.SavedSearches = conn.GetSavedSearchesWeb(AppUserState.UserName, AppUserState.Wgs, AppUserState.Ds); _viewModel.Theme = serhvm.Theme; return(View(_viewModel)); }
private void UpdateTileInformation() { // Update team site dashboard settings var tileData = Request.Params["TilesData"]; var teamGuid = Request.Params["SiteGUID"].ToString(); // tile data JavaScriptSerializer jss = new JavaScriptSerializer(); List <TileViewModel> paraTileList = jss.Deserialize <List <TileViewModel> >(tileData); // Save the tile data into our database using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { TileRepository repository = new TileRepository(context); // Get the team id by its team guid value TeamRepository tRepository = new TeamRepository(context); TeamAppService teamService = new TeamAppService(tRepository); TileQueryLogicRepository tileQueryRepository = new TileQueryLogicRepository(context); int teamId = teamService.GetAllTeamSites().First(_ => _.TeamGuid == Guid.Parse(teamGuid)).Id.Value; //validate the data if (paraTileList.Count() > 24) { throw new ArgumentException("the count of the tile is more than 24"); } foreach (var item in paraTileList) { if (item.coordinateX < 0 || item.coordinateX > 7) { throw new ArgumentException("coordinateX must be between 0 and 7"); } if (item.coordinateY < 0 || item.coordinateY > 2) { throw new ArgumentException("coordinateY must be between 0 and 2"); } if (item.demensionX < 1 || item.demensionX > 8) { throw new ArgumentException("demensionX must be between 1 and 8"); } if (item.demensionY < 1 || item.demensionY > 3) { throw new ArgumentException("demensionY must be between 1 and 3"); } } TileServices tService = new TileServices(repository, null, null, null, null, null, tileQueryRepository); List <AppTile> tiles = new List <AppTile>(); List <AppTile> orignalTiles = tService.GetTilesByTeamId(teamId).ToList(); //tiles will be remove foreach (var item in orignalTiles) { if (!paraTileList.Any(_ => _.id == item.Id)) { if (item.logicType == LogicType.AllReports) { continue; } AppTile appTile = tService.GetTileById(item.Id.Value); appTile.Status = ChangeStatus.Delete; tiles.Add(appTile); } } foreach (var para in paraTileList) { //tiles will be Added if (para.id < 0) { AppTile appTile = new AppTeamSiteCustomizedTile(); appTile.TileType = TileType.TeamSite; appTile.Status = ChangeStatus.Add; appTile.Title = para.title; appTile.Top = para.coordinateY; appTile.Left = para.coordinateX; appTile.Width = para.demensionX; appTile.Height = para.demensionY; appTile.BackgroundColor = para.backgroundColor; appTile.Icon = para.icon; appTile.BackgroundImage = para.backgroundImage; appTile.ImageOverlayColor = para.overlayColor; appTile.ReportCountStyle = para.shownCount; appTile.OwnerTeamSiteId = teamId; appTile.IsCustomized = true; appTile.logicType = (LogicType)Enum.Parse(typeof(LogicType), para.LogicType); SetAppTitleLogic(para.LogicString, appTile); tiles.Add(appTile); } //tiles will be Updated if (para.id > 0) { AppTile appTile = tService.GetTileById(para.id); if (appTile == null) { continue; } appTile.Status = ChangeStatus.Change; appTile.Top = para.coordinateY; appTile.Left = para.coordinateX; appTile.Width = para.demensionX; appTile.Height = para.demensionY; appTile.BackgroundColor = para.backgroundColor; appTile.Icon = para.icon; appTile.BackgroundImage = para.backgroundImage; appTile.ImageOverlayColor = para.overlayColor; appTile.ReportCountStyle = para.shownCount; appTile.IsCustomized = true; if (appTile.logicType != LogicType.AllReports) { appTile.Title = para.title; appTile.logicType = (LogicType)Enum.Parse(typeof(LogicType), para.LogicType); SetAppTitleLogic(para.LogicString, appTile); } tiles.Add(appTile); } } tService.ModifyTile(tiles); } }
private void SetAppTitleLogic(string logicString, AppTile appTile) { using (MainDBUnitWorkContext context = new MainDBUnitWorkContext()) { TileRepository repository = new TileRepository(context); ReportRepository _reportRepository = new ReportRepository(context); if (!string.IsNullOrEmpty(logicString)) { EditReportService reportService = new EditReportService(null, null, null, null, null, null); switch (appTile.logicType) { case LogicType.Static: appTile.BasicLogic = null; break; case LogicType.Selected: List <int> cataIDList = logicString.Split(',').Select(_ => Convert.ToInt32(_)).ToList(); appTile.BasicLogic = (new ReportDataId()).In(cataIDList); break; case LogicType.Filtered: ReportFilter filer = new ReportFilter(); JavaScriptSerializer jss = new JavaScriptSerializer(); #region Deserialize TileFilterListViewModel vm = new TileFilterListViewModel(); if (!String.IsNullOrEmpty(logicString)) { vm = jss.Deserialize <TileFilterListViewModel>(logicString); } #endregion #region Get ReportFilter filer.OwnerIdCollection = (from o in vm.Owner select o.Id).ToList(); //filer.CatalogTypeIdCollection = (from c in vm.CatelogType select c.Id).ToList(); filer.TagsIdCollection = (from t in vm.Tag select t.Id.Value).ToList(); filer.SubCategoryIdCollection = (from c in vm.SubCategory select c.Id.Value).ToList(); #endregion appTile.BasicLogic = reportService.GenerateLogicByFilter(filer); break; case LogicType.Tagged: List <int> tagIds = logicString.Split(',').Select(i => int.Parse(i.Trim())).ToList(); appTile.BasicLogic = (new TagId()).In(tagIds); break; case LogicType.AllReports: appTile.BasicLogic = null; break; } } else { appTile.BasicLogic = null; } } }
public Int32 GetTempTilesWithReportCount(String teamSiteGuid, string userAlias, AppTile appTile) { Guid guid = new Guid(teamSiteGuid); ParameterProvider pp = new ParameterProvider(); //if (userAlias != "") //{ // pp.AddParameter(ContextVariable.CurrentUser.ToString(), userAlias); //} pp.AddParameter(ContextVariable.CurrentTeamSiteGuid.ToString(), new Guid(teamSiteGuid)); pp.AddParameter(ContextVariable.TeamSiteGuidUnderControl.ToString(), new List <Guid>() { new Guid(teamSiteGuid) }); appTile.BasicLogic = appTile.BasicLogic.And((new TeamSiteGUID()).Equal(guid)); appTile.ReportCount = _reportRepository.GetReportsByExpression(appTile.GetCombinedLogic(true, appTile.Id).GetExpression(pp)).Count(); return(appTile.ReportCount); }
private static string GetlogicStringFromLogic(AppTile appTile) { string logicString = string.Empty; switch (appTile.logicType) { case LogicType.Selected: logicString = string.Join(",", (appTile.BasicLogic as IN <int>).FieldValue.GetValue()); break; case LogicType.Filtered: List <Logic> elements = (appTile.BasicLogic as AND).LogicElements; if (elements != null && elements.Count > 0) { #region Get ReportFilter from Logic ReportFilter filer = new ReportFilter(); foreach (var t in elements) { if (t as IN <int> != null) { if ((t as IN <int>).Field is TagId) { filer.TagsIdCollection = (t as IN <int>).FieldValue.GetValue(); } if ((t as IN <int>).Field is SubCategoryId) { filer.SubCategoryIdCollection = (t as IN <int>).FieldValue.GetValue(); } } if ((t as IN <string>) != null) { if ((t as IN <string>).Field is ReportOwnerId) { filer.OwnerIdCollection = (t as IN <string>).FieldValue.GetValue(); } } } #endregion #region Get TileFilterListViewModel from ReportFilter TileFilterListViewModel vm = new TileFilterListViewModel(); if (filer.TagsIdCollection != null && filer.TagsIdCollection.Count > 0) { vm.Tag = filer.TagsIdCollection.Select(id => new AppTeamTag { Id = id }); } if (filer.SubCategoryIdCollection != null && filer.SubCategoryIdCollection.Count > 0) { vm.SubCategory = filer.SubCategoryIdCollection.Select(id => new AppCategory { Id = id }); } if (filer.OwnerIdCollection != null && filer.OwnerIdCollection.Count > 0) { vm.Owner = filer.OwnerIdCollection.Select(id => new UserLoginApp { Id = id }); } #endregion JavaScriptSerializer jss = new JavaScriptSerializer(); logicString = jss.Serialize(vm); } break; case LogicType.Tagged: logicString = string.Join(",", (appTile.BasicLogic as IN <int>).FieldValue.GetValue()); break; default: break; } return(logicString); }