Beispiel #1
0
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        LoginSite lg = new LoginSite();

        lg.Senha = ValidParam.ValidarParametro(txtSenha.Text);
        lg.Login = ValidParam.ValidarParametro(txtLogin.Text);
        if (lg.Senha != "")
        {
            if (lg.Valida() == true)
            {
                Session["LOGADO"]     = lg.Nome;
                Session["CPF"]        = lg.Login;
                Session["cd_usuario"] = lg.Codigo;
                lblResultado.Text     = lg.Nome;
                Response.Redirect("AreaRestrita.aspx");
            }
            else
            {
                lblResultado.Text = "Erro ao efetuar o login";
            }
        }
        else
        {
            lblResultado.Text = "Erro ao efetuar o login informe uma senha.";
        }
    }
Beispiel #2
0
        /// <summary>
        /// Operation the specified loginSite, imageUrl and image.
        /// </summary>
        /// <param name="loginSite">Login site.</param>
        /// <param name="imageUrl">Image URL.</param>
        /// <param name="image">Image.</param>
        public string Operation(LoginSite loginSite, string imageUrl = "", Image image = null)
        {
            string     result    = "";
            TTransport transport = new TSocket(_host, _port);

            try
            {
                TProtocol protocol            = new TBinaryProtocol(transport);
                ThriftOperation.Client client = new ThriftOperation.Client(protocol);
                transport.Open();
                OperationObj operationObj = new OperationObj()
                {
                    LoginSite = loginSite,
                    ImageUrl  = imageUrl,
                    Image     = ImageHelper.GetBytesByImage(image)
                };

                result = client.Operation(operationObj);
            }
            catch (Exception ex)
            {
                ILog logger = LogManager.GetLogger(typeof(ThriftHelper));
                logger.Error("Operation Not Found!" + Environment.NewLine + ex.ToString());
            }
            finally {
                transport.Close();
            }
            return(result);
        }
        /// <summary>
        /// Login the specified userName, password and loginSite.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password.</param>
        /// <param name="loginSite">Login site.</param>
        /// <returns>cookies string</returns>
        public LoginResult Login(string userName, string password, LoginSite loginSite)
        {
            LoginResult result = new LoginResult();

            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                result.Result = ResultType.Failed;
                result.Msg    = "error, username or password can't be null.";
            }
            else
            {
                bool hasOperation = false;

                foreach (Lazy <ILogin, ILoginSiteData> i in operations)
                {
                    if (i.Metadata.loginSite.Equals(loginSite))
                    {
                        hasOperation = true;
                        result       = i.Value.DoLogin(userName, password);
                    }
                }

                if (!hasOperation)
                {
                    result.Result = ResultType.Failed;
                    result.Msg    = "error, can't find the login class.";
                }
            }

            return(result);
        }
        /// <summary>
        /// Operation the specified loginSite, imageUrl and image.
        /// </summary>
        /// <param name="loginSite">Login site.</param>
        /// <param name="imageUrl">Image URL.</param>
        /// <param name="image">Image.</param>
        public string Operation(LoginSite loginSite, string imageUrl = "", Image image = null)
        {
            try
            {
                if (_method.ToUpper() == "GET")
                {
                    return(HttpHelper.GetHttpContent(string.Format(_urlFormat, (int)loginSite, imageUrl)));
                }
                else if (_method.ToUpper() == "POST")
                {
                    string postData = JsonConvert.SerializeObject(
                        new OperationObj()
                    {
                        LoginSite = loginSite, ImageUrl = imageUrl, Image = ImageHelper.GetBytesByImage(image)
                    });
                    return(HttpHelper.GetHttpContent(_urlFormat, postData));
                }

                ILog logger = LogManager.GetLogger(typeof(RESTHelper));
                logger.Error("Operation Method Not Found!");
            }
            catch (Exception ex)
            {
                ILog logger = LogManager.GetLogger(typeof(RESTHelper));
                logger.Error("Operation Not Found!" + Environment.NewLine + ex.ToString());
            }
            return("");
        }
Beispiel #5
0
 public void Wait_until_login_form_exist(LoginSite _site = LoginSite.RDS)
 {
     switch (_site.ToString())
     {
     case "RDS":
         explicitWaitUntilExist(LoginRepo.LOGIN_FORM_RDS);
         break;
     }
 }
