コード例 #1
0
ファイル: train.cs プロジェクト: osuraw/TrainFinder
        private static async Task GetTrain(int id)
        {
            var tempData = await WebConnect.GetData("Train/GetTrainInRoute/" + id);

            var results = JsonConvert.DeserializeObject <IEnumerable <Train> >(tempData);
            var trains  = new ObservableCollection <Train>()
            {
                new Train()
                {
                    Name = "Select Train"
                }
            };

            foreach (var result in results)
            {
                var temp = new Train
                {
                    RID          = result.RID,
                    TID          = result.TID,
                    Name         = result.Name,
                    StartStation = result.StartStation,
                    EndStation   = result.EndStation,
                    Description  = result.Description
                };
                trains.Add(temp);
            }
            Trains = trains;
        }
コード例 #2
0
ファイル: train.cs プロジェクト: osuraw/TrainFinder
        public static async Task <List <Train> > GetTrains()
        {
            var tempData = await WebConnect.GetData("Trains");

            var results = JsonConvert.DeserializeObject <IEnumerable <Train> >(tempData);
            var trains  = new List <Train>()
            {
                new Train()
                {
                    Name = "Select Train", TID = 0
                }, new Train()
                {
                    Name = "All Trains", TID = 1
                }
            };

            foreach (var result in results)
            {
                var temp = new Train
                {
                    RID          = result.RID,
                    TID          = result.TID,
                    Name         = result.Name,
                    StartStation = result.StartStation,
                    EndStation   = result.EndStation,
                    Description  = result.Description
                };
                trains.Add(temp);
            }
            return(trains);
        }
コード例 #3
0
ファイル: route.cs プロジェクト: osuraw/TrainFinder
        //private static async Task<ObservableCollection<Route>> GetRouteList1()
        private static async Task GetRouteList1()
        {
            //var tempData = WebConnect.GetData("Route/GetRouteList");
            var tempData = await WebConnect.GetData("Route/GetRouteList");

            var results = JsonConvert.DeserializeObject <IEnumerable <Route> >(tempData);
            //---------------------------------------------------------------------
            var routes = new ObservableCollection <Route>()
            {
                new Route {
                    RID = 0, Name = "Select Route"
                }
            };

            foreach (var result in results)
            {
                var temp = new Route
                {
                    RID          = result.RID,
                    Name         = result.Name,
                    Distance     = result.Distance,
                    StartStation = result.StartStation,
                    EndStation   = result.EndStation,
                    Description  = result.Description
                };
                routes.Add(temp);
            }

            Routes = routes;
            //return routes;
        }
コード例 #4
0
        private static async Task GetStationBy(int id)
        {
            var tempData = await WebConnect.GetData("Stations/GetStationInRoute/" + id);

            var results  = JsonConvert.DeserializeObject <IEnumerable <Station> >(tempData);
            var stations = new ObservableCollection <Station> {
                new Station()
                {
                    Name = "Select Station"
                }
            };

            foreach (var result in results)
            {
                var temp = new Station
                {
                    SID       = result.SID,
                    Name      = result.Name,
                    Distance  = result.Distance,
                    Location  = result.Location,
                    Address   = result.Address,
                    Telephone = result.Telephone,
                    RID       = result.RID
                };
                stations.Add(temp);
            }
            //could make error
            Stations = stations;
        }
コード例 #5
0
        static void Main(string[] args)
        {
            WebConnect    web = new WebConnect();
            ExchangeRates r   = web.GetExchangeRates();

            Console.WriteLine(r);
            Console.ReadKey();
        }
コード例 #6
0
ファイル: Pinlocation.cs プロジェクト: osuraw/TrainFinder
        private static async Task GetLocations(short routeId)
        {
            var tempData = await WebConnect.GetData("PinLocation/GetPinLocation?rid=" + routeId);

            var results      = JsonConvert.DeserializeObject <IEnumerable <PinLocation> >(tempData);
            var locationList = new ObservableCollection <PinLocation>();

            foreach (var result in results)
            {
                locationList.Add(result);
            }
            PinLocations = locationList;
        }
