示例#1
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog myOpenFileDialog = new OpenFileDialog();

            myOpenFileDialog.Filter           = string.Format("{1} (*.{0})|*.{0}", FileExtensionEnum.ItgBind, FileExtensionEnum.ItgBind.GetDescription());
            myOpenFileDialog.Title            = "选择方法";
            myOpenFileDialog.InitialDirectory = Busi.Common.Configuration.FolderMInteg;
            if (myOpenFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            this._model = BindModel.ReadModel <IntegrateModel>(myOpenFileDialog.FileName);



            //检查子方法是否存在
            List <string> notExitFiles = this._model.CheckModelNotExist();

            if (notExitFiles.Count > 0)
            {
                MessageBox.Show(string.Format("以下方法不存在,未被加载:\n{0}", string.Join("\n", notExitFiles)));
                return;
            }
            this.initGrid();
            this.showModel();
            this.setWightWithModel();

            this.btnAddModel.Enabled = true;
            this.btnSave.Enabled     = true;
            this.setTitle();
        }
示例#2
0
        private void init(BindModel m)
        {
            this.dataGridView1.Columns.Clear();
            this.dataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "样本名称",
                Width = 120
            });
            this.dataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "方法",
                Width = 60
            });
            foreach (var sm in m.GetComponents())
            {
                this.dataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
                {
                    HeaderText = sm.Name,
                    ToolTipText = sm.Name,
                    Width = 60,
                    Tag = sm.Name
                });
            }
            this.dataGridView1.Columns.Add(new DataGridViewTextBoxColumn()
            {
                AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
            });

            this._inited = true;
        }
示例#3
0
        //(options[\s]*{[\w\d\s;\-{}.*]+[\s]*};)
        public static BindModel ParseOptions(BindModel bindConfigurationModel, string text)
        {
            var regex         = new Regex("(options[\\s]*{[\\w\\d\\s;\\-{}.*]+[\\s]*};)");
            var matchedGroups = regex.Match(text).Groups;
            var capturedText  = matchedGroups[1].Value;

            bindConfigurationModel.Notify              = CaptureGroup(capturedText, "[^\\-]notify[\\s]*([\\w]*);");
            bindConfigurationModel.MaxCacheSize        = CaptureGroup(capturedText, "max-cache-size[\\s]*([\\w\\d]*);");
            bindConfigurationModel.MaxCacheTtl         = CaptureGroup(capturedText, "max-cache-ttl[\\s]*([\\w\\d]*);");
            bindConfigurationModel.MaxNcacheTtl        = CaptureGroup(capturedText, "max-ncache-ttl[\\s]*([\\w\\d]*);");
            bindConfigurationModel.Forwarders          = CaptureGroup(capturedText, "forwarders[\\s]*{[\\s]*([\\w\\d.; ]*)[\\s]*};").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.AllowNotify         = CaptureGroup(capturedText, "allow-notify[\\s]*{[\\s]*([\\w\\d.; ]*)[\\s]*};").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.AllowTransfer       = CaptureGroup(capturedText, "allow-transfer[\\s]*{[\\s]*([\\w\\d.; ]*)[\\s]*};").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.Recursion           = CaptureGroup(capturedText, "recursion[\\s]*([\\w\\d]*);");
            bindConfigurationModel.TransferFormat      = CaptureGroup(capturedText, "transfer-format[\\s]*([\\w\\d\\-]*);");
            bindConfigurationModel.QuerySourceAddress  = CaptureGroup(capturedText, "query-source address[\\s]*([\\w\\d\\-*]*) port");
            bindConfigurationModel.QuerySourcePort     = CaptureGroup(capturedText, "query-source address[\\s]*[\\w\\d\\-*]* port[\\s]*([\\w\\d\\-*]*);");
            bindConfigurationModel.Version             = CaptureGroup(capturedText, "version[\\s]*([\\w\\d]*);");
            bindConfigurationModel.AllowQuery          = CaptureGroup(capturedText, "allow-query[\\s]*{[\\s]*([\\w\\d.; ]*)[\\s]*};").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.AllowRecursion      = CaptureGroup(capturedText, "allow-recursion[\\s]*{[\\s]*([\\w\\d.; ]*)[\\s]*};").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.IxfrFromDifferences = CaptureGroup(capturedText, "ixfr-from-differences[\\s]*([\\w\\d]*);");
            bindConfigurationModel.ListenOnV6          = CaptureGroup(capturedText, "listen-on-v6[\\s]*{[\\s]*([\\w\\d.; ]*)[\\s]*};").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.ListenOnPort53      = CaptureGroup(capturedText, "listen-on port 53 [\\s]*{[\\s]*([\\w\\d.; ]*)[\\s]*};").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.DnssecEnabled       = CaptureGroup(capturedText, "dnssec-enable[\\s]*([\\w\\d]*);");
            bindConfigurationModel.DnssecValidation    = CaptureGroup(capturedText, "dnssec-validation[\\s]*([\\w\\d]*);");
            bindConfigurationModel.DnssecLookaside     = CaptureGroup(capturedText, "dnssec-lookaside[\\s]*([\\w\\d]*);");
            bindConfigurationModel.AuthNxdomain        = CaptureGroup(capturedText, "auth-nxdomain[\\s]*([\\w\\d]*);");
            return(bindConfigurationModel);
        }
