Beispiel #1
0
        /// <summary>
        /// Create a new model that fetches data from the specified server.
        /// </summary>
        /// <param name="password">The password to the server</param>
        /// <param name="server">The address of the server.</param>
        public LogModel(string password, string server)
        {
            this.password = password;
            this.server = server;

            var conn = DigitalVoterList.GetInstance("groupCJN", this.password, this.server);

            this.logs = new BindingList<LogDO>();
            this.lDAO = new LogDAO(conn);

            this.vDAO = new VoterDAO(conn);

            this.Update();

            this.filter = new LogFilter();
        }
Beispiel #2
0
 /// <summary>
 /// Updates the log with activity registered for the current voter
 /// </summary>
 /// <param name="ae">The activity to be logged</param>
 private void UpdateLog(ActivityEnum ae)
 {
     try
     {
         //Create the log DAO with setup information, activity and current voter.
         var ldo = new LogDO(setupInfo.TableNo, currentVoter.PrimaryKey, ae);
         var ldao = new LogDAO(DigitalVoterList.GetInstanceFromServer(setupInfo.Ip));
         ldao.Create(ldo);
     }
     catch (Exception)
     {
         ConnectionError();
     }
 }
        public async Task <ApiAccountInfoReponse> AuthenLoginFacebook(PostLoginFacebook data)
        {
            try
            {
                var fb = await Utilities.FB.Facebook.GetIDsForBusiness(data.accessToken);

                if (fb == null)
                {
                    return new ApiAccountInfoReponse {
                               Code = -50
                    }
                }
                ;
                string accountIds = fb.Select(x => x.id).Aggregate((i, j) => i + ";" + j);
                long   accountId  = AccountDAO.CheckBussinessAccount(accountIds);//request the minium user_id
                var    account    = new Models.Account();
                if (accountId > 0)
                {
                    account = AccountDAO.GetAccountInfo(accountId);
                }
                if (account == null || account.AccountID == 0)
                {
                    account = new Models.Account();
                }
                else
                {
                    if (account.IsBlocked)
                    {
                        return new ApiAccountInfoReponse {
                                   Code = -65
                        }
                    }
                    ;
                    //if (account.IsOTP)
                    //{
                    //    string token = $"{DateTime.Now.Ticks}|{account.AccountID}|{account.DisplayName}|{data.device}";
                    //    return new ApiAccountReponse
                    //    {
                    //        Code = 2,
                    //        Account = account,
                    //        OTPToken = Security.TripleDESEncrypt(ConfigurationManager.AppSettings["OTPKey"], token)
                    //    };
                    //}
                    LogDAO.Login(data.device, IPAddressHelper.GetClientIP(), account.AccountID, 2);
                    SetAuthCookie(account.AccountID, account.DisplayName, data.device, 2);
                    return(new ApiAccountInfoReponse {
                        Code = 1, Account = account
                    });
                }
                int response = account.RegisterFacebookAccount($"FB_{fb.FirstOrDefault().id}");
                if (response < 0)
                {
                    return new ApiAccountInfoReponse {
                               Code = response
                    }
                }
                ;
                AccountDAO.CheckBussinessAccount(accountIds);
                LogDAO.Login(data.device, IPAddressHelper.GetClientIP(), account.AccountID, 2, true);
                SetAuthCookie(account.AccountID, "U." + account.AccountID, data.device, 2);
                var accuntInfo = new
                {
                    userid   = account.AccountID,
                    username = account.DisplayName
                };
                return(new ApiAccountInfoReponse {
                    Code = response, Account = accuntInfo
                });
            }
            catch (Exception ex)
            {
                NLogManager.PublishException(ex);
            }

            return(new ApiAccountInfoReponse
            {
                Code = -99
            });
        }