public override bool CompleteExecuting(params object[] parameters)
        {
            var activity = parameters[0] as Activity;

            if (activity == null)
            {
                return(false);
            }
            OwnerId = activity.OwnerId;
            var columnLead = activity.Schema.Columns.FindByName("Lead");

            if (columnLead != null)
            {
                object lead = activity.GetColumnValue(columnLead);
                if (lead != null)
                {
                    Lead = (Guid)lead;
                }
            }
            Account = activity.AccountId;
            Contact = activity.ContactId;
            var columnOpportunity = activity.Schema.Columns.FindByName("Opportunity");

            if (columnOpportunity != null)
            {
                object opportunity = activity.GetColumnValue(columnOpportunity);
                if (opportunity != null)
                {
                    Opportunity = (Guid)opportunity;
                }
            }
            var columnInvoice = activity.Schema.Columns.FindByName("Invoice");

            if (columnInvoice != null)
            {
                object invoice = activity.GetColumnValue(columnInvoice);
                if (invoice != null)
                {
                    Invoice = (Guid)invoice;
                }
            }
            var columnOrder = activity.Schema.Columns.FindByName("Order");

            if (columnOrder != null)
            {
                object order = activity.GetColumnValue(columnOrder);
                if (order != null)
                {
                    Order = (Guid)order;
                }
            }
            var columnRequests = activity.Schema.Columns.FindByName("Requests");

            if (columnRequests != null)
            {
                object requests = activity.GetColumnValue(columnRequests);
                if (requests != null)
                {
                    Requests = (Guid)requests;
                }
            }
            var columnListing = activity.Schema.Columns.FindByName("Listing");

            if (columnListing != null)
            {
                object listing = activity.GetColumnValue(columnListing);
                if (listing != null)
                {
                    Listing = (Guid)listing;
                }
            }
            var columnProperty = activity.Schema.Columns.FindByName("Property");

            if (columnProperty != null)
            {
                object property = activity.GetColumnValue(columnProperty);
                if (property != null)
                {
                    Property = (Guid)property;
                }
            }
            var columnContract = activity.Schema.Columns.FindByName("Contract");

            if (columnContract != null)
            {
                object contract = activity.GetColumnValue(columnContract);
                if (contract != null)
                {
                    Contract = (Guid)contract;
                }
            }
            var columnProject = activity.Schema.Columns.FindByName("Project");

            if (columnProject != null)
            {
                object project = activity.GetColumnValue(columnProject);
                if (project != null)
                {
                    Project = (Guid)project;
                }
            }
            var columnDocument = activity.Schema.Columns.FindByName("Document");

            if (columnDocument != null)
            {
                object document = activity.GetColumnValue(columnDocument);
                if (document != null)
                {
                    Document = (Guid)document;
                }
            }
            var columnChange = activity.Schema.Columns.FindByName("Change");

            if (columnChange != null)
            {
                object change = activity.GetColumnValue(columnChange);
                if (change != null)
                {
                    Change = (Guid)change;
                }
            }
            var columnProblem = activity.Schema.Columns.FindByName("Problem");

            if (columnProblem != null)
            {
                object problem = activity.GetColumnValue(columnProblem);
                if (problem != null)
                {
                    Problem = (Guid)problem;
                }
            }
            var columnRelease = activity.Schema.Columns.FindByName("Release");

            if (columnRelease != null)
            {
                object release = activity.GetColumnValue(columnRelease);
                if (release != null)
                {
                    Release = (Guid)release;
                }
            }
            EntitySchemaColumn columnApplication = activity.Schema.Columns.FindByName("Application");

            if (columnApplication != null)
            {
                object application = activity.GetColumnValue(columnApplication);
                if (application != null)
                {
                    Application = (Guid)application;
                }
            }
            EntitySchemaColumn columnFinApplication = activity.Schema.Columns.FindByName("FinApplication");

            if (columnFinApplication != null)
            {
                object finApplication = activity.GetColumnValue(columnFinApplication);
                if (finApplication != null)
                {
                    FinApplication = (Guid)finApplication;
                }
            }
            BaseProcessUserTaskUtilities.SetDynamicParameterValues(this, activity);
            ActivityResult      = activity.ResultId;
            IsActivityCompleted = true;
            bool result = base.CompleteExecuting(parameters);

            activity.SetColumnValue("ProcessElementId", null);
            activity.UseAdminRights = false;
            activity.Save();
            return(result);
        }
예제 #2
0
        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);
        }