Пример #1
0
        public Dictionary <string, object> GetNameValueList(string Categorys)
        {
            CheckParameter.NotEmpty(Categorys, "GetNameValueList 中的Categorys值为空");
            Dictionary <string, object> dic = new Dictionary <string, object>();

            string[] CategoryArray = Categorys.Split(',');
            foreach (string item in CategoryArray)
            {
                dic.Add(item, GetNameValue(item));
            }
            return(dic);
        }
Пример #2
0
        public List <string> GetNameValue(string Category)
        {
            CheckParameter.NotEmpty(Category, "GetNameValue 中的Category值为空");
            List <string> ValueList = new List <string>();

            var NameValueList = nameValuePairsRepository.GetNameValuePairs(Category);

            if (NameValueList != null)
            {
                foreach (var item in NameValueList)
                {
                    ValueList.Add(item.Value);
                }
            }
            return(ValueList);
        }
Пример #3
0
        static void Main(string[] args)
        {
            string         ln;
            CheckParameter obj = new CheckParameter();

            while ((ln = Console.ReadLine()) != null)
            {
                Console.WriteLine("------------------------------------------------------");
                Console.WriteLine(ln);
                string[] stringArray = ConvertJson(ln);
                Dictionary <CheckParameter.Parameters, string> data = GenerateData(stringArray);
                obj.VitalsAreNormal(data);
                Console.WriteLine("------------------------------------------------------");
                Console.WriteLine();
            }
        }
Пример #4
0
        /// <summary>
        /// 授权检测是否登录
        /// 在执行操作方法之前由 MVC 框架调用。
        /// </summary>
        /// <param name="actionContext"></param>
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            Stopwatch stopWatch = new Stopwatch();//测量运行时间类

            actionContext.Request.Properties[Key] = stopWatch;
            stopWatch.Start();//时间开始
            Stream stream         = actionContext.Request.Content.ReadAsStreamAsync().Result;
            string requestDataStr = "";

            if (stream != null && stream.Length > 0)
            {
                stream.Position = 0; //当你读取完之后必须把stream的读取位置设为开始
                using (StreamReader reader = new StreamReader(stream, System.Text.Encoding.UTF8))
                {
                    requestDataStr = reader.ReadToEnd().ToString();
                }
            }
            string actionName = actionContext.ActionDescriptor.ActionName;

            LogInfo.RequestInfoLogMessage(actionName, requestDataStr);
            CheckParameter checkParameter = JsonConvert.DeserializeObject <CheckParameter>(requestDataStr);

            if (checkParameter != null)
            {
                if (!Cache.GetCheckTokenCache(checkParameter.userid, checkParameter.token))
                {
                    ResultInfo <object> resultInfo = new ResultInfo <object>();
                    resultInfo.ResultCode = EmResultDescribe.请登录;
                    throw new HttpResponseException(new HttpResponseMessage {
                        Content = new StringContent(JsonConvert.SerializeObject(resultInfo), Encoding.GetEncoding("UTF-8"), "application/json")
                    });
                }
            }
            else
            {
                ResultInfo <object> resultInfo = new ResultInfo <object>();
                resultInfo.ResultCode = EmResultDescribe.请登录;
                throw new HttpResponseException(new HttpResponseMessage {
                    Content = new StringContent(JsonConvert.SerializeObject(resultInfo), Encoding.GetEncoding("UTF-8"), "application/json")
                });
            }
        }
