Ejemplo n.º 1
0
        private IEnumerable <string> QueryGoogle(string url)
        {
            string result = null;

            for (int i = 0; i < QueryRetries && String.IsNullOrEmpty(result); i++)
            {
                try
                {
                    result = WebUtils.DownloadText(url, false);
                }
                catch (WebException exception)
                {
                    if (exception.Status != WebExceptionStatus.Timeout)
                    {
                        throw exception;
                    }

                    LoggerWriter.WriteStep(Tokens.Info, "Retry", url);
                }
            }

            if (!String.IsNullOrEmpty(result) && result.Contains("dyn.setResults(["))
            {
                return(ParseGoogleResponse(result));
            }
            else
            {
                return(new List <string>());
            }
        }
Ejemplo n.º 2
0
        public static string RunPosterContainerHeaderHavaParam(string url, string head, string json, CookieContainer cookie = null)
        {
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

            request.Method = "POST";
            if (cookie != null)
            {
                request.CookieContainer = cookie;
            }
            HttpContent content = new StringContent(json, Encoding.UTF8, "application/json");

            byte[] jsonStream = Encoding.UTF8.GetBytes(json);
            request.ContentLength = jsonStream.Length;
            using (Stream requestSt = request.GetRequestStream())
            { //进行请求时的流信息
                requestSt.Write(jsonStream, 0, jsonStream.Length);
                requestSt.Close();
            }
            FillHttpWebRequestHead(request, head);
            WebResponse  response = request.GetResponse();
            Stream       st       = response.GetResponseStream();
            StreamReader sr       = new StreamReader(st, Encoding.UTF8);
            string       text     = sr.ReadToEnd();

            sr.Close();
            response.Close();
            string dir = ConfigItem.LoggerDefaultDir;

            if (string.IsNullOrEmpty(dir))
            {
                dir = NowAppDirHelper.GetNowAppDir(AppCategory.WinApp);
            }
            LoggerWriter.CreateLogFile(text, dir, ELogType.SessionOrCookieLog);
            return(text);
        }
Ejemplo n.º 3
0
        private PickUpQQDoResponse ForeachFindQQ(QueryQQParam param, string cookie)
        {
            string json    = param.UrlParam();
            string logPath = LogPrepare.GetLogPath();

            LoggerWriter.CreateLogFile(json, logPath, ELogType.ParamLog);
            string response = HttpClientExtend.HttpWebRequestPost(findQQAccountUrl, json, cookie);
            //将查询反馈的数据写入到数据库中

            // LoggerWriter.CreateLogFile(response, logPath, ELogType.DataLog);
            ConfigurationItems c        = new ConfigurationItems();
            FindQQDataManage   manage   = new FindQQDataManage(c.TecentDA_Read);
            JsonData           jsondata = new JsonData();
            PickUpQQDoResponse pickup   = new PickUpQQDoResponse();

            pickup.responseData = manage.SaveFindQQ(response);
            //此处开启一个线程查询qq群组

            pickup.cookie       = cookie;
            pickup.request      = json;
            pickup.responseJson = response;
            if (callback != null)
            {
            }
            return(pickup);
        }
