コード例 #1
0
ファイル: Test1.aspx.cs プロジェクト: rongcheng/benz
        protected void Page_Load(object sender, EventArgs e)
        {

            //throw new Exception("hahaha");
            //string img1 = @"c:\rc111.jpg";

            //string waterMark = @"c:\water.gif";

            //ImageHelper obj = new ImageHelper(img1);
            //obj.SetGrayscale();
            //obj.SetColorFilter(ColorFilterTypes.Green);
            //obj.SetGamma(200, 100, 100);
            //obj.SetBrightness(-80);
            //obj.SetContrast(50);
            //obj.SetInvert();
            //obj.Resize(900);
            //obj.Resize(600, 1000);
            //obj.RotateFlip(System.Drawing.RotateFlipType.Rotate180FlipX);
            //obj.Crop(230, 160, 200, 200);
            //obj.SetGrayscale();
            //obj.InsertText("中国人", 10, 10, "", 32, "", "red", "");
            //obj.InsertImage(waterMark, 20, 20);
            //obj.InsertImage(waterMark, WathermarkPosition.BottomLeft);


            
            //obj.Save(@"c:\z2222.jpg");

            //MemoryStream ms=new MemoryStream();
            //obj.GetImage().Save(ms,System.Drawing.Imaging.ImageFormat.Jpeg);
            //Response.ContentType = "image/Jpeg";
            //Response.Write(obj.GetImage());
            //Response.BinaryWrite(ms.ToArray());

            //Response.ContentType = "image/Jpeg";
            //Response.Clear();
            //Response.BufferOutput = true;
            //obj.GetImage().Save(Response.OutputStream, ImageFormat.Jpeg);
            //Response.End();

            //obj.Dispose();

            //s = "男";
            //Response.Write(s);
            //string s = Request.QueryString["s"];
            //Response.Write(s);
            //string[] sa = GetRelatedKeywords(s);

            //foreach (string x in sa)
            //{
            //    Response.Write(x);
            //    Response.Write("<br/>");
            //}



            //IList<string> color = new List<string>();
            //for (int r = 0; r <=256; r=r+64)
            //{
            //    for (int g = 0; g <=256; g=g+64)
            //    {

            //        for (int b = 0; b <= 256; b = b + 64)
            //        {

            //            color.Add("#" + to2(Convert.ToString(r,16))+ to2(Convert.ToString(g, 16)) + to2(Convert.ToString(b, 16)));
                        
                    
            //        }
            //    }
            //}

            //Response.Write("<div>");
            //foreach (string s in color)
            //{
            //    Response.Write("<font color="+s+">10</font> ");
            //}
            //Response.Write("</div>");



           // Response.Write(MemberShipManager.loginBoss("test2011", "12341234x").ToString());



            Boss objBoss=new Boss();

            string roleName = "总监";
            string groupName = "香港";

            roleName = objBoss.GetVrmsRoleByBossRole(roleName);
            groupName = objBoss.GetVrmsGroupByBossGroup(groupName);

            Response.Write("groupId:"+Group.GetGroupIdByGroupName(groupName));
            Response.Write("<br>");
            Response.Write("roleId:"+Role.GetRoleIdByName(roleName));




            


            string userName, password;
            userName = "******";
            password = "******";


            bool isOk = MemberShipManager.loginBoss(userName, password);

            if (isOk)
            {
                string[] arr = MemberShipManager.GetBossGroup(userName, password);
                foreach (string s in arr)
                {
                    Response.Write(s + "<br/>");
                }
            }
            else
            {
                Response.Write("用户名密码不正确");
            }

        }
コード例 #2
0
ファイル: MemberShipManager.cs プロジェクト: rongcheng/benz
        public static bool AuthUserByRequest(string loginName, string password, string ipAddress, ref object returnObj, bool isCreated) {
            string addressParam = ConfigurationManager.AppSettings["RequestUrl"];
            string lnParam = ConfigurationManager.AppSettings["LoginNameParamName"];
            string pParam = ConfigurationManager.AppSettings["PasswordParamName"];
            string ipParam = ConfigurationManager.AppSettings["IPParamName"];

            string url;
            if (addressParam.Contains("?"))
            {
                url = addressParam + "&" + lnParam + "=" + loginName + "&" + pParam + "=" + password + "&" + ipParam + "=" + ipAddress;
            }
            else
            {
                url = addressParam + "?" + lnParam + "=" + loginName + "&" + pParam + "=" + password + "&" + ipParam + "=" + ipAddress;                
            }
            
                
            string result = DoGetRequest(url);

            if (result == "0") {

                //这里远程验证如果错误的话,就进行一次数据库验证
                QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
                SerializeObjectFactory sof = new SerializeObjectFactory();
                string objStr = mss.AuthUserByForm(loginName, password, ipAddress);                

                if (!string.IsNullOrEmpty(objStr))
                {
                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;
                    return true;
                }

                return false;
            }
            else {



                //这里先要获得该用户的机构(groupId)和角色(roleId)
                    string[] arrIds = new Boss().GetVrmsId(loginName, password);
                    string roleId = arrIds[0];
                    string groupId = arrIds[1];
                    string email=arrIds[2];

                    if (string.IsNullOrEmpty(roleId))
                    {
                        roleId = ConfigurationManager.AppSettings["RoleID"];
                    }
                    if (string.IsNullOrEmpty(groupId))
                    {
                        groupId = "356b8e9c-005d-47ae-8aad-e7d1d60a1496";
                    }

                    if(string.IsNullOrEmpty(email))
                    {
                        email= loginName + "@quanjing.com";
                    }





                if (isCreated)
                {
                    
                    MemberShipManager msm = new MemberShipManager();
                    //string email = loginName + "@sany.com.cn";
                    IUser u = msm.CreateUser(password, loginName, loginName,
                        new Guid(groupId), email, string.Empty, false, "false", false);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)u;
                    //string roleID = ConfigurationManager.AppSettings["RoleID"];
                    string roleID = roleId;
                    //分配角色
                    Role.CreateRoleUsers(new Guid[] { new Guid(roleID) }, user.UserId);
                    returnObj = user;
                }
                else
                {
                    QJVRMS.Business.MemWS.MemberShipService mss = new QJVRMS.Business.MemWS.MemberShipService();
                    SerializeObjectFactory sof = new SerializeObjectFactory();

                    //string objStr = mss.AuthUserByForm(loginName, password, ipAddress);
                    string objStr = mss.GetUserByLoginName(loginName);

                    object o = sof.DesializeFromBase64(objStr);
                    QJVRMS.Business.User user = (QJVRMS.Business.User)o;
                    returnObj = user;

                    //如果数据库里有这个用户的话,就更新一次密码(这里应该判断一下用户是否相等),更新一下角色、机构和email
                    mss.ResetPassword(user.UserId,password);

                    bool isDownloaded = false;
                    if (user.IsDownLoad.ToLower().Equals("true"))
                    {
                        isDownloaded = true;
                    }
                    mss.ModifyUserInfo1(user.UserId, new Guid(groupId), user.UserName, email, user.Telphone, user.IsLocked, isDownloaded, user.IsIPValidate);

                    Role.CreateRoleUsers(new Guid[] { new Guid(roleId) }, user.UserId);
                    
                    
                    
                }
                
            }

            return true;
        }