private void BindDbConfig() { string str = IniConfigHelper.ReadDefaultDBInfo(); string currentName = ""; foreach (DbConfigInfo dc in _dbConfigList) { if (!_dbConfigDic.ContainsKey(dc.DbConfigName)) { _tscbDbConfig.Items.Add(dc.DbConfigName); _dbConfigDic.Add(dc.DbConfigName, dc); } if (dc.DbId == str) { currentName = dc.DbConfigName; } } if (_dbConfigList != null && _dbConfigList.Count > 0) { if (string.IsNullOrEmpty(_tscbDbConfig.Text)) { if (string.IsNullOrEmpty(currentName)) { _tscbDbConfig.Text = _dbConfigList[0].DbConfigName; } else { _tscbDbConfig.Text = currentName; } } } }
private void GenCsharpPage(DataRow[] drTable) { var gen = new GenCsharpPage(); gen.cmc = IniConfigHelper.getDefaultObject(); process(drTable, gen); }
private void GenwsService(DataRow[] drTable) { var gen = new GenJavaWS(); gen.cmc = IniConfigHelper.getDefaultObject(); process(drTable, gen); }
private void btnSave_Click(object sender, EventArgs e) { bool status = true; string message = ""; if (isChanged) { foreach (var dbConfigInfo in dbConfigInfos) { status = IniConfigHelper.WriteDBInfo(dbConfigInfo, ref message); if (!status) { break; } } if (status) { if (DBConfigInfoChanged != null) { DBConfigInfoChanged(); } } } if (status) { Close(); } else { MessageBox.Show(this, "保存失败[" + message + "]", @"提示"); } }
private void GenDALServer(DataRow[] drTable) { var gen = new GenCsharpDALWebService(); gen.cmc = IniConfigHelper.getDefaultObject(); process(drTable, gen); }
private void init() { isInit = true; clear(); javaCodeGenConfigs.Clear(); clearCbUI(); addItem(""); JavaCodeGenConfig config = IniConfigHelper.getDefaultObject(); if (config != null) { setUI(config); setCbText(config.DisplayName); } IList <JavaCodeGenConfig> configs = IniConfigHelper.ReadDBInfo(); foreach (JavaCodeGenConfig jcc in configs) { if (!javaCodeGenConfigs.ContainsKey(jcc.DisplayName)) { javaCodeGenConfigs.Add(jcc.DisplayName, jcc); addItem(jcc.DisplayName); } } isInit = false; }
public void GetDbConfigList() { _dbConfigList.Clear(); _tscbDbConfig.Items.Clear(); _dbConfigDic.Clear(); _dbConfigList = IniConfigHelper.ReadDBInfo(); BindDbConfig(); }
protected override void load() { configInfo = IniConfigHelper.ReadConfigInfo(); if (configInfo.Show) { AddContextMenu(); } }
private void FrmExportHistory_Load(object sender, EventArgs e) { string str = new IniConfigHelper().ReadIniData("已选曲线", "selectTrend", "", CommonMethods.FilePath); sqlArray = str.Split(','); if (sqlArray.Length == 1 && sqlArray[0] == "@") { return; } HeaderTextList.Add("日期时间"); sqlString.Add("InsertTime"); for (int i = 0; i < sqlArray.Length; i++) { HeaderTextList.Add(CommonMethods.TrendName[sqlArray[i]].Description); sqlString.Add((CommonMethods.TrendName[sqlArray[i]].Name)); } for (int i = 0; i < HeaderTextList.Count; i++) { DataGridViewTextBoxColumn dgvc = new DataGridViewTextBoxColumn(); dgvc.HeaderText = HeaderTextList[i]; dgvc.ReadOnly = true; dgvc.Width = 150; dgvc.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; dgvc.DataPropertyName = sqlString[i]; dgvc.Name = sqlString[i]; this.DgvExport.Columns.Add(dgvc); } //拼接SQL语句 StringBuilder sb = new StringBuilder(); sb.Append("select "); string str1 = string.Join(",", sqlString.ToArray()); sb.Append(str1); sb.Append(" from TemperaTureMeasure where 1=1 and InsertTime between '{0}' and '{1}'"); string sql = string.Format(sb.ToString(), dtpStart.Text.Trim(), dtpEnd.Text.Trim()); DataTable dt = SQLHelper.GetDataSet(sql).Tables[0]; //如何把DataTable赋值到DataGridView int index = this.DgvExport.Rows.Add(); DgvExport.DataSource = null; DgvExport.DataSource = dt; }
void PriceFeederMonitorUI_Load(object sender, EventArgs e) { logHelper = new TextLogHelper(txtMsg, this, ip, port); configInfo = IniConfigHelper.ReadConfigInfo();//获取配置文件 ConnectionServer(); }
public void Save() { bool status = false; string msg = ""; CsharpCodeGenConfig tem = getConfigObject(); IniConfigHelper.writeDefaultDBInfo(tem); if (CsharpCodeGenConfig.Count > 0) { if (CsharpCodeGenConfig.ContainsKey(cbObject.Text)) { string id = CsharpCodeGenConfig[cbObject.Text].Id; bool isDelete = CsharpCodeGenConfig[cbObject.Text].IsDelete; CsharpCodeGenConfig[cbObject.Text] = null; CsharpCodeGenConfig[cbObject.Text] = tem; CsharpCodeGenConfig[cbObject.Text].Id = id; CsharpCodeGenConfig[cbObject.Text].IsDelete = isDelete; } else if (!string.IsNullOrEmpty(cbObject.Text)) { CsharpCodeGenConfig.Add(cbObject.Text, tem); addItem(cbObject.Text); } foreach (string key in CsharpCodeGenConfig.Keys) { status = IniConfigHelper.WriteDBInfo(CsharpCodeGenConfig[key], ref msg); if (!status) { throw new Exception(msg); } else { status = false; msg = ""; } } } else { if (!string.IsNullOrEmpty(tem.DisplayName)) { status = IniConfigHelper.WriteDBInfo(tem, ref msg); if (!status) { throw new Exception(msg); } else { CsharpCodeGenConfig.Add(tem.DisplayName, tem); addItem(tem.DisplayName); } } } }
private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { FolderBrowserDialog dlg = new FolderBrowserDialog(); dlg.ShowDialog(); if (dlg.SelectedPath != "") { IniConfigHelper.SetValue("RemoteFile", "SavaFilePath", dlg.SelectedPath, Path.Combine(Environment.CurrentDirectory, "SiMayConfig.ini")); txtSavePath.Text = dlg.SelectedPath; } }
public static void processExcel(Excel.Application application) { ConfigInfo configInfo = IniConfigHelper.ReadConfigInfo();//获取配置文件 Excel.Workbook book = (Excel.Workbook)application.ActiveWorkbook; string path = configInfo.OutPath; string fileName = configInfo.OutFileName; string[] strF = configInfo.OutFileName.Split(new char[] { '{', '}' }); if (strF.Length == 3) { fileName = string.Format("{0}{1}{2}", strF[0], DateTime.Now.ToString(strF[1]), strF[2]); LogHelper.Info("输出的文件名:" + fileName); } FileHelper.Delete(path, fileName); FileHelper.Write(path, fileName, configInfo.Header, true); List <string> list = new List <string>(configInfo.RowsCount); for (int i = 0; i < configInfo.RowsCount; i++) { string row = configInfo.Rows[i]; string[] strs = row.Split(new char[] { ',' }); foreach (string str in strs) { string temp = str.Trim(); if (temp.IndexOf("}") > 0) { string[] str1s = temp.Replace("{", "").Replace("}", "").Split(new char[] { '.' }); Excel.Worksheet sheet = (Excel.Worksheet)book.Sheets[int.Parse(str1s[0])]; Excel.Range source = sheet.get_Range(str1s[1], str1s[1]); string value = source.Value + ""; list.Add(value); if (str1s.Length >= 3 && !string.IsNullOrEmpty(value)) { int dataScale = 0; decimal d = 0; if (int.TryParse(str1s[2], out dataScale) && decimal.TryParse(value, out d)) { value = string.Format("{0:N" + dataScale + "}", d); } } row = row.Replace(temp, value); } } FileHelper.Write(path, fileName, row, true); } //发邮件 if (templist(list) == true) { Mail.sends(); LogHelper.Info("邮件发送成功"); } }
public override string GetConfig(string key) { if (!AppConfig.ContainsKey(key) && _defaultConfig.ContainsKey(key)) { AppConfig[key] = IniConfigHelper.GetValue("SiMayConfig", key, _defaultConfig[key], _filePath); } string val; if (AppConfig.TryGetValue(key, out val)) { return(val); } else { return(null); } }
private void FrmHistoryTrend_Load(object sender, EventArgs e) { chartHistory.AxisX.MajorGridCount = 4; string str = new IniConfigHelper().ReadIniData("已选曲线", "selectTrend", "", CommonMethods.FilePath); chartHistory.DisplayPoints = Convert.ToInt32(new IniConfigHelper().ReadIniData("历史显示点数", "Points", "", CommonMethods.FilePath)); sqlArray = str.Split(','); if (sqlArray.Length == 1 && sqlArray[0] == "@") { return; } for (int i = 0; i < sqlArray.Length; i++) { listParameter.Add(CommonMethods.TrendName[sqlArray[i]].Name); } }
private void init() { isInit = true; clear(); CsharpCodeGenConfig.Clear(); string str = IniConfigHelper.ReadDefaultDBInfo(); IList <CsharpCodeGenConfig> tem = IniConfigHelper.ReadDBInfo(); CsharpCodeGenConfig.Clear(); clearCbUI(); addItem(""); foreach (CsharpCodeGenConfig config in tem) { if (!CsharpCodeGenConfig.ContainsKey(config.DisplayName)) { CsharpCodeGenConfig.Add(config.DisplayName, config); addItem(config.DisplayName); } } if (string.IsNullOrEmpty(str)) { clear(); } else { if (CsharpCodeGenConfig.Count > 0) { foreach (string key in CsharpCodeGenConfig.Keys) { if (key.Equals(str)) { CsharpCodeGenConfig[key].IsDelete = false; setUI(CsharpCodeGenConfig[key]); setCbText(CsharpCodeGenConfig[key].DisplayName); } } } } isInit = false; }
public override bool SetConfig(string key, string value) { AppConfig[key] = value; IniConfigHelper.SetValue("SiMayConfig", key, value, _filePath); return(true); }
private void ConfigForm_Load(object sender, EventArgs e) { dbConfigInfos = IniConfigHelper.ReadDBInfo(); createTreeNode(); }
private void LoadDbInfoBySync(bool reloadDb) { _isLoadSuccess = false; DbConfigInfo dbConfigInfo = GetCurenctDbConfigInfo(); IniConfigHelper.WriteDefaultDBInfo(dbConfigInfo); string TargetEncoding = ""; string OriginalEncoding = ""; if (dbConfigInfo != null) { try { #region 贡献当前数据库配置信息 TargetEncoding = dbConfigInfo.DbEncoder; OriginalEncoding = EncodingHelper.OriginalEncoding; registerObject(PluginShareHelper.TargetEncoding, TargetEncoding); registerObject(PluginShareHelper.OriginalEncoding, OriginalEncoding); registerObject(PluginShareHelper.DBCurrentDBName, dbConfigInfo.DbConfigName); registerObject(PluginShareHelper.DBCurrentDBConnectionString, dbConfigInfo.ConnectionString.Trim('"')); registerObject(PluginShareHelper.DBCurrentDBType, dbConfigInfo.DbType); #endregion #region 加载所有表信息 SetStatusBar(string.Format("正在获取{0}中所有表信息", dbConfigInfo.DbConfigName)); SetProgress(0); if (_dsTable.Tables.Contains(dbConfigInfo.DbConfigName + Tables)) { _dsTable.Tables.Remove(dbConfigInfo.DbConfigName + Tables); } #region 从本地读取数据 bool status = DBFileHelper.IsExist(dbConfigInfo.DbConfigName, Tables); if (!reloadDb) { if (status) { DBFileHelper.ReadXml(_dsTable, dbConfigInfo.DbConfigName, Tables); } } #endregion #region 从数据库中读取数据 if (!status || reloadDb) { DNCCFrameWork.DataAccess.IDbHelper db = new DNCCFrameWork.DataAccess.DbFactory(dbConfigInfo.ConnectionString.Trim(new[] { '"' }), DBType.GetDbProviderString(dbConfigInfo.DbType)).IDbHelper; string sql = SqlDefHelper.GetTableNames(dbConfigInfo.DbType); DataSet temp = new DataSet(); db.Fill(sql, temp, new[] { dbConfigInfo.DbConfigName + Tables }); temp = DBFileHelper.WriteXml(temp, OriginalEncoding, TargetEncoding);//缓存表数据到本地 _dsTable.Merge(temp); } #endregion SetStatusBar(string.Format("{0}所有表信息加载完毕", dbConfigInfo.DbConfigName)); SetProgress(10); #endregion #region 加载所有表主键 SetStatusBar(string.Format("正在获取{0}中所有表主键信息", dbConfigInfo.DbConfigName)); if (_dsTablePrimaryKey.Tables.Contains(dbConfigInfo.DbConfigName + TablesPrimaryKeys)) { _dsTablePrimaryKey.Tables.Remove(dbConfigInfo.DbConfigName + TablesPrimaryKeys); } #region 从本地读取数据 status = DBFileHelper.IsExist(dbConfigInfo.DbConfigName, TablesPrimaryKeys); if (!reloadDb) { if (status) { DBFileHelper.ReadXml(_dsTablePrimaryKey, dbConfigInfo.DbConfigName, TablesPrimaryKeys); } } #endregion #region 从数据库中读取数据 if (!status || reloadDb) { DNCCFrameWork.DataAccess.IDbHelper db = new DNCCFrameWork.DataAccess.DbFactory(dbConfigInfo.ConnectionString.Trim(new[] { '"' }), DBType.GetDbProviderString(dbConfigInfo.DbType)).IDbHelper; string sql = SqlDefHelper.GetAllTablePrimaryKeys(dbConfigInfo.DbType); DataSet temp = new DataSet(); db.Fill(sql, temp, new[] { dbConfigInfo.DbConfigName + TablesPrimaryKeys }); temp = DBFileHelper.WriteXml(temp, OriginalEncoding, TargetEncoding);//缓存表数据到本地 _dsTablePrimaryKey.Merge(temp); } #endregion SetStatusBar(string.Format("{0}所有表主键信息加载完毕", dbConfigInfo.DbConfigName)); SetProgress(10); #endregion #region 构造树形结构 BindTreeBySync(); #endregion #region 加载所有表字段信息 SetStatusBar(string.Format("正在获取{0}中所有表字段信息", dbConfigInfo.DbConfigName)); if (_dsTableColumn.Tables.Contains(dbConfigInfo.DbConfigName + TablesColumns)) { _dsTableColumn.Tables.Remove(dbConfigInfo.DbConfigName + TablesColumns); } #region 从本地读取表字段信息 status = DBFileHelper.IsExist(dbConfigInfo.DbConfigName, TablesColumns); if (!reloadDb) { if (status) { DBFileHelper.ReadXml(_dsTableColumn, dbConfigInfo.DbConfigName, TablesColumns); SetProgress(80); } } #endregion #region 从数据库读取表字段信息 if (!status || reloadDb) { DNCCFrameWork.DataAccess.IDbHelper db = new DNCCFrameWork.DataAccess.DbFactory(dbConfigInfo.ConnectionString.Trim(new[] { '"' }), DBType.GetDbProviderString(dbConfigInfo.DbType)).IDbHelper; int count = _dsTable.Tables[dbConfigInfo.DbConfigName + Tables].Rows.Count; if (count != 0) { int temp1 = count / 7; bool isDivisible = count % temp1 == 0; string sql = SqlDefHelper.GetTableColumnNames(dbConfigInfo.DbType); DataSet dsTemp = new DataSet(); for (int i = 0; i < count; i++) { DataRow dr = _dsTable.Tables[dbConfigInfo.DbConfigName + Tables].Rows[i]; var temp = new DataSet(); var dicPar = new Dictionary <string, string> { { "@tableName", dr["name"] as string } }; SetStatusBar(string.Format("正在获取{0}中{1}字段信息", dbConfigInfo.DbConfigName, dr["name"] as string)); db.Fill(sql, temp, new[] { dbConfigInfo.DbConfigName + TablesColumns }, dicPar); dsTemp.Merge(temp); if (i % temp1 == 0) { SetProgress(10); } } dsTemp = DBFileHelper.WriteXml(dsTemp, OriginalEncoding, TargetEncoding); //缓存表字段数据到本地, _dsTableColumn.Merge(dsTemp); if (!isDivisible) { SetProgress(10); } } } #endregion SetEnable(true); #endregion _isLoadSuccess = true; } catch (Exception ex) { SetStatusBar(string.Format("加载数据失败[{0}]", ex.Message)); } } else { SetStatusBar("加载数据失败[没有获取到数据库配置]"); } }
public void Save() { bool status = false; string msg = ""; JavaCodeGenConfig temp = getConfigObject(); status = IniConfigHelper.writeDefaultDBInfo(temp); if (!status) { throw new Exception(msg); } else { status = false; msg = ""; } if (javaCodeGenConfigs.Count > 0) { if (javaCodeGenConfigs.ContainsKey(cbObject.Text)) { string id = javaCodeGenConfigs[cbObject.Text].Id; bool isDelete = javaCodeGenConfigs[cbObject.Text].IsDelete; javaCodeGenConfigs[cbObject.Text] = null; temp.Id = id; temp.IsDelete = isDelete; javaCodeGenConfigs[cbObject.Text] = temp; } else if (!string.IsNullOrEmpty(cbObject.Text)) { javaCodeGenConfigs.Add(cbObject.Text, temp); addItem(cbObject.Text); } foreach (string key in javaCodeGenConfigs.Keys) { status = IniConfigHelper.WriteDBInfo(javaCodeGenConfigs[key], ref msg); if (!status) { throw new Exception(msg); } else { status = false; msg = ""; } } } else { if (!string.IsNullOrEmpty(temp.DisplayName)) { status = IniConfigHelper.WriteDBInfo(temp, ref msg); if (!status) { throw new Exception(msg); } else { javaCodeGenConfigs.Add(temp.DisplayName, temp); addItem(temp.DisplayName); } } } }
protected override void AddContextMenu() { if (Application.MainContextMenu.InvokeRequired) { var s = new Simple(AddContextMenu); Application.MainContextMenu.Invoke(s, null); } else { TemplateConfig templateConfig = IniConfigHelper.ReadTemplateConfig(); if (templateConfig.TemplateNum > 0) { foreach (var template in templateConfig.TemplateParas) { string[] strs = template.MenuName.Split(new[] { "|" }, StringSplitOptions.RemoveEmptyEntries); string menuName = ""; var tsmiTemplate = new ToolStripMenuItem(); tsmiTemplate.Visible = template.IsMenuVisable; if (template.DataTye == "DB") { SetEnable(false); ToolStripMenuItem itemG = null; if (strs.Length >= 2) { foreach (ToolStripMenuItem temp in _dbContextMenuStrip.Items) { if (temp.Text == strs[0]) { itemG = temp; break; } } if (itemG == null) { itemG = new ToolStripMenuItem(); itemG.Text = strs[0]; _dbContextMenuStrip.Items.Add(itemG); } menuName = strs[1]; itemG.DropDownItems.Add(tsmiTemplate); } else { menuName = strs[0]; _dbContextMenuStrip.Items.AddRange(new[] { tsmiTemplate }); } tsmiTemplate.Text = menuName; tsmiTemplate.Tag = template; tsmiTemplate.Click += new EventHandler(tsmiTemplate_Click); } else if (template.DataTye == "Fix") { if (fixCmcSubPlugin != null) { SetFixCmcEnable(false); ToolStripMenuItem itemG = null; if (strs.Length >= 2) { foreach (ToolStripMenuItem temp in fixCmcSubPlugin.Items) { if (temp.Text == strs[0]) { itemG = temp; break; } } if (itemG == null) { itemG = new ToolStripMenuItem(); itemG.Text = strs[0]; fixCmcSubPlugin.Items.Add(itemG); } menuName = strs[1]; itemG.DropDownItems.Add(tsmiTemplate); } else { menuName = strs[0]; fixCmcSubPlugin.Items.AddRange(new[] { tsmiTemplate }); } tsmiTemplate.Text = menuName; tsmiTemplate.Tag = template; tsmiTemplate.Click += new EventHandler(tsmiTemplate_Click); } } } } } }