Ejemplo n.º 4
0
        void QueryTicket()
        {
            #region--参数检测
            rtbTip.Text = string.Empty;
            ResourceManager rm = Lang.ResourceManager;
            List<string> nullItem = new List<string>();
            if (string.IsNullOrEmpty(ticketParam.from_station))
            {
                nullItem.Add(rm.GetString(langTipFix + cmbBeginStation.Tag));
            }
            if (string.IsNullOrEmpty(ticketParam.to_station))
            {
                nullItem.Add(rm.GetString(langTipFix + cmbToStation.Tag));
            }
            if (nullItem.Count > 0)
            {
                List<string> requireItem = new List<string>();
                requireItem.Add(rm.GetString(langTipFix + cmbBeginStation.Tag));
                requireItem.Add(rm.GetString(langTipFix + cmbToStation.Tag));
                rtbTip.Text = string.Format(Lang.Tip_12306_QueryTicketIsRequired, string.Join(",", requireItem), string.Join(",", nullItem));
                return;
            }
            #endregion
            string url = InitQueryTicketParam(ticketParam);
            string json = HttpClientExtend.HttpClientGet(url);
            LoggerWriter.CreateLogFile(json, LogDir, ELogType.DataLog, DateTime.Now.ToString(CommonFormat.DateTimeIntFormat) + ".txt");
            leftTicketDTOResponse response = json.ConvertObject<leftTicketDTOResponse>();//不能序列化字典
            JObject jr = JObject.Parse(json);
            JObject jd = (JObject)jr["data"];//字典为data下数据  map
            //由于json序列化时不能将节点下的字典型json串进行逆序列化,次出使用中转形式先读取取字典内容,在填充到对象
            JObject jdic = (JObject)jd["map"];
            Dictionary<string, string> _Data = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(jdic.ToString());
            if (response != null && response.data != null)
            {
                response.data.map = _Data;
            }
            //leftTicketDTOResponse responseNew= Newtonsoft.Json.JsonConvert.DeserializeObject<leftTicketDTOResponse>(json);
            /*
             * Newtonsoft
             其他信息: Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.String[]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.
             */
            foreach (var item in response.data.result)
            {
                GetCarTicket(item, response);
            }
            //存储列车座位信息
            //反射时构造函数没有提供参数可以进行创建
            ISyncTicketDataManage sync = IocHelper.CreateObjectCtorWithParam<ISyncTicketDataManage>(
                new object[]{AppCategory.WinApp,"Conn" },
                typeof(SyncTicketDataManage).Name,
                "TicketData.Manage",
                "CaptureManage.AppWin",//此为程序集,而不是命名空间
                NowAppDirHelper.GetNowAppDir(AppCategory.WinApp));
             
            //由于实现类中对于构造函数存在参数限定,此处需要特殊参数的传递
            sync.SaveCarWithSeatData(response);
            //读取列车过站信息
            //存储列车过站信息,绘制运动轨迹图

        }
Ejemplo n.º 5
0
        public static void NowProcess()
        {
            //获取当前进程
            string path = LogPrepare.GetLogPath();

            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            Process cur = Process.GetCurrentProcess();
            string  pn  = cur.ProcessName;//当前运行进程 w3wp/iisexpress

            sb.AppendLine("ProcessName=" + pn);
            string site = cur.Site != null? cur.Site.Name:string.Empty;

            sb.AppendLine("Site=" + site);
            string maiche = cur.MachineName;

            sb.AppendLine("MachineName{.=local}=" + maiche);
            string window = cur.MainWindowTitle;

            sb.AppendLine("MainWindowTitle=" + window);
            string poolName = Environment.GetEnvironmentVariable("APP_POOL_ID", EnvironmentVariableTarget.Process);//应用程序池名称 HrApp/Clr4IntegratedAppPool

            sb.AppendLine("APP_POOL_ID=" + poolName);
            // string json = Newtonsoft.Json.JsonConvert.SerializeObject(cur);
            ELogType lt = ELogType.BackgroundProcess;

            LoggerWriter.CreateLogFile(sb.ToString(), path, lt, LogPrepare.GetLogName(lt), true);
        }
Ejemplo n.º 6
0
        int DownLoadImageSize()
        {
            GatherUinImage guin  = new GatherUinImage();
            bool           isZip = true;

            if (rbOrigin.Checked)
            {
                isZip = false;
            }
            List <string> dirs = guin.DownLoadImage(isZip);

            if (dirs.Count > 0)
            {
                LoggerWriter.CreateLogFile("Rows:" + dirs.Count + "\r\n" + string.Join("\r\n", dirs),
                                           NowAppDirHelper.GetNowAppDir(AppCategory.WinApp) + "/" + AppCategory.WinApp.ToString(), ELogType.DebugData);
            }
            int gather = dirs.Count;

            if (gather > 0)
            {//如果本次操作有图片进行下载,则删除轮询调度作业,直接使用while去查找,避免出现锁死的现象
                (new QuartzJob()).DeleteJob <JobDelegateFunction>();
                DownLoadImageSize();
            }
            return(gather);
        }
