Ejemplo n.º 1
0
 public void LogTable(TimeSpan acw, TimeSpan idle, TimeSpan nready, TimeSpan ready,
                      TimeSpan hold, TimeSpan talk, TimeSpan login, TimeSpan handle, TimeSpan avgans,
                      TimeSpan avgtalk, int totrcv, int totdial, int totans, int psl, int gsl)
 {
     try
     {
         Table table = new Table();
         table.avgAnsSpeed  = avgans;
         table.avgHandTime  = handle;
         table.avgTalkTime  = avgtalk;
         table.Exten        = Extension;
         table.Name         = LoginName;
         table.GSL          = gsl;
         table.LoginTime    = LoginTime.ToString("yyyyMMddHHmmss");
         table.PSL          = psl;
         table.totACWTime   = acw;
         table.totAnsCalls  = totans;
         table.totDialCalls = totdial;
         table.totHoldTime  = hold;
         table.totLoginDur  = login;
         table.totNrdyTime  = nready;
         table.totRcvCalls  = totrcv;
         table.totTalkTime  = talk;
         dataContext.Tables.InsertOnSubmit(table);
         dataContext.SubmitChanges();
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(ex.ToString(), "Error# 4009: " + ex.Message);
     }
 }
Ejemplo n.º 2
0
        public void UserLogin(String cookieName, int userId, String userName, LoginTime expiration)
        {
            Boolean isPersistent = (expiration == LoginTime.Never ? false : true);

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                2,
                userName,
                DateTime.Now,
                getExpiration(expiration),
                isPersistent,
                userId.ToString(),
                FormsAuthentication.FormsCookiePath
                );

            String     str    = FormsAuthentication.Encrypt(ticket);
            HttpCookie cookie = new HttpCookie(cookieName, str);

            if (isPersistent)
            {
                cookie.Expires = ticket.Expiration;
            }

            if (FormsAuthentication.CookieDomain != null)
            {
                cookie.Domain = FormsAuthentication.CookieDomain;
            }

            this.Response.Cookies.Add(cookie);
        }
Ejemplo n.º 3
0
 public void LogConsolidated(TimeSpan acw, TimeSpan idle, TimeSpan nready, TimeSpan ready,
                             TimeSpan hold, TimeSpan talk, TimeSpan login)
 {
     try
     {
         Consolidated report = new Consolidated();
         report.Name       = LoginName;
         report.Extension  = Extension;
         report.LoginTime  = LoginTime.ToString("yyyyMMddHHmmss");
         report.LogoutTime = LogoutTime.ToString("yyyyMMddHHmmss");
         //
         report.TotalACWTime   = String.Format("{0:00}:{1:00}:{2:00}", acw.Hours, acw.Minutes, acw.Seconds);
         report.TotalHoldTime  = String.Format("{0:00}:{1:00}:{2:00}", hold.Hours, hold.Minutes, hold.Seconds);
         report.TotalIdleTime  = String.Format("{0:00}:{1:00}:{2:00}", idle.Hours, idle.Minutes, idle.Seconds);
         report.TotalLoginTime = String.Format("{0:00}:{1:00}:{2:00}", login.Hours, login.Minutes, login.Seconds);
         report.TotalNtRdyTime = String.Format("{0:00}:{1:00}:{2:00}", nready.Hours, nready.Minutes, nready.Seconds);
         report.TotalReadyTime = String.Format("{0:00}:{1:00}:{2:00}", ready.Hours, ready.Minutes, ready.Seconds);
         report.TotalTalkTime  = String.Format("{0:00}:{1:00}:{2:00}", talk.Hours, talk.Minutes, talk.Seconds);
         //
         dataContext.Consolidateds.InsertOnSubmit(report);
         dataContext.SubmitChanges();
     }
     catch (Exception ex)
     {
         System.Windows.MessageBox.Show(ex.ToString(), "Error# 4008: " + ex.Message);
     }
 }
Ejemplo n.º 4
0
        // 从第三方带骨
        public virtual void Login(User user, int userConnectId, LoginTime expiration, String ip, MvcContext ctx)
        {
            logger.Info("userConnectId=" + userConnectId);

            user.LoginType = userConnectId;
            updateLastLogin(user, ip);
            ctx.web.UserLogin(user.Id, user.Name, expiration);
            OnlineStats.Instance.AddMemberCount();
        }
Ejemplo n.º 5
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");

            if (ModelState.IsValid)
            {
                // This doesn't count login failures towards account lockout
                // To enable password failures to trigger account lockout, set lockoutOnFailure: true
                Input.UserName = Input.UserName.ToLower();
                var result = await _signInManager.PasswordSignInAsync(Input.UserName, Input.Password, Input.RememberMe, lockoutOnFailure : true);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User logged in.");

                    var LoginModel = new LoginTime
                    {
                        Time     = DateTime.Now,
                        UserName = Input.UserName
                    };
                    await _applicationUserImplementation.AddLoginTime(LoginModel);

                    var user = _applicationUserImplementation.GetByUserName(Input.UserName);

                    if (!user.EmailConfirmed)
                    {
                        await _signInManager.SignOutAsync();

                        return(RedirectToAction("ConFirm", "Home"));
                    }
                    if (user.IsActive)
                    {
                        await _signInManager.SignOutAsync();

                        return(RedirectToAction("Block", "Home"));
                    }
                    return(LocalRedirect(returnUrl));
                }
                if (result.RequiresTwoFactor)
                {
                    return(RedirectToPage("./LoginWith2fa", new { ReturnUrl = returnUrl, RememberMe = Input.RememberMe }));
                }
                if (result.IsLockedOut)
                {
                    _logger.LogWarning("User account locked out.");
                    return(RedirectToPage("./Lockout"));
                }
                else
                {
                    ModelState.AddModelError(string.Empty, "Invalid login attempt.");
                    return(Page());
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }
Ejemplo n.º 6
0
        // 从第三方带骨
        public virtual void Login(User user, long userConnectId, LoginTime expiration, string ip, MvcContext ctx)
        {
            logger.Info( "userConnectId=" + userConnectId );

            user.LoginType = userConnectId;
            updateLastLogin( user, ip );
            ctx.web.UserLogin( user.Id, user.Name, expiration );
            OnlineStats.Instance.AddMemberCount();
        }
Ejemplo n.º 7
0
 /// <summary>
 ///     Записать объект в райтер
 /// </summary>
 /// <param name="writer"></param>
 public void Write(BinaryWriter writer)
 {
     writer.Write(Ok);
     writer.Write(Login);
     writer.Write(Token);
     writer.Write(Expire.ToOADate());
     writer.Write((byte)Type);
     writer.Write(LoginTime.ToOADate());
     writer.Write(UserAgent);
     writer.Write(LocalAddress);
     writer.Write(RemoteAddress);
 }
