diff --git a/web/documentserver-example/csharp/Default.aspx.cs b/web/documentserver-example/csharp/Default.aspx.cs index b5aa4bf1..725b582c 100644 --- a/web/documentserver-example/csharp/Default.aspx.cs +++ b/web/documentserver-example/csharp/Default.aspx.cs @@ -383,22 +383,22 @@ namespace OnlineEditorsExample return storedFiles; } - public static List> GetFilesInfo(string idFile = null) + public static List> GetFilesInfo(string fileId = null) { - var files = new List>(); + var files = new List>(); foreach (var file in GetStoredFiles()) { - var dictionary = new Dictionary(); - dictionary.Add("version", GetFileVersion(file.Name, null).ToString()); + var dictionary = new Dictionary(); + dictionary.Add("version", GetFileVersion(file.Name, null)); dictionary.Add("id", ServiceConverter.GenerateRevisionId(_Default.CurUserHostAddress(null) + "/" + file.Name + "/" + File.GetLastWriteTime(_Default.StoragePath(file.Name, null)).GetHashCode())); dictionary.Add("contentLength", Math.Round(file.Length / 1024.0, 2) + " KB"); - dictionary.Add("pureContentLength", file.Length.ToString()); + dictionary.Add("pureContentLength", file.Length); dictionary.Add("title", file.Name); dictionary.Add("updated", file.LastWriteTime.ToString()); - if (idFile != null) + if (fileId != null) { - if (idFile.Equals(dictionary["id"])) + if (fileId.Equals(dictionary["id"])) { files.Add(dictionary); break; diff --git a/web/documentserver-example/csharp/WebEditor.ashx.cs b/web/documentserver-example/csharp/WebEditor.ashx.cs index f088da20..f2eb2561 100644 --- a/web/documentserver-example/csharp/WebEditor.ashx.cs +++ b/web/documentserver-example/csharp/WebEditor.ashx.cs @@ -240,23 +240,31 @@ namespace OnlineEditorsExample private static void Files(HttpContext context) { - List> files = null; + List> files = null; try { - var idFile = context.Request["id"]; - if (idFile == null) + context.Response.ContentType = "application/json"; + var jss = new JavaScriptSerializer(); + + if (context.Request["fileId"] == null) { files = _Default.GetFilesInfo(); + context.Response.Write(jss.Serialize(files)); } else { - files = _Default.GetFilesInfo(idFile); + var fileId = context.Request["fileId"]; + files = _Default.GetFilesInfo(fileId); + if (files.Count == 0) + { + context.Response.Write("\"File not found\""); + } + else + { + context.Response.Write(jss.Serialize(files)); + } } - - context.Response.ContentType = "application/json"; - var jss = new JavaScriptSerializer(); - context.Response.Write(jss.Serialize(files)); } catch (Exception e) {