/// <summary> /// Check existance of footnote record into database if false then create footnote record /// </summary> /// <param name="footnoteInfo">object of FootnoteInfo</param> /// <returns>Footnote Nid</returns> public int CheckNCreateFoonote(FootnoteInfo footnoteInfo) { int RetVal = 0; try { // check footnote exists or not RetVal = this.CheckFootnoteExists(footnoteInfo); // if footnote does not exist then create it. if (RetVal <= 0) { // insert footnote if (this.InsertIntoDatabase(footnoteInfo)) { RetVal = this.GetNidByName(footnoteInfo.Name); } } // add footnote information into collection footnoteInfo.Nid = RetVal; this.AddFootnoteIntoCollection(footnoteInfo); } catch (Exception) { RetVal = 0; } return RetVal; }
/// <summary> /// Check existance of footnote record into database if false then create footnote record /// </summary> /// <param name="footnote">Footnote</param> /// <returns>Footnote Nid</returns> public int CheckNCreateFoonote(string footnote) { int RetVal = 0; FootnoteInfo FootnoteObj = new FootnoteInfo(); FootnoteObj.Name = footnote; RetVal= this.CheckNCreateFoonote(FootnoteObj); return RetVal; }
/// <summary> /// To check existance of Footnote first into collection then into database /// </summary> /// <param name="footnoteInfo">object of FootnoteInfo</param> /// <returns>Footnote Nid</returns> public int CheckFootnoteExists(FootnoteInfo footnoteInfo) { int RetVal = 0; //Step 1: check source exists in source collection RetVal = this.CheckFootnoteInCollection(footnoteInfo.Name); //Step 2: check footnote exists in database. if (RetVal <= 0) { RetVal = this.GetFootnoteNid(footnoteInfo.GID, footnoteInfo.Name); } return RetVal; }
/// <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); } }
/// <summary> /// Insert Footnote record into database /// </summary> /// <param name="footnoteInfo">object of FootnoteInfo</param> /// <returns>Ture/False. Return true after successful insertion otherwise false</returns> private bool InsertIntoDatabase(FootnoteInfo footnoteInfo) { bool RetVal = false; string Footnote = footnoteInfo.Name; string FootnoteGId = Guid.NewGuid().ToString(); string LanguageCode = string.Empty; string DefaultLanguageCode = string.Empty; string FootnoteForDatabase = string.Empty; try { DefaultLanguageCode = this.DBQueries.LanguageCode; //replace GID only if given gid is not empty or null. if (!string.IsNullOrEmpty(footnoteInfo.GID)) { FootnoteGId = footnoteInfo.GID; } foreach (DataRow languageRow in this.DBConnection.DILanguages(this.DBQueries.DataPrefix).Rows) { LanguageCode = languageRow[Language.LanguageCode].ToString(); if (LanguageCode == DefaultLanguageCode.Replace("_", String.Empty)) { FootnoteForDatabase = Footnote; } else { FootnoteForDatabase = Constants.PrefixForNewValue + Footnote; } this.DBConnection.ExecuteNonQuery(DevInfo.Lib.DI_LibDAL.Queries.Footnote.Insert.InsertFootnote(this.DBQueries.DataPrefix,"_" + LanguageCode,FootnoteForDatabase ,FootnoteGId)); } RetVal = true; } catch (Exception) { RetVal = false; } return RetVal; }
/// <summary> ///To add footnoteInfo into collection /// </summary> /// <param name="footnoteInfo">object of FootnoteInfo</param> private void AddFootnoteIntoCollection(FootnoteInfo footnoteInfo) { if (!this.FootnoteCollection.ContainsKey(footnoteInfo.Name)) { this.FootnoteCollection.Add(footnoteInfo.Name, footnoteInfo); } }
/// <summary> ///Update FootNotes /// </summary> /// <param name="notesClassInfo"></param> /// <returns >Count Of Records Updated</returns> public int UpdateFootNotes(FootnoteInfo footnoteInfo) { int RetVal = 0; string SqlQuery = string.Empty; try { SqlQuery = DevInfo.Lib.DI_LibDAL.Queries.Footnote.Update.UpdateFootnote(this.DBQueries.TablesName.FootNote, footnoteInfo.Nid , footnoteInfo.Name ); RetVal = this.DBConnection.ExecuteNonQuery(SqlQuery); } catch (Exception ex) { ExceptionHandler.ExceptionFacade.ThrowException(ex); } return RetVal; }
/// <summary> /// Imports footnotes from source database into current template or database /// </summary> /// <param name="footnoteInfo"></param> /// <param name="NidInSourceDB"></param> /// <param name="sourceQurey"></param> /// <param name="sourceDBConnection"></param> /// <returns></returns> public int ImportFootnote(FootnoteInfo footnoteInfo, int NidInSourceDB, DIQueries sourceQurey, DIConnection sourceDBConnection) { int RetVal = -1; Dictionary<String, String> OldIconNId_NewIconNId = new Dictionary<string, string>(); try { //check footnote already exists in database or not RetVal = this.GetFootnoteNid("", footnoteInfo.Name); if (RetVal > 0) { // NA } else { RetVal = this.CheckNCreateFoonote(footnoteInfo); } } catch (Exception ex) { throw new ApplicationException(ex.Message); } return RetVal; }
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); } }