示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var userid = "";
        var domain = "";
        if (!string.IsNullOrEmpty(Request.LogonUserIdentity.Name) && Request.LogonUserIdentity.Name.IndexOf("\\") > 0)
        {
            domain = Request.LogonUserIdentity.Name.Remove(Request.LogonUserIdentity.Name.IndexOf("\\"));
            userid = Request.LogonUserIdentity.Name.Substring(Request.LogonUserIdentity.Name.IndexOf("\\") + 1);
        }

        if (string.IsNullOrEmpty(userid))
        {
            Response.Write("UserID is empty.");
            return;
        }

        if (string.IsNullOrEmpty(domain))
        {
            Response.Write("Domain is empty.");
            return;
        }
        var database = Request.QueryString["Database"];
        if (string.IsNullOrEmpty(database))
        {
            Response.Write("Database is empty.");
            return;
        }
        var solution = Request.QueryString["Solution"];
        if(string.IsNullOrEmpty(solution))
        {
            Response.Write("Solution is empty.");
            return;
        }

        EFServiceClient client = EFClientTools.ClientUtility.Client;
        var locale = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
        var ipAddress = Request.UserHostAddress;
        EFClientTools.ClientUtility.ServerIPAddress = client.GetServerIPAddress();
        var clientInfo = new ClientInfo()
        {
            UserID = userid,
            Password = "",
            Database = database,
            Solution = solution,
            IPAddress = ipAddress,
            Locale = locale,
            UseDataSet = true,
            SecurityKey = EncryptValue(domain)
        };
        client = EFClientTools.ClientUtility.Client;
        var result = client.LogOn(clientInfo);
        if (result.LogonResult == LogonResult.Logoned)
        {
            result.Locale = Request.UserLanguages.FirstOrDefault();
            Session["ClientInfo"] = result;
            String flow = ConfigurationManager.AppSettings["IsFlow"];
            if (String.IsNullOrEmpty(flow))
                this.Response.Redirect("MainPage.aspx");
            else if (flow.ToLower() == "true")
            {
                this.Response.Redirect("MainPage_Flow.aspx");
                this.Page.Session["IsFlow"] = flow;
            }
            else
            {
                this.Response.Redirect("MainPage.aspx");
            }
        }
        else
        {
            string messageKey = string.Empty;
            switch (result.LogonResult)
            {
                case LogonResult.UserNotFound: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserNotFound"; break;
                case LogonResult.UserDisabled: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserDisabled"; break;
                case LogonResult.PasswordError: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserOrPasswordError"; break;
                default: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserOrPasswordError"; break;
            }
            EFBase.MessageProvider provider = new EFBase.MessageProvider(this.Request.PhysicalApplicationPath, locale);
            Response.Write(provider[messageKey]);
        }
    }
