Beispiel #1
0
        public override Task <Empty> Setup(SetupRequest request, Grpc.Core.ServerCallContext context)
        {
            var payments = request.Payments.Select(p => mapper.Map <Repository.Payment>(p));

            paymentsRepository.Setup(payments);
            return(Task.FromResult(new Empty()));
        }
Beispiel #2
0
        public override Task <Empty> Setup(SetupRequest request, ServerCallContext context)
        {
            var loans = request.Loans.Select(l => mapper.Map <Repository.Loan>(l));

            loansRepository.Setup(loans);
            return(Task.FromResult(new Empty()));
        }
Beispiel #3
0
 public override Task<Empty> Setup(SetupRequest request, ServerCallContext context)
 {
     var cards = request.Cards.Select(c => mapper.Map<Repository.Card>(c));
     var blocks = request.Blocks.Select(b => mapper.Map<Repository.Block>(b));
     cardsRepository.Setup(cards, blocks);
     return Task.FromResult(new Empty());
 }
        public override Task <Empty> SetupAppend(SetupRequest request, ServerCallContext context)
        {
            var transactions = request.Transactions.Select(t => mapper.Map <Repository.Transaction>(t));

            transactionsRepository.SetupAppend(transactions);
            return(Task.FromResult(new Empty()));
        }
Beispiel #5
0
        /// <summary>
        /// Send a list of <see cref="User.Name"/> To all palyers in that session
        /// </summary>
        /// <param name="listOfUsernames"></param>
        private void SendPlayerList(List <string> listOfUsernames)
        {
            Thread.Sleep(1000);
            string s;

            byte[]        buffer;
            NetworkStream stream;

            SetupRequest setupRequest = new SetupRequest();

            setupRequest.RequestType = 4;
            setupRequest.Players     = listOfUsernames;

            s      = JsonConvert.SerializeObject(setupRequest, Formatting.Indented);
            buffer = Encoding.UTF8.GetBytes(s);

            lock (_lock)
            {
                foreach (User player in ListOfUsers)
                {
                    stream = player.Client.GetStream();
                    stream.Write(buffer, 0, buffer.Length);
                }
            }
        }
Beispiel #6
0
        public override Task <Empty> SetupAppend(SetupRequest request, ServerCallContext context)
        {
            var accounts = request.Accounts.Select(a => mapper.Map <Repository.Account>(a));

            accountsRepository.SetupAppend(accounts);
            return(Task.FromResult(new Empty()));
        }
Beispiel #7
0
        private async Task SeedContentDataAsync(SetupRequest setupRequest)
        {
            // Insert User Photo Types
            foreach (var userPhotoType in setupRequest.UserPhotoTypes)
            {
                await _caminoDataConnection.InsertAsync(new UserPhotoType()
                {
                    Name        = userPhotoType.Name,
                    Description = userPhotoType.Description
                });
            }

            // Insert Shortcuts
            foreach (var shortcut in setupRequest.Shortcuts)
            {
                await _caminoDataConnection.InsertAsync(new Shortcut()
                {
                    Name        = shortcut.Name,
                    Description = shortcut.Description,
                    Icon        = shortcut.Icon,
                    TypeId      = shortcut.TypeId,
                    Url         = shortcut.Url
                });
            }
        }
Beispiel #8
0
        public async Task <IActionResult> Setup([FromBody] SetupRequest input)
        {
            input.AdminExternalUserId = this.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier).Value;
            await _administrationService.Setup(input);

            return(Ok());
        }
        public override Task <Empty> Setup(SetupRequest request, ServerCallContext context)
        {
            var users   = request.Users.Select(u => new Repository.User(u.Id, u.Login, u.Password));
            var inboxes = request.Messages.GroupBy(m => m.UserId)
                          .Select(g => new Inbox(g.Key, g.Select(g => g.Content).ToArray()));

            usersRepository.Setup(users, inboxes);
            return(Task.FromResult(new Empty()));
        }
Beispiel #10
0
        public override Task <Empty> SetupAppend(SetupRequest request, ServerCallContext context)
        {
            var accounts = request.Accounts.Select(a => mapper.Map <Models.Account>(a));

            accountsRepository.SetupAppend(accounts);
            projectionChannel.Publish(null, new DataProjection <Models.Account, string> {
                Upsert = accounts.ToArray()
            });
            return(Task.FromResult(new Empty()));
        }
Beispiel #11
0
        public override Task <Empty> SetupAppend(SetupRequest request, ServerCallContext context)
        {
            var transactions = request.Transactions.Select(t => mapper.Map <Models.Transaction>(t));

            transactionsRepository.SetupAppend(transactions);
            projectionChannel.Publish(null, new DataProjection <Models.Transaction, string> {
                Upsert = transactions.ToArray()
            });
            return(Task.FromResult(new Empty()));
        }
