コード例 #1
0
        Task <T> IUserStore <T, string> .FindByIdAsync(string userId)
        {
            if (string.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentNullException("userId");
            }

            if (string.IsNullOrEmpty(_connectionString))
            {
                _connectionString = GetClientConnectionString();
            }
            SettingFacade fac = new SettingFacade(_connectionString);
            int           parsedUserId;

            if (!int.TryParse(userId, out parsedUserId))
            {
                throw new ArgumentOutOfRangeException("userId", string.Format("'{0}' is not a valid GUID.", new { userId }));
            }

            return(Task.Factory.StartNew(() =>
            {
                UsersEntity oUser = fac.GetUserDetailsById(Convert.ToInt32(userId));
                if (oUser == null)
                {
                    return null;
                }
                else
                {
                    return (T)(new ApplicationUser(oUser));
                }
            }));
        }
コード例 #2
0
ファイル: BaseController.cs プロジェクト: weedkiller/demo
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);
            WebHelper _webHelper = new WebHelper(requestContext.HttpContext);

            //determine the current store by HTTP_HOST
            var host = _webHelper.ServerVariables("HTTP_HOST");

            Helper.hostName = host;
            _oBaseModel     = CacheHelper.Get <BaseModel>(host);
            if (_oBaseModel == null)
            {
                _oBaseModel = CacheHelper.GetBaseModel(host, requestContext.HttpContext);
            }

            try
            {
                // if User information is not found than need to fill current user information
                if (User != null && User.Identity.IsAuthenticated)
                {
                    if (Helper.oUser == null)
                    {
                        SettingFacade sfac = new SettingFacade(oBaseModel.CurrentClient.ApplicationDBConnectionString);
                        Helper.oUser = sfac.GetUserDetailsById(Convert.ToInt32(User.Identity.GetUserId()));
                    }
                    Helper.Enable2StepUpdate = Helper.oUser.Enable2StepUpdate;
                    Helper.IsApprover        = Helper.oUser.IsApprover;
                    Helper.UserType          = Helper.oUser.UserType;
                    Helper.UserName          = User.Identity.GetUserName();
                }
                if (_oBaseModel == null)
                {
                    requestContext.HttpContext.Items["NoUser"] = true;
                    return;
                }
            }
            catch (Exception)
            {
                Helper.IsUserAllreadyLogin = true;
            }
        }
コード例 #3
0
ファイル: AboutUsController.cs プロジェクト: weedkiller/demo
        // GET: AboutUs

        public ActionResult Index()
        {
            SettingFacade sfac = new SettingFacade(this.CurrentClient.ApplicationDBConnectionString);

            //Get Current User Name
            Helper.UserName = Convert.ToString(User.Identity.GetUserName());
            CompanyFacade fac = new CompanyFacade(this.CurrentClient.ApplicationDBConnectionString, Helper.UserName);

            //Get User detail by the user Id.
            if (Helper.oUser == null)
            {
                Helper.oUser = sfac.GetUserDetailsById(Convert.ToInt32(User.Identity.GetUserId()));
            }
            UsersModel Users = new UsersModel();

            //Get Login User Detail
            Users.objUsers = fac.StewUserLogIn(Helper.oUser.EmailAddress, null, true);
            if (Users.objUsers != null)
            {
                ViewBag.ClientGUID = Users.objUsers.ClientGUID;
                ViewBag.ClientName = Users.objUsers.ClientName;
            }
            ViewBag.User = Helper.oUser.UserFullName + "/" + Helper.oUser.EmailAddress;
            // Get Database detail from the connection string.
            using (SqlConnection connection = new SqlConnection(this.CurrentClient.ApplicationDBConnectionString))
            {
                ViewBag.ServerName   = connection.DataSource;
                ViewBag.DataBaseName = connection.Database;
            }

            //set IpAddress and Version
            ViewBag.IpAddress     = Helper.GetCurrentIpAddress();
            ViewBag.BuildVersion  = Convert.ToString(ConfigurationManager.AppSettings["BuildVersion"]);
            ViewBag.FinaldVersion = Convert.ToString(ConfigurationManager.AppSettings["FinalVersion"]);

            string url = Request.Url.Authority;

            sfac = new SettingFacade(General.masterDatabaseConnectionString);
            DataTable dt = sfac.GetLicenseSetting(url);

            if (dt != null)
            {
                //set all License elements
                ViewBag.LicenseSKU                  = Convert.ToString(dt.Rows[0]["LicenseSKU"].ToString());
                ViewBag.LicenseNumberOfUsers        = !string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["LicenseNumberOfUsers"])) ? Convert.ToInt32(dt.Rows[0]["LicenseNumberOfUsers"]) : 0;
                ViewBag.LicenseNumberOfTransactions = !string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["LicenseNumberOfTransactions"])) ? Convert.ToInt32(dt.Rows[0]["LicenseNumberOfTransactions"]) : 0;
                ViewBag.LicenseEnableLiveAPI        = !string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["LicenseEnableLiveAPI"])) ? Convert.ToBoolean(dt.Rows[0]["LicenseEnableLiveAPI"]) : false;
                ViewBag.LicenseEnableTags           = !string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["LicenseEnableTags"])) ? Convert.ToBoolean(dt.Rows[0]["LicenseEnableTags"]) : false;
                ViewBag.LicenseEndDate              = !string.IsNullOrEmpty(dt.Rows[0]["LicenseEndDate"].ToString()) ? Convert.ToDateTime(dt.Rows[0]["LicenseEndDate"]).ToString("MM-dd-yyyy") : string.Empty;
                ViewBag.MonitorProfile              = !string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["LicenseEnableMonitoring"])) ? Convert.ToBoolean(dt.Rows[0]["LicenseEnableMonitoring"]) : false;
                ViewBag.Investigation               = !string.IsNullOrEmpty(Convert.ToString(dt.Rows[0]["LicenseEnableInvestigations"])) ? Convert.ToBoolean(dt.Rows[0]["LicenseEnableInvestigations"]) : false;
            }
            else
            {
                //set all License elements empty or default when data is null in database
                ViewBag.LicenseSKU                  = "";
                ViewBag.LicenseNumberOfUsers        = "0";
                ViewBag.LicenseNumberOfTransactions = "0";
                ViewBag.LicenseEnableLiveAPI        = false;
                ViewBag.LicenseEnableTags           = false;
                ViewBag.LicenseEndDate              = "";
                ViewBag.MonitorProfile              = false;
                ViewBag.Investigation               = false;
            }
            return(View());
        }