Tuesday, May 15, 2012

Docflow Timer Job for Document Synch..

Purpose: The purpose of this timer job to update the status of deliverable of Docflow from the GDMS systems in timely fashion. On a particuler time it takes synch the docflow document status from the GDMS System.

Code flow and functionality..
override

There are two functions defined in the basic functionality one for documentSynch and other for DocumentContribution synch.. Document synch pull all the items from the Docflow Calender list except Completed and Discontinued, takes the releated document from the Document list and update the status. while documentcontribution picks the records from the Docuemnt list.

using the web application we picks site and using the site we pick web.
objSPListItemCollection is the collection of items from Docflow calender except Completed and Discontinued.

SynchronizeDocument(currentSPweb, objSPListItemCollection);

Loop through each item of objSPLIstItemCollection check the intiationstart of calender item if it is null then assign to new DateTime(1900,1,1) otherwise pick from calender list item and put the calender status to the local variable status.
actualInitStartDate =

//now get the document list item heredocListItem =
The common function used to get the document of the particuler calenderlist item in which we pass the calenderListItemID.
DocumentDAO.GetDocumentListItemByCalendarID(currentSPweb.Site.Url, CalenderListItem.ID.ToString());
The DocListItem is getting from Document List using the SPQuery Object.

If DocList item is not null then we pull the following fields values to access the data from GDMS.
 Convert.ToString(docListItem[GlobalConstants.COLUMN_GDMS_R_OBJECT_ID]);Convert.ToString(docListItem[GlobalConstants.COLUMN_GDMS_I_CHRONICLE_ID]);
strObjectID =
strChronicleID =

In StrNewObjectID it gets the versionID to communicate from the GDMS web service passing the crediantials using the cryptography format. first getting the applicable versionID to communicate from GDMS web service and passing this to the GDMS database and apply the query to find this chronicleID.. if it find then assign it to the strNewObjectID.
string

Now apply the function, If strObjectID not equel to strNewObjectID apply function
if
{

}

In the above function only two fields are updating one is  gdms_r_object_id and other is GDMS_x0020_Link

//now get GDMS document object based on object idobjGDMSObject =

Now Check If objGDMSObject is not equal to null  then

If  the status of objGDMSObject is "In Review" then set the
// set the list item status to review
then set the status of following fields
CalenderListItem[
updatedStatus =
CalenderListItem[
iscalendarChange =
GlobalConstants.COLUMN_DOCFLOW_STATUS] = Enumerators.DocStatus.Review.ToString();Enumerators.DocStatus.Review.ToString();GlobalConstants.COLUMN_ACTUAL_APPROVAL_START_DATE] = null;true;
GDMSDataBaseDAO.GETDGMSObject(currentSPweb.Site.Url, strNewObjectID);
(strObjectID != strNewObjectID)CalendarDAO.UpdateDocumentObjectInfo(docListItem, strNewObjectID);
queryNewObject = "select r_object_id from pfe_document where i_chronicle_id = '" + strChronicleID + "';";
void Execute funtion : 

and setting the start date from the //set the start date from audit trail event

//if status = pending approval
update the status
//always update latest the Approval start date from audit trail event
// set earliest review start date