Beispiel #12
0
        public override Task <Empty> SetupAppend(SetupRequest request, Grpc.Core.ServerCallContext context)
        {
            var payments = request.Payments.Select(p => mapper.Map <Models.Payment>(p));

            paymentsRepository.SetupAppend(payments);
            projectionChannel.Publish(null, new DataProjection <Models.Payment, string> {
                Upsert = payments.ToArray()
            });
            return(Task.FromResult(new Empty()));
        }
Beispiel #13
0
        public override Task <Empty> Setup(SetupRequest request, ServerCallContext context)
        {
            var loans = request.Loans.Select(l => mapper.Map <Models.Loan>(l));

            loansRepository.Setup(loans);
            projectionChannel.Publish(null, new DataProjection <Models.Loan, string> {
                Upsert = loans.ToArray()
            });
            return(Task.FromResult(new Empty()));
        }
Beispiel #14
0
        public async Task <IActionResult> SetServerAddress([FromBody] SetupRequest setupRequest)
        {
            string result = await xServer.SetupServer(setupRequest);

            var setupResult = new SetupResponse()
            {
                SignAddress = result
            };

            return(Json(setupResult));
        }
Beispiel #15
0
        public bool AddServerToSetup(SetupRequest setupRequest, string profileName)
        {
            bool result         = false;
            var  profileNameSet = database.dataStore.SetDictionaryValue("ProfileName", profileName);
            var  signAddressSet = database.dataStore.SetDictionaryValue("SignAddress", setupRequest.SignAddress);
            var  dateAddedSet   = database.dataStore.SetDictionaryValue("DateAdded", DateTime.UtcNow);

            if (profileNameSet && signAddressSet && dateAddedSet)
            {
                result = true;
            }
            return(result);
        }
        public override Task <Empty> Setup(SetupRequest request, ServerCallContext context)
        {
            var cards  = request.Cards.Select(c => mapper.Map <Models.Card>(c));
            var blocks = request.Blocks.Select(b => mapper.Map <Models.Block>(b));

            cardsRepository.Setup(cards, blocks);

            var upsert = cards.Select(c => new CardsUpsert {
                Card = c
            });

            upsert = upsert.Concat(blocks.Select(b => new CardsUpsert {
                Block = b
            }));
            projectionChannel.Publish(null, new DataProjection <CardsUpsert, string> {
                Upsert = upsert.ToArray()
            });
            return(Task.FromResult(new Empty()));
        }
Beispiel #17
0
        public async Task <ActionResult> Index(SetupRequest req)
        {
            //TODO: allow user to requets read scopes only (no app creation)
            await _authenticator.ChallengeAsync(
                Request.HttpContext,
                "OpenIdConnect",
                new AuthenticationProperties(
                    new Dictionary <string, string>()
            {
                { ".redirect", $"/home/setup?readOnly={req.ValidateOnly.ToString()}&fb={req.CreateDummyFacebook}" }
            },
                    new Dictionary <string, object>()
            {
                { "tenant", req.DomainName },
                { "readOnly", req.ValidateOnly }
                //{"admin_consent", true }
            }));

            return(View());
        }
        public async Task VerifySetupAsync(
            VerifySetupResponse expectedResult,
            Mock <IPlatformExtension> mockExtension,
            SetupRequest setupRequest)
        {
            // ARRANGE

            var verifySetup = new Mock <VerifySetupService>();

            verifySetup
            .Setup(vs => vs.NewPlatformExtension())
            .Returns(mockExtension.Object);

            // ACT

            var actualResult = await verifySetup.Object.VerifySetupAsync(setupRequest);

            // ASSERT

            actualResult.Should().BeEquivalentTo(expectedResult);
        }
Beispiel #19
0
        public async Task <ActionResult> Index(SetupRequest req)
        {
            //TODO: allow user to requets read scopes only (no app creation)
            await _authenticator.ChallengeAsync(
                Request.HttpContext,
                "AzureADOpenID",
                new AuthenticationProperties(
                    new Dictionary <string, string>()
            {
                { ".redirect", "/home/setup?fb=" + req.RemoveFacebookReferences.ToString() + "&domainName=" + req.DomainName.ToString() + "&deployPhoneSignInJourneys=" + req.InitialisePhoneSignInJourneys.ToString() }
            },
                    new Dictionary <string, object>()
            {
                { "tenant", req.DomainName },
                { "RemoveFacebook", req.RemoveFacebookReferences },
                { "deployPhoneSignInJourneys", req.InitialisePhoneSignInJourneys }
                //{"admin_consent", true }
            }));

            return(View());
        }
