A Practical Guide to SharePoint 2013

A Practical Guide to SharePoint 2013
A Practical Guide to SharePoint 2013 - Book by Saifullah Shafiq

Wednesday, February 7, 2007

TechnoService Source Code

Update:
Originally posted: Sat, Feb 24, 2007
Reposted: Aug 25, 2007
Click here to download the source code of TechnoService web service. TechnoService is a web service that retrieves blog information from Technorati.com. This service can be used to display blog information in MOSS 2007 and WSS 3.0 sites.

-SSA

Integrating ASP.NET AJAX with SharePoint (By Mike Ammerlaan)

An excellent article I would say! It has all the basics that one would want to know about integrating ASP.NET AJAX with SharePoint.   
------------------------
Originally posted on: Friday, Feb 23, 2007
Reposted: Aug 26, 2007

TechnoPart: Display your blog/site statistics in SharePoint sites.


Click here to download
TechnoPart is a web part that gets site or blog information from Technorati. It uses the Technorati API.

The TechnoPart retrieves following information from the Technorati site:
1. Blog/Site Name
2. Author Name
3. Rank
4. Inbound Blogs
5. Inbound Links

Click here to download TechnoPart.
Installation
Installation is very easy. Following are the steps required to install TechnoPart on your server:
1. Copy the Technocab.CAB file to the following location on the server:
C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12 in
This location also contains stsadm.exe file.
2. From the location mentioned in Step 1, run the following command:
stsadm -o addwppack -filename Technocab.CAB -url http://localhost -globalinstall -force
(Change localhost to your servername. You can install it anywhere including the root site.)
3. Run following command to reset IIS:
iisreset /timeout:0
4. To add TechnoPart to the SharePoint site, open the site in a web browser.
5. Click Site Actions and select Edit Page.

6. Click Add a Web Part (in Right zone).
7. Expand All Web Parts by clicking the + button.
8. Select WS-TechnoPart from the Miscellaneous section.

9. Click the Publish button to publish the changes.

10. Now, test the web part by refreshing the page where you added the part. By default, it will show you my blog's stats. You can change the blog/site URL. Here are the steps:
11. Click the arrow at the top right corner of the TechnoPart and select "Modify Shared Web Part".

12. Expand the "Miscellaneous" section by clicking the + sign and enter the URL of the site or blog for which you want to retrieve information in the Site URL box. By default, Site URL contains my blog's URL. Enter Technorati Key in the Technorati Key box. This key is required to get information from the Technorati site using the API. To get a key for your own site or blog, visit Technorati site. You can use this key to get information for any blog or site registered on Technorati which means that even if you do not change the default value in the Technorati Key box, you will still be able to retrieve information from the Technorati site.

Remove TechnoPart
Following are the instructions to remove TechnoPart from your server:
1. Go to following location on the server:
C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12 in
2. Run following command to remove the web part.
stsadm -o deletewppack -name Technocab.cab -url http://localhost
(Change localhost to your servername.)
Samples
------
Originally posted on: Fri, Feb 23, 2007

Microsoft GroupBoard Workspace


Microsoft GroupBoard Workspace

"The GroupBoard Workspace template for Microsoft Windows SharePoint Services 3.0 creates a space for a group or team to connect and share information in a collaborative environment, improving team efficiency and productivity." ... Source

Click here to download this workspace.
Here is a screenshot:

It's an amazing application, very easy to use! The features I liked most are:
-Schedules and Reservations
-Time Card

Create a new appointment and it will appear immediately in the "Schedule and Reservations" and "What's new" parts.
The following figure shows a web part in the "New Appointment" page. This chart helps users to select the begin and end date and time for the appointment.

Entering time in time card is a one click process.

Click Start to register "Time-in" and click Return to register "Time-out". That's it. Time card automatically calculates all other necessary information.

You can modify time card settings in the Settings page.
-------
 Originally posted on: Thursday, Feb 22, 2007

Creating an Installer for your web service

