Archive for the 'Uncategorized' Category

20
Jul
09

#30 Sharepoint: Accessing a Site Collection\SPWeb within a Workflow and updating a list

Below I am grabbing data off a Workflow with a browser enabled Infopath Form and loading a separate list.


public Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties workflowProperties = new Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties(); 

  private void onWorkflowActivated1_Invoked(object sender, ExternalDataEventArgs e)
        {

              ...
                //Save the identifier for the workflow
                workflowId = workflowProperties.WorkflowId;

                // InitiationData comes from the initialization form
                XmlDocument document = new XmlDocument();
                document.LoadXml(workflowProperties.InitiationData);

                // Get Data Off Of Init Form
                XmlNamespaceManager ns = new XmlNamespaceManager(document.NameTable);
                ns.AddNamespace("my", "http://schemas.microsoft.com/office/infopath/2003/myXSD/2006-12-05T20:04:17");
                managerUsername = document.SelectSingleNode("/my:flowFields/my:managerUsername", ns).InnerText;
                managerFullname = document.SelectSingleNode("/my:flowFields/my:managerFullname", ns).InnerText;
                reviewType = document.SelectSingleNode("/my:flowFields/my:reviewType", ns).InnerText;
                reviewComments = document.SelectSingleNode("/my:flowFields/my:reviewComments", ns).InnerText; 

                using (SPSite siteCollection = workflowProperties.Site)
                {
                    using (SPWeb web = siteCollection.OpenWeb())
                    {
                        SPList EmployeeReviewList = (SPList)web.Lists["EmployeeReview"];                     // Specific List
                        SPListItem EmployeeReviewItem = OptimizedAddItem(EmployeeReviewList);       // Add New Item to List
                        EmployeeReviewItem["Review Name"] = reviewType;                                            // Update elements of new item
                        EmployeeReviewItem.Update();
                    }
                }  

  ... }

       //cf.  http://blog.robgarrett.com/2009/02/25/efficient-way-to-add-a-new-item-to-a-sharepoint-list
        public  SPListItem OptimizedAddItem(SPList list)
        {
            const string EmptyQuery = "0";
            SPQuery q = new SPQuery { Query = EmptyQuery };
            return list.GetItems(q).Add();
        }

Credit due for OptimizedAddItem(): http://blog.robgarrett.com/2009/02/25/efficient-way-to-add-a-new-item-to-a-sharepoint-list/

25
Jun
08

#14 Code Posts – WordPress.com and VB.net

If you need VB.net code from the C# you can use Telerik’s code converter at http://converter.telerik.com

Update: WordPress does allow a nice format for presenting code :

http://support.wordpress.com/code/#posting-source-code

Wrap your code in these tags:

[sourcecode language='css']

your code here

[/sourcecode]

Notes:

  1. The quotes are messed via posting on WordPress.com which does not allow nice plug-ins to help display code better.
  2. I will see about converting better first but be aware the of the double quotes converting to odd characters.
  3. You can copy C# code into a nice text editor like Textpad or Notepad++ and do a change all & then slap it into the code converter to get VB.net code.
  4. If anyone has a better idea please post a comment.
10
Jun
08

#10 List of Some Things We Have Integrated

Employee Directory - custom filter, Visual Directory fed from EM and Employee Custom Fields tables

Training Request System - fed from VE Vendor table, merged with custom data and one-click auto loaded back into Deltek EM Custom grid table to store training history. Heavy use of Telerik radgrid to group PDH/CEU credits for date ranges. Other features include nag emails, SRS reports and a review process on sponsor and event.

Training History Bulk Loaded - Define the event (title,dates, hours) - select participants and  bulk load the training history for these employees.

Client Files Tab Bulk Loaded - define the file name, UNC path (not lettered drive) & bulk load the clients file tab of all clients with a link. We use this to link back to an asp.net page so this ‘loader’ (as an option) changes the ending parm on the link to the internal Client CL table ID.

Client Profiles - Over 100 fields are stored on client to keep track of their preferences. This is loosely integrated via the client Files Tab link mentioned above.

Birthday List- simple asp.net user control display Employee name, birth Month & Day (not Year ;-) ) on our intranet with links to their picture. Easily moved to Sharepoint via SmartPart

SRS Phone List- 2 multi-column reports displaying employees ext, direct, mobile and office rendered automatically as a PDF via SQL Report Services link using EM and custom tables.

File Folders- simple method call to create file folders for projects on our servers.