Ejemplo n.º 7
0
        public MyLogger()
        {
            ConsoleLogger.Create();
#if SERVER
            LoggerWriter.Create();
#endif
        }
Ejemplo n.º 8
0
        static void EveryDayDo()
        {
            string path = LogPrepare.GetLogPath();

            try
            {
                StringBuilder text = new StringBuilder();
                text.AppendFormat("Background process【{0}】,index={1} ,time ={2}", GetStartWebOfProcess(), BackRunNumber, DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat));
                ELogType el = ELogType.BackgroundProcess;
                LoggerWriter.CreateLogFile(text.ToString(), path, el, LogPrepare.GetLogName(el), true);
                DoSomeInitEventFacadeFactory dosome = new DoSomeInitEventFacadeFactory();
                dosome.ActiveEmailSmtp();
                //读取xml配置
                string xmlFile = InitAppSetting.DefaultLogPath + "/XmlConfig/AppConfig.xml";
                //执行成功时间写入到xml中
                UiCfgNode.NodeKeyValue = typeof(AppEmailAccount).Name;
                AppEmailAccount appEmail = xmlFile.GetNodeSpecialeAttribute <AppEmailAccount>(UiCfgNode, nodeCfgFormat);
                appEmail.EmailLastActiveTime = DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat);
                appEmail.EmailAccount        = InitAppSetting.AppSettingItemsInDB[EAppSetting.SystemEmailSendBy.ToString()];
                xmlFile.UpdateXmlNode(appEmail, UiCfgNode, nodeCfgFormat);
                LoggerWriter.CreateLogFile(Newtonsoft.Json.JsonConvert.SerializeObject(appEmail), path, el, LogPrepare.GetLogName(el), false);
            }
            catch (Exception ex)
            {
                ELogType el = ELogType.BackgroundProcess;
                LoggerWriter.CreateLogFile("【Error】" + ex.Message.ToString(), path, el, LogPrepare.GetLogName(el), true);
            }
        }
Ejemplo n.º 9
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            GlobalNotifyHandle handle = new GlobalNotifyHandle();
            string             format = Common.Data.CommonFormat.DateTimeMilFormat;
            string             time   = DateTime.Now.ToString(format);
            string             path   = LogPrepare.GetLogPath();
            ELogType           heart  = ELogType.DebugData;
            string             file   = LogPrepare.GetLogName(heart);

            LoggerWriter.CreateLogFile(string.Format("begin init Data  {0}", time), path, heart, file, true);
            Domain.GlobalModel.AppRunData.InitAppData();
            time = DateTime.Now.ToString(format);
            LoggerWriter.CreateLogFile(string.Format("end init Data {0}", time), path, heart, file, true);
            Domain.GlobalModel.AppRunData.AppName = this.GetType().Name;
            time = DateTime.Now.ToString(format);
            LoggerWriter.CreateLogFile(string.Format("begin init ioc {0}", time), path, heart, file, true);
            IocMvcFactoryHelper.GetIocDict(true);
            time = DateTime.Now.ToString(format);
            LoggerWriter.CreateLogFile(string.Format("end init ioc {0}", time), path, heart, file, true);
            InitAppSetting.AppSettingItemsInDB = RefreshAppSetting.QueryAllAppSetting(IocMvcFactoryHelper.GetInterface <IAppSettingService>());
            RefreshAppSetting.RefreshFileVersion();
            AppProcess.GlobalXmlManage();
            AppProcess.CallTodo();
        }
Ejemplo n.º 10
0
        public void WriteLoginCookie(string text)
        {
            ConfigItem web = new ConfigItem();
            string     dir = web.WebChatLogger;

            LoggerWriter.CreateLogFile(text, dir, ELogType.DataLog);
        }
