コード例 #1
0
        //保存数据库信息
        public void SaveDatabase()
        {
            NameValueCollection Params   = HttpContext.Request.Form;//参数
            Database            database = new Database();

            database.Author      = User.Identity.Name;
            database.ProjectCode = new Guid(Params["projectCode"]);
            database.Name        = Params["name"];
            database.Alias       = Params["alias"];
            database.Type        = Params["type"];
            database.ServerName  = Params["serverName"];
            database.ServerUser  = Params["serverUser"];
            database.ServerPwd   = NHibernateHelper.EncryptAES(Params["serverPwd"], "zhangzhangdebing");//加密
            database.Bewrite     = Params["bewrite"];
            string result = string.Empty;

            if (Params["code"] != null)
            {
                database.Code = new Guid(Params["code"]);
                result        = DDatabase.Update(database) != null ? "{HasError:false,msg:'数据库编辑成功!'}" : "{HasError:true,msg:'数据库编辑失败,请稍候再试!'}";
            }
            else
            {
                database.Code = Guid.NewGuid();
                result        = DDatabase.Add(database) != null ? "{HasError:false,msg:'数据库创建成功!'}" : "{HasError:true,msg:'数据库创建失败,请稍候再试!'}";
            }
            Response.Write(result);
            Response.End();
        }