/// <summary> /// Imports records from source database to target database/template /// </summary> /// <param name="selectedNids"></param> /// <param name="allSelected">Set true to import all records</param> public override void ImportValues(List<string> SelectedNids, bool allSelected) { DataRow Row; FootnoteInfo FootnoteRecord = null; FootnoteBuilder FootnoteBuilderObj = null; int ProgressBarValue = 0; try { //import selected footnotes foreach (string Nid in SelectedNids) { try { Row = this.SourceTable.Select(this.TagValueColumnName + "=" + Nid)[0]; //import footnote FootnoteRecord = new FootnoteInfo(); FootnoteRecord.Name = Convert.ToString(Row[FootNotes.FootNote]); FootnoteRecord.Nid = Convert.ToInt32(Row[FootNotes.FootNoteNId]); FootnoteRecord.GID = Convert.ToString(Row[FootNotes.FootNoteGId]); FootnoteBuilderObj = new FootnoteBuilder(this._TargetDBConnection, this._TargetDBQueries); FootnoteBuilderObj.CheckNCreateFoonote(FootnoteRecord); //FootnoteBuilderObj.ImportFootnote(FootnoteRecord, Convert.ToInt32(Nid), this.SourceDBQueries, this.SourceDBConnection); } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } this.RaiseIncrementProgessBarEvent(ProgressBarValue); ProgressBarValue++; } } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } }
private void InsertNewFootNotes() { String SqlQuery = string.Empty; DataTable NewFootnotes; DataTable TempFootnotesTable; FootnoteBuilder DIFootNote; FootnoteInfo DIFootNoteInfo; int NewNid; Dictionary<string, int> InsertedFootnotes = new Dictionary<string, int>(); string FootnoteText = string.Empty; try { // 1. Update special quotes in FootNotes // as replace function does not work with ADO.net so first get the special foonote with quotes and then update footnote text one by one. if (this.DBConnection.ConnectionStringParameters.ServerType == DIServerType.MsAccess) { TempFootnotesTable = this.DBConnection.ExecuteDataTable(this.DAQuery.GetFootnoteTextWSpecialQuotesFrmTempDataTbl()); //update footnote text foreach (DataRow Row in TempFootnotesTable.Rows) { this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateSpecialInFootnoteText(Convert.ToString(Row[FootNotes.FootNote]), Convert.ToString(Row[Data.DataNId]))); } } //this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateFootNoteNid()); // 2. Get new FootNotes from Temp_Data table which are not in UT_FootNotes Table. //NewFootnotes = this.DBConnection.ExecuteDataTable(this.DAQuery.GetNewFootNotes()); NewFootnotes = this.DBConnection.ExecuteDataTable(this.DAQuery.GetFootNotesFrmTempDataTable()).DefaultView.ToTable(true, DAImportCommon.Constants.FootNoteColumnName); // 3. Insert FootNotes from TempData Table into UT_FootNote DIFootNote = new FootnoteBuilder(this.DBConnection, this.DBQueries); foreach (DataRow SourceRow in NewFootnotes.Rows) { FootnoteText = Lib.DI_LibBAL.Utility.DICommon.RemoveQuotes(Convert.ToString(SourceRow[DAImportCommon.Constants.FootNoteColumnName])); if (!InsertedFootnotes.ContainsKey(FootnoteText) && !string.IsNullOrEmpty(FootnoteText)) { DIFootNoteInfo = new FootnoteInfo(); DIFootNoteInfo.Name = FootnoteText; NewNid = DIFootNote.CheckNCreateFoonote(DIFootNoteInfo); if (NewNid > 0) { InsertedFootnotes.Add(FootnoteText, NewNid); // 4. Update FootNotes Nid in Temp_Data. this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateFootNoteNid(NewNid, FootnoteText)); } } } //////// 4. Update FootNotes Nid in Temp_Data. //////this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateFootNoteNid()); // 5. Update FootNote Nid = -1 where FootNote is blank. this.DBConnection.ExecuteNonQuery(this.DAQuery.UpdateNidForEmptyFootNote()); } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } }