Пример #1
0
        private void ShowWrongPasswordNotification(string ssid, string username)
        {
            var lastToast = ToastNotificationManager.History.GetHistory().FirstOrDefault();

            if (lastToast != null)
            {
                var expirationTime  = lastToast.ExpirationTime ?? DateTimeOffset.MinValue;
                var lastProfileName = lastToast.Content.InnerText.Split("\n").Last();
                var now             = DateTimeOffset.Now.AddDays(3);
                var timeDiff        = now.Subtract(expirationTime);
                var lastSsid        = lastProfileName.Substring(lastProfileName.LastIndexOf(' ') + 1);

                if (lastProfileName == ssid && timeDiff.Minutes < 1)
                {
                    return;
                }
                else if (lastSsid == ssid && timeDiff.Minutes < 1)
                {
                    return;
                }
            }

            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse();
            var toast          = new NotificationToast(".Net Campus", String.Format(resourceLoader.GetString("WrongPasswordToast"), username))
            {
                Tag   = "64",
                Group = "Login"
            };

            toast.Show();
        }
Пример #2
0
        private async Task LowBalanceAlert()
        {
            var localHelper = new LocalObjectStorageHelper();
            var isLowBalanceAlertEnabled = true;

            if (localHelper.KeyExists("IsLowBalanceAlertEnabled"))
            {
                isLowBalanceAlertEnabled = localHelper.Read("IsLowBalanceAlertEnabled", true);
            }

            if (isLowBalanceAlertEnabled)
            {
                var profile = Windows.Networking.Connectivity.NetworkInformation.GetInternetConnectionProfile();

                if (profile != null)
                {
                    var status = await NetHelper.GetStatusAsync();

                    if (status != null)
                    {
                        var balance            = Convert.ToDouble(status["balance"]);
                        var balanceDescription = Utility.GetBalanceDescription(balance);
                        var threshold          = 5;

                        if (localHelper.KeyExists("BalanceThreshold"))
                        {
                            threshold = localHelper.Read("BalanceThreshold", 5);
                        }

                        if (balance < threshold)
                        {
                            var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse();
                            var toast          = new NotificationToast(".Net Campus", String.Format(resourceLoader.GetString("LowBalanceAlertNotification"), balanceDescription))
                            {
                                Tag   = "65",
                                Group = "Balance"
                            };
                            toast.Show();
                        }
                    }
                }
            }
        }
Пример #3
0
        private async void ShowAutoLoginNotification(string ssid)
        {
            var status = await NetHelper.GetStatusAsync();

            if (status != null)
            {
                var lastToast = ToastNotificationManager.History.GetHistory().FirstOrDefault();
                if (lastToast != null)
                {
                    var expirationTime  = lastToast.ExpirationTime ?? DateTimeOffset.MinValue;
                    var lastProfileName = lastToast.Content.InnerText.Split("\n").Last();
                    var now             = DateTimeOffset.Now.AddDays(3);
                    var timeDiff        = now.Subtract(expirationTime);
                    var lastSsid        = lastProfileName.Substring(lastProfileName.LastIndexOf(' ') + 1);

                    if (lastProfileName == ssid && timeDiff.Minutes < 1)
                    {
                        return;
                    }
                    else if (lastSsid == ssid && timeDiff.Minutes < 1)
                    {
                        return;
                    }
                }

                var usage    = Utility.GetUsageDescription((long)status["total_usage"]);
                var balance  = Utility.GetBalanceDescription(Convert.ToDouble(status["balance"]));
                var username = status["username"] as string;

                var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForViewIndependentUse();
                var toast          = new NotificationToast(".Net Campus", String.Format(resourceLoader.GetString("Auto-loginToast"), username, usage, balance, ssid))
                {
                    Tag   = "64",
                    Group = "Login"
                };
                toast.Show();
            }
        }