Ejemplo n.º 1
0
        public void onTaskCompleted(string result, APIRequest.requestCodeType requestCode)
        {
            if (result != null)
            {
                if (requestCode == APIRequest.requestCodeType.Portfolio)
                {
                    Items.Clear();

                    JsonArray json = JsonArray.Parse(result);

                    foreach (var share in json)
                    {
                        JsonObject shareObj = share.GetObject();
                        string     symbol   = shareObj.GetNamedString("symbol");
                        string     name     = shareObj.GetNamedString("name");
                        double     value    = shareObj.GetNamedNumber("value");
                        bool       isMain   = shareObj.GetNamedBoolean("is_main");
                        Quotation  q        = new Quotation()
                        {
                            Name = name, Symbol = symbol, Value = value, IsMain = isMain
                        };
                        Items.Add(q);
                    }
                }
                else if (requestCode == APIRequest.requestCodeType.PortfolioAdd)
                {
                    RefreshPortfolio();
                }
                else if (requestCode == APIRequest.requestCodeType.UpdateUri)
                {
                    // update sucessfull
                }
                else if (requestCode == APIRequest.requestCodeType.Logout)
                {
                    JsonObject json = new JsonObject();
                    JsonObject.TryParse(result, out json);
                    view.LogoutHandler(!json.ContainsKey("error"));
                }
            }
            else
            {
                var toastXmlContent = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

                var txtNodes = toastXmlContent.GetElementsByTagName("text");
                txtNodes[0].AppendChild(toastXmlContent.CreateTextNode("Server request failed."));
                txtNodes[1].AppendChild(toastXmlContent.CreateTextNode("Server is down or you lost internet connection."));

                var toast         = new ToastNotification(toastXmlContent);
                var toastNotifier = ToastNotificationManager.CreateToastNotifier();
                toastNotifier.Show(toast);
            }
        }
        public void onTaskCompleted(string result, APIRequest.requestCodeType requestCode)
        {
            if (requestCode == APIRequest.requestCodeType.AllShares)
            {
                if (result != null)
                {
                    JsonArray json = JsonArray.Parse(result);

                    foreach (var share in json)
                    {
                        JsonObject shareObj = share.GetObject();
                        string symbol = shareObj.GetNamedString("symbol");
                        string name = shareObj.GetNamedString("name");
                        Quotation q = new Quotation() { Name = name, Symbol = symbol };
                        allItems.Add(q);
                    }
                }
            }
        }
        public void onTaskCompleted(string result, APIRequest.requestCodeType requestCode)
        {
            if (requestCode == APIRequest.requestCodeType.AllShares)
            {
                if (result != null)
                {
                    JsonArray json = JsonArray.Parse(result);

                    foreach (var share in json)
                    {
                        JsonObject shareObj = share.GetObject();
                        string     symbol   = shareObj.GetNamedString("symbol");
                        string     name     = shareObj.GetNamedString("name");
                        Quotation  q        = new Quotation()
                        {
                            Name = name, Symbol = symbol
                        };
                        allItems.Add(q);
                    }
                }
            }
        }
        private void SetLimit(object sender, RoutedEventArgs e)
        {
            Quotation q = null;

            if ((string)((Button)sender).Tag == "SetLimitUp")
            {
                q = new Quotation()
                {
                    Symbol = pageModel.Symbol, Name = pageModel.Name, Value = pageModel.Value, LimitType = "Upper Limit", Date = pageModel.Date, Time = pageModel.Time
                }
            }
            ;
            else if ((string)((Button)sender).Tag == "SetLimitDown")
            {
                q = new Quotation()
                {
                    Symbol = pageModel.Symbol, Name = pageModel.Name, Value = pageModel.Value, LimitType = "Lower Limit", Date = pageModel.Date, Time = pageModel.Time
                }
            }
            ;

            Frame.Navigate(typeof(SetLimitDialog), q);
        }
        private void SetLimit(object sender, RoutedEventArgs e)
        {
            Quotation q = null;

            if ((string)((Button)sender).Tag == "SetLimitUp")
                q = new Quotation() {Symbol = pageModel.Symbol, Name = pageModel.Name, Value = pageModel.Value, LimitType = "Upper Limit", Date = pageModel.Date, Time = pageModel.Time };
            else if((string)((Button)sender).Tag == "SetLimitDown")
                q = new Quotation() { Symbol = pageModel.Symbol, Name = pageModel.Name, Value = pageModel.Value, LimitType = "Lower Limit", Date = pageModel.Date, Time = pageModel.Time };

            Frame.Navigate(typeof (SetLimitDialog), q);
        }
        public void onTaskCompleted(string result, APIRequest.requestCodeType requestCode)
        {
            if (result != null)
            {
                if (requestCode == APIRequest.requestCodeType.Portfolio)
                {
                    Items.Clear();

                    JsonArray json = JsonArray.Parse(result);

                    foreach (var share in json)
                    {
                        JsonObject shareObj = share.GetObject();
                        string symbol = shareObj.GetNamedString("symbol");
                        string name = shareObj.GetNamedString("name");
                        double value = shareObj.GetNamedNumber("value");
                        bool isMain = shareObj.GetNamedBoolean("is_main");
                        Quotation q = new Quotation() {Name = name, Symbol = symbol, Value = value, IsMain = isMain};
                        Items.Add(q);
                    }
                }
                else if (requestCode == APIRequest.requestCodeType.PortfolioAdd)
                {
                    RefreshPortfolio();
                }
                else if (requestCode == APIRequest.requestCodeType.UpdateUri)
                {
                    // update sucessfull
                }
                else if (requestCode == APIRequest.requestCodeType.Logout)
                {
                    JsonObject json = new JsonObject();
                    JsonObject.TryParse(result, out json);
                    view.LogoutHandler(!json.ContainsKey("error"));
                 
                }
            }
            else
            {
                var toastXmlContent = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText02);

                var txtNodes = toastXmlContent.GetElementsByTagName("text");
                txtNodes[0].AppendChild(toastXmlContent.CreateTextNode("Server request failed."));
                txtNodes[1].AppendChild(toastXmlContent.CreateTextNode("Server is down or you lost internet connection."));

                var toast = new ToastNotification(toastXmlContent);
                var toastNotifier = ToastNotificationManager.CreateToastNotifier();
                toastNotifier.Show(toast);
            }
        }