Ejemplo n.º 1
0
        public ActionResult GetSupportImage(string name, string ratio)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(APIStatus.NotFound());
            }

            ratio = ratio.Replace(',', '.');
            float.TryParse(ratio, NumberStyles.AllowDecimalPoint,
                           CultureInfo.CreateSpecificCulture("en-EN"), out float newratio);

            name = Path.GetFileNameWithoutExtension(name);
            ResourceManager man = Resources.ResourceManager;

            byte[] dta = (byte[])man.GetObject(name);
            if ((dta == null) || (dta.Length == 0))
            {
                return(APIStatus.NotFound());
            }
            MemoryStream ms = new MemoryStream(dta);

            ms.Seek(0, SeekOrigin.Begin);
            System.Drawing.Image im = System.Drawing.Image.FromStream(ms);

            return(File(ResizeImageToRatio(im, newratio), "image/png"));
        }
Ejemplo n.º 2
0
 public ActionResult <WebUI_Settings> GetWebUIConfig()
 {
     if (!string.IsNullOrEmpty(ServerSettings.Instance.WebUI_Settings))
     {
         try
         {
             return(JsonConvert.DeserializeObject <WebUI_Settings>(ServerSettings.Instance.WebUI_Settings));
         }
         catch
         {
             return(APIStatus.InternalError("error while reading webui settings"));
         }
     }
     else
     {
         return(APIStatus.NotFound());
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Read json file that is converted into string from .config file of jmmserver
 /// </summary>
 /// <returns></returns>
 private object GetWebUIConfig()
 {
     if (!String.IsNullOrEmpty(ServerSettings.WebUI_Settings))
     {
         try
         {
             WebUI_Settings settings =
                 JsonConvert.DeserializeObject <WebUI_Settings>(ServerSettings.WebUI_Settings);
             return(settings);
         }
         catch
         {
             return(APIStatus.InternalError("error while reading webui settings"));
         }
     }
     else
     {
         return(APIStatus.NotFound());
     }
 }
Ejemplo n.º 4
0
        public ActionResult GetSupportImage(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                return(APIStatus.NotFound());
            }
            name = Path.GetFileNameWithoutExtension(name);
            ResourceManager man = Resources.ResourceManager;

            byte[] dta = (byte[])man.GetObject(name);
            if ((dta == null) || (dta.Length == 0))
            {
                return(APIStatus.NotFound());
            }
            MemoryStream ms = new MemoryStream(dta);

            ms.Seek(0, SeekOrigin.Begin);

            return(File(ms, "image/png"));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// return int position - current position
        /// return string[] lines - lines from current log file
        /// </summary>
        /// <param name="lines">max lines to return</param>
        /// <param name="position">position to seek</param>
        /// <returns></returns>
        private object GetLog(int lines, int position)
        {
            string log_file = LogRotator.GetCurrentLogFile();

            if (string.IsNullOrEmpty(log_file))
            {
                return(APIStatus.NotFound("Could not find current log name. Sorry"));
            }

            if (!File.Exists(log_file))
            {
                return(APIStatus.NotFound());
            }

            Dictionary <string, object> result = new Dictionary <string, object>();
            FileStream fs = File.OpenRead(log_file);

            if (position >= fs.Length)
            {
                result.Add("position", fs.Length);
                result.Add("lines", new string[] { });
                return(result);
            }

            List <string> logLines = new List <string>();

            LogReader reader = new LogReader(fs, position);

            for (int i = 0; i < lines; i++)
            {
                string line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }
                logLines.Add(line);
            }
            result.Add("position", reader.Position);
            result.Add("lines", logLines.ToArray());
            return(result);
        }