public ActionResult Index()
 {
     //Gets authentication
     LoginModel login = (LoginModel)Session.Contents["AuthenticatedUser"];
     CatalogModel catalog = (CatalogModel)Session.Contents["Catalog"];
     CatalogModel model = new CatalogModel();
     if (catalog == null)
     {
         if (login != null)
         {
             model.SRSProxy = CatalogModel.SRSAuthenticate(login.AuthenticationUser);
             model = CatalogModel.GetCatalogItems(login.AuthenticationUser, model.SRSProxy);
             RememberMe(model);
             return View(model);
         }
         else
         {
             LoginModel.ErrorMessage = "Session Expired";
             return RedirectToAction("Login", "Login");
         }
     }
     else
     {
         return View(catalog);
     }
 }
 private void AddReport(FormCollection collection, CatalogModel content, LoginModel login)
 {
     try
     {
         content.ReportItem.FilePath = collection["ReportFilePath"];
         content.ReportItem.Name = collection["ReportName"];
         content.AddReport();
     }
     catch (Exception e)
     {
         content.Error = e;
     }
 }
 private void Delete(LoginModel login, CatalogModel content)
 {
     try
     {
         //Delete item in SRS
         content.DeleteItem(login.AuthenticationUser);
         RefreshCatalog(login, content);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
        private CatalogModel SeletedItem()
        {
            string url = Request.Url.AbsoluteUri;
            string key = url.Substring(url.IndexOf('_'));

            LoginModel login = (LoginModel)Session.Contents["AuthenticatedUser"];
            CatalogModel catalog = (CatalogModel)Session.Contents["Catalog"];
            CatalogModel content = new CatalogModel();

            if (key.Equals("_"))
            {
                //Select Home
                content.Name = "Home";
                content.Path = "/";
                content.ItemType = "Folder";
            }
            else
            {
                //Select other item
                content = CatalogModel.GetItem(catalog.AllItems, key);
                if (content != null)
                {
                    switch (content.ItemType)
                    {
                        case "Report":
                            content.GetReportParameters(login.AuthenticationUser, catalog.SRSProxy);
                            content.GetItemProperty(login.AuthenticationUser);
                            break;

                        case "Folder":
                            content.GetItemProperty(login.AuthenticationUser);
                            break;

                        case "LinkedReport":
                            content.GetReportParameters(login.AuthenticationUser, catalog.SRSProxy);
                            content.GetItemProperty(login.AuthenticationUser);
                            break;

                        case "DataSource":
                            content.GetDataSourceItem(login.AuthenticationUser, catalog.SRSProxy);
                            content.GetItemProperty(login.AuthenticationUser);
                            break;
                    }
                }
                else
                {
                    //Item not found
                }
            }

            catalog.Name = content.Name;
            catalog.ItemType = content.ItemType;
            catalog.Parent = content.Parent;
            catalog.Path = content.Path;
            catalog.ReportParameters = content.ReportParameters;
            catalog.ItemProperties = content.ItemProperties;
            catalog.DataSourceItem = content.DataSourceItem;
            catalog.Result = string.Empty;
            catalog.Error = null;
            return catalog;
        }
 private CatalogModel Run(FormCollection collection, CatalogModel content)
 {
     foreach (var item in content.ReportParameters)
     {
         item.SelectedValue = collection[item.Name];
         if (string.IsNullOrEmpty(item.SelectedValue))
         {
             if (item.ParameterType.ToString().Equals("Float", StringComparison.OrdinalIgnoreCase) || item.ParameterType.ToString().Equals("Integer", StringComparison.OrdinalIgnoreCase))
             {
                 item.SelectedValue = "0";
             }
         }
     }
     content.RunReport(Request.Url.Host);
     return content;
 }
        private bool SaveDatasource(FormCollection collection, CatalogModel content, LoginModel login)
        {
            try
            {
                string address = string.Empty;
                foreach (var item in content.DataSourceItem.itemProperties)
                {
                    item.Value = collection[item.PropertyName];
                }

                if (content.ItemType.Equals("Folder"))
                {
                    address = content.Path.Substring(content.Path.IndexOf('/'));
                }
                else
                {
                    address = content.Parent.Substring(content.Parent.IndexOf('/'));
                }

                content.SaveDataSource(login.AuthenticationUser, address);
                RefreshCatalog(login, content);
                return true;
            }
            catch (Exception e)
            {
                content.Error = e;
                return false;
            }
        }
        private void RememberMe(CatalogModel model)
        {
            //Add to cookie
            HttpCookie webcookie = new HttpCookie(model.SRSProxy.AuthCookie.Name, model.SRSProxy.AuthCookie.Value);
            webcookie.Expires = DateTime.MaxValue;
            Response.AppendCookie(webcookie);

            //Add to session
            Session.Add("Catalog", model);
        }
        private void RefreshCatalog(LoginModel login, CatalogModel content)
        {
            //Refresh the catalog model
            content = CatalogModel.GetCatalogItems(login.AuthenticationUser, content.SRSProxy);

            //Replace the catalog session with the updated one
            Session.Remove("Catalog");
            Session.Add("Catalog", content);
        }
Ejemplo n.º 9
0
        public static SettingsModel GetExportMappings(AuthenticatedUserManager user)
        {
            SettingsModel model = InitializeCatalog(user, CatalogModel.SRSAuthenticate(user));

            CatalogModel proxyCatalog = new CatalogModel();
            model.Catalog.Catalogs.RemoveAll(item => item.ItemType != "Folder" && item.ItemType !="Report");
            foreach (CatalogModel catModel in model.Catalog.Catalogs)
            {
                catModel.Children.RemoveAll(item => item.ItemType != "Folder" && item.ItemType != "Report");
                foreach (CatalogModel catModel2 in catModel.Children)
                {
                    catModel2.Children.RemoveAll(item => item.ItemType != "Folder" && item.ItemType != "Report");
                }
            }
            model.Catalog.Catalogs.RemoveAll(item => item.ItemType == "Folder" && item.Children.Count == 0);

            foreach (CatalogModel catModel in model.Catalog.Catalogs)
            {
                catModel.Catalogs.RemoveAll(item => item.ItemType == "Folder" && item.Children.Count == 0);
                foreach (CatalogModel catModel2 in model.Catalog.Catalogs)
                {
                    catModel2.Catalogs.RemoveAll(item => item.ItemType == "Folder" && item.Children.Count == 0);
                }
            }
            model.ExportMappings = new BOExportMapCollection();
            model.ExportMappings.Fill();

            model.ExportMapDisplayOptions = new StringCollection();
            model.ExportMapDisplayOptions.Add(Constants.ExportMapCatalogOptions.ExportAndView);
            model.ExportMapDisplayOptions.Add(Constants.ExportMapCatalogOptions.ExportOnly);
            return model;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Converts NCatalogItem to CatalogModel
        /// </summary>
        public static CatalogModel ToModel(NCatalogItem item)
        {
            CatalogModel model = new CatalogModel();
            //Construct the key
            model.Key = item.Path.Replace("/", "_");
            model.Key = model.Key.Replace(" ", "");

            model.Name = item.Name;
            model.Path = "root"+ item.Path;
            model.ItemType = item.ItemType;
            model.ImageUrlSuffix = item.ImageUrlSuffix;
            model.ReportParameters = item.ReportParameters;

            string parent = "root" + item.Path;
            string[] nodes = parent.Split('/');
            int length = nodes.Length;
            int index = 1;
            parent = nodes[0];
            while(index < length-1)
            {
                parent += "/" + nodes[index];
                index ++;
            }
            model.Parent = parent;
            return model;
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Gets the catalog items from the SRS.
        /// </summary>
        public static CatalogModel GetCatalogItems(AuthenticatedUserManager user, ReportingServiceClient srsProxy)
        {
            CatalogModel final = new CatalogModel();
            NCatalogItemCollection catalogs = user.CatalogInteractionManager.LookupCatalogItems(null, true, true, srsProxy);
            List<CatalogModel> models = new List<CatalogModel>();

            foreach (NCatalogItem item in catalogs)
            {
                models.Add(ToModel(item));
            }
            final.AllItems = models;

            //Process Child
            List<CatalogModel> finalCatalog = new List<CatalogModel>();
            foreach (var parent in models)
            {
                parent.AllItems.Add(parent);
                if (parent.ItemType.Equals("Folder", StringComparison.OrdinalIgnoreCase))
                {
                    foreach (var child in models)
                    {
                        //check parents
                        if (child.Parent.Equals(parent.Path, StringComparison.OrdinalIgnoreCase))
                        {
                            parent.Children.Add(child);
                        }
                    }

                    if(parent.Parent.Equals("root", StringComparison.OrdinalIgnoreCase))
                    {
                        finalCatalog.Add(parent);
                    }
                }
            }
            final.Catalogs = finalCatalog;
            final.SRSProxy = srsProxy;
            return final;
        }