public void TestTest()
        {
            WopiAppHelper linkHelper   = new WopiAppHelper("Discovery.xml");
            var           wopiHostLink = "http://wopi2.com/api/wopi/files/test.docx";

            linkHelper.GetDocumentLink(wopiHostLink);
        }
        public void Generate_Word_Zone()
        {
            WopiAppHelper linkHelper = new WopiAppHelper("Discovery.xml");

            var obj = linkHelper.GetZone("Word");

            Assert.IsNotNull(obj);
        }
        public void TestTest()
        {
            _mockConfiguration.SetupGet(r => r["appHmacKey"]).Returns("XFrJrnwjShiyXFuKjqlD/yTfXkUHEOGn/TUmUyiZwaPqFMiyx1nkieNDkMwhRux/VPu16oPuDyg03EHKttLsgA==");
            WopiAppHelper linkHelper   = new WopiAppHelper("Discovery.xml", true, _mockConfiguration.Object);
            var           wopiHostLink = "http://wopi2.com/api/wopi/files/test.docx";

            linkHelper.GetDocumentLink(wopiHostLink);
        }
        public void Generate_Word_Zone()
        {
            //_mockConfiguration.Setup(x => x)
            WopiAppHelper linkHelper = new WopiAppHelper("Discovery.xml", true, _mockConfiguration.Object);

            var obj = linkHelper.GetZone("Word");

            Assert.IsNotNull(obj);
        }
        public void Get_ExcelX_Doc_Link()
        {
            WopiAppHelper linkHelper = new WopiAppHelper("Discovery.xml", false, _mockConfiguration.Object);

            var wopiHostLink = "http://wopi2.com/api/wopi/files/test.xlsx";

            var obj = linkHelper.GetDocumentLink("Excel", "xlsx", wopiHostLink, "tbd");

            Assert.IsNotNull(obj);
        }
        public void Get_Excel_Doc_Link()
        {
            WopiAppHelper linkHelper = new WopiAppHelper("Discovery.xml");

            var wopiHostLink = "http://wopi2.com/api/wopi/files/test.xls";

            var obj = linkHelper.GetDocumentLink("Excel", "xls", wopiHostLink, "tbd");

            Assert.IsNotNull(obj);
        }
        public void Get_Word_Doc_Link()
        {
            _mockConfiguration.SetupGet(r => r["appHmacKey"]).Returns("XFrJrnwjShiyXFuKjqlD/yTfXkUHEOGn/TUmUyiZwaPqFMiyx1nkieNDkMwhRux/VPu16oPuDyg03EHKttLsgA==");
            WopiAppHelper linkHelper = new WopiAppHelper("Discovery.xml", true, _mockConfiguration.Object);

            var wopiHostLink = "http://wopi2.com/api/wopi/files/test.docx";

            var obj = linkHelper.GetDocumentLink("Word", "docx", wopiHostLink, "tbd");

            Assert.IsNotNull(obj);
        }
Example #8
0
        /// <summary>
        /// Provides a link that can be used to Open a document in the relative viewer
        /// from the Office Web Apps server
        /// </summary>
        /// <param name="fileRequest">indicates the request type</param>
        /// <returns>A link usable for HREF</returns>
        public Link GetLink(string name)
        {
            WopiAppHelper wopiHelper = new WopiAppHelper(HostingEnvironment.MapPath(Constant.appDiscoveryXml));

            var result = wopiHelper.GetDocumentLink(Constant.appWopiServer + name);

            var rv = new Link
            {
                Url = result
            };

            return(rv);
        }
Example #9
0
        //
        // GET: /Link/


        public ActionResult GetLink(FileRequest fileRequest)
        {
            if (ModelState.IsValid)
            {
                WopiAppHelper wopiHelper = new WopiAppHelper(HostingEnvironment.MapPath(Constant.appDiscoveryXml));

                var result = wopiHelper.GetDocumentLink(fileRequest.name);

                var rv = new Link
                {
                    Url = result
                };
                return(Json(rv, JsonRequestBehavior.AllowGet));
            }

            throw new ApplicationException("Invalid ModelState");
        }
Example #10
0
        /// <summary>
        /// Provides a link that can be used to Open a document in the relative viewer
        /// from the Office Web Apps server
        /// </summary>
        /// <param name="fileRequest">indicates the request type</param>
        /// <returns>A link usable for HREF</returns>
        public Link GetLink([FromUri] FileRequest fileRequest)
        {
            if (ModelState.IsValid)
            {
                WopiAppHelper wopiHelper = new WopiAppHelper(HostingEnvironment.MapPath(Constant.appDiscoveryXml));

                var result = wopiHelper.GetDocumentLink(Constant.appWopiServer + fileRequest.name);

                var rv = new Link
                {
                    Url = result
                };
                return(rv);
            }

            throw new ApplicationException("Invalid ModelState");
        }
