Ejemplo n.º 1
0
        public override object Execute()
        {
            AccountList <accountItem> m_List = new AccountList <accountItem>(true);

            m_List.Load(fileName);
            return(m_List);
        }
Ejemplo n.º 2
0
            public AccountCache()
            {
                LocalUser = new User();

                Users = new AccountList <User>();
                Clans = new AccountList <Clan>();
            }
Ejemplo n.º 3
0
        protected override AccountsViewsList getRandomObject()
        {
            var l = new AccountList(null, null);

            SetRandom.Values(l);
            return(new AccountsViewsList(l));
        }
Ejemplo n.º 4
0
        public ActionResult Delete(AccountClass acc)
        {
            AccountList accList = new AccountList();

            accList.DeleteAccount(acc);
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 5
0
        public ActionResult Delete(string id = null)
        {
            AccountList         accList = new AccountList();
            List <AccountClass> obj     = accList.GetAccountClass(id);

            return(View(obj.FirstOrDefault()));
        }
Ejemplo n.º 6
0
        public AccountListManager(Database db, AccountList listType)
        {
            InitializeComponent();

            _db       = db;
            _listType = listType;
        }
Ejemplo n.º 7
0
        public void Refresh()
        {
            if (TargetObject == null)
            {
                return;
            }
            var o = TargetObject as IPortfolio;

            if (o == null)
            {
                return;
            }

            PositionList.Clear();
            AccountList.Clear();

            o.PositionList.ForEach(v =>
            {
                PositionList.Add(v);
            });

            o.AccountList.ForEach(v =>
            {
                AccountList.Add(v);
            });
        }
Ejemplo n.º 8
0
 public Bank()
 {
     BankAccounts = new AccountList[10];
     AddAccount(100, "Bob");
     AddAccount(200, "Mary");
     AddAccount(300, "Charlie");
 }
Ejemplo n.º 9
0
        private string WithdrawFunction(AccountList mylist, string input, int i)
        {
            if ((int.TryParse(input, out x)) && x > 0 && x <= 400)
            {
                x = int.Parse(input);

                if (mylist.CustomerAccountList[i].WithdrawFunds(x))
                {
                    popUpOk.gameObject.SetActive(false);
                    popUpCancel.GetComponentInChildren <Text> ().text = "Back";

                    accList.ChangeSavedData(mylist);

                    return("Cash withdrawn,\nnew balance: " + mylist.CustomerAccountList[i].GetBalance());
                }
                else
                {
                    popUpOk.gameObject.SetActive(false);
                    return("Insufficient funds");
                }
            }
            else
            {
                return("Wrong Input, try again \nusing value between 0 and 400");
            }
        }
Ejemplo n.º 10
0
        private void bShow_Click(object sender, EventArgs e)
        {
            AccountList accountList = AccountList.GetAccountList();

            output.Text += string.Concat(Environment.NewLine,
                                         "___List___", Environment.NewLine, accountList.GetList(), "__________", Environment.NewLine);
        }
Ejemplo n.º 11
0
        public void InitFindAccount(AccountList myacc)
        {
            if (myacc.CustomerAccountList.Count != 0)
            {
                if (index == 0)
                {
                    buttons = new List <Button> ();
                }

                if (buttons.Count > 0)
                {
                    for (int i = 0; i < buttons.Count; i++)
                    {
                        Destroy(buttons [i].gameObject);
                        index = 0;
                    }
                    buttons.Clear();
                }

                for (int i = 0; i < myacc.CustomerAccountList.Count; i++)
                {
                    button     = Instantiate(accountButton, accountButtonContainer.transform) as Button;
                    buttonText = "Surname: " + myacc.CustomerAccountList [i].surname +
                                 "\nName: " + myacc.CustomerAccountList [i].name + "\nAddress: " + myacc.CustomerAccountList [i].address
                                 + "\nAccount ID: " + myacc.CustomerAccountList[i].accountID;
                    button.GetComponentInChildren <Text> ().text = buttonText;
                    index++;
                    buttons.Add(button);
                    Button b = button.GetComponent <Button> ();
                    ButtonAddListener(myacc, b);
                }
                accounts.CustomerAccountList = myacc.CustomerAccountList;
            }
        }
        public async Task <IActionResult> Index()
        {
            //This is a citizen, send them to the citizen controller
            if (LoggedInUser.Permission == Data.Enums.SystemPermissions.None)
            {
                return(RedirectToAction("Index", "Citizens"));
            }

            //This is vendor, send them to the Vendor view.
            if (LoggedInUser.Permission == Data.Enums.SystemPermissions.Vendor)
            {
            }

            //get all accounts for this user
            var accounts = await CommonContext.UserAccounts.AsNoTracking()
                           .Include(m => m.Account).ThenInclude(m => m.City)
                           .Where(m => m.UserId == LoggedInUser.Id).ToListAsync();

            var model = new AccountList();

            model.Accounts = Mapper.Map <List <AccountListItem> >(accounts.Select(m => m.Account));

            if (model.Accounts.Count == 1)
            {
                return(RedirectToAction("Index", "Home", new { AccountNum = model.Accounts.First().Number }));
            }

            return(View(model));
        }
Ejemplo n.º 13
0
        public JsonResponse AccountUserList([FromUri] string Code, string UserId)
        {
            //判断用户是否登录
            if (!TokenHelper.CheckLoginStateByUserId(UserId))
            {
                return(BadResponse("用户未登录", null, false));
            }
            AccountList model = new AccountList();

            model = AccountListBll.GetModelByCode(Code);
            string[]        allUserIdArray = model.AllUserId.Split(',');
            List <UserInfo> AllUserList    = UserInfoBll.GetListByIdList(allUserIdArray).ToList();

            List <AccountListAllUserDto> returnList = new List <AccountListAllUserDto>();

            foreach (var user in AllUserList)
            {
                AccountListAllUserDto userModel = new AccountListAllUserDto
                {
                    NickName = user.Nickname,
                    UserId   = user.Id
                };
                returnList.Add(userModel);
            }
            return(OkResponse(returnList, "请求成功!"));
        }
Ejemplo n.º 14
0
        public void TimedPassExpiredAtExitBarrier()
        {
            //setup for ticket and file creation
            Ticket initTicket = new Ticket();

            initTicket.InitialiseTicketId();

            CustomerAccount bobAccount = new CustomerAccount(1, 38.50m, 1, "Bob", "password", "Bob Shanks", false);
            AccountList     accList    = new AccountList(false);

            accList.AddCustomerAccount(bobAccount);
            accList.SaveCustomerData();

            Station startStation = new Station("Newcastle");
            Station endStation   = new Station("Sheffield");

            Ticket ticket = new Ticket(true, DateTime.Now.AddDays(-8), "timed", DateTime.Now.AddDays(-1), bobAccount.GetAccountId());

            ticket.InitialiseTicketId();
            ticket.InitialiseTickets();

            //create an exit barrier with any station
            Scanner scanner = new Scanner(new Station(new DepartureList(), "Birmingham"), false);

            scanner.AddScannedTicket(ticket);
            Assert.IsFalse(scanner.ValidateTicket());
        }
Ejemplo n.º 15
0
        private void AccountList_Button_Click(object sender, EventArgs e)
        {
            AccountList control = new AccountList();

            this.ShowControl(control, Content);
            //this.SetTitle("Thông tin hệ thống tài khoản");
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Initialises a new instance of the <see cref="MainDesktopViewModel"/> class.
        /// </summary>
        /// <param name="windowService">The platform's window service.</param>
        /// <param name="deviceSettings">Platform-specific device settings</param>
        public MainDesktopViewModel(IWindowService windowService, IDeviceSettings deviceSettings)
        {
            this.windowService = windowService;

            Messenger.Default.Register <LoadedApplicationState>(
                this,
                (x) =>
            {
                this.RebindReadModels();
            });

            this.applicationKernel = ServiceLocatorWrapper.Current.GetInstance <Kernel>();
            var repositories = ServiceLocatorWrapper.Current.GetInstance <ReadRepositories>();

            // this.RebindReadModels(); // this would cause events while this class is not yet initialised
            // so use local fields instead
            // this.accountList = repositories.AccountListRepository.Find(BudgetId.OffBudgetId); // TODO: use correct budget ids etc later
            this.accountList = repositories.BudgetListRepository.Find().Single(x => BudgetId.OffBudgetId.Equals(x.BudgetId)).Accounts;
            this.InitialiseRelayCommands();

            // Only after everything has been initialised, continue with the application flow
            var autoloaded = deviceSettings.GetAutoloadBudgetIdentifier();

            if (!string.IsNullOrWhiteSpace(autoloaded))
            {
                // TODO: error handling, obviously
                this.applicationKernel.LoadApplicationState(autoloaded); // causes message
            }
            else
            {
                // TODO: navigate to "new or load" view
            }
        }
Ejemplo n.º 17
0
        public static void ATMLogIn(ref AccountList theList)
        {
            Console.Clear();
            while (true)
            {
                Console.Clear();
                Console.WriteLine("Welcome to the ATM\n");

                int accountNumber = 0;
                bool exists = false;
                while (exists == false)
                {
                    accountNumber = TryParse("Please enter your account number: ");

                    exists = IsAccountInAccountList(theList, accountNumber);
                    if (exists == false) Console.WriteLine("Account number not found - Please try again");
                }

                for (int numOfTries = 0; numOfTries < 3; numOfTries++)
                {
                    Console.Write("Please enter your password: "******"Incorrect password - Please retry");
                }
            }
        }
Ejemplo n.º 18
0
        public override int run(AccountList accts)
        {
            /* validate the options. */
            Account acct = new Account();

            acct.name = _opts.name;
            if (string.IsNullOrWhiteSpace(acct.name))
            {
                Console.WriteLine("Account name can't be blank.");
                return(-1);
            }

            if (string.Compare(_opts.type, "local", true) == 0)
            {
                acct.svcName = typeof(BackupLib.LocalService).FullName;
                acct.connStr = _opts.directory;
            }
            if (string.Compare(_opts.type, "b2", true) == 0)
            {
                acct.svcName = typeof(CommB2.Connection).FullName;
                acct.connStr = string.Format("{0}:{1}", _opts.user, _opts.password);
            }

            if (string.IsNullOrWhiteSpace(acct.svcName))
            {
                Console.WriteLine("Account type unknown: valid types: local, b2");
                return(-1);
            }

            accts.Add(acct);
            BackupLib.AccountBuilder.Load(accts, acct);
            return(0);
        }
        public JsonResult ReturnContractsFile([FromBody] ContractsFilterCallModel model)
        {
            var usernameSplit = model.Credentials.User.Split("\\");
            var username      = usernameSplit.Length == 2 ? usernameSplit[1].ToUpper() : "unknown";

            var listname = $"{Utils.GetRandomString()}";
            var name     = new AccountList()
            {
                AccountListName = listname
            };

            if (CssAppConfig.RunInTestMode)
            {
                var results = new CssCommandResult()
                {
                    Results = new List <CommandResponse> ()
                    {
                        new CommandResponse("sample css action", "sample css response"),
                        new CommandResponse("sample css action", "sample css response")
                    }
                };
                return(new JsonResult(new { ListName = name.ToString(), FilterResultLog = results }));
            }

            CssCommandResult data = FilterCapability.FilterContracts(model.FilterCriteria, name, model.Credentials);

            return(new JsonResult(new { ListName = name.ToString(), FilterResultLog = data }));
        }
Ejemplo n.º 20
0
        void LoadData(object obj)
        {
            if (obj == null)
            {
                return;
            }

            var p = obj as IPortfolio;

            if (p == null)
            {
                return;
            }

            PositionList.Clear();
            p.PositionList.ForEach(v =>
            {
                PositionList.Add(v.Clone() as IPosition);
            });
            p.AccountList.ForEach(v =>
            {
                AccountList.Add(v.Clone() as Account);
            });
            Name = p.Name;
            Memo = p.Memo;

            LastMarketDataTime = p.LastMarketDataTime;
            CurrentCurrency    = p.CurrentCurrency;
        }
Ejemplo n.º 21
0
        public static void Main(string[] args)
        {
            AccountList <int> intAccountList = new AccountList <int>();

            intAccountList[0] = new Account <int>(111, 100);
            intAccountList[1] = new Account <int>(222, 50);
            intAccountList[2] = new Account <int>(333, 75);
            intAccountList[3] = new Account <int>(444, 200);

            foreach (Account <int> account in intAccountList)
            {
                account.AddBalance(100);
                Console.WriteLine(account);
            }

            Console.WriteLine("----------------------------------");

            AccountList <string> stringAccountList = new AccountList <string>();

            stringAccountList[0] = new Account <string>("555", 342);
            stringAccountList[1] = new Account <string>("666", 430);
            stringAccountList[2] = new Account <string>("777", 550);
            stringAccountList[3] = new Account <string>("888", 1000);

            foreach (Account <string> account in stringAccountList)
            {
                account.WithdrawBalance(50);
                Console.WriteLine(account);
            }

            Console.ReadKey();
        }
Ejemplo n.º 22
0
        public ActionResult UpdateInitialBalance(AccountList accountlist)
        {
            try
            {
                AccountList Account = new AccountList();
                Account = db.AccountList.Find(accountlist.AccountListID);
                Account.InitialBalance  = accountlist.InitialBalance;
                Account.UpdateBy        = AppUtils.GetLoginUserID();
                Account.UpdateDate      = AppUtils.GetDateTimeNow();
                db.Entry(Account).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();


                AccountingHistory accountingHistory = db.AccountingHistory.Where(x => x.AccountListID == accountlist.AccountListID).FirstOrDefault();
                //Mode 1 mean Create 2 mean Update
                SetInformationForAccountHistory(ref accountingHistory, accountlist, 2);
                db.Entry(accountingHistory).State = EntityState.Modified;
                db.SaveChanges();

                var JSON = Json(new { success = true }, JsonRequestBehavior.AllowGet);
                JSON.MaxJsonLength = int.MaxValue;
                return(JSON);
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 23
0
        //public ActionResult TransHist()
        //{
        //    var transHist = from c in db.Customers
        //                  join a in db.Accounts on c.CustomerID equals a.CustomerFK
        //                  join t in db.Transactions on c.CustomerID equals t.CustomerFK
        //                  join tt in db.TransactionTypes on t.TransactionTypeFK equals tt.TransactionTypeID
        //                  select new AccountTransHist { CreateDate = t.CreateDate, TransactionName = tt.TransactionName, Amount = t.Amount, RemainingBalance = t.RemainingBalance };
        //    return View(transHist);
        //}

        public ActionResult Edit(int acctid)
        {
            AccountList acctlist = new AccountList();
            var         acct     = db.Accounts.Where(a => a.AccountId == acctid).FirstOrDefault();

            if (acct != null)
            {
                //**Get customer name
                var name   = db.Customers.Where(c => c.CustomerID == acct.CustomerFK).Select(c => c.CustomerName).FirstOrDefault();
                var custid = db.Customers.Where(i => i.CustomerID == acct.CustomerFK).FirstOrDefault();
                //**Get Mobile Number
                var mbl = db.Customers.Where(c => c.CustomerID == acct.CustomerFK).FirstOrDefault();

                acctlist              = new AccountList();
                acctlist.AccountId    = acctid;
                acctlist.AccountNo    = acct.AccountNo;
                acctlist.CustomerName = name;
                //acctlist.MobileNumber = db.MobileNumbers.Where(m => m.CustomerFK == mbl.CustomerID).Select(m => m.MobileNumber1).FirstOrDefault();

                var embl = db.MobileNumbers.Where(n => n.CustomerFK == custid.CustomerID).ToList();
                acctlist.MobileNumbers = embl.ToList();
            }
            ;

            return(View(acctlist));
        }
Ejemplo n.º 24
0
 public ActionResult UpdateAccountList(AccountList AccountInfo)
 {
     try
     {
         AccountList Account = new AccountList();
         Account = db.AccountList.Find(AccountInfo.AccountListID);
         Account.AccountTitle    = AccountInfo.AccountTitle;
         Account.Description     = AccountInfo.Description;
         Account.InitialBalance  = AccountInfo.InitialBalance;
         Account.AccountNumber   = AccountInfo.AccountNumber;
         Account.ContactPerson   = AccountInfo.ContactPerson;
         Account.Phone           = AccountInfo.Phone;
         Account.BankUrl         = AccountInfo.BankUrl;
         Account.OwnerID         = AccountInfo.OwnerID;
         Account.UpdateBy        = AppUtils.GetLoginUserID();
         Account.UpdateDate      = AppUtils.GetDateTimeNow();
         db.Entry(Account).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         var JSON = Json(new { success = true }, JsonRequestBehavior.AllowGet);
         JSON.MaxJsonLength = int.MaxValue;
         return(JSON);
     }
     catch (Exception ex)
     {
         return(Json(new { success = false }, JsonRequestBehavior.AllowGet));
     }
 }
Ejemplo n.º 25
0
        public ActionResult CreateConfirm(AccountList accountlist)
        {
            var dbAccounlist = db.AccountList.Where(s => s.AccountTitle == accountlist.AccountTitle).FirstOrDefault();

            if (dbAccounlist != null)
            {
                return(Json(new { nameExist = true }));
            }

            try
            {
                accountlist.CreateBy   = AppUtils.GetLoginUserID();
                accountlist.CreateData = AppUtils.GetDateTimeNow();
                accountlist.Status     = AppUtils.TableStatusIsActive;
                db.AccountList.Add(accountlist);
                db.SaveChanges();

                AccountingHistory accountingHistory = new AccountingHistory();
                //Mode 1 mean Create 2 mean Update
                SetInformationForAccountHistory(ref accountingHistory, accountlist, 1);
                db.AccountingHistory.Add(accountingHistory);
                db.SaveChanges();

                return(Json(new { success = true }));
            }
            catch (Exception ex)
            {
                return(Json(new { success = false }));
            }
        }
        public IHandlerBuilder Index(int page, bool inactive, IRequest request)
        {
            if (page < 1)
            {
                page = 1;
            }

            using var context = Database.Create();

            IQueryable <Account> query = context.Accounts;

            if (!inactive)
            {
                query = query.Where(u => u.Active);
            }

            var total = query.Count();

            var records = query.Skip((page - 1) * PAGE_SIZE)
                          .Take(PAGE_SIZE)
                          .OrderBy(u => u.DisplayName)
                          .ToList();

            var pages = (total + PAGE_SIZE - 1) / PAGE_SIZE;

            var paged = new PagedList <Account>(records, page, pages, total);

            var user = AccessControl.GetAccount(request);

            var list = new AccountList(user, paged);

            return(ModRazor.Page(Resource.FromAssembly("Account.List.cshtml"), (r, h) => new ViewModel <AccountList>(r, h, list))
                   .Title("Mitarbeiter"));
        }
Ejemplo n.º 27
0
 public void FindClashIngameToons(AccountList <ClashAccount> clashAccountList)
 {
     foreach (ClashAccount clashAccount in clashAccountList)
     {
         FindClashIngameToons(clashAccount);
     }
 }
        //load
        public void LoadList()
        {
            string filePath = Application.dataPath + filename1;

            if (File.Exists(filePath))
            {
                if (File.ReadAllText(filePath).Length != 0)
                {
                    myAccounts = JasonManager.GetAccountList(File.ReadAllText(filePath));
                }
                else
                {
                    List <CustomerAccount> mylistofcustomers = new List <CustomerAccount> ();
                    myAccounts = new AccountList(mylistofcustomers);
                }

                findAccPanel.InitFindAccount(myAccounts);
                newAccPanel.InitNewAccount(myAccounts.CustomerAccountList);
            }
            else
            {
                List <CustomerAccount> mylist = new List <CustomerAccount>();
                newAccPanel.InitNewAccount(mylist);
            }
        }
        public void ChangeSavedData(AccountList secondList)
        {
            for (int i = 0; i < myAccounts.CustomerAccountList.Count; i++)
            {
                for (int j = 0; j < secondList.CustomerAccountList.Count; j++)
                {
                    if (myAccounts.CustomerAccountList[i].name == secondList.CustomerAccountList[j].name)
                    {
                        if (myAccounts.CustomerAccountList[i].surname == secondList.CustomerAccountList[j].surname)
                        {
                            if (myAccounts.CustomerAccountList[i].address == secondList.CustomerAccountList[j].address)
                            {
                                myAccounts.CustomerAccountList [i].balance = secondList.CustomerAccountList [j].balance;
                                myAccounts.CustomerAccountList [i].state   = secondList.CustomerAccountList [j].state;
                                myAccounts.CustomerAccountList [i].address = secondList.CustomerAccountList [j].address;

                                SaveList(myAccounts);
                                break;
                            }
                        }
                    }
                }
            }
            //end for
        }
Ejemplo n.º 30
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                hMailServerNetRemote.IApplication app = RemoteActivation.GetAuthenticatedRemotehMailServerApplication();
                if (app == null)
                {
                    Response.End();
                }

                hMailServerNetRemote.IDomain dom = app.Domains.ItemByDBID(Convert.ToInt32(Request.QueryString["ID"]));

                DomainName.Text = dom.Name;

                List <hMailServerNetRemote.IAccount> accounts = new List <hMailServerNetRemote.IAccount>();
                hMailServerNetRemote.IAccounts       accs     = dom.Accounts;
                int c = accs.Count;

                for (int i = 0; i < c; i++)
                {
                    accounts.Add(accs[i]);
                }

                AccountList.DataSource = accounts;
                AccountList.DataBind();
            }
        }
Ejemplo n.º 31
0
        public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
        {
            //Get the list
            AccountList manager = (AccountList)value;

            if (manager == null)
            {
                writer.WriteNull();
                return;
            }

            //Create a object to hold the elements
            JObject accountMapping = new JObject();

            foreach (var acc in manager.Accounts)
            {
                //Create the inner account object
                JObject accobj = new JObject();
                accobj.Add("admin", acc.Value.IsAdmin);
                accobj.Add("password", acc.Value.Password);

                //Add it to the holding element with the key of the account name
                accountMapping.Add(acc.Key, accobj);
            }

            //Write the mapping
            accountMapping.WriteTo(writer);
        }
Ejemplo n.º 32
0
        /* ****************************************************************************************
         * Add the amount given to the balance of the account given
         * Assumption - The account is in the list
         */
        public static void Deposit(double theAmount, int accountNumber, ref AccountList theList)
        {
            theList.theAccounts[FindAccount(accountNumber, theList)].balance += theAmount;
            RewriteAccountsFile(theList);

            Console.Clear();
            Console.WriteLine("Successfully deposited ${0}", theAmount);
            Console.WriteLine("Your new balance is: ${0}\n", theList.theAccounts[FindAccount(accountNumber, theList)].balance);
        }
Ejemplo n.º 33
0
 /// <summary>
 /// Initialises a new instance of the <see cref="MainDesktopViewModel"/> class.
 /// </summary>
 /// <param name="windowService">The platform's window service.</param>
 public MainDesktopViewModel(IWindowService windowService)
 {
     this.windowService = windowService;
     this.AddAccountCommand = new RelayCommand(() => this.AddAccount());
     this.RenameAccountCommand = new RelayCommand(() => this.RenameAccount());
     this.BootstrapDomain();
     var accountListRepo = ApplicationCore.Core.Default.Repositories.AccountListReadModelRepository;
     this.accountList = accountListRepo.Find();
 }
Ejemplo n.º 34
0
        public string GetOTP(int loginMethod, AccountList acc, string service_code="610074", string service_region="T9")
        {
            try
            {
                string response;
                if (loginMethod == 5)
                    response = this.DownloadString("https://tw.beanfun.com/beanfun_block/game_zone/game_start_step2.aspx?service_code="+service_code+"&service_region="+service_region+"&sotp=" + acc.sotp + "&dt=" + GetCurrentTime(2), Encoding.UTF8);
                else
                    response = this.DownloadString("https://tw.beanfun.com/beanfun_block/auth.aspx?channel=game_zone&page_and_query=game_start_step2.aspx%3Fservice_code%3D"+service_code+"%26service_region%3D"+service_region+"%26sotp%3D" + acc.sotp + "&web_token=" + this.webtoken);
                if (response == "")
                { this.errmsg = "OTPNoResponse"; return null; }

                Regex regex = new Regex("GetResultByLongPolling&key=(.*)\"");
                if (!regex.IsMatch(response))
                { this.errmsg = "OTPNoLongPollingKey"; return null; }
                string longPollingKey = regex.Match(response).Groups[1].Value;
                if (acc.screatetime == null)
                {
                    regex = new Regex("ServiceAccountCreateTime: \"([^\"]+)\"");
                    if (!regex.IsMatch(response))
                    { this.errmsg = "OTPNoCreateTime"; return null; }
                    acc.screatetime = regex.Match(response).Groups[1].Value;
                }
                response = this.DownloadString("https://tw.newlogin.beanfun.com/generic_handlers/get_cookies.ashx");
                regex = new Regex("var m_strSecretCode = '(.*)';");
                if (!regex.IsMatch(response))
                { this.errmsg = "OTPNoSecretCode"; return null; }
                string secretCode = regex.Match(response).Groups[1].Value;
                
                NameValueCollection payload = new NameValueCollection();
                payload.Add("service_code", service_code);
                payload.Add("service_region", service_region);
                payload.Add("service_account_id", acc.sacc);
                payload.Add("service_sotp", acc.sotp);
                payload.Add("service_display_name", acc.sname);
                payload.Add("service_create_time", acc.screatetime);
                // testing...
                System.Net.ServicePointManager.Expect100Continue = false;
                this.UploadValues("https://tw.new.beanfun.com/beanfun_block/generic_handlers/record_service_start.ashx", payload);
                response = this.DownloadString("https://tw.new.beanfun.com/generic_handlers/get_result.ashx?meth=GetResultByLongPolling&key=" + longPollingKey + "&_=" + GetCurrentTime());
                response = this.DownloadString("https://tw.new.beanfun.com/beanfun_block/generic_handlers/get_webstart_otp.ashx?SN=" + longPollingKey + "&WebToken=" + this.webtoken + "&SecretCode=" + secretCode + "&ppppp=FE40250C435D81475BF8F8009348B2D7F56A5FFB163A12170AD615BBA534B932&ServiceCode="+service_code+"&ServiceRegion="+service_region+"&ServiceAccount=" + acc.sacc + "&CreateTime=" + acc.screatetime.Replace(" ", "%20"));
                response = response.Substring(2);
                string key = response.Substring(0, 8);
                string plain = response.Substring(8);
                string otp = DecryptDES(plain, key);
                if (otp != null)
                    this.errmsg = null;       
           
                return otp;
            }
            catch (Exception e)
            {
                this.errmsg = "獲取密碼失敗,請嘗試重新登入。\n\n" + e.Message + "\n" + e.StackTrace;
                return null;
            }
        }
Ejemplo n.º 35
0
        public static void CreateNewAccount(ref AccountList theList)
        {
            while (true)
            {
                Account newAccount = GetNewAccountFromUser(theList);
                AddAccountToAccountList(ref theList, newAccount);
                WriteAccountToFile(newAccount);

                Console.Write("\nCreate another account? (YES/NO) ");

                if (Console.ReadLine().ToUpper() == "YES") { }
                else
                {
                    Console.Clear();
                    return;
                }
            }
        }
Ejemplo n.º 36
0
        public static AccountList GetAccountsByCustomer(int Id)
        {
            AccountList list = new AccountList();

            SqlParamsColl paramList = new SqlParamsColl();
            paramList.Add("@CustomerId", SqlDbType.Int, Id);

            SqlTools.ExecuteReader("dbo.Accounts_RetrieveByCustomer", paramList, reader =>
                {
                    while (reader.Read())
                    {
                        Account acc = new Account();
                        PopulateObjectFromReader(reader, acc);
                        list.Add(acc);
                    }
                });

            return list;
        }
Ejemplo n.º 37
0
        /* ****************************************************************************************
         * Get the details of a new account from the user.
         * Make sure the account number is not already in use
         * Return the new account
         */
        // User enters account information, checks to make sure account number isn't in use, and then returns the account
        public static Account GetNewAccountFromUser(AccountList theList)
        {
            Account newAccount;

            Console.Write("Enter your name: ");
            newAccount.name = Console.ReadLine();

            bool used = false;
            do
            {
                used = false;
                newAccount.number = TryParse("Enter an account number: ");
                used = IsAccountInAccountList(theList, newAccount.number);
            }
            while (used == true);

            Console.Write("Enter a password: ");
            newAccount.password = Console.ReadLine();

            newAccount.balance = 0; //

            return newAccount;
        }
Ejemplo n.º 38
0
 /* ****************************************************************************************
  * Check if t here is an account in the given AccountList with the given account number
  */
 public static bool IsAccountInAccountList(AccountList theList, int accountNumber)
 {
     for (int i = 0; i < MAX_ACCOUNTS; i++)
     {
         if (theList.theAccounts[i].number == accountNumber)
             return true;
     }
     return false;
 }
Ejemplo n.º 39
0
 /* ****************************************************************************************
  * Check if the AccountList is full.  I.E. is are there already NUM_ACCOUNTS in the list?
  */
 public static bool IsAccountListFull(AccountList theList)
 {
     if (theList.numberOfAccounts >= MAX_ACCOUNTS)
         return true;
     else
         return false;
 }
Ejemplo n.º 40
0
 /* ****************************************************************************************
  * Add the given Account to the given AccountList
  * Assumption - There is room for the Account
  */
 public static void AddAccountToAccountList(ref AccountList theList, Account theAccount)
 {
     theList.theAccounts[theList.numberOfAccounts] = theAccount;
     theList.numberOfAccounts++;
 }
Ejemplo n.º 41
0
        public static void ReadAllAccountsFromFile(ref AccountList theList)
        {
            try
            {
                using (StreamReader reader = new StreamReader(FILE_PATH))
                {
                    for (int i = 0; i < MAX_ACCOUNTS; i++) // If I set i to 'theList.numberOfAccounts' it will not overwrite already added accounts
                    {
                        if (reader.EndOfStream)
                        {
                            Console.WriteLine("Imported {0} account(s)\n", theList.numberOfAccounts);
                            return;
                        }

                        theList.theAccounts[i].name = reader.ReadLine();
                        theList.theAccounts[i].number = Int32.Parse(reader.ReadLine());
                        theList.theAccounts[i].balance = double.Parse(reader.ReadLine());
                        theList.theAccounts[i].password = reader.ReadLine();

                        theList.numberOfAccounts++;
                    }
                }
            }
            catch (IOException)
            {
                Console.WriteLine("Failed to access the file. Do you have permissions?");
            }
        }
Ejemplo n.º 42
0
        public static void RewriteAccountsFile(AccountList theList)
        {
            try
            {
                using (StreamWriter writer = new StreamWriter(FILE_PATH))
                {
                    writer.Write("");
                }
            }
            catch (IOException)
            {
                Console.WriteLine("Failed to create / modify the file. Do you have permissions?");
            }

            for (int i = 0; i < theList.numberOfAccounts; i++)
            {
                try
                {
                    using (StreamWriter writer = new StreamWriter(FILE_PATH, true))
                    {
                        writer.WriteLine(theList.theAccounts[i].name);
                        writer.WriteLine(theList.theAccounts[i].number);
                        writer.WriteLine(theList.theAccounts[i].balance);
                        writer.WriteLine(theList.theAccounts[i].password);
                    }
                }
                catch (IOException)
                {
                    Console.WriteLine("Failed to create / modify the file. Do you have permissions?");
                }
            }
        }
 /// <summary>
 /// Save the account list, or add it to the repository. Beware: replaces existing account list in repository.
 /// </summary>
 /// <param name="accountList">Account list to save</param>
 public void Save(AccountList accountList)
 {
     this.accountList = accountList;
 }
Ejemplo n.º 44
0
        /* ****************************************************************************************
         * Subtract the amount given from the balance of the account given
         * Assumption - The account is in the list
         */
        public static void Withdraw(double theAmount, int accountNumber, ref AccountList theList)
        {
            double theBalance = theList.theAccounts[FindAccount(accountNumber, theList)].balance;

            if (theBalance >= theAmount)
            {
                theBalance -= theAmount;

                theList.theAccounts[FindAccount(accountNumber, theList)].balance = theBalance;
                RewriteAccountsFile(theList);

                Console.Clear();
                Console.WriteLine("Successfully withdrew ${0}", theAmount);
                Console.WriteLine("Your new balance is: ${0}\n", theBalance);
            }
            else
            {
                Console.WriteLine("Not enough funds.\n");
            }
        }
Ejemplo n.º 45
0
        /* ****************************************************************************************
         * Finds the index of the account in the array given the account number
         * Assumption - The account is in the list, otherwise it returns 0
         */
        public static int FindAccount(int accountNumber, AccountList theList)
        {
            for (int i = 0; i < MAX_ACCOUNTS; i++)
            {
                if (theList.theAccounts[i].number == accountNumber)
                    return i;
            }

            return 0; // Have to return an int to shut Visual Studio up
        }
Ejemplo n.º 46
0
 private TwitterController()
 {
     m_aclAccounts = new AccountList();
 }
Ejemplo n.º 47
0
 public CredentialFile(AccountList list, string fileName)
 {
     FileName = fileName;
     _mAccountList=new AccountList(list);
 }
Ejemplo n.º 48
0
        public static void UserLoggedIn(AccountList theList, int accountNumber)
        {
            Console.Clear();
            Console.WriteLine("Welcome, {0}. Please use the options below.\n", theList.theAccounts[FindAccount(accountNumber, theList)].name);

            int userChoice = 0;
            while (true)
            {
                Console.WriteLine("1) Check Balance");
                Console.WriteLine("2) Deposit");
                Console.WriteLine("3) Withdraw");
                Console.WriteLine("4) Change Password");
                Console.WriteLine("5) Sign out");
                Console.Write("\n> ");
                userChoice = TryParse(displayMessage: false);
                Console.WriteLine();

                switch (userChoice)
                {
                    case 1:
                        Console.Clear();
                        Console.WriteLine("Your current balance is: ${0}\n", theList.theAccounts[FindAccount(accountNumber, theList)].balance);
                        break;
                    case 2:
                        Console.Clear();
                        Deposit(TryParse("How much do you want to deposit: "), accountNumber, ref theList);
                        break;
                    case 3:
                        Console.Clear();
                        Withdraw(TryParse("How much do you want to withdraw: "), accountNumber, ref theList);
                        break;
                    case 4:
                        Console.Clear();
                        Console.Write("Enter new password: "******"Password successfully changed\n");
                        break;
                    case 5:
                        return;
                }
            }
        }
Ejemplo n.º 49
0
 public CredentialFile(string fileName)
 {
     FileName = fileName;
     _mAccountList=new AccountList();
 }
 /// <summary>
 /// Initialises a new instance of the <see cref="AccountListReadModelRepository"/> class.
 /// </summary>
 public AccountListReadModelRepository()
 {
     this.accountList = new AccountList();
 }