Monday, May 17, 2010

SharePoint 2010 How-To: Copy your production content database to a development server

Although this is written for SharePoint 2010, I imagine it should still work on 2007 and 2003 (WSS3) environments.

I had to come up with an easy method for a client to copy their production content database to a development server. The production system was separated across multiple servers for the various components (Web and Database split) while the development server was a stand-alone virtual on the same network. This meant I could not rely on a simple VM snapshot or OOTB SharePoint backup/restore functionality, so this was the quick process.

  1. Using SQL Server Management Studio (SSMS) connect to the live SharePoint SQL instance
  2. Create a backup of the live WSS_Content database
  3. Copy the backup file from the live server to the development server
  4. Connect SSMS to the development server SharePoint SQL instance
  5. Restore the backed up database as a new database. Ideal naming example would be WSS_Content_v2 incrementing the version number with each new restore, or a date stamp or some other recognizable iteration
  6. From the development server, launch the SharePoint Central Administration site
  7. Click on Manage content databases from located under the Application Management header
  8. Click on the name of the current database
  9. Scroll down the properties window and check to Remove content database
  10. Confirm removal
  11. Run a command prompt as Administrator
  12. Navigate to C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\
  13. Run the following command replacing the database name with the name of the newly restored database from step 5 above: stsadm –o addcontentdb –URL http://YourDevSiteURL –databasename NewDatabaseName
  14. Connect to your development SharePoint site URL and verify that everything is working as expected
  15. You can now safely take offline or detach the previous development version of the WSS_Content database using SSMS

Friday, May 14, 2010

Connecting to Sharepoint Lists with C# and ASP.Net

I was recently tasked with a workflow process that would automatically notify SharePoint users that their timesheets were due. This was to happen every Monday at 8am and again at 11am based off of a form library in SharePoint.

There was already a 3-step approval process workflow in place for this library so my first thought was to create a workflow in SharePoint designer to fill this need. I created a Boolean column in the Employees list to flip a submission status and tapped into the approval workflow to toggle this flag when the form was submitted and flip it back when the final approval step happened. So now I had something to check against to generate my "list of shame" for users to notify.

I created a 2nd workflow to get the list of users who had this flag set to false and send out a reminder email, but this had 2 inherent issues. The first issue was that this did not allow a way to trigger the workflow on a set schedule. Second issue was SharePoint workflows do not seem to allow you to iterate through a list and perform an action against all matching criteria (for each loop). They only seem to allow the top returned result to be acted against.

The first issue I solved with a small console .exe file that taps into the SharePoint list and starts the workflow. I scheduled this with windows task scheduler to run at the needed times and everything worked perfect. However this did not solve the inability to iterate through the list of users.

Since this was just an email task and didn’t rely on modifying the document in any way, I realized that the small app I had already developed could handle all of this for me and eliminate the 2nd workflow all together. So I took what I already had and added a method to get the list of employees, check it against the submitted flag and send out emails accordingly. The code below accomplishes this task.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Workflow;
using System.Net.Mail;

namespace TriggerEmailNag1
{
class Program
{
static void Main(string[] args)
{
SendNagEmails();
}


///
/// This will send a nag email to users whos timesheet submitted status in the employees list is set to No.
///

static void SendNagEmails()
{
using (SPSite site = new SPSite("http://YourSharePointSite/"))
{
using (SPWeb web = site.OpenWeb())
{
// Provide the name of the SharePoint list to connect to
SPList list = web.Lists["Employees"];
SPListItemCollection listItems = list.Items;

// Loop through the list and do work
foreach (SPListItem item in listItems)
{
if (!(bool)item["Timesheet Submitted"])
{
string UserName = item["User Name"].ToString();

// Check to see if the username has the domain prepended to match. If not then add it
int check = UserName.IndexOf("\\");
if (check <= 0)
{
UserName = "domain\\" + UserName;
}

// Get the users profile from SharePoint by the username in the list
SPUser user = web.AllUsers[UserName];

// Create the email message to send to the user
StringBuilder body = new StringBuilder();
MailMessage message = new MailMessage();
message.From = new MailAddress("some@emailaddress.com");
message.To.Add(new MailAddress(user.Email.ToString()));
message.Subject = "Timesheet Reminder";
body.Append("This is a reminder that your timesheet for this week has not been submitted yet.").AppendLine().AppendLine();
body.Append("Please submit your timesheets by 8am on Monday morning to avoid any delay in billing and payroll disbursment.").AppendLine().AppendLine();
body.Append("Thank you.");
message.Body = body.ToString();

// Send the email
SmtpClient client = new SmtpClient();
client.Send(message);
}
}

}
}
}
}
}

Tuesday, May 11, 2010

Creating visual web parts in Sharepoint 2010

An easy to follow example of how to get started building visual web parts in Sharepoint 2010.

http://www.helloitsliam.com/archive/2009/10/20/sharepoint-2010-%E2%80%93-create-a-visual-web-part.aspx

Thursday, April 22, 2010

Well that was a fun ride while it lasted.

I am officially among the ranks of the unemployed again today. The ever present questions is whether to attempt to continue on in the general workforce or head out on my own and try to grow AllTech Solutions again.

Over the last year and a half I've had the opportunity to learn a lot about how Amazon works and how to be competitive in the marketplace. During this time I created a software solution that polled all of a vendors competition for a given product, added up the price and shipping (something the competition never did figure out) and run re-pricing logic to update the vendors price to be #1 featured merchant and ultimately grab the Buy Box and KEEP IT!

So with that in mind, I now have the opportunity to offer consulting services to Amazon sellers on how to improve sales, quickly react to other re-pricers and integrate Amazon overall with their existing systems.


Monday, February 1, 2010

TSQL - Delete Top X Rows from a Table

Quick post on how to delete top x rows from a sql table while avoiding a table scan. Helps save time and processing power.

http://sqlblogcasts.com/blogs/simons/archive/2009/05/22/DELETE-TOP-x-rows-avoiding-a-table-scan.aspx

Thursday, January 14, 2010

Website Design with Wireframes

Wireframes make sense.  As noted in this article, many of us do this without thinking about it by drawing out a concept on paper, or maybe a basic starting layout in Photoshop. 

Take a look at Why Your Next Website Should Be Designed with Wireframes over at build Internet for a good look at how to get started with effective and time-saving wireframes.

Thursday, December 17, 2009

I just need a place to put a collection of sites I've designed/developed in the last year. This list is non-inclusive of the custom web apps that are not internet accessible.

2009
http://www.x5automation.com - ASP.Net, C#, SQL
http://www.g3service.com - DNN based template
http://www.spvlaw.com - ASP.Net, C#
http://www.liquidfloors.com - ASP.Net, C#, JQuery
http://www.glenndiving.com - Matching SharePoint portal
http://www.finishthewall.com - ASP.Net, C#, JQuery
http://www.synergyerg.com - ASP.Net, C#, Custom CMS, matching SharePoint portal
http://www.ckhbuilders.com - ASP.Net, JQuery
http://www.mswoodcraft.com - ASP.Net, C#, SQL, JQuery, Custom CMS

2008
http://www.transamericareinsurance.com - ASP.Net, C#, SQL, Custom CMS


 
src='http://sites.google.com/site/carljfisher/shBrushCss.js'/> src='http://sites.google.com/site/carljfisher/shBrushJScript.js'/> src='http://sites.google.com/site/carljfisher/shBrushSql.js'/> src='http://sites.google.com/site/carljfisher/shBrushXml.js'/>