public ActionResult Hub()
        {
            ViewBag.PageType = "Hub";

            string ambitoNode = Request["AmbitoList"];

            if (string.IsNullOrEmpty(ambitoNode) || !ambitoNode.Contains("|"))
            {
                return(RedirectToAction("Index"));
            }
            int ambitoId = Convert.ToInt32(ambitoNode.Split('|')[0]);
            int nodeId   = Convert.ToInt32(ambitoNode.Split('|')[1]);
            var node     = AmbitiUtility.GetAmbitoNode(ambitoId, nodeId);
            var ambito   = AmbitiUtility.GetAmbitoById(new List <string>()
            {
                ambitoId.ToString()
            });

            SetCookie("AmbitoId", ambitoNode.Split('|')[0]);
            SetCookie("NodeId", ambitoNode.Split('|')[1]);
            SetCookie("AmbitoName", ambito.FirstOrDefault().Name + " - " + node.Name);
            SetCookie("UrlWebTicket", node.UrlWebTicket);
            ViewBag.AmbitoName   = GetCookie("AmbitoName");
            ViewBag.Server       = node.Server;
            ViewBag.VirtualProxy = node.VirtualProxy;
            ViewBag.UserIdentity = GetCookie("UserIdentity");
            return(View());
        }
Exemple #2
0
        public ActionResult ToPublish(string AppId, string AppName, string AppOldName, string OverwriteRequired, string StreamID, string StreamName, string AppToOverwriteId, string checkOverwrite, string AmbitoList)
        {
            string path   = Server.MapPath("~/cert/client.pfx");
            var    ambito = AmbitiUtility.GetAmbitoById(GetCookie("AmbitoId"));

            if (OverwriteRequired.ToLower() == "false")
            {
                // Duplico l'app
                QRSSenseApp newApp       = new QRSSenseApp();
                string      errorMessage = "";
                QRSQlikAPI  QRSqlikAPI   = new QRSQlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Server, path);
                QRSqlikAPI.CopyApp(GetCookie("UserID"), GetCookie("UserDirectory"), AppId, AppOldName, out newApp, out errorMessage);

                // Pubblico l'app
                QlikAPI qlikAPI = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Link, ambito.superuserid, ambito.superuserdom, path);
                qlikAPI.PublishApp(AppId, AppName, StreamID);
            }
            else
            {
                string  errorMessage = "";
                QlikAPI qlikAPI      = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Link, ambito.superuserid, ambito.superuserdom, path);
                qlikAPI.ReplaceApp(AppId, AppToOverwriteId);
            }

            return(RedirectToAction("Hub", "Home", new { AmbitoList = AmbitoList }));
        }
Exemple #3
0
        // GET: Publish
        public ActionResult Index()
        {
            ViewBag.PageType = "InternalAction";

            ViewBag.AmbitoName   = GetCookie("AmbitoName");
            ViewBag.UserIdentity = GetCookie("UserIdentity");
            ViewBag.AmbitoList   = GetCookie("AmbitoId") + "|" + GetCookie("NodeId");

            string path = Server.MapPath("~/cert/client.pfx");

            ReportViewModel    model = new ReportViewModel();
            List <SenseStream> myStreams;

            QRSQlikAPI QRSqlikAPI = new QRSQlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Server, path);
            List <SenseApplication> notPublishedApps = new List <SenseApplication>();
            string errorMessage = "";

            ViewBag.Error = "";
            var ambito = AmbitiUtility.GetAmbitoById(GetCookie("AmbitoId"));

            if (QRSqlikAPI.GetStreamsByCustomProperty(GetCookie("UserID"), GetCookie("UserDirectory"), "StreamType", "Self-Service", ambito.customproperty, out myStreams, out errorMessage))
            {
                model = ReportViewModel.CreateReportViewModel(notPublishedApps, myStreams);
            }
            else
            {
                ViewBag.Error = "Errore nel reperimento degli streams. " + errorMessage;
            }
            if (string.IsNullOrEmpty(ViewBag.Error) && (myStreams == null || myStreams.Count == 0))
            {
                ViewBag.Error = "Non sei abilitato a nessuno stream dell'ambito Report Self-Service BI su cui distribuire il report.";
            }
            return(View(model));
        }
