Example #1
0
        /// <summary>
        /// Hangfire job to do the data import tasks.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="seniorityScoringRules"></param>
        /// <param name="connectionstring"></param>
        /// <param name="fileLocation"></param>
        public static void ImportJob(PerformContext context, string seniorityScoringRules, string connectionstring, string fileLocation)
        {
            // open a connection to the database.
            DbContextOptionsBuilder <DbAppContext> options = new DbContextOptionsBuilder <DbAppContext>();

            options.UseNpgsql(connectionstring);

            DbAppContext dbContext = new DbAppContext(null, options.Options);

            context.WriteLine("Starting Data Import Job");

            // adding system Account if not there in the database
            ImportUtility.InsertSystemUser(dbContext, SystemId);

            //*** Import Service Areas from ServiceArea.xml (HET_SERVICE_AREA)
            dbContext = new DbAppContext(null, options.Options);
            ImportServiceArea.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Local Areas from Area.xml (HET_LOCAL_AREA)
            dbContext = new DbAppContext(null, options.Options);
            ImportLocalArea.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Cities from HETS_City.xml (HET_CITY)
            dbContext = new DbAppContext(null, options.Options);
            ImportCity.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Users from User_HETS.xml (HET_USER and HET_USER_ROLE)
            dbContext = new DbAppContext(null, options.Options);
            ImportUser.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Owners from Owner.xml (HETS_OWNER and HETS_Contact)
            dbContext = new DbAppContext(null, options.Options);
            ImportOwner.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Equipment Type from EquipType.xml (HET_EQUIPMENT_TYPE)
            dbContext = new DbAppContext(null, options.Options);
            ImportEquipmentType.Import(context, dbContext, fileLocation, SystemId);

            //*** Import District Equipment Type from EquipType.xml (HET_DISTRICT_EQUIPMENT_TYPE)
            dbContext = new DbAppContext(null, options.Options);
            ImportDistrictEquipmentType.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Equipment from Equip.xml (HET_EQUIPMENT)
            dbContext = new DbAppContext(null, options.Options);
            ImportEquip.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Dump Truck from Dump_Truck.xml (HET_EQUIPMENT_TYPE)
            dbContext = new DbAppContext(null, options.Options);
            ImportDumpTruck.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Equipment Attachments from Equip_Attach.xml (HET_EQUIPMENT_ATTACHMENT)
            dbContext = new DbAppContext(null, options.Options);
            ImportEquipAttach.Import(context, dbContext, fileLocation, SystemId);

            //*** Process Equipment Block Assigments
            dbContext = new DbAppContext(null, options.Options);
            ImportEquip.ProcessBlocks(context, seniorityScoringRules, dbContext, SystemId);

            //*** Import Projects from Project.xml (HET_PROJECT)
            dbContext = new DbAppContext(null, options.Options);
            ImportProject.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Blocks / Local Area Rotation List from Block.xml (HET_DISTRICT_ROTATION_LIST)
            dbContext = new DbAppContext(null, options.Options);
            ImportBlock.Import(context, dbContext, fileLocation, SystemId);

            //*** Import Equipment Usage (Time) from Equip_Usage.xml (HET_RENTAL_AGREEMENT and HET_TIME_RECORD)
            dbContext = new DbAppContext(null, options.Options);
            ImportEquipUsage.Import(context, dbContext, fileLocation, SystemId);

            // *** Fix Contact Foreign Key Relationships
            dbContext = new DbAppContext(null, options.Options);
            ImportOwner.FixPrimaryContacts(context, dbContext);

            // *** Final Step - fix the database sequences
            dbContext = new DbAppContext(null, options.Options);
            ImportServiceArea.ResetSequence(context, dbContext);
            ImportLocalArea.ResetSequence(context, dbContext);
            ImportCity.ResetSequence(context, dbContext);
            ImportUser.ResetSequence(context, dbContext);
            ImportOwner.ResetSequence(context, dbContext);
            ImportEquipmentType.ResetSequence(context, dbContext);
            ImportDistrictEquipmentType.ResetSequence(context, dbContext);
            ImportEquip.ResetSequence(context, dbContext);
            ImportEquipAttach.ResetSequence(context, dbContext);
            ImportProject.ResetSequence(context, dbContext);
            ImportBlock.ResetSequence(context, dbContext);
            ImportEquipUsage.ResetSequence(context, dbContext);
        }
