Esempio n. 1
0
        /// <summary>
        /// GET: WopiFrame
        /// </summary>
        /// <param name="id">File name</param>
        /// <returns>A ViewResult object</returns>
        public ActionResult Index(string id)
        {
            string sourceDoc = id.ToLower();
            string uid       = ConfigurationManager.AppSettings["BrowserUserName"].ToLower();

            string access_token = AccessTokenUtil.WriteToken(AccessTokenUtil.GenerateToken(uid, sourceDoc));

            List <WopiAction> actions   = DiscoveryUtil.GetDiscoveryInfo();
            string            extention = sourceDoc.Split('.')[sourceDoc.Split('.').Length - 1];
            WopiAction        action    = actions.FirstOrDefault(i => i.ext == extention && i.name == "view");
            string            urlSrc    = action.urlsrc;

            urlSrc = string.Format("{0}WOPISrc={1}",
                                   urlSrc.Substring(0, urlSrc.IndexOf('<')),
                                   HttpUtility.UrlEncode(string.Format("http://{0}/wopi/files/{1}",
                                                                       ConfigurationManager.AppSettings["WOPIServerName"],
                                                                       HttpUtility.UrlEncode(sourceDoc))));

            urlSrc = urlSrc.ToLower().Replace(ConfigurationManager.AppSettings["OfficeServerName"].ToLower().Trim(), ConfigurationManager.AppSettings["OfficeServerIP"]);

            urlSrc = string.Format("{0}&access_token={1}", urlSrc, HttpUtility.UrlEncode(access_token));

            ViewData["URL"] = urlSrc;

            return(View());
        }
Esempio n. 2
0
        // GET: WopiValidator
        public ActionResult Index(string id)
        {
            WopiValidator wvModel = new WopiValidator();

            wvModel.FileName = id;
            string sourceDoc = id.ToLower();
            string uid       = "TestUser".ToLower();

            wvModel.AccessToken = AccessTokenUtil.WriteToken(AccessTokenUtil.GenerateToken(uid, sourceDoc));
            wvModel.HostURL     = string.Format("http://{0}/wopi/files/{1}",
                                                ConfigurationManager.AppSettings["WOPIServerName"],
                                                HttpUtility.UrlEncode(sourceDoc));
            return(View(wvModel));
        }