Esempio n. 1
0
    public static string LoginCredential(string Username, string Password)
    {
        try
        {
            string Success    = "Success";
            string SuccessApp = "SuccessApp";

            string Fail = "Fail";
            Agent  obj  = Agent.LoginCredentials(Username, Password);
            if (obj != null)
            {
                HttpContext.Current.Session["userName"] = Username;
                SessionManager.AddToUserSession(HttpContext.Current, obj.Code, obj.AgentName);
                SessionManager.AddItemCategoryToSession(HttpContext.Current, obj.ItemCategoryCode);
                SessionManager.AddUserTypeSession(HttpContext.Current, obj.UserType);
                //SessionManager.AddLoginTimeSession(HttpContext.Current, Convert.ToDateTime(obj.LastLoginTime));

                HttpContext.Current.Session["ItemCategoryCode"] = obj.ItemCategoryCode;


                // for updating the date time of the user login. .// added by Raj Shah 09/11/2016
                try
                {
                    NetworkCredential NetCredentials = new NetworkCredential(ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"]);
                    Web_Order_Mail    objser1        = new Web_Order_Mail();
                    objser1.UseDefaultCredentials = true;
                    objser1.Credentials           = NetCredentials;

                    //DateTime LastLoginTime = objser1.GetLastLoginDateTime(obj.LastLoginTime);
                    SessionManager.AddLoginTimeSession(HttpContext.Current, Convert.ToDateTime(obj.LastLoginTime));
                    objser1.LastLoginLogoutDateTime(obj.Code, DateTime.Now, true);
                    objser1 = null;
                }
                catch (Exception ex)
                {
                    // not to throw error.
                }

                if (obj.AccountActivated == false)
                {
                    return(SuccessApp);
                }
                else
                {
                    return(Success);
                }
            }
            else
            {
                return(Fail);
            }
        }
        catch (Exception ex)
        {
            //throw ex;
            return(ex.Message);
        }
    }
Esempio n. 2
0
        public string IsValid(string UserID, string Password)
        {
            //DataTable dtUsers = objSQLServer.Fill_Datatable(objSQL.VendorConn, "LoginCredentials", new string[] { UserID, Password });
            //if (dtUsers.Rows.Count > 0)
            //{
            //    return true;
            //}
            //else
            //{
            //    return false;
            //}

            string Success    = "Success";
            string SuccessApp = "SuccessApp";

            string Fail = "Fail";
            Vendor obj  = Vendor.LoginCredentials(UserID, Password);

            if (obj != null)
            {
                HttpContext.Current.Session["VendorName"] = obj.VendorName;
                SessionManager.AddToUserSession(HttpContext.Current, obj.VendorName);
                SessionManager.AddToNavUserSession(HttpContext.Current, obj.NavUserName);
                SessionManager.AddToNavUserPasswordSession(HttpContext.Current, obj.NavPassword);
                SessionManager.AddToUserID(HttpContext.Current, obj.ID);
                SessionManager.AddTypeOfUser(HttpContext.Current, obj.UserType);

                // LOG ALL THE ENTRIES OF THE USER
                DataLogHistory loghi = new DataLogHistory();
                loghi.LoginUserID    = obj.ID;
                loghi.LoginInTime    = System.DateTime.Now;
                loghi.AccessActivity = 1;
                int result = DataLogHistory.InsertLogHistory(loghi);
                SessionManager.AddToUserLogID(HttpContext.Current, result);
                // MAIN USER LOG SUMMARY

                if (obj.AccountActivated == false)
                {
                    return(Fail);
                }
                else
                {
                    return(Success);
                }
            }
            else
            {
                return(Fail);
            }
        }
    // GET api/<controller>
    // GET api/<controller>/
    public string Get(string Username, string Password)
    {
        string Success = "Success";
        string Fail    = "Fail";
        Agent  obj     = Agent.LoginCredentials(Username, Password);

        if (obj != null)
        {
            SessionManager.AddToUserSession(HttpContext.Current, obj.Code, obj.AgentName);
            return(Success);
        }
        else
        {
            return(Fail);
        }
    }
Esempio n. 4
0
        public static string LoginCredential(string Username, string Password)
        {
            try
            {
                string Success    = "Success";
                string SuccessApp = "SuccessApp";

                string Fail = "Fail";
                Vendor obj  = Vendor.LoginCredentials(Username, Password);
                if (obj != null)
                {
                    HttpContext.Current.Session["VendorName"] = obj.VendorName;
                    SessionManager.AddToUserSession(HttpContext.Current, obj.VendorName);
                    SessionManager.AddToNavUserSession(HttpContext.Current, obj.NavUserName);
                    SessionManager.AddToNavUserPasswordSession(HttpContext.Current, obj.NavPassword);
                    SessionManager.AddToUserID(HttpContext.Current, obj.ID);
                    SessionManager.AddTypeOfUser(HttpContext.Current, obj.UserType);

                    // LOG ALL THE ENTRIES OF THE USER
                    DataLogHistory loghi = new DataLogHistory();
                    loghi.LoginUserID    = obj.ID;
                    loghi.LoginInTime    = System.DateTime.Now;
                    loghi.AccessActivity = 1;
                    int result = DataLogHistory.InsertLogHistory(loghi);
                    SessionManager.AddToUserLogID(HttpContext.Current, result);
                    // MAIN USER LOG SUMMARY

                    if (obj.AccountActivated == false)
                    {
                        return(Fail);
                    }
                    else
                    {
                        return(Success);
                    }
                }
                else
                {
                    return(Fail);
                }
            }
            catch (Exception ex)
            {
                //throw ex;
                return(ex.Message);
            }
        }