Exemple #1
0
        /// <summary>
        /// This method updates approval Status
        /// </summary>
        /// <param name="ItemID">int</param>
        /// <param name="ListName">string</param>
        /// <param name="CurrentWeb">SPWeb</param>
        /// <param name="Status">string</param>
        private void UpdateApprovalStatus(int ItemID,string ListName,SPWeb CurrentWeb,string Status)
        {
            using (DisabledItemEventsScope scope = new DisabledItemEventsScope())
            {
                CurrentWeb.AllowUnsafeUpdates = true;
                SPList list = CurrentWeb.Lists[ListName];
                SPListItem item = list.Items.GetItemById(ItemID);
                item["Publishable Status"] = Status;
                item.SystemUpdate();
                CurrentWeb.AllowUnsafeUpdates = false;
            }

            //Add Task Refs in the root site.
            using (DocumentApprovalTasks tasks = new DocumentApprovalTasks())
            {
                using (SPWeb ObjRootWeb = SPHelper.GetRootWeb(SPHelper.GetRootUrl(workflowProperties.SiteUrl)))
                {
                    tasks.UpdateTask(_documentApprovalTaskId, "Complete", ObjRootWeb);
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// This method handle create task event
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="e">EventArgs</param>
        private void logTaskCreated(object sender, EventArgs e)
        {
            //Add Task Refs in the root site.
            using (DocumentApprovalTasks tasks = new DocumentApprovalTasks())
            {
                using (SPWeb ObjRootWeb = SPHelper.GetRootWeb(SPHelper.GetRootUrl(workflowProperties.SiteUrl)))
                {
                    //Getting Created By - Login Name
                    SPFieldUserValue val = new SPFieldUserValue(workflowProperties.Item.Web, workflowProperties.Item["Created By"] as string);
                    SPUser usr = val.User;
                    string _documentAuthor = usr.LoginName;
                    string initiationData = workflowProperties.InitiationData;

                    // Getting Publishbale Location ID
                    var Publish_Location_ID = from _value in XElement.Load(new StringReader(EscapeXml(initiationData))).Elements("Publish_Location_ID")
                                select _value;
                    string _locationID = string.Empty;
                    foreach (var ID in Publish_Location_ID)
                    {
                        _locationID = ID.Value;
                    }

                    // Getting Publishbale Location Name
                    var Publish_Location_Name = from _value in XElement.Load(new StringReader(EscapeXml(initiationData))).Elements("Publish_Location_Name")
                                              select _value;
                    string _locationName = string.Empty;
                    foreach (var Name in Publish_Location_Name)
                    {
                        _locationName = Name.Value;
                    }

                    SPFieldLookupValue _publishableLocation = new SPFieldLookupValue(Convert.ToInt32(_locationID), _locationName); ;

                    //_publishableLocation=new SPFieldLookupValue(location
                    //Getting Approver - Login Name
                    string _taskUrl = workflowProperties.Item.Web.Url + "/Lists/DocumentApprovalTasks/DispForm.aspx?ID=" + CreateAppovalTask.ListItemId.ToString();

                    //Add Task Ref in the root site
                    _documentApprovalTaskId = tasks.AddTask(CreateAppovalTask.TaskProperties.Title, CreateAppovalTask.TaskProperties.DueDate, CreateAppovalTask.TaskProperties.AssignedTo, _documentAuthor, _taskUrl, ObjRootWeb, _publishableLocation);

                    //int _groupID = Convert.ToInt32(CreateAppovalTask.TaskProperties.AssignedTo.ToString().Split(';')[0]);
                    SPGroup _approverGroup = ObjRootWeb.Groups[CreateAppovalTask.TaskProperties.AssignedTo];

                    //Send Email notification to the approver
                    SendApproverEmail(_approverGroup, "CLIF");
                }
            }
            LogToHistoryListActivity log = (LogToHistoryListActivity)sender;
            if (log != null)
            {
                log.HistoryDescription = "Document approval task created.";
            }
        }