Ejemplo n.º 11
0
        /*
         * 1.获取登录的skey
         * POST https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxinit?r=$r$
         *  "/cgi-bin/mmwebwx-bin/webwxinit?r=" + ~new Date  这里 ~ new Date是获取什么时间【~ 位 非运算】 获取数据的反码 实际上就是毫秒级数据的反码
         *
         * 需要提取数据
         * Uin:   this.getUserInfo() && this.getUserInfo().Uin || a.getCookie("wxuin")
         * Sid:a.getCookie("wxsid")
         * DeviceID:"e" + ("" + Math.random().toFixed(15)).substring(2, 17)   如:"e485887172927031" 生成15位的随机浮点数 并获取对应字符串形式
         *
         * 2.获取指定群的成员
         * Get https://wx.qq.com/cgi-bin/mmwebwx-bin/webwxgetcontact?r=1498406493586&seq=0&skey=@crypt_45ae67ad_25514fafe82ebe778cf4986cd6d08f4f
         */
        public void GetWebGroupMembers(string loginCookie)
        {
            ConfigItem web = new ConfigItem();
            string     dir = web.WebChatLogger;

            LoggerWriter.CreateLogFile(loginCookie, dir, ELogType.SessionOrCookieLog);
        }
Ejemplo n.º 12
0
        private void QuartzGuidForach(object quartzParam)
        {
            if (this.InvokeRequired)
            {//是否通过其他形式调用
                DelegateData.BaseDelegate bd = new DelegateData.BaseDelegate(QuartzGuidForach);
                this.Invoke(bd, quartzParam);
                return;
            }
            LoggerWriter.CreateLogFile(Cookie, (new QQDataDA().GeneratePathTimeSpan(Cookie)), ELogType.SessionOrCookieLog);
            QueryQQParam param = GetBaseQueryParam();
            QQDataDA     da    = new QQDataDA();

            da.QueryParam = param;
            PickUpQQDoResponse response = da.QueryQQData(Cookie);
            // QueryTodayPickUp();
            //为下一次产生随机参数
            Guid   gid = Guid.NewGuid();
            Random ran = new Random(gid.GetHashCode());
            //所在城市联动
            int szd   = ran.Next(0, 8);
            int ps    = cmbProvince.Items.Count;
            int guidP = ran.Next(0, ps);

            cmbProvince.SelectedIndex = guidP;
            QuartzCallBack(response);
        }
Ejemplo n.º 13
0
        public static void WriteLog(string text)
        {
            string path = LogPrepare.GetLogPath();

            LoggerWriter.CreateLogFile(text, path,
                                       ELogType.DebugData, DateTime.Now.ToString(CommonFormat.DateIntFormat) + ".log", true);
        }
Ejemplo n.º 14
0
 void LoadStaionData() 
 {
     string url = "https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.9028";
     string response = HttpClientExtend.HttpClientGet(url);//@bjb|北京北|VAP|beijingbei|bjb|0 前6项为一组(并且第六项索引可以舍弃)
     LoggerWriter.CreateLogFile(response, LogDir, ELogType.LogicLog, typeof(WebDataCaptureForm).Name);
     GetStationModelFromString(response);
     
 }
Ejemplo n.º 15
0
 public static void Info(string msg)
 {
     if (!IsOutPutLog)
     {
         return;
     }
     LoggerWriter.LogInformation(msg);
 }
Ejemplo n.º 16
0
        static void GetEduList()
        {
            AppConfig  app      = new AppConfig();
            HttpHelper http     = new HttpHelper();
            string     response = http.GetHttpResponse(AppConfig.EduListUrl + app.FormatEduComUrlParam("普通本科", 1, 30), string.Empty);

            LoggerWriter.CreateLogFile(response, AppDir.GetParentDir(3) + "/" + ELogType.SpliderDataLog, ELogType.DataLog);
        }
