protected void MakeComponents(DAL parentDB, int numComponents) { numComponents = Math.Min(numComponents, MAX_COMPONENTS); //start up the progress bar int totalSteps = numComponents + 4; View.InitializeAndShowProgress(totalSteps); if (!_doesMasterExist) { //initialize a master component file //create a master component by creating a copy of the parent parentDB.CopyTo(_masterPath); MasterDAL = new DAL(_masterPath); SetRowIDs(MAX_COMPONENTS + 1, MasterDAL); ////clean the master file, any field data from the original file will be removed //ClearFieldData(masterDAL); } View.StepProgressBar();///////////////////////////////////////////////// //insert component records into the master file List <ComponentDO> componentInfo = BuildMasterComponentTable(MasterDAL, numComponents); View.StepProgressBar();///////////////////////////////////////////////// int componentsCreated = 0; int curCompNum = 1; String saveDir = GetSaveDir(MasterDAL.Path); foreach (ComponentDO comp in componentInfo) { String compPath = string.Format("{0}\\{1}", saveDir, comp.FileName);//extrapolate the path of the comp file if (!File.Exists(compPath)) { CreateComponent(MasterDAL, curCompNum++, comp, compPath); componentsCreated++; } View.StepProgressBar();////////////////////////////////////////////// } //create count record copies in the master for each component MasterDAL.Execute(SQL.MAKE_COUNTS_FOR_COMPONENTS); View.StepProgressBar();///////////////////////////////////////////////// //add some meta data to the master GlobalsDO lastMergeEntry = new GlobalsDO(MasterDAL) { Block = "Comp", Key = "LastMerge", Value = string.Empty }; lastMergeEntry.Save(OnConflictOption.Ignore); GlobalsDO numCompEntry = new GlobalsDO(MasterDAL) { Block = "Comp", Key = "ChildComponents", Value = numComponents.ToString() }; numCompEntry.Save(OnConflictOption.Replace); View.StepProgressBar();///////////////////////////////////////////////// Analytics.TrackEvent(AnalyticsEvents.COMPONENTS_CREATE, new Dictionary <string, string>() { { nameof(numComponents), numComponents.ToString() }, { nameof(componentsCreated), componentsCreated.ToString() }, }); View.HideProgressBar(); }