Ejemplo n.º 8
0
        public bool AuthenticateUser(string username, string password)
        {
            try
            {
                var query = from u in dataContext.Logins
                            where u.Extension == username && u.Secret == password
                            select u;

                if (Enumerable.Count(query) > 0)
                {
                    LoginName           = query.Single().Name;
                    Extension           = query.Single().Extension;
                    LoginTime           = DateTime.Now;
                    currState           = dataContext.CurrStateInfos.Single(u => u.Extension == Extension.Trim());
                    currState.LoginTime = LoginTime.ToString("yyyyMMddHHmmss");
                    currState.IsLogin   = true;


                    //Adding Account Info
                    this.accountConfig.AccountName  = LoginName;
                    this.accountConfig.DisplayName  = LoginName;
                    this.accountConfig.DomainName   = "*";
                    this.accountConfig.HostName     = GetProxyIP() + ":5060";
                    this.accountConfig.Id           = LoginName;
                    this.accountConfig.Password     = password.Trim();
                    this.accountConfig.ProxyAddress = "";
                    this.accountConfig.UserName     = Extension;
                    this.accountConfig.AsteriskIP   = GetProxyIP();

                    //Adding Phone Config
                    this.phoneConfig.AAFlag      = GetSettings(Extension).AAFlag;
                    this.phoneConfig.CFBFlag     = GetSettings(Extension).CFBFlag;
                    this.phoneConfig.CFNRFlag    = GetSettings(Extension).CFNRFlag;
                    this.phoneConfig.CFUFlag     = GetSettings(Extension).CFUFlag;
                    this.phoneConfig.DNDFlag     = GetSettings(Extension).DNDFlag;
                    this.phoneConfig.SIPPort     = GetSettings(Extension).Port;
                    this.phoneConfig.CFBNumber   = GetSettings(Extension).CFBNumber;
                    this.phoneConfig.CFNRNumber  = GetSettings(Extension).CFNRNumber;
                    this.phoneConfig.CFUNumber   = GetSettings(Extension).CFUNumber;
                    this.phoneConfig.Accounts[0] = accountConfig;
                }
                return(Enumerable.Count(query) > 0);
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show(ex.ToString(), "Error# 4001: " + ex.Message);
                return(false);
            }
        }
Ejemplo n.º 9
0
        private void processLogin(AuthConnect connect, String code)
        {
            if (ctx.viewer.IsLogin)
            {
                echoError("对不起,您已经登录");
                return;
            }

            AccessToken accessToken = OAuthClient.New().GetAccessToken(connect, code, connect.HttpMethod_AccessToken);

            logger.Info("accessToken=" + accessToken.Token);
            logger.Info("uid=" + accessToken.Uid);
            logger.Info("refresh_token=" + accessToken.RefreshToken);
            logger.Info("expires_in=" + accessToken.ExpiresIn);
            logger.Info("scope=" + accessToken.Scope);

            String uid = connect.GetUid(accessToken);

            // 1) 检查网站中是否有此用户
            UserConnect x = connectService.GetConnectInfo(uid, connect.GetType().FullName);

            // 第一次登录
            if (x == null)
            {
                try {
                    loadUserProfile(connect, accessToken);
                }
                catch (HttpClientException ex) {
                    if (ex.Message.IndexOf("applications over the unaudited use restrictions") > 0)
                    {
                        echo(getTestRestrictionsMsg("登录"));
                    }
                    else
                    {
                        throw ex;
                    }
                }
            }
            // 其他:获取用户信息,然后登录
            else
            {
                checkAccessToken(x, accessToken);

                LoginTime expiration = LoginTime.OneWeek;
                loginService.Login(x.User, x.Id, expiration, ctx.Ip, ctx);

                echoRedirect("登录成功", "/");
            }
        }
Ejemplo n.º 10
0
        public static void Login( int userId, String userName, LoginTime loginTime )
        {
            Boolean isPersistent = true;
            if (loginTime == LoginTime.Never) {
                isPersistent = false;
            }

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket( 1, userName, DateTime.Now, getExpiration( loginTime ), isPersistent, userId.ToString(), FormsAuthentication.FormsCookiePath );
            String str = FormsAuthentication.Encrypt( ticket );
            HttpCookie cookie = new HttpCookie( FormsAuthentication.FormsCookieName, str );
            if (ticket.IsPersistent) {
                cookie.Expires = ticket.Expiration;
            }
            HttpContext.Current.Response.Cookies.Add( cookie );
        }
Ejemplo n.º 11
0
 private static DateTime getExpiration( LoginTime loginTime )
 {
     if (loginTime != LoginTime.Never) {
         if (loginTime == LoginTime.Forever) {
             return DateTime.Now.AddYears( 100 );
         }
         if (loginTime == LoginTime.OneYear) {
             return DateTime.Now.AddYears( 1 );
         }
         if (loginTime == LoginTime.OneMonth) {
             return DateTime.Now.AddMonths( 1 );
         }
         if (loginTime == LoginTime.OneWeek) {
             return DateTime.Now.AddDays( 7.0 );
         }
     }
     return DateTime.Now;
 }
