Example #1
0
        public static void WriteLog(string text)
        {
            string path = LogPrepare.GetLogPath();

            LoggerWriter.CreateLogFile(text, path,
                                       ELogType.DebugData, DateTime.Now.ToString(CommonFormat.DateIntFormat) + ".log", true);
        }
Example #2
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);
        }
Example #3
0
        void SendEmail(string subject, string body)
        {
            string dir  = LogPrepare.GetLogPath();
            string file = DateTime.Now.ToString(Common.Data.CommonFormat.DateIntFormat) + ".log";
            string msg  = DateTime.Now.ToString(Common.Data.CommonFormat.DateTimeFormat) + "\r\n";

            try
            {
                string       from  = SystemConfig.EmailId;
                EmailService email = new EmailService(SystemConfig.EmailClient, from, SystemConfig.EmailKey,
                                                      SystemConfig.EmailClientPort, SystemConfig.EmailEnableSsl);
                email.LogPath = dir;
                //此处需要验证 发信人和发件人的区别
                email.SendEmail(subject, body, from, from, SystemConfig.DefaultEmailTo, null, false, System.Net.Mail.MailPriority.High, null);
                msg += "EmailSend Success";
            }
            catch (Exception ex)
            {
                msg += ex.Message;
                LoggerWriter.CreateLogFile(msg, dir, ELogType.EmailLog, file, true);
            }
        }
Example #4
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Cookie))
            {
                rtbTip.Text = "please  login,and get cookie,and continue";
                return;
            }
            //
            int    interval = 0;
            string inter    = txtTimeSpan.Text;

            int.TryParse(inter, out interval);
            if (interval > 0)
            {
                intervalSec = interval;
            }
            else
            {
                interval = intervalSec;
            }
            int    repeact = 0;
            string rep     = txtRepeact.Text;

            int.TryParse(rep, out repeact);
            QQDataDA das  = new QQDataDA();
            string   path = LogPrepare.GetLogPath();

            LoggerWriter.CreateLogFile(Cookie, das.GeneratePathTimeSpan(Cookie), ELogType.SessionOrCookieLog);
            Uin = das.GetUinFromCookie(Cookie);//当前登录的账户
            //useralias  这是提取账户名称的元素
            QueryQQParam             param = GetBaseQueryParam();
            ParameterizedThreadStart pth;

            if (!ckStartQuartz.Checked)
            {//不进行轮询
                JustQuery(param);
            }
            else if (!ckBackGroundCall.Checked)
            {
                #region 进行的是quartz.net轮询调度
                if (ckStartQuartz.Checked && rbGuid.Checked)
                {//开启随机轮询
                    DelegateData.BaseDelegate del = QuartzGuidForach;
                    QuartzJobParam            p   = new QuartzJobParam()
                    {
                        JobExecutionContextJobDataMap = new object[] { del, param, null },
                        StartTime        = DateTime.Now.AddSeconds(interval),
                        TriggerRepeat    = repeact,
                        TrigggerInterval = interval
                    };
                    pth = new ParameterizedThreadStart(BackstageRun <JobDelegateFunction>);
                    Thread th = new Thread(pth);
                    th.Start(p);
                    // job.CreateJobWithParam<JobDelegateFunction>(new object[] { del, param,null }, DateTime.Now.AddSeconds(interval), interval, repeact);
                }
                else if (ckStartQuartz.Checked && rbDepth.Checked)
                {//该查询结果页轮询
                    DelegateData.BaseDelegate del = QuartzForeachPage;
                    QuartzJobParam            p   = new QuartzJobParam()
                    {
                        JobExecutionContextJobDataMap = new object[] { del, null, null },
                        StartTime        = DateTime.Now.AddSeconds(interval),
                        TriggerRepeat    = repeact,
                        TrigggerInterval = interval
                    };
                    pth = new ParameterizedThreadStart(BackstageRun <JobDelegateFunction>);
                    Thread th = new Thread(pth);
                    th.Start(p);
                    //job.CreateJobWithParam<JobDelegateFunction>(new object[] { del, null,null }, DateTime.Now.AddSeconds(interval), interval, repeact);
                }
                else if (ckStartQuartz.Checked)
                {
                    DelegateData.BaseDelegate del = QuartzCallBack;
                    QuartzJobParam            p   = new QuartzJobParam()
                    {
                        JobExecutionContextJobDataMap = new object[] { Cookie, param, del },
                        StartTime        = DateTime.Now.AddSeconds(interval),
                        TriggerRepeat    = repeact,
                        TrigggerInterval = interval
                    };
                    pth = new ParameterizedThreadStart(BackstageRun <JobAction <QQDataDA> >);
                    Thread th = new Thread(pth);
                    th.Start(p);
                    // job.CreateJobWithParam<JobAction<QQDataDA>>(new object[] { Cookie, param, del }, DateTime.Now, interval, repeact);
                }
                else
                {
                    JustQuery(param);
                }
                #endregion
            }
            else if (ckBackGroundCall.Checked && ckStartQuartz.Checked)
            {//轮询但是使用的是后台进程
                #region 使用的是后台进程
                BackGrounForeachCallType(param);
                #endregion
            }
            #region 数据同步到核心库
            if (ckSyncUin.Checked)
            { //同步数据
                string key = ForachCallEvent.SyncUinToCodeDB.ToString();
                if (BackGroundCallRunEvent.ContainsKey(key))
                {
                    BackGroundCallRunEvent.Remove(key);
                }
                DelegateData del = new DelegateData()
                {
                    BaseDel = BackGrounSyncUinToCoreDB, BaseDelegateParam = null
                };
                BackGroundCallRunEvent.Add(key, del);
            }
            #endregion
            if (!backRun.IsBusy)
            {
                backRun.RunWorkerAsync();
            }
        }
