示例#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++;

            }
        }
示例#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;
        }
示例#3
0
        private static void Unpack(Level level, Assembly asm, BackgroundTask worker, SqlTrans transaction, bool insert)
        {
            foreach (Type type in asm.GetExportedTypes())
            {
                if (type.HasInterface<IPacking>() && type != typeof(BasePackage<>))
                {
                    IPacking packing = (IPacking)Activator.CreateInstance(type);
                    if (level == packing.Level)
                    {
                        worker.SetProgress(0, string.Format("Unpacking #record={0} of table [{1}].", packing.Count, packing.TableName));
                        packing.Unpack(worker, transaction, insert);
                    }
                }
            }

            return;
        }