Ejemplo n.º 1
0
        /// <summary>
        ///     Copies the value click.
        /// </summary>
        /// <param name="app">The application.</param>
        private void CopyValueClick(AppLibraryApp app)
        {
            RetryHandler.Retry(() =>
            {
                Clipboard.SetData(DataFormats.Text, app.PackageId.ToString("B"));

                PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Value copied to clipboard...", 2000).ToString( ));
            }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e));
        }
Ejemplo n.º 2
0
        /// <summary>
        ///     Copies the click.
        /// </summary>
        /// <param name="app">The application.</param>
        private void CopyClick(AppLibraryApp app)
        {
            const string format = @"Application:           {0}
Application Entity Id: {1}
Package Id:            {2}
Package Entity Id:     {3}
Version:               {4}
Application Id:        {5}
Publisher:             {6}
Publisher Url:         {7}
Release Date:          {8}";

            RetryHandler.Retry(() =>
            {
                Clipboard.SetData(DataFormats.Text, string.Format(format, app.Application, app.ApplicationEntityId, app.PackageId.ToString("B"), app.PackageEntityId, app.Version, app.ApplicationId.ToString("B"), app.Publisher, app.PublisherUrl, app.ReleaseDate));

                PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Data copied to clipboard...", 2000).ToString( ));
            }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e));
        }