Beispiel #20
0
        public async Task Setup(SetupRequest input)
        {
            // check user and permissions
            Session.EnsureAuthenticated();

            // validation

            // save settings
            var appSettingService = this.GetService <AppSettingService>();
            var settings          = new Dictionary <string, string>
            {
                { AppSettingService.KEY_Locale, input.Locale },
                { AppSettingService.KEY_CompanyName, input.CompanyName }
            };

            appSettingService.BatchSet(settings);

            //// assign owner role to current user
            //var _authService = GetService<UtilityServices.AuthService>();
            //await _authService.AssignRolesToUser(input.AdminExternalUserId,
            //    new string[] { "deploca:knowledgebase:owner" });

            // create the user
            var externalUser = await _authService.GetUserInfo(input.AdminExternalUserId);

            var appUserId = GetService <AppUserService>()
                            .Create(new Models.AppUser.AppUserCreate
            {
                ExternalId = externalUser.UserId,
                Picture    = externalUser.Picture,
                Name       = externalUser.FullName,
                Email      = externalUser.Email,
                IsOwner    = true
            });

            Session.SetAuthenticatedUserId(appUserId);

            // seed data
            addSeedData(input.Locale);
        }
Beispiel #21
0
        public async Task SeedDataAsync(SetupRequest setupRequest)
        {
            try
            {
                var isSucceed = await SeedIdentityDataAsync(setupRequest);

                if (isSucceed)
                {
                    await SeedContentDataAsync(setupRequest);

                    await _caminoDataConnection.CommitTransactionAsync();
                }
                else
                {
                    await _caminoDataConnection.RollbackTransactionAsync();
                }
            }
            catch (Exception ex)
            {
                await _caminoDataConnection.RollbackTransactionAsync();

                throw new LinqToDBException(ex);
            }
        }
 public async Task SeedDataAsync(SetupRequest setupRequest)
 {
     await _dataSeedRepository.SeedDataAsync(setupRequest);
 }
Beispiel #23
0
 public async Task <Registration> Setup(SetupRequest setup)
 {
     return(await Put <SetupRequest, Registration>("/setup", new string[0], setup));
 }
Beispiel #24
0
        /// <summary>
        /// The transaction string that have provided by BBS UI Interface.
        /// To start off a payment operation, a setup-call needs to be made
        ///  This is always the first operation made for a transaction.
        /// </summary>
        /// <param name="cart">The shopping cart.</param>
        /// <param name="thisCustomer">The customer.</param>
        /// <param name="totalAmount">The total amount.</param>
        /// <returns> The transaction string </returns>
        public string GetTransactionString(ShoppingCart cart, Customer thisCustomer, decimal totalAmount)
        {
            // Merchant account
            string token      = AppLogic.AppConfig("NETAXEPT.Merchant_Token");
            string merchantID = AppLogic.AppConfig("NETAXEPT.Merchant_Id");

            TokenService service = new TokenService();
            SetupRequest request = new SetupRequest();

            string responseCode = string.Empty;
            string responseText = string.Empty;

            // the server url
            string url = string.Empty;

            if (AppLogic.AppConfigBool("UseLiveTransactions"))
            {
                url = AppLogic.AppConfig("NETAXEPT.Live_Server"); // use live
            }
            else
            {
                url = AppLogic.AppConfig("NETAXEPT.Test_Server"); // use test
            }

            service.Url = url;

            string orderNumber = AppLogic.GetNextOrderNumber().ToString();

            // setup request from parameters
            // Send order details to BBS

            // Set total amount that customer has to pay for the order. Do not use a seperator. Instead
            // use: 123,50 Norwegian kroner = "12350"
            request.Amount = RemoveSeperatorFromAmount(totalAmount);

            // Set currency for total amount
            request.CurrencyCode = thisCustomer.CurrencySetting.ToUpperInvariant();

            // Set order id (Ordrenummer). This is the store's order id.
            request.OrderNumber = orderNumber;

            // Set the order description. You have up to 4096 characters available.
            request.OrderDescription = cart.OrderNotes;

            // Set customers e-mail & phone (optional)
            request.CustomerEmail       = thisCustomer.EMail;
            request.CustomerPhoneNumber = thisCustomer.PrimaryBillingAddress.Phone;

            // Set the description of this transaction. (optional)
            request.Description = string.Empty;

            // Language in BBS hosted UI
            request.Language = this.ReplaceLocalle(thisCustomer.LocaleSetting);

            // After payment information at BBS, customer will be redirected to:
            request.RedirectUrl = AppLogic.GetStoreHTTPLocation(AppLogic.AppConfigBool("UseSSL")) + AppLogic.AppConfig("NETAXEPT.MerchantSettings.RedirectUrl");

            // Set type of service: B = BBS hosted, M = Merchant hosted, C = Callcenter
            request.ServiceType = "B";

            // Set a unique id (up to 32 characters) for the transaction.
            // This ID must be saved for later use when you want to "CAPTURE" or "CREDIT" the transaction.
            request.TransactionId = Guid.NewGuid().ToString().Replace("-", string.Empty);

            // Set the session ID. This is typically used to recognize the returning customer if there is no cookie in the users browser. (optional)
            request.SessionId = thisCustomer.CustomerGUID.Replace("-", string.Empty);

            // this will hold the hidden input element
            // which we'll inject into the form
            // required to postback to nextApi
            string ticket = string.Empty;

            try
            {
                ticket = service.Setup(token, merchantID, request);
            }
            catch (Exception ex)
            {
                SoapException se = ex as SoapException;

                if (se != null)
                {
                    GetStatusCodeMessage(se, out responseText, out responseCode);
                }

                string sql = "INSERT INTO FailedTransaction(CustomerID,OrderNumber,IPAddress,OrderDate,PaymentGateway,PaymentMethod,TransactionCommand,TransactionResult) values(" + thisCustomer.CustomerID + "," + orderNumber + "," + DB.SQuote(cart.ThisCustomer.LastIPAddress) + ",getdate()," + DB.SQuote(Gateway.ro_GWNETAXEPT) + "," + DB.SQuote(AppLogic.ro_PMCreditCard) + "," + DB.SQuote("N/A") + "," + DB.SQuote(responseText) + ")";
                DB.ExecuteSQL(sql);
                return(AppLogic.GetString("toc.aspx.6", thisCustomer.SkinID, thisCustomer.LocaleSetting) + ex.Message);
            }

            // Create a session that will handle the order number
            thisCustomer.ThisCustomerSession["Nextaxept_OrderNumber"] = orderNumber;

            return(ticket);
        }
