Ejemplo n.º 1
0
        /// <summary>
        /// 检查用户状态
        /// </summary>
        /// <param name="intSID">用户SID</param>
        /// <returns>1\禁用 0\正常</returns>
        public static byte UserStatus(int intSID)
        {
            byte byteStatus = 0;

            string strSQL = "SELECT TOP 1 Status FROM Fx_User WHERE [SID] = " + intSID + "";

            try
            {
                DataRow dr = SqlHelper.ExecuteDataRow(SqlLibrary.GetFx_Main(), CommandType.Text, strSQL);
                byteStatus = Convert.ToByte(dr["Status"]);
                if (byteStatus == 1)
                {
                    Console.WriteLine("==================== [系统消息] 开始 ================== \r\n");
                    Console.WriteLine("UserID:" + intSID + " 已被锁定!\r\n");
                    Console.WriteLine("==================== [系统消息] 结束 ================== \r\n");
                }
                else if (byteStatus == 0)
                {
                    byteStatus = 0;
                }
            }
            catch
            {
                Console.WriteLine("==================== [系统消息] 开始 ================== \r\n");
                Console.WriteLine("UserID:" + intSID + " 查无此用户!\r\n");
                Console.WriteLine("==================== [系统消息] 结束 ================== \r\n");
            }
            return(byteStatus);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 发送消息
        /// </summary>
        public static void SendMessage()
        {
            int    intID         = 0;
            int    intSID        = 0;
            string strSMSContent = "";

            string strSQL = "SELECT TOP 1 ID,SID,SMSContent FROM Fx_OutBox WHERE [Status] = 0";

            Console.WriteLine(strSQL);//111111111111111111111111111111111
            try
            {
                Console.WriteLine("==================== [发送消息] 开始 ================== \r\n");
                DataRow dr = SqlHelper.ExecuteDataRow(SqlLibrary.GetFx_Main(), CommandType.Text, strSQL);
                intID         = Convert.ToInt32(dr["ID"]);
                intSID        = Convert.ToInt32(dr["SID"]);
                strSMSContent = Convert.ToString(dr["SMSContent"]);
                Console.WriteLine(intID + " " + intSID + " " + strSMSContent); //111111111111111111111111
                string[] arrSMSContent = strSMSContent.Split(new char[] { ' ' });
                Console.WriteLine(arrSMSContent.Length);                       //1111111111111111111111111
                if (arrSMSContent.Length > 1)
                {
                    if (intID > 0)
                    {
                        Console.WriteLine("用户状态:" + UserStatus(intSID));//111111111111111111
                        if (UserStatus(intSID) == 0)
                        {
                            Console.WriteLine("SysConsole: " + intSID + "  " + arrSMSContent[0].ToLower().ToString() + "  " + arrSMSContent[1].ToLower().ToString());
                            SysConsole(intSID, arrSMSContent[0].ToLower().ToString(), arrSMSContent[1].ToLower().ToString());
                            Console.WriteLine("sysconsole runing");//11111111111111111
                            intID = SqlLibrary.Fx_UpdateMessage(intID);
                            Console.WriteLine("[信息已发出]");
                            Console.WriteLine("发送对像:" + intSID + " 命令:" + arrSMSContent[0].ToString() + " 参数:" + arrSMSContent[1].ToString() + "\r\n");
                        }
                        else
                        {
                            SqlLibrary.Fx_UpdateMessage(intID);
                            Console.WriteLine("[信息已被取消]");
                        }
                    }
                    else
                    {
                        Console.WriteLine("[信息标记出错]");
                    }
                }
                else
                {
                    SqlLibrary.Fx_UpdateMessage(intID);
                    Console.WriteLine("[信息已被取消]");
                }
                Console.WriteLine("==================== [发送消息] 结束 ================== \r\n");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                //Console.WriteLine("[没有要发送的消息]\r\n");
                Console.WriteLine("==================== [发送消息] 结束 ================== \r\n");
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 运行计划任务
        /// </summary>
        public static void RunTask()
        {
            int    intID       = 0;
            int    intSID      = 0;
            int    intCategory = 0;
            string strTask     = "";
            byte   byteStatus  = 0;

            string strSQL = "SELECT TOP 1 ID,[SID],Category,Task,RunTime,[Status] FROM Fx_Task WHERE [Status] = 1 AND RunTime < CONVERT(Char(10),GetDate()+1,120) ORDER BY RunTime";

            try
            {
                Console.WriteLine("==================== [计划任务] 开始 ================== \r\n");

                DataRow dr = SqlHelper.ExecuteDataRow(SqlLibrary.GetFx_Main(), CommandType.Text, strSQL);
                intID       = Convert.ToInt32(dr["ID"]);
                intSID      = Convert.ToInt32(dr["SID"]);
                intCategory = Convert.ToInt32(dr["Category"]);
                strTask     = Convert.ToString(dr["Task"]);
                byteStatus  = Convert.ToByte(dr["Status"]);
                string[] arrTask = strTask.Split(new char[] { ' ' });
                Console.WriteLine(Convert.ToDateTime(dr["RunTime"]) + "<" + DateTime.Now + "&&" + byteStatus);
                if (Convert.ToDateTime(dr["RunTime"]) < DateTime.Now && byteStatus == 1)
                {
                    Console.WriteLine(">>>>>>>>>进入计划任务判断<<<<<<<<");
                    SysConsole(intSID, arrTask[0].ToLower().ToString(), arrTask[1].ToLower().ToString());
                    SqlLibrary.Fx_UpdateTaskRuntime(intID);
                    Console.WriteLine("发送对像:" + intSID + " 命令:" + arrTask[0].ToString() + " 参数:" + arrTask[1].ToString() + " 任务编号:" + intID + "\r\n");
                    Console.WriteLine("==================== [计划任务] 结束 ================== \r\n");
                }
            }
            catch
            {
                Console.WriteLine("---[没有计划任务要执行]--- \r\n");
                Console.WriteLine("==================== [计划任务] 结束 ================== \r\n");
            }
        }