Пример #1
0
 public void Advanced_Search_By_Role_Filters_Results()
 {
     using (var driver = BrowserFactory.Create())
     {
         SignInAsAdmin(driver);
         driver.FindElement(By.PartialLinkText("Users")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count > 1);
         driver.FindElement(By.CssSelector(".advanced")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count > 0);
         (driver as IJavaScriptExecutor).ExecuteScript(@"$('select[name=""Role""]').val('Administrator')");
         ModalHelper.ClickPrimary(driver);
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count == 0);
         var rows     = driver.FindElementsByCssSelector(".table tbody tr");
         var filtered = true;
         foreach (var el in rows)
         {
             var td = el.FindElement(By.CssSelector("td:nth-child(3)"));
             if (td.Text != "Administrator")
             {
                 filtered = false;
             }
         }
         Assert.IsTrue(filtered);
     }
 }
Пример #2
0
    private void AuthSuccessCallback(string UserID)
    {
        LoginMsg.text = "Auth Success";

        SystemManage.GetAllTitleData();                 //取得所有title data
        SystemManage.GetAllStroeItem();                 //取得所有物品

        //使用playfab登入photon
        PlayFabClientAPI.GetPhotonAuthenticationToken(new GetPhotonAuthenticationTokenRequest()
        {
            PhotonApplicationId = PhotonNetwork.PhotonServerSettings.AppSettings.AppIdRealtime
        }, (xr) =>
        {
            var customAuth = new AuthenticationValues {
                AuthType = CustomAuthenticationType.Custom
            };

            customAuth.AddAuthParameter("username", UserID);
            customAuth.AddAuthParameter("token", xr.PhotonCustomAuthenticationToken);

            PhotonNetwork.AuthValues = customAuth;
            PhotonNetwork.ConnectUsingSettings();

            LoginMsg.text = "Login....";
        },
                                                      (xe) =>
        {
            LoginMsg.text = "Login Fail";
            ModalHelper.WarningMessage("Photon Authentication fail.");
        });
    }
Пример #3
0
        public static void UpdateProfit(Action callBack = null)
        {
            PlayFabClientAPI.GetUserReadOnlyData(new GetUserDataRequest()
            {
                Keys = new[] { "win", "loss", "tie" }.ToList()
            }, userDataResult =>
            {
                if (userDataResult.Data.TryGetValue("win", out var winObj))
                {
                    PlayerManage.win = int.Parse(winObj.Value);
                }

                if (userDataResult.Data.TryGetValue("loss", out var lossObj))
                {
                    PlayerManage.loss = int.Parse(lossObj.Value);
                }

                if (userDataResult.Data.TryGetValue("tie", out var tieObj))
                {
                    PlayerManage.tie = int.Parse(tieObj.Value);
                }



                callBack?.Invoke();
            }, (errResult) => {
                ModalHelper.WarningMessage("Get UserReadOnlyData fail.");
            }
                                                 );
        }
Пример #4
0
        public async Task <IActionResult> SaveForReplaceMode([Bind("CategoryId,Name")] Category category)
        {
            //https://stackoverflow.com/questions/35202804/submitting-a-razor-form-using-jquery-ajax-in-mvc6-using-the-built-in-functionali
            try
            {
                if (ModelState.IsValid)
                {
                    //add
                    if (category.CategoryId == 0)
                    {
                        _context.Add(category);
                        await _context.SaveChangesAsync();

                        _result = Result.Ok(MessageHelper.Save);
                    }
                    else if (category.CategoryId > 0) //edit
                    {
                        _context.Update(category);
                        await _context.SaveChangesAsync();

                        _result = Result.Ok(MessageHelper.Update);
                    }

                    return(Content(ModalHelper.Content(_result)));
                }

                return(Content(ModalHelper.ContentModelError(ModelState)));
            }
            catch (Exception ex)
            {
                return(Content(ModalHelper.ContentError(ex)));
            }
        }
