private static void Try(string type) { string ext; switch (type) { case "document": ext = ".docx"; break; case "spreadsheet": ext = ".xlsx"; break; case "presentation": ext = ".pptx"; break; default: return; } var demoName = "demo" + ext; FileName = EditDefault.GetCorrectName(demoName); File.Copy(HttpRuntime.AppDomainAppPath + "app_data/" + demoName, EditDefault.StoragePath + FileName); }
private static void Upload(HttpContext context) { context.Response.ContentType = "text/plain"; try { context.Response.Write("{ \"filename\": \"" + EditDefault.DoUpload(context) + "\"}"); } catch (Exception e) { context.Response.Write("{ \"error\": \"" + e.Message + "\"}"); } }
private static void Convert(HttpContext context) { context.Response.ContentType = "text/plain"; try { context.Response.Write(EditDefault.DoConvert(context)); } catch (Exception e) { context.Response.Write("{ \"error\": \"" + e.Message + "\"}"); } }
protected void Page_Load(object sender, EventArgs e) { var externalUrl = Request["fileUrl"]; if (!string.IsNullOrEmpty(externalUrl)) { FileName = EditDefault.DoUpload(externalUrl); } else { FileName = Request["fileID"]; } var type = Request["type"]; if (!string.IsNullOrEmpty(type)) { Try(type); Response.Redirect("doceditor.aspx?fileID=" + HttpUtility.UrlEncode(FileName)); } }
private static void Get(HttpContext context) { context.Response.ContentType = "text/plain"; var fileName = context.Request["fileName"]; if (string.IsNullOrEmpty(fileName)) { context.Response.Write("error"); return; } try { var fileUri = EditDefault.FileUri(fileName); var key = ServiceConverter.GenerateRevisionId(EditDefault.CurUserHostAddress + "/" + Path.GetFileName(fileUri)); var validateKey = ServiceConverter.GenerateValidateKey(key); context.Response.Write(String.Format("{{ \"fileUri\": \"{0}\", \"key\": \"{1}\", \"validateKey\": \"{2}\" }}", fileUri, key, validateKey)); } catch (Exception e) { context.Response.Write("{ \"error\": \"" + e.Message + "\"}"); } }