示例#4
0
文件: Bind.cs 项目: jeason0813/Antd
        public static void Parse()
        {
            if (!File.Exists(MainFilePath))
            {
                return;
            }
            var content = File.ReadAllText(MainFilePath);

            if (!content.Contains("options"))
            {
                return;
            }
            var model = new BindModel {
                Active = false
            };

            model = BindParser.ParseOptions(model, content);
            model = BindParser.ParseControl(model, content);
            model = BindParser.ParseKeySecret(model, content);
            model = BindParser.ParseLogging(model, content);
            var acls = BindParser.ParseAcl(content).ToArray();

            model.AclList = acls;
            var simpleZone  = BindParser.ParseSimpleZones(content).ToList();
            var complexZone = BindParser.ParseComplexZones(content).ToList();

            complexZone.AddRange(simpleZone);
            model.Zones = complexZone;
            var includes = BindParser.ParseInclude(content).ToArray();

            model.IncludeFiles = includes;
            Application.CurrentConfiguration.Services.Bind = model;
            ConsoleLogger.Log("[bind] import existing configuration");
        }
示例#5
0
        private void loadModel()
        {
            var ftype        = (FileExtensionEnum)this.type;
            var tempfullName = Path.Combine(HttpContext.Current.Server.MapPath("~/"), this.path);

            switch (ftype)
            {
            case FileExtensionEnum.Allmethods:
                if (this._mBind == null)
                {
                    this._mBind      = BindModel.ReadModel <BindModel>(tempfullName);
                    this._components = this._mBind.GetComponents();
                }
                break;

            case FileExtensionEnum.PLSBind:
                if (this._mPLS == null)
                {
                    this._mPLS       = BindModel.ReadModel <PLSModel>(tempfullName);
                    this._components = this._mPLS.GetComponents();
                }
                break;

            case FileExtensionEnum.IdLib:
                if (this._mId == null)
                {
                    this._mId        = BindModel.ReadModel <IdentifyModel>(tempfullName);
                    this._components = this._mId.GetComponents();
                }
                break;

            case FileExtensionEnum.FitLib:
                if (this._mFitting == null)
                {
                    this._mFitting   = BindModel.ReadModel <FittingModel>(tempfullName);
                    this._components = this._mFitting.GetComponents();
                }
                break;

            case FileExtensionEnum.PLS1:
            case FileExtensionEnum.PLSANN:
                if (this._mPLS1 == null)
                {
                    this._mPLS1      = BindModel.ReadModel <PLSSubModel>(tempfullName);
                    this._components = this._mPLS1.GetComponents();
                }
                break;

            case FileExtensionEnum.ItgBind:
                if (this._itgSub == null)
                {
                    this._itgSub     = BindModel.ReadModel <IntegrateModel>(tempfullName);
                    this._components = this._itgSub.GetComponents();
                }
                break;

            default:
                break;
            }
        }
