Example #1
0
        /// <summary>
        /// Create tables used for installation
        /// </summary>
        /// <param name="level"></param>
        /// <param name="worker"></param>
        public static void CreateTable(Level level, BackgroundTask worker)
        {
            Type[]   baiscTypes    = CreateBasicTable();
            Assembly basicAssembly = baiscTypes[0].Assembly;

            Assembly[] assemblies = SysExtension.GetInstalledAssemblies();

            int i = 0;

            foreach (Assembly asm in assemblies)
            {
                MessageBuilder messages = new MessageBuilder();
                foreach (Type type in asm.GetTypes())
                {
                    if (type.BaseType != typeof(DPObject))
                    {
                        continue;
                    }

                    if (asm == basicAssembly && Array.IndexOf(baiscTypes, type) >= 0)
                    {
                        continue;
                    }

                    TableAttribute[] A = type.GetAttributes <TableAttribute>();
                    if (A.Length == 0)
                    {
                        continue;
                    }


                    if (A[0].Level == level)
                    {
                        messages.AddRange(CreateTable(type));
                    }
                }

                worker.ReportProgress((int)(i * 100.0 / assemblies.Length), messages.ToString());
                i++;
            }
        }
Example #2
0
        public static void Unpack(Level level, BackgroundTask worker, bool insert)
        {
            SqlTrans transaction = new SqlTrans();

            Assembly[] assemblies = SysExtension.GetInstalledAssemblies();

            int i = 0;

            foreach (Assembly asm in assemblies)
            {
                int progress = (int)(i * 100.0 / assemblies.Length);
                worker.SetProgress(progress, 0, asm.GetName().Name);

                Unpack(level, asm, worker, transaction, insert);

                i++;
            }

            transaction.Commit();

            return;
        }