Beispiel #1
0
        /// <summary>
        /// 提交收录
        /// </summary>
        /// <param name="urls"></param>
        /// <returns></returns>
        public async Task <bool> LinkSubmitSync(IEnumerable <string> urls)
        {
            //TODO:需要的话记录结果 但是需要登录
            var searchUrl = @"http://data.zz.baidu.com/urls?site={0}&token=KtnGR7zBD8930TQr";
            var domain    = "www.txooo.com";
            var tempUrl   = urls.FirstOrDefault();

            if (_urlReg.IsMatch(tempUrl))
            {
                domain = _urlReg.Match(tempUrl).Groups[2].Value.Replace(_urlReg.Match(tempUrl).Groups[3].Value, "");
            }

            var content  = Encoding.Default.GetBytes(string.Join(Environment.NewLine, urls));
            var response = await client.PostAsync(string.Format(searchUrl, domain), new ByteArrayContent(content));

            try
            {
                response.EnsureSuccessStatusCode();
            }
            catch (Exception ex)
            {
                this.TxLogError(ex.Message, ex);
            }
            string resultStr = await response.Content.ReadAsStringAsync();

            TxLogHelper.GetLogger("提交百度记录结果").TxLogInfo(resultStr);
            return(true);
        }
Beispiel #2
0
 static void Main()
 {
     Application.EnableVisualStyles();
     Application.SetCompatibleTextRenderingDefault(false);
     if (CanRun())
     {
         try
         {
             Application.Run(new MainForm());
         }
         catch (Exception ex)
         {
             TxLogHelper.GetLogger("app").TxLogError(ex.Message, ex);
         }
     }
 }
Beispiel #3
0
        /// <summary>
        /// 是否联网
        /// </summary>
        static bool IsConnect()
        {
            Int32 dwFlag = new int();
            bool  result = true;

            if (!InternetGetConnectedState(ref dwFlag, 0))
            {
                TxLogHelper.GetLogger("netWork").TxLogInfo("网络连接已断开...");
                result = false;
            }
            else if ((dwFlag & INTERNET_CONNECTION_MODEM) != 0)
            {
                TxLogHelper.GetLogger("netWork").TxLogInfo("网络已连接[调治解调器]...");
            }
            else if ((dwFlag & INTERNET_CONNECTION_LAN) != 0)
            {
                TxLogHelper.GetLogger("netWork").TxLogInfo("网络已连接[网卡]...");
            }
            return(result);
        }