private void ShowData(IEnumerable data) { ListViewParent.ItemsSource = data; ListViewParent.ScrollIntoView(ListViewParent.Items[0]); new Task(() => GlobalTool.CloseDialog(this)).Start(); }
private static MySqlParameter[] MakeUpdateParameter(Project project) { MySqlParameter p_id = new MySqlParameter("_id", MySqlDbType.Int32); p_id.Value = project.Id; MySqlParameter p_name = new MySqlParameter("_name", MySqlDbType.String); p_name.Value = project.Name; MySqlParameter p_mode = new MySqlParameter("_mode", MySqlDbType.Int32); p_mode.Value = project.Mode; MySqlParameter p_type = new MySqlParameter("_type", MySqlDbType.Int32); p_type.Value = project.Schema; MySqlParameter p_time = new MySqlParameter("_time", MySqlDbType.Double); p_time.Value = GlobalTool.ConvertDateTimeInt(DateTime.Now); MySqlParameter p_data = new MySqlParameter("_data", MySqlDbType.Blob); p_data.Value = project.Serialize(); MySqlParameter p_share = new MySqlParameter("_share", MySqlDbType.Byte); p_share.Value = project.Share; MySqlParameter p_remark = new MySqlParameter("_remark", MySqlDbType.String); p_remark.Value = project.Remark; MySqlParameter[] pars = new MySqlParameter[] { p_id, p_name, p_mode, p_type, p_time, p_data, p_share, p_remark }; return(pars); }
private void CheckBox_Checked(object sender, RoutedEventArgs e) { GlobalTool.ChangeParentCheckBox(sender); CheckBox cb = sender as CheckBox; if (cb.IsChecked == false) { return; } string senderName = cb.Name; switch (senderName) { case "CheckBoxColor": CheckBoxGene.IsChecked = false; ComboBoxA1.SelectedIndex = 0; ComboBoxA2.SelectedIndex = 0; ComboBoxA3.SelectedIndex = 0; ComboBoxA4.SelectedIndex = 0; break; case "CheckBoxGene": CheckBoxColor.IsChecked = false; ComboBoxColor.SelectedIndex = 0; break; } }
public static DataTable Search(string input) { try { DbManager dm = DbManager.Ins; MySqlParameter p_input = new MySqlParameter("_input", MySqlDbType.String); p_input.Value = input; MySqlParameter[] pars = new MySqlParameter[] { p_input }; DataTable dt = dm.ExecuteProcQuery("Material_SearchWithKeyword", pars); if (dt == null) { return(null); } dt.Columns.Add("modify_time_"); foreach (DataRow dr in dt.Rows) { dr["modify_time_"] = GlobalTool.ConvertIntDateTime((double)dr["modify_time"]); } dt.Columns.Remove("modify_time"); return(dt); } catch (Exception) { return(null); } }
private void ButtonSearch_Click(object sender, RoutedEventArgs e) { if (null == GlobalTool.AllEmojis || new List <MyEmoji>() == GlobalTool.AllEmojis) { return; } if (string.IsNullOrWhiteSpace(TextBoxSearch.Text)) { GlobalTool.BarMsg("请输入关键字"); return; } ListShowEmoji = new List <MyEmoji>(); foreach (var emoji in GlobalTool.AllEmojis) { if (emoji.Note.Contains(TextBoxSearch.Text.Trim())) { ListShowEmoji.Add(emoji); } } if (0 == ListShowEmoji.Count) { GlobalTool.BarMsg("无结果"); return; } ComboBoxChoose.SelectedIndex = 0; ChangeListItemSource(); }
public static DataTable Search(string keyword) { try { DbManager dm = DbManager.Ins; MySqlParameter p_input = new MySqlParameter("_keyword", MySqlDbType.String); p_input.Value = keyword; MySqlParameter[] pars = new MySqlParameter[] { p_input }; DataTable dt = dm.ExecuteProcQuery("Project_SearchWithKeyword", pars); if (dt == null) { return(null); } dt.Columns.Add("time_", typeof(DateTime)); dt.Columns.Add("mode_", typeof(string)); dt.Columns.Add("type_", typeof(string)); foreach (DataRow dr in dt.Rows) { double t = (double)dr["time"]; CalculationMode mode = (CalculationMode)dr["mode"]; GeometrySchema type = (GeometrySchema)dr["type"]; dr["time_"] = GlobalTool.ConvertIntDateTime(t); dr["mode_"] = (mode == CalculationMode.Temperature?"温度":"厚度"); dr["type_"] = (type == GeometrySchema.Plate ? "平板" : "圆筒"); } dt.Columns.Remove("mode"); dt.Columns.Remove("type"); return(dt); } catch (Exception) { return(null); } }
/// <summary> /// 执行一条计算查询结果语句,返回查询结果(object)。 /// </summary> /// <param name="SQLString">计算查询结果语句</param> /// <returns>查询结果(object)</returns> public object ExecuteScalar(string SQLString, params MySqlParameter[] paras) { using (MySqlConnection connection = new MySqlConnection(ConnStr)) { using (MySqlCommand cmd = new MySqlCommand(SQLString, connection)) { try { connection.Open(); cmd.Parameters.AddRange(paras); object obj = cmd.ExecuteScalar(); if ((Object.Equals(obj, null)) || (Object.Equals(obj, System.DBNull.Value))) { return(null); } else { return(obj); } } catch (MySql.Data.MySqlClient.MySqlException e) { connection.Close(); GlobalTool.LogError("Datebase Manager", e.Message, true); return(null); } } } }
/// <summary> /// 标题栏按钮事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void TitlebarButton_Click(object sender, RoutedEventArgs e) { var mySender = sender as Button; switch (mySender.Name) { case "ButtonTitlebarMin": { this.WindowState = WindowState.Minimized; } break; case "ButtonTitlebarMax": { if (this.ActualWidth == SystemParameters.WorkArea.Width && this.ActualHeight == SystemParameters.WorkArea.Height) { WindowNormal(); } else { WindowMax(); } } break; case "ButtonTitlebarClose": { GlobalTool.CloseApp(); } break; } }
public static User LoadWithName(string _name) { try { DbManager dm = DbManager.Ins; MySqlParameter p_index = new MySqlParameter("_name", MySqlDbType.String); p_index.Value = _name; MySqlParameter[] pars = new MySqlParameter[] { p_index }; DataTable dt = dm.ExecuteProcQuery("User_LoadWithName", pars); DataRow dr = dt.Rows[0]; int id = (int)dr["id"]; string login_id = (string)dr["login_id"]; string login_password = (string)dr["login_password"]; string name = (string)dr["name"]; string department = (string)dr["department"]; int level = (int)dr["level"]; User u = new User(id, login_id, login_password, name, department); u.Level = level; return(u); } catch (Exception e) { GlobalTool.LogError("DBUserAdapter.LoadWithName", e.Message, true); return(null); } }
public static DataTable Search(string keyword, int ownerid, bool share) { try { DbManager dm = DbManager.Ins; MySqlParameter p_input = new MySqlParameter("_keyword", MySqlDbType.String); p_input.Value = keyword; MySqlParameter p_ownerid = new MySqlParameter("_ownerid", MySqlDbType.Int32); p_ownerid.Value = ownerid; MySqlParameter p_share = new MySqlParameter("_share", MySqlDbType.Byte); p_share.Value = share; MySqlParameter[] pars = new MySqlParameter[] { p_input, p_ownerid, p_share }; DataTable dt = dm.ExecuteProcQuery("Project_SearchWithKeywordOwnerShare", pars); if (dt == null) { return(null); } dt.Columns.Add("time_", typeof(DateTime)); foreach (DataRow dr in dt.Rows) { double t = (double)dr["time"]; dr["time_"] = GlobalTool.ConvertIntDateTime(t); } dt.Columns.Remove("time"); return(dt); } catch (Exception) { return(null); } }
public static Material LoadWithId(int index) { try { DbManager dm = DbManager.Ins; MySqlParameter p_index = new MySqlParameter("_id", MySqlDbType.Int32); p_index.Value = index; MySqlParameter[] pars = new MySqlParameter[] { p_index }; DataTable dt = dm.ExecuteProcQuery("Material_LoadWithId", pars); DataRow dr = dt.Rows[0]; string name = (string)dr["name"]; int ownerid = (int)dr["owner"]; string code = (string)dr["code"]; string use_for = (string)dr["use_for"]; DateTime create_time = GlobalTool.ConvertIntDateTime((double)dr["create_time"]); DateTime modify_time = GlobalTool.ConvertIntDateTime((double)dr["modify_time"]); double density = (double)dr["density"]; Boolean tc_is_fun = Boolean.Parse(dr["tc_is_fun"].ToString()); Boolean sh_is_fun = Boolean.Parse(dr["sh_is_fun"].ToString()); string s_tc_list = (string)dr["tc_list"]; string s_sh_list = (string)dr["sh_list"]; List <RefValue> tc_list = StrToRefvalList(s_tc_list); List <RefValue> sh_list = StrToRefvalList(s_sh_list); string remark = (string)dr["remark"]; bool share = bool.Parse(dr["share"].ToString()); User owner = DBUserAdapter.LoadWithId(ownerid); Material mat = new Material(index, name, owner, ownerid, code, use_for, create_time, modify_time, density, remark, tc_list, sh_list, tc_is_fun, sh_is_fun, share); return(mat); } catch (Exception) { return(null); } }
public void InstallGlobalTool(GlobalTool globalTool) { var arguments = BuildArgumentString(globalTool); Console.WriteLine($"Installing tool {globalTool.Id}"); var output = _processManager.RunProcess("dotnet", arguments); WriteOuput(output); }
private void ShowData(IEnumerable data) { ListViewChildren.ItemsSource = data; ListViewChildren.ScrollIntoView(ListViewChildren.Items[0]); Task c = new Task(() => GlobalTool.CloseDialog(this)); c.Start(); }
private void Button_Click(object sender, RoutedEventArgs e) { string senderName = (sender as Button).Name; switch (senderName) { case "ButtonSearch": { if (null == GlobalTool.AllEmojis || new List <MyEmoji>() == GlobalTool.AllEmojis) { return; } if (string.IsNullOrWhiteSpace(TextBoxSearch.Text)) { FlyoutBase.ShowAttachedFlyout(TextBoxSearch); return; } var newList = new List <MyEmoji>(); foreach (var emoji in GlobalTool.AllEmojis) { if (emoji.Note.Contains(TextBoxSearch.Text.Trim())) { newList.Add(emoji); } } if (0 == newList.Count) { GlobalTool.ShowDialog("注意", "无搜索结果!"); } else { ListShowEmoji = new List <MyEmoji>(); foreach (var emoji in newList) { ListShowEmoji.Add(emoji); } ComboBoxChoose.SelectedIndex = 0; ChangeListItemSource(); } } break; case "ButtonCopy": { DataPackage package = new DataPackage(); package.SetText(GlobalTool.SelectedEmoji.Text); Clipboard.SetContent(package); FlyoutBase.ShowAttachedFlyout(ButtonCopy); } break; case "ButtonSave": //SaveWindow(); //使用Xaml保存PNG的方法,现弃用,但代码保留以备不时之需。 FileHelper.ExportPngAsync(); //使用Win2D保存PNG,方法抄自Edi Wang。 break; } }
private void SchedulerWork() { Task a = new Task(() => GlobalTool.OpenDialogProgress(this, "加载中")); Task b = new Task(B_Click); a.Start(); a.Wait(); b.Start(); b.Wait(); }
private void ShowEmoji() { GlobalTool.GetEmoji(); foreach (var i in GlobalTool.AllGroup) { ComboBoxChoose.Items.Add(i); } ComboBoxChoose.SelectionChanged += GroupChanged; ComboBoxChoose.SelectedIndex = 1; }
private async void StartFunc() { if (!await GlobalTool.GetEmoji(GlobalTool.EmojiFrom.Local)) { return; } foreach (var i in GlobalTool.AllGroups) { ComboBoxChoose.Items.Add(i); } ComboBoxChoose.SelectionChanged += ComboBox_SelectionChanged; ComboBoxChoose.SelectedIndex = 1; }
private GlobalTools ParseListOutput(ProcessOutput output) { var gts = new GlobalTools(); if (output.StandardOutLines.Count > 2) { for (var i = 2; i < output.StandardOutLines.Count; i++) { var line = output.StandardOutLines[i]; if (line != null) { var id = ""; var version = ""; var command = ""; var current = 0; var valid = false; foreach (var ch in line) { if (ch == ' ' && valid) { current++; valid = false; } else if (ch != ' ') { valid = true; if (current == 0) { id = id + ch; } else if (current == 1) { version = version + ch; } else if (current == 2) { command = command + ch; } } } var gt = new GlobalTool(); gt.Id = id; gt.Version = version; gts.Tools.Add(gt); } } } return(gts); }
public override void OnInitialization() { base.OnInitialization(); mEntityRoot = GameObject.Find("EntityRoot").transform; for (int i = 0; i < defineEntityNames.Count; i++) { if (!mDefineEntity.ContainsKey(defineEntityNames[i])) { mDefineEntity.Add(defineEntityNames[i], defineEntityGos[i]); } } //初始化相关的数据 并且将指定的类型均已添加到实体字典中 List <Type> types = GlobalTool.GetRuntimeTypes(); foreach (Type t in types) { if (!t.IsSubclassOf(typeof(Entity))) { continue; } System.Object[] objs = t.GetCustomAttributes(true); EntityInfoAttribute att = objs[0] as EntityInfoAttribute; if (att != null) { mEntities.Add(t, new List <Entity> ()); //对放实体对象的容器 GameObject group = GameObjectTool.NewGameObject(t.Name + "_[Group]", mEntityRoot.gameObject); mEntityGroup[t] = group; //按照实体的类型将队列初始化 mObjectPool[t] = new Queue <GameObject> (); this.d("+++++", "添加实体类型" + t.GetType(), false); } else { this.e("damon", "未定义实体资源属性"); } } //实体的生命周期 foreach (List <Entity> list in mEntities.Values) { foreach (Entity e in list) { e.OnAwake(); } } }
public static DataTable LoadAll() { try { DbManager dm = DbManager.Ins; DataTable dt = dm.ExecuteProcQuery("User_LoadAll", new MySqlParameter[] { }); return(dt); } catch (Exception e) { GlobalTool.LogError("DBUserAdapter.LoadWithAll", e.Message, true); return(null); } }
public override void OnInitialization() { base.OnInitialization(); List <Type> list = GlobalTool.GetRuntimeTypes(); foreach (Type t in list) { if (t.IsSubclassOf(typeof(BaseDateSet))) { mDateSet.Add(t, new List <BaseDateSet> ()); this.d("damon", t.FullName, false); } } }
public static bool Update(User user) { try { DbManager dm = DbManager.Ins; MySqlParameter[] pars = MakeUpdateParameter(user); dm.ExecuteProcNonQuery("User_Update", pars); return(true); } catch (Exception e) { GlobalTool.LogError("DBUserAdapter.Update", e.Message, true); return(false); } }
public override void OnInitialization() { base.OnInitialization(); List <Type> types = GlobalTool.GetRuntimeTypes(); foreach (Type t in types) { if (t.IsSubclassOf(typeof(BaseEvent))) { if (!mEvents.ContainsKey(t)) { mEvents.Add(t, null); } } } }
public static bool IncLoginCount(int _id) { try { DbManager dm = DbManager.Ins; MySqlParameter p_id = new MySqlParameter("_id", MySqlDbType.Int32); p_id.Value = _id; MySqlParameter[] pars = new MySqlParameter[] { p_id }; dm.ExecuteProcNonQuery("User_IncLoginCount", pars); return(true); } catch (Exception e) { GlobalTool.LogError("DBUserAdapter.IncLoginCount", e.Message, true); return(false); } }
/// <summary> /// 执行Update,Delete,Insert操作 /// </summary> /// <param name="sql"></param> /// <returns></returns> /// public int ExecuteNonquery(string sql, params MySqlParameter[] paras) { try { using (MySqlConnection con = new MySqlConnection(ConnStr)) { MySqlCommand cmd = new MySqlCommand(sql, con); cmd.Parameters.AddRange(paras); con.Open(); return(cmd.ExecuteNonQuery()); } } catch (MySql.Data.MySqlClient.MySqlException e) { GlobalTool.LogError("Datebase Manager", e.Message, true); return(0); } }
private static MySqlParameter[] MakeInsertParameter(Material mat) { MySqlParameter p_name = new MySqlParameter("_name", MySqlDbType.String); p_name.Value = mat.Name; MySqlParameter p_owner = new MySqlParameter("_owner", MySqlDbType.Int32); p_owner.Value = mat.OwnerId; MySqlParameter p_code = new MySqlParameter("_code", MySqlDbType.String); p_code.Value = mat.Code; MySqlParameter p_use_for = new MySqlParameter("_use_for", MySqlDbType.String); p_use_for.Value = mat.Use_for; MySqlParameter p_create_time = new MySqlParameter("_create_time", MySqlDbType.Double); p_create_time.Value = GlobalTool.ConvertDateTimeInt(mat.Create_time); MySqlParameter p_modify_time = new MySqlParameter("_modify_time", MySqlDbType.Double); p_modify_time.Value = GlobalTool.ConvertDateTimeInt(mat.Modify_time); MySqlParameter p_density = new MySqlParameter("_density", MySqlDbType.Double); p_density.Value = mat.Density; MySqlParameter p_remark = new MySqlParameter("_remark", MySqlDbType.String); p_remark.Value = mat.Remark; MySqlParameter p_tc_is_fun = new MySqlParameter("_tc_is_fun", MySqlDbType.Byte); p_tc_is_fun.Value = mat.TcIsFun; MySqlParameter p_sh_is_fun = new MySqlParameter("_sh_is_fun", MySqlDbType.Byte); p_sh_is_fun.Value = mat.ShIsFun; MySqlParameter p_tc_list = new MySqlParameter("_tc_list", MySqlDbType.String); p_tc_list.Value = RefvalListToStr(mat.TCs); MySqlParameter p_sh_list = new MySqlParameter("_sh_list", MySqlDbType.String); p_sh_list.Value = RefvalListToStr(mat.SHs); MySqlParameter p_share = new MySqlParameter("_share", MySqlDbType.Byte); p_share.Value = mat.Share; MySqlParameter[] pars = new MySqlParameter[] { p_name, p_owner, p_code, p_use_for, p_create_time, p_modify_time, p_density, p_remark, p_tc_is_fun, p_sh_is_fun, p_tc_list, p_sh_list, p_share }; return(pars); }
private DbManager() { /* * string s1 = GlobalTool.GetConnectStringsConfig(); * string s2 = GlobalTool.GetConnectStringsLanConfig(); * MySqlConnection con = new MySqlConnection(s1); * try * { * con.Open(); * connStr = s1; * con.Close(); * } * catch(Exception) * { * connStr = s2; * } */ connStr = GlobalTool.GetConnectStringsLanConfig(); }
/// <summary> /// 获得单个结果集时使用该方法,返回DataTable对象。 /// </summary> /// <param name="sql"></param> /// <returns></returns> public DataTable ExcuteDataTable(string sql, params MySqlParameter[] paras) { try { using (MySqlConnection con = new MySqlConnection(ConnStr)) { MySqlDataAdapter sqlda = new MySqlDataAdapter(sql, con); sqlda.SelectCommand.Parameters.AddRange(paras); DataTable dt = new DataTable(); sqlda.Fill(dt); return(dt); } } catch (MySql.Data.MySqlClient.MySqlException e) { GlobalTool.LogError("Datebase Manager", e.Message, true); return(null); } }
public static bool SetLastLoginTimeNow(int _id) { try { DbManager dm = DbManager.Ins; MySqlParameter p_id = new MySqlParameter("_id", MySqlDbType.Int32); p_id.Value = _id; MySqlParameter p_time = new MySqlParameter("_time", MySqlDbType.String); p_time.Value = DateTime.Now.ToString(); MySqlParameter[] pars = new MySqlParameter[] { p_id, p_time }; dm.ExecuteProcNonQuery("User_SetLastLoginTime", pars); return(true); } catch (Exception e) { GlobalTool.LogError("DBUserAdapter.SetLastLoginTime", e.Message, true); return(false); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (null == GlobalTool.SelectedEmoji || new MyEmoji() == GlobalTool.SelectedEmoji) { return; } string senderName = (sender as Button).Name; switch (senderName) { case "ButtonCopy": Clipboard.SetDataObject(GlobalTool.SelectedEmoji.Text); GlobalTool.BarMsg("已复制到剪贴板"); break; case "ButtonSave": GlobalTool.WinEmoji = new WindowEmoji(); GlobalTool.WinEmoji.Show(); break; } }