Ejemplo n.º 1
0
        /// <summary>
        /// Creates the database schema for a <see cref="DynamicTarget"/>
        /// </summary>
        /// <returns></returns>
        public override int Create()
        {
            try
            {
                var dynamicTarget = Target as DynamicTarget;
                if (dynamicTarget == null)
                {
                    return(0);
                }

                // create table for target type
                SchemaBuilder.CreateTable(dynamicTarget.DbSchemaName, table => table
                                          .DatasetRecord()
                                          .DatasetReferenceRecord()
                                          .AddColumns(dynamicTarget.Columns.ToArray())
                                          );
                // create FK to datasets table
                SchemaBuilder.CreateForeignKey(
                    string.Format("FK_{0}_Datasets", dynamicTarget.DbSchemaName),
                    dynamicTarget.DbSchemaName,
                    new[] { "Dataset_id" },
                    typeof(Dataset).GetCustomAttribute <EntityTableNameAttribute>().TableName,
                    new[] { "Id" });
            }
            catch (Exception exc)
            {
                SessionLogger.Write(exc);
                return(0);
            }

            return(1);
        }
 /// <summary>
 /// Attach a navigation failed event handler to every region
 /// </summary>
 /// <param name="regions"></param>
 private void MonitorRegions(IEnumerable <IRegion> regions)
 {
     foreach (var region in regions)
     {
         Debug.WriteLine("RegionNavigationService: {0:X}", region.NavigationService.GetHashCode()); // prove that they're all unique
         var r = region;
         region.NavigationService.NavigationFailed += (s, e) =>
         {
             var msg = $"Error navigating to view {e.NavigationContext.Uri} for region {r.Name}";
             SessionLogger.Write(e.Error, msg);
             EventManager.GetEvent <GenericNotificationEvent>().Publish(msg);
         };
         region.NavigationService.Navigating += (s, e) =>
         {
             SessionLogger.Debug("Loading view: '{1}' for region '{0}'", r.Name,
                                 e.NavigationContext.Uri);
         };
         region.NavigationService.Navigated += (s, e) =>
         {
             SessionLogger.Debug("Loading complete: view '{1}' for region '{0}'", r.Name,
                                 e.NavigationContext.Uri);
         };
     }
 }
Ejemplo n.º 3
0
        //private void DatabaseNotRecognized()
        //{
        //    AppendLog("Database not recognized.");
        //    AbortImport();
        //}

        /// <summary>
        /// Appends the log.
        /// </summary>
        /// <param name="message">The message.</param>
        void AppendLog(string message)
        {
            LogFile.Add(message);
            _sessionLogger.Write(message);
            System.Windows.Forms.Application.DoEvents();
        }