Ejemplo n.º 17
0
 public static void Error(string msg)
 {
     if (!IsOutPutLog)
     {
         return;
     }
     LoggerWriter.LogError(msg);
 }
    void Start()
    {
        //if (ExperimentSettings_CoinTask.isLogging) {
        myLoggerQueue  = new LoggerQueue();
        myLoggerWriter = new LoggerWriter(fileName, myLoggerQueue);

        myLoggerWriter.Start();

        myLoggerWriter.log("DATE: " + DateTime.Now.ToString("M/d/yyyy"));                   //might not be needed
        //}
    }
 //logging itself can happen in regular update. the rate at which ILoggable objects add to the log Queue should be in FixedUpdate for framerate independence.
 void Update()
 {
     frameCount++;
     if (myLoggerWriter != null)
     {
         if (myLoggerWriter.Update())
         {
             // Alternative to the OnFinished callback
             myLoggerWriter = null;
         }
     }
 }
Ejemplo n.º 20
0
        public ImageResult Query(string query)
        {
            if (!cache.ContainsKey(query))
            {
                ImageResult result = new ImageResult();

                string googleQuery = BuildGoogleQuery(query);
                LoggerWriter.WriteStep(Tokens.Info, "Google query", googleQuery);

                string[] imageUrls = QueryGoogle(googleQuery).ToArray();

                for (int i = 0; i < Math.Min(imageUrls.Length, DownloadRetries); i++)
                {
                    LoggerWriter.WriteStepIndent(Tokens.Info, "\"" + imageUrls[i] + "\"");
                }

                for (int i = 0
                     ; i < Math.Min(imageUrls.Length, DownloadRetries) && !result.Succeeded
                     ; i++)
                {
                    string url = imageUrls[i];
                    LoggerWriter.WriteStep(Tokens.Info, "Download", url);

                    try
                    {
                        byte[] image = WebUtils.DownloadBinary(url);

                        if (!Object.ReferenceEquals(image, null) &&
                            image.Length >= MinImageSize &&
                            image.Length <= MaxImageSize)
                        {
                            result = new ImageResult(image, url);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.WriteLine(Tokens.Exception, ex);
                    }
                }

                cache[query] = result;
            }

            if (cache.ContainsKey(query) && cache[query].Succeeded)
            {
                return(cache[query]);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        ///使用日志功能【配置文件中OpenLogFun<> true则不写日志】
        /// </summary>
        /// <param name="msg"></param>
        /// <param name="logType"></param>
        public static void CreateLog(this string msg, ELogType logType)
        {
            string cfg = ConfigurationManager.AppSettings["OpenLogFun"];

            if (cfg != "true")
            {
                return;
            }
            //加上日期戳
            string week = Logger.GetWeekIndex();

            LoggerWriter.CreateLogFile(msg, NowAppDirHelper.GetNowAppDir(AppCategory.WinApp) + "/" + week + "/" + logType, logType);
        }
Ejemplo n.º 22
0
        private void QueryHtmlData(object response)
        {
            HtmlItem html = response as HtmlItem;

            if (html == null)
            {
                return;
            }
            lstData.Items.Add(html.Url);
            LoggerWriter.CreateLogFile(html.Html, NowAppDirHelper.GetNowAppDir(AppCategory.WinApp) + "/" + ELogType.HttpResponse.ToString() + "/" + html.Domain, ELogType.HttpResponse);
            //提取索引页码
            //使用xpath <B class=ui-page-s-len>2/100</B>
            Regex           reg = new Regex("<B class=ui-page-s-len>(.+)</B>");//提取符合要求的一段文本
            GroupCollection gc  = reg.Match(html.Html).Groups;

            if (gc.Count <= 1)
            {//第一项为匹配的完整串,第二项为标签内的文本  [2/100]
                return;
            }
            string htmlEle = gc[0].Value; //提取匹配的标签
            Group  g       = gc[1];
            string value   = g.Value;     //提取标签内的内容

            string[] pageInfo = value.Split('/');
            if (pageInfo.Length < 2)
            {
                return;
            }
            int numerator = -1, denominator = -1;

            int.TryParse(pageInfo[0], out numerator);
            if (!int.TryParse(pageInfo[1], out denominator))
            {//转换失败时 设置 参数为-1 避免出现分母为0的情形
                denominator = -1;
            }
            if (numerator >= denominator)
            { //不是查询到尾页
                return;
            }
            numerator++;
            string url = "https://list.tmall.com/search_product.htm?spm=a220m.1000858.1000724.10.4f506713HbGUt4&s={page}&q=%C3%AB%D2%C2&sort=s&style=g&from=mallfp..pc_1_searchbutton&active=2&smAreaId=110106&type=pc#J_Filter";
            // 羽绒服 "https://list.tmall.com/search_product.htm?spm=a220m.1000858.1000724.10.7f5f72ac0cvkWI&s={page}&q=%D3%F0%C8%DE%B7%FE%C4%D0&sort=s&style=g&smAreaId=110106&type=pc";
            int start = numerator * 60;

            url = url.Replace("{page}", start.ToString());
            web.RefreshUrl(url);

            /*
             * js: /<B[^>]*>(.+)<\/B>/
             */
        }
Ejemplo n.º 23
0
        public void LoopSendEmali(List <EmailAccount> accs, string subject)
        {//每日激活邮件账户
         //查询邮件账户列表
            string            dir          = LogPrepare.GetLogPath();
            ELogType          el           = ELogType.EmailLog;
            string            file         = LogPrepare.GetLogName(el);
            IEmailDataService emailService = IocMvcFactoryHelper.GetInterface <IEmailDataService>();

            foreach (var item in accs)
            {
                string time  = DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat);
                string title = "[HrApp Everyday active]";
                try
                {
                    //使用邮件账户进行邮件发送
                    short smtp = item.Smtp;
                    //拼接发送的邮件内容
                    EmailSystemSetting ess = new EmailSystemSetting()
                    {
                        EmailAccount      = item.Account,
                        EmailAuthortyCode = item.AuthortyCode,
                        EmailHost         = item.SmtpHost,
                        EmailHostPort     = EmailSystemSetting.GetHostPortSmtp(smtp)
                    };
                    ess.Smtp = (EnumSMTP)smtp;
                    StringBuilder body = new StringBuilder();
                    body.AppendLine(" Guid:<br/> ");
                    for (int i = 0; i < 10; i++)
                    {
                        body.AppendLine(string.Format(" {0}<br/> ", Guid.NewGuid().ToString().ToUpper()));
                    }
                    string       text      = string.Format("{0} <br/>  smtp= {1}<br/> time= {2} <br/>{3}  ", title, item.Account, time, body.ToString());
                    string       receive   = InitAppSetting.Global.ReceiverInEmailActive;
                    AppEmailData emailData = new AppEmailData()
                    {
                        EmailCreateTime = DateTime.Now,
                        To      = string.IsNullOrEmpty(receive) ? "*****@*****.**" : receive,
                        Subject = subject,
                        From    = item.Account,
                        Body    = text
                    };
                    emailService.SendEmail(ess, emailData, ess.Smtp);
                    LoggerWriter.CreateLogFile(title + "[Success]" + time, dir, el, file, true);
                }
                catch (Exception ex)
                {
                    title += ex.Message;
                    LoggerWriter.CreateLogFile(title + "[Error]" + time, dir, el, file, true);
                }
            }
        }
Ejemplo n.º 24
0
 void LoadUrlComplateEvent(object data) 
 {
     HtmlItem item = data as HtmlItem;
     if (item != null)
     {
         Init12306Cookie = item;
         string json = item.ConvertJson();
         LoggerWriter.CreateLogFile(json, NowAppDirHelper.GetNowAppDir(AppCategory.WinApp), ELogType.HttpResponse, string.Empty, false, Encoding.UTF8);
     }
     else
     {
         Init12306Cookie = new HtmlItem();
     }
 }
Ejemplo n.º 25
0
        public static bool WriteLogProcess(string log, ELogType logType)
        {
            string   logDir = LogPrepare.GetLogPath();
            DateTime time   = DateTime.Now;
            string   file   = LogPrepare.GetLogName(logType);

            LoggerWriter.CreateLogFile(log + time.ToString(Common.Data.CommonFormat.DateTimeMilFormat), logDir, logType, file, true);
            if (logType == ELogType.HeartBeatLine)
            {//心跳线检测不计入数据库
                return(true);
            }
            //这里调用日志数据库存储
            return(true);
        }
Ejemplo n.º 26
0
        public static bool WriteLogProcess(string log)
        {
            string   logDir    = new AppDirHelper().GetAppDir(AppCategory.WebApp);
            DateTime time      = DateTime.Now;
            string   logFormat = Common.Data.CommonFormat.DateToHourIntFormat;//这里会切换使用的日志文件存储大小

            //如果不是当天作为文件名,需要在键一个目录
            logDir += "/" + time.ToString(Common.Data.CommonFormat.YearMonth);
            string file = time.ToString(logFormat) + ".log";

            LoggerWriter.CreateLogFile(log + time.ToString(Common.Data.CommonFormat.DateTimeMilFormat), logDir,
                                       ELogType.HeartBeatLine, file, true);
            //这里调用日志数据库存储
            return(true);
        }
Ejemplo n.º 27
0
        static void QueryIdCard(string url)
        {
            string requestParam = @"Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:zh-CN,zh;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ASPSESSIONIDSQABCDRA=AJCBIMLAFHDDPOKGJDPBGIHB; gxskydzx31_f5ee_saltkey=V8j84g4P; gxskydzx31_f5ee_lastvisit=1503227237; gxskydzx31_f5ee_sid=wL5R7g; gxskydzx31_f5ee_lastact=1503230837%09nav_js.php%09; UM_distinctid=15dff8a57c50-0ad597d1229d24-474a0521-15f900-15dff8a57c61; Card3=Url=; ASPSESSIONIDQQCACCRB=PBHHKPLACDPLIPHOAFPIJOBI; CNZZDATA1259785388=339484251-1503230374-%7C1503230374
Host:idcard.gxsky.com
Referer:{url}
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.115 Safari/537.36";

            requestParam = requestParam.Replace("{url}", url);
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Headers.Add("Accept-Encoding", "gzip,deflate");
            //request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
            request.Method    = "GET";
            request.UserAgent = "Mozilla/5.0 (Windows NT 5.1; rv:19.0) Gecko/20100101 Firefox/19.0";
            request.KeepAlive = false;
            request.AllowWriteStreamBuffering = true;//对响应数据进行缓冲处理
            try
            {
                HttpWebResponse webResponse = null;
                Stream          str         = null;
                webResponse = (HttpWebResponse)request.GetResponse(); //此处有坑【如果http响应超时此处会抛出异常】
                if (webResponse.StatusCode != HttpStatusCode.OK)
                {                                                     //http请求失败
                }
                str = webResponse.GetResponseStream();
                GZipStream   gzip = new GZipStream(str, CompressionMode.Decompress);//解压缩
                Encoding     enc  = Encoding.GetEncoding("gb2312");
                StreamReader sr   = new StreamReader(gzip, enc);
                string       text = sr.ReadToEnd();
                str.Dispose();
                gzip.Close();
                sr.Close();
                // HttpClientExtend.GetHttpResponseData(url);
                AssemblyDataExt ass = new AssemblyDataExt();
                string          dir = ass.ForeachDir(ass.GetAssemblyDir(), 3);
                LoggerWriter.CreateLogFile(text, dir + "/" + ELogType.DataLog, ELogType.DataLog);
            }
            catch (Exception ex)
            {
                return;
            }
        }
Ejemplo n.º 28
0
        static void BackProcessDoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            ELogType el = ELogType.BackgroundProcess;

            while (true)
            {
                string path = LogPrepare.GetLogPath();
                if (StopBackProcess)
                {
                    LoggerWriter.CreateLogFile("Stop Background process =" + DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat), path, el, LogPrepare.GetLogName(el), true);
                    return;
                }
                BackRunNumber++;
                EveryDayDo();
                System.Threading.Thread.Sleep(1000 * 60 * 15);//15 分钟触发一次
            }
        }