Beispiel #6
0
            public void Read(TProtocol iprot)
            {
                TField field;

                iprot.ReadStructBegin();
                while (true)
                {
                    field = iprot.ReadFieldBegin();
                    if (field.Type == TType.Stop)
                    {
                        break;
                    }
                    switch (field.ID)
                    {
                    case 1:
                        if (field.Type == TType.String)
                        {
                            UserName = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 2:
                        if (field.Type == TType.String)
                        {
                            Password = iprot.ReadString();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    case 3:
                        if (field.Type == TType.I32)
                        {
                            LoginSite = (LoginSite)iprot.ReadI32();
                        }
                        else
                        {
                            TProtocolUtil.Skip(iprot, field.Type);
                        }
                        break;

                    default:
                        TProtocolUtil.Skip(iprot, field.Type);
                        break;
                    }
                    iprot.ReadFieldEnd();
                }
                iprot.ReadStructEnd();
            }
Beispiel #7
0
 public string SendMail(LoginSite loginSite, string imageUrl)
 {
     if (MailHelper.SendEmail(loginSite.ToString() + "Logining, please help me!", string.Format("<img src=\"{0}\"><br /> {0}", imageUrl)))
     {
         return("success");
     }
     else
     {
         return(null);
     }
 }
 public string SendMail(LoginSite loginSite, string imageUrl)
 {
     if (MailHelper.SendEmail(loginSite.ToString() + "登录中,请求协助!", string.Format("<img src=\"{0}\"><br /> {0}", imageUrl)))
     {
         return("success");
     }
     else
     {
         return("");
     }
 }
Beispiel #9
0
    public static void ShowAcessos(string cpf)
    {
        string    strCss = "";
        DataTable dt     = LoginSite.Listar(cpf);

        for (int i = 0; i < dt.Rows.Count; i++)
        {
            strCss = strCss + "<li><span><a href='" + dt.Rows[i]["pagina"].ToString() + "'>" + dt.Rows[i]["nome_modulo"].ToString() + "</a></span></li>";
        }
        HttpContext.Current.Response.Write(strCss);
    }
Beispiel #10
0
            public void send_Login(string userName, string password, LoginSite loginSite)
            {
                oprot_.WriteMessageBegin(new TMessage("Login", TMessageType.Call, seqid_));
                Login_args args = new Login_args();

                args.UserName  = userName;
                args.Password  = password;
                args.LoginSite = loginSite;
                args.Write(oprot_);
                oprot_.WriteMessageEnd();
                oprot_.Transport.Flush();
            }
        /// <summary>
        /// Operation the specified loginSite, imageUrl and image.
        /// </summary>
        /// <param name="loginSite">Login site.</param>
        /// <param name="imageUrl">Image URL.</param>
        /// <param name="image">Image.</param>
        public static string Operation(LoginSite loginSite, string imageUrl = "", Image image = null)
        {
            if (pluginConfig != null)
            {
                var extensions = pluginConfig.Extensions.Where(f => f.SupportSite.Contains(loginSite));
                if (extensions != null)
                {
                    foreach (Extension extension in extensions)
                    {
                        string result = "";
                        switch (extension.ExtendType)
                        {
                        case PluginType.MEF:
                            MEFHelper mefHelper = new MEFHelper(extension.Path);
                            result = mefHelper.Operation(loginSite, imageUrl, image);
                            break;

                        case PluginType.REST:
                            RESTHelper restHelper = new RESTHelper(extension.UrlFormat, extension.HttpMethod);
                            result = restHelper.Operation(loginSite, imageUrl, image);
                            break;

                        case PluginType.Thrift:
                            ThriftHelper thriftHelper = new ThriftHelper(extension.Host, extension.Port);
                            result = thriftHelper.Operation(loginSite, imageUrl, image);
                            break;
                        }
                        if (!string.IsNullOrEmpty(result))
                        {
                            return(result);
                        }
                    }
                }
                else
                {
                    ILog logger = LogManager.GetLogger(typeof(PluginHelper));
                    logger.Error("Extension Not Found!");
                }
            }
            else
            {
                ILog logger = LogManager.GetLogger(typeof(PluginHelper));
                logger.Error("Extension Config File Not Found!");
            }
            return("");
        }
Beispiel #12
0
 /// <summary>
 /// Operation the specified loginSite, imageUrl and image.
 /// </summary>
 /// <param name="loginSite">Login site.</param>
 /// <param name="imageUrl">Image URL.</param>
 /// <param name="image">Image.</param>
 public string Operation(LoginSite loginSite, string imageUrl = "", Image image = null)
 {
     try
     {
         foreach (Lazy <IMEFOperation, ILoginSiteData> i in operations)
         {
             if (i.Metadata.loginSite == loginSite)
             {
                 return(i.Value.Operate(imageUrl, image));
             }
         }
         ILog logger = LogManager.GetLogger(typeof(MEFHelper));
         logger.Error("Operation Not Found!");
     }
     catch (Exception ex)
     {
         ILog logger = LogManager.GetLogger(typeof(MEFHelper));
         logger.Error("Operation Not Found!" + Environment.NewLine + ex.ToString());
     }
     return("");
 }
Beispiel #13
0
        /// <summary>
        /// Login the specified userName, password and loginSite.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password.</param>
        /// <param name="loginSite">Login site.</param>
        /// <returns>cookies string</returns>
        public LoginResult Login(string userName, string password, LoginSite loginSite)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                return new LoginResult()
                       {
                           Result = ResultType.Failed, Msg = "error, username or password can't be null."
                       }
            }
            ;

            ILogin LoginClass = null;

            switch (loginSite)
            {
            case LoginSite.Weibo:
                LoginClass = new WeiboLogin();

                break;

            case LoginSite.WeiboWap:
                LoginClass = new WeiboWapLogin();
                break;
            }

            if (LoginClass == null)
            {
                return new LoginResult()
                       {
                           Result = ResultType.Failed, Msg = "error, can't find the login class."
                       }
            }
            ;

            return(LoginClass.DoLogin(userName, password));
        }
    }
