public void Create_ValidParams_AccountReturned() { //Arrange var idGuid = Guid.Parse("051f8160-ce43-4ac0-b8c2-09707c2bcda3"); var id = AccountId.FromGuid(idGuid); var ownerGuid = Guid.Parse("4bc0c0e9-7181-45e4-934d-e91c0e7bbd75"); var ownerId = UserId.FromGuid(ownerGuid); var period = Period.FromMonth(2020, 9); var currency = CurrencyCode.FromString("EUR"); //Act var account = AccountRoot.Create(id, ownerId, period, currency); //Assert Assert.IsNotNull(account); Assert.AreEqual(idGuid, account.Id); Assert.AreEqual(ownerGuid, account.OwnerId.Value); Assert.AreEqual(DateTime.Parse("2020-09-01"), account.Period.StartDate); Assert.AreEqual(DateTime.Parse("2020-09-30"), account.Period.EndDate); Assert.AreEqual("EUR", account.Currency.Value); Assert.AreEqual(1, account.GetChanges().Count); Assert.AreEqual(typeof(V1.AccountCreated), account.GetChanges()[0].GetType()); var @event = account.GetChanges()[0] as V1.AccountCreated; Assert.AreEqual(idGuid, @event.AccountId); Assert.AreEqual(ownerGuid, @event.OwnerId); Assert.AreEqual(DateTime.Parse("2020-09-01"), @event.StartDate); Assert.AreEqual(DateTime.Parse("2020-09-30"), @event.EndDate); Assert.AreEqual("EUR", @event.CurrencyCode); Assert.AreEqual(AccountState.AccountStateEnum.Open, account.State.Value); }
public void GetFirstUnusedAccountReturnsAccountWithLowerIndexHavingNoAddresses() { AccountRoot accountRoot = CreateAccountRoot(KnownCoinTypes.Stratis); HdAccount unused = CreateAccount("unused1"); unused.Index = 2; accountRoot.Accounts.Add(unused); HdAccount unused2 = CreateAccount("unused2"); unused2.Index = 1; accountRoot.Accounts.Add(unused2); HdAccount used = CreateAccount("used"); used.ExternalAddresses.Add(CreateAddress()); used.Index = 3; accountRoot.Accounts.Add(used); HdAccount used2 = CreateAccount("used2"); used2.InternalAddresses.Add(CreateAddress()); used2.Index = 4; accountRoot.Accounts.Add(used2); HdAccount result = accountRoot.GetFirstUnusedAccount(); Assert.NotNull(result); Assert.Equal(1, result.Index); Assert.Equal("unused2", result.Name); }
public async Task TestUpdatePost() { // Create a post AccountRoot post = new AccountRoot { Account = new Account { Active = true, Number = "9005", Description = "Updated account", SRU = "8002" } }; // Update the post FortnoxResponse<AccountRoot> fr = await config.fortnox_client.Update<AccountRoot>(post, "accounts/9005"); // Log the error if (fr.model == null) { config.logger.LogError(fr.error); } // Test evaluation Assert.AreNotEqual(null, fr.model); } // End of the TestUpdatePost method
public void GetAllTransactionsByCoinTypeReturnsTransactionsFromWalletByCoinType() { var wallet = new Wallet(); AccountRoot stratisAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("StratisAccount", CoinType.Stratis); AccountRoot bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin); AccountRoot stratisAccountRoot2 = CreateAccountRootWithHdAccountHavingAddresses("StratisAccount2", CoinType.Stratis); TransactionData transaction1 = CreateTransaction(new uint256(1), new Money(15000), 1); TransactionData transaction2 = CreateTransaction(new uint256(2), new Money(91209), 1); TransactionData transaction3 = CreateTransaction(new uint256(3), new Money(32145), 1); TransactionData transaction4 = CreateTransaction(new uint256(4), new Money(654789), 1); TransactionData transaction5 = CreateTransaction(new uint256(5), new Money(52387), 1); TransactionData transaction6 = CreateTransaction(new uint256(6), new Money(879873), 1); stratisAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction1); stratisAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction2); bitcoinAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction3); bitcoinAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction4); stratisAccountRoot2.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction5); stratisAccountRoot2.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction6); wallet.AccountsRoot.Add(stratisAccountRoot); wallet.AccountsRoot.Add(bitcoinAccountRoot); wallet.AccountsRoot.Add(stratisAccountRoot2); List <TransactionData> result = wallet.GetAllTransactionsByCoinType(CoinType.Stratis).ToList(); Assert.Equal(4, result.Count); Assert.Equal(transaction2, result[0]); Assert.Equal(transaction6, result[1]); Assert.Equal(transaction1, result[2]); Assert.Equal(transaction5, result[3]); }
public void GetAllTransactionsReturnsTransactionsFromWallet() { var wallet = new Types.Wallet(); wallet.walletStore = new WalletMemoryStore(); AccountRoot stratisAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("StratisAccount", KnownCoinTypes.Stratis); TransactionOutputData transaction1 = CreateTransaction(new uint256(1), new Money(15000), 1); TransactionOutputData transaction2 = CreateTransaction(new uint256(2), new Money(91209), 1); transaction1.OutPoint = new OutPoint(new uint256(1), 1); transaction1.Address = stratisAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Address; wallet.walletStore.InsertOrUpdate(transaction1); transaction2.OutPoint = new OutPoint(new uint256(2), 1); transaction2.Address = stratisAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Address; wallet.walletStore.InsertOrUpdate(transaction2); wallet.AccountsRoot.Add(stratisAccountRoot); List <TransactionOutputData> result = wallet.GetAllTransactions().ToList(); Assert.Equal(2, result.Count); Assert.Contains(transaction1.OutPoint, result.Select(x => x.OutPoint)); Assert.Contains(transaction2.OutPoint, result.Select(x => x.OutPoint)); }
public void ChangeBooking_BookingDoesNotExist_InvalidOperationException() { //Arrange var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2"); var bookingId = BookingId.FromGuid(bookingIdGuid); var payment = Payment.FromDecimal(100.00m, "EUR"); var bookingDate = BookingDate.FromString("2020-09-26"); var description = Description.FromString("My payment"); var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec"); var account = AccountRoot.Create( AccountId.FromGuid(accountIdGuid), UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")), Period.FromMonth(2020, 9), CurrencyCode.FromString("EUR")); account.BookPayment(bookingId, payment, bookingDate, description); var nonExistingBookingId = BookingId.FromGuid(Guid.Parse("58bead84-e4d6-481b-9c7a-b52a36a98c3f")); var changedPayment = Payment.FromDecimal(200.00m, "EUR"); var changedBookingDate = BookingDate.FromString("2020-09-01"); var changedDescription = Description.FromString("My payment changed"); //Act & Assert Assert.Throws <InvalidOperationException>(() => account.ChangeBooking(nonExistingBookingId, changedPayment, changedBookingDate, changedDescription)); }
public void ChangeBooking_BookingWithDifferentCurrency_PaymentNotSameCurrencyAsAccountException() { //Arrange var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2"); var bookingId = BookingId.FromGuid(bookingIdGuid); var payment = Payment.FromDecimal(100.00m, "EUR"); var bookingDate = BookingDate.FromString("2020-09-26"); var description = Description.FromString("My payment"); var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec"); var account = AccountRoot.Create( AccountId.FromGuid(accountIdGuid), UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")), Period.FromMonth(2020, 9), CurrencyCode.FromString("EUR")); account.BookPayment(bookingId, payment, bookingDate, description); var changedPayment = Payment.FromDecimal(200.00m, "USD"); var changedBookingDate = BookingDate.FromString("2020-09-01"); var changedDescription = Description.FromString("My payment changed"); //Act & Assert Assert.Throws <PaymentNotSameCurrencyAsAccountException>(() => account.ChangeBooking(bookingId, changedPayment, changedBookingDate, changedDescription)); }
public bool Execute(AccountRoot account, List <MappingFields> mapping) { if (base.Execute(account)) { return(SendRequestSave(account, mapping.Where(w => FilterEntity(w.Entity)).ToList(), GetResponse)); } return(false); }
public void GetFirstUnusedAccountWithoutAccountsReturnsNull() { AccountRoot accountRoot = CreateAccountRoot(KnownCoinTypes.Stratis); HdAccount result = accountRoot.GetFirstUnusedAccount(); Assert.Null(result); }
public void GetFirstUnusedAccountWithoutAccountsReturnsNull() { AccountRoot accountRoot = CreateAccountRoot(KnownCoinTypes.Stratis); WalletMemoryStore store = new WalletMemoryStore(); IHdAccount result = accountRoot.GetFirstUnusedAccount(store); Assert.Null(result); }
public void GetAccountByNameWithMatchingNameReturnsAccount() { AccountRoot accountRoot = CreateAccountRootWithHdAccountHavingAddresses("Test", KnownCoinTypes.Stratis); HdAccount result = accountRoot.GetAccountByName("Test"); Assert.NotNull(result); Assert.Equal("Test", result.Name); }
public static AccountRoot CreateAccountRoot(CoinType coinType) { var accountRoot = new AccountRoot((Wallet)null) { CoinType = coinType }; accountRoot.Accounts = new WalletAccounts(accountRoot); return(accountRoot); }
public void GetAllPubKeysByCoinTypeWithoutMatchingCoinTypeReturnsEmptyList() { var wallet = new Wallet(); AccountRoot bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin); wallet.AccountsRoot.Add(bitcoinAccountRoot); List <Script> result = wallet.GetAllPubKeysByCoinType(CoinType.Stratis).ToList(); Assert.Empty(result); }
public string GetIdAccount(Authentication value, string id) { AccountRoot account = new AccountRoot { Authentication = value }; if (SendRequestGetRecord(account, id, LoadResponseAccount)) { return(account.GetId()); } return(string.Empty); }
public void GetAllPubKeysReturnsPubkeysFromWallet() { var wallet = new Types.Wallet(); AccountRoot stratisAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("StratisAccount", KnownCoinTypes.Stratis); wallet.AccountsRoot.Add(stratisAccountRoot); List <Script> result = wallet.GetAllPubKeys().ToList(); Assert.Equal(2, result.Count); Assert.Equal(stratisAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).ScriptPubKey, result[0]); Assert.Equal(stratisAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).ScriptPubKey, result[1]); }
private static StObject LedgerFormatted(StObject source, LedgerEntryType ledgerEntryType) { StObject constructed = null; if (ledgerEntryType == Enums.LedgerEntryType.Offer) { constructed = new Offer(); } else if (ledgerEntryType == Enums.LedgerEntryType.RippleState) { constructed = new RippleState(); } else if (ledgerEntryType == Enums.LedgerEntryType.AccountRoot) { constructed = new AccountRoot(); } else if (ledgerEntryType == Enums.LedgerEntryType.Invalid) { } else if (ledgerEntryType == Enums.LedgerEntryType.DirectoryNode) { constructed = new DirectoryNode(); } else if (ledgerEntryType == Enums.LedgerEntryType.GeneratorMap) { } else if (ledgerEntryType == Enums.LedgerEntryType.Nickname) { } else if (ledgerEntryType == Enums.LedgerEntryType.Contract) { } else if (ledgerEntryType == Enums.LedgerEntryType.LedgerHashes) { } else if (ledgerEntryType == Enums.LedgerEntryType.EnabledFeatures) { } else if (ledgerEntryType == Enums.LedgerEntryType.FeeSettings) { } if (constructed == null) { constructed = new LedgerEntry(ledgerEntryType); } constructed.fields = source.fields; return(constructed); }
private AccountRoot GetAccount(ScheduleRoot value) { AccountRoot company = new AccountRoot { Authentication = value.Authentication, MappingFields = value.MappingFields.Where(w => FilterEntity(w.Entity)).ToList() }; string accountSite = GetFieldValue(value, "City", ZohoLead.Filter) + " / " + GetFieldValue(value, "State", ZohoLead.Filter) + " - " + GetFieldValue(value, "Country", ZohoLead.Filter); company.MappingFields.Add(new MappingFields { Entity = ENTITY, Field = "Account Site", Value = accountSite }); return(company); }
public void populateUIWithUserInfo() { var client = new RestClient("https://api.envato.com/v1/market/private/user/account.json"); var request = new RestRequest(Method.POST); request.AddHeader("Authorization", "Bearer " + envato.access_token); IRestResponse newResponse = client.Execute(request); account = JsonConvert.DeserializeObject <AccountRoot>(newResponse.Content); // Populate the UI with User Info e.g. username / icon // UI_USERNAME.Text = "Welcome back, " + account.account.firstname + "."; UI_IMG.ImageLocation = account.account.image; UI_BALANCE.Text = "Balance: £" + account.account.balance; label1.Text = "Earnt: £" + account.account.available_earnings; }
public static AccountRoot CreateAccountRootWithHdAccountHavingAddresses(Wallet wallet, string accountName, CoinType coinType) { var root = new AccountRoot(wallet) { CoinType = coinType }; var account = new HdAccount(root.Accounts) { Name = accountName }; account.ExternalAddresses.Add(CreateAddress(false)); account.InternalAddresses.Add(CreateAddress(true)); return(root); }
public void ChangeBooking_ValidParams_BookingAddedToAccount() { //Arrange var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2"); var bookingId = BookingId.FromGuid(bookingIdGuid); var payment = Payment.FromDecimal(100.00m, "EUR"); var bookingDate = BookingDate.FromString("2020-09-26"); var description = Description.FromString("My payment"); var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec"); var account = AccountRoot.Create( AccountId.FromGuid(accountIdGuid), UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")), Period.FromMonth(2020, 9), CurrencyCode.FromString("EUR")); account.BookPayment(bookingId, payment, bookingDate, description); var changedPayment = Payment.FromDecimal(200.00m, "EUR"); var changedBookingDate = BookingDate.FromString("2020-09-20"); var changedDescription = Description.FromString("My payment changed"); //Act account.ChangeBooking(bookingId, changedPayment, changedBookingDate, changedDescription); //Assert Assert.IsNotNull(account.Bookings); Assert.IsNotNull(account.Bookings[0]); var booking = account.Bookings[0]; Assert.AreEqual(bookingIdGuid, booking.Id.Value); Assert.AreEqual(200.00m, booking.Payment.Amount); Assert.AreEqual("EUR", booking.Payment.CurrencyCode); Assert.AreEqual(DateTime.Parse("2020-09-20"), booking.Date.Value); Assert.AreEqual("My payment changed", booking.Description.Value); Assert.AreEqual(3, account.GetChanges().Count); Assert.AreEqual(typeof(V1.BookingChanged), account.GetChanges()[2].GetType()); var @event = account.GetChanges()[2] as V1.BookingChanged; Assert.AreEqual(accountIdGuid, @event.AccountId); Assert.AreEqual(bookingIdGuid, @event.BookingId); Assert.AreEqual(200.00m, @event.Amount); Assert.AreEqual("EUR", @event.CurrencyCode); Assert.AreEqual(DateTime.Parse("2020-09-20"), @event.Date); Assert.AreEqual("My payment changed", @event.Description); }
public void Close_AccountAlreadyClosed_InvalidOperationException() { //Arrange var idGuid = Guid.Parse("051f8160-ce43-4ac0-b8c2-09707c2bcda3"); var id = AccountId.FromGuid(idGuid); var ownerGuid = Guid.Parse("4bc0c0e9-7181-45e4-934d-e91c0e7bbd75"); var ownerId = UserId.FromGuid(ownerGuid); var period = Period.FromMonth(2020, 9); var currency = CurrencyCode.FromString("EUR"); var account = AccountRoot.Create(id, ownerId, period, currency); account.Close(); //Act & Assert Assert.Throws <InvalidOperationException>(() => account.Close()); }
public void GetAllTransactionsByCoinTypeWithoutMatchingAccountReturnsEmptyList() { var wallet = new Wallet(); AccountRoot bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin); TransactionData transaction1 = CreateTransaction(new uint256(3), new Money(32145), 1); TransactionData transaction2 = CreateTransaction(new uint256(4), new Money(654789), 1); bitcoinAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction1); bitcoinAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction2); wallet.AccountsRoot.Add(bitcoinAccountRoot); List <TransactionData> result = wallet.GetAllTransactionsByCoinType(CoinType.Stratis).ToList(); Assert.Empty(result); }
public async Task Save(AccountRoot aggregateRoot) { var streamName = $"account-{aggregateRoot.Id}"; var eventData = aggregateRoot.GetChanges().Select(x => new EventData( Guid.NewGuid(), streamName, true, Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(x, Formatting.None, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All })), null) ); await connection.AppendToStreamAsync(streamName, ExpectedVersion.Any, eventData); }
private bool GetIdByRecord(string response, object value) { try { AccountRoot account = (AccountRoot)value; var responseObject = JsonConvert.DeserializeObject(response, typeof(Models.Zoho.GetRecord.RootObject)); if (((Models.Zoho.GetRecord.RootObject)responseObject).response.result.Potentials.row.FL.Exists(e => e.val.Equals("ACCOUNTID"))) { account.Id = ((Models.Zoho.GetRecord.RootObject)responseObject).response.result.Potentials.row.FL .Where(e => e.val.Equals("ACCOUNTID")).First().content; return(true); } } catch { } return(false); }
public void BookPayment_PaymentDateOutsidePeriod_InvalidEntityStateException() { //Arrange var bookingIdGuid = Guid.Parse("b9c18f4d-8f11-408d-be7c-c7f022abefb2"); var bookingId = BookingId.FromGuid(bookingIdGuid); var payment = Payment.FromDecimal(100.00m, "EUR"); var bookingDate = BookingDate.FromString("2020-01-01"); var description = Description.FromString("My payment"); var accountIdGuid = Guid.Parse("9ccf4aa8-cd1e-4044-a183-464c8a8730ec"); var account = AccountRoot.Create( AccountId.FromGuid(accountIdGuid), UserId.FromGuid(Guid.Parse("13f172e2-7189-4506-b232-894bafcd4449")), Period.FromMonth(2020, 9), CurrencyCode.FromString("EUR")); //Act & Assert Assert.Throws <InvalidEntityState>(() => account.BookPayment(bookingId, payment, bookingDate, description)); }
public void GetAllPubKeysByCoinTypeReturnsPubkeysFromWalletByCoinType() { var wallet = new Wallet(); AccountRoot stratisAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("StratisAccount", CoinType.Stratis); AccountRoot bitcoinAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("BitcoinAccount", CoinType.Bitcoin); AccountRoot stratisAccountRoot2 = CreateAccountRootWithHdAccountHavingAddresses("StratisAccount2", CoinType.Stratis); wallet.AccountsRoot.Add(stratisAccountRoot); wallet.AccountsRoot.Add(bitcoinAccountRoot); wallet.AccountsRoot.Add(stratisAccountRoot2); List <Script> result = wallet.GetAllPubKeysByCoinType(CoinType.Stratis).ToList(); Assert.Equal(4, result.Count); Assert.Equal(stratisAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).ScriptPubKey, result[0]); Assert.Equal(stratisAccountRoot2.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).ScriptPubKey, result[1]); Assert.Equal(stratisAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).ScriptPubKey, result[2]); Assert.Equal(stratisAccountRoot2.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).ScriptPubKey, result[3]); }
public void GetAllTransactionsReturnsTransactionsFromWallet() { var wallet = new Wallet(); AccountRoot stratisAccountRoot = CreateAccountRootWithHdAccountHavingAddresses("StratisAccount", CoinType.Stratis); TransactionData transaction1 = CreateTransaction(new uint256(1), new Money(15000), 1); TransactionData transaction2 = CreateTransaction(new uint256(2), new Money(91209), 1); stratisAccountRoot.Accounts.ElementAt(0).InternalAddresses.ElementAt(0).Transactions.Add(transaction1); stratisAccountRoot.Accounts.ElementAt(0).ExternalAddresses.ElementAt(0).Transactions.Add(transaction2); wallet.AccountsRoot.Add(stratisAccountRoot); List <TransactionData> result = wallet.GetAllTransactions().ToList(); Assert.Equal(2, result.Count); Assert.Equal(transaction1, result[1]); Assert.Equal(transaction2, result[0]); }
public void Close_StateClosedAmountSumOfBookings() { //Arrange var idGuid = Guid.Parse("051f8160-ce43-4ac0-b8c2-09707c2bcda3"); var id = AccountId.FromGuid(idGuid); var ownerGuid = Guid.Parse("4bc0c0e9-7181-45e4-934d-e91c0e7bbd75"); var ownerId = UserId.FromGuid(ownerGuid); var period = Period.FromMonth(2020, 9); var currency = CurrencyCode.FromString("EUR"); var account = AccountRoot.Create(id, ownerId, period, currency); account.BookPayment( BookingId.FromGuid(Guid.Parse("9d8d8a72-59a0-4a1b-8b86-94960df74586")), Payment.FromDecimal(10.00m, "EUR"), BookingDate.FromString("2020-09-01"), Description.FromString("Booking1")); account.BookPayment( BookingId.FromGuid(Guid.Parse("cbf7333e-3a7a-4bf9-ac85-4bdb22f7afb0")), Payment.FromDecimal(5.10m, "EUR"), BookingDate.FromString("2020-09-02"), Description.FromString("Booking2")); account.BookPayment( BookingId.FromGuid(Guid.Parse("07a94bd6-ae33-4765-9d1d-5257297e7ed0")), Payment.FromDecimal(8.43m, "EUR"), BookingDate.FromString("2020-09-03"), Description.FromString("Booking3")); //Act account.Close(); //Assert Assert.AreEqual(AccountState.AccountStateEnum.Closed, account.State.Value); Assert.IsTrue(account.GetChanges().Last() is V1.AccountClosed); var @event = account.GetChanges().Last() as V1.AccountClosed; Assert.AreEqual(idGuid, @event.AccountId); }
/// <summary> /// 验证用户名密码(返回 0:认证失败,1:管理员[库中写死],2:普通用户) /// </summary> public static int Logon(string acc, string pwd) { //首先查询数据库中账户acc的用户权限,如果存在查询密码对不对,如果不存在返回错 if (acc == "admin" && pwd == "admin") { return(3); } string file = Path.Combine(Utils.GetUserPath(), "userInfo"); if (File.Exists(file)) { AccountRoot ar = Utils.FromXMLFile <AccountRoot>(file); foreach (var item in ar.Users) { if (acc == item.UserName && pwd == item.PassWord) { return(item.Level); } } } return(0); }
public bool Execute(ScheduleRoot schedule, List <MappingFields> mapping) { if (base.Execute(schedule)) { AccountRoot account = GetAccount(schedule); if (!string.IsNullOrEmpty(schedule.Lead.Id)) { SendRequestGetRecord(account, ZohoPotential.ENTITY_NAME, schedule.Lead.Id, GetIdByRecord); } if (Execute(account, account.MappingFields.Where(w => FilterEntity(w.Entity)).ToList())) { schedule.Account = new Account { Id = account.Id }; account.MappingFields.Where(w => ZohoEvent.Filter(w.Entity)).ToList().ForEach(f => { schedule.MappingFields.Add(f); }); account.MappingFields.Where(w => ZohoPotential.Filter(w.Entity)).ToList().ForEach(f => { schedule.MappingFields.Add(f); }); return(true); } } return(false); }