示例#2
0
    protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
    {
        Session.Timeout = 60;
        EFServiceClient client = EFClientTools.ClientUtility.Client;
        var locale = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
        var ipAddress = Request.UserHostAddress;
        if ((Login1.FindControl("tbCheckCode") as TextBox).Text != hfOValue.Value)
        {
            string messageKey = "EEPWebNetClient/WinSysMsg/msg_CheckCode";
            EFBase.MessageProvider provider = new EFBase.MessageProvider(this.Request.PhysicalApplicationPath, locale);
            (Login1.FindControl("FailureLabel") as Literal).Text = string.Format("<font color=\"red\">{0}</font>", provider[messageKey]);
            e.Authenticated = false;
            return;
        }
        //CliUtils.fClientSystem = "Web";
        //CliUtils.fLoginUser = (Login1.FindControl("UserName") as TextBox).Text;
        //CliUtils.fLoginPassword = (Login1.FindControl("Password") as TextBox).Text;
        //CliUtils.fLoginDB = SelectedDataBase;
        //CliUtils.fCurrentProject = SelectedSolution;

        //CliUtils.fComputerIp = serverIPAddress;

        //object[] myRets = CliUtils.CallMethod("GLModule", "GetDataBaseType", new object[] { CliUtils.fLoginDB });
        //String databaseType = String.Empty;
        //if (myRets[0].ToString() == "0")
        //{
        //    databaseType = myRets[1].ToString();
        //}
        //CliUtils.fLoginDBType = (ClientType)Enum.Parse(typeof(ClientType), databaseType);

        var clientInfo = new ClientInfo()
        {
            UserID = (Login1.FindControl("UserName") as TextBox).Text,
            Password = (Login1.FindControl("Password") as TextBox).Text,
            Database = SelectedDataBase,
            Solution = SelectedSolution,
            IPAddress = ipAddress,
            Locale = locale,
            //ServerIPAddress = serverIPAddress,
            //UseDataSet = IsDataSet,
            UseDataSet = true
            //DatabaseType = databaseType
        };

        try
        {
            var result = new ClientInfo();
            if (clientInfo.UserID.Contains("'"))
            {
                result = new ClientInfo() { LogonResult = LogonResult.UserNotFound };
            }
            else
            {
                result = client.LogOn(clientInfo);
            }
            if (result.LogonResult == LogonResult.Logoned)
            {
                result.Locale = Request.UserLanguages.FirstOrDefault();
                Session["ClientInfo"] = result;
                e.Authenticated = true;
                SaveCookie(clientInfo);
                //this.Response.Redirect("Test/JQSingleTest.aspx");
                //this.Response.Redirect("Test/MDTest2.aspx");
                //String flow = ConfigurationManager.AppSettings["IsFlow"];
                //if (String.IsNullOrEmpty(flow))
                //    this.Response.Redirect("MainPage.aspx");
                //else if (flow.ToLower() == "true")
                //{
                //    this.Response.Redirect("MainPage_Flow.aspx");
                //    this.Page.Session["IsFlow"] = flow;
                //}
                //else
                //{
                //    this.Response.Redirect("MainPage.aspx");
                //}
                this.Response.Redirect("MainPage_Flow.aspx");

                return;

                //if (this.Page.Request["IsReportManager"] != null && string.Compare(this.Page.Request["IsReportManager"].ToString(), "true", true) == 0)
                //{
                //    this.Response.Redirect("SLEasilyReportManager.Web/ReportManagerMain.aspx");
                //}
                //else
                //{
                //    String flow = ConfigurationManager.AppSettings["IsFlow"];
                //    if (String.IsNullOrEmpty(flow))
                //        this.Response.Redirect("Main2.aspx");
                //    else if (flow.ToLower() == "true")
                //    {
                //        //this.Response.Redirect("Main_Flow.aspx");
                //        this.Response.Redirect("Main_Flow2.aspx");
                //        this.Page.Session["IsFlow"] = flow;
                //    }
                //    else
                //    {
                //        this.Response.Redirect("Main2.aspx");
                //    }
                //}
            }
            else
            {
                string messageKey = string.Empty;
                switch (result.LogonResult)
                {
                    case LogonResult.UserNotFound: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserNotFound"; break;
                    case LogonResult.UserDisabled: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserDisabled"; break;
                    case LogonResult.PasswordError: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserOrPasswordError"; break;
                    default: messageKey = "EEPWebNetClient/WinSysMsg/msg_UserOrPasswordError"; break;
                }
                EFBase.MessageProvider provider = new EFBase.MessageProvider(this.Request.PhysicalApplicationPath, locale);
                (Login1.FindControl("FailureLabel") as Literal).Text = string.Format("<font color=\"red\">{0}</font>", provider[messageKey]);
                e.Authenticated = false;
            }
        }
        catch (System.ServiceModel.EndpointNotFoundException)
        {
            string messageKey = "EEPWebNetClient/WinSysMsg/msg_CanNotFindServer";
            EFBase.MessageProvider provider = new EFBase.MessageProvider(this.Request.PhysicalApplicationPath, locale);
            (Login1.FindControl("FailureLabel") as Literal).Text = string.Format("<font color=\"red\">{0}</font>", provider[messageKey]);
            e.Authenticated = false;
        }
    }