Ejemplo n.º 29
0
        static void QueryUserRemarkLossId()
        {
            int cur = 1;

            string text = GetRequestData(string.Format(AppConfig.UserRemarkLoseIdCard, cur));

            string startRegex = "<form method=post";

            if (!text.Contains(startRegex))
            {
                return;
            }
            int             position = text.IndexOf(startRegex);
            string          page     = text.Substring(position + startRegex.Length);
            string          endRegex = "<input";
            string          releate  = page.Substring(0, page.IndexOf(endRegex));
            AssemblyDataExt ass      = new AssemblyDataExt();
            string          dir      = ass.ForeachDir(ass.GetAssemblyDir(), 3);

            LoggerWriter.CreateLogFile(text, dir + "/" + ELogType.DataLog, ELogType.DataLog);
            string sign = "#ff0000'>";

            releate = releate.Substring(releate.LastIndexOf(sign) + sign.Length);
            releate = releate.Substring(0, releate.LastIndexOf("</b>"));
            Regex           reg  = new Regex("([0-9]+)");
            MatchCollection list = reg.Matches(releate);
            //--->"3500</font></b>条记录 <b>35"
            Match total = list[0];// total
            Match limit = list[1];
            int   sum   = int.Parse(total.ToString());
            int   size  = int.Parse(limit.ToString());
            int   pages = (sum / size) + (sum % size > 0 ? 1 : 0);

            cur++;
            while (cur <= pages)
            {
                text = GetRequestData(string.Format(AppConfig.UserRemarkLoseIdCard, cur));
                cur++;
                if (string.IsNullOrEmpty(text))
                {
                    continue;
                }
                LoggerWriter.CreateLogFile(text, dir + "/" + ELogType.DataLog, ELogType.DataLog);
            }
        }