Outlook Folders- Not entirely integrated but sends support staff an email with a link to an asp.net page which creates Outlook Folders with the proper permissions. The WF that sends and email could be replaced with a call to this underlying code but we have not done it yet since that page was written in the asp.net 2.0 framework.

I have created numerous stored procedures, views, UDFs and some custom methods to make Work Flow work better for us. To be honest you can do lots out of the box.  In some cases we used some of these more hands on methods because we had not upgraded to 5.0 at that point (i.e. Project Number Generator SP and asp.net page (see post #02 Simple Popup) which we installed while on 4.0)

In some scenarios we could have used a very complex stored procedure but chose to use a series of SQL Views to simplify and layer in a solution that would allow us to view intermediate results. The end product of all these calculations were pushed(via a Stored Procedure) into a custom field on the ProjectCustomTabFields table.

I will add more to this list as I get time. If you have questions and/or would like more details please post a comment or contact me directly.

23
May
08

#04 Microsoft’s Enterprise Data Layer

Note: This is a more advanced programming topic

As we migrated to the 2.0+ (3.x) frameworks I have been using Microsoft’s Enterprise Library and in particular the DAAB (Data Access Application Blocks). Here is a look at one method in the Employee Data Access layer. This is a static wrapper method but keeps the code clean.

There are other method calls but I have stripped them out for the moment.

The following object allows me to bind to a Telerik RadGrid (Gridview)  like this:

protected void rgEmployees_NeedDataSource(object source, GridNeedDataSourceEventArgs e) {

rgEmployees.DataSource = Employee.getAllEmployees();
}

Note: This is an Telerik AJAX method call but the binding to a simple Gridview is just the same. Ideally this receives some search parms that filter the return a tailored dataset.

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.Common;
using System.Web.Configuration;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Telerik.WebControls;
using System.Data.SqlTypes;

public class Employee
{
public Employee ()
{

}

/// <summary>
/// Gets All Employees
/// </summary>
/// <returns> dataset of EM data </returns>
static public DataSet getAllEmployees()
{
DataSet ds = null;
DbCommand dbc = null;
Database db = DatabaseFactory.CreateDatabase(“*****”);    // readonly ID
dbc = db.GetStoredProcCommand(“SPName”);                    // SP reference

try
{
ds = db.ExecuteDataSet(dbc);
}
catch (Exception exc)
{
throw new IntranetException(exc.Message,
exc,
SystemConstants.Intranet_ErrorMessage);
}

return ds;

}

}

21
May
08

#03 SQL Reporting Link Rendering A Report as a PDF

Once you create a SQL Reporting Services report and deploy (or upload the .rdl and .rds files) you can reference the report via a link and render it as a pdf (or Excel) via the following pattern (assumes no ssl)

http://ServerName/ReportServer?%2fFolderName%2fReportName&parm1=value&rs%3aCommand=Render&rs%3AFormat=PDF

Variables (note ‘ReportServer’ is a constant)

  • ServerName – Server housing SQL Reporting Services
  • FolderName – Typically the name of your Visual Studio Project
  • ReportName – name of the .rdl file defining your report
  • parm1=value  (ignore if not passing parms) You can add as many as you want like &parm2=value2…)

Note: The last phrase tells the report server to render as a pdf: 3aCommand=Render&rs%3AFormat=PDF You can change that last parm (Format=) to Excel from PDF to render a spreadsheet (assuming Excel is installed on your client PC)

This link can be placed in an ASP.net page or user control and redirected via the Response.Redirect command (often fired via a button click event/delegate) using string concatenation to add in any variables like a date range etc.  You could also use a Sharepoint webpart connected to some filter fields controlling any parameters sent just like a ASP.net page or user control. Another idea is that the link can be added as a static link on the Dashboard in Vision. 

11
Jan
08

Welcome

This is an experiment for me in several ways. My hope is that I can offer help to those companies that have Deltek installed and are trying to extend out their internal operations & systems.  I am aware of the excellent work done by Deltek and some users in this area.  I offer this blog as a tool & as a tool if it does not help please disregard it. I do appreciate notification on anything you see that can be improved or corrected.  The code & help here is offered free but please use your own due diligence to make sure you do not cause problems on your own system. There are no guarantees attached. 

Lastly, I am making an effort to give credit due since coded solutions are rarely done in a vacumn. If you notice anything that should be credited to another source please contact me. It is easy to do this with older code where I have forgotten all the blogs and resources I searched out to get it working.