public bool CopyApp(string userID, string userDirectory, string appID, string appDestName, out QRSSenseApp app, out string errorMessage)
        {
            app          = new QRSSenseApp();
            errorMessage = "";
            try
            {
                RestClient client = conn.CreateRestClientPost("app/" + appID + "/copy?name=" + appDestName, userID, userDirectory, out restRequest);

                var response = client.Execute <QRSSenseApp>(restRequest);

                if (response.IsSuccessful)
                {
                    app = response.Data;
                }
                else
                {
                    errorMessage = response.ErrorMessage;
                }

                return(response.IsSuccessful);
            }
            catch (Exception ex)
            {
                errorMessage = ex.Message;
                while (ex.InnerException != null)
                {
                    ex            = ex.InnerException;
                    errorMessage += " -> " + ex.Message;
                }
                return(false);
            }
        }
示例#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 }));
        }
示例#3
0
        public ActionResult CreateReport(string Name, string Description, string AmbitoList, string SelectedTemplate)
        {
            ViewBag.PageType = "InternalAction";

            string appId = "";

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

            if (string.IsNullOrEmpty(SelectedTemplate) || SelectedTemplate == "void")
            {
                QlikAPI qlikAPI = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Link, GetCookie("UserID"), GetCookie("UserDirectory"), path);
                qlikAPI.CreateApp(Name, Description, out appId);
            }
            else
            {
                // 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"), SelectedTemplate, Name, out newApp, out errorMessage);
                QlikAPI qlikAPI = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).Link, GetCookie("UserID"), GetCookie("UserDirectory"), path);
                qlikAPI.RenameApp(newApp.id, Description);
            }
            return(RedirectToAction("Hub", "Home", new { AmbitoList = AmbitoList }));
        }
示例#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 }));
        }
示例#5
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));
        }
示例#6
0
        public ActionResult Detail(string AppName, string AppId, string StreamId, string AmbitoList, string StreamName, string AppOldName, string dummy)
        {
            AppToPublishViewModel model = new AppToPublishViewModel();

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

            ViewBag.AmbitoList = AmbitoList;

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

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

            // Prendo la lista delle app pubblicate
            List <SenseApplication> publishedApps;
            QlikAPI qlikAPIMaster = new QlikAPI(AmbitiUtility.GetAmbitoNode(GetCookie("AmbitoId"), GetCookie("NodeId")).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("ToPublish", model));
        }