Example #5
0
        /// <summary>
        /// 对于从数据库中读取的城市数据进行处理写入到文本文件中作为基础数据使用
        /// </summary>
        /// <param name="data"></param>
        /// <param name="root"></param>
        private void AnalyCity(List <CategoryData> data, CategoryData root)
        {
            AssemblyDataExt     ass      = new AssemblyDataExt();
            string              debugDir = ass.GetAssemblyDir() + "/" + SystemConfig.RedisCacheFromFileReleative;
            CategoryGourpHelper helper   = new CategoryGourpHelper();
            CategoryGroup       result   = helper.DataGroup(data);;
            CategoryGroup       nodes    = new CategoryGroup();// (CategoryGroup)result;//提取国家列表
            string              cityDir  = debugDir + "/" + typeof(CategoryGroup).Name;

            //中国的省会列表
            foreach (CategoryGroup item in result.Childrens)
            {//查询到国家,过滤省市直辖区
                //item.Childrens = new List<CategoryGroup>();
                CategoryGroup temp = new CategoryGroup()
                {
                    Root = item.Root
                };
                nodes.Childrens.Add(temp);
            }
            string country = nodes.ConvertJson();

            Logger.CreateNewAppData(country, "Country.txt", cityDir);
            //提取中国的省会列表
            CategoryGroup provinceGroup = new CategoryGroup();
            CategoryGroup china         = result.Childrens.Where(s => s.Root.Name == root.Name).FirstOrDefault();

            provinceGroup.Root = china.Root;
            foreach (CategoryGroup item in china.Childrens)
            {//查询省会,过滤到市、区
                provinceGroup.Childrens.Add(new CategoryGroup()
                {
                    Root = item.Root
                });
                //item.Childrens = new List<CategoryGroup>();
            }
            string province = provinceGroup.ConvertJson();

            Logger.CreateNewAppData(province, GetNodeItemFileName(china,
                                                                  redisItemOrFileNameFormat(SystemConfig.RedisValueIsJsonFormat)),
                                    GetRedisRelyFileDir());
            CategoryGroup cgJson = province.ConvertObject <CategoryGroup>();

            //各个省会的市区列表
            foreach (var item in china.Childrens)
            {
                string path = LogPrepare.GetLogPath();
                LoggerWriter.CreateLogFile(item.Root.Name, path,
                                           ELogType.DebugData, DateTime.Now.ToString(Common.Data.CommonFormat.DateToHourIntFormat) + ".log", true);
                //提取省会列表到市
                CategoryGroup level = new CategoryGroup()
                {
                    Childrens = item.Childrens.Select(s => new CategoryGroup()
                    {
                        Root = s.Root
                    }).ToList()
                };
                string jsonNode = level.ConvertJson();
                //string provinceJson=item.ConvertJson();
                if (!string.IsNullOrEmpty(jsonNode))
                {
                    Logger.CreateNewAppData(jsonNode, GetNodeItemFileName(item,
                                                                          redisItemOrFileNameFormat(SystemConfig.RedisValueIsJsonFormat)),
                                            GetRedisRelyFileDir());
                    if (SystemConfig.OpenRedis)
                    {
                    }
                }
                CategoryGroup cg = new CategoryGroup()
                {
                    Root      = item.Root,
                    Childrens = item.Childrens
                };
                LoggerWriter.CreateLogFile(cg.Root.Name, path,
                                           ELogType.DebugData, DateTime.Now.ToString(Common.Data.CommonFormat.DateToHourIntFormat) + ".log", true);
                foreach (CategoryGroup c in item.Childrens)
                {//省直辖市的子节点
                    CategoryGroup cn = new CategoryGroup()
                    {
                        Root      = c.Root,
                        Childrens = c.Childrens
                    };
                    string nodeJson = string.Empty;
                    if (c.Childrens.Count > 0)
                    {
                        nodeJson = cn.ConvertJson();
                    }
                    LoggerWriter.CreateLogFile(cn.Root.Name, path,
                                               ELogType.DebugData, DateTime.Now.ToString(Common.Data.CommonFormat.DateToHourIntFormat) + ".log", true);
                    Logger.CreateNewAppData(nodeJson, GetNodeItemFileName(c,
                                                                          redisItemOrFileNameFormat(SystemConfig.RedisValueIsJsonFormat)), GetRedisRelyFileDir());
                }
            }
        }
Example #6
0
        /// <summary>
        /// 根据登录qq用户账户以及时间戳生成日志部分路径
        /// </summary>
        /// <param name="cookie"></param>
        /// <returns></returns>
        public string GeneratePathTimeSpan(string cookie)
        {
            string tag = GetUinFromCookie(cookie);

            return(LogPrepare.GetLogPath(tag));
        }