Beispiel #1
0
        public void TestAppendUserSyncQueryParameter()
        {
            string url = "http://www.example.com";
            string urlWithQueryParameter = UserSync.AppendUserSyncQueryParameter(url);
            int    separatorIndex        = urlWithQueryParameter.IndexOf("?");
            string queryParameter        = urlWithQueryParameter.Substring(separatorIndex + 1);

            string[] parameters = queryParameter.Split('&');
            string[] keyValue   = parameters[0].Split('=');
            Assert.AreEqual("_k_ntvsync_b", keyValue[0]);
        }
Beispiel #2
0
        public async Task CreateTestContributor()
        {
            var now = DateTime.Now.ToShortDateString() + "_" + DateTime.Now.ToShortTimeString();

            now = now.Replace(':', '-');
            var user = await UserSync.Create("test-user_03.02.2018_13-11", "*****@*****.**", "123456");

            Assert.IsTrue(user.Success);
            Assert.IsNotNull(user.Id);
            Assert.IsNotNull(user.EMail);
            Assert.IsNotNull(user.Username);
        }
Beispiel #3
0
        public async Task Info()
        {
            var testUser = User.GetUser(out var tokenSuccess);

            Assert.IsNotNull(testUser);
            Assert.IsTrue(tokenSuccess);

            var info = await UserSync.Info();

            Assert.AreEqual(info.EMail, testUser.Email);
            Assert.AreEqual(info.Id, testUser.Id);
            Assert.AreEqual(info.Username, testUser.Username);
        }
Beispiel #4
0
        public async Task CreateUser()
        {
            var now = DateTime.Now.ToShortDateString() + "_" + DateTime.Now.ToShortTimeString();

            now = now.Replace(':', '-');
            var user = UserSync.Create("test-user_" + now, "test-user_" + now + "@testmail.testmail", "123456").Result;

            Assert.IsTrue(user.Success);
            Assert.IsNotNull(user.Id);
            Assert.IsNotNull(user.EMail);
            Assert.IsNotNull(user.Username);
            File.WriteAllLines("TestUser\\test-user_" + now + ".txt", new string[] { user.Id.ToString(), user.EMail, user.Username });
        }
Beispiel #5
0
        public async Task LoginEmail()
        {
            var userInfo = User.GetUser();
            var user     = UserSync.LoginEmail(userInfo.Email, "123456").Result;

            Assert.IsTrue(user.Success);
            Assert.IsNotNull(user.Id);
            Assert.IsNotNull(user.EMail);
            Assert.IsNotNull(user.Username);
            Assert.IsNotNull(user.Token);

            Assert.IsTrue(JsonWebToken.Decode(user.Token, out NsslSession payload));

            Assert.AreEqual(payload.Id, userInfo.Id);
            if (!File.Exists("TestUser\\" + userInfo.Username + "_token.txt"))
            {
                File.WriteAllLines("TestUser\\" + userInfo.Username + "_token.txt", new string[] { user.Id.ToString(), user.Token, payload.Expires.ToString() });
            }
        }
Beispiel #6
0
        public async Task <(User user, int listId)> GetUserWithList(bool withToken = true)
        {
            User user;

            if (withToken)
            {
                user = User.GetUser(out var success);
                IsTrue(success, "Token is missing");
            }
            else
            {
                user = User.GetUser();
            }

            var info = await UserSync.Info();

            IsNotNull(info.ListIds, "The User has no lists");

            var list = info.ListIds.FirstOrDefault();

            IsNotNull(list, "The User has no lists");

            return(user, list);
        }
Beispiel #7
0
        private void UserSyncTest()
        {
            var uri = Android.Net.Uri.Parse("https://karte.io");
            var appendingQueryParameterUrl1 = UserSync.AppendUserSyncQueryParameter(uri);

            System.Diagnostics.Debug.WriteLine("AppendingQueryParameterWithURL: " + appendingQueryParameterUrl1);

            var appendingQueryParameterUrl2 = UserSync.AppendUserSyncQueryParameter(uri.ToString());

            System.Diagnostics.Debug.WriteLine("AppendingQueryParameterWithURLString: " + appendingQueryParameterUrl2);

            var webView = new WebView(this);

            webView.Settings.JavaScriptEnabled = true;
            webView.SetWebViewClient(new MyWebViewClient(view =>
            {
                UserSync.SetUserSyncScript(view);
                webView.EvaluateJavascript("(function() { return window.__karte_ntvsync; })();", new ValueCallback((value) =>
                {
                    System.Diagnostics.Debug.WriteLine("WebView UserScripts: " + value);
                }));
            }));
            webView.LoadUrl("https://karte.io");
        }
Beispiel #8
0
        //GET http://localhost:8005/api/sync/users/{reqDate}/{serialNo}
        //GET http://localhost:8005/api/sync/users/2014-11-23/920013c000814
        public IHttpActionResult GetUsers(DateTime reqDate, string serialNo)
        {
            serialNo = serialNo.Trim().ToLower();

            Terminals terminal = TerminalServices.GetTerminalBySerial(serialNo);

            if (terminal == null)
            {
                return(Unauthorized());
            }

            var             users    = UserService.GetAuthUsersByTenantAndDateUpdated(terminal.TenantId, reqDate);
            List <UserSync> newUsers = new List <UserSync>();

            foreach (var usr in users)
            {
                UserSync newUser = new UserSync();
                newUser.UserId = usr.UserId;

                var resourceId = UserService.GetResourceIdByUserId(usr.UserId);
                newUser.IsResource = resourceId > 0;
                newUser.ResourceId = resourceId;

                newUser.Username = usr.UserName;
                newUser.Password = usr.UserPassword;
                newUser.Name     = usr.DisplayName;
                newUser.IsActive = usr.IsActive;

                newUser.IsDeleted   = usr.IsDeleted;
                newUser.DateUpdated = usr.DateUpdated;

                //get parent warehouse to check permissions
                int warehouseId = terminal.WarehouseId;

                var location = _tenantLocationServices.GetActiveTenantLocationById(terminal.WarehouseId);

                if (location.IsMobile == true)
                {
                    warehouseId = location.ParentWarehouseId ?? warehouseId;
                }

                newUser.PurchaseOrderPerm          = _activityServices.PermCheck("Handheld", "PurchaseOrderPerm", usr.UserId, warehouseId);
                newUser.SalesOrderPerm             = _activityServices.PermCheck("Handheld", "SalesOrderPerm", usr.UserId, warehouseId);
                newUser.TransferOrderPerm          = _activityServices.PermCheck("Handheld", "TransferOrderPerm", usr.UserId, warehouseId);
                newUser.GoodsReturnPerm            = _activityServices.PermCheck("Handheld", "GoodsReturnPerm", usr.UserId, warehouseId);
                newUser.StockTakePerm              = _activityServices.PermCheck("Handheld", "StockTakePerm", usr.UserId, warehouseId);
                newUser.PalletingPerm              = _activityServices.PermCheck("Handheld", "PalletingPerm", usr.UserId, warehouseId);
                newUser.WorksOrderPerm             = _activityServices.PermCheck("Handheld", "WorksOrderPerm", usr.UserId, warehouseId);
                newUser.MarketRoutesPerm           = _activityServices.PermCheck("Handheld", "MarketRoutesPerm", usr.UserId, warehouseId);
                newUser.RandomJobsPerm             = _activityServices.PermCheck("Handheld", "RandomJobsPerm", usr.UserId, warehouseId);
                newUser.PODPerm                    = _activityServices.PermCheck("Handheld", "PODPerm", usr.UserId, warehouseId);
                newUser.StockEnquiryPerm           = _activityServices.PermCheck("Handheld", "StockEnquiryPerm", usr.UserId, warehouseId);
                newUser.EndOfDayPerm               = _activityServices.PermCheck("Handheld", "EndOfDayPerm", usr.UserId, warehouseId);
                newUser.HolidaysPerm               = _activityServices.PermCheck("Handheld", "HolidaysPerm", usr.UserId, warehouseId);
                newUser.AddProductsOnScan          = _activityServices.PermCheck("Handheld", "AddProductsOnScan", usr.UserId, warehouseId);
                newUser.DirectSalesPerm            = _activityServices.PermCheck("Handheld", "DirectSalesPerm", usr.UserId, warehouseId);
                newUser.WastagesPerm               = _activityServices.PermCheck("Handheld", "WastagesPerm", usr.UserId, warehouseId);
                newUser.GeneratePalletLabelsPerm   = _activityServices.PermCheck("Handheld", "GeneratePalletLabelsPerm", usr.UserId, warehouseId);
                newUser.GoodsReceiveCountPerm      = _activityServices.PermCheck("Handheld", "GoodsReceiveCountPerm", usr.UserId, warehouseId);
                newUser.HandheldOverridePerm       = _activityServices.PermCheck("Handheld", "HandheldOverridePerm", usr.UserId, warehouseId);
                newUser.ExchangeOrdersPerm         = _activityServices.PermCheck("Handheld", "ExchangeOrdersPerm", usr.UserId, warehouseId);
                newUser.AllowModifyPriceInTerminal = _activityServices.PermCheck("Handheld", "AllowModifyPriceInTerminal", usr.UserId, warehouseId);
                newUser.PrintBarcodePerm           = _activityServices.PermCheck("Handheld", "PrintBarcodePerm", usr.UserId, warehouseId);
                newUser.PendingOrdersPerm          = _activityServices.PermCheck("Handheld", "PendingOrdersPerm", usr.UserId, warehouseId);

                newUsers.Add(newUser);
            }

            int count = users.Count();

            try
            {
                UsersSyncCollection collection = new UsersSyncCollection
                {
                    Count         = count,
                    TerminalLogId = TerminalServices
                                    .CreateTerminalLog(reqDate, terminal.TenantId, count, terminal.TerminalId,
                                                       TerminalLogTypeEnum.UsersSync).TerminalLogId,
                    Users = newUsers
                };

                return(Ok(collection));
            }
            catch (Exception ex)
            {
                throw new Exception("Exception while getting user sync collection - " + ex.Message.ToString(), ex.InnerException);
            }
        }