Пример #5
0
        public static void EntryPoint(string[] args)
        {
            try
            {
                Console.InputEncoding  = Encoding.UTF8;
                Console.OutputEncoding = Encoding.UTF8;
                //string reallyLongDirectory = @"C:\Users\Daniel\Source\Repos\FolderRenameAssist\FolderRenameAssist\bin\Debug\New folder\[Ano Hi Mita Hana no Namae o Bokutachi wa Mada Shiranai][あの日見た花の名前を僕達はまだ知らない.][ANK-Raws] 劇場版 あの日見た花の名前を僕達はまだ知らない。 (BDrip x264 FLAC DTS TRUE-HD 5.1ch SUP Hi10P)\New Text Document.txt";
                //string reallyLongFile = @"D:\Downloaded\[Menelkir] THE iDOLM@STER Cinderella Girls (2012-2017) [MP3]\[2017-2017] CINDERELLA GIRLS THEATER\[2017-2017] CINDERELLA GIRLS THEATER 1st Season Theme\[2017.05.24] CINDERELLA GIRLS LITTLE STARS! エチュードは1曲だけ\08. lilac time (ピクニックライブ Acoustic Ver.) [bonus track].mp3";
                //Console.WriteLine($"Creating a directory that is {reallyLongDirectory.Length} characters long");
                //Directory.CreateDirectory(reallyLongDirectory);

                //Console.WriteLine(reallyLongFile);
                //Console.WriteLine(File.Exists(reallyLongFile));
                //Console.WriteLine(Processing.ComputeMD5(reallyLongFile));
                int StartingPoint = 0;
                Console.WriteLine("Version:" + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString());
                Console.WriteLine("Proccessing Mode");
                Console.WriteLine("A. Verify Checksums");
                Console.WriteLine("\t(Initial index is 0, or you can input a different onem like {a,(ProcessingPower),50})");
                Console.WriteLine("\t(or input date format yyyy-MM-dd as Date filter, like {a," + DateTime.Today.AddHours(8).ToString("yyyy-MM-dd") + "} .)");
                Console.WriteLine("B. Verify File Existences and Path Length");
                Console.WriteLine("C. Combine All md5s into One");
                Console.WriteLine("D. Create Checksum for every folder.");
                Console.WriteLine("\t(Alternatively you can append input date format yyyy-MM-dd as Date filter, like {d,(ProcessingPower)," + DateTime.Today.ToString("yyyy-MM-dd") + "} .)");
                if (File.Exists(@"C:\ffmpeg\bin\ffmpeg.exe"))
                {
                    Console.WriteLine("E. Check all video files for corruption.");
                }
                Console.WriteLine("ProcessingPower : Single = 1, Half = 2, Full = 3");
                Console.WriteLine("Select Proccessing Mode : ");

                Input_ModeSection Input = Prepare.ParseModeSection(Console.ReadLine().ToLowerInvariant());

                switch (Input.Mode)
                {
                default:
                case Mode.Verify_Checksums:
                    if (!string.IsNullOrEmpty(Input.Optional_Parameter))
                    {
                        if (CheckParameter.IsDateParameter(Input.Optional_Parameter))
                        {
                            ReportFile = Prepare.ProduceReportName(WorkingDirectory, Input.Mode, ArgumentType.Date, Input.Optional_Parameter);
                            Processing.Verify(WorkingDirectory, ReportFile, Mode.Verify_Checksums, StartingPoint, Convert.ToDateTime(Input.Optional_Parameter).Date, true);
                            break;
                        }
                        else if (CheckParameter.IsIndexParameter(Input.Optional_Parameter))
                        {
                            StartingPoint = Convert.ToInt32(Input.Optional_Parameter);
                            ReportFile    = Prepare.ProduceReportName(WorkingDirectory, Input.Mode, ArgumentType.Index, Input.Optional_Parameter);
                            Processing.Verify(WorkingDirectory, ReportFile, Mode.Verify_Checksums, StartingPoint);
                            break;
                        }
                    }
                    ReportFile = Prepare.ProduceReportName(WorkingDirectory, Input.Mode);
                    Processing.Verify(WorkingDirectory, ReportFile, Mode.Verify_Checksums);
                    break;

                case Mode.Verify_Path_Length_and_Existences:
                    ReportFile = Prepare.ProduceReportName(WorkingDirectory, Input.Mode);
                    Processing.Verify(WorkingDirectory, ReportFile, Mode.Verify_Path_Length_and_Existences);
                    break;

                case Mode.Combine_All_MD5:
                    ReportFile = Prepare.ProduceReportName(WorkingDirectory, Input.Mode);
                    Processing.Verify(WorkingDirectory, ReportFile, Mode.Combine_All_MD5);
                    break;

                case Mode.Create_Checksum_for_Every_Folder:
                    if (CheckParameter.IsIndexParameter(Input.Optional_Parameter))
                    {
                        StartingPoint = Convert.ToInt32(Input.Optional_Parameter);
                    }
                    ReportFile = Prepare.ProduceReportName(WorkingDirectory, Input.Mode);
                    Processing.ParalleRefresh(WorkingDirectory, ReportFile, Mode.Create_Checksum_for_Every_Folder, Input.ProcessingPower, StartingPoint);
                    break;

                case Mode.Check_Video_Corruption:
                    if (!File.Exists(@"C:\ffmpeg\bin\ffmpeg.exe"))
                    {
                        throw new Exception(@"C:\ffmpeg\bin\ffmpeg.exe not found.");
                    }
                    ReportFile = Prepare.ProduceReportName(WorkingDirectory, Input.Mode);
                    Processing.VideoCheck(WorkingDirectory, ReportFile, Mode.Check_Video_Corruption);
                    break;
                }
                Console.WriteLine("Report generated @ " + ReportFile);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                TaskbarProgress.SetState(Process.GetCurrentProcess().MainWindowHandle, TaskbarProgress.TaskbarStates.Error);
            }
            finally
            {
                ConsoleKeyInfo key = new ConsoleKeyInfo();
                while (key.Key != ConsoleKey.Enter)
                {
                    key = Console.ReadKey();
                }
            }
        }
        public async Task <Unit> Handle(SaveCheckResultCommand request, CancellationToken cancellationToken)
        {
            //todo: почистить код

            foreach (var checkDto in request.CheckResult.HardwareChecks)
            {
                var hardware = await _context.Hardwares.FindAsync(checkDto.Hardware.Id);

                hardware.CheckResult ??= new HardwareCheck();

                var parameters = hardware.CheckResult.CheckParameters;

                _context.CheckParameters.RemoveRange(parameters);

                foreach (var parameterDto in checkDto.CheckParameters)
                {
                    var parameter = new CheckParameter
                    {
                        Description = parameterDto.Description,
                        Method      = parameterDto.Method,
                        Result      = parameterDto.Result,
                        Date        = parameterDto.Date,
                        Comment     = parameterDto.Comment
                    };

                    hardware.CheckResult.CheckParameters.Add(parameter);
                }
            }

            foreach (var checkDto in request.CheckResult.SoftwareChecks)
            {
                var software = await _context.Softwares.FindAsync(checkDto.Software.Id);

                software.CheckResult ??= new SoftwareCheck();

                var parameters = software.CheckResult.CheckParameters;

                _context.CheckParameters.RemoveRange(parameters);

                foreach (var parameterDto in checkDto.CheckParameters)
                {
                    var parameter = new CheckParameter
                    {
                        Description = parameterDto.Description,
                        Method      = parameterDto.Method,
                        Result      = parameterDto.Result,
                        Date        = parameterDto.Date,
                        Comment     = parameterDto.Comment
                    };

                    software.CheckResult.CheckParameters.Add(parameter);
                }
            }

            var contract = await _context.Contracts.FindAsync(request.CheckResult.Contract.Id);

            contract.HasProtocol = true;

            try
            {
                await _context.SaveChangesAsync(cancellationToken);
            }
            catch (System.Exception ex)
            {
                throw ex;
            }

            return(Unit.Value);
        }