Ejemplo n.º 3
0
        /// <summary>
        ///     Loads the applications.
        /// </summary>
        private void LoadApplications( )
        {
            var databaseManager = new DatabaseManager(PluginSettings.DatabaseSettings);

            const string commandText = @"--ReadiMon - LoadApplications
SET NOCOUNT ON

DECLARE @isOfType BIGINT = dbo.fnAliasNsId( 'isOfType', 'core', DEFAULT )
DECLARE @app BIGINT = dbo.fnAliasNsId( 'app', 'core', DEFAULT )
DECLARE @name BIGINT = dbo.fnAliasNsId( 'name', 'core', DEFAULT )
DECLARE @packageForApplication BIGINT = dbo.fnAliasNsId( 'packageForApplication', 'core', DEFAULT )
DECLARE @appVersionString BIGINT = dbo.fnAliasNsId( 'appVersionString', 'core', DEFAULT )
DECLARE @appVerId BIGINT = dbo.fnAliasNsId( 'appVerId', 'core', DEFAULT )
DECLARE @applicationId BIGINT = dbo.fnAliasNsId( 'applicationId', 'core', DEFAULT )


SELECT
	Application = x.Application,
	ApplicationEntityId = x.ApplicationId,
	PackageId = pid.Data,
	PackageEntityId = p.PackageId,
	Version = p.Version,
	ApplicationId = aid.Data,
	Publisher = p1.Data,
	PublisherUrl = u.Data,
	ReleaseDate = c.Data
FROM
	(
	SELECT
		Application = n.Data,
		ApplicationId = n.EntityId
	FROM
		Relationship r
	JOIN
		Data_NVarChar n ON
			n.TenantId = r.TenantId
			AND r.FromId = n.EntityId
			AND n.FieldId = @name
	WHERE
		r.TenantId = 0
		AND r.TypeId = @isOfType
		AND r.ToId = @app
	) x
JOIN
(
	SELECT
		dt.PackageId,
		dt.ApplicationId,
		dt.Version,
		dt.RowNumber
	FROM
	(
		SELECT
			ROW_NUMBER( ) OVER
			(
				PARTITION BY
					r.ToId
				ORDER BY
					CAST( '/' + REPLACE( dbo.fnSanitiseVersion( v.Data ), '.', '/' ) + '/' AS HIERARCHYID ) DESC
			) AS 'RowNumber',
			PackageId = r.FromId,
			ApplicationId = r.ToId,
			Version = v.Data
		FROM
			Relationship r
		JOIN
			Data_NVarChar v ON
				v.TenantId = r.TenantId
				AND v.EntityId = r.FromId
				AND r.TypeId = @packageForApplication
				AND	v.FieldId = @appVersionString
		WHERE
			r.TenantId = 0
	) dt
) p ON
	x.ApplicationId = p.ApplicationId
JOIN
	Data_Guid pid ON
		pid.TenantId = 0
		AND pid.EntityId = p.PackageId
		AND	pid.FieldId = @appVerId
JOIN
	Data_Guid aid ON
		aid.TenantId = 0
		AND aid.EntityId = x.ApplicationId
		AND	aid.FieldId = @applicationId
LEFT JOIN
(
	SELECT
		p.EntityId,
		p.Data
	FROM
		Data_NVarChar p
	JOIN
		Data_Alias ap ON
			ap.TenantId = p.TenantId
			AND ap.EntityId = p.FieldId
			AND	ap.Data = 'publisher'
			AND	ap.Namespace = 'core'
	WHERE
		p.TenantId = 0
) p1 ON
	x.ApplicationId = p1.EntityId
LEFT JOIN
(
	SELECT
		u.EntityId,
		u.Data
	FROM
		Data_NVarChar u
	JOIN
		Data_Alias au ON
			au.TenantId = u.TenantId
			AND u.FieldId = au.EntityId
			AND au.Data = 'publisherUrl'
			AND	au.Namespace = 'core'
	WHERE
		u.TenantId = 0
) u ON
	x.ApplicationId = u.EntityId
LEFT JOIN
(
	SELECT
		c.EntityId,
		c.Data
	FROM
		Data_DateTime c
	JOIN
		Data_Alias ac ON
			ac.TenantId = c.TenantId
			AND ac.EntityId = c.FieldId
			AND ac.Data = 'releaseDate'
			AND	ac.Namespace = 'core'
	WHERE
		c.TenantId = 0
) c ON
	x.ApplicationId = c.EntityId"    ;

            try
            {
                using (IDbCommand command = databaseManager.CreateCommand(commandText))
                {
                    using (IDataReader reader = command.ExecuteReader( ))
                    {
                        var appLibraryApps = new List <AppLibraryApp>( );

                        HashSet <string> applications  = new HashSet <string>( );
                        HashSet <string> versions      = new HashSet <string>( );
                        HashSet <string> publishers    = new HashSet <string>( );
                        HashSet <string> publisherUrls = new HashSet <string>( );

                        Dictionary <Guid, AppLibraryApp> map = new Dictionary <Guid, AppLibraryApp>( );

                        do
                        {
                            while (reader.Read( ))
                            {
                                var application         = reader.GetString(0, "Unnamed");
                                var applicationEntityId = reader.GetInt64(1, -1);
                                var packageId           = reader.GetGuid(2);
                                var packageEntityId     = reader.GetInt64(3, -1);
                                var version             = reader.GetString(4, "");
                                var applicationId       = reader.GetGuid(5);
                                var publisher           = reader.GetString(6, "");
                                var publisherUrl        = reader.GetString(7, "");
                                var releaseDate         = reader.GetDateTime(8, DateTime.MinValue);

                                var appLibraryApp = new AppLibraryApp(application, applicationEntityId, packageId, packageEntityId, version, applicationId, publisher, publisherUrl, releaseDate);

                                if (LatestVersionsOnly)
                                {
                                    AppLibraryApp existingApp;

                                    if (map.TryGetValue(applicationId, out existingApp))
                                    {
                                        if (!string.IsNullOrEmpty(existingApp?.Version))
                                        {
                                            Version existingVersion;
                                            Version thisVersion;

                                            if (Version.TryParse(existingApp.Version, out existingVersion) && Version.TryParse(appLibraryApp.Version, out thisVersion))
                                            {
                                                if (thisVersion > existingVersion)
                                                {
                                                    map[applicationId] = appLibraryApp;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        map[applicationId] = appLibraryApp;
                                    }
                                }
                                else
                                {
                                    appLibraryApps.Add(appLibraryApp);
                                }
                            }
                        }while (reader.NextResult( ));

                        AppLibraryApps = LatestVersionsOnly ? map.Values.OrderBy(x => x.Application).ToList( ) : appLibraryApps.OrderBy(x => x.Application).ToList( );

                        applications.UnionWith(AppLibraryApps.Select(a => a.Application));
                        versions.UnionWith(AppLibraryApps.Select(a => a.Version));
                        publishers.UnionWith(AppLibraryApps.Select(a => a.Publisher));
                        publisherUrls.UnionWith(AppLibraryApps.Select(a => a.PublisherUrl));

                        ApplicationFilters = new List <FilterObject>( );

                        foreach (string sol in applications.OrderBy(k => k))
                        {
                            ApplicationFilters.Add(new FilterObject(sol, string.IsNullOrEmpty(sol) ? "<empty>" : sol, true, ApplicationFilterUpdate));
                        }

                        OnPropertyChanged("ApplicationFilters");

                        VersionFilters = new List <FilterObject>( );

                        foreach (string ver in versions.OrderBy(k => k))
                        {
                            VersionFilters.Add(new FilterObject(ver, string.IsNullOrEmpty(ver) ? "<empty>" : ver, true, VersionFilterUpdate));
                        }

                        OnPropertyChanged("VersionFilters");

                        PublisherFilters = new List <FilterObject>( );

                        foreach (string pub in publishers.OrderBy(k => k))
                        {
                            PublisherFilters.Add(new FilterObject(pub, string.IsNullOrEmpty(pub) ? "<empty>" : pub, true, PublisherFilterUpdate));
                        }

                        OnPropertyChanged("PublisherFilters");

                        PublisherUrlFilters = new List <FilterObject>( );

                        foreach (string puburl in publisherUrls.OrderBy(k => k))
                        {
                            PublisherUrlFilters.Add(new FilterObject(puburl, string.IsNullOrEmpty(puburl) ? "<empty>" : puburl, true, PublisherUrlFilterUpdate));
                        }

                        OnPropertyChanged("PublisherUrlFilters");

                        FilteredAppLibraryApps = new List <AppLibraryApp>(AppLibraryApps);
                    }
                }
            }
            catch (Exception exc)
            {
                PluginSettings.EventLog.WriteException(exc);
            }
        }