예제 #1
0
 /// <summary>
 /// 获取html
 /// </summary>
 /// <param name="Url"></param>
 /// <param name="Encoding1"></param>
 /// <returns></returns>
 public static string GetUrltoHtml(string Url, Encoding Encoding1)
 {
     try
     {
         System.Net.WebRequest wReq = System.Net.WebRequest.Create(Url);
         // Get the response instance.
         System.Net.WebResponse wResp      = wReq.GetResponse();
         System.IO.Stream       respStream = wResp.GetResponseStream();
         // Dim reader As StreamReader = New StreamReader(respStream)
         using (System.IO.StreamReader reader = new System.IO.StreamReader(respStream, Encoding1))
         {
             return(reader.ReadToEnd());
         }
     }
     catch (System.Exception ex)
     {
         Cs.Fatal("93" + ex.ToString());
         //errorMsg = ex.Message;
     }
     return("");
 }
예제 #2
0
    public void initDaoruDaxue()
    {
        #region 初始化大学列表
        string StartupPath = root1;//.Replace("考试题", "");
        string daxueFile1  = @"\\fuwuqi3\微信运营辅助管理软件" + @"\大学列表.txt";
        if (!File.Exists(daxueFile1))
        {
            Cs.Fatal("目录不能访问:" + daxueFile1);
        }
        string daxueFile2 = daxueFile1;
        //try
        //{
        //    if (File.Exists(daxueFile1))
        //    {
        //        File.Copy(daxueFile1, @"c:\大学列表.txt", true);
        //    }
        //    else
        //        daxueFile2 = @"c:\大学列表.txt";
        //}
        //catch (Exception ex1)
        //{
        //    Cs.Error(ex1.ToString());
        //}

        //读取大学列表.txt文件,获取所有爱帮大学,初始化 chklist4 chklist5
        string[] strDaxue1 = File.ReadAllLines(daxueFile2, Encoding.Default);
        int      count1    = 0;
        foreach (string strDaXue in strDaxue1)        //
        {
            //792	北京邮电大学	//北邮//17758129465
            if (string.IsNullOrEmpty(strDaXue))
            {
                continue;
            }
            if (string.IsNullOrEmpty(strDaXue) || strDaXue.Trim() == "" || strDaXue.StartsWith("//"))
            {
                continue;
            }
            string   str3   = strDaXue.Replace("\t", "").Replace(" ", "").Trim();//301浙大
            string[] str3s  = StringHelper.Split(str3, "//");
            string   str2   = str3s[0];
            string   ScName = StringHelper.GetHanZi(str2);     //浙大

            string ScId = StringHelper.GetNumericLianXu(str2); //浙大

            string ScDescription = strDaXue;

            TscWxInfo val1 = new TscWxInfo();
            val1.Sc_name        = ScName;
            val1.Sc_id          = ScId;
            val1.Sc_description = ScDescription;

            int ret1 = BLLTable <TscWxInfo> .SaveOrUpdate(val1, TscWxInfo.Attribute.Sc_id);

            if (ret1 < 1)
            {
                Cs.Fatal("学校更新存在问题:" + ScDescription);
            }
            count1++;
        }
        Cs.WriteLine("总数 " + count1);//daxue_NumDaxueDic.Count);

        #endregion 初始化大学列表
    }
예제 #3
0
    public static AFDictionary <string, FileInfo> btnReNameFile_Click(string txtRename1)
    {
        if (template_files2.Count > 0)
        {
            return(template_files2);
        }
        renameInt = 0;
        if (!Directory.Exists(txtRename1))
        {
            return(template_files2);
        }
        //string[] files = FileService.GetFile(txtRename1);
        int count = 1;
        SortedList <string, FileInfo> template_files1 = FileService.GetFile(txtRename1, "*", ref count);
        bool ret1 = false;

        foreach (string file in template_files1.Keys)
        {
            ret1 = false;
            string f1 = Path.GetFileNameWithoutExtension(file);
            if (f1.StartsWith("~") || f1.StartsWith("="))
            {
                continue;
            }
            if (f1.Contains("树大"))
            {
                "".ToLower();
            }

            string f1DaXue = StringHelper.GetHanZiLianXu(f1);
            if (string.IsNullOrEmpty(f1DaXue))
            {
                continue;
            }

            string f1Num = StringHelper.GetNumericLianXu(f1);

            bool ret2 = false; string daxue11 = "";
            if (daxue_NumDaxueDic.ContainsKey(f1DaXue))
            {
                ret2    = true;
                daxue11 = daxue_NumDaxueDic[f1DaXue];
            }
            else
            {
                foreach (string daxue1 in daxue_NumDaxueDic.Keys)
                {
                    if (string.IsNullOrEmpty(daxue1))
                    {
                        continue;
                    }
                    if (daxue1 == "南大")
                    {
                        daxue1.ToString();
                    }
                    daxue11 = daxue_NumDaxueDic[daxue1];
                    List <string> f1Daxue2 = new List <string>();
                    f1Daxue2.Add(daxue1);
                    if (daxue_BieMingDic.ContainsKey(daxue1))
                    {
                        f1Daxue2.AddRange(daxue_BieMingDic[daxue1]);
                    }
                    //ret2 = isSameDaXue(f1DaXue, f1Daxue2);
                    if (ret2)
                    {
                        break;
                    }
                }
            }
            if (ret2)
            {
                string f2 = f1.Replace(f1Num + f1DaXue, daxue11);

                if (!template_files2.ContainsKey(daxue11))//f1Num + daxue1
                {
                    template_files2.Add(daxue11, template_files1[file]);
                }

                if (f1 != "" && f2 != "" && f1 != f2)
                {
                    string f3 = file.Replace(@"\" + f1, @"\" + f2);
                    if (File.Exists(file))
                    {
                        try
                        {
                            renameInt++;
                            FileService.Copy(file, f3, true);
                            if (File.Exists(f3))
                            {
                                File.Delete(file);
                            }
                        }
                        catch (Exception ex1)
                        {
                            Cs.Fatal(ex1.Message);
                        }
                    }
                    ret1 = true;
                }
            }
            if (file.EndsWith(".jpg") && !ret1)
            {
                "".ToLower();
                Cs.Warn(f1 + ",没有找到重命名");
            }
        }
        return(template_files2);
    }