Ejemplo n.º 1
0
 // 登入消息处理
 public static bool login(string account, string password, string ip, string port)
 {
     try
     {
         string homeFolder   = CommonStaticVariables.homePath + account;
         string selectCmdStr = "SELECT * FROM tb_accounts WHERE account = '" + account + "' And password = '******'";
         string updateCmdStr = "UPDATE tb_accounts SET ip = '" + ip + "', port = '" + port + "', status = '" + CommonStaticVariables.statusOnline + "', home = '" + homeFolder + "', lastTime = '" + DateTime.Now + "' WHERE account = '" + account + "' AND password = '******'";
         if (SQLHandler.DrRead(selectCmdStr))
         {
             SQLHandler.OperateRecord(updateCmdStr);
             if (!Directory.Exists(homeFolder))
             {
                 FileSystemHandler.CreateDirectory(homeFolder, DateTime.Now);
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
         return(false);
     }
 }
Ejemplo n.º 2
0
 // 注册消息处理
 public static bool registration(string account, string password, string ip, string port)
 {
     try
     {
         string homeFolder   = CommonStaticVariables.homePath + account;
         string selectCmdStr = "SELECT account FROM tb_accounts WHERE account = '" + account + "'";
         if (SQLHandler.DrRead(selectCmdStr))
         {
             return(false);
         }
         else
         {
             string insertCmdStr = "INSERT INTO tb_accounts (account, password, ip, port, status, home, registerTime) VALUES ( '" + account + "','" + password + "', '" + ip + "', '" + port + "', '" + CommonStaticVariables.statusOffline + "', '" + homeFolder + "', '" + DateTime.Now + "')";
             SQLHandler.OperateRecord(insertCmdStr);
             FileSystemHandler.CreateDirectory(homeFolder, DateTime.Now);
             return(true);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message.ToString());
         return(false);
     }
 }