Update: 
Originally posted: Wednesday, Feb 28, 2007
Some of the links might not work. If you find any dead links, kindly send an email to share.point@yahoo.com. Retrieved from web archive! 
When I first wrote the installer for the WSUploadService, some people asked me how did I create the installer and yesterday when I published the post "Installing WSUploadService manually", again there was a request from one of my blog readers to share the installer code with the community. In this post, I will discuss the installer code.
This installer is a .NET application that copies the web service files to the correct folders on the destination machine. All manual work stated in the article "Installing WSUploadService manually" is done automatically by the installer. After copying the files and modifying some of the default SharePoint files, installer application runs another installer package that simply copies the web service assembly to the correct bin folder. Even this step could have been added in the installer application but I did not have the time so I created a new installer to add the assembly to the GAC. Just a few more lines and we can get rid of the second installer! The source code is attached. Feel free to modify it to meet your own requirements. I found a couple of links on Google that show how to add an assembly to the GAC programmatically:
Creating the second installer (to install assembly in the GAC) is very easy. Just create a web setup project, add the web service assembly file to the project, compile it and you are done. Of course, you may want to take some additional steps that are not actually required but can enhance the performance. For example, remove all dependency files from the package to reduce the installer size. Include a readme.txt in the package to let your users know about the installation steps, history, functionality, etc.
Create a C# application and add following namespaces at the top:
using System.IO;
using System.Diagnostics;
using Microsoft.Win32;
Check Registry to see if the application is already installed. Ask the user if he wants to keep the application. Based on his response, take the action.
RegistryKey rk = Registry.LocalMachine;
RegistryKey nk = rk.OpenSubKey("SOFTWARE\UploadService");
bool bGoAhead = false;

DialogResult response;