Beispiel #25
0
        void Loop()
        {
            SerialPort serialPort          = new SerialPort();
            bool       serialPortAvailable = false;

            while (run)
            {
                lock (setupRequestsLock) {
                    while (setupRequests.Count > 0)
                    {
                        serialPort.Dispose();
                        SetupRequest request = setupRequests.Dequeue();
                        if (request == null)
                        {
                            serialPortAvailable = false;
                        }
                        else
                        {
                            serialPort = request.Port;
                            string message = "";
                            try {
                                serialPort.Open();
                            } catch (Exception e) {
                                message = e.Message;
                            }
                            if (serialPort.IsOpen)
                            {
                                serialPort.DtrEnable   = true;
                                serialPortAvailable    = true;
                                serialPort.ReadTimeout = 1;
                            }
                            else
                            {
                                serialPort.Dispose();
                                serialPortAvailable = false;
                            }
                            lock (setupCallbacksLock) {
                                if (request.SetupCallback != null)
                                {
                                    setupCallbacks.Enqueue(() => request.SetupCallback(serialPortAvailable, message));
                                }
                            }
                        }
                    }
                }

                if (serialPortAvailable)
                {
                    bool  inputAvailable;
                    sbyte input;
                    // Alternative patterns that will fail:
                    //   BytesToRead may return larger values than actually available consequently causing a timeout exception in Read(buffer, 0, bytesToRead).
                    //   DataReceived may not be invoked at all in NET 2.0, and if it ever did, it is documented that may not be raised for all bytes received.
                    try {
                        input = (sbyte)serialPort.ReadByte();
                        Debug.Log(input);
                        inputAvailable = true;
                    } catch (TimeoutException) {
                        // Timeout is expected when no input is present.
                        input          = 0;
                        inputAvailable = false;
                    } catch {
                        input          = 0;
                        inputAvailable = false;
                    }

                    if (inputAvailable)
                    {
                        lock (inputsLock)
                            inputs.Enqueue(input);
                    }

                    // Write and remove output data.
                    byte[] outputArray;
                    lock (outputsLock)
                        outputArray = outputs.ToArray();

                    bool outputAvailable = true;
                    if (outputArray.Length > 0)
                    {
                        try {
                            serialPort.Write(outputArray, 0, outputArray.Length);
                            lock (outputsLock)
                                outputs.Clear();
                        } catch {
                            outputAvailable = false;
                        }
                    }

                    // Take a breath in the absence of both inputs and outputs.
                    if (!inputAvailable && !outputAvailable)
                    {
                        Thread.Sleep(1);
                    }
                }
                else
                {
                    Thread.Sleep(1);
                }
            }
            serialPort.Dispose();
        }