Beispiel #14
0
        public void Read(TProtocol iprot)
        {
            TField field;

            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.I32)
                    {
                        ExtendType = (PluginType)iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.Set)
                    {
                        {
                            SupportSite = new THashSet <LoginSite>();
                            TSet _set5 = iprot.ReadSetBegin();
                            for (int _i6 = 0; _i6 < _set5.Count; ++_i6)
                            {
                                LoginSite _elem7 = (LoginSite)0;
                                _elem7 = (LoginSite)iprot.ReadI32();
                                SupportSite.Add(_elem7);
                            }
                            iprot.ReadSetEnd();
                        }
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 3:
                    if (field.Type == TType.String)
                    {
                        Path = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 4:
                    if (field.Type == TType.String)
                    {
                        Host = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 5:
                    if (field.Type == TType.I32)
                    {
                        Port = iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 6:
                    if (field.Type == TType.String)
                    {
                        UrlFormat = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 7:
                    if (field.Type == TType.String)
                    {
                        HttpMethod = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
Beispiel #15
0
 /// <summary>
 /// Login the specified userName, password and loginSite.
 /// </summary>
 /// <param name="userName">User name.</param>
 /// <param name="password">Password.</param>
 /// <param name="loginSite">Login site.</param>
 /// <returns>cookies string</returns>
 public LoginResult Login(string userName, string password, LoginSite loginSite)
 {
     return(DoLogin(userName, password, loginSite.ToString()));
 }
Beispiel #16
0
        /// <summary>
        /// Login the specified userName, password and loginSite.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password.</param>
        /// <param name="loginSite">Login site.</param>
        /// <returns>cookies string</returns>
        public LoginResult Login(string userName, string password, LoginSite loginSite)
        {
            if (string.IsNullOrEmpty (userName) || string.IsNullOrEmpty (password))
                return new LoginResult (){Result = ResultType.Failed, Msg = "error, username or password can't be null."};

            ILogin LoginClass = null;

            switch (loginSite) {
            case LoginSite.Weibo:
                LoginClass = new WeiboLogin ();
                break;
            case LoginSite.WeiboWap:
                LoginClass = new WeiboWapLogin ();
                break;
            case LoginSite.Baidu:
                LoginClass = new BaiduLogin ();
                break;
            }

            if(LoginClass == null)
                return new LoginResult (){Result = ResultType.Failed, Msg = "error, can't find the login class."};

            return LoginClass.DoLogin (userName, password);
        }
Beispiel #17
0
 public LoginResult Login(string userName, string password, LoginSite loginSite)
 {
     send_Login(userName, password, loginSite);
     return(recv_Login());
 }
Beispiel #18
0
 public LoginResult Login(string userName, string password, LoginSite loginSite)
 {
     send_Login(userName, password, loginSite);
     return recv_Login();
 }
Beispiel #19
0
 public void send_Login(string userName, string password, LoginSite loginSite)
 {
     oprot_.WriteMessageBegin(new TMessage("Login", TMessageType.Call, seqid_));
     Login_args args = new Login_args();
     args.UserName = userName;
     args.Password = password;
     args.LoginSite = loginSite;
     args.Write(oprot_);
     oprot_.WriteMessageEnd();
     oprot_.Transport.Flush();
 }