public virtual Activity CreateActivity() { var activity = new Activity(UserConnection); activity.SetDefColumnValues(); activity.Id = Guid.NewGuid(); activity.TypeId = ActivityConsts.TaskTypeUId; activity.Title = GetActivityTitle(); activity.StartDate = GetDateTime(UserConnection.CurrentUser.GetCurrentDateTime(), StartIn, (ProcessDurationPeriod)StartInPeriod); activity.DueDate = GetDateTime(activity.StartDate, Duration, (ProcessDurationPeriod)DurationPeriod); activity.ActivityCategoryId = ActivityCategory; activity.ShowInScheduler = ShowInScheduler; if (OwnerId != Guid.Empty) { activity.OwnerId = OwnerId; if (RemindBefore != 0) { activity.RemindToOwner = true; activity.RemindToOwnerDate = GetDateTime(activity.StartDate, -1 * RemindBefore, (ProcessDurationPeriod)RemindBeforePeriod); } } var columnLead = activity.Schema.Columns.FindByName("Lead"); if (columnLead != null && Lead != Guid.Empty) { activity.SetColumnValue(columnLead, Lead); } if (Account != Guid.Empty) { activity.AccountId = Account; } if (Contact != Guid.Empty) { activity.ContactId = Contact; } var columnOpportunity = activity.Schema.Columns.FindByName("Opportunity"); if (columnOpportunity != null && Opportunity != Guid.Empty) { activity.SetColumnValue(columnOpportunity, Opportunity); } var columnInvoice = activity.Schema.Columns.FindByName("Invoice"); if (columnInvoice != null && Invoice != Guid.Empty) { activity.SetColumnValue(columnInvoice, Invoice); } var columnCase = activity.Schema.Columns.FindByName("Case"); if (columnCase != null && Case != Guid.Empty) { activity.SetColumnValue(columnCase, Case); } var columnOrder = activity.Schema.Columns.FindByName("Order"); if (columnOrder != null && Order != Guid.Empty) { activity.SetColumnValue(columnOrder, Order); } var columnRequests = activity.Schema.Columns.FindByName("Requests"); if (columnRequests != null && Requests != Guid.Empty) { activity.SetColumnValue(columnRequests, Requests); } var columnListing = activity.Schema.Columns.FindByName("Listing"); if (columnListing != null && Listing != Guid.Empty) { activity.SetColumnValue(columnListing, Listing); } var columnProperty = activity.Schema.Columns.FindByName("Property"); if (columnProperty != null && Property != Guid.Empty) { activity.SetColumnValue(columnProperty, Property); } var columnContract = activity.Schema.Columns.FindByName("Contract"); if (columnContract != null && Contract != Guid.Empty) { activity.SetColumnValue(columnContract, Contract); } var columnProject = activity.Schema.Columns.FindByName("Project"); if (columnProject != null && Project != Guid.Empty) { activity.SetColumnValue(columnProject, Project); } var columnDocument = activity.Schema.Columns.FindByName("Document"); if (columnDocument != null && Document != Guid.Empty) { activity.SetColumnValue(columnDocument, Document); } var columnChange = activity.Schema.Columns.FindByName("Change"); if (columnChange != null && Change != Guid.Empty) { activity.SetColumnValue(columnChange, Change); } var columnRelease = activity.Schema.Columns.FindByName("Release"); if (columnRelease != null && Release != Guid.Empty) { activity.SetColumnValue(columnRelease, Release); } var columnProblem = activity.Schema.Columns.FindByName("Problem"); if (columnProblem != null && Problem != Guid.Empty) { activity.SetColumnValue(columnProblem, Problem); } BaseProcessUserTaskUtilities.SetEntityColumnValues(this, activity); activity.ProcessElementId = UId; activity.AllowedResult = JsonConvert.SerializeObject(GetResultParameterAllowedValues(), Formatting.None, new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All, TypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple }); Guid resultColumnUId = activity.Schema.Columns.GetByName("Status").UId; UserConnection.IProcessEngine .AddProcessListener(activity, UId, GetConditionData(resultColumnUId, activity)); IsActivityCompleted = false; CurrentActivityId = activity.Id; return(activity); }
public virtual Activity CreateActivity() { var activity = new Activity(UserConnection); activity.SetDefColumnValues(); activity.Id = Guid.NewGuid(); activity.TypeId = ActivityConsts.TaskTypeUId; string subject = GetActivityTitle(); SysUserInfo currentUser = UserConnection.CurrentUser; DateTime startDate = NewDate(currentUser.GetCurrentDateTime(), StartIn, (ProcessDurationPeriod)StartInPeriod); activity.Title = subject; activity.StartDate = startDate; activity.DueDate = NewDate(activity.StartDate, Duration, (ProcessDurationPeriod)DurationPeriod); if (ActivityCategory.Equals(Guid.Empty)) { // Sets the Activity's category "To do" by default ActivityCategory = new Guid("F51C4643-58E6-DF11-971B-001D60E938C6"); } activity.ActivityCategoryId = ActivityCategory; activity.ShowInScheduler = ShowInScheduler; if (OwnerId != Guid.Empty) { activity.OwnerId = OwnerId; if (RemindBefore != 0) { activity.RemindToOwner = true; activity.RemindToOwnerDate = NewDate(activity.StartDate, -1 * RemindBefore, (ProcessDurationPeriod)RemindBeforePeriod); } } var columnLead = activity.Schema.Columns.FindByName("Lead"); if (columnLead != null && Lead != Guid.Empty) { activity.SetColumnValue(columnLead, Lead); } if (Account != Guid.Empty) { activity.AccountId = Account; } if (Contact != Guid.Empty) { activity.ContactId = Contact; } var columnOpportunity = activity.Schema.Columns.FindByName("Opportunity"); if (columnOpportunity != null && Opportunity != Guid.Empty) { activity.SetColumnValue(columnOpportunity, Opportunity); } var columnDocument = activity.Schema.Columns.FindByName("Document"); if (columnDocument != null && Document != Guid.Empty) { activity.SetColumnValue(columnDocument, Document); } var columnInvoice = activity.Schema.Columns.FindByName("Invoice"); if (columnInvoice != null && Invoice != Guid.Empty) { activity.SetColumnValue(columnInvoice, Invoice); } var columnCase = activity.Schema.Columns.FindByName("Case"); if (columnCase != null && Case != Guid.Empty) { activity.SetColumnValue(columnCase, Case); } var columnOrder = activity.Schema.Columns.FindByName("Order"); if (columnOrder != null && Order != Guid.Empty) { activity.SetColumnValue(columnOrder, Order); } var columnProject = activity.Schema.Columns.FindByName("Project"); if (columnProject != null && Project != Guid.Empty) { activity.SetColumnValue(columnProject, Project); } var columnRequests = activity.Schema.Columns.FindByName("Requests"); if (columnRequests != null && Requests != Guid.Empty) { activity.SetColumnValue(columnRequests, Requests); } var columnListing = activity.Schema.Columns.FindByName("Listing"); if (columnListing != null && Listing != Guid.Empty) { activity.SetColumnValue(columnListing, Listing); } var columnProperty = activity.Schema.Columns.FindByName("Property"); if (columnProperty != null && Property != Guid.Empty) { activity.SetColumnValue(columnProperty, Property); } var columnContract = activity.Schema.Columns.FindByName("Contract"); if (columnContract != null && Contract != Guid.Empty) { activity.SetColumnValue(columnContract, Contract); } var columnChange = activity.Schema.Columns.FindByName("Change"); if (columnChange != null && Change != Guid.Empty) { activity.SetColumnValue(columnChange, Change); } var columnRelease = activity.Schema.Columns.FindByName("Release"); if (columnRelease != null && Release != Guid.Empty) { activity.SetColumnValue(columnRelease, Release); } var columnProblem = activity.Schema.Columns.FindByName("Problem"); if (columnProblem != null && Problem != Guid.Empty) { activity.SetColumnValue(columnProblem, Problem); } var columnApplication = activity.Schema.Columns.FindByName("Application"); if (columnApplication != null && Application != Guid.Empty) { activity.SetColumnValue(columnApplication, Application); } var columnFinApplication = activity.Schema.Columns.FindByName("FinApplication"); if (columnFinApplication != null && FinApplication != Guid.Empty) { activity.SetColumnValue(columnFinApplication, FinApplication); } BaseProcessUserTaskUtilities.SetEntityColumnValues(this, activity); activity.ProcessElementId = UId; activity.AllowedResult = GetResultAllowedValues(); Guid resultColumnUId = activity.Schema.Columns.GetByName("Status").UId; // After adding process listener entity is saved UserConnection.IProcessEngine .AddProcessListener(activity, UId, GetConditionData(resultColumnUId, activity)); UserConnection.IProcessEngine.LinkProcessToEntity(Owner, activity.Schema.UId, activity.Id); IsActivityCompleted = false; CurrentActivityId = activity.Id; return(activity); }