/// <summary> /// 获取远程hosts /// </summary> /// <returns></returns> public Dictionary <string, string> GetRemoteDictionary() { var dic = new Dictionary <string, string>(); var list = GetAllHostsSource(); if (list != null) { //排序 list = list.Where(d => d.IsEnabled == 1).OrderBy(d => d.Id).ToList(); foreach (var hostsSource in list) { var d = ExtentionClass.DownloaHosts(hostsSource.Url); foreach (KeyValuePair <string, string> pair in d) { if (!dic.ContainsKey(pair.Key)) { dic.Add(pair.Key, pair.Value); } } } } return(dic); }
public void TestMethod1() { var list = ExtentionClass.DownloaHosts("https://raw.githubusercontent.com/racaljk/hosts/master/hosts"); }
private void SaveData(string ServTaxId) { BLL.DBInteraction dbinteract = new BLL.DBInteraction(); DateTime maxDate = Convert.ToDateTime(GeneralFunctions.DecryptQueryString(Request.QueryString["dt"])); if (ServTaxId == "-1") { txtStDate.Text = DatePicker1.dt.ToShortDateString(); if (DatePicker1.dt.CompareTo(maxDate) < 0) { GeneralFunctions.RegisterAlertScript(this, "Start Date must be greater than: " + maxDate.ToShortDateString()); return; } } else { if (dbinteract.InvoiceDateCheck(Convert.ToDateTime(txtStDate.Text)) > 0) { GeneralFunctions.RegisterAlertScript(this, "This Date has been already used for Invoice. It can not be edited"); return; } } bool isedit = ServTaxId != "-1" ? true : false; int result = dbinteract.AddEditSTax(_userId, Convert.ToInt32(ServTaxId), Convert.ToDateTime(txtStDate.Text), ExtentionClass.TryParseBlankAsZero(txtAddiCess.Text), ExtentionClass.TryParseBlankAsZero(txtCess.Text), ExtentionClass.TryParseBlankAsZero(txtTax.Text), ddlStatus.SelectedIndex == 0 ? true : false, isedit); if (result > 0) { Response.Redirect("~/MasterModule/ManageServTax.aspx"); } else { GeneralFunctions.RegisterAlertScript(this, "Error Occured"); } }
/// <summary> /// 读取缓存的远程hosts配置 /// </summary> /// <returns></returns> public Dictionary <string, string> ReadRemoteDicBak() { return(ExtentionClass.ReadBinary <Dictionary <string, string> >(ExtentionClass.ApplicationPath + "remote.bak")); }
/// <summary> /// 写入远程hosts配置缓存 /// </summary> /// <param name="dictionary"></param> public void WriteRemoteDicBak(Dictionary <string, string> dictionary) { ExtentionClass.WriteBinary(dictionary, ExtentionClass.ApplicationPath + "remote.bak"); }