Exemple #4
0
        public ActionResult ToShare(string AppId, string AppName, string OverwriteRequired, string StreamID, string StreamName, string AppToOverwriteId, string checkOverwrite, string AmbitoList)
        {
            string path = Server.MapPath("~/cert/client.pfx");

            // Prendo il nodo dei Report Distribuiti
            var ambito    = AmbitiUtility.GetAmbitoById(GetCookie("AmbitoId"));
            var distrNode = (from f in ambito.Nodes where f.NodeType == "D" select f).FirstOrDefault();
            //

            // Duplico l'app
            QRSSenseApp newApp       = new QRSSenseApp();
            string      errorMessage = "";
            QRSQlikAPI  QRSqlikAPI   = new QRSQlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Server, path);

            QRSqlikAPI.CopyApp(GetCookie("UserID"), GetCookie("UserDirectory"), AppId, AppName, out newApp, out errorMessage);
            bool publishResult = true;

            if (OverwriteRequired.ToLower() == "false")
            {
                // Pubblico l'app
                QlikAPI qlikAPI = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Link, ambito.superuserid, ambito.superuserdom, path);
                publishResult = qlikAPI.PublishApp(newApp.id, AppName, StreamID, out errorMessage);
            }
            else
            {
                // Rimpiazzo l'app
                QlikAPI qlikAPI = new QlikAPI(ambito.centralnode, ambito.superuserid, ambito.superuserdom, path);
                publishResult = qlikAPI.ReplaceApp(newApp.id, AppToOverwriteId, out errorMessage);

                qlikAPI.DeleteApp(newApp.id);
            }

            return(RedirectToAction("Hub", "Home", new { AmbitoList = AmbitoList }));
        }
Exemple #5
0
        public ActionResult GetReportsGrid(string idStream, string desStream)
        {
            ViewBag.idStream  = idStream;
            ViewBag.desStream = desStream;

            string          path  = Server.MapPath("~/cert/client.pfx");
            ReportViewModel model = new ReportViewModel();

            List <SenseApplication> publishedApps;
            List <SenseStream>      streams = new List <SenseStream>();

            string errorMessage = "";

            // Prendo gli stream di self-service e creo una lista
            QRSQlikAPI QRSqlikAPIMaster = new QRSQlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Server, path);

            var ambito = AmbitiUtility.GetAmbitoById(GetCookie("AmbitoId"));

            QRSqlikAPIMaster.GetStreamsByCustomProperty(GetCookie("UserID"), GetCookie("UserDirectory"), "StreamType", "Self-Service", ambito.customproperty, out streams, out errorMessage);
            List <string> streamIdList = new List <string>();

            if (streams != null)
            {
                streamIdList = (from s in streams select s.Id).ToList();
            }
            //

            // Prendo le app pubblicate in self-service controllando che siano nella lista creata prima
            QlikAPI qlikAPIMaster = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Link, GetCookie("UserID"), GetCookie("UserDirectory"), path);

            if (qlikAPIMaster.GetPublishedAppsInSelectedStreams(streamIdList, out publishedApps))
            {
                foreach (var app in publishedApps)
                {
                    errorMessage = "";
                    QRSSenseAppDetail appDetail = new QRSSenseAppDetail();
                    //if (QRSqlikAPIMaster.GetAppDetail(ConfigurationManager.AppSettings["QlikUser"], ConfigurationManager.AppSettings["QlikUserDirectory"], app.AppId, out appDetail, out errorMessage))
                    if (QRSqlikAPIMaster.GetAppDetail(GetCookie("UserID"), GetCookie("UserDirectory"), app.AppId, out appDetail, out errorMessage))
                    {
                        app.OwnerUserName = appDetail.owner.name;
                    }
                }
                model = ReportViewModel.CreateReportViewModel(publishedApps, streams);
            }
            return(PartialView("ReportsGrid", model));
        }
Exemple #6
0
        public ActionResult Detail(string AppName, string AppId, string StreamId, string AmbitoList, string StreamName, string dummy)
        {
            AppToPublishViewModel model = new AppToPublishViewModel();

            model.AppId      = AppId;
            model.AppName    = AppName;
            model.StreamName = StreamName;
            model.StreamID   = StreamId;

            ViewBag.AmbitoList = AmbitoList;

            string path = Server.MapPath("~/cert/client.pfx");

            QRSSenseAppDetail detail = new QRSSenseAppDetail();
            QRSSenseApp       newApp = new QRSSenseApp();

            // Prendo il nodo dei Report Distribuiti
            var ambito = AmbitiUtility.GetAmbitoById(new List <string>()
            {
                GetCookie("AmbitoId")
            }).FirstOrDefault();
            var distrNode = (from f in ambito.Nodes where f.NodeType == "D" select f).FirstOrDefault();
            //

            // Prendo le app pubblicate nel nodo dei Report Distribuiti
            List <SenseApplication> publishedApps;
            QlikAPI qlikAPIMaster = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), distrNode.Id.ToString()).Link, GetCookie("UserID"), GetCookie("UserDirectory"), path);

            qlikAPIMaster.GetPublishedApps(out publishedApps);

            model.OverwriteRequired = false;
            // Controllo se c'è già un'app nello stream che si chiama così
            foreach (var publishedApp in publishedApps)
            {
                if (publishedApp.StreamID == StreamId && publishedApp.Name == AppName)
                {
                    model.OverwriteRequired = true;
                    model.AppToOverwriteId  = publishedApp.AppId;
                }
            }

            return(View("ToShare", model));
        }
