Exemplo n.º 1
0
 private void timer_Elapsed(object sender, EventArgs arg)
 {
     try
     {
         if (!Program.ProClose)
         {
             //检查并刷新AccessToken;
             if (RenewToken())
             {
                 dt_kw       = cmd.GetTabel("select KeyWord from KeyWords group by KeyWord");
                 dt_event    = cmd.GetTabel("select name,keyword,kid from KeyWords group by name,keyword,kid");
                 dt_partWord = cmd.GetTabel("select word,part from partword");
                 keywords    = new string[dt_kw.Rows.Count];
                 for (int i = 0; i < dt_kw.Rows.Count; i++)
                 {
                     keywords[i] = dt_kw.Rows[i][0].ToString();
                 }
                 getPublic_Timeline();
                 getFriends_Timeline();
             }
         }
     }
     catch (Exception ex)
     {
         timer.Enabled = false;
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 2
0
 public void timer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
 {
     if (!Program.ProClose)
     {
         getSinaClientAuto();
         cmd = new MySqlCmd();
         dt_kw = cmd.GetTabel("select KeyWord from KeyWords group by KeyWord");
         dt_event = cmd.GetTabel("select name,keyword,kid from KeyWords group by name,keyword,kid");
         dt_partWord = cmd.GetTabel("select word,part from partword");
         getPublic_Timeline_sina(sina, 200);
         getFriends_Timeline_sina(sina, 100);
     }
 }
Exemplo n.º 3
0
        public DataTable GetLatestData(int kid, string eventName)
        {
            DataPage firstPage = Finder.util.Comm.GetPageInfo();

            //string sql = "Select * From ReleaseInfo where pid={0} and deleted=0 order by collectdate desc limit 0,100";
            string sql = @"select b.Name eventname, a.* from releaseinfo a  left join keywords b on a.keywords=b.KeyWord 
                                    where b.Name is not null and  a.deleted=0 and a.uid between " + firstPage.CurrenPageStartUid + " and " + firstPage.CurrenPageEndUid;

            if (kid != -1)
            {
                sql += "    and a.kid=" + kid;
                if (!string.IsNullOrEmpty(eventName) && eventName != "全部")
                {
                    sql += " and  b.Name='" + eventName + "'";
                }
            }
            sql += " order by a.collectdate desc limit 0,50";
            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();

                return(dbobj.GetTabel(sql));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 4
0
        private void SystemSetting_Load(object sender, EventArgs e)
        {
            label18.ForeColor = Color.Red;
            label2.ForeColor  = Color.LightBlue;

            //填充数据
            SystemSet ss = null;

            if (GlobalPars.GloPars.ContainsKey("systemset"))
            {
                ss = (SystemSet)GlobalPars.GloPars["systemset"];
            }
            else
            {
                string    sql = "select Id,EvidenceImgSavePath from systemset";
                DataTable dt  = cmd.GetTabel(sql);
                ss    = new SystemSet();
                ss.Id = dt.Rows[0]["Id"].ToString();
                ss.EvidenceImgSavePath = dt.Rows[0]["EvidenceImgSavePath"].ToString();
                GlobalPars.GloPars.Add("systemset", ss);
            }
            tb_choosedimgpath.Text = ss.EvidenceImgSavePath;
        }
Exemplo n.º 5
0
        /// <summary>
        /// 查询采集信息(按网址)
        /// </summary>
        /// <returns></returns>
        public DataTable GetReleaseInfoFormat()
        {
            string sql = "SELECT uid,Title,Contexts,ReleaseDate,InfoSource,KeyWords,ReleaseName,CollectDate,Snapshot,webName,pid,part,comments,reposts FROM ReleaseInfo WHERE 1=2";

            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();

                return(dbobj.GetTabel(sql));
            }
            catch (Exception ex)
            {
                throw new Exception("查询失败,位置:GetReleaseInfoFormat.原因:" + ex.Message);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 查询全部的信息
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public DataTable SelReleaseInfo()
        {
            DataPage firstPage = Finder.util.Comm.GetPageInfo();
            string   sql       = "SELECT * FROM ReleaseInfo where uid between " + firstPage.CurrenPageStartUid + " and " + firstPage.CurrenPageEndUid;

            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();
                return(dbobj.GetTabel(sql));
            }
            catch (Exception ex)
            {
                throw new Exception("查询失败,位置:SelReleaseInfo.原因:" + ex.Message);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 查询信息(按ID)
        /// </summary>
        /// <returns></returns>
        public DataTable SelReleaseInfo(int uid)
        {
            string sql = "SELECT * FROM ReleaseInfo WHERE uid={0}";

            sql = string.Format(sql, uid);

            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();
                return(dbobj.GetTabel(sql));
            }
            catch (Exception ex)
            {
                throw new Exception("查询失败,位置:SelReleaseInfo.原因:" + ex.Message);
            }
        }
Exemplo n.º 8
0
        private void btn_login_Click(object sender, EventArgs e)
        {
            string username = tb_username.Text.Trim();
            string password = tb_password.Text.Trim();
            string uid      = "0";

            if (username.Length <= 0 || password.Length <= 0)
            {
                MessageBox.Show("请填写用户名和密码!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            string sql = "SELECT * FROM LoginUser WHERE UName='{0}'";

            sql = string.Format(sql, username);

            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();
                DataTable one = dbobj.GetTabel(sql);
                if (one.Rows.Count <= 0)
                {
                    MessageBox.Show("您输入的用户名和密码不正确!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                object pwd = one.Rows[0]["PWord"];
                if (!(pwd != null) || (password != pwd.ToString()))
                {
                    MessageBox.Show("您输入的用户名和密码不正确!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                uid = one.Rows[0]["uid"].ToString();
            }
            catch (Exception ex)
            {
                MessageBox.Show("出现异常,请稍后重试或联系软件提供商!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            UserInfo ui = new UserInfo();

            ui.UName = username;
            ui.Pword = password;
            ui.Uid   = uid;
            //将用户信息放入到缓存中。
            GlobalPars.GloPars.Add("UserInfo", ui);
            this.Close();
        }
Exemplo n.º 9
0
        /// <summary>
        /// 查询采集信息
        /// </summary>
        /// <param name="t1">时间起</param>
        /// <param name="t2">时间至</param>
        /// <param name="infoType">数据类型</param>
        /// <returns></returns>
        public DataTable SelReleaseInfo(string t1, string t2, string pid)
        {
            DataPage firstPage = Finder.util.Comm.GetPageInfo();
            string   sql       = "SELECT * FROM ReleaseInfo WHERE CollectDate BETWEEN '{1}' AND '{0}' AND pid={2}  and uid between " + firstPage.CurrenPageStartUid + " and " + firstPage.CurrenPageEndUid + " ORDER BY CollectDate";

            sql = string.Format(sql, t1, t2, pid);
            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();

                return(dbobj.GetTabel(sql));
            }
            catch (Exception ex)
            {
                throw new Exception("查询失败,位置:SelReleaseInfo.原因:" + ex.Message);
            }
        }
Exemplo n.º 10
0
        public DataTable GetLatestData(int pid)
        {
            DataPage firstPage = Finder.util.Comm.GetPageInfo();

            //string sql = "Select * From ReleaseInfo where pid={0} and deleted=0 order by collectdate desc limit 0,100";
            string sql = @"select b.Name eventname, a.* from releaseinfo a  left join keywords b on a.keywords=b.KeyWord 
                                    where b.Name is not null and  a.pid={0} and a.deleted=0 and a.uid between " + firstPage.CurrenPageStartUid + " and " + firstPage.CurrenPageEndUid
                         + " order by a.collectdate desc limit 0,50";

            sql = string.Format(sql, pid);
            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();

                return(dbobj.GetTabel(sql));
            }
            catch (Exception ex)
            {
                return(null);
            }
        }
Exemplo n.º 11
0
        public int GetMaxUid()
        {
            string sql = "SELECT max(uid) FROM ReleaseInfo";

            try
            {
                DataBaseServer.MySqlCmd dbobj = new MySqlCmd();
                DataTable dt = new DataTable();
                dt = dbobj.GetTabel(sql);
                try
                {
                    return(int.Parse(dt.Rows[0][0].ToString()));
                }
                catch (Exception)
                {
                    return(0);
                }
            }
            catch (Exception ex)
            {
                throw new Exception("查询失败,位置:GetMaxUid.原因:" + ex.Message);
            }
        }
Exemplo n.º 12
0
        public void timer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
        {
            //关键字预警方式表
            string timeNow    = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            string timeBefore = "";

            int aviCount = 1;
            //int sendAviCountSMS=1;
            string sql = "";
            //string url = "http://www.shangwukaocha.cn/finder/users.php?userID=" + userID + "&m=q";      //取短信余额的网址,用userid先去服务端取可用短信数量aviCount
            ////每次往服务端提交一次短信使用量,服务端用来记录用户短信可用数量。当到达一定阀值,给用户发短信提示短信不足。
            //string[] retVal = new string[3] { "", "","" };
            //try
            //{
            //    string _r = postSend(url, "");
            //    if (_r.Contains(','))
            //    {
            //       retVal = _r.Split(',');
            //    }
            //    aviCount = int.Parse(retVal[0].Equals("") ? "1" : retVal[0]);         //可用量
            //    sendAviCountSMS = int.Parse(retVal[1].Equals("") ? "1" : retVal[1]);  //是否已发送短信账户不足提示
            //}
            //catch (FormatException fe) {}

            //DataTable dt_alert_collection_sms = cmd.GetTabel("select * from warn where WarnWay=1");
            //DataTable dt_alert_collection_snd = cmd.GetTabel("select * from warn where WarnWay=2");

            string   sendText = "";
            DateTime hashtableTime;
            int      thisTimeCount              = 0;  //本次短信使用数量
            string   tmp_IntervalHours          = ""; //每个关键词的预警周期
            int      tmp_IntervalHoursTotalInfo = 0;  //每个关键词的预警数量
            string   tmp_keyword       = "";          //关键词
            string   tmp_sendContent   = "";          //关键词报警短信发送的内容
            string   tmp_phoneNumber   = "";          //发送到手机号
            string   tmp_hasSmsAlerted = "0";         //同一个关键词短信是否已报过警,报过为1

            DataTable dt_alert_collection = cmd.GetTabel("select * from warn");

            for (int icount = 0; icount <= dt_alert_collection.Rows.Count - 1; icount++)
            {
                //短信预警开始
                if (dt_alert_collection.Rows[icount]["WarnWay"].ToString().Equals("1"))
                {
                    if (aviCount > 0)
                    {
                        tmp_IntervalHours          = dt_alert_collection.Rows[icount]["IntervalHours"].ToString();
                        tmp_IntervalHoursTotalInfo = int.Parse(dt_alert_collection.Rows[icount]["IntervalHoursTotalInfo"].ToString());
                        timeBefore      = DateTime.Now.AddHours(-double.Parse(tmp_IntervalHours)).ToString("yyyy-MM-dd HH:mm:ss");
                        tmp_keyword     = dt_alert_collection.Rows[icount]["keyword"].ToString();
                        tmp_sendContent = dt_alert_collection.Rows[icount]["WarnContent"].ToString();
                        tmp_phoneNumber = dt_alert_collection.Rows[icount]["mobile"].ToString();

                        sql = "select * from sms where keyword = '" + tmp_keyword + "' order by sendtime desc";
                        DataTable dtsms = cmd.GetTabel(sql);
                        if (dtsms != null && dtsms.Rows.Count > 0)
                        {
                            string lastTime = dtsms.Rows[0]["sendtime"].ToString();
                            if (string.Compare(timeBefore, lastTime) < 0)
                            {
                                timeBefore = lastTime;
                            }
                        }
                        //2015.3.18 wangcg 修改后,ReleaseInfo数据库的keywords字段存储的是关键字不是事件名称,需要修改sql
                        //sql = "select count(1) cs,keywords from releaseinfo where collectdate between '"
                        //    + timeBefore + "' and '"
                        //    + timeNow + "' and "
                        //    + " keywords = '" + tmp_keyword + "'";
                        //样例sql:
                        //select count(*) cs, b.name from releaseinfo a
                        //left join keywords b on a.keywords=b.[KeyWord]
                        //where b.[Name]='自然灾害'
                        sql = @"select count(1) cs,b.Name keywords from releaseinfo a
                                left join keywords b on a.keywords=b.KeyWord
                                where a.collectdate between '{0}' and '{1}'
                                and  b.Name='{2}'";
                        sql = string.Format(sql, timeBefore, timeNow, tmp_keyword);
                        DataTable dt_SMS = cmd.GetTabel(sql);

                        if (int.Parse(dt_SMS.Rows[0]["cs"].ToString()) >= tmp_IntervalHoursTotalInfo)
                        {
                            tmp_hasSmsAlerted = "1";
                            //短时间内刚发过同样短信就不再发的判断
                            //if (ht.Contains(tmp_keyword))
                            //{
                            //    hashtableTime = (DateTime)ht[tmp_keyword];
                            //    if ((DateTime.Now - hashtableTime).TotalMinutes > double.Parse(tmp_IntervalHours) * 60)
                            //    {
                            sendText = StringReplace(tmp_sendContent, "[事件名称]", insertSign(tmp_keyword));
                            sendSMS(sendText, tmp_phoneNumber, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            thisTimeCount++;
                            //aviCount--;
                            //ht.Remove(tmp_keyword);
                            //ht.Add(tmp_keyword, DateTime.Now);
                            sendText = "";

                            //发完短信在数据库中插入刚才发的短信记录
                            sql = "insert into sms (content,sendtime,mobile,keyword) values ('"
                                  + tmp_sendContent + "','"
                                  + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','"
                                  + tmp_phoneNumber + "','"
                                  + tmp_keyword + "')";
                            cmd.ExecuteNonQueryInt(sql);
                            //    }
                            //}
                            //else
                            //{
                            //    ht.Add(tmp_keyword, DateTime.Now);
                            //    sendText = StringReplace(tmp_sendContent, "[事件名称]", insertSign(tmp_keyword));
                            //    sendSMS(sendText, tmp_phoneNumber, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                            //    thisTimeCount++;
                            //    //aviCount--;
                            //    sendText = "";

                            //    //发完短信在数据库中插入刚才发的短信记录
                            //    sql = "insert into sms (content,sendtime,mobile,keyword) values ('"
                            //                + tmp_sendContent + "','"
                            //                + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "','"
                            //                + tmp_phoneNumber + "','"
                            //                + tmp_keyword + "')";
                            //    cmd.ExecuteNonQueryInt(sql);
                            //}
                        }
                        else
                        {
                            tmp_hasSmsAlerted = "0";
                        }

                        //if (aviCount <= 100 && sendAviCountSMS == 0)
                        //{
                        //    sendSMS("截止目前,您的舆情系统账户短信剩余量已不足100条,请尽快联系客服续费!",
                        //            tmp_phoneNumber,
                        //            DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        //}

                        //"把本次使用量thisTimeCount,userID作为参数请求url"
                        string url = "http://www.shangwukaocha.cn/finder/users.php?userID=" + userID + "&m=usc&smscount=" + thisTimeCount.ToString();
                        //2016.4.17 地址已经失效,去掉短信条数的登记服务
                        //postSend(url, "");



                        //if (int.Parse(retVal[2].Equals("") ? "0" : retVal[2]) == 0 && aviCount <= 0)
                        //{
                        //    sendSMS("截止目前,您的舆情系统账户短信剩余量已为0,短信功能将停止,请尽快联系客服续费!",
                        //            tmp_phoneNumber,
                        //            DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                        //}
                    }     //短信预警结束
                }
                else
                {
                    //声音预警开始
                    if (dt_alert_collection.Rows[icount]["keyword"].ToString().Equals(tmp_keyword))
                    {
                        //该关键字短信已经报警则声音也报警
                        if (tmp_hasSmsAlerted.Equals("1"))
                        {
                            tmp_sendContent = dt_alert_collection.Rows[icount]["WarnContent"].ToString();
                            soundAlert(tmp_keyword, tmp_sendContent);
                        }
                    }
                    else
                    {
                        tmp_IntervalHours          = dt_alert_collection.Rows[icount]["IntervalHours"].ToString();
                        tmp_IntervalHoursTotalInfo = int.Parse(dt_alert_collection.Rows[icount]["IntervalHoursTotalInfo"].ToString());
                        timeBefore      = DateTime.Now.AddHours(-double.Parse(tmp_IntervalHours)).ToString("yyyy-MM-dd HH:mm:ss");
                        tmp_keyword     = dt_alert_collection.Rows[icount]["keyword"].ToString();
                        tmp_sendContent = dt_alert_collection.Rows[icount]["WarnContent"].ToString();
                        tmp_phoneNumber = dt_alert_collection.Rows[icount]["mobile"].ToString();

                        //sql = "select count(1) cs,keywords from releaseinfo where collectdate between '"
                        //    + timeBefore + "' and '"
                        //    + timeNow + "' and "
                        //    + " keywords = '" + tmp_keyword + "'";

                        sql = "select * from soundAlert where keyword = '" + tmp_keyword + "' order by sendtime desc";
                        DataTable dtsms = cmd.GetTabel(sql);
                        if (dtsms != null && dtsms.Rows.Count > 0)
                        {
                            string lastTime = dtsms.Rows[0]["sendtime"].ToString();
                            if (string.Compare(timeBefore, lastTime) < 0)
                            {
                                timeBefore = lastTime;
                            }
                        }

                        //样例sql:
                        //select count(*) cs, b.name from releaseinfo a
                        //left join keywords b on a.keywords=b.[KeyWord]
                        //where b.[Name]='自然灾害'
                        sql = @"select count(1) cs,b.Name keywords from releaseinfo a
                                left join keywords b on a.keywords=b.KeyWord
                                where a.collectdate between '{0}' and '{1}'
                                and  b.Name='{2}'";
                        sql = string.Format(sql, timeBefore, timeNow, tmp_keyword);

                        DataTable dt_SND = cmd.GetTabel(sql);

                        if (int.Parse(dt_SND.Rows[0]["cs"].ToString()) >= tmp_IntervalHoursTotalInfo)
                        {
                            //此处还应加短时间内刚发过同样内容的声音预警就不再播放声音的判断
                            soundAlert(tmp_keyword, tmp_sendContent);
                        }
                    }
                } //声音预警结束
            }
        }