else
|| objGDMSObject.Status.Equals(
|| objGDMSObject.Status.Equals(
|| objGDMSObject.Status.Equals(

Updating followings fields
CalenderListItem[
CalenderListItem[
CalenderListItem[
CalenderListItem[


If GDMS status is unknown else condition
CalenderListItem[
updatedStatus =
CalenderListItem[
iscalendarChange =

{
dtReviewStartDate =

{
CalenderListItem[
}
GlobalConstants.COLUMN_DOCFLOW_STATUS] = Enumerators.DocStatus.Review.ToString();Enumerators.DocStatus.Review.ToString();GlobalConstants.COLUMN_ACTUAL_APPROVAL_START_DATE] = null;true;if (String.IsNullOrEmpty(Convert.ToString(CalenderListItem[GlobalConstants.COLUMN_ACTUAL_REVIEW_START_DATE])))GDMSDataBaseDAO.GetObjectReviewStartDate(currentSPweb.Site.Url, objGDMSObject, actualInitStartDate);if (dtReviewStartDate.HasValue)GlobalConstants.COLUMN_ACTUAL_REVIEW_START_DATE] = dtReviewStartDate;
GlobalConstants.COLUMN_ACTUAL_REVIEW_START_DATE]
GlobalConstants.COLUMN_ACTUAL_APPROVAL_START_DATE]
GlobalConstants.COLUMN_ACTUAL_RAD_HANDOVER_DATE]
GlobalConstants.COLUMN_DOCFLOW_STATUS]
if (objGDMSObject.Status.Equals(GlobalConstants.GDMS_DOC_STATUS_FIT_FOR_USE)GlobalConstants.GDMS_DOC_STATUS_APPROVED)GlobalConstants.GDMS_DOC_STATUS_FINAL)GlobalConstants.GDMS_DOC_STATUS_EFFECTIVE))



SynchronizeRelatedDocumentContributions(SPWeb oWeb)

Retrieving allitems from the Document List, Converting to datatable if collection is not empty. creating query to making a call in database to all the list items
strQuery =

Removing all the items from "Document Contributions" List. using the for loop.
Looping through the each item of Document List, retrieving row to the datarow object and retrieving the
gdms_r_object_id and checking whether it has value or not, If it has
//now get GDMS document object based on object id
// get a string concating all related document ids
// constructing query to get related document info
// assume the list is empty,

Checking the condition of
GDMS_DOC_STATUS_FINAL
GDMS_DOC_STATUS_HA_APPROVED
GDMS_DOC_STATUS_APPROVED
GDMS_DOC_STATUS_EFFECTIVE and inseting the fields accordingly.
// foreach related document returned, create an entry in document contribution list
"select r_object_id, r_version_label,xm_status,title ,subtype, pfe_xm_p_lc_change,i_chronicle_id from gtc_document(all) where r_object_id in


Timer job logs has been logged on the
LIST_Logs, Logs list.


How to create TimerJob
1. Create a class inherited from SPJobDefinition create constructor and override the Execute method write your logic in Execute method.
  GDMSContributionSync : SPJobDefinition{
// No Argument Constructor (required for the system internal operation)
{
}

:
{
}
public
{}

2. Create the feature that should have a reciever class in which you configure the Job, where you add the job on the portal and configure it for schedule.

// GDMSDocumentSync Job

GDMSDocumentSync objTimerJob = new GDMSDocumentSync(GlobalConstants.FEATURE_GDMS_DOCUMENT_SYNC, currentSite.WebApplication);SPDailySchedule schedule = new SPDailySchedule();//this service will start at 1 AMschedule.BeginHour = 2;
schedule.BeginMinute = 2;
schedule.EndHour = 3;
objTimerJob.Schedule = schedule;
objTimerJob.Title =
currentSite.WebApplication.JobDefinitions.Add(objTimerJob);
objTimerJob.Update();

3. Activate a feature, If you can develope a screen to schedule the job to run.


objContSyncTimerJob.Title = jobName;
objContSyncTimerJob.Schedule = schedule;
objContSyncTimerJob.IsDisabled = rdbLstJobStatus.Items[1].Selected;
objContSyncTimerJob.Update();
case GlobalConstants.FEATURE_GDMS_CONTRIBUTION_SYNC:GDMSContributionSync objContSyncTimerJob = new GDMSContributionSync(GlobalConstants.FEATURE_GDMS_CONTRIBUTION_SYNC, currentSite.WebApplication);

4. You can debug the timer job from OWStimer process.
GlobalConstants.FEATURE_GDMS_DOCUMENT_SYNC;
override void Execute(Guid targetInstanceId)
public GDMSContributionSync()public GDMSContributionSync(string JobName, SPWebApplication objWebApplication)base(JobName, objWebApplication, null, SPJobLockType.Job)
class

No comments:

Post a Comment