Esempio n. 1
0
        /// <summary>
        /// Gets the next version number for a workflow.
        /// </summary>
        /// <param name="request">An object describing the workflow for which we need a new version number.</param>
        /// <param name="userName">The name of the user making the request.</param>
        /// <returns></returns>
        public static Version GetNextVersion(StoreActivitiesDC request, string userName)
        {
            var checkResult = VersionHelper.CheckVersioningRules(request, null, userName);
            Version result = Version.Parse(request.Version);

            // Item1 is the boolean entry in the tuple indicating success or failure
            // If the version number passed in passes the rules, it is OK to use it -- return it unaltered.
            // If not, ask what the next available version number is, and return that, instead.
            if (!checkResult.Item1)
                result = VersionHelper.GetNextVersion(request);

            return result;
        }
Esempio n. 2
0
 /// <summary>
 /// Set lock on StoreActivities
 /// </summary>
 /// <param name="request"></param>
 /// <param name="lockedTime"></param>
 /// <returns></returns>
 public static StatusReplyDC StoreActivitiesSetLock(StoreActivitiesDC request, DateTime lockedTime)
 {
     var result = Activities.StoreActivitiesGetByName(request.Name, string.Empty);
     if (result.Any())
     {
         return Activities.StoreActivitiesUpdateLock(request, lockedTime).StatusReply;
     }
     else
     {
         return new StatusReplyDC();
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Uploads three objects
        /// 1. Activity library
        /// 2. Activities associated with the activity library
        /// 3. Activity Library dependency list
        /// </summary>
        /// <param name="request">StoreLibraryAndActivitiesRequestDC object</param>
        /// <returns>StatusReplyDC object</returns>
        public static List<StoreActivitiesDC> UploadActivityLibraryAndDependentActivities(StoreLibraryAndActivitiesRequestDC request)
        {
            List<StoreActivitiesDC> reply = new List<StoreActivitiesDC>();
            reply.Add(new StoreActivitiesDC());
            StatusReplyDC status = new StatusReplyDC();
            var publishingState = String.Empty;
            Tuple<bool, string> dependencyCheckResult;  // true/false for if the dependencies pass, and a string error message if there are problems
            StoreActivitiesDC activityDC = new StoreActivitiesDC()
            {
                Incaller = request.Incaller,
                IncallerVersion = request.IncallerVersion,
                Locked = false,
                LockedBy = null,
            };
            Version nextVersion = null;

            request.ActivityLibrary.Incaller = request.Incaller;
            request.ActivityLibrary.IncallerVersion = request.IncallerVersion;

            //// Check if the library is in production first. If so bail.
            if (IsLibraryInProduction(request.ActivityLibrary))
            {
                status = SetUpReplyStatus(SprocValues.ACTIVITYLIBRARY_MARKED_FOR_PRODUCTION_ID, SprocValues.ACTIVITYLIBRARY_MARKED_FOR_PRODUCTION_MSG, Convert.ToString(Guid.Empty));
                return SetupErrorReply(reply, status);
            }

            if (request.EnforceVersionRules)
            {
                var checkReply = ActivityBusinessService.CheckActivityExists(request.StoreActivitiesList[0]);

                if (checkReply.Errorcode == 0)
                {
                    bool exists = false;

                    if (bool.TryParse(checkReply.Output, out exists) && exists)
                    {
                        nextVersion = GetNextVersion(request.StoreActivitiesList[0], Environment.UserName);
                    }
                }

                dependencyCheckResult = VersionHelper.CheckDependencyRules(request);

                if (!dependencyCheckResult.Item1)
                    throw new VersionException(dependencyCheckResult.Item2, null);

                reply.Clear();

            }

            using (var scope = new TransactionScope())
            {

                if (string.IsNullOrEmpty(request.ActivityLibrary.StatusName))
                    throw new ValidationException(-1, "'Status Name' for Activity Library records cannot be null.");

                if (request.EnforceVersionRules)
                {
                    foreach (var activity in request.StoreActivitiesList)
                    {
                        activityDC.Name = activity.Name;
                        activityDC.Version = activity.OldVersion;
                        List<StoreActivitiesDC> existingRecords = Activities.StoreActivitiesGetByName(activityDC.Name, string.Empty);
                        if (existingRecords.Any())
                        {
                            //Clear the Store Activities lock
                            var lockReply = Activities.StoreActivitiesUpdateLock(activityDC, DateTime.Now);
                            if (lockReply.StatusReply.Errorcode != 0)
                            {
                                status = SetUpReplyStatus(lockReply.StatusReply.Errorcode, lockReply.StatusReply.ErrorMessage, Convert.ToString(Guid.Empty));
                                return SetupErrorReply(reply, status);
                            }
                        }
                    }

                    if (nextVersion != null)
                    {
                        request.ActivityLibrary.VersionNumber = nextVersion.ToString();
                        request.StoreActivitiesList[0].Version = nextVersion.ToString();
                        request.StoreActivityLibraryDependenciesGroupsRequestDC.Version = nextVersion.ToString();
                    }
                }

                // add the entires
                // Create the ActivityLibrary
                var activityLibraryDCCreate = request.ActivityLibrary;
                activityLibraryDCCreate.Incaller = request.Incaller;
                activityLibraryDCCreate.IncallerVersion = request.IncallerVersion;
                ActivityLibraryDC createALreply = ActivityLibrary.ActivityLibraryCreateOrUpdate(activityLibraryDCCreate);
                if (createALreply.StatusReply.Errorcode != 0)
                {
                    status = SetUpReplyStatus(createALreply.StatusReply.Errorcode, createALreply.StatusReply.ErrorMessage, Convert.ToString(Guid.Empty));
                    return SetupErrorReply(reply, status);
                }

                // Store the store activities
                foreach (var activity in request.StoreActivitiesList)
                {
                    activity.Incaller = request.Incaller;
                    activity.IncallerVersion = request.IncallerVersion;
                    activity.ActivityLibraryName = request.ActivityLibrary.Name;
                    activity.ActivityLibraryVersion = request.ActivityLibrary.VersionNumber;
                    activity.AuthGroupName = request.ActivityLibrary.AuthGroupName;
                    activity.Locked = true;
                    activity.LockedBy = request.InUpdatedByUserAlias;
                    StoreActivitiesDC createSAreply = null;
                    createSAreply = Activities.StoreActivitiesCreateOrUpdate(activity);
                    if (createSAreply.StatusReply.Errorcode != 0)
                    {
                        status = SetUpReplyStatus(createSAreply.StatusReply.Errorcode, createSAreply.StatusReply.ErrorMessage, Convert.ToString(Guid.Empty));
                        return SetupErrorReply(reply, status);
                    }
                    reply.Add(createSAreply);
                }

                if (request.TaskActivitiesList != null)
                    //Store TaskActivityDC
                    foreach (var ta in request.TaskActivitiesList)
                    {
                        ta.Incaller = request.Incaller;
                        ta.IncallerVersion = request.IncallerVersion;
                        if (ta.TaskActivitiesList != null && ta.TaskActivitiesList[0] != null)
                        {
                            if (ta.TaskActivitiesList[0].Status == TaskActivityStatus.Unassigned)
                            {
                                ta.TaskActivitiesList[0].Incaller = request.Incaller;
                                ta.TaskActivitiesList[0].IncallerVersion = request.IncallerVersion;
                                TaskActivityRepositoryService.TaskActivity_SetStatus(ta.TaskActivitiesList[0]);
                            }
                            else
                            {
                                var statusReply = ActivityRepositoryService.CheckActivityExists(ta.TaskActivitiesList[0].Activity);
                                if (statusReply.Output != Convert.ToString(true))
                                //|| ta.TaskActivitiesList[0].Status == TaskActivityStatus.Assigned
                                //|| ta.TaskActivitiesList[0].Status == TaskActivityStatus.CheckedIn)
                                {
                                    ta.EnforceVersionRules = true;
                                    List<TaskActivityDC> taReply = SaveStoreLibraryAndTaskActivity(ta);
                                    if (taReply != null && taReply[0] != null)
                                        if (taReply[0].StatusReply.Errorcode != 0)
                                        {
                                            status = SetUpReplyStatus(taReply[0].StatusReply.Errorcode, taReply[0].StatusReply.ErrorMessage, Convert.ToString(Guid.Empty));
                                            return SetupErrorReply(reply, status);
                                        }
                                }
                            }

                        }
                    }

                // Create the ActivityLibrary dependency list
                // store the 1st entry
                // create the head list
                try
                {
                    if (request.StoreActivityLibraryDependenciesGroupsRequestDC != null)
                    {
                        if (request.StoreActivityLibraryDependenciesGroupsRequestDC.List != null &&
                            request.StoreActivityLibraryDependenciesGroupsRequestDC.List.Count > 0)
                        {
                            var headList = new ActivityLibraryDependenciesListHeadCreateOrUpdateRequestDC();

                            headList.Name = request.ActivityLibrary.Name;
                            headList.Version = request.ActivityLibrary.VersionNumber;
                            headList.Incaller = request.Incaller;
                            headList.IncallerVersion = request.IncallerVersion;
                            headList.InInsertedByUserAlias = request.InInsertedByUserAlias;
                            headList.InUpdatedByUserAlias = request.InUpdatedByUserAlias;
                            StatusReplyDC replyHeadCreate = ActivityLibraryDependency.ActivityLibraryDependenciesListHeadCreateOrUpdate(headList);

                            if (replyHeadCreate.Errorcode != 0)
                                return SetupErrorReply(reply, status);

                            StatusReplyDC ActivityLibraryDependenciesCreateOrUpdateStatusReply = null;
                            ActivityLibraryDependenciesCreateOrUpdateStatusReply =
                                ActivityLibraryDependenciesCreateOrUpdate(
                                                                            request.StoreActivityLibraryDependenciesGroupsRequestDC.Name,
                                                                            request.StoreActivityLibraryDependenciesGroupsRequestDC.Version,
                                                                            request.StoreActivityLibraryDependenciesGroupsRequestDC.List,
                                                                            request.Incaller,
                                                                            request.IncallerVersion,
                                                                            request.InInsertedByUserAlias,
                                                                            request.InUpdatedByUserAlias
                                                                          );
                            if (ActivityLibraryDependenciesCreateOrUpdateStatusReply.Errorcode != 0)
                                return SetupErrorReply(reply, ActivityLibraryDependenciesCreateOrUpdateStatusReply);
                        }
                    }
                }
                catch (TransactionAbortedException tex)
                {
                    status = SetUpReplyStatus(SprocValues.GENERIC_CATCH_ID,
                                             "[UploadActivityLibraryAndDependentActivities]" + tex.Message,
                                             Convert.ToString(Guid.Empty));
                    return SetupErrorReply(reply, status);
                }
                catch (Exception ex)
                {
                    status = SetUpReplyStatus(SprocValues.GENERIC_CATCH_ID,
                                             "[UploadActivityLibraryAndDependentActivities]" + ex.Message,
                                             Convert.ToString(Guid.Empty));
                    return SetupErrorReply(reply, status);
                }

                scope.Complete();
                return reply;
            }
        }
 /// <summary>
 /// Set lock on StoreActivities
 /// </summary>
 /// <param name="request"></param>
 /// <param name="lockedTime"></param>
 /// <returns></returns>
 public StatusReplyDC StoreActivitiesSetLock(StoreActivitiesDC request, DateTime lockedTime)
 {
     if (request == null)
     {
         return SetupStatusreplyNullRequestError();
     }
     return CWF.BAL.Services.StoreActivitiesSetLock(request, lockedTime);
 }
 /// <summary>
 /// Get all records for a workflow name that are public or retired, plus all workflows with that 
 /// name that are private and owned by the specified user.
 /// </summary>
 /// <param name="request">StoreActivitiesDC object</param>
 /// <returns></returns>
 public IList<StoreActivitiesDC> StoreActivitiesGetByName(StoreActivitiesDC request)
 {
     if (request == null)
     {
         var reply = new List<StoreActivitiesDC>();
         reply.Add(new StoreActivitiesDC());
         reply[0].StatusReply = SetupStatusreplyNullRequestError();
         return reply;
     }
     return Activities.StoreActivitiesGetByName(request.Name, string.Empty);
 }
        /// <summary>
        /// Get StoreActivities row(s)
        /// </summary>
        /// <param name="request">StoreActivitiesDC object</param>
        /// <returns>reply object</returns>
        public List<StoreActivitiesDC> StoreActivitiesGet(StoreActivitiesDC request)
        {
            //// Eliminate with validation pipeline implementation
            if (request == null)
            {
                var reply = new List<StoreActivitiesDC>();
                reply.Add(new StoreActivitiesDC());
                reply[0].StatusReply = SetupStatusreplyNullRequestError();
                return reply;
            }

            return Activities.StoreActivitiesGet(request);
        }
 /// <summary>
 /// Gets the next version number for a workflow.
 /// </summary>
 /// <param name="request">An object describing the workflow for which we need a new version number.</param>
 /// <param name="userName">The name of the user making the request.</param>
 /// <returns></returns>
 public Version GetNextVersion(StoreActivitiesDC request, string userName)
 {
     return CWF.BAL.Services.GetNextVersion(request, userName);
 }
Esempio n. 8
0
 /// <summary>
 /// Compute ActivityAssemblyItem dependencies
 /// </summary>
 /// <param name="client"></param>
 /// <param name="workflowAssembly"></param>
 /// <returns></returns>
 public static StoreActivityLibrariesDependenciesDC ComputeDependencies(IWorkflowsQueryService client, StoreActivitiesDC activity)
 {
     var dependenciesByID = client.StoreActivityLibraryDependenciesTreeGet(
         new StoreActivityLibrariesDependenciesDC
         {
             StoreDependenciesRootActiveLibrary =
             new StoreDependenciesRootActiveLibrary()
             {
                 activityLibraryId = activity.ActivityLibraryId,
                 activityLibraryName = activity.ActivityLibraryName,
                 activityLibraryVersionNumber = activity.ActivityLibraryVersion
             },
             Incaller = "DeployToIIS Activity",
             IncallerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString()
         });
     return dependenciesByID.Single();
 }