示例#6
0
        void FrmModelSet_Load(object sender, EventArgs e)
        {
            this.Enabled = false;
            RIPP.NIR.Controls.StyleTool.FormatGrid(ref this.dataGridView1);
            if (this._user.Role == RoleEnum.Operater)
            {
                this.dataGridView1.Columns[1].Visible = false;
                this.btnDel.Enabled    = false;
                this.btnImport.Enabled = false;
            }

            Action a = () =>
            {
                string modelPath = this._config.FolderModel;
                if (!Directory.Exists(modelPath))
                {
                    Directory.CreateDirectory(modelPath);
                }
                string fileter = string.Format("*.{0}|*.{1}|*.{2}|*.{3}|*.{4}",
                                               FileExtensionEnum.Allmethods,
                                               FileExtensionEnum.FitLib,
                                               FileExtensionEnum.IdLib,
                                               FileExtensionEnum.PLSBind,
                                               FileExtensionEnum.ItgBind
                                               );
                string[] files = GetFiles(
                    modelPath,
                    fileter,
                    SearchOption.TopDirectoryOnly);

                for (int i = 0; i < files.Length; i++)
                {
                    try
                    {
                        var model = BindModel.LoadModel(files[i]);
                        if (this._config.AvailableModelNames.Contains((new FileInfo(files[i]).Name)) || this._user.Role != RoleEnum.Operater)
                        {
                            this.addRow(model);
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                }

                if (this.InvokeRequired)
                {
                    ThreadStart s = () => { this.Enabled = true; };
                    this.Invoke(s);
                }
                else
                {
                    this.Enabled = true;
                }
            };

            a.BeginInvoke(null, null);
        }
示例#7
0
        //(trusted-keys {[\s]+[\s\d\w\-;."\/+]+};)
        public static BindModel ParseTrustedKey(BindModel bindConfigurationModel, string text)
        {
            var regex         = new Regex("(trusted-keys {[\\s]+[\\s\\d\\w\\-;.\"\\/+]+};)");
            var matchedGroups = regex.Match(text).Groups;
            var capturedText  = matchedGroups[1].Value;

            bindConfigurationModel.TrustedKeys = capturedText;
            return(bindConfigurationModel);
        }
示例#8
0
        private void addModel(string fullpath)
        {
            FileInfo f      = new FileInfo(fullpath);
            string   fexten = f.Extension.ToUpper().Replace(".", "");

            if (fexten == FileExtensionEnum.IdLib.ToString().ToUpper())
            {
                var model = BindModel.ReadModel <IdentifyModel>(fullpath);
                if (!this._model.AddID(model))
                {
                    MessageBox.Show("该方法已经存在!");
                }
            }
            else if (fexten == FileExtensionEnum.FitLib.ToString().ToUpper())
            {
                var model = BindModel.ReadModel <FittingModel>(fullpath);
                if (!this._model.AddFit(model))
                {
                    MessageBox.Show("该方法已经存在!");
                }
            }
            else if (fexten == FileExtensionEnum.PLSBind.ToString().ToUpper())
            {
                var submodel = BindModel.ReadModel <PLSModel>(fullpath);
                if (this._model.Itg != null && MessageBox.Show("信息提示", "该方法包包含有集成包,是否替换?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
                if (this._model.PLS != null)
                {
                    if (MessageBox.Show("已经存在,是否替换", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
                    {
                        return;
                    }
                }
                this._model.PLS1Path = submodel.FullPath;
                this._model.ItgPath  = null;
            }
            else if (fexten == FileExtensionEnum.ItgBind.ToString().ToUpper())
            {
                var submodel = BindModel.ReadModel <IntegrateModel>(fullpath);
                if (this._model.PLS != null && MessageBox.Show("信息提示", "该方法包包含有PLS捆绑模型,是否替换?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.No)
                {
                    return;
                }
                if (this._model.Itg != null)
                {
                    if (MessageBox.Show("已经存在,是否替换", "信息提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
                    {
                        return;
                    }
                }
                this._model.PLS1Path = null;
                this._model.ItgPath  = submodel.FullPath;
            }
            this.fillGrid();
        }
示例#9
0
        //(key "[\w]+" {[\s\d\w\-;"=]+[\s]+};)
        public static BindModel ParseKeySecret(BindModel bindConfigurationModel, string text)
        {
            var regex         = new Regex("(key \"[\\w]+\" {[\\s\\d\\w\\-;\"=]+[\\s]+};)");
            var matchedGroups = regex.Match(text).Groups;
            var capturedText  = matchedGroups[1].Value;

            bindConfigurationModel.KeyName   = CaptureGroup(capturedText, "key \"([\\w]+)\"");
            bindConfigurationModel.KeySecret = CaptureGroup(capturedText, "secret \"([\\s\\S]*)\";");
            return(bindConfigurationModel);
        }
示例#10
0
        //(controls[\s]*{[\s]*[\w\s\d.]+allow[\s]*{[\s\w\d;]+}[\s]*keys {[\s]*["\w;]+[\s]*};)
        public static BindModel ParseControl(BindModel bindConfigurationModel, string text)
        {
            var regex         = new Regex("(controls[\\s]*{[\\s]*[\\w\\s\\d.]+allow[\\s]*{[\\s\\w\\d;]+}[\\s]*keys {[\\s]*[\"\\w;]+[\\s]*};)");
            var matchedGroups = regex.Match(text).Groups;
            var capturedText  = matchedGroups[1].Value;

            bindConfigurationModel.ControlIp    = CaptureGroup(capturedText, "inet[\\s]+([\\d.]+)");
            bindConfigurationModel.ControlPort  = CaptureGroup(capturedText, "port[\\s]+([\\d.]+)");
            bindConfigurationModel.ControlAllow = CaptureGroup(capturedText, "allow {[\\s]+([\\w\\d\\s;]+)}").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim()).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            bindConfigurationModel.ControlKeys  = CaptureGroup(capturedText, "keys {[\\s]+([\\w\\d\\s;\"]+)}").Split(new[] { ";" }, StringSplitOptions.RemoveEmptyEntries).Select(_ => _.Trim().Replace("\"", "")).Where(_ => !string.IsNullOrWhiteSpace(_)).ToArray();
            return(bindConfigurationModel);
        }
示例#11
0
        //(channel syslog {[\s]+[\s\d\w\-;]+)
        public static BindModel ParseLogging(BindModel bindConfigurationModel, string text)
        {
            var regex         = new Regex("(channel syslog {[\\s]+[\\s\\d\\w\\-;]+)");
            var matchedGroups = regex.Match(text).Groups;
            var capturedText  = matchedGroups[1].Value;

            bindConfigurationModel.SyslogSeverity      = CaptureGroup(capturedText, "[^-]severity[\\s]*([\\w]+);");
            bindConfigurationModel.SyslogPrintCategory = CaptureGroup(capturedText, "print-category[\\s]*([\\w]+);");
            bindConfigurationModel.SyslogPrintSeverity = CaptureGroup(capturedText, "print-severity[\\s]*([\\w]+);");
            bindConfigurationModel.SyslogPrintTime     = CaptureGroup(capturedText, "print-time[\\s]*([\\w]+);");
            return(bindConfigurationModel);
        }
示例#12
0
        public JsonResult OnPostDeleteProduct([FromBody] BindModel model)
        {
            var channel = GrpcChannel.ForAddress("https://localhost:5001");
            var client  = new GRPCCoreCrudExampleServer.Product.ProductClient(channel);

            client.DeleteProduct(new GRPCCoreCrudExampleServer.ProductMessage()
            {
                Id = model.Id
            });

            return(new JsonResult("Success"));
        }
示例#13
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (this.cheakSave())
            {
                return;
            }
            OpenFileDialog myOpenFileDialog = new OpenFileDialog();

            myOpenFileDialog.Filter           = string.Format("{1} (*.{0})|*.{0}", FileExtensionEnum.PLSBind, FileExtensionEnum.PLSBind.GetDescription());
            myOpenFileDialog.InitialDirectory = Busi.Common.Configuration.FolderMModel;
            if (myOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this._model = BindModel.ReadModel <PLSModel>(myOpenFileDialog.FileName);
                if (this._model != null)
                {
                    if (this._model.LibBase == null || this._model.LibBase.Count == 0)
                    {
                        MessageBox.Show("该捆绑模型不含光谱库,不能修改!", "信息提示");
                    }
                    else
                    {
                        lblLibIntro.Text = this._model.ToString();
                    }

                    this._nodes.Clear();
                    foreach (var m in this._model.SubModels)
                    {
                        var step = 1;
                        var tag  = true;
                        if (m.LibBase == null || m.LibBase.Count == 0 || m.Trained)
                        {
                            step = 4;
                            tag  = false;
                        }

                        this._nodes.Add(new MyTreeNode()
                        {
                            IsFinished  = false,
                            ToolTipText = "双击可编辑子模型",
                            PLS         = new PLSFormContent()
                            {
                                ActiveStep      = step,
                                VResult         = null,
                                CVResult        = null,
                                Model           = m,
                                FlowPanelEnable = tag
                            }
                        });
                    }
                    this.treeInit();
                }
            }
        }
示例#14
0
        /// <summary>
        /// 初始化增量数据存放月数
        /// </summary>
        private void InitDataMonth()
        {
            var list = new List <BindModel>();

            for (var i = 1; i <= 24; i++)
            {
                var item = new BindModel();
                item.key   = string.Format("{0} 个月", i);
                item.value = i;
                list.Add(item);
            }

            DataMonth.ItemsSource = list;
        }
示例#15
0
        /// <summary>
        /// 初始化抽取条数
        /// </summary>
        private void InitUpdateCount()
        {
            var list = new List <BindModel>();

            for (var i = 1; i <= 10; i++)
            {
                var item = new BindModel();
                item.key   = string.Format("{0} 万条", i);
                item.value = i;
                list.Add(item);
            }

            UpdateCount.ItemsSource = list;
        }
示例#16
0
        /// <summary>
        /// 初始化更新时间
        /// </summary>
        private void InitUpdateTime()
        {
            var list = new List <BindModel>();

            for (var i = 0; i < 24; i++)
            {
                var item = new BindModel();
                item.key   = string.Format("{0} 点", i);
                item.value = i;
                list.Add(item);
            }

            UpdateTime.ItemsSource = list;
        }
示例#17
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            OpenFileDialog myOpenFileDialog = new OpenFileDialog();

            myOpenFileDialog.Filter           = string.Format("{1} (*.{0})|*.{0}", FileExtensionEnum.Allmethods, FileExtensionEnum.Allmethods.GetDescription());
            myOpenFileDialog.InitialDirectory = Busi.Common.Configuration.FolderMMethod;
            if (myOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this._model = BindModel.ReadModel <BindModel>(myOpenFileDialog.FileName);
                if (this._model != null)
                {
                    this.fillGrid();
                }
            }
        }
示例#18
0
        private void btnLoadModel_Click(object sender, EventArgs e)
        {
            OpenFileDialog myOpenFileDialog = new OpenFileDialog();

            myOpenFileDialog.Filter           = string.Format("{1} (*.{0})|*.{0}", FileExtensionEnum.IdLib, FileExtensionEnum.IdLib.GetDescription());
            myOpenFileDialog.InitialDirectory = Busi.Common.Configuration.FolderMId;
            if (myOpenFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }
            this._baseModel = BindModel.ReadModel <IdentifyModel>(myOpenFileDialog.FileName);
            ToolTip tip = new ToolTip();

            tip.SetToolTip(this.btnLoadModel, myOpenFileDialog.FileName);
            this.clear();
        }
示例#19
0
        public override void Predict(List<string> files, object model,int numofId)
        {
            

            //throw new NotImplementedException();
            BindModel m = model as BindModel;
            if (m == null || files==null)
                throw new ArgumentNullException("");
            if (!this._inited)
            {
                if (this.dataGridView1.InvokeRequired)
                {
                    ThreadStart s = () => { this.init(m); };
                    this.dataGridView1.Invoke(s);
                }
                else
                    this.init(m);
            }
            var error_filelst = new List<string>();
            int rowNum = 1;
            foreach (var f in files)
            {
                try
                {
                var spec =new Spectrum(f);
                var robj = m.Predict(spec,true,numofId);
                if (this.dataGridView1.InvokeRequired)
                {
                    ThreadStart s = () => { this.addRow(robj, spec,rowNum,numofId); };
                    this.dataGridView1.Invoke(s);
                }
                else
                    this.addRow(robj, spec,rowNum,numofId);
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                    error_filelst.Add(new FileInfo(f).Name);
                }
                rowNum++;
            }
            if (error_filelst.Count > 0)
                MessageBox.Show(string.Format("以下{1}条光谱未正确预测:\n{0}",
                    string.Join(";", error_filelst),
                    error_filelst.Count
            ));
        }
 public IActionResult Get(BindModel data)
 {
     //Validate request
     if (WeatherForecastValidator.ValidateGet(data).IsSuccess)
     {
         return(Ok(new Response <List <string> >
         {
             Data = new List <string> {
                 "Data A", "Data B"
             }
         }));
     }
     else
     {
         return(BadRequest(WeatherForecastValidator.ValidateGet(data)));
     }
 }
示例#21
0
        private void btnLoadModel_Click(object sender, EventArgs e)
        {
            OpenFileDialog myOpenFileDialog = new OpenFileDialog();

            myOpenFileDialog.Filter           = string.Format("{0} (*.{1})|*.{1}", FileExtensionEnum.PLSBind.GetDescription(), FileExtensionEnum.PLSBind);
            myOpenFileDialog.InitialDirectory = Busi.Common.Configuration.FolderBlendMod;
            if (myOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    this._model = BindModel.ReadModel <PLSModel>(myOpenFileDialog.FileName);
                    if (this._model.SubModels.Count < 2)
                    {
                        MessageBox.Show("该捆绑模型不是混兑比例光谱的模型");
                        this._model = null;
                        return;
                    }

                    //验证是不是混兑模型
                    foreach (var m in this._model.SubModels)
                    {
                        if (m.Method != PLSMethodEnum.PLSMix)
                        {
                            MessageBox.Show("该捆绑模型不是混兑比例光谱的模型");
                            this._model = null;
                            return;
                        }
                    }

                    //设置按钮
                    this.btnAddFromLib.Enabled = true;
                    this.btnPredict.Enabled    = true;
                    this.btnSpec1.Enabled      = this._model.SubModels.Count > 0;
                    this.btnSpec2.Enabled      = this._model.SubModels.Count > 1;
                    this.btnSpec3.Enabled      = this._model.SubModels.Count > 2;
                }

                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    log.Error(ex);
                }
            }
        }
示例#22
0
            public static void Render()
            {
                var path          = $"{Dir}/{MainFile}";
                var namedFileText = File.ReadAllText(path);

                var acl                = BindStatement.AssignAcl(namedFileText).ToList();
                var controls           = BindStatement.AssignControls(namedFileText).ToList();
                var include            = BindStatement.AssignInclude(namedFileText).ToList();
                var key                = BindStatement.AssignKey(namedFileText).ToList();
                var logging            = BindStatement.AssignLogging(namedFileText).ToList();
                var lwres              = BindStatement.AssignLwres(namedFileText).ToList();
                var masters            = BindStatement.AssignMasters(namedFileText).ToList();
                var options            = BindStatement.AssignOptions(namedFileText).ToList();
                var server             = BindStatement.AssignServer(namedFileText).ToList();
                var statisticsChannels = BindStatement.AssignStatisticsChannels(namedFileText).ToList();
                var trustedKeys        = BindStatement.AssignTrustedKeys(namedFileText).ToList();
                var managedKeys        = BindStatement.AssignManagedKeys(namedFileText).ToList();
                var view               = BindStatement.AssignView(namedFileText).ToList();
                var zones              = BindStatement.AssignZone(namedFileText).ToList();

                var bind = new BindModel()
                {
                    _Id                    = ServiceGuid,
                    Guid                   = ServiceGuid,
                    Timestamp              = Timestamp.Now,
                    BindAcl                = acl,
                    BindControls           = controls,
                    BindInclude            = include,
                    BindKey                = key,
                    BindLogging            = logging,
                    BindLwres              = lwres,
                    BindMasters            = masters,
                    BindOptions            = options,
                    BindServer             = server,
                    BindStatisticsChannels = statisticsChannels,
                    BindTrustedKeys        = trustedKeys,
                    BindManagedKeys        = managedKeys,
                    BindView               = view,
                    BindZone               = zones
                };

                DeNSo.Session.New.Set(bind);
            }
示例#23
0
        private void btnOpen_Click(object sender, EventArgs e)
        {
            if (this.cheakSave())
            {
                return;
            }

            OpenFileDialog myOpenFileDialog = new OpenFileDialog();

            myOpenFileDialog.Filter           = string.Format("{1} (*.{0})|*.{0}", FileExtensionEnum.FitLib, FileExtensionEnum.FitLib.GetDescription());
            myOpenFileDialog.InitialDirectory = Busi.Common.Configuration.FolderMFit;
            if (myOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                this._model = BindModel.ReadModel <FittingModel>(myOpenFileDialog.FileName);
                if (this._model != null)
                {
                    this.libGridView.Specs    = this._model.LibBase;
                    this.preForFit.Processors = this._model.Filters.Select(f => new RIPP.NIR.Data.Preprocesser()
                    {
                        Filter = f,
                        Statu  = WorkStatu.NotSet
                    }).ToList();
                    this.setIdParams1.Model     = this._model;
                    this.setTQ1.Model           = this._model;
                    this.resultForm1.Model      = this._model;
                    this.calibResultForm1.Model = this._model;


                    if (this._model.LibBase == null)
                    {
                        MessageBox.Show("该模型没有存储建模所需的光谱库,无法对模型进行修改,只能使用外部验证功能!", "信息提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        this.flowControl1.Active(6);
                    }
                    else
                    {
                        this.flowControl1.Active(1);
                        this.flowControl1.Enabled = true;
                    }
                    this._model.Edited = false;
                }
            }
            this.setTitle();
        }
示例#24
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            OpenFileDialog myOpenFileDialog = new OpenFileDialog();

            myOpenFileDialog.Filter           = string.Format("{1} (*.{0})|*.{0}", FileExtensionEnum.PLS1, FileExtensionEnum.PLS1.GetDescription());
            myOpenFileDialog.InitialDirectory = Busi.Common.Configuration.FolderMModelLib;
            myOpenFileDialog.Multiselect      = true;
            if (myOpenFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    foreach (var f in myOpenFileDialog.FileNames)
                    {
                        var model = BindModel.ReadModel <PLSSubModel>(f);
                        if (model == null)
                        {
                            return;
                        }
                        for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
                        {
                            var row = this.dataGridView1.Rows[i] as mydataRow;
                            if (row != null && row.Model.Comp.Name == model.Comp.Name)
                            {
                                MessageBox.Show("所添加的子模型对应的性质已经存在!");
                                row.Selected = true;
                                return;
                            }
                        }
                        var myrow = new mydataRow()
                        {
                            Model = model
                        };
                        myrow.CreateCells(this.dataGridView1, model.Comp.Name);
                        this.dataGridView1.Rows.Add(myrow);
                    }
                }
                catch
                {
                }
            }
        }
示例#25
0
        private void addRow(BindModel m)
        {
            if (m == null)
            {
                return;
            }
            var f   = new FileInfo(m.FullPath);
            var row = new myrow()
            {
                Model    = m,
                FullPath = m.FullPath
            };

            row.CreateCells(this.dataGridView1,
                            f.Name,
                            this._config.AvailableModelNames.Contains(f.Name)
                            );
            if (this.dataGridView1.InvokeRequired)
            {
                ThreadStart s = () => { this.dataGridView1.Rows.Add(row); };
                this.dataGridView1.Invoke(s);
            }
            else
            {
                this.dataGridView1.Rows.Add(row);
            }
            if (this._config.ModelDefaultPath == m.FullPath)
            {
                if (this.dataGridView1.InvokeRequired)
                {
                    ThreadStart s = () => { row.Selected = true; };
                    this.dataGridView1.Invoke(s);
                }
                else
                {
                    row.Selected = true;
                }
            }
        }
 public static Response ValidateGet(BindModel data)
 {
     Errors.Clear();
     try
     {
         if (data.Age > 10)
         {
             Errors.Add("Age should be less than 10");
         }
         if (data.Name.Length > 10)
         {
             Errors.Add("The length of the name should be less than 10");
         }
         return(Errors.Count > 0 ? Response.ErrorResponse(Errors) : new Response());
     }
     catch (Exception)
     {
         return(Response.ErrorResponse(new List <string> {
             "Unable to validate the request"
         }));
     }
 }
示例#27
0
        //checks all the validations and insert hanger details into the table
        public ActionResult AddHanger(BindModel bind)
        {
            if (ModelState.IsValid)
            {
                if (DBOperations.CheckManager(bind.Manager.EmailAddress, bind.Manager.MobileNo))
                {
                    DBOperations.getIds(bind);

                    ViewBag.str = DBOperations.insertHanger(bind);
                    return(View("AddHanger"));
                }
                else
                {
                    ViewBag.str = "Email and Mobileno details already Exists";
                    return(View("AddHanger"));
                }
            }//end of model state
            else
            {
                return(View("AddHanger"));
            }
        }
示例#28
0
        /// <summary>
        /// 初始化关键主键
        /// </summary>
        private void InitIsDel()
        {
            var list = new List <BindModel>();
            var item = new BindModel();

            item.key   = "重复保留";
            item.value = 0;
            list.Add(item);

            var info = new BindModel();

            info.key   = "重复删除";
            info.value = 1;
            list.Add(info);

            var temp = new BindModel();

            temp.key   = "重复更新";
            temp.value = 2;
            list.Add(temp);

            IsDel.ItemsSource = list;
        }
示例#29
0
        private void addModel(string fullpath)
        {
            FileInfo f      = new FileInfo(fullpath);
            string   fexten = f.Extension.ToUpper().Replace(".", "");

            try
            {
                if (fexten == FileExtensionEnum.IdLib.ToString().ToUpper())
                {
                    var model = BindModel.ReadModel <IdentifyModel>(fullpath);
                    if (!this._model.AddID(model))
                    {
                        MessageBox.Show("该方法已经存在!");
                    }
                    else
                    {
                        this.showModel();
                    }
                }
                else if (fexten == FileExtensionEnum.FitLib.ToString().ToUpper())
                {
                    var model = BindModel.ReadModel <FittingModel>(fullpath);
                    if (!this._model.AddFit(model))
                    {
                        MessageBox.Show("该方法已经存在,或者该方法的参数与与有拟合库参数不一致!");
                    }
                    else
                    {
                        this.showModel();
                    }
                }
                else if (fexten == FileExtensionEnum.PLS1.ToString().ToUpper() || fexten == FileExtensionEnum.PLSANN.ToString().ToUpper())
                {
                    var model = BindModel.ReadModel <PLSSubModel>(fullpath);
                    var tag   = false;
                    if (model.AnnType != PLSAnnEnum.None)
                    {
                        tag = this._model.CheckPLSIsExist(model, false);
                    }
                    else
                    {
                        tag = this._model.CheckPLSIsExist(model, true);
                    }
                    if (tag)
                    {
                        if (MessageBox.Show("信息提示!", "该模型已经存在,是否覆盖原有模型?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.Yes)
                        {
                            tag = true;
                        }
                    }
                    if (!tag)
                    {
                        if (model.AnnType != PLSAnnEnum.None)
                        {
                            this._model.AddAnn(model);
                        }
                        else
                        {
                            this._model.AddPLS1(model);
                        }
                        this.showModel();
                    }
                }
            }
            catch
            {
                MessageBox.Show("读取方法出错,请检查文件!");
            }
            this.getDataFromControls();
            this.setWightWithModel();
        }
示例#30
0
        public void ShowMotheds(BindModel model)
        {
            if (model == null)
            {
                return;
            }
            this._model = model;
            this.dataGridView1.Rows.Clear();
            this.dataGridView2.Columns.Clear();

            //填充方法信息
            if (model.IdModels != null)
            {
                foreach (var m in model.IdModels)
                {
                    var row = new mydatarow()
                    {
                        Model = m, Method = PredictMethod.Identify
                    };
                    row.CreateCells(this.dataGridView1, m.Name,
                                    "识别",
                                    m.Creater,
                                    m.CreateTime.ToString("yy-MM-dd HH:mm"),
                                    m.SpecLib.FirstOrDefault().Components.Count,
                                    m.SpecLib.Count);
                    dataGridView1.Rows.Add(row);
                }
            }
            if (model.FitModels != null)
            {
                foreach (var m in model.FitModels)
                {
                    var row = new mydatarow()
                    {
                        Model = m, Method = PredictMethod.Fitting
                    };
                    row.CreateCells(this.dataGridView1, m.Name,
                                    "拟合",
                                    m.Creater,
                                    m.CreateTime.ToString("yy-MM-dd HH:mm"),
                                    m.SpecLib.FirstOrDefault().Components.Count,
                                    m.SpecLib.Count,
                                    m.SpecLib.Count);
                    dataGridView1.Rows.Add(row);
                }
            }
            if (model.PLS != null)
            {
                var row = new mydatarow()
                {
                    Model = model.PLS, Method = PredictMethod.PLSBind
                };
                var m = model.PLS;
                row.CreateCells(this.dataGridView1, m.Name,
                                "PLS",
                                m.Creater,
                                m.CreateTime.ToString("yy-MM-dd HH:mm"),
                                m.SubModels.Count);
                dataGridView1.Rows.Add(row);
            }
            if (model.Itg != null)
            {
                var row = new mydatarow()
                {
                    Model = model.Itg, Method = PredictMethod.Integrate
                };
                var m = model.Itg;
                row.CreateCells(this.dataGridView1, m.Name,
                                "集成包",
                                m.Creater,
                                m.CreateTime.ToString("yy-MM-dd HH:mm"),
                                m.Comps.Count);
                dataGridView1.Rows.Add(row);
            }

            //填充性质信息
            this.dataGridView2.Columns.Add(new DataGridViewTextBoxColumn()
            {
                HeaderText = "性质",
                Width      = 80
            });

            var trow = new DataGridViewRow();

            trow.CreateCells(this.dataGridView2, "");
            this.dataGridView2.Rows.Add(trow);
            if (model.IdModels != null)
            {
                foreach (var m in model.IdModels)
                {
                    var col = new DataGridViewTextBoxColumn()
                    {
                        HeaderText = "识别",
                        Width      = 60
                    };
                    this.dataGridView2.Columns.Add(col);
                    this.dataGridView2[col.Index, 0].Value = m.Name;
                    foreach (var c in m.SpecLib.FirstOrDefault().Components)
                    {
                        int ridx = findRowIndex(c.Name);
                        if (ridx >= 0)
                        {
                            this.dataGridView2[col.Index, ridx].Value = "是";
                        }
                        else
                        {
                            var row = new DataGridViewRow();
                            row.Tag = c.Name;
                            row.CreateCells(this.dataGridView2, c.Name);
                            this.dataGridView2.Rows.Add(row);
                            this.dataGridView2[col.Index, row.Index].Value = "是";
                        }
                    }
                }
            }
            if (model.FitModels != null)
            {
                foreach (var m in model.FitModels)
                {
                    var col = new DataGridViewTextBoxColumn()
                    {
                        HeaderText = "拟合",
                        Width      = 60
                    };
                    this.dataGridView2.Columns.Add(col);
                    this.dataGridView2[col.Index, 0].Value = m.Name;
                    foreach (var c in m.SpecLib.FirstOrDefault().Components)
                    {
                        int ridx = findRowIndex(c.Name);
                        if (ridx >= 0)
                        {
                            this.dataGridView2[col.Index, ridx].Value = "是";
                        }
                        else
                        {
                            var row = new DataGridViewRow();
                            row.Tag = c.Name;
                            row.CreateCells(this.dataGridView2, c.Name);
                            this.dataGridView2.Rows.Add(row);
                            this.dataGridView2[col.Index, row.Index].Value = "是";
                        }
                    }
                }
            }
            if (model.PLS != null)
            {
                var col = new DataGridViewTextBoxColumn()
                {
                    HeaderText = "PLS",
                    Width      = 60
                };
                this.dataGridView2.Columns.Add(col);
                this.dataGridView2[col.Index, 0].Value = model.PLS.Name;
                foreach (var m in model.PLS.SubModels)
                {
                    // this.dataGridView2[col.Index, 0].Value = m.Name;
                    var c = m.Comp;

                    int ridx = findRowIndex(c.Name);
                    if (ridx >= 0)
                    {
                        this.dataGridView2[col.Index, ridx].Value = "是";
                    }
                    else
                    {
                        var row = new DataGridViewRow();
                        row.Tag = c.Name;
                        row.CreateCells(this.dataGridView2, c.Name);
                        this.dataGridView2.Rows.Add(row);
                        this.dataGridView2[col.Index, row.Index].Value = "是";
                    }
                }
            }
            if (model.Itg != null)
            {
                var col = new DataGridViewTextBoxColumn()
                {
                    HeaderText = "集成包",
                    Width      = 60
                };
                this.dataGridView2.Columns.Add(col);
                this.dataGridView2[col.Index, 0].Value = model.Itg.Name;
                foreach (var c in model.Itg.Comps)
                {
                    // this.dataGridView2[col.Index, 0].Value = m.Name;
                    int ridx = findRowIndex(c.Name);
                    if (ridx >= 0)
                    {
                        this.dataGridView2[col.Index, ridx].Value = "是";
                    }
                    else
                    {
                        var row = new DataGridViewRow();
                        row.Tag = c.Name;
                        row.CreateCells(this.dataGridView2, c.Name);
                        this.dataGridView2.Rows.Add(row);
                        this.dataGridView2[col.Index, row.Index].Value = "是";
                    }
                }
            }

            this.dataGridView2.Columns.Add(new DataGridViewTextBoxColumn()
            {
                AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill
            });
        }