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
        public SharersHub()
        {
            Activities = new ObservableCollection<Activity>();
            SearchSet = new Observables<HubScriptItem, HubScriptItem>();

            RCache = new RuntimeCache();
            Grants = new SHGrant[ 0 ];
            Member = X.Singleton<IMember>( XProto.SHMember );
            Member.OnStatusChanged += Member_OnStatusChanged;

            MessageBus.OnDelivery += MessageBus_OnDelivery;

            SearchSet.LoadStart += ( s, e ) => { Searching = true; };
            SearchSet.LoadEnd += ( s, e ) => { Searching = false; };

            UpdateLLText();
        }
Esempio n. 3
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 )
                {
                    AddActivity( () =>
                    {
                        StringResources stx = new StringResources();
                        return string.Format( stx.Text( "GrantsReceived" ), NGrants, NScripts );
                    }, () => MessageBus.SendUI( typeof( SharersHub ), AppKeys.SH_SHOW_GRANTS ) );
                }
            }
            catch ( Exception ex )
            {
                Logger.Log( ID, ex.Message, LogType.WARNING );
            }
        }