Getting Custom Columns from SharePoint list

Getting Custom Columns from SharePoint list

Dim sReturnValue As String = Nothing
    Dim sReturnValuec As String = Nothing
    Dim listService As New WssListsSvc.Lists()
    Dim m_credentials  As ICredentials = New Net.NetworkCredential(UserId, Pwd, Domain)
    listService.Credentials = m_credentials
    Dim result As XmlNode = listService.GetList(sLibName)
    For Each ndField As XmlNode In result.FirstChild.ChildNodes
        Dim IsReadOnly As String = String.Empty
        Dim name As String = String.Empty
        If ndField.Attributes("ReadOnly") IsNot Nothing Then
           IsReadOnly = DirectCast(ndField.Attributes("ReadOnly").Value, String)
        End If
        If Not IsReadOnly = "TRUE" Then
            If ndField.Attributes("DisplayName") IsNot Nothing Then
                 name = DirectCast(ndField.Attributes("DisplayName").Value, String)
            End If                        If sTagType.ToLower = "custom" Then
                 Dim SourceID = DirectCast(ndField.Attributes("SourceID").Value, String)
                 If SourceID.Contains("sharepoint") = False Then
                     sReturnValue = name & "," & sReturnValue
                 End If
            Else                                    sReturnValue = name & "," & sReturnValue                          End If
        End If
    Next
Return sReturnValue

C# Version


string sReturnValue = null;
string sReturnValuec = null;
WssListsSvc.Lists listService = new WssListsSvc.Lists();
ICredentials m_credentials = new System.Net.NetworkCredential(UserId, Pwd, Domain);
listService.Credentials = m_credentials;
XmlNode result = listService.GetList(sLibName);
foreach (XmlNode ndField in result.FirstChild.ChildNodes) {
 string IsReadOnly = string.Empty;
 string name = string.Empty;
 if (ndField.Attributes("ReadOnly") != null) {
  IsReadOnly = (string)ndField.Attributes("ReadOnly").Value;
 }
 if (!(IsReadOnly == "TRUE")) {
  if (ndField.Attributes("DisplayName") != null) {
   name = (string)ndField.Attributes("DisplayName").Value;
  }
  if (sTagType.ToLower == "custom") {
   dynamic SourceID = (string)ndField.Attributes("SourceID").Value;
   if (SourceID.Contains("sharepoint") == false) {
    sReturnValue = name + "," + sReturnValue;
   }
  } else {
   sReturnValue = name + "," + sReturnValue;
  }
 }
}

Notes :
1.: UserId, Pwd, Domain, sTagType, sLibName are string variables used in the function.
2.: sTagType Contains the values “All” or “Custom”. If all is passed then all the
columns are retrieved and if custom is selected then Custom Columns Comma separated
list is returned.


Making Data Dictionary from SQL or MS. Access

It is very easy to create data dictionary from M.S. Access as well as SQL.

Microsoft Access


Step 1 : Open the Access Database
Step 2 : Go to Database Tools.

Step 3 : Click on Database Documenter.

Step 4 : Select the tables.
Step 5 : Go to Options & Select Appropriate Options.

Step 6 : Click OK.
Step 7 : Export it word from More -> Word.

You get your Data Dictionary Ready.

Microsoft SQL Server.


Step 1 : Create New Query.

Step 2 : Write any one query given below.

For All Tables. 

“select * from <DatabaseName>.INFORMATION_SCHEMA.COLUMNS;”

For Single Table
“select * from <DatabaseName>.INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='Table Name';”

Step 3 : Execute the query.
Step 4 : Select the output by clicking the small square on the top left corner of your result.

Step 5 : Paste it in excel sheet.
Step 6 : Modify the Output as per your requirement.

Step 7 : It is ready for your use.

Please Send your comments

How to print a web page

It is very easy and one or two step process to print the web page. Printing of web page can be done in two ways.

Method 1:  Print the whole web page using the print button.
Step 1: Write the code given below where you want to add the print button