Пример #5
0
        public void Auth(string customId, Action <string> AuthSuccessCallback, Action <PlayFabError> AuthFailCallback)
        {
            //customId等於NickName

            var request = new LoginWithCustomIDRequest {
                CustomId = customId, CreateAccount = true
            };

            PlayFabClientAPI.LoginWithCustomID(request, (loginResult) =>
            {
                //新建帳號需修改DisplayName
                if (loginResult.NewlyCreated)
                {
                    PlayFabClientAPI.UpdateUserTitleDisplayName(new UpdateUserTitleDisplayNameRequest {
                        DisplayName = customId
                    }, (xe) => {
                        var xxx = xe;
                    }, (ue) =>
                    {
                        ModalHelper.WarningMessage("update DisplayName fail.");
                    });
                }

                AuthSuccessCallback(loginResult.PlayFabId);
            }, AuthFailCallback);
        }
Пример #6
0
        public static void RunSheet(NSWindow theWindow, out ModalHelper helper)
        {
            var app    = NSApplication.SharedApplication;
            var parent = theWindow.ParentWindow;

            app.BeginSheet(theWindow, parent, delegate {
                NSApplication.SharedApplication.StopModal();
            });

            var session = app.BeginModalSession(theWindow);

            helper = new ModalHelper {
                Session = session, IsModal = true, IsSheet = true, Window = theWindow
            };
            int result;

            // Loop until some result other than continues:
            do
            {
                // Run the window modally until there are no events to process:
                result = (int)app.RunModalSession(session);

                // Give the main loop some time:
                NSRunLoop.Current.RunUntil(NSRunLoop.NSDefaultRunLoopMode, NSDate.DistantFuture);
            }while (result == (int)NSRun.ContinuesResponse || !helper.Stopped);

            app.EndModalSession(session);

            /**
             * theWindow.OrderOut (null);
             * app.EndSheet (theWindow);
             * /**/
        }
Пример #7
0
    private void UseSomething()
    {
        if (_catalogItem == null)
        {
            return;
        }

        Action <PlayFabError> errAct = (e) => { ModalHelper.WarningMessage("UseSomething fail. " + e.ErrorMessage); };

        if (_catalogItem.Container != null)
        {
            PlayFabClientAPI.UnlockContainerInstance(new UnlockContainerInstanceRequest()
            {
                CatalogVersion = "main", ContainerItemInstanceId = _instance.ItemInstanceId
            }, (r) =>
            {
                var grantedItem     = r.GrantedItems.Select(x => x.DisplayName);
                string getedItemMsg = ",獲得:" + string.Join("、", grantedItem);

                ModalHelper.WarningMessage("成功使用 [" + _instance.DisplayName + "]" + getedItemMsg);
                _reSearchBag?.Invoke();
            }, errAct);
        }
        else
        {
            PlayFabClientAPI.ConsumeItem(new ConsumeItemRequest()
            {
                ItemInstanceId = _instance.ItemInstanceId, ConsumeCount = 1
            }, (r) =>
            {
                ModalHelper.WarningMessage("成功使用 [" + _instance.DisplayName + "]");
                _reSearchBag?.Invoke();
            }, errAct);
        }
    }
Пример #8
0
 /// <summary>
 /// 移除模态管理
 /// </summary>
 protected void RemoveModalHelper()
 {
     if (m_ModalKey != null)
     {
         ModalHelper.Close((int)m_ModalKey);
         m_ModalKey = null;
     }
 }
Пример #9
0
 public void CloseModalWnd()
 {
     if (m_ModalKey != null)
     {
         ModalHelper.Close((int)m_ModalKey);
         m_ModalKey = null;
     }
     SetVisible(false);
 }
Пример #10
0
    void Awake()
    {
        modal = ModalHelper.Create();
        modal.Show(G.DialogCvs.transform, null, new Color(0, 0, 0, 153 / 255f));

        RxSubjects.GameReset.Subscribe((_) => {
            Destroy(gameObject);
        }).AddTo(this);
    }