Exemple #7
0
        // GET: CreateReport
        public ActionResult CreateReport()
        {
            ViewBag.PageType = "InternalAction";

            ViewBag.AmbitoName   = GetCookie("AmbitoName");
            ViewBag.UserIdentity = GetCookie("UserIdentity");
            ViewBag.AmbitoList   = GetCookie("AmbitoId") + "|" + GetCookie("NodeId");

            CreateReport model = new CreateReport()
            {
                Name = "", Description = ""
            };

            model.TemplateItems = new List <ReportTemplate>();
            string             path       = Server.MapPath("~/cert/client.pfx");
            var                ambito     = AmbitiUtility.GetAmbitoById(GetCookie("AmbitoId"));
            QRSQlikAPI         qrsQlikApi = new QRSQlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Server, path);
            List <SenseStream> myStreams;
            string             errorMessage = "";

            qrsQlikApi.GetStreamsByCustomProperty(GetCookie("UserID"), GetCookie("UserDirectory"), "StreamType", "Template", ambito.customproperty, out myStreams, out errorMessage);
            if (myStreams != null && myStreams.Count > 0)
            {
                QlikAPI qlikApi = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Link, ambito.superuserid, ambito.superuserdom, path);
                List <SenseApplication> apps = new List <SenseApplication>();
                if (qlikApi.GetPublishedAppsInSelectedStreams(myStreams.Select(s => s.Id).ToList(), out apps))
                {
                    if (apps != null && apps.Count > 0)
                    {
                        foreach (var app in apps)
                        {
                            model.TemplateItems.Add(new ReportTemplate()
                            {
                                TemplateStreamID = app.StreamID, TemplateID = app.AppId, TemplateDescription = app.Name
                            });
                        }
                    }
                }
            }
            return(View(model));
        }
Exemple #8
0
        // GET: Share
        public ActionResult Index()
        {
            ViewBag.PageType = "InternalAction";

            ViewBag.AmbitoName   = GetCookie("AmbitoName");
            ViewBag.UserIdentity = GetCookie("UserIdentity");
            ViewBag.AmbitoList   = GetCookie("AmbitoId") + "|" + GetCookie("NodeId");

            string          path  = Server.MapPath("~/cert/client.pfx");
            ReportViewModel model = new ReportViewModel();

            // Prendo il nodo dei Report Distribuiti
            var ambito = AmbitiUtility.GetAmbitoById(new List <string>()
            {
                GetCookie("AmbitoId")
            }).FirstOrDefault();
            var distrNode = (from f in ambito.Nodes where f.NodeType == "D" select f).FirstOrDefault();
            //

            // Prendo tutti gli stream del nodo dei report distribuiti
            QRSQlikAPI QRSqlikAPIMaster           = new QRSQlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), distrNode.Id.ToString()).Server, path);
            List <SenseApplication> publishedApps = new List <SenseApplication>();
            List <SenseStream>      streams;
            string errorMessage = "";

            //if (QRSqlikAPIMaster.GetStreamsBuCustomProperty(ConfigurationManager.AppSettings["QlikUser"], ConfigurationManager.AppSettings["QlikUserDirectory"], "StreamType", "Production", out streams, out errorMessage))
            if (QRSqlikAPIMaster.GetStreamsByCustomProperty(GetCookie("UserID"), GetCookie("UserDirectory"), "StreamType", "Production", ambito.customproperty, out streams, out errorMessage))
            {
                model = ReportViewModel.CreateReportViewModel(publishedApps, streams);
            }
            else
            {
                ViewBag.Error = "Errore nel reperimento degli stream di distribuzione." + errorMessage;
            }
            if (string.IsNullOrEmpty(ViewBag.Error) && (streams == null || streams.Count == 0))
            {
                ViewBag.Error = "Non sei abilitato a nessuno stream dell'ambito Report Distribuiti su cui distribuire il report.";
            }
            return(View(model));
        }
        public ActionResult OpenFrame(string server, string vp)
        {
            string UserID        = GetCookie("UserID");
            string UserDirectory = GetCookie("UserDirectory");
            string UrlWebTicket  = GetCookie("UrlWebTicket");
            var    ambito        = AmbitiUtility.GetAmbitoById(GetCookie("AmbitoId"));

            SetCookie("Server", server);
            SetCookie("VirtualProxy", vp);
            try
            {
                QSession qSession = new QSession("POST", server, vp, UserID, UserDirectory, UrlWebTicket, ambito.customproperty);
                qSession.OpenSession(HttpContext.ApplicationInstance.Context);
                Request.Cookies.Add(qSession.GetCookie(server, true));
                Response.Cookies.Add(qSession.GetCookie(server, true));
                return(Redirect(qSession.GetHubURL()));
            }
            catch (Exception ex)
            {
                throw new Exception(string.Format("{0} - {1}", UserID, UserDirectory), ex);
            }
        }