public ActionResult File(string fileName)
 {
     try
     {
         Stream stream = null;
         if (Request.ContentType.Contains(@"multipart/form-data"))
         {   // IE
             HttpPostedFileBase postedFile = Request.Files[0];
             stream   = postedFile.InputStream;
             fileName = Request.Files[0].FileName;
         }
         else if (Request.ContentType.Contains("application/octet-stream"))
         {   // Webkit, Mozilla
             stream   = Request.InputStream;
             fileName = Request.QueryString["qqfile"];
         }
         else
         {
             throw new Exception("Unsupported ContentType");
         }
         fileName = Path.GetFileName(fileName);
         RenderingSets.SaveFile(fileName, stream);
     }
     catch (System.IO.IOException ex)
     {
         Log.Write(TraceEventType.Stop, "Upload Controller, File | Exception {0}", ex);
         return(Json(new { success = false, message = ex.Message }, "text/html"));
     }
     catch (Exception ex)
     {
         Log.Write(TraceEventType.Stop, "Upload Controller, File | Exception {0}", ex);
         return(Json(new { success = false, message = ex.Message }, "text/html"));
     }
     return(Json(new { success = true }, "text/html"));
 }
Esempio n. 2
0
 public ActionResult RSetsNumber()
 {
     try
     {
         int num = RenderingSets.Count();
         return(Json(new { success = true, count = num }, "application/json"));
     }
     catch (Exception ex)
     {
         Log.Write(TraceEventType.Stop, "Home Controller, RSetNumber | Exception {0}", ex);
         return(Json(new { success = false, message = ex.Message }, "text/json"));
     }
 }
Esempio n. 3
0
 public ActionResult ServerInfo()
 {
     try
     {
         DateTime access = LogEntry.DateFromString(SystemLog.GetLastAccess());
         int      num    = RenderingSets.Count();
         return(Json(new { success = true, access = access.ToString(), rsetnum = num }, "application/json"));
     }
     catch (Exception ex)
     {
         Log.Write(TraceEventType.Stop, "Home Controller, ServerInfo | Exception {0}", ex);
         return(Json(new { success = false, message = ex.Message }, "text/json"));
     }
 }
Esempio n. 4
0
        public ActionResult Load()
        {
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            try
            {
                List <string> dd = RenderingSets.GetList();

                return(Json(new { success = true, data = serializer.Serialize(dd.ToArray()) }, "json/application"));
            }
            catch (Exception ex)
            {
                Log.Write(TraceEventType.Stop, "Rendering Set Controller, Load | Exception {0}", ex);
                return(Json(new { success = false, message = ex.Message }, "json/application"));
            }
        }
 public ActionResult Delete(string fileName)
 {
     if (!string.IsNullOrEmpty(fileName))
     {
         try
         {
             RenderingSets.DeleteFile(fileName);
             return(Json(new { success = true, message = "" }, "application/json"));
         }
         catch (Exception ex)
         {
             Log.Write(TraceEventType.Stop, "Upload Controller, Delete | Exception {0}", ex);
             return(Json(new { success = false, message = ex.Message }, "application/json"));
         }
     }
     return(Json(new { success = false, message = "Arguments error" }, "application/json"));
 }
Esempio n. 6
0
        public IEnumerable <SelectListItem> GetRenderingSets(HttpRequest request)
        {
            List <SelectListItem> list = new List <SelectListItem>();

            try
            {
                foreach (string file in RenderingSets.GetList())
                {
                    list.Add(new SelectListItem()
                    {
                        Text = Path.GetFileNameWithoutExtension(file), Value = file
                    });
                }
            }
            catch (Exception)
            {
                list.Add(new SelectListItem()
                {
                    Text = "No rendering Set", Value = ""
                });
            }
            return(list);
        }