Beispiel #26
0
        private async Task <bool> SeedIdentityDataAsync(SetupRequest setupRequest)
        {
            // Insert user statuses
            int activedStatusId = 0;

            foreach (var statusRequest in setupRequest.Statuses)
            {
                var status = new Status
                {
                    Name        = statusRequest.Name,
                    Description = statusRequest.Description
                };

                if (status.Name == UserStatus.Actived.ToString())
                {
                    activedStatusId = await _caminoDataConnection.InsertWithInt32IdentityAsync(status);
                }
                else
                {
                    await _caminoDataConnection.InsertAsync(status);
                }
            }

            if (activedStatusId == 0)
            {
                return(false);
            }

            // Insert genders
            foreach (var gender in setupRequest.Genders)
            {
                await _caminoDataConnection.InsertAsync(new Gender()
                {
                    Name = gender.Name
                });
            }

            // Insert countries
            foreach (var country in setupRequest.Countries)
            {
                await _caminoDataConnection.InsertAsync(new Country()
                {
                    Name = country.Name,
                    Code = country.Code
                });
            }

            // Insert user
            var userRequest = setupRequest.InitualUser;
            var user        = new User
            {
                CreatedDate      = DateTime.UtcNow,
                UpdatedDate      = DateTime.UtcNow,
                Email            = userRequest.Email,
                Firstname        = userRequest.Firstname,
                Lastname         = userRequest.Lastname,
                PasswordHash     = userRequest.PasswordHash,
                SecurityStamp    = userRequest.SecurityStamp,
                StatusId         = activedStatusId,
                UserName         = userRequest.UserName,
                DisplayName      = userRequest.DisplayName,
                IsEmailConfirmed = true
            };

            var userId = await _caminoDataConnection.InsertWithInt64IdentityAsync(user);

            if (userId > 0)
            {
                await _caminoDataConnection.InsertWithInt64IdentityAsync(new UserInfo
                {
                    BirthDate   = userRequest.BirthDate,
                    Description = userRequest.Description,
                    GenderId    = userRequest.GenderId,
                    Id          = userId
                });

                // Insert roles
                var adminRoleId = 0;
                foreach (var role in setupRequest.Roles)
                {
                    var newRole = new Role()
                    {
                        Name        = role.Name,
                        Description = role.Description,
                        CreatedById = userId,
                        UpdatedById = userId,
                        CreatedDate = DateTime.UtcNow,
                        UpdatedDate = DateTime.UtcNow
                    };

                    if (role.Name == "Admin")
                    {
                        adminRoleId = await _caminoDataConnection.InsertAsync(newRole);
                    }
                    else
                    {
                        await _caminoDataConnection.InsertAsync(newRole);
                    }
                }

                if (adminRoleId > 0)
                {
                    // Insert user role
                    var adminUserRole = new UserRole()
                    {
                        UserId      = userId,
                        GrantedById = userId,
                        GrantedDate = DateTime.UtcNow,
                        IsGranted   = true,
                        RoleId      = adminRoleId
                    };

                    await _caminoDataConnection.InsertAsync(adminUserRole);
                }

                // Insert authorization policies
                foreach (var authorizationPolicy in setupRequest.AuthorizationPolicies)
                {
                    var authorizationPolicyId = await _caminoDataConnection.InsertWithInt64IdentityAsync(new AuthorizationPolicy()
                    {
                        Name        = authorizationPolicy.Name,
                        Description = authorizationPolicy.Description,
                        CreatedById = userId,
                        CreatedDate = DateTime.UtcNow,
                        UpdatedById = userId,
                        UpdatedDate = DateTime.UtcNow
                    });

                    await _caminoDataConnection.InsertAsync(new RoleAuthorizationPolicy()
                    {
                        GrantedById           = userId,
                        GrantedDate           = DateTime.UtcNow,
                        IsGranted             = true,
                        RoleId                = adminRoleId,
                        AuthorizationPolicyId = authorizationPolicyId
                    });

                    await _caminoDataConnection.InsertAsync(new UserAuthorizationPolicy()
                    {
                        GrantedById           = userId,
                        GrantedDate           = DateTime.UtcNow,
                        IsGranted             = true,
                        UserId                = userId,
                        AuthorizationPolicyId = authorizationPolicyId
                    });
                }

                return(true);
            }

            return(false);
        }