/// <summary> /// 初始化数据 /// </summary> private void InitData() { userStr = iniFileOp.ReadValue(section, ukey); passStr = iniFileOp.ReadValue(section, pkey); userTb.Text = userStr; passTb.Text = passStr; }
private void Form1_Load(object sender, EventArgs e) { string iniReadvalue = IniFileHelper.ReadValue(iniMainSection, iniKey, System.IO.Path.GetFullPath(iniFilePath)); textBox1.Text = iniReadvalue; string iniReadManualDatevalue = IniFileHelper.ReadValue(iniManualSection, iniManualDateKey, System.IO.Path.GetFullPath(iniFilePath)); if (iniReadManualDatevalue == "" || iniReadSetvalue == "auto") { textBox2.Text = DateTime.Now.ToShortDateString(); } else { textBox2.Text = iniReadManualDatevalue; } string iniReadManualTimevalue = IniFileHelper.ReadValue(iniManualSection, iniManualTimeKey, System.IO.Path.GetFullPath(iniFilePath)); if (iniReadManualTimevalue == "" || iniReadSetvalue == "auto") { textBox3.Text = DateTime.Now.ToLongTimeString(); } else { textBox3.Text = iniReadManualTimevalue; } }
private void button1_Click(object sender, EventArgs e) { string iniReadvalue = IniFileHelper.ReadValue(iniMainSection, iniOpenFileKey, System.IO.Path.GetFullPath(iniFilePath)); openFileDialog1.Title = "Datei wählen"; openFileDialog1.InitialDirectory = iniReadvalue; openFileDialog1.ValidateNames = true; openFileDialog1.FileName = iniValue; if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (openFileDialog1.CheckFileExists) { textBox1.Text = openFileDialog1.FileName; //iniOpenFileValue = openFileDialog1.FileName; String directory = openFileDialog1.FileName.Substring(0, openFileDialog1.FileName.LastIndexOf('\\')); iniValue = openFileDialog1.SafeFileName; iniOpenFileValue = directory; } } else { textBox1.Text = ""; } }
public void ReadINI() { //try //{ var fileconfig = "config.ini"; var Database1 = "Database"; var ServerName1 = "ServerName"; var UserName1 = "UserName"; var Password1 = "Password"; var DatabaseName1 = "DatabaseName"; _ServerName1 = txtServerName1.Text = new Encoding().Decrypt(IniFileHelper.ReadValue(Database1, ServerName1, Path.GetFullPath(fileconfig))); _UserName1 = txtUserName1.Text = IniFileHelper.ReadValue(Database1, UserName1, Path.GetFullPath(fileconfig)); _Password1 = txtPassword1.Text = IniFileHelper.ReadValue(Database1, Password1, Path.GetFullPath(fileconfig)); _DatabaseName1 = cbxDatabaseName1.Text = IniFileHelper.ReadValue(Database1, DatabaseName1, Path.GetFullPath(fileconfig)); var Database2 = "DatabaseMongoDB"; var ServerName2 = "ServerName"; var UserName2 = "UserName"; var Password2 = "Password"; var DatabaseName2 = "DatabaseName"; _ServerName2 = txtServerName2.Text = IniFileHelper.ReadValue(Database2, ServerName2, Path.GetFullPath(fileconfig)); _UserName2 = txtUserName2.Text = IniFileHelper.ReadValue(Database2, UserName2, Path.GetFullPath(fileconfig)); _Password2 = txtPassword2.Text = IniFileHelper.ReadValue(Database2, Password2, Path.GetFullPath(fileconfig)); _DatabaseName2 = cbxDatabaseName2.Text = IniFileHelper.ReadValue(Database2, DatabaseName2, Path.GetFullPath(fileconfig)); //} //catch (Exception) //{ //} }
public void LoadPrinter(ComboBox cbx) { string value = IniFileHelper.ReadValue("Printer", "Printer", Path.GetFullPath(pathIni)); cbx.Items.Add(value); cbx.SelectedIndex = 0; }
private void ReadIni() { string value = IniFileHelper.ReadValue("Printer", "Printer", Path.GetFullPath(dc.pathIni)); cbxPrinter.ComboBox.DataSource = new object[] { value }; cbxPrinter.ComboBox.SelectedIndex = 0; }
private void bReadConfig_Click(object sender, EventArgs e) { string filePath = Environment.CurrentDirectory + @"\set.dat"; if (File.Exists(filePath)) { try { checkBox1.Checked = Convert.ToBoolean(IniFileHelper.ReadValue("Timer", "Enable", filePath)); comboBox1.SelectedValue = IniFileHelper.ReadValue("Timer", "Timer", filePath); numericUpDown1.Value = Convert.ToDecimal(IniFileHelper.ReadValue("Main", "ErrorCount", filePath)); textBox1.Text = IniFileHelper.ReadValue("Main", "Regex", filePath); textBox2.Text = IniFileHelper.ReadValue("Firewall", "Name", filePath); comboBox2.SelectedValue = IniFileHelper.ReadValue("Firewall", "Protocol", filePath); comboBox3.SelectedItem = IniFileHelper.ReadValue("Firewall", "Profile", filePath); textBox3.Text = IniFileHelper.ReadValue("Firewall", "LocalPort", filePath); textBox4.Text = IniFileHelper.ReadValue("Firewall", "RemotePort", filePath); comboBox4.SelectedItem = IniFileHelper.ReadValue("Firewall", "Action", filePath); comboBox5.SelectedItem = IniFileHelper.ReadValue("Firewall", "Dir", filePath); } catch { MessageBox.Show("Error on reading filed configuration.\r\nLoad standart configuration."); DefaultSettings(); } } else { DefaultSettings(); } }
/// <summary> /// 更新点位列表框 /// </summary> private void UpdatePointCombo() { //加载当前产品的点位信息 List <string> pList = new List <string>(); pointCombo.Items.Clear(); pointCombo.SelectedIndex = -1; pointCombo.Text = ""; pList = iniFileOp.ReadKeys(curProductName); pointList = pList; if (pList.Count <= 0) { return; } pointCombo.Items.AddRange(pList.ToArray()); pointCombo.SelectedIndex = 0; ClearTable();//先清空表格再添加新的数据 //加载点位信息到表格中去 for (int i = 0; i < pList.Count; i++) { string val = iniFileOp.ReadValue(curProductName, pList[i]); string[] pointUnit = val.Split(','); for (int j = 0; j < pointUnit.Count(); j++) { dataGridView1.Rows[j].Cells[i + 1].Value = pointUnit[j]; } } }
private void ReadIni() { string value = IniFileHelper.ReadValue("Printer", "Printer", Path.GetFullPath(dc.pathIni)); var cbx = comboBox1; cbx.Items.Add(value); cbx.SelectedIndex = 0; }
static Settings() { string defaultIniFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Settings.ini"); string iniFilePath = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "VC Render Manager", "Settings.ini"); if (!File.Exists(iniFilePath)) { Directory.CreateDirectory(Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "VC Render Manager")); File.Copy(defaultIniFilePath, iniFilePath); } RenderChunkSize = Convert.ToInt32(IniFileHelper.ReadValue("Constants", "RenderChunkSize", iniFilePath)); MaxRenderIdleCount = Convert.ToInt32(IniFileHelper.ReadValue("Constants", "MaxRenderIdleCount", iniFilePath)); BasePathVariable = IniFileHelper.ReadValue("LocalPaths", "BasePathVariable", iniFilePath); LocalBasePath = IniFileHelper.ReadValue("LocalPaths", "BasePath", iniFilePath); LocalProductPath = IniFileHelper.ReadValue("LocalPaths", "ProductPath", iniFilePath); LocalAudioPath = IniFileHelper.ReadValue("LocalPaths", "AudioPath", iniFilePath); LocalFusionPluginPath = IniFileHelper.ReadValue("LocalPaths", "FusionPluginPath", iniFilePath); LocalDeadlineExePath = IniFileHelper.ReadValue("LocalPaths", "DeadlinePath", iniFilePath); LocalFfmpegExePath = IniFileHelper.ReadValue("LocalPaths", "FFMpegPath", iniFilePath); LocalProductionPath = IniFileHelper.ReadValue("LocalPaths", "ProductionPath", iniFilePath); ServerUrl = IniFileHelper.ReadValue("ExternalPaths", "ServerUrl", iniFilePath); ServicesUrl = IniFileHelper.ReadValue("ExternalPaths", "ServicesUrl", iniFilePath); FilmUrl = IniFileHelper.ReadValue("ExternalPaths", "FilmUrl", iniFilePath); MasterLogin = new LoginData( Url: IniFileHelper.ReadValue("Ftp", "MasterFtpURL", iniFilePath), Username: IniFileHelper.ReadValue("Ftp", "MasterFtpLogin", iniFilePath), Password: IniFileHelper.ReadValue("Ftp", "MasterFtpPassword", iniFilePath)); FtpUserSubdirectory = IniFileHelper.ReadValue("Ftp", "UserFtpSubdirectory", iniFilePath); FtpAudioSubdirectory = IniFileHelper.ReadValue("Ftp", "AudioFtpSubdirectory", iniFilePath); FtpHashSubdirectory = IniFileHelper.ReadValue("Ftp", "HashFtpSubdirectory", iniFilePath); FtpProductPreviewSubdirectory = IniFileHelper.ReadValue("Ftp", "ProductPreviewFtpSubdirectory", iniFilePath); EmailServerLogin = new LoginData( Url: IniFileHelper.ReadValue("Email", "EmailHost", iniFilePath), Username: IniFileHelper.ReadValue("Email", "EmailLogin", iniFilePath), Password: IniFileHelper.ReadValue("Email", "EmailPassword", iniFilePath)); EmailSender = IniFileHelper.ReadValue("Email", "EmailAddress", iniFilePath); SALTED = IniFileHelper.ReadValue("RemoteService", "SALTED", iniFilePath); MongoServerURL = IniFileHelper.ReadValue("MongoDB", "MongoServer", iniFilePath); MongoPort = IniFileHelper.ReadValue("MongoDB", "MongoPort", iniFilePath); UseCuda = Convert.ToBoolean(IniFileHelper.ReadValue("CUDA", "UseCuda", iniFilePath)); LicenseKey = IniFileHelper.ReadValue("Licensing", "LicenseKey", iniFilePath); }
public void ReadINI() { txtServerName1.Text = _servername = new Encoding().Decrypt(IniFileHelper.ReadValue(Database1, ServerName1, pathConfig)); txtUserName1.Text = _username = new Encoding().Decrypt(IniFileHelper.ReadValue(Database1, UserName1, pathConfig)); txtPassword1.Text = _password = new Encoding().Decrypt(IniFileHelper.ReadValue(Database1, Password1, pathConfig)); cbxDatabaseName1.Items.Add(_database = new Encoding().Decrypt(IniFileHelper.ReadValue(Database1, DatabaseName1, pathConfig))); cbxDatabaseName1.SelectedIndex = 0; txtServerFTP.Text = _serverFTP = new Encoding().Decrypt(IniFileHelper.ReadValue(FTP, ServerFTP, pathConfig)); txtUserFTP.Text = _userFTP = new Encoding().Decrypt(IniFileHelper.ReadValue(FTP, UserFTP, pathConfig)); txtPassFTP.Text = _passFTP = new Encoding().Decrypt(IniFileHelper.ReadValue(FTP, PassFTP, pathConfig)); txtPathFTP.Text = _pathFTP = new Encoding().Decrypt(IniFileHelper.ReadValue(FTP, PathFTP, pathConfig)); }
private void ReadIni() { try { string value = IniFileHelper.ReadValue("Printer", "Printer", Path.GetFullPath(dc.pathIni)); cbxPrinter.ComboBox.DataSource = new object[] { value }; cbxPrinter.ComboBox.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show(ex.Message); // throw; } }
private void AddDataToTable() { ClearTable(); pointlist.Clear(); //加载点位信息到表格中去 for (int i = 0; i < pointList.Count; i++) { string val = iniFileOp.ReadValue(curProductName, pointList[i]); pointlist.Add(val); string[] pointUnit = val.Split(','); for (int j = 0; j < pointUnit.Count(); j++) { dataGridView1.Rows[j].Cells[i + 1].Value = pointUnit[j]; } } }
private object CheckConfigValue(string selection, string key) { string filePath = Environment.CurrentDirectory + @"\set.dat"; object result; if (File.Exists(filePath)) { try { result = IniFileHelper.ReadValue(selection, key, filePath); if (result != null) { return(result); } } catch { return(null); } return(null); } else { using (fSettings fs = new fSettings()) { this.Hide(); if (DialogResult.Cancel == fs.ShowDialog()) { fs.Dispose(); } this.Show(); result = IniFileHelper.ReadValue(selection, key, filePath); if (result != null) { return(result); } } return(null); } }
private void LoadSettings() { string filePath = Environment.CurrentDirectory + @"\set.dat"; if (File.Exists(filePath)) { sRegex = IniFileHelper.ReadValue("Main", "Regex", filePath); sSucces = IniFileHelper.ReadValue("Main", "Success", filePath); sFailed = IniFileHelper.ReadValue("Main", "Failed", filePath); } else { fSettings fs = new fSettings(); this.Hide(); if (DialogResult.Cancel == fs.ShowDialog()) { fs.Dispose(); } this.Show(); } }
private void btnSave_Click(object sender, EventArgs e) { //var ServerName1 = new Encoding().Encrypt(txtServerName1.Text); //var ServerName1 = new Encoding().Encrypt(txtServerName1.Text); //var ServerName1 = new Encoding().Encrypt(txtServerName1.Text); //var ServerName1 = new Encoding().Encrypt(txtServerName1.Text); var fileconfig = "config.ini"; var Database1 = "Database"; var ServerName1 = "ServerName"; var UserName1 = "UserName"; var Password1 = "Password"; var DatabaseName1 = "DatabaseName"; var test = Path.GetFullPath(fileconfig); _ServerName1 = IniFileHelper.ReadValue(Database1, ServerName1, test); _UserName1 = IniFileHelper.ReadValue(Database1, UserName1, Path.GetFullPath(fileconfig)); _Password1 = IniFileHelper.ReadValue(Database1, Password1, Path.GetFullPath(fileconfig)); _DatabaseName1 = IniFileHelper.ReadValue(Database1, DatabaseName1, Path.GetFullPath(fileconfig)); bool result = IniFileHelper.WriteValue(Database1, ServerName1, new Encoding().Encrypt(txtServerName1.Text), Path.GetFullPath(fileconfig)); }
private void FunctExecute(string ip = "", Execut exu = Execut.Add) { string filePath = Environment.CurrentDirectory + @"\set.dat"; if (File.Exists(filePath)) { string sNameRule = IniFileHelper.ReadValue("Firewall", "Name", filePath); string sProtocolRule = IniFileHelper.ReadValue("Firewall", "Protocol", filePath); string sProfileRule = IniFileHelper.ReadValue("Firewall", "Profile", filePath); string sLocalPortRule = IniFileHelper.ReadValue("Firewall", "LocalPort", filePath); string sRemotePortRule = IniFileHelper.ReadValue("Firewall", "RemotePort", filePath); string sAction = IniFileHelper.ReadValue("Firewall", "Action", filePath); string sDir = IniFileHelper.ReadValue("Firewall", "Dir", filePath); if (exu == Execut.Show) { string Command = @"netsh advfirewall firewall show rule name=" + sNameRule; ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + Command); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = true; Process proc = new Process(); procStartInfo.StandardOutputEncoding = Encoding.GetEncoding(866); proc.StartInfo = procStartInfo; proc.Start(); string OutputResult = proc.StandardOutput.ReadToEnd(); AddToLogs(OutputResult, DateTime.Now.ToString(), ""); listBox2.Items.AddRange(ParseOut(OutputResult).ToArray()); } else if (exu == Execut.Add) { string Command = @"netsh advfirewall firewall add rule name=" + sNameRule + " protocol=" + sProtocolRule + " profile=" + sProfileRule + " localport=" + sLocalPortRule + " remoteport=" + sRemotePortRule + " action=" + sAction + " dir=" + sDir + " remoteip=" + ip; ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + Command); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = true; Process proc = new Process(); procStartInfo.StandardOutputEncoding = Encoding.GetEncoding(866); proc.StartInfo = procStartInfo; proc.Start(); string OutputResult = proc.StandardOutput.ReadToEnd(); AddToLogs(OutputResult, DateTime.Now.ToString(), ""); } if (exu == Execut.Delete) { string Command = @"netsh advfirewall firewall delete rule name=" + sNameRule; ProcessStartInfo procStartInfo = new ProcessStartInfo("cmd", "/c " + Command); procStartInfo.RedirectStandardOutput = true; procStartInfo.UseShellExecute = false; procStartInfo.CreateNoWindow = true; Process proc = new Process(); procStartInfo.StandardOutputEncoding = Encoding.GetEncoding(866); proc.StartInfo = procStartInfo; proc.Start(); string OutputResult = proc.StandardOutput.ReadToEnd(); AddToLogs(OutputResult, DateTime.Now.ToString(), ""); } } else { fSettings fs = new fSettings(); this.Hide(); if (DialogResult.Cancel == fs.ShowDialog()) { fs.Dispose(); } this.Show(); } }
/// <summary> /// 初始化产品信息 /// </summary> private void InitProductInfo() { curProduct = iniFileOp.ReadValue("CurOpProduct", "ProductName"); productName.Text = curProduct; curPointList = GetPointInfoByProduct(curProduct); }
public static void ReadCallback(IAsyncResult ar) { String content = String.Empty; //IniFileHelper IniFileHelper iniFile = new IniFileHelper(); // Retrieve the state object and the handler socket // from the asynchronous state object. StateObject state = (StateObject)ar.AsyncState; Socket handler = state.workSocket; // Read data from the client socket. int bytesRead = handler.EndReceive(ar); if (bytesRead > 0) { // There might be more data, so store the data received so far. state.sb.Append(Encoding.ASCII.GetString( state.buffer, 0, bytesRead)); // Check for end-of-file tag. If it is not there, read // more data. content = state.sb.ToString(); if (content.IndexOf("\r") > -1) { string ReceivedOutput = null; switch (content.Substring(0, 3)) { case "611": string device1Result = iniFile.ReadValue("Device1", "status", System.IO.Path.GetFullPath("IniFile.ini")); string device2Result = iniFile.ReadValue("Device2", "status", System.IO.Path.GetFullPath("IniFile.ini")); string resultOutput = null; if (device1Result == "-1" && device2Result == "-1") { resultOutput = "0"; } else { resultOutput = "1"; } ReceivedOutput = "621" + DateTime.Now.ToString("HHmmss") + "015" + "|" + content.Substring(13, 6) + "|" + resultOutput + "|01|02|"; if (device1Result != "-1") { bool result = IniFileHelper.WriteValue("Device1", "status", " 1", System.IO.Path.GetFullPath("IniFile.ini")); } if (device2Result != "-1") { bool results = IniFileHelper.WriteValue("Device2", "status", " 1", System.IO.Path.GetFullPath("IniFile.ini")); } break; case "612": string device1Reset = iniFile.ReadValue("Device1", "status", System.IO.Path.GetFullPath("IniFile.ini")); string device2Reset = iniFile.ReadValue("Device2", "status", System.IO.Path.GetFullPath("IniFile.ini")); string resetOutput1 = null; string resetOutput2 = null; if (device1Reset == "-1") { resetOutput1 = "1"; } else { resetOutput1 = "0"; } if (device2Reset == "-1") { resetOutput2 = "1"; } else { resetOutput2 = "0"; } ReceivedOutput = "622" + DateTime.Now.ToString("HHmmss") + "010" + "|" + content.Substring(13, 6) + "|" + resetOutput1 + "|" + resetOutput2 + "|"; if (device1Reset != "-1") { bool result = IniFileHelper.WriteValue("Device1", "status", "0", System.IO.Path.GetFullPath("IniFile.ini")); } if (device2Reset != "-1") { bool results = IniFileHelper.WriteValue("Device2", "status", "0", System.IO.Path.GetFullPath("IniFile.ini")); } //modbusClient.Connect(); //modbusClient.WriteSingleCoil(0001, false); //modbusClient.Disconnect(); break; case "619": string device1Status = iniFile.ReadValue("Device1", "status", System.IO.Path.GetFullPath("IniFile.ini")); string device2Status = iniFile.ReadValue("Device2", "status", System.IO.Path.GetFullPath("IniFile.ini")); ReceivedOutput = "629" + DateTime.Now.ToString("HHmmss") + "011" + "|" + content.Substring(13, 6) + "|" + device1Status + "|" + device2Status + "|"; break; default: ReceivedOutput = "invalid command code"; break; } // All the data has been read from the // client. Display it on the console. Console.WriteLine("Read {0} bytes from socket.\nData : {1}", content.Length, content); // Echo the data back to the client. Send(handler, ReceivedOutput + "\r"); } else { // Not all data received. Get more. handler.BeginReceive(state.buffer, 0, StateObject.BufferSize, 0, new AsyncCallback(ReadCallback), state); } } }