示例#3
0
    public static bool ProcessRequest(HttpContext context)
    {
        if (context.Request.Form["mode"] != null)
        {
            var page = context.CurrentHandler;
            var mode = context.Request.Form["mode"];
            if (mode == "default")
            {
                EFClientTools.ClientUtility.ClientInfo.cErrorCode = 1230;

                var methodNames = context.Request.Form["method"];
                Newtonsoft.Json.Linq.JObject result = new Newtonsoft.Json.Linq.JObject();
                Newtonsoft.Json.Linq.JObject obj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(methodNames);
                foreach (var item in obj)
                {
                    var key = item.Key;
                    var methodName = (string)(item.Value as Newtonsoft.Json.Linq.JValue).Value;
                    if (methodName.StartsWith("_"))
                    {
                        var defaultValue = GetSystemVariable(context, methodName);
                        result.Add(key, new Newtonsoft.Json.Linq.JValue(defaultValue));
                    }
                    else
                    {
                        var defaultValue = (string)page.GetType().GetMethod(methodName).Invoke(page, null);
                        result.Add(key, new Newtonsoft.Json.Linq.JValue(defaultValue));
                    }
                }
                context.Response.ContentType = "text/plain";
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
                EFClientTools.ClientUtility.ClientInfo.cErrorCode = 0;
                return true;
            }
            else if (mode == "validate")
            {
                EFClientTools.ClientUtility.ClientInfo.cErrorCode = 1240;

                var methodName = context.Request.Form["method"];
                var value = context.Request.Form["value"];
                var validateValue = (bool)page.GetType().GetMethod(methodName).Invoke(page, new object[] { value });
                context.Response.ContentType = "text/plain";
                context.Response.Write(validateValue.ToString().ToLower());
                EFClientTools.ClientUtility.ClientInfo.cErrorCode = 0;
                return true;
            }
            else if (mode == "language")
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(EFClientTools.ClientUtility.ClientInfo.Locale.ToString().ToLower());
                return true;
            }
            else if (mode == "message")
            {
                var locale = string.Empty;
                if (context.Session["ClientInfo"] == null)
                {
                    locale = context.Request.UserLanguages[0];
                }
                else
                {
                    locale = EFClientTools.ClientUtility.ClientInfo.Locale;
                    EFClientTools.ClientUtility.ClientInfo.cErrorCode = 1250;
                }

                EFBase.MessageProvider provider = new EFBase.MessageProvider(context.Request.PhysicalApplicationPath, locale);
                var messageKeys = context.Request.Form["keys"];
                Newtonsoft.Json.Linq.JObject result = new Newtonsoft.Json.Linq.JObject();
                Newtonsoft.Json.Linq.JArray obj = (Newtonsoft.Json.Linq.JArray)Newtonsoft.Json.JsonConvert.DeserializeObject(messageKeys);
                foreach (string item in obj)
                {
                    var messageKey = item;
                    result.Add(messageKey, provider[messageKey]);
                }
                context.Response.Write(Newtonsoft.Json.JsonConvert.SerializeObject(result));
                if (context.Session["ClientInfo"] != null)
                    EFClientTools.ClientUtility.ClientInfo.cErrorCode = 0;
                return true;
            }
            else if (mode == "clientinfo")
            {
                var name = context.Request.Form["key"];
                context.Response.ContentType = "text/plain";
                context.Response.Write(GetClientInfo(context, name));
                return true;
            }
            else if (mode == "databasetype")
            {
                context.Response.ContentType = "text/plain";
                context.Response.Write(EFClientTools.ClientUtility.ClientInfo.DatabaseType.ToString().ToLower());
                return true;
            }
            else if (mode == "sendMail")
            {
                EFClientTools.ClientUtility.ClientInfo.cErrorCode = 1260;
                Dictionary<string, string> mailOptions = new Dictionary<string, string>();
                var options = context.Request.Form["options"];
                Newtonsoft.Json.Linq.JObject obj = (Newtonsoft.Json.Linq.JObject)Newtonsoft.Json.JsonConvert.DeserializeObject(options);
                var BCC = obj["bCC"].ToString();
                var CC = obj["cC"].ToString();
                var To = obj["to"].ToString();
                var Subject = obj["subject"].ToString();
                var Body = obj["body"].ToString();
                var IsBodyHtml = obj["isBodyHtml"].ToString();
                var Password = "";
                var Host ="";
                var Port = "";
                var EnableSsl = obj["enableSsl"].ToString();
                var Encoding = obj["encoding"].ToString();
                var From = "";
                var mailOption = System.Configuration.ConfigurationManager.AppSettings["MailOption"];

                if (!string.IsNullOrEmpty(mailOption))
                {
                    var o = mailOption.Split(',');
                    foreach (var option in o)
                    {
                        var keyValue = option.Split('=');
                        if (keyValue.Length == 2)
                        {
                            mailOptions.Add(keyValue[0], keyValue[1]);
                        }
                    }
                }
                if (mailOptions.ContainsKey("Smtp"))
                {
                    Host = mailOptions["Smtp"];
                }
                if (mailOptions.ContainsKey("Port"))
                {
                    Port = mailOptions["Port"];
                }
                if (mailOptions.ContainsKey("From"))
                {
                    From = mailOptions["From"];
                }
                if (mailOptions.ContainsKey("Password"))
                {
                    Password = mailOptions["Password"];
                }
                if (mailOptions.ContainsKey("EnableSsl"))
                {
                    EnableSsl = mailOptions["EnableSsl"];
                }
                try
                {
                    var smtpclient = new System.Net.Mail.SmtpClient(mailOptions["Smtp"]);
                    if (Port != "") smtpclient.Port = int.Parse(Port);
                    if (EnableSsl != "") smtpclient.EnableSsl = bool.Parse(EnableSsl);
                    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                    message.From = new System.Net.Mail.MailAddress(From);
                    AddMailAddress(message.To, To);
                    AddMailAddress(message.Bcc, BCC);
                    AddMailAddress(message.CC, CC);
                    message.SubjectEncoding = System.Text.Encoding.GetEncoding(Encoding);
                    message.BodyEncoding = System.Text.Encoding.GetEncoding(Encoding);
                    message.Subject = Subject;
                    message.Body = Body;
                    message.IsBodyHtml = bool.Parse(IsBodyHtml);
                    smtpclient.EnableSsl = bool.Parse(EnableSsl);
                    smtpclient.UseDefaultCredentials = false;
                    smtpclient.Credentials = new System.Net.NetworkCredential(From, Password);
                    smtpclient.SendAsync(message, null);
                }
                catch { }
                EFClientTools.ClientUtility.ClientInfo.cErrorCode = 0;
            }
        }

        return false;
    }