if (nk == null)
{
bGoAhead = true;
}
else
{
if ((string)nk.GetValue("Installed") == "1")
{
response = MessageBox.Show("UploadService is already installed! Do you want to uninstall?", "Uninstall", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

If the response from the user is Yes, that is, if he wants to continue with the uninstall, run the following code:
 if (response == DialogResult.Yes)
{
//Uninstall
string dest = (string)nk.GetValue("Path") + @"Program FilesCommon FilesMicrosoft Sharedweb server extensions12ISAPI";

if (File.Exists(dest + "Files.asmx"))
{
File.Delete(dest + "Files.asmx");
}
if (File.Exists(dest + "Filesdisco.aspx"))
{
File.Delete(dest + "Filesdisco.aspx");
}
if (File.Exists(dest + "Fileswsdl.aspx"))
{
File.Delete(dest + "Fileswsdl.aspx");
}
if (File.Exists(dest + "spsdisco_backup.aspx"))
{
File.Delete(dest + "spsdisco.aspx");
File.Copy(dest + "spsdisco_backup.aspx", dest + "spsdisco.aspx");
File.Delete(dest + "spsdisco_backup.aspx");
}
RegistryKey regkey = Registry.LocalMachine;
RegistryKey newkey = regkey.CreateSubKey("SOFTWARE\UploadService");
newkey.SetValue("Installed", "0");

//MessageBox.Show("Uninstall");
System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\setup.exe");

//bGoAhead = true;
this.Close();
This code will remove the values from the registry and then invoke the setup.exe (the second installer) which will remove the web service assembly from the GAC.
If he cancels the setup, simply close the application.
else
{
bGoAhead = false;
this.Close();
}
If the user is running the setup for the first time to install the web service, then use the following code to add values to the registry and run the second installer:
string[] drives = Environment.GetLogicalDrives();
string sPath = @"Program FilesCommon FilesMicrosoft Sharedweb server extensions12ISAPI";


foreach (string sDrive in drives)
{
if (System.IO.Directory.Exists(sDrive + sPath))
{

if ((File.Exists(Environment.CurrentDirectory + "\Files.asmx") && (!File.Exists(sDrive + sPath + "Files.asmx"))))
{
installed = true;
File.Copy(Environment.CurrentDirectory + "\Files.asmx", sDrive + sPath + "Files.asmx", true);

//Modify spsdisco.aspx file!
Modify(sDrive + sPath,"spsdisco",".aspx");

}
if ((File.Exists(Environment.CurrentDirectory + "\Filesdisco.aspx") && (!File.Exists(sDrive + sPath + "Filesdisco.aspx"))))
{
File.Copy(Environment.CurrentDirectory + "\Filesdisco.aspx", sDrive + sPath + "Filesdisco.aspx", true);
}
if ((File.Exists(Environment.CurrentDirectory + "\Fileswsdl.aspx") && (!File.Exists(sDrive + sPath + "Fileswsdl.aspx"))))
{
File.Copy(Environment.CurrentDirectory + "\Fileswsdl.aspx", sDrive + sPath + "Fileswsdl.aspx", true);
}
if (!installed)
{
MessageBox.Show("UploadService could not be installed because default SharePoint installation directory could not be found. Make sure SharePoint is installed on this machine.");
this.Close();
}

System.Diagnostics.Process.Start(Environment.CurrentDirectory + "\setup.exe");


//MessageBox.Show("UploadService has been installed successfully!");
RegistryKey regkey = Registry.LocalMachine;
RegistryKey newkey = regkey.CreateSubKey("SOFTWARE\UploadService");
newkey.SetValue("Installed", "1");
newkey.SetValue("Path", sDrive.ToString());
//break;
this.Close();
The above code uses a Modify() function. Modify() function modifies the spsdisco.aspx file and includes the reference to the web service being installed. After this, the web service will become visible to the users searching for the web services on the server. Here is the Modify() code:
public void Modify(string spsPath, string filename, string ext)
{
try
{
File.Copy(spsPath + filename + ext, spsPath + filename + "_backup" + ext);
File.Delete(spsPath + filename + ext);

StreamReader sr,sr1;
StreamWriter sw;

sw = File.CreateText(spsPath + filename + ext);
sr1 = File.OpenText(Environment.CurrentDirectory + "\replacement.txt");
string str2 = sr1.ReadLine();
string str1 = string.Empty;

while (str2 != null)
{
str1 += str2;
str2 = sr1.ReadLine();
}


sr = File.OpenText(spsPath + filename + "_backup" + ext);
string str = sr.ReadLine();

while (str!=null)
{
if (str.Substring(0) == "</discovery>")
{
str = str.Replace("</discovery>", str1);

}

sw.WriteLine(str);
str = sr.ReadLine();

}

sr.Close();
sr1.Close();
sw.Close();

}
catch (Exception ex)
{
MessageBox.Show(ex.Source + " - " + ex.Message + " - Could not modify the spsdisco.aspx file. Contact web service vendor!");
}
}
This function copies the content of replacement.txt to the spsdisco.aspx file. The code automatically makes a backup copy of the spsdisco.aspx file so that you can go back to the original settings if required. Replacement.txt contains the following:
<contractRef ref=<% SPEncode.WriteHtmlEncodeWithQuote(Response, spWeb.Url + "/_vti_bin/Files.asmx?wsdl",'"'); %> docRef=<% SPEncode.WriteHtmlEncodeWithQuote(Response, spWeb.Url + "/_vti_bin/Files.asmx", '"'); %> xmlns="http://schemas.xmlsoap.org/disco/scl/" />
<soap address=<% SPEncode.WriteHtmlEncodeWithQuote(Response, spWeb.Url + "/_vti_bin/Files.asmx", '"'); %> xmlns:q1="http://schemas.microsoft.com/sharepoint/soap/directory/" binding="q1:FilesSoap" xmlns="http://schemas.xmlsoap.org/disco/soap/" />

</discovery>
To learn more about these tags and to know what this text is, read the following article, which is by the way, one of the most read articles on my blog:
To download the installer code, click here. Download size is 414 KB.
To download the installer application that installs web service assembly to the GAC, click here. Download size is 358 KB.

Adding a field to the document library template - MOSS 2007

Note: Don't forget to make backup copies of the files you modify in this tip.
1. Open schema.xml file for the document library that is located in the following path:
LocalDrive:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATEFEATURESDocumentLibraryDocLib
2. Locate <Fields> tag and add following field inside the <Fields> tag:
  <Field ID="{20487AC7-D872-4B10-ACB8-CF3002C29687}" Type="Text" Name="MyField" ShowInNewForm="FALSE" ShowInFileDlg="FALSE" DisplayName="$Resources:core,MyField;" Filterable="TRUE" Sortable="TRUE" Sealed="TRUE"  SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="MyField"><!-- _locID@DisplayName="camlid2" _locComment="  " -->
      </Field>
Field ID should be unique. Run Select NewID() in SQL Query Analyzer to get a new GUID and use it as the field ID.
3. Open core.en-US.resx file located in the following path:
LocalDrive:Program FilesCommon FilesMicrosoft Sharedweb server extensions12Resources
4. Locate following tag in the file:
  <!-- shared resources -->
and add following lines in this section (shared resouces section)
  <data name="MyField">
    <value>My Demo Field</value>
  </data>

5. Save the changes and reset IIS. Next time when you will create a document library, this field will be a part of your document libray.
I once blogged about creating site definitions in SPS 2003. Things have changed a lot in version 2007 but this time we have lot of help available in the form of blogs, forums, etc. If you want to learn more about site definitions in 2007, read following excellent articles by Todd Baginski:

-SSA
Published Wednesday, February 07, 2007 6:01 PM by ssa

Comment Notification

If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using RSS

Comments

 

Mike Walsh's WSS and more said:

February 11, 2007 1:59 AM

Tuesday, February 6, 2007

MS KB Article: Solution to name.dll problem in IE7

 

Following MS KB article (released Jan 26, 2007) gives the solution to the name.dll problem in Internet Explorer 7. People did not want to make changes in the clients' computers so now there is a solution that will solve the problem without making changes in the client computer (See method 3).