コード例 #1
0
        public static AsScanned CheckImage(string imagePath)
        {
            AsScanned scan = new AsScanned();

            scan.Image = imagePath;

            double  filelen = new FileInfo(imagePath).Length;
            string  f_size  = " (" + AppCore.GetFileSize(filelen) + ")";
            Process process = CreateProcess("/C \"arcoreimg.exe eval-img --input_image_path=" + imagePath);

            process.Start();

            try
            {
                string result = process.StandardOutput.ReadToEnd();
                process.WaitForExit();
                int score = int.Parse(result);
                scan.Score = score;


                if (score < 49)
                {
                    scan.Title = Path.GetFileName(imagePath) + f_size + " | Poor Quality Image";
                }

                else if (score > 50 && score < 89)
                {
                    scan.Title = Path.GetFileName(imagePath) + f_size + " | Good Quality Image";
                }

                else if (score > 90)
                {
                    scan.Title = Path.GetFileName(imagePath) + f_size + " | Best Quality Image";
                }
            }
            catch (Exception)
            {
                //arcoreimg.WriteLogs("App Errors", @" " + ex.Message, @"" + ex.InnerException, @"" + ex.StackTrace);
            }
            return(scan);
        }
コード例 #2
0
        public static void WriteLogs(string source, string message, string innerexception, string stacktrace)
        {
            string FileLog = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AppCore.Todate() + "-logs.log");

            using (StreamWriter sw = new StreamWriter(FileLog, true))
            {
                sw.WriteLine("maarcilog>");
                sw.WriteLine("    <time>" + JustNow() + "</time>");
                sw.WriteLine("    <source>" + source + "</source>");
                sw.WriteLine("    <message>" + message + "</message>");
                if (innerexception.Length > 0)
                {
                    sw.WriteLine("    <innerexception>" + innerexception + "</innerexception>");
                }
                if (stacktrace.Length > 0)
                {
                    sw.WriteLine("    <stacktrace>" + stacktrace + "</stacktrace>");
                }
                sw.WriteLine("</maarcilog>");
                sw.WriteLine("");
                sw.Dispose();
            }
        }