Esempio n. 1
0
        private void RequestsStatus(DRequestCompletedEventArgs e, string QId)
        {
            try
            {
                int        NGrants  = 0;
                int        NScripts = 0;
                JsonObject JMesg    = JsonStatus.Parse(e.ResponseString);
                JsonArray  JData    = JMesg.GetNamedArray("data");

                if (0 < Grants.Count())
                {
                    List <SHGrant> CurrGrants = new List <SHGrant>(Grants);
                    foreach (JsonValue JValue in JData)
                    {
                        SHGrant G = new SHGrant(JValue.GetObject());
                        if (Grants.Any(x => x.Id == G.Id))
                        {
                            continue;
                        }
                        CurrGrants.Add(G);
                    }
                    Grants = CurrGrants.ToArray();
                }
                else
                {
                    Grants = JData.Remap(x =>
                    {
                        SHGrant G = new SHGrant(x.GetObject());

                        int l = G.Grants.Length;
                        if (!G.SourceRemoved)
                        {
                            if (0 < l)
                            {
                                NScripts++;
                            }
                            NGrants += l;
                        }

                        return(G);
                    });
                }

                if (0 < NGrants)
                {
                    Member.Activities.Add(() =>
                    {
                        StringResources stx = StringResources.Load();
                        return(string.Format(stx.Text("GrantsReceived"), NGrants, NScripts));
                    }, () => MessageBus.SendUI(typeof(MyRequests), AppKeys.SH_SHOW_GRANTS));
                }
            }
            catch (Exception ex)
            {
                Logger.Log(ID, ex.Message, LogType.WARNING);
            }
        }
Esempio n. 2
0
 private void GrantComplete(DRequestCompletedEventArgs e, string Id)
 {
     try
     {
         JsonStatus.Parse(e.ResponseString);
         SetGranted(Id);
     }
     catch (Exception ex)
     {
         Logger.Log(ID, ex.Message);
     }
 }
Esempio n. 3
0
        private async void SaveTemp(DRequestCompletedEventArgs e, DownloadBookContext Context)
        {
            StorageFile ISF = await AppStorage.MkTemp(
                Context.Id
                + ". "
                + (string.IsNullOrEmpty(Context.Title) ? "[ Parse Needed ]" : Context.Title)
                + ".txt"
                );

            await ISF.WriteBytes(e.ResponseBytes);

            ViewSource.BSData.ImportItem(new LocalBook(ISF));
        }
Esempio n. 4
0
 private void PlaceSuccess(DRequestCompletedEventArgs e, string Id)
 {
     try
     {
         JsonStatus.Parse(e.ResponseString);
         Canceled = false;
         Worker.UIInvoke(() => { Hide(); });
     }
     catch (Exception ex)
     {
         Error(ex.Message);
     }
 }
Esempio n. 5
0
 private void CommentSuccess(DRequestCompletedEventArgs e, string Id)
 {
     try
     {
         JsonStatus.Parse(e.ResponseString);
         CommentInput.Document.SetText(Windows.UI.Text.TextSetOptions.None, "");
         DropComment();
         ReloadComments();
     }
     catch (Exception ex)
     {
         CommentError.Text = ex.Message;
     }
 }
Esempio n. 6
0
 private void RequestComplete(DRequestCompletedEventArgs e, string QueryId)
 {
     IndicateIdle();
     try
     {
         JsonStatus.Parse(e.ResponseString);
         Canceled = false;
         Hide();
     }
     catch (Exception ex)
     {
         ErrorMessage(ex.Message);
         Account.Focus(FocusState.Keyboard);
     }
 }
Esempio n. 7
0
        private void SearchItemUpdate(DRequestCompletedEventArgs e, string Id)
        {
            HubScriptItem Target;

            if (TryGetId(Id, out Target))
            {
                try
                {
                    JsonObject JResponse = JsonStatus.Parse(e.ResponseString);
                    Target.Update(JResponse.GetNamedArray("data").First().GetObject());
                }
                catch (Exception ex)
                {
                    Target.ErrorMessage = ex.Message;
                }
            }
        }
Esempio n. 8
0
        private void GotServerList(DRequestCompletedEventArgs e, string key)
        {
            IEnumerable <ServerChoice> SC = null;

            XParameter[] Params = ServerReg.Parameters("uri");

            try
            {
                IEnumerable <string> Servers = X.Call <IEnumerable <string> >(XProto.ServerSelector, "ExtractList", e.ResponseString);

                SC = Servers.Remap(x =>
                {
                    string[] s = x.Split(new char[] { ',' });
                    return(new ServerChoice(s[0], s[1]));
                });

                var j = Task.Run(async() =>
                {
                    await X.Call <Task>(XProto.ServerSelector, "ProcessList", Servers);

                    foreach (ServerChoice C in SC)
                    {
                        C.Preferred = X.Static <IEnumerable <Weight <string> > >(XProto.ServerSelector, "ServerList").Any(x =>
                        {
                            if (x.Freight == C.Name)
                            {
                                C.Desc = x.Factor + "";
                                return(true);
                            }

                            return(false);
                        });

                        C.IsLoading = false;
                    }
                });
            }
            catch (Exception ex)
            {
                Logger.Log(ID, ex.Message, LogType.ERROR);
            }

            Worker.UIInvoke(() => AvailableServers.ItemsSource = SC);
        }
Esempio n. 9
0
 private void ProcessInbox(DRequestCompletedEventArgs e, string QId)
 {
     try
     {
         JsonObject JDef  = JsonStatus.Parse(e.ResponseString);
         JsonArray  JData = JDef.GetNamedArray("data");
         foreach (JsonValue JItem in JData)
         {
             InboxMessage BoxMessage = new InboxMessage(JItem.GetObject());
             Member.Activities.AddUI(new Activity(BoxMessage.Name, BoxMessage.OpenComment)
             {
                 TimeStamp = BoxMessage.TimeStamp
             });
         }
     }
     catch (Exception)
     {
     }
 }
Esempio n. 10
0
 private void ReportSuccess(DRequestCompletedEventArgs e, string Id)
 {
     try
     {
         JsonStatus.Parse(e.ResponseString);
         new RuntimeCache().POST(
             Shared.ShRequest.Server
             , Shared.ShRequest.Search("uuid: " + Id, 0, 1)
             // Pass the uuid instead of the query id
             , (re, q) => MessageBus.Send(GetType(), AppKeys.HS_REPORT_SUCCESS, new Tuple <string, DRequestCompletedEventArgs>(Id, re))
             , GR.GSystem.Utils.DoNothing
             , true
             );
     }
     catch (Exception ex)
     {
         MessageBus.Send(GetType(), AppKeys.HS_REPORT_FAILED, new Tuple <string, string>(Id, ex.Message));
     }
 }
Esempio n. 11
0
 private void SaveIntro(DRequestCompletedEventArgs e, string id)
 {
     CurrentBook.Intro = Shared.Conv.Chinese.Translate(e.ResponseString);
 }
Esempio n. 12
0
 private void DownloadComplete(DRequestCompletedEventArgs e, string Id)
 {
     BindItem.SetScriptData(e.ResponseString);
 }