Example #11
0
        List <Link> BuildLinks(List <Link> files)
        {
            WopiAppHelper wopiHelper = new WopiAppHelper(HostingEnvironment.MapPath(Constant.appDiscoveryXml));

            foreach (Link link in files)
            {
                try
                {
                    var tlink = wopiHelper.GetDocumentLink(Constant.appWopiServer + link.FileName);
                    link.Url = tlink;
                }
                catch (ArgumentException ex)
                {
                    link.Url = "bad file ext: " + ex.Message;
                }
            }

            return(files);
        }
        public async Task <Link> GetLink([FromUri] FileRequest fileRequest)
        {
            if (ModelState.IsValid)
            {
                var wopiServer    = WebConfigurationManager.AppSettings["appWopiServer"];
                var updateEnabled = false;
                bool.TryParse(WebConfigurationManager.AppSettings["updateEnabled"], out updateEnabled);
                var wopiHelper = new WopiAppHelper(await Getxml(), updateEnabled);

                var result = wopiHelper.GetDocumentLink(wopiServer, fileRequest.name, AppUserState.UserName,
                                                        AppUserState.Wgs, AppUserState.Ds);

                var rv = new Link
                {
                    Url = result
                };
                return(rv);
            }

            throw new ApplicationException("Invalid ModelState");
        }
        List <Link> BuildLinks(List <Link> files)
        {
            var           xml        = WebConfigurationManager.AppSettings["appDiscoveryXml"];
            var           wopiServer = WebConfigurationManager.AppSettings["appWopiServer"];
            WopiAppHelper wopiHelper = new WopiAppHelper(HostingEnvironment.MapPath(xml));

            foreach (Link link in files)
            {
                try
                {
                    var tlink = wopiHelper.GetDocumentLink(wopiServer + link.FileName);
                    link.Url = tlink;
                }
                catch (ArgumentException ex)
                {
                    link.Url = "bad file ext: " + ex.Message;
                }
            }

            return(files);
        }
      public async Task <string> GetLinkEdit([FromUri] FileRequest fileRequest)
      {
          if (ModelState.IsValid)
          {
              var wopiServer    = WebConfigurationManager.AppSettings["appWopiServer"];
              var updateEnabled = true;
              var wopiHelper    = new WopiAppHelper(await Getxml(), true);

              var result = wopiHelper.GetDocumentLink(wopiServer, fileRequest.name, AppUserState.UserName,
                                                      AppUserState.Wgs, AppUserState.Ds);

              var rv = new Link
              {
                  Url = result
              };
              return(result);
              // return "\\asppages\\Editor.aspx";
          }

          throw new ApplicationException("Invalid ModelState");
      }
Example #15
0
        /// <summary>
        /// Provides a link that can be used to Open a document in the relative viewer
        /// from the Office Web Apps server
        /// </summary>
        /// <param name="fileRequest">indicates the request type</param>
        /// <returns>A link usable for HREF</returns>
        public Link GetLink([FromUri] FileRequest fileRequest)
        {
            if (ModelState.IsValid)
            {
                var  xml           = WebConfigurationManager.AppSettings["appDiscoveryXml"];
                var  wopiServer    = WebConfigurationManager.AppSettings["appWopiServer"];
                bool updateEnabled = false;
                bool.TryParse(WebConfigurationManager.AppSettings["updateEnabled"], out updateEnabled);
                WopiAppHelper wopiHelper = new WopiAppHelper(HostingEnvironment.MapPath(xml), updateEnabled);

                var result = wopiHelper.GetDocumentLink(wopiServer + fileRequest.name);

                var rv = new Link
                {
                    Url = result
                };
                return(rv);
            }

            throw new ApplicationException("Invalid ModelState");
        }
      public async Task <string> GetLinkView([FromUri] FileRequest fileRequest)
      {
          Logger.Info($"Get File Info called for file name {fileRequest.name}");
          if (ModelState.IsValid)
          {
              var wopiServer = WebConfigurationManager.AppSettings["appWopiServer"];
              Logger.Info($"WOPI server is  {wopiServer}");
              var updateEnabled = false;
              var wopiHelper    = new WopiAppHelper(await Getxml(), false);

              var result = wopiHelper.GetDocumentLink(wopiServer, fileRequest.name, AppUserState.UserName,
                                                      AppUserState.Wgs, AppUserState.Ds);
              Logger.Info($"Result is {wopiServer}");
              var rv = new Link
              {
                  Url = result
              };
              return(result);
          }

          throw new ApplicationException("Invalid ModelState");
      }
Example #17
0
        public Link GetLink([FromQuery] FileRequest fileRequest)
        {
            if (ModelState.IsValid)
            {
                var  xml           = _configuration["appDiscoveryXml"];
                var  wopiServer    = _configuration["appWopiServer"];
                bool updateEnabled = false;
                bool.TryParse(_configuration["updateEnabled"], out updateEnabled);
                var           appDataPath = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
                WopiAppHelper wopiHelper  = new WopiAppHelper(System.IO.Path.Combine(appDataPath, xml), updateEnabled, _configuration);

                var result = wopiHelper.GetDocumentLink(wopiServer + fileRequest.name);

                var rv = new Link
                {
                    Url = result
                };
                return(rv);
            }

            throw new ApplicationException("Invalid ModelState");
        }
Example #18
0
        List <Link> BuildLinks(List <Link> files)
        {
            var           appDataPath = AppDomain.CurrentDomain.GetData("DataDirectory").ToString();
            var           xml         = _configuration["appDiscoveryXml"];
            var           wopiServer  = _configuration["appWopiServer"];
            WopiAppHelper wopiHelper  = new WopiAppHelper(Path.Combine(appDataPath, xml));

            foreach (Link link in files)
            {
                try
                {
                    var tlink = wopiHelper.GetDocumentLink(wopiServer + link.FileName);
                    link.Url = tlink;
                }
                catch (ArgumentException ex)
                {
                    link.Url = "bad file ext: " + ex.Message;
                }
            }

            return(files);
        }