コード例 #7
0
        private void AddUpdate(object data)
        {
            var havePassword = data as IHavePassword;

            if (havePassword.SecureString.ComparePassword(havePassword.SecureString1, out string password))
            {
                var response = WebConnect.PostData("User/Create", new User {
                    Name = Name, Uname = UserName, Password = password, UserId = flag ? 0 : LogInFor.User.UserId
                });
                DialogDisplayHelper.DisplayMessageBox(flag?"Add Complete":"Update Complete", "Informative");
            }
            else
            {
                DialogDisplayHelper.DisplayMessageBox("Confirm Password And Password Not Matched", "Informative", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #8
0
        public SharedUI()
        {
            var a = false;

            //注册后台任务
            foreach (var cur in BackgroundTaskRegistration.AllTasks)
            {
                if (cur.Value.Name == "RefreshBackgroundTask")
                {
                    a = true;
                }
            }
            if (!a)
            {
                var builder = new BackgroundTaskBuilder();
                builder.Name           = "RefreshBackgroundTask";
                builder.TaskEntryPoint = "TsinghuaNet.RefreshBackgroundTask";
                builder.SetTrigger(new SystemTrigger(SystemTriggerType.InternetAvailable, false));
                builder.Register();
            }

            //初始化信息存储区
            try
            {
                ApplicationData.Current.LocalSettings.Values.Add("UserName", "");
                ApplicationData.Current.LocalSettings.Values.Add("PasswordMD5", "");
            }
            catch (ArgumentException)
            {
                //已经添加字段
                if (!string.IsNullOrEmpty((string)ApplicationData.Current.LocalSettings.Values["UserName"]))
                {
                    Connect = new WebConnect((string)ApplicationData.Current.LocalSettings.Values["UserName"], (string)ApplicationData.Current.LocalSettings.Values["PasswordMD5"]);
                }
            }

            // 准备Toast通知
            toastXml   = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText04);
            toastTitle = toastXml.CreateTextNode("");
            toastText1 = toastXml.CreateTextNode("");
            toastText2 = toastXml.CreateTextNode("");
            XmlNodeList stringElements = toastXml.GetElementsByTagName("text");

            stringElements[0].AppendChild(toastTitle);
            stringElements[1].AppendChild(toastText1);
            stringElements[2].AppendChild(toastText2);
        }
コード例 #9
0
        private async System.Threading.Tasks.Task <bool> SignIn()
        {
            this.textBlockHint.Text = "";
            var userName = this.textBoxUserName.Text;

            if (string.IsNullOrEmpty(userName))
            {
                this.textBoxUserName.Focus(Windows.UI.Xaml.FocusState.Programmatic);
                this.textBlockHint.Text = LocalizedStrings.Errors.EmptyUserName;
                return(false);
            }
            var password = this.passwordBoxPassword.Password;

            if (string.IsNullOrEmpty(password))
            {
                this.passwordBoxPassword.Focus(Windows.UI.Xaml.FocusState.Programmatic);
                this.textBlockHint.Text = LocalizedStrings.Errors.EmptyPassword;
                return(false);
            }
            this.progressBar.Visibility = Windows.UI.Xaml.Visibility.Visible;
            try
            {
                if (!(await WebConnect.CheckAccount(userName, password) is AccountInfo accountInfo))
                {
                    this.passwordBoxPassword.SelectAll();
                    this.passwordBoxPassword.Focus(Windows.UI.Xaml.FocusState.Programmatic);
                    this.progressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                    this.textBlockHint.Text     = LocalizedStrings.Errors.AuthError;
                    return(false);
                }
                var connect = new WebConnect(accountInfo, password);
                AccountManager.Save(accountInfo, password);
                WebConnect.Current = connect;
                WebConnect.Current.PropertyChanged += NotificationService.NotificationService.UpdateTile;
                return(true);
            }
            catch (Exception)
            {
                this.textBlockHint.Text     = LocalizedStrings.Errors.ConnectError;
                this.progressBar.Visibility = Windows.UI.Xaml.Visibility.Collapsed;
                return(false);
            }
        }
コード例 #10
0
        private void ActivateTrain(object obj)
        {
            if (obj == null || Action.Equals("SelectAction") || Direction.Equals("SelectDirection"))
            {
                return;
            }
            var data     = obj as InactiveTrains;
            var response = WebConnect.UpdateDate("Train/AddTranToWatch", new { TrainId = data.TID, Status = Action, Direction = Direction.Equals("UpWay") });

            if (response.StatusCode == HttpStatusCode.OK)
            {
                GetData();
                DialogDisplayHelper.DisplayMessageBox("Activation Completed", "Informative");
            }
            else if (response.StatusCode == HttpStatusCode.BadRequest)
            {
                DialogDisplayHelper.DisplayMessageBox("Configuration Error Occur Check System Configurations", "System Error Detection", boxIcon: MessageBoxImage.Warning);
            }
            Action    = "SelectAction";
            Direction = "SelectDirection";
        }
コード例 #11
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            if (!run)
            {
                return;
            }
            var connection = NetworkInformation.GetInternetConnectionProfile();

            if (connection == null)
            {
                return;
            }
            if (connection.IsWwanConnectionProfile)
            {
                return;
            }
            var d      = taskInstance.GetDeferral();
            var client = new WebConnect(userName, passwordMD5);

            try
            {
                await client.LogOnAsync();
            }
            catch (LogOnException) { }
            try
            {
                await client.RefreshAsync();

                if (!client.IsOnline)
                {
                    return;
                }
                SendToastNotification(logOnSucessful, string.Format(CultureInfo.CurrentCulture, used, client.WebTrafficExact));
            }
            catch (LogOnException) { }
            finally
            {
                d.Complete();
            }
        }
コード例 #12
0
        private static async Task GetTimeTable(byte flag, int id)
        {
            var tempData = await WebConnect.GetData($"TimeTables/GetTimeTableByTypeId?type={flag}&id={id}");

            var results = JsonConvert.DeserializeObject <IEnumerable <Stops> >(tempData);

            StopList = new ObservableCollection <Stops>();
            foreach (var result in results)
            {
                var temp = new Stops
                {
                    TrainId       = result.TrainId,
                    StationId     = result.StationId,
                    TrainName     = result.TrainName,
                    StationName   = result.StationName,
                    Direction     = result.Direction,
                    ArriveTime    = result.ArriveTime.TimeToString(),
                    DepartureTime = result.DepartureTime.TimeToString()
                };
                StopList.Add(temp);
            }
        }
コード例 #13
0
ファイル: Endpoints.cs プロジェクト: 0xdeafcafe/SnapDotNet
		/// <summary>
		/// 
		/// </summary>
		/// <param name="snapchatManager"></param>
		/// <returns></returns>
		public Endpoints(SnapChatManager snapchatManager)
		{
			_snapchatManager = snapchatManager;
			_webConnect = new WebConnect(Settings.ApiBasePoint);
			_logWebConnect = new WebConnect(Settings.ApiLogBasePoint);
		}
コード例 #14
0
ファイル: Endpoints.cs プロジェクト: 0xdeafcafe/SnapDotNet
		public Endpoints()
		{
			_webConnect = new WebConnect();
		}
コード例 #15
0
        public static IAsyncAction UpdateTile(WebConnect connect)
        {
            return(Task.Run(() =>
            {
                var manager = TileUpdateManager.CreateTileUpdaterForApplication();
                manager.Clear();
                var usage = connect.WebTrafficExact.ToString();
                manager.EnableNotificationQueue(true);
                var devices = connect.DeviceList.ToArray();
                SetBadgeNumber(devices.Length);
                if (devices.Length == 0)
                {
                    addTile(manager, $@"
<tile>
    <visual branding='name'>
        <binding template='TileMedium'>
            <text hint-style='body'>
                <![CDATA[{usage}]]>
            </text>
            <text hint-style='caption' hint-wrap='true'>
                <![CDATA[{LocalizedStrings.Resources.NoDevices}]]>
            </text>
        </binding>
        <binding template='TileWide'>
            <text hint-style='body'>
                <![CDATA[{string.Format(CultureInfo.CurrentCulture, LocalizedStrings.Resources.Usage, usage)}]]>
            </text>
            <text hint-style='caption' hint-wrap='true'>
                <![CDATA[{LocalizedStrings.Resources.NoDevices}]]>
            </text>
        </binding>
    </visual>
</tile>");
                    return;
                }
                foreach (var item in devices)
                {
                    addTile(manager, $@"
<tile>
    <visual branding='name'>
        <binding template='TileMedium'>
            <text hint-style='body'>
                <![CDATA[{usage}]]>
            </text>
            <text hint-style='caption'>
                <![CDATA[{item.Name}]]>
            </text>
            <text hint-style='captionsubtle'>
                <![CDATA[{item.LogOnDateTime.TimeOfDay}]]>
            </text>
            <text hint-style='captionsubtle'>
                <![CDATA[{item.IPAddress}]]>
            </text>
        </binding>
        <binding template='TileWide'>
            <text hint-style='body'>
                <![CDATA[{string.Format(CultureInfo.CurrentCulture, LocalizedStrings.Resources.Usage, usage)}]]>
            </text>
            <text hint-style='caption'>
                <![CDATA[{item.Name}]]>
            </text>
            <text hint-style='captionsubtle'>
                <![CDATA[{item.LogOnDateTime}]]>
            </text>
            <text hint-style='captionsubtle'>
                <![CDATA[{item.IPAddress}]]>
            </text>
        </binding>
    </visual>
</tile>");
                }
            }).AsAsyncAction());
        }