Workflow Tasks in sharepoint
-
hi all, i wanna thank you for you contribution in all those forum and we know all that real knowledge is sharing so thank you again. here is my problem i want to make a job in sharepoint site who check all task in certain workflow i'll call him "sampleworkflow" i want to get task not completed in this "sampleworkflow" and impresionate a user called "goMan" to achieve this tasks. but first of all i must check all groups wich go man belong to and got this task who are assigned to those group. here is my code #region "Imports" using System.Globalization; using Microsoft.SharePoint; using Microsoft.Office.Server.UserProfiles; using System.Security.Principal; using Microsoft.Office.Server; using Microsoft.SharePoint.Workflow; using FileHelpers; using Microsoft.SharePoint.Utilities; using System.Collections; using System.Runtime.InteropServices; #endregion static class Module1 { public const string goMan = "Domain\\goMan"; public static void Main() { SPSite site = new SPSite("http://Site/"); List ListGroupgoMan = default(List); SPWeb web = site.AllWebs("http://Site/"); SPUser user = web.AllUsers(YesMan); impersonateValidUser("goMan", Result, "toto"); UpdateAllWorkflowTasks(site.RootWeb); Console.ReadKey(); } private static bool CheckUserInGroup(SPGroup Group, string name) { bool isInGoup = false; foreach (SPUser User in Group.Users) { if (User.Name.ToLower() == name.ToLower()) { isInGoup = true; break; // TODO: might not be correct. Was : Exit For } else { isInGoup = false; } } return isInGoup; } private static List GetGoManGroup(SPWeb web) { List ListGroup = new List(); foreach (SPGroup @group in web.SiteGroups) { if (CheckUserInGroup(@group, YesMan)) { ListGroup.Add(@group); } } Console.ReadLine(); return ListGroup; } #region "Workflow" public static void UpdateAllWorkflowTasks(SPWeb web) { var q = new SPSiteDataQuery(); q.Lists = ""; q.Query = "0x010801