Ejemplo n.º 30
0
        public void Test()
        {
            string[] maxims = new string[] {
                "事常与人违,事总在人为",
                "骏马是跑出来的,强兵是打出来的",
                "驾驭命运的舵是奋斗。不抱有一丝幻想,不放弃一点机会,不停止一日努力。 ",
                "如果惧怕前面跌宕的山岩,生命就永远只能是死水一潭",
                "懦弱的人只会裹足不前,莽撞的人只能引为烧身,只有真正勇敢的人才能所向披靡"
            };
            StringBuilder sb = new StringBuilder();

            foreach (string item in maxims)
            {
                string pinying = item.TextConvertChar(true);
                sb.AppendLine(item + "\t" + pinying);
            }
            LoggerWriter.CreateLogFile(sb.ToString(), new AppDirHelper().GetAppDir(AppCategory.WinApp), ELogType.DebugData);
        }
Ejemplo n.º 31
0
	void Start ()
	{
		exp = GameObject.FindGameObjectWithTag ("Experiment").GetComponent<Experiment>();

		if (!exp.isReplay) {
			myLoggerQueue = new LoggerQueue ();
			myLoggerWriter = new LoggerWriter (fileName, myLoggerQueue);
		
			myLoggerWriter.Start ();
		
			myLoggerWriter.log ("DATE: " + DateTime.Now.ToString ("M/d/yyyy")); //might not be needed
		}
	}
Ejemplo n.º 32
0
	void Update()
	{
		frameCount++;

		if (myLoggerWriter != null)
		{
			if (myLoggerWriter.Update())
			{
				// Alternative to the OnFinished callback
				myLoggerWriter = null;
			}
		}
	}