public static string LocalIpAddress_Texp() { string IP = string.Empty; string vpnIp = string.Empty; try { IPHostEntry host = Dns.GetHostEntry(System.Environment.MachineName); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { if (ip.ToStr().Contains("20.10.")) { vpnIp = ip.ToStr(); return(vpnIp); } else { vpnIp = ip.ToStr(); } } } } catch (Exception ee) { CLog.Write(ee.GetAllMessages()); } return(vpnIp); }
public static void Set(string name, string val) { try { var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); var settings = configFile.AppSettings.Settings; bool found = false; var ks = settings.AllKeys; foreach (var item in ks) { if (item == name) { found = true; break; } } if (!found) { settings.Add(name, val); } else { settings[name].Value = val; } configFile.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name); } catch (ConfigurationErrorsException ee) { CLog.Write(ee.Message); CLog.Write(ee.StackTrace); } }
public static string LocalIpAddressAll(string ia) { string IP = string.Empty; try { string[] sa = ia.Split('.'); ia = $"{sa[0]}.{sa[1]}.{sa[2]}."; IPHostEntry host = Dns.GetHostEntry(System.Environment.MachineName); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { string ai = ip.ToStr(); if (ia == ai.Substring(0, ia.Length)) { return(ai); } } } } catch (Exception ee) { CLog.Write(ee.GetAllMessages()); } return(""); }
public static void SetValue(string name, string value) { try { RegistryKey rk = Registry.CurrentUser.CreateSubKey("Software\\BIOPasport"); rk.SetValue(name, value); rk.Close(); } catch (Exception e) { CLog.Write("CRegistry->SetValue " + e.Message); } }
public static int ToInt(this string source) { int i = -1; if (!string.IsNullOrEmpty(source)) { i = Convert.ToInt32(source.Replace(" ", "")); } else { CLog.Write("source IsNullOrEmpty"); } return(i); }
public static string GetValue(string name) { string res = ""; try { RegistryKey rk = Registry.CurrentUser.CreateSubKey("Software\\BIOPasport"); string value = rk.GetValue(name).ToString(); rk.Close(); res = value; } catch (Exception e) { CLog.Write("CRegistry->GetValue " + e.Message); } return(res); }
public static void SetValue(string MainSection, string sn, string val) { try { if (config.Sections[MainSection] == null) { section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToApplication; config.Sections.Add(MainSection, section); } else { section = (AppSettingsSection)config.Sections[MainSection]; } section.Settings.Remove(sn); section.Settings.Add(sn, val); config.Save(); } catch (Exception e) { CLog.Write("CCofig->SetValue " + e.Message); } }
public static string LocalIpAddressAll() { string IP = string.Empty; string allIp = ""; try { IPHostEntry host = Dns.GetHostEntry(System.Environment.MachineName); foreach (IPAddress ip in host.AddressList) { if (ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { allIp += ip.ToStr() + " "; } } } catch (Exception ee) { CLog.Write(ee.GetAllMessages()); } return(allIp); }
public static string GetValue(string MainSection, string sn) { string res = ""; try { if (config.Sections[MainSection] == null) { section.SectionInformation.AllowExeDefinition = ConfigurationAllowExeDefinition.MachineToApplication; config.Sections.Add(MainSection, section); } else { section = (AppSettingsSection)config.Sections[MainSection]; } res = section.Settings[sn].Value; } catch (Exception e) { CLog.Write("CCofig->GetValue " + e.GetAllMessages()); } return(res); }