示例#4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            try
            {

                EFServiceClient client = EFClientTools.ClientUtility.Client;
                EFClientTools.ClientUtility.ServerIPAddress = client.GetServerIPAddress();
                client = EFClientTools.ClientUtility.Client;
                if (!string.IsNullOrEmpty(DefaultDatabase))
                {
                    (Login1.FindControl("Database") as DropDownList).Visible = false;
                    (Login1.FindControl("DatabaseLabel") as Label).Visible = false;
                }
                else
                {
                    var listDatabase = client.GetDatabases(null);
                    foreach (var database in listDatabase)
                    {
                        (Login1.FindControl("Database") as DropDownList).Items.Add(database);
                    }
                }
                if (!string.IsNullOrEmpty(DefaultSolution))
                {
                    (Login1.FindControl("Solution") as DropDownList).Visible = false;
                    (Login1.FindControl("SolutionLabel") as Label).Visible = false;
                }
                else
                {
                    var locale = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
                    var ipAddress = Request.UserHostAddress;

                    //object[] myRets = CliUtils.CallMethod("GLModule", "GetDataBaseType", new object[] { SelectedDataBase });
                    //String databaseType = String.Empty;
                    //if (myRets[0].ToString() == "0")
                    //{
                    //    databaseType = myRets[1].ToString();
                    //}

                    var clientInfo = new ClientInfo()
                    {
                        UserID = (Login1.FindControl("UserName") as TextBox).Text,
                        Password = (Login1.FindControl("Password") as TextBox).Text,
                        Database = SelectedDataBase,
                        Solution = SelectedSolution,
                        IPAddress = ipAddress,
                        Locale = locale,
                        UseDataSet = true,
                        DatabaseType = "1"
                    };
                    var listSolution = client.GetSolutions(clientInfo);
                    foreach (var solution in listSolution)
                    {
                        (Login1.FindControl("Solution") as DropDownList).Items.Add(new ListItem(solution.Name, solution.ID));
                    }

                }
                //EFBase.MessageProvider provider = new EFBase.MessageProvider(System.Web.HttpContext.Current.Request.PhysicalApplicationPath, Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us");
                //SetLabelText(provider);
                LoadCookie();

            }
            catch (System.ServiceModel.EndpointNotFoundException)
            {
                string messageKey = "EEPWebNetClient/WinSysMsg/msg_CanNotFindServer";
                var locale = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
                EFBase.MessageProvider provider = new EFBase.MessageProvider(this.Request.PhysicalApplicationPath, locale);
                (Login1.FindControl("FailureLabel") as Literal).Text = string.Format("<font color=\"red\">{0}</font>", provider[messageKey]);
            }
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
        }
        var locale2 = Request.UserLanguages.Length > 0 ? Request.UserLanguages[0] : "en-us";
        EFBase.MessageProvider provider2 = new EFBase.MessageProvider(this.Request.PhysicalApplicationPath, locale2);
        SetLabelText(provider2);
    }