<input type="button" value="Print" onclick="window.print();">
This will print the whole web page which contains the button.

Step 2: Print the other page, specially designed for printing.

Step 1 : Make two pages of the same content, first for web display and second for printing.

Step 2 : On first web page write the code below to add the print button.

<input type="button" value="Print" onclick="window.open('YourPrintPage.aspx')"/>
Step 3 : Add the given script to the end of the second page.

<script language="javascript" >
window.print();

</script>

But, Printing of web page depends on many things, like Different web browsers,
Operating systems, CSS Styles etc.

So, Using PDF format’s is better than making two different files. Because PDF’s
are platform independent.

Making Log for your application / Website

Making Log for your application / Website


 


 

Now it is easy to create log for your application or website or function.

Here I am explaining the way of making log in text file using log4net dll .

Step 1


 

Download log4net 1.2.10 (zip) from http://logging.apache.org/log4net/download.html.


 

Step 2

Get the dll file from path ~\log4net-1.2.10\bin\net\2.0\debug\ log4net.dll


 

Step 3

Add this dll to your project folder and give it's reference to the project.


 

Step 4

Create one Configuration File as below and name it. (here LogConfigure.config)


 

<?xml
version="1.0" encoding="utf-8" ?>

<configuration>

<configSections>

<section
name="log4net"


type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

</configSections>

<log4net>

<appender
name="LogFileAppender" type="log4net.Appender.FileAppender">

<param
name="File" value="LOGGING.txt" />

<param
name="AppendToFile" value="true" />

<layout
type="log4net.Layout.PatternLayout">

<param
name="ConversionPattern" value="%d [%t] %-5p %m%n" />

</layout>

</appender>

<root>

<level
value="INFO" />

<appender-ref
ref="LogFileAppender" />

</root>

</log4net>

</configuration>


 

Step 5

Make one class as below and name it. (here LoggerNet.vb)


 

Imports log4net

Imports log4net.Config

Imports System.IO

Class
LoggerNet


Private
ReadOnly ilog As
ILog = LogManager.GetLogger(GetType(SharePointLoader))


Public
Sub
New()


Dim fno As
FileInfo = New
FileInfo("LogConfigure.config")


XmlConfigurator.Configure(fno)


End
Sub


Public
Sub LogInfo(ByVal Message As
String)

ilog.Info(Message)


End
Sub


Public
Sub LogError(ByVal Message As
String)

ilog.Error(Message)


End
Sub


Public
Sub LogError(ByVal Message As
String, ByVal ex As
Exception)

ilog.Error(Message, ex)


End
Sub

End
Class


Or C# Code as below LoggerNet.cs

using log4net;

using log4net.Config;

using System.IO;

class LoggerNet

{

    private readonly ILog ilog = LogManager.GetLogger(typeof(SharePointLoader));

    public LoggerNet()

    {

        FileInfo fno = new FileInfo("LogConfigure.config");

        XmlConfigurator.Configure(fno);

    }

    public void LogInfo(string Message)

    {

        ilog.Info(Message);

    }

    public void LogError(string Message)

    {

        ilog.Error(Message);

    }

    public void LogError(string Message, Exception ex)

    {

        ilog.Error(Message, ex);

    }

}

Step 6

Now from every class file where you want to create log just add the below code.

Create Static Object of LoggerNet

VB    Private
Shared ilog As
New
LoggerNet()

C# private static LoggerNet
ilog = new LoggerNet();


 

For information logging


 

Add the code from where you want to log information


 

VB    ilog.LogInfo("Information")


 

Add the code from where you want to log Error


 

VB    ilog.LogError("Error Message")


 

Add the code from where you want to log Exception


 

VB    ilog.LogError(exception.Message, exception)


 

Step 7

This will create a log file named "LOGGING.txt"
(As per config file)

Tip

At the end of application you can rename your file with a Unique name so that there is a unique log for each instance.

File.Move("LOGGING.txt","Unique Name")


 

Search This Blog

Link Within Related Posts Plugin for WordPress, Blogger...