Beispiel #1
0
        /// <summary>
        /// Download dependencies and copy them to the deploy directory's \bin subdirectory
        /// </summary>
        /// <param name="client"></param>
        /// <param name="destinationDirectoryPath"></param>
        /// <param name="dependencies"></param>
        public static void DownloadDependencies(IWorkflowsQueryService client, string destinationDirectoryPath, StoreActivityLibrariesDependenciesDC dependencies)
        {
            // IIS needs assemblies to go under bin subdirectory whereas .xamlx goes in the root
            string binPath = Path.Combine(destinationDirectoryPath, "bin");
            Directory.CreateDirectory(binPath);

            foreach (var dependentAssembly in dependencies.StoreDependenciesDependentActiveLibraryList)
            {
                var reply = client.ActivityLibraryGet(new ActivityLibraryDC
                {
                    Incaller = "DeployToIIS Activity",
                    IncallerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                    Id = dependentAssembly.activityLibraryDependentId
                }).Single();
                string destFile = Path.Combine(binPath, reply.Name + ".dll");
                File.WriteAllBytes(destFile, reply.Executable);
            }
        }
        /// <summary>
        /// Gets the Workflow Template Activity Item based on the Selected Workflow Template, and its dependencies
        /// </summary>
        /// <returns>The Activity Item that will have the XAML required to create the workflow from the specified Workflow Template</returns>
        private WorkflowItem GetWorkflowTemplateActivityExecute(IWorkflowsQueryService client)
        {
            WorkflowItem workflowActivityTemplateItem = null;
            List<StoreActivitiesDC> storeActivitiesList = null;
            ActivityAssemblyItem workflowActivityTemplateItemAssembly = null;
            StoreActivitiesDC targetDC = null;
            ActivityLibraryDC targetLibrary = null;
            List<ActivityLibraryDC> activityLibraryList;

            // Throw if nothing selected. CanExecute should prevent this.
            if (null == SelectedWorkflowTemplateItem)
                throw new ArgumentNullException();
            // Create the Activity request
            var requestActivity = new StoreActivitiesDC()
                                                    {
                                                        Incaller = Assembly.GetExecutingAssembly().GetName().Name,
                                                        IncallerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                                                        Id = SelectedWorkflowTemplateItem.WorkflowTemplateId
                                                    };

            // Get the List of Activities that qualify, should only be one
            storeActivitiesList = client.StoreActivitiesGet(requestActivity);
            storeActivitiesList[0].StatusReply.CheckErrors();
            if (null != storeActivitiesList)
            {
                // Get the first or one and only StoreActivity
                targetDC = storeActivitiesList.First();
                // We have to get the Activity Library associated with the Store Activity
                if (0 != targetDC.ActivityLibraryId)
                {
                    List<ActivityAssemblyItem> references = new List<ActivityAssemblyItem>();
                    Utility.DoTaskWithBusyCaption("Loading...",() =>
                    {
                        // Create the Library request
                        var requestLibrary = new ActivityLibraryDC
                        {
                            Incaller = Assembly.GetExecutingAssembly().GetName().Name,
                            IncallerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString(),
                            Id = targetDC.ActivityLibraryId
                        };
                        // Get the list
                        try
                        {
                            activityLibraryList = client.ActivityLibraryGet(requestLibrary);
                        }

                        catch (FaultException<ServiceFault> ex)
                        {
                            throw new CommunicationException(ex.Detail.ErrorMessage);
                        }
                        catch (FaultException<ValidationFault> ex)
                        {
                            throw new BusinessValidationException(ex.Detail.ErrorMessage);
                        }
                        catch (Exception ex)
                        {
                            throw new CommunicationException(ex.Message);
                        }

                        // Get the First one or null, should only be one
                        targetLibrary = activityLibraryList.FirstOrDefault();
                        workflowActivityTemplateItemAssembly = DataContractTranslator.ActivityLibraryDCToActivityAssemblyItem(targetLibrary);

                        // download dependencies
                        references = Caching.CacheAndDownloadAssembly(client, Caching.ComputeDependencies(client, workflowActivityTemplateItemAssembly));
                    });

                    workflowActivityTemplateItem = DataContractTranslator.StoreActivitiyDCToWorkflowItem(targetDC, workflowActivityTemplateItemAssembly, references);
                    workflowActivityTemplateItem.WorkflowType = SelectedWorkflowTemplateItem.WorkflowTypeName;
                    workflowActivityTemplateItem.IsOpenFromServer = false;
                }
            }
            return workflowActivityTemplateItem;   // Return the ActivityItem
        }
Beispiel #3
0
        /// <summary>
        /// Method gets the Executable that this Activity Library represents
        /// </summary>
        /// <param name="client">The WCF Service</param>
        /// <param name="aai">The ActivityAssemblyItem</param>
        /// <returns>a Byte[]</returns>
        public static byte[] GetExecutableBytes(IWorkflowsQueryService client, ActivityAssemblyItem aai)
        {
            List<ActivityLibraryDC> replyList;

            if (aai == null)
            {
                throw new Exception("aai");
            }

            byte[] sourceFileBytes = null;

            var request = new ActivityLibraryDC
            {
                Name = aai.Name,
                VersionNumber = aai.Version.ToString(),
                Incaller = Environment.UserName,
                IncallerVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString()
            };

            try
            {
                replyList = client.ActivityLibraryGet(request);
            }
            catch (FaultException<ServiceFault> ex)
            {
                throw new CommunicationException(ex.Detail.ErrorMessage);
            }
            catch (FaultException<ValidationFault> ex)
            {
                throw new BusinessValidationException(ex.Detail.ErrorMessage);
            }
            catch (Exception ex)
            {
                throw new CommunicationException(ex.Message);
            }

            if ((null != replyList) && (0 < replyList.Count))
            {
                sourceFileBytes = replyList[0].Executable;
            }

            return sourceFileBytes;
        }