コード例 #1
0
        /// <summary>
        /// Raises the <see cref="E:System.Drawing.Printing.PrintDocument.BeginPrint"></see> event. It is called after the <see cref="M:System.Drawing.Printing.PrintDocument.Print"></see> method is called and before the first page of the document prints.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Drawing.Printing.PrintEventArgs"></see> that contains the event data.</param>
        protected override void OnBeginPrint(System.Drawing.Printing.PrintEventArgs e)
        {
            _taskActivities = TaskActivitiesProvider.RollupByTaskDescription(Config.Activities);
            _start          = Config.Start;
            _end            = Config.End;
            _fontHeight     = SystemFonts.DefaultFont.Height + 4;
            _totalDuration  = 0;

            base.OnBeginPrint(e);
        }
コード例 #2
0
 /// <summary>
 /// When overridden in a provider, it discovers the date metrics stored in the users data area.
 /// </summary>
 /// <param name="question">The question.</param>
 /// <returns></returns>
 protected override Collection<System.DateTime> ProviderDiscoverDateMetrics(TaskActivitiesProvider.MetricQuestion question)
 {
     Collection<System.DateTime> dates = new Collection<System.DateTime>();
     using (SqlConnection connection = new SqlConnection(_connectionString))
     {
         connection.Open();
         SqlCommand command = new SqlCommand(discoverDateMetricsStatement, connection);
         command.CommandType = System.Data.CommandType.StoredProcedure;
         command.Parameters.AddWithValue("@UserId", Engine.IdentityProvider.Principal.Identity.Name);
         command.Parameters.AddWithValue("@Question", question.ToString());
         SqlDataReader reader = command.ExecuteReader();
         while (reader.Read())
         {
             DateTime date = reader.GetDateTime(0);
             dates.Add(date);
         }
     }
     return dates;
 }
コード例 #3
0
        /// <summary>
        /// Initalises the engine.
        /// </summary>
        private void InitaliseEngine()
        {
            LicenseManagement();

            _heartbeatTimer = new System.Timers.Timer
            {
                Enabled  = false,
                Interval = int.Parse(Properties.Resources.HeartbeatInterval)
            };
            _heartbeatTimer.Elapsed += InternalHeartbeatTimerElapsed;
            _nagTimer = new System.Timers.Timer
            {
                Enabled = false
            };
            _nagTimer.Elapsed += InternalNagTimerElapsed;

            _appFolder = (new FileInfo(Assembly.GetExecutingAssembly().Location)).Directory;

            _dataFolder = new DirectoryInfo(System.Windows.Forms.Application.UserAppDataPath);
            if (_dataFolder.Exists == false)
            {
                _dataFolder.Create();
                _dataFolder.Refresh();
            }

            //Read Provider Configuration
            if (ConfigurationManager.GetSection(ConfigurationSection.SectionName) is ConfigurationSection config)
            {
                if (config.Providers == null || config.Providers.Count == 0)
                {
                    Trace.TraceError(Properties.Resources.NoProvidersFoundInConfigurationFile);
                    throw new InvalidOperationException(Properties.Resources.NoProvidersFoundInConfigurationFile);
                }

                // The providers are created and initalised in a special order,
                // first is the
                // identity provider (work out who is using this application)
                _identityProvider =
                    InitializeProvider(config, "IdentityProvider") as IdentityProvider;
                _identityProvider.DiscoverIdentity();
                if (!_identityProvider.Principal.Identity.IsAuthenticated)
                {
                    Trace.TraceError(Properties.Resources.IdentityCouldNotBeEstablished);
                    throw new InvalidOperationException(Properties.Resources.IdentityCouldNotBeEstablished);
                }

                // Then comes the plugin provider
                _pluginsProvider =
                    InitializeProvider(config, "PluginsProvider") as PluginsProvider;
                _pluginsProvider.DiscoverPlugins();

                // then comes the TaskDescription and Task Activity providers
                _taskDescriptionsProvider =
                    InitializeProvider(config, "TaskDescriptionsProvider") as TaskDescriptionsProvider;
                _taskActivitiesProvider =
                    InitializeProvider(config, "TaskActivitiesProvider") as TaskActivitiesProvider;
                // The UI provider then gets created and initalised
                _uiProvider =
                    InitializeProvider(config, "UIProvider") as UIProvider;
                // Finnaly the Users memory provider
                _userMemoryProvider =
                    InitializeProvider(config, "UserMemoryProvider") as UserMemoryProvider;
            }
            else
            {
                Trace.TraceError(Properties.Resources.ConfigurationFileInvalid);
                throw new InvalidOperationException(Properties.Resources.ConfigurationFileInvalid);
            }

            Trace.TraceInformation("TaskClerkSDK:InitaliseEngine");
        }