コード例 #1
0
  }//ConfigurationXml	 

  /// <summary>Scripture Reference URI.</summary>
  /// <param name="databaseConnectionString">The database connection string.</param>
  /// <param name="filenameConfigurationXml">The filename configuration Xml.</param>
  /// <param name="exceptionMessage">The exception message.</param>  
  /// <param name="dataSet">The dataset.</param>
  public static void ScriptureReferenceURI
  (
       string  databaseConnectionString,
       string  filenameConfigurationXml,
   ref string  exceptionMessage,
   ref DataSet dataSet
  )
  {
   bool                                         boolView                                  = false;
   
   int                                          columnIndexScriptureReference             = -1;
   
   string                                       dataColumnName                            = null;
   string                                       scriptureReferenceColumnValue             = null;
   string                                       scriptureReferenceColumnName              = null;
   string                                       scriptureReferenceColumnNameURI           = null;
   string                                       scriptureReferenceURI                     = null;   
   string[][]                                   scriptureReferenceArray                   = null;    
   string                                       columnNamePrimary                         = null;
   string                                       columnValuePrimary                        = null; 
   string                                       tableName                                 = null;
   
   ArrayList                                    scriptureReferenceSet                     = null;
   ArrayList                                    scriptureReferenceURISet                  = null;
   ScriptureReferenceBookChapterVersePrePost[]  scriptureReferenceBookChapterVersePrePost = null;
   StringBuilder                                columnSet                                 = null;   
   StringBuilder                                uriCrosswalkXml                           = null;
   StringBuilder                                uriCrosswalkHtml                          = null;   
   StringBuilder                                SQLStatement                              = null;      
   OleDbConnection                              oleDbConnection                           = null;
   XmlNodeList                                  scriptureReferenceColumnSet               = null;

   scriptureReferenceColumnSet = UtilityXml.SelectNodes
   (
        filenameConfigurationXml,
    ref exceptionMessage,
        XPathColumnScriptureReference
   );
   try
   {
    oleDbConnection = UtilityDatabase.DatabaseConnectionInitialize
    (
         databaseConnectionString,
     ref exceptionMessage
    ); 

    foreach ( DataTable dataTable in dataSet.Tables )
    {
   
     columnIndexScriptureReference = UtilityDatabase.DataTableColumnIndex
     (
      dataTable,
      "ScriptureReference"
     ); 
     
     if ( columnIndexScriptureReference < 0 )
     {
      continue;
     }           	
    	
     tableName                = dataTable.TableName;
     scriptureReferenceSet    = new ArrayList();
     scriptureReferenceURISet = new ArrayList();
     SQLStatement = new StringBuilder();
     
     if ( tableName.IndexOf("View" ) < 0 )
     {
      boolView = false;
      SQLStatement.AppendFormat
      (
       InformationSchemaColumnNamePrimaryColumnSQL,
       tableName
      );
     }
     else
     {
      boolView = true;	
      SQLStatement.AppendFormat
      (
       InformationSchemaColumnNamePrimaryColumnSQL,
       tableName.Substring(4)
      );
     }

      #if (DEBUG)
       System.Console.WriteLine("SQLStatement: {0}", SQLStatement);
      #endif
     
     columnNamePrimary = (string) UtilityDatabase.DatabaseQuery
     (
          databaseConnectionString,
      ref exceptionMessage,
          SQLStatement.ToString(),
          CommandType.Text
     );
     
     if ( boolView == true )
     {
      columnNamePrimary = String.Concat( tableName.Substring(4), columnNamePrimary );	
     }	 

     #if (DEBUG)
      System.Console.WriteLine("ColumnNamePrimary: {0}", columnNamePrimary);
     #endif
     
     foreach ( DataColumn dataColumn in dataTable.Columns )
     {
      dataColumnName = dataColumn.ColumnName.Trim();
      /*
      #if (DEBUG)
       System.Console.WriteLine("Table Name: {0} | ColumnName: {1}", tableName, dataColumnName);
      #endif
      */
      if ( dataColumnName.IndexOf( ScriptureReferenceURIColumnNamePostfix ) >= 0 )
      {
       continue;
      }
      if ( dataColumnName.IndexOf( ScriptureReferenceColumnNamePostfix ) >= 0 )
      {
       scriptureReferenceSet.Add( dataColumnName );
       scriptureReferenceColumnName    = dataColumnName;
       scriptureReferenceColumnNameURI = scriptureReferenceColumnName + "URI";
       if ( dataTable.Columns.Contains( scriptureReferenceColumnNameURI ) == false )
       {
        /*
        #if (DEBUG)
         System.Console.WriteLine("Table Name: {0} | ColumnName: {1}", tableName, scriptureReferenceColumnNameURI);
        #endif
        */
        scriptureReferenceURISet.Add( scriptureReferenceColumnNameURI );
       }//if dataTable.Columns.Contains( scriptureReferenceColumnNameURI ) == false )
      }//if ( dataColumnName.IndexOf( ScriptureReferenceColumnNamePostfix ) >= 0 )
     }//foreach ( DataColumn dataColumn in dataTable.Columns )

     foreach ( object columnName in scriptureReferenceURISet )
     {
      scriptureReferenceColumnNameURI = columnName.ToString().Trim();
      dataTable.Columns.Add( scriptureReferenceColumnNameURI );
     }

     foreach ( DataColumn dataColumn in dataTable.Columns )
     {
      dataColumnName = dataColumn.ColumnName.Trim();
      /*
       #if (DEBUG)
        System.Console.WriteLine("Table Name: {0} | ColumnName: {1}", tableName, dataColumnName);
       #endif
      */ 
     }//foreach ( DataColumn dataColumn in dataTable.Columns )

     foreach ( DataRow dataRow in dataTable.Rows )
     {
      columnValuePrimary = dataRow[columnNamePrimary].ToString().Trim();
      columnSet = new StringBuilder();
      /*
       #if (DEBUG)
        System.Console.WriteLine("ColumnValuePrimary: {0}", columnValuePrimary);
       #endif
      */ 
      foreach ( object columnName in scriptureReferenceSet )
      {
       #if (DEBUG)
        System.Console.WriteLine("ColumnName: {0}", columnName);
       #endif
       scriptureReferenceColumnName  = columnName.ToString().Trim();
       scriptureReferenceColumnValue = dataRow[scriptureReferenceColumnName].ToString().Trim();
     
       #if (DEBUG)
        System.Console.WriteLine
        (
         "Scripture Reference Column Name: {0} | Value: {1}", 
         scriptureReferenceColumnName,
         scriptureReferenceColumnValue
        );
       #endif
       scriptureReferenceColumnNameURI = scriptureReferenceColumnName + "URI";
       if ( scriptureReferenceColumnValue != null && scriptureReferenceColumnValue != string.Empty )
       {
        ScriptureReference.ScriptureReferenceParser
        (
             new string[] { scriptureReferenceColumnValue },
             databaseConnectionString,
         ref exceptionMessage,
         ref scriptureReferenceBookChapterVersePrePost,
         ref scriptureReferenceArray,
         ref uriCrosswalkHtml,
         ref uriCrosswalkXml
        );//ScriptureReference.ScriptureReferenceParser()
        scriptureReferenceURI = uriCrosswalkHtml.ToString();
        if ( UtilityDatabase.DataSetTableColumnContains( dataSet, tableName, scriptureReferenceColumnNameURI ) == false )
        {
         UtilityDatabase.DataSetTableColumnAdd( dataSet, tableName, scriptureReferenceColumnNameURI );	
         dataRow[scriptureReferenceColumnNameURI] = scriptureReferenceURI;
         continue;
        }//if ( DataSetTableColumnContains( dataSet, dataTable, scriptureReferenceColumnNameURI ) )	
        dataRow[scriptureReferenceColumnNameURI] = scriptureReferenceURI;
        if ( scriptureReferenceURISet.IndexOf( scriptureReferenceColumnNameURI ) >= 0 )
        {
         continue;
        }

        if ( columnSet.Length != 0 )
        {
         columnSet.Append(',');
        }
        columnSet.AppendFormat
        (
         UtilityDatabase.DatabaseTemplateSQLSet,
         scriptureReferenceColumnNameURI,
         scriptureReferenceURI
        ); 
        /*
        #if (DEBUG)
         System.Console.WriteLine("columnSet: {0}", columnSet);      
        #endif
        */
        SQLStatement = new StringBuilder();
        SQLStatement.AppendFormat
        (
         UtilityDatabase.DatabaseTemplateSQLUpdateScriptureReferenceURISet,
         tableName,
         columnSet,
         columnNamePrimary,
         columnValuePrimary
        );   
        #if (DEBUG)
         System.Console.WriteLine("SQL Statement: {0}", SQLStatement.ToString() );      
        #endif
        UtilityDatabase.DatabaseNonQuery
        (
             oleDbConnection,
         ref exceptionMessage,
             SQLStatement.ToString()
        );
       }//if ( scriptureReferenceColumnValue != null && scriptureReferenceColumnValue != string.Empty )
      }//foreach ( object columnName in dataTableColumnName )
     }//foreach ( DataRow dataRow in dataTable )
    }//foreach ( DataTable dataTable in dataSet ) 
    UtilityDatabase.DatabaseConnectionHouseKeeping
    (
         oleDbConnection,
     ref exceptionMessage
    );
   }//try
   catch (OleDbException exception)
   {
    //exceptionMessage = exception.Message;
    exceptionMessage = UtilityEventLog.WriteEntryOleDbErrorCollection( exception );
    System.Console.WriteLine("OleDbException: {0}", exceptionMessage);
   }//catch (OleDbException exception)
   catch (SecurityException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SecurityException: {0}", exception.Message );
   }//catch (SecurityException exception)
   catch (SystemException exception)
   {
    exceptionMessage = exception.Message;
    System.Console.WriteLine( "SystemException: {0}", exception.Message );
   }//catch (SystemException exception)
   catch (Exception exception)
   {
    exceptionMessage = exception.Message;   
    System.Console.WriteLine( "Exception: {0}", exception.Message );
   }//catch (Exception exception)
  }//public static void ScriptureReferenceURI()