Example #2
0
        /// <summary>
        /// Hangfire job to do the Annual Rollover tasks.
        /// </summary>
        /// <param name="connectionstring"></param>
        static public void ImportJob(PerformContext context, string connectionstring, string fileLocation)
        {
            // open a connection to the database.
            DbContextOptionsBuilder <DbAppContext> options = new DbContextOptionsBuilder <DbAppContext>();

            options.UseNpgsql(connectionstring);

            DbAppContext dbContext = new DbAppContext(null, options.Options);

            context.WriteLine("Starting Data Import Job");

            //Adding system Account if not there in the database.
            InsertSystemUser(dbContext);

            //*** start by importing Region from Region.xml. THis goes to table HETS_REGION
            // ImportRegion.Import(context, dbContext, fileLocation, systemId);

            //*** start by importing districts from District.xml. THis goes to table HETS_DISTRICT
            // dbContext = new DbAppContext(null, options.Options);
            // ImportDistrict.Import(context, dbContext, fileLocation, systemId);

            //*** start by importing Cities from HETS_City.xml to HET_CITY
            //dbContext = new DbAppContext(null, options.Options);
            // ImportCity.Import(context, dbContext, fileLocation, systemId);

            //*** Service Areas: from the file of Service_Area.xml to the table of HET_SERVICE_AREA
            //dbContext = new DbAppContext(null, options.Options);
            // ImportServiceArea.Import(context, dbContext, fileLocation, systemId);

            //############################ We start here #####################################
            //*** Importing the Local Areas from the file of Area.xml to the table of HET_LOCAL_AREA
            dbContext = new DbAppContext(null, options.Options);
            ImportLocalArea.Import(context, dbContext, fileLocation, systemId);

            //*** Users from User_HETS.xml. This has effects on Table HET_USER and HET_USER_ROLE
            dbContext = new DbAppContext(null, options.Options);
            ImportUser.Import(context, dbContext, fileLocation, systemId);

            //*** Owners: This has effects on Table HETS_OWNER and HETS_Contact
            dbContext = new DbAppContext(null, options.Options);
            ImportOwner.Import(context, dbContext, fileLocation, systemId);

            //*** Import Dump_Truck  from Dump_Truck.xml
            dbContext = new DbAppContext(null, options.Options);
            ImportProject.Import(context, dbContext, fileLocation, systemId);

            //*** Import Equiptment type from EquipType.xml This has effects on Table HET_USER and HET_EQUIPMENT_TYPE
            dbContext = new DbAppContext(null, options.Options);
            ImportDisEquipType.Import(context, dbContext, fileLocation, systemId);

            //*** Import Equiptment  from Equip.xml  This has effects on Table HET_USER and HET_EQUIP
            dbContext = new DbAppContext(null, options.Options);
            ImportEquip.Import(context, dbContext, fileLocation, systemId);

            //*** Import Dump_Truck  from Dump_Truck.xml
            dbContext = new DbAppContext(null, options.Options);
            ImportDumpTruck.Import(context, dbContext, fileLocation, systemId);

            var watch = System.Diagnostics.Stopwatch.StartNew();

            //*** Import Equipment_Attached  from Equip_Attach.xml
            dbContext = new DbAppContext(null, options.Options);
            ImportEquipAttach.Import(context, dbContext, fileLocation, systemId);


            //*** Import the table of "HET_DISTRICT_EQUIPMENT_TYPE"  from Block.xml
            dbContext = new DbAppContext(null, options.Options);
            ImportBlock.Import(context, dbContext, fileLocation, systemId);
            watch.Stop();
            var elapsedMs = watch.ElapsedMilliseconds;

            Console.WriteLine(elapsedMs.ToString());

            //*** Import the table of  "HET_RENTAL_AGREEMENT" and "HET_TIME_RECORD";  from Equip_Usage.xml
            dbContext = new DbAppContext(null, options.Options);
            ImportEquipUsage.Import(context, options, dbContext, fileLocation, systemId);

            //*** Import the table of  "HET_RENTAL_AGREEMENT" and "HET_TIME_RECORD";  from Equip_Usage.xml
            dbContext = new DbAppContext(null, options.Options);
            ImportRotation.Import(context, dbContext, fileLocation, systemId);
        }
Example #3
0
        /// <summary>
        /// Hangfire job to do the data import tasks.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="connectionstring"></param>
        /// <param name="sourceFileLocation"></param>
        /// <param name="destinationFileLocation"></param>
        public static void ObfuscationJob(PerformContext context, string connectionstring, string sourceFileLocation, string destinationFileLocation)
        {
            // open a connection to the database.
            DbContextOptionsBuilder <DbAppContext> options = new DbContextOptionsBuilder <DbAppContext>();

            options.UseNpgsql(connectionstring);

            DbAppContext dbContext = new DbAppContext(null, options.Options);

            context.WriteLine("Starting Data Import Job");

            // adding system Account if not there in the database
            ImportUtility.InsertSystemUser(dbContext, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process service areas
            ImportServiceArea.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process local areas
            ImportLocalArea.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process local areas
            ImportCity.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process users
            ImportUser.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // process owners
            ImportOwner.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // process equipment
            ImportEquipmentType.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // process equipment
            ImportEquip.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // process dump trucks
            ImportDumpTruck.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process equipment attachments
            ImportEquipAttach.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process projects
            ImportProject.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process blocks
            ImportBlock.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
            dbContext = new DbAppContext(null, options.Options);

            // Process equipment usage
            ImportEquipUsage.Obfuscate(context, dbContext, sourceFileLocation, destinationFileLocation, SystemId);
        }