/// <summary> /// 批量比较计算 答案和数据源 选项是否都相等 /// </summary> /// <returns>都相等: True, 有错误or其中有一个不相等: False</returns> public bool Calc() { if (CheckData.IsObjectNull(Answer)) { Console.WriteLine("Answer 答案为空"); return(false); } if (CheckData.IsObjectNull(Source)) { Console.WriteLine("Source 数据源为空"); return(false); } if (CheckData.IsSizeEmpty(Answer) && CheckData.IsSizeEmpty(Source)) { return(true); } if (Answer.Count != Source.Count) { Func_lengthNotEquals(Answer.Count, Source.Count); return(false); } Func <bool> method = GetCalcWayExeMethod(); return(method()); }
private Boolean UpdateRowInfoValid() { if (!CheckData.checkBookData((string)txtTitle.EditValue, (string)txtPublisher.EditValue, (string)txtYear.EditValue, lookUpAuthor.Text)) { return(false); } else { bkr.Title = (string)txtTitle.EditValue; bkr.Publisher = (string)txtPublisher.EditValue; bkr.Year = Int32.Parse(txtYear.EditValue.ToString()); } bkr.AuthorRow = libraryDS.Author.FindById((int)lookUpAuthor.EditValue); List <LibraryDataSet.ChapterRow> listchr = libraryDS.Chapter.Where(row => row.IdBook == bkr.Id).ToList(); foreach (LibraryDataSet.ChapterRow chr in listchr) { if (!CheckData.checkChapterData(chr)) { return(false); } } return(true); }
private void Instance_OnInfoIPDM(CheckData e) { lock (this) { try { this.BeginInvoke(new Action(() => { DataRow dr = Globals.dt_100data.NewRow(); dr[0] = e.StartDate; dr[1] = e.StartTime; dr[2] = e.SN; dr[3] = e.PDCAPASS ? "OK" : "NG"; dr[4] = e.IPD_Left1; dr[5] = e.IPD_Right1; dr[6] = e.IPD_Left2; dr[7] = e.IPD_Right2; Globals.dt_100data.Rows.InsertAt(dr, 0); if (Globals.dt_100data.Rows.Count > maxcount)//有时候跳出100没有,然后变大红× { Globals.dt_100data.Rows.RemoveAt(maxcount); } Globals.csv.SaveCSV(Globals.dt_100data, PVar.ListDataIniPathIPDM);//退出的时候保存 //跑久了会出现大红× dgvHighlightRows(1); this.dataGridView1[3, 0].Style.BackColor = (e.PDCAPASS ? Mycolor.White : Mycolor.ErrorRed);//给第一行判断结果,显示颜色 })); } catch (Exception ex) { MessageBox.Show(ex.Message); } } }
public void ProcessValidationSample(SentenceData sample) { n_test_samples++; for (int iword = 1; iword < sample.CountWords() - 1; ++iword) { WordData token = sample.GetWord(iword); string wordform = token.GetWord().ToLower(); string lemma = gren.GetEntryName(token.GetEntryID()); if (IsUnknownLexem(lemma) || IsNumword(lemma)) { continue; } CheckData d = new CheckData(); d.POS_tag = tags.MatchTags(token, gren); d.wordform = wordform; d.lemma = lemma; check_data_list.Add(d); } return; }
/// <summary> /// <param name="sync"></param> arg determines if it sends the paint request using the API, and automatically checks skin ownership. Must be false for mod-added skins. /// </summary> public void PaintBlock(bool sync, IMyCubeGrid grid, Vector3I gridPosition, PaintMaterial paint, ulong originalSenderSteamId) { IMySlimBlock slim = grid.GetCubeBlock(gridPosition); if (sync) { grid.SkinBlocks(gridPosition, gridPosition, paint.ColorMask, paint.Skin?.String); if (paint.Skin.HasValue) { // check if skin was applied to alert player CheckSkinned[slim] = new CheckData(paint.Skin.Value); // add or replace SetUpdateMethods(UpdateFlags.UPDATE_AFTER_SIM, true); } } else { // NOTE getting a MySlimBlock and sending it straight to arguments avoids getting prohibited errors. MyCubeGrid gridInternal = (MyCubeGrid)grid; gridInternal.ChangeColorAndSkin(gridInternal.GetCubeBlock(gridPosition), paint.ColorMask, paint.Skin); if (paint.Skin.HasValue) { CheckSkinned.Remove(slim); // prevent alerting if skin gets changed into an always-owned one } } }
/* ================================== ~华丽的间隔线~ ================================== */ /// <summary> /// 获取URL重写信息, 根据请求URI信息 /// </summary> /// <param name="uri">用户的请求 uri 信息</param> /// <returns>获取唯一匹配的信息数据</returns> public Model.URLReWriter GetItem_RequestURI(string url_absolute_path) { if (CheckData.IsStringNull(url_absolute_path)) { return(null); } Model.URLReWriter result = this.GetModel(model => { if (CheckData.IsSizeEmpty(model.ReItems)) { return(false); } Model.URLReWriter.RegularQuery requery = null; foreach (Model.URLReWriter.RegularQuery item in model.ReItems) { if (CheckData.IsStringNull(item.Pattern)) { continue; } if (Regex.IsMatch(url_absolute_path, item.Pattern, RegexOptions.IgnoreCase)) { requery = item; break; } } if (!CheckData.IsObjectNull(requery)) { model.ReItems = new Model.URLReWriter.RegularQuery[] { requery }; return(true); } return(false); }, null); return(result); }
/// <summary> /// 数据集 转为 模型列表 /// </summary> /// <param name="ds">数据集</param> /// <returns>模型列表</returns> public M[] DataSetToModels(DataSet ds) { if (CheckData.IsSizeEmpty(ds)) { return(new M[] { }); } List <M> list = new List <M>(); foreach (DataTable dt in ds.Tables) { if (CheckData.IsSizeEmpty(dt)) { continue; } foreach (DataRow dr in dt.Rows) { M model = DataRowToModel(dr); if (!CheckData.IsObjectNull(model)) { list.Add(model); } } } return(list.ToArray()); }
/// <summary> /// 根据用户名返回一个实体 /// </summary> public Model.manager GetModel(string user_name) { if (CheckData.IsStringNull(user_name)) { return(null); } StringBuilder strSql = new StringBuilder(); strSql.Append("select top 1 * from " + databaseprefix + "manager"); strSql.Append(" where user_name=@user_name"); SqlParameter[] parameters = { new SqlParameter("@user_name", SqlDbType.NVarChar, 100) }; parameters[0].Value = user_name; DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (CheckData.IsSizeEmpty(ds)) { return(null); } if (CheckData.IsSizeEmpty(ds.Tables[0])) { return(null); } return(DataRowToModel(ds.Tables[0].Rows[0])); }
public override void OnDisabled() { base.OnDisabled(); CheckData.Clear(); ScenarioQueue.Clear(); AllScenarioTypesInAssemblies.Clear(); }
public readonly string ColName_Field_Title = defDAL.ColName_Field_Title; /* 字段中文标题 */ /// <summary> /// 获得字段 /// </summary> /// <param name="field_name"></param> /// <param name="site_id"></param> /// <param name="channel_name"></param> /// <param name="channel_id"></param> /// <returns></returns> public Model.dv_SiteChannelFieldInfo[] GetFields(string field_name, int site_id = 0, string channel_name = "", int channel_id = 0) { List <string> wheres = new List <string>(); wheres.Add(CreateSQL.WhereEqual(ColName_Field_Name, field_name)); if (site_id > 0) { wheres.Add(CreateSQL.WhereEqual(ColName_Channel_SiteID, site_id.ToString())); } if (!CheckData.IsStringNull(channel_name)) { wheres.Add(CreateSQL.WhereEqual(ColName_Channel_Name, channel_name.ToString())); } if (channel_id > 0) { wheres.Add(CreateSQL.WhereEqual(ColName_ID_ChannelInfo, channel_id.ToString())); } string sqlwhere = ConvertTool.ToString(wheres, CreateSQL.WHERE_AND); DataTable dt = base.GetList(0, sqlwhere, string.Empty).Tables[0]; if (CheckData.IsSizeEmpty(dt)) { return(new Model.dv_SiteChannelFieldInfo[] { }); } return(base.GetModelList(dt).ToArray()); }
/// <summary> /// 字符/字符串类型的基本转化过程 /// </summary> /// <param name="sourceValue"></param> /// <returns></returns> protected string CharStringTypeConvert(object sourceValue) { string result = LimitCharLengthContent(sourceValue); if (CheckData.IsStringNull(result)) { return GetDefaultValueString(); } return result; }
public CaseModel Func_Update() { return(new CaseModel() { NameSign = @"更新", ExeEvent = () => { string abs_file_path = Get_AbsFilePath(); string[] lines = ReaderLines(abs_file_path, line => { if (CheckData.IsStringNull(line)) { return null; } TestModel model = JSON.Deserialize <TestModel>(line); if (CheckData.IsObjectNull(model)) { return null; } if (model.IID % 2 == 0) { model.Name = @"正常名称"; return JSON.Serializer(model); } return line; }); File.Delete(abs_file_path); File.Create(abs_file_path).Close(); WriterLine(abs_file_path, lines); Func_Select().ExeEvent(); return true; }, }); }
public void Check(SampleData sample) { n_test_samples++; for (int iword = 1; iword < sample.morphology.Count - 1; ++iword) { SolarixGrammarEngineNET.SyntaxTreeNode token = sample.morphology[iword]; string wordform = token.GetWord().ToLower(); string lemma = gren.GetEntryName(token.GetEntryID()); if (IsUnknownLexem(lemma) || IsNumword(lemma)) { continue; } CheckData d = new CheckData(); d.POS_tag = tags.MatchTags(token, gren); d.wordform = wordform; d.lemma = lemma; check_data_list.Add(d); } return; }
/// <summary> /// Sends the parsed config nodes to the server after doing basic checks /// </summary> private void SendModulesConfigNodes() { ScenarioData.Clear(); ScenarioName.Clear(); foreach (var scenarioConfigNode in ScenariosConfigNodes) { var scenarioBytes = ConfigNodeSerializer.Serialize(scenarioConfigNode.Item2); var scenarioHash = Common.CalculateSha256Hash(scenarioBytes); if (scenarioBytes.Length == 0) { LunaLog.Log($"[LMP]: Error writing scenario data for {scenarioConfigNode.Item1}"); continue; } //Data is the same since last time - Skip it. if (CheckData.ContainsKey(scenarioConfigNode.Item1) && CheckData[scenarioConfigNode.Item1] == scenarioHash) { continue; } CheckData[scenarioConfigNode.Item1] = scenarioHash; ScenarioName.Add(scenarioConfigNode.Item1); ScenarioData.Add(scenarioBytes); } if (ScenarioName.Any()) { MessageSender.SendScenarioModuleData(ScenarioName, ScenarioData); } }
protected override void OnDisabled() { base.OnDisabled(); CheckData.Clear(); ScenarioQueue = new ConcurrentQueue <ScenarioEntry>(); AllScenarioTypesInAssemblies.Clear(); }
private void ManageNoteBooks_Load(object sender, EventArgs e) { try { noteBooks = CallAPI.GetListContent <Models.NoteBook, Models.NoteBook>("GetNoteBooks"); if (!noteBooks.Any()) { foreach (Control item in this.Controls) { item.Enabled = false; } return; } noteBooksTitles = new List <NoteBooksTitle>(); foreach (var item in noteBooks) { noteBooksTitles.Add(new NoteBooksTitle { Id = item.Id, Title = item.Subject.SubjectName + " " + item.Subject.Dept.ToString() + " " + item.Subject.Chapter + " " + item.ReleaseDate.Year }); } comboDeptSubjectYear.DataSource = noteBooksTitles; comboDeptSubjectYear.DisplayMember = "Title"; comboDeptSubjectYear.ValueMember = "Id"; } catch { CheckData.ErrorMessage(); } }
private void AddButton_Click(object sender, RoutedEventArgs e) { MainWindow mainWindow = (MainWindow)Application.Current.MainWindow; User user = mainWindow.user; string type = (string)TypeComboBox.SelectionBoxItem; if (!string.IsNullOrEmpty(DistanceTextBox.Text)) { float distance = float.Parse(CheckData.ChengeDot(DistanceTextBox.Text)); if (type != null && (DatePicker.SelectedDate != null && SaveDB.AddActivityToDB(user, type, distance, DatePicker.SelectedDate.Value, NoteTextBox.Text))) { MessageBoxResult msgBoxResult = MessageBox.Show("Added"); if (NavigationService.CanGoBack) { NavigationService.GoBack(); TypeList.RefreshMainView(); } else { InfoLabel.Content = "Bad Data"; } } else { InfoLabel.Content = "Bad Data"; } } else { InfoLabel.Content = "Bad Data"; } }
void WriteResult(HttpContext context, int errno, CheckData checkData) { CheckResult result = new CheckResult(); if (errno == 0) { result.errno = errno; result.errmsg = "查询成功"; result.data = new CheckData[1]; result.data[0] = checkData; } else if (errno == -1) { result.errno = errno; result.errmsg = "未创建角色"; } else if (errno == -2) { result.errno = errno; result.errmsg = "参数错误"; } string str = JsonHelper.ConvertToStr(result); context.Response.Write(str); }
public void LoadDatas(EncodeCollection <CheckData> datas) { for (int i = 0; i < Fields.Count; i++) { int rowindex = i + FixedRows; for (int sampleindex = 1; sampleindex <= SampleCount; sampleindex++) { CheckData sd = CheckData.FindData(datas, Order.CheckOrderID, Fields[i].ID, sampleindex); if (sd == null) { sd = CheckData.CreateItem(Order.CheckOrderID, Fields[i].ID, sampleindex); sd.SampleID = Order.SampleID; } else { if (sampleindex == 1) { if (!CheckData.UseNewstStandard) { this[rowindex, 4].Value = sd.StandardStr; } } this[rowindex, HeaderCount + sampleindex - 1].Value = sd.DataValue; } sd.ValueType = Fields[i].ValueType; var cell = this[rowindex, HeaderCount + sampleindex - 1]; SetCellColor(cell, sd); cell.Tag = sd; } } }
private Model.AjaxResult Action_Commit(HttpContext context, Model.AjaxResult jsonResult) { Model.visitor_message info_model = GetCommitInfo(); string error_msg = CheckCommitInfo(info_model); if (!CheckData.IsStringNull(error_msg)) { return(base.ErrorAjaxResult(jsonResult, error_msg)); } info_model.ipaddress = DTRequest.GetIP(); info_model.TimeAdd = DateTime.Now; BLL.visitor_message bll_vismsg = new BLL.visitor_message(); const int minute_interval = 15; int ip_repeat_count = bll_vismsg.GetIPRepeatCount(info_model.ipaddress, info_model.TimeAdd, 15); if (ip_repeat_count >= 2) { return(base.ErrorAjaxResult(jsonResult, @"您提交的太频繁了, 请" + minute_interval.ToString() + @"分钟后再提交!")); } int rid = bll_vismsg.Add(info_model); if (rid > 0) { jsonResult.Status = Model.AjaxResult.StatusValue.Success; jsonResult.Msg = @"添加记录成功"; } else { jsonResult.Status = Model.AjaxResult.StatusValue.Error; jsonResult.Msg = @"添加记录失败"; } return(jsonResult); }
public CheckWindow(CheckData Data) { InitializeComponent(); isEnded = false; work = new Worker(Data); LbNum.DataContext = work; dataCount = Data.Logs.Count; if (dataCount == 0) { TbProgress.Text = "ログを読み込ませてください。"; BtCancel.Content = "終了"; isEnded = true; return; } work.RunAsync( percentage => { PbExecute.Value = (double)percentage / (double)dataCount * 100; TbProgress.Text = (PbExecute.Value / 100).ToString("0.00%"); }, isCancel => { PbExecute.Value = (double)work.NowCount / (double)dataCount * 100; TbProgress.Text = (PbExecute.Value / 100).ToString("0.00%"); BtCancel.Content = "終了"; isEnded = true; } ); }
/// <summary> /// 更新 /// </summary> /// <param name="kos">需要更新的键值</param> /// <param name="where">查询条件</param> /// <returns>是否成功 是:True 否:False</returns> public override bool Update(KeyObject[] kos, Func <M, bool> where) { if (CheckData.IsSizeEmpty(kos)) { return(true); } List <M> nowlist = new List <M>(Select(0, null, null)); if (CheckData.IsObjectNull(where)) { where = model => true; } Dictionary <string, ShineUponInfo> dic = this.Parser.GetDictionary(); for (var i = nowlist.Count - 1; i >= 0; i--) { M model = nowlist[i]; if (where (model)) { foreach (KeyObject item in kos) { if (!CheckData.IsStringNull(item.Key) && dic.ContainsKey(item.Key)) { this.Parser.SetValue_Object(dic[item.Key], model, item.Value); } } nowlist[i] = model; } } return(this.Insert(nowlist.ToArray(), true)); }
public CaseModel Func_ColumnModelParser() { return(new CaseModel() { NameSign = @"列", ExeEvent = () => { ColumnModelParser <T> parser = new ColumnModelParser <T>(); KeyString[] keys = T.Answer_ColumnInfos(); ColumnInfo[] columns = parser.GetList(); return new VerifyIList <KeyString, ColumnInfo>(CalcWayEnum.DoubleCycle) { Answer = keys, Source = columns, Func_isEquals = (item, info) => { return item.Key == info.Name && item.Key == info.Property.Name && item.Value == info.Explain.Text && !CheckData.IsObjectNull(info.Attribute); }, Func_lengthNotEquals = (len_key, len_column) => { Console.WriteLine("keys.Length: {0} columns.Length: {1} 不相等", len_key, len_column); }, Func_notFind = (item) => { Console.WriteLine("Key: {0} Value: {1} 没找到", item.Key, item.Value); }, }.Calc(); }, }); }
private void tsbCommit_Click(object sender, EventArgs e) { if (ReturnValue.ShowYesNo("是否确定提交数据,提交成功后数据不能更改,检验工单状态将设置为[已完成]") == System.Windows.Forms.DialogResult.Yes) { if (_sampleOrder != null) { _sampleOrder.CheckOrderState = CheckOrderStateEnum.Complete; _sampleOrder.ActualCheckDate = DateTime.Now.ToString(EncodeConst.DateTimeFormat); if (User.CurrentUser != null) { _sampleOrder.ActualInspector = User.CurrentUser.ParamName; } _sampleOrder.State = DataState.Changed; _sampleOrder.FinishedCheckItemString = CheckData.DataCommitSetting(_sampleOrder.SampleID); ReturnValue rv = Encode.EncodeData.SaveDatas <CheckOrder>(new EncodeCollection <CheckOrder>(_sampleOrder)); ReturnValue.ShowMessage(rv); if (rv.Success) { //_sampleOrderGrid.ReloadRow(1); SetOrderState(); } } else { ReturnValue.ShowMessage("检验工单对象不存在"); } } }
public void FixedUpdate() { var now = OneServer.NowTime; DeltaTime = (float)(now - lastUpdateTime).TotalSeconds; if (updateIndex++ % 10 == 0) { // 间隔 30/10 *1000 ms的间隔向服务器通知一次当前的位置 var data = new CheckData { Postion = new Vector3(PlayerShip.Postion.x + 200, PlayerShip.Postion.y, PlayerShip.Postion.z + 200), Rotation = PlayerShip.GameObject.transform.rotation, Speed = PlayerShip.Speed, SpeedUpTypes = PlayerShip.SpeedUpType, Time = now, RotationRate = PlayerShip.RotationRate, }; notifyData.Enqueue(data); } else { // 每隔3帧向模拟的npc船只传递一次数据 // 模拟网络延迟 if (notifyData.Count > 1 && updateIndex % 3 == 0) { var data = notifyData.Dequeue(); npcShip1.UpdateNetPostion(data); } } //npcShip1.UpdateShip(); }
private void btnDeAvtiveNoteBook_Click(object sender, EventArgs e) { try { if (Convert.ToInt32(txtUsed.Text) > 0) { int notebookId = (int)comboDeptSubjectYear.SelectedValue; Models.NoteBook noteBook = CallAPI.GetObjectContent <Models.NoteBook, Models.NoteBook>("DeActiveNoteBook", notebookId.ToString()); if (noteBook == null) { MessageBox.Show("Error in connection", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show("Done", "Done", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("this notebooks was deactivated", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { CheckData.ErrorMessage(); } }
/// <summary> /// 检查某个 section 下的某个 key-value 是否存在 /// </summary> /// <param name="section">部分名称</param> /// <param name="key">键名称</param> /// <returns>是否存在</returns> public bool IsExistsValue(string section, string key) { //StringCollection keys = GetKeys(section); //return keys.Contains(key); string value = ReadString(section, key); return(!CheckData.IsStringNull(key)); }
public override object InputConvert(object sourceValue, ColumnItemModel colmodel) { if (CheckData.IsObjectNull(sourceValue) || !CheckData.IsDouble(sourceValue)) { return(GetDefaultValueString()); } return(sourceValue.ToString()); }
/* ================================== ~华丽的间隔线~ ================================== */ public string GetSiteNamePathFolder(string root) { if (CheckData.IsStringNull(root)) { return(string.Format("/{0}", this.SelfSiteName)); } return(string.Format("/{0}/{1}", PathHelp.ToPathSymbol(root), PathHelp.ToPathSymbol(this.SelfSiteName))); }
public IEnumerable <ValidationResult> Validate(ValidationContext validationContext) { CheckData.Name(nameof(this.name), name, 3, 50); CheckData.Name(nameof(this.surName), surName, 3, 50); var errors = new List <ValidationResult>(); return(errors); }