コード例 #2
0
  }//Page_Load
  
  /// <summary>PageBuild().</summary>
  public void PageBuild()
  {

   int          dataTableCount                = -1;
   int          dataTableTotal                = -1;
   int          theWordIdColumnIndex          = 0;

   DateTime     dated                         = DateTime.Now;

   System.Web.UI.WebControls.Label            label  =  null;
   
   String       columnNameForeignKey          = null;
   String       exceptionMessage              = null;
   String[]     sourceName                    = null;
   String[]     sourceSQL                     = null;
   String       tableName                     = null;

   System.Web.UI.WebControls.TextBox          textBox  =  null;
   
   XmlNodeList  sourceXML                     = null;

   TheWord.SourceSQLQuery
   (
        filenameConfigurationXml,
    ref exceptionMessage,
    ref sourceXML,
    ref sourceSQL,
    ref sourceName
   );

   if ( exceptionMessage != null )
   {
    Feedback = exceptionMessage;
    return;
   }//if ( exceptionMessage != null ) 
   
   if ( !Page.IsPostBack )
   {

    theWord.DataSetInitialize
    (
         databaseConnectionString,
     ref exceptionMessage,
         nodeRoot,
         sourceSQL,
         sourceName
    );

    if ( exceptionMessage != null )
    {
     Feedback = exceptionMessage;
     return;
    }//if ( exceptionMessage != null ) 
          	
   }//if ( Page.IsPostBack )

    UtilityXml.XmlDocumentNodeInnerText
    (
         filenameConfigurationXml,
     ref exceptionMessage,         
         TheWord.XPathColumnForeign,
     ref columnNameForeignKey
    );

   dataTableTotal           = theWord.DataSetTheWord.Tables.Count;

   GridViewTheWord          = new System.Web.UI.WebControls.GridView[ dataTableTotal ];
   linkButtonAdd            = new System.Web.UI.WebControls.LinkButton[ dataTableTotal ];

   for( dataTableCount = 0; dataTableCount < theWord.DataSetTheWord.Tables.Count; ++dataTableCount )
   {
   	theWord.DataSetTheWord.Tables[dataTableCount].TableName = sourceName[dataTableCount];
   }

   dataTableCount = -1;

   foreach( DataTable dataTable in theWord.DataSetTheWord.Tables )
   {
    ++dataTableCount;
    
    GridViewTheWord[dataTableCount]                           = new System.Web.UI.WebControls.GridView();
    
    tableName                                                 = dataTable.TableName;

    GridViewTheWord[dataTableCount].BorderWidth               = 1;
    GridViewTheWord[dataTableCount].CellPadding               = 1;
    GridViewTheWord[dataTableCount].DataSource                = dataTable;

    GridViewTheWord[dataTableCount].AllowPaging               = true;
    GridViewTheWord[dataTableCount].AllowSorting              = true;    

    GridViewTheWord[dataTableCount].AutoGenerateColumns       = false;
      
    GridViewTheWord[dataTableCount].AutoGenerateDeleteButton  = true;    
    GridViewTheWord[dataTableCount].AutoGenerateEditButton    = true;
    GridViewTheWord[dataTableCount].AutoGenerateSelectButton  = true;

    switch ( DataColumnFieldGridView )
    {
     case DataColumnField.Bound:

      foreach( DataColumn dataColumn in dataTable.Columns )
      {
       BoundField boundField      = null;
       boundField                 = new BoundField();
       boundField.DataField       = dataColumn.ColumnName;
       boundField.HeaderText      = dataColumn.ColumnName;
       boundField.SortExpression  = dataColumn.ColumnName;
       GridViewTheWord[dataTableCount].Columns.Add( boundField );
      }
      break;

     case DataColumnField.Template:
      foreach( DataColumn dataColumn in dataTable.Columns )
      {
       TemplateField                    templateField    = null;
       //System.Web.UI.WebControls.Label  label            = null;
       
       templateField                     = new TemplateField();
      
       templateField.HeaderText          = dataColumn.ColumnName;
       templateField.SortExpression      = dataColumn.ColumnName;
       
       //templateField.EditItemTemplate    = new DataGridTemplate(ListItemType.EditItem,  dataColumn.ColumnName);       
       //templateField.FooterTemplate    = new DataGridTemplate(ListItemType.Footer,    dataColumn.ColumnName);
       //templateField.HeaderTemplate    = new DataGridTemplate(ListItemType.Header,    dataColumn.ColumnName);
       templateField.ItemTemplate      = new DataGridTemplate(ListItemType.Item,      dataColumn.ColumnName);

       GridViewTheWord[dataTableCount].Columns.Add( templateField );
      }
      break;

     case DataColumnField.TextBox:
      PlaceHolderGridView.Controls.Add
      ( 
       new LiteralControl
       (
        "<b>" + tableName + "</b><br />"
       ) 
      );

      foreach( DataColumn dataColumn in dataTable.Columns )
      {
       label         =  new System.Web.UI.WebControls.Label(); 
       //label.Id      =  dataColumn.ColumnName;
       label.Text    =  dataColumn.ColumnName + ": ";
       PlaceHolderGridView.Controls.Add( label );
                     
       textBox       =  new System.Web.UI.WebControls.TextBox();
       //textBox.Name  =  dataColumn.ColumnName;
       textBox.Text  =  dataColumn.ColumnName;
       PlaceHolderGridView.Controls.Add( textBox );
       
       label         =  new System.Web.UI.WebControls.Label(); 
       label.Text    =  "<br />";
       PlaceHolderGridView.Controls.Add( label );

      }
      break;

    }  

    GridViewTheWord[dataTableCount].DataBind();
    GridViewTheWord[dataTableCount].ID                        = tableName;

    theWordIdColumnIndex = UtilityDatabase.DataTableColumnIndex
    (
     theWord.DataSetTheWord.Tables[tableName],
     columnNameForeignKey  
    );
    
    if ( DataColumnFieldGridView <= DataColumnField.Template )
    {
     if ( theWordIdColumnIndex >= 0 )
     {     
      //UtilityDatabase.DataSetTableColumnVisible( GridViewTheWord[dataTableCount], theWordIdColumnIndex, false );
      GridViewTheWord[dataTableCount].Columns[theWordIdColumnIndex].Visible = false;
     }//if ( theWordIdColumnIndex >= 0 ) 

     //GridViewTheWord[dataTableCount].UserDeletingRow += new GridViewRowCancelEventHandler( GridViewDeleteEventArgs );

     PlaceHolderGridView.Controls.Add
     ( 
      new LiteralControl
      (
       "<b>" + GridViewTheWord[dataTableCount].ID + "</b>"
      ) 
     );
    }
    
    if ( dataTableCount != 0 )
    {
     linkButtonAdd[dataTableCount]                              = new System.Web.UI.WebControls.LinkButton();
     linkButtonAdd[dataTableCount].ID                           = dataTableCount + "|" + tableName + "|" + "Add";
     linkButtonAdd[dataTableCount].Text                         = "Add <br />";

     // Register the event-handling method for the Click event. 
     linkButtonAdd[dataTableCount].Click                       += new EventHandler(this.LinkButtonAdd_Click);

     PlaceHolderGridView.Controls.Add( linkButtonAdd[dataTableCount]  );
    } 

    if ( DataColumnFieldGridView <= DataColumnField.Template )
    {
     PlaceHolderGridView.Controls.Add(GridViewTheWord[dataTableCount]);
     PlaceHolderGridView.Controls.Add(new LiteralControl("<br />"));
    }

   }//foreach( DataTable dataTable in theWord.DataSetTheWord.Tables )

  }//public static void PageBuild()