Ejemplo n.º 12
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (UserId != 0)
            {
                hash ^= UserId.GetHashCode();
            }
            if (LoginTime != 0L)
            {
                hash ^= LoginTime.GetHashCode();
            }
            if (OnlineTime != 0L)
            {
                hash ^= OnlineTime.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 13
0
        public static void Login(int userId, String userName, LoginTime loginTime)
        {
            Boolean isPersistent = true;

            if (loginTime == LoginTime.Never)
            {
                isPersistent = false;
            }

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, userName, DateTime.Now, getExpiration(loginTime), isPersistent, userId.ToString(), FormsAuthentication.FormsCookiePath);
            String     str    = FormsAuthentication.Encrypt(ticket);
            HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, str);

            if (ticket.IsPersistent)
            {
                cookie.Expires = ticket.Expiration;
            }
            HttpContext.Current.Response.Cookies.Add(cookie);
        }
Ejemplo n.º 14
0
        private DateTime getExpiration(LoginTime loginTime)
        {
            if (loginTime == LoginTime.Forever)
            {
                return(DateTime.Now.AddYears(50));
            }
            if (loginTime == LoginTime.OneYear)
            {
                return(DateTime.Now.AddYears(1));
            }
            if (loginTime == LoginTime.OneMonth)
            {
                return(DateTime.Now.AddMonths(1));
            }
            if (loginTime == LoginTime.OneWeek)
            {
                return(DateTime.Now.AddDays(7));
            }

            // 20分钟内如果不活动即失效
            return(DateTime.Now.AddMinutes(20));
        }
Ejemplo n.º 15
0
 private static DateTime getExpiration(LoginTime loginTime)
 {
     if (loginTime != LoginTime.Never)
     {
         if (loginTime == LoginTime.Forever)
         {
             return(DateTime.Now.AddYears(100));
         }
         if (loginTime == LoginTime.OneYear)
         {
             return(DateTime.Now.AddYears(1));
         }
         if (loginTime == LoginTime.OneMonth)
         {
             return(DateTime.Now.AddMonths(1));
         }
         if (loginTime == LoginTime.OneWeek)
         {
             return(DateTime.Now.AddDays(7.0));
         }
     }
     return(DateTime.Now);
 }
Ejemplo n.º 16
0
 public void UserLogin(int userId, String userName, LoginTime expiration)
 {
     UserLogin(FormsAuthentication.FormsCookieName, userId, userName, expiration);
 }
Ejemplo n.º 17
0
 public void UserLogin( String cookieName, int userId, String userName, LoginTime expiration )
 {
 }
Ejemplo n.º 18
0
        private DateTime getExpiration( LoginTime loginTime )
        {
            if (loginTime == LoginTime.Forever) return DateTime.Now.AddYears( 50 );
            if (loginTime == LoginTime.OneYear) return DateTime.Now.AddYears( 1 );
            if (loginTime == LoginTime.OneMonth) return DateTime.Now.AddMonths( 1 );
            if (loginTime == LoginTime.OneWeek) return DateTime.Now.AddDays( 7 );

            // 20分钟内如果不活动即失效
            return DateTime.Now.AddMinutes( 20 );
        }
Ejemplo n.º 19
0
        public void UserLogin( String cookieName, int userId, String userName, LoginTime expiration )
        {
            Boolean isPersistent = (expiration == LoginTime.Never ? false : true);

            FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                2,
                userName,
                DateTime.Now,
                getExpiration( expiration ),
                isPersistent,
                userId.ToString(),
                FormsAuthentication.FormsCookiePath
            );

            String str = FormsAuthentication.Encrypt( ticket );
            HttpCookie cookie = new HttpCookie( cookieName, str );
            if (isPersistent) {
                cookie.Expires = ticket.Expiration;
            }

            if (FormsAuthentication.CookieDomain != null) {
                cookie.Domain = FormsAuthentication.CookieDomain;
            }

            this.Response.Cookies.Add( cookie );
        }
Ejemplo n.º 20
0
 public void UserLogin( int userId, String userName, LoginTime expiration )
 {
     UserLogin( FormsAuthentication.FormsCookieName, userId, userName, expiration );
 }
Ejemplo n.º 21
0
 public virtual void Login(User user, LoginTime expiration, String ip, MvcContext ctx)
 {
     updateLastLogin(user, ip);
     ctx.web.UserLogin(user.Id, user.Name, expiration);
     OnlineStats.Instance.AddMemberCount();
 }
Ejemplo n.º 22
0
 // 直接本站登录(不是从第三方登录)
 public virtual void Login( User user, LoginTime expiration, String ip, MvcContext ctx )
 {
     Login( user, 0, expiration, ip, ctx );
 }
Ejemplo n.º 23
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (TradingDay.Length != 0)
            {
                hash ^= TradingDay.GetHashCode();
            }
            if (LoginTime.Length != 0)
            {
                hash ^= LoginTime.GetHashCode();
            }
            if (BrokerId.Length != 0)
            {
                hash ^= BrokerId.GetHashCode();
            }
            if (UserId.Length != 0)
            {
                hash ^= UserId.GetHashCode();
            }
            if (SystemName.Length != 0)
            {
                hash ^= SystemName.GetHashCode();
            }
            if (FrontId != 0)
            {
                hash ^= FrontId.GetHashCode();
            }
            if (SessionId != 0)
            {
                hash ^= SessionId.GetHashCode();
            }
            if (MaxOrderRef.Length != 0)
            {
                hash ^= MaxOrderRef.GetHashCode();
            }
            if (ShfeTime.Length != 0)
            {
                hash ^= ShfeTime.GetHashCode();
            }
            if (DceTime.Length != 0)
            {
                hash ^= DceTime.GetHashCode();
            }
            if (CzceTime.Length != 0)
            {
                hash ^= CzceTime.GetHashCode();
            }
            if (FfexTime.Length != 0)
            {
                hash ^= FfexTime.GetHashCode();
            }
            if (IneTime.Length != 0)
            {
                hash ^= IneTime.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 24
0
 public void UserLogin(string cookieName, long userId, string userName, LoginTime expiration)
 {
 }
Ejemplo n.º 25
0
 public void UserLogin(string cookieName, long userId, string userName, LoginTime expiration)
 {
 }
Ejemplo n.º 26
0
 public virtual void Login( User user, LoginTime expiration, String ip, MvcContext ctx )
 {
     updateLastLogin( user, ip );
     ctx.web.UserLogin( user.Id, user.Name, expiration );
     OnlineStats.Instance.AddMemberCount();
 }
Ejemplo n.º 27
0
 public void UserLogin(string cookieName, long userId, string userName, LoginTime expiration) {
     UserLogin( cookieName, userId, userName, getExpiration( expiration ) );
 }
Ejemplo n.º 28
0
 public void UserLogin(String cookieName, int userId, String userName, LoginTime expiration)
 {
     UserLogin(cookieName, userId, userName, getExpiration(expiration));
 }
 public async Task AddLoginTime(LoginTime loginTime)
 {
     _context.LoginTime.Add(loginTime);
     await _context.SaveChangesAsync();
 }
Ejemplo n.º 30
0
 // 直接本站登录(不是从第三方登录)
 public virtual void Login(User user, LoginTime expiration, String ip, MvcContext ctx)
 {
     Login(user, 0, expiration, ip, ctx);
 }
Ejemplo n.º 31
0
 public void UserLogin(String cookieName, int userId, String userName, LoginTime expiration)
 {
 }