Пример #11
0
    private void hideModal()
    {
        if (modalHelper != null)
        {
            modalHelper.Despawn();
        }

        modalHelper = null;
    }
Пример #12
0
    private void hideModal()
    {
        if (modal != null)
        {
            modal.Despawn();
        }

        modal = null;
    }
Пример #13
0
    private void AuthFailCallback(PlayFabError error)
    {
        LoginMsg.text = "Auth Fail";

        if (error != null)
        {
            ModalHelper.WarningMessage("Auth Fail" + error.ErrorMessage);
        }
    }
Пример #14
0
        // 显示设置
        public void SetData()
        {
            if (IsActive())
            {
                return;
            }

            m_nModelKey = ModalHelper.Open(this, null, new Color(0.15f, 0.15f, 0.15f, 0f), Hide, this.transform as RectTransform);
            this.gameObject.SetActive(true);
        }
Пример #15
0
    public void OnRowClick()
    {
        //顯示detail內容
        Action showDetail = () =>
        {
            decimal total = win + loss + tie;
            decimal rate  = 0;
            if (total > 0)
            {
                rate = Math.Round((win / total), 4) * 100;
            }

            friendInfoBlock.Find("name").GetComponent <Text>().text = "暱稱: " + NameTxt.text;
            friendInfoBlock.Find("Rate").GetComponent <Text>().text = "勝率: " + rate.ToString("0.##") + $"(贏:{win} 輸:{loss} 平:{tie})";
            friendInfoBlock.gameObject.SetActive(true);
        };


        if (!IsQuery)
        {
            PlayFabClientAPI.GetUserReadOnlyData(new PlayFab.ClientModels.GetUserDataRequest()
            {
                Keys = new List <string>()
                {
                    "win", "loss", "tie"
                },
                PlayFabId = UserID
            }, (r) => {
                IsQuery = true;

                if (r.Data.TryGetValue("win", out var winObj))
                {
                    win = int.Parse(winObj.Value);
                }

                if (r.Data.TryGetValue("loss", out var lossObj))
                {
                    loss = int.Parse(lossObj.Value);
                }

                if (r.Data.TryGetValue("tie", out var tieObj))
                {
                    tie = int.Parse(tieObj.Value);
                }

                showDetail();
            }, (e) => {
                ModalHelper.WarningMessage("Get UserDataRequest fail.");
            });

            return;
        }

        showDetail();
    }
Пример #16
0
 private void RemoveFriend()
 {
     PlayFabClientAPI.RemoveFriend(new PlayFab.ClientModels.RemoveFriendRequest()
     {
         FriendPlayFabId = UserID
     }, (r) => {
         ModalHelper.WarningMessage("刪除成功", ReGetFriendFunc);
     }, (e) => {
         ModalHelper.WarningMessage("操作失敗");
     });
 }
Пример #17
0
 public static void GetAllStroeItem()
 {
     PlayFabClientAPI.GetCatalogItems(new GetCatalogItemsRequest()
     {
         CatalogVersion = "main"
     }, (r) =>
     {
         AllStoreItem = r.Catalog.ToDictionary(k => k.ItemId, v => v);
     }, (e) =>
     {
         ModalHelper.WarningMessage("Get CatalogItems fail. " + e.ErrorMessage);
     });
 }
Пример #18
0
    private void ShowStoreItem()
    {
        //清除舊的商店資料
        foreach (var g in ItemEntries)
        {
            Destroy(g.gameObject);
        }
        ItemEntries.Clear();

        foreach (var g in PackItemEntries)
        {
            Destroy(g.gameObject);
        }
        PackItemEntries.Clear();

        //重新抓取商店資料
        PlayFabClientAPI.GetStoreItems(new GetStoreItemsRequest()
        {
            CatalogVersion = "main", StoreId = "FruitStore"
        }, (r) =>
        {
            storeName.text        = r.MarketingData.DisplayName;
            storeDescription.text = r.MarketingData.Description;

            foreach (var s in r.Store)
            {
                if (SystemManage.AllStoreItem.TryGetValue(s.ItemId, out CatalogItem _item))
                {
                    GameObject entry = Instantiate(StorePrefab);
                    if (_item.Bundle != null || _item.Container != null)
                    {
                        entry.transform.SetParent(PackItemContent.transform);
                        PackItemEntries.Add(entry);
                    }
                    else
                    {
                        entry.transform.SetParent(ItemContent.transform);
                        ItemEntries.Add(entry);
                    }
                    entry.transform.localScale = Vector3.one;
                    var _prise = s.VirtualCurrencyPrices.TryGetValue("PI", out var val) ? (int)val : 0;

                    entry.GetComponent <StoreItemPrefab>().Initialize(_item.DisplayName, _prise, _item.Description, s.ItemId);
                }
            }
        }, (e) =>
        {
            ModalHelper.WarningMessage("GetStoreItems faile. " + e.ErrorMessage);
        });
    }
Пример #19
0
        // 模态点击响应
        public void Hide()
        {
            ModalHelper.Close(m_nModelKey);
            this.gameObject.SetActive(false);

            if (m_listPublishItem == null)
            {
                return;
            }
            foreach (var item in m_listPublishItem)
            {
                item.SetDeselect();
            }
        }
Пример #20
0
 public void Admin_Can_Delete_User()
 {
     using (var driver = BrowserFactory.Create())
     {
         SignInAsAdmin(driver);
         driver.FindElement(By.PartialLinkText("Users")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count > 1);
         driver.FindElement(By.CssSelector(".user-row-10 a[title='Delete user']")).Click();
         driver.WaitFor(u => u.FindElements(By.CssSelector(".modal-footer")).Count > 0);
         ModalHelper.ClickPrimary(driver);
         driver.WaitFor(u => u.FindElements(By.CssSelector(".alert-info")).Count > 0);
         Assert.IsTrue(driver.ElementExists(By.CssSelector(".alert-info")));
     }
 }
Пример #21
0
 public void Search_Users_By_Advanced_Email_Filters_Results()
 {
     using (var driver = BrowserFactory.Create())
     {
         SignInAsAdmin(driver);
         driver.FindElement(By.PartialLinkText("Users")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count > 1);
         driver.FindElement(By.CssSelector(".advanced")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count > 0);
         (driver as IJavaScriptExecutor).ExecuteScript(@"$('input[name=""Email""]').val('*****@*****.**')");
         ModalHelper.ClickPrimary(driver);
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count < DefaultNumPerPage);
         Assert.AreEqual(1, driver.FindElementsByCssSelector(".table tbody tr").Count);
     }
 }
Пример #22
0
        public static void GetAllTitleData()
        {
            PlayFabClientAPI.GetTitleData(new GetTitleDataRequest(), (r) =>
            {
                AllTitleData = r.Data;

                //讀取21點所有房間
                if (AllTitleData.TryGetValue("BlackJackRooms", out string blackJackRoomJson))
                {
                    BlackJackRooms = LitJson.JsonMapper.ToObject <List <BlackJackRoom> >(blackJackRoomJson);
                }
            }, (e) =>
            {
                ModalHelper.WarningMessage("Get AllTitleData fail. " + e.ErrorMessage);
            });
        }
Пример #23
0
 public void Advanced_Search_By_Value_Filters_Results()
 {
     using (var driver = BrowserFactory.Create())
     {
         SignInAsAdmin(driver);
         driver.FindElement(By.PartialLinkText("Resources")).Click();
         driver.FindElement(By.PartialLinkText("Content")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count > 1);
         driver.FindElement(By.CssSelector(".advanced")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count > 0);
         (driver as IJavaScriptExecutor).ExecuteScript(@"$('input[name=""Value""]').val('27')");
         ModalHelper.ClickPrimary(driver);
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count == 0);
         Assert.AreEqual(1, driver.FindElementsByCssSelector(".table tbody tr").Count);
     }
 }
Пример #24
0
 public void Advanced_Search_By_User_Filters_Results()
 {
     using (var driver = BrowserFactory.Create())
     {
         SignInAsAdmin(driver);
         driver.FindElement(By.PartialLinkText("Logs")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count > 1);
         driver.FindElement(By.CssSelector(".advanced")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count > 0);
         (driver as IJavaScriptExecutor).ExecuteScript(@"$('input[name=""UserId""]').val('1')");
         ModalHelper.ClickPrimary(driver);
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count == 0);
         var td = driver.FindElementByCssSelector(".table tbody tr td:first-child");
         Assert.AreEqual("99", td.Text);
     }
 }
Пример #25
0
 public void Advanced_Search_By_Date_Filters_Results()
 {
     using (var driver = BrowserFactory.Create())
     {
         SignInAsAdmin(driver);
         driver.FindElement(By.PartialLinkText("Logs")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count > 1);
         driver.FindElement(By.CssSelector(".advanced")).Click();
         driver.WaitFor(d => d.FindElements(By.CssSelector(".modal-body")).Count > 0);
         (driver as IJavaScriptExecutor).ExecuteScript("$('.date-range').trigger('click')");
         (driver as IJavaScriptExecutor).ExecuteScript("$('.ranges ul li:nth-child(2)').trigger('click')");
         ModalHelper.ClickPrimary(driver);
         driver.WaitFor(d => d.FindElements(By.CssSelector(".table tbody tr")).Count < DefaultNumPerPage);
         Assert.AreEqual(1, driver.FindElementsByCssSelector(".table tbody tr").Count);
     }
 }
Пример #26
0
        public static void BeginSheet(NSWindow theWindow, out ModalHelper helper, Action completed)
        {
            var app    = NSApplication.SharedApplication;
            var parent = theWindow.ParentWindow;

            app.BeginSheet(theWindow, parent, delegate {
                NSApplication.SharedApplication.StopModal();
                if (completed != null)
                {
                    completed();
                }
            });
            helper = new ModalHelper {
                IsModal = true, IsSheet = true, Window = theWindow
            };
        }
Пример #27
0
        public void LateUpdate()
        {
            if (m_listUsingComponent != null && m_listUsingComponent.Count > 0 && ModalHelper.IsModalExit())
            {
                for (int i = 0; i < m_listUsingComponent.Count; ++i)
                {
                    {
                        m_listUsingComponent[i].GetTransform.SetParent(UISystem.Instance.transform);
                        m_listUsingComponent[i].GetTransform.SetAsLastSibling();
                    }
                }
                m_bNeedUpdateSibling = false;
            }
            else if (m_listUsingComponent != null && m_listUsingComponent.Count > 0 && m_bNeedUpdateSibling && !ModalHelper.IsModalExit())
            {
                for (int i = 0; i < m_listUsingComponent.Count; ++i)
                {
                    {
                        m_listUsingComponent[i].GetTransform.SetParent(GetTransform());
                        m_listUsingComponent[i].GetTransform.SetAsLastSibling();
                    }
                }
            }

            if (m_listUsingRewardComponent != null && m_listUsingRewardComponent.Count > 0 && ModalHelper.IsModalExit())
            {
                for (int i = 0; i < m_listUsingRewardComponent.Count; ++i)
                {
                    {
                        m_listUsingRewardComponent[i].GetTransform.SetParent(UISystem.Instance.transform);
                        m_listUsingRewardComponent[i].GetTransform.SetAsLastSibling();
                    }
                }
                m_bNeedUpdateSibling = false;
            }
            else if (m_listUsingRewardComponent != null && m_listUsingRewardComponent.Count > 0 && m_bNeedUpdateSibling && !ModalHelper.IsModalExit())
            {
                for (int i = 0; i < m_listUsingRewardComponent.Count; ++i)
                {
                    {
                        m_listUsingRewardComponent[i].GetTransform.SetParent(GetTransform());
                        m_listUsingRewardComponent[i].GetTransform.SetAsLastSibling();
                    }
                }
            }
        }
Пример #28
0
 public void OnToggleListView(bool _bOpen)
 {
     if (_bOpen)
     {
         DispositionListView.gameObject.SetActive(true);
         modalKey = ModalHelper.Open(DispositionListView, color: new Color(0, 0, 0, 0), onClick: () =>
         {
             UISystem.Instance.SendTargetWndMessage(WndID.WND_ID_WAR_GOODSSTORE, WndMsgID.WND_MSG_WAR_GOODSSTORE_SET_TOGGLEDISPOSITIONSTATE,
                                                    new UIMsgCmdData((int)WndMsgID.WND_MSG_WAR_GOODSSTORE_SET_TOGGLEDISPOSITIONSTATE, 0, string.Empty, IntPtr.Zero, 0));
         }, _tModalTarget: DispositionListContainer);
     }
     else
     {
         DispositionListView.gameObject.SetActive(false);
         ModalHelper.Close(modalKey);
     }
 }
Пример #29
0
        public void Auth(string customId, Action <string> AuthSuccessCallback, Action <PlayFabError> AuthFailCallback)
        {
            FB.LogInWithReadPermissions(new List <string>()
            {
                "public_profile", "email", "user_friends"
            }, (result) =>
            {
                if (result.Cancelled)
                {
                    AuthFailCallback(null);
                }
                else if (!string.IsNullOrEmpty(result.Error))
                {
                    AuthFailCallback(null);
                    ModalHelper.WarningMessage("FaceBookLogin fail: " + result.Error);
                }
                else
                {
                    PlayFabClientAPI.LoginWithFacebook(new LoginWithFacebookRequest()
                    {
                        AccessToken   = result.AccessToken.TokenString,
                        CreateAccount = true
                    }, (loginResult) =>
                    {
                        if (loginResult.NewlyCreated)
                        {
                            FB.API("/me?fields=id,name,gender,email", HttpMethod.GET, (r) =>
                            {
                                if (r.ResultDictionary.TryGetValue("name", out string name))
                                {
                                    PlayFabClientAPI.UpdateUserTitleDisplayName(new UpdateUserTitleDisplayNameRequest {
                                        DisplayName = name
                                    }, null, (ue) =>
                                    {
                                        ModalHelper.WarningMessage("update DisplayName fail.");
                                    });
                                }
                            });
                        }

                        AuthSuccessCallback(loginResult.PlayFabId);
                    }, AuthFailCallback);
                }
            });
        }
Пример #30
0
        public override void ShowList()
        {
            if (listView == null)
            {
                return;
            }

            listView.gameObject.SetActive(true);

            ModalKey = ModalHelper.Open(this, null, new Color(0, 0, 0, 0f), HideList, listView.transform as RectTransform);

            PopupListView();

            if (listView.Layout != null)
            {
                listView.Layout.UpdateLayout();
            }
        }
Пример #31
0
		public static void BeginSheet(NSWindow theWindow, out ModalHelper helper, Action completed)
		{
			var app = NSApplication.SharedApplication;
			var parent = theWindow.ParentWindow;
			app.BeginSheet(theWindow, parent, delegate {
				NSApplication.SharedApplication.StopModal();
				if (completed != null)
					completed();
			});
			helper = new ModalHelper { IsModal = true, IsSheet = true, Window = theWindow };
		}
Пример #32
0
		public static void Run (NSWindow theWindow, out ModalHelper helper)
		{
			var app = NSApplication.SharedApplication;
			var session = app.BeginModalSession (theWindow);
			helper = new ModalHelper { Session = session, IsModal = true, Window = theWindow };
			int result;
			
			// Loop until some result other than continues:
			do {
				// Run the window modally until there are no events to process:
				result = app.RunModalSession (session);

				// Give the main loop some time:
				NSRunLoop.Current.RunUntil (NSRunLoop.NSDefaultRunLoopMode, NSDate.DistantFuture);
			}
			while (result == (int)NSRun.ContinuesResponse || !helper.Stopped);
			
			app.EndModalSession (session);
		}