Exemplo n.º 1
0
 public string GetToken(string userName, string password)
 {
     try
     {
         List <MyParameter> sqlParameters = new List <MyParameter>();
         MyParameter        userPara      = new MyParameter("@User_Name", userName, (int)DbType.String, null);
         sqlParameters.Add(userPara);
         MyParameter userPass = new MyParameter("@User_Password", password, (int)DbType.String, null);
         sqlParameters.Add(userPass);
         string    ReadSql = @"SELECT * FROM Sys_User Where User_Name = @User_Name AND User_Password = @User_Password";
         DataTable rdt     = db.ExecuteDataTable(ReadSql, PreparParameters(sqlParameters));
         sys_User = EntityHelper.GetEntity <Sys_User>(rdt);
         if (sys_User != null)
         {
             string token = Guid.NewGuid().ToString();
             sys_User.User_Password = token;
             //System.Web.HttpContext.Current.Session["SysUser"] = sys_User;
             return(sys_User.ToJson());
         }
         throw new Exception("账号或密码不正确!");
     }
     catch (FaultException ex)
     {
         throw ex;
     }
 }
Exemplo n.º 2
0
 private Sys_WorkSet PreparWorkSet(string worksetName)
 {
     if (sys_User == null)
     {
         throw new Exception("Authentication");
     }
     if (sys_User != null)
     {
         List <MyParameter> lsp   = new List <MyParameter>();
         string             sql   = @"MyRapid_SqlCommand @WorkSet_Name ,@User_Id";
         MyParameter        pName = new MyParameter("@WorkSet_Name", worksetName, (int)DbType.String, null);
         lsp.Add(pName);
         MyParameter pUser = new MyParameter("@User_Id", sys_User.User_Id.ToString(), (int)DbType.String, null);
         lsp.Add(pUser);
         DataTable          sdt   = db.ExecuteDataTable(sql, PreparParameters(lsp));
         List <Sys_WorkSet> wkCmd = EntityHelper.GetEntities <Sys_WorkSet>(sdt);
         if (wkCmd.Count > 0)
         {
             return(wkCmd[0]);
         }
         throw new Exception($"未能找到请求的WorkSet:{worksetName}");
     }
     return(null);
 }