Example #1
0
        private object SetRulerInfo()
        {
            var successFiles = new List <string>();
            var failedFiles  = new List <PointRulerErrFileModel>();

            if (!Request.Files.Any())
            {
                return(Response.AsText("请上传配置文件").WithStatusCode(HttpStatusCode.BadRequest));
            }
            foreach (var file in Request.Files)
            {
                if (!file.Name.Split(".").Last().Equals("XML", StringComparison.OrdinalIgnoreCase))
                {
                    failedFiles.Add(new PointRulerErrFileModel {
                        FileName = file.Name, ErrMsg = "该文件类型错误"
                    });
                }
                var resultCode = RulersXmlUtil.AddNewRuleXml(file.Name, file.Value);
                if (resultCode != RuleXmlCode.SUCCESS)
                {
                    failedFiles.Add(new PointRulerErrFileModel {
                        FileName = file.Name, ErrMsg = resultCode.ToString()
                    });
                }
                else
                {
                    successFiles.Add(file.Name);
                }
            }
            return(Response.AsJson(new { SuccessFiles = successFiles, FailedFiles = failedFiles }));
        }
Example #2
0
        private object StartusingRuleXml()
        {
            var model = this.Bind <UsingRuleXmlModel>();

            RulersXmlUtil.GetRulersDic(model.FileName);
            return(Response.AsText(""));
        }
 protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
 {
     RulersXmlUtil.GetRulersDic();
 }