예제 #1
0
 private void operationsListBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (operationsListBox.SelectedItemViewControl != null)
     {
         this.addOperationButton.Visible = false;
         detailsViewPanel.Visible        = false;
         // Give the old details control a chance to valiadte its fields before tearing it down.
         foreach (Control control in detailsViewPanel.Controls)
         {
             UserControl userControl = control as UserControl;
             if (userControl != null)
             {
                 userControl.ValidateChildren();
             }
         }
         detailsViewPanel.Controls.Clear();
         operationsListBox.SelectedItemViewControl.Dock = DockStyle.Fill;
         detailsViewPanel.Controls.Add(operationsListBox.SelectedItemViewControl);
         detailsViewPanel.Visible = true;
         if (operationsListBox.SelectedItem is ServiceOperationListItem)
         {
             this.okButton.Enabled = true;
         }
         else
         {
             this.okButton.Enabled = false;
             ServiceContractListItem serviceContractListItem = this.operationsListBox.SelectedItem as ServiceContractListItem;
             if ((serviceContractListItem != null) && (serviceContractListItem.IsCustomContract))
             {
                 this.addOperationButton.Visible = true;
             }
         }
     }
 }
예제 #2
0
        private void SelectServiceOperation(OperationInfoBase operationInfo)
        {
            Fx.Assert(operationInfo != null, "operationInfo cannot be null");
            ServiceContractListItem serviceContract = this.serviceContracts.Find(operationInfo.GetContractFullName(null));

            // Dont select operation if the contract cannot be found in the serviceContracts list
            if (serviceContract == null)
            {
                return;
            }
            ServiceOperationListItem operationItem = null;

            if (operationInfo is OperationInfo)
            {
                operationItem             = new WorkflowServiceOperationListItem();
                operationItem.Validating += new CancelEventHandler(ServiceOperationValidating);

                operationItem.Name = operationInfo.Name;
                ((WorkflowServiceOperationListItem)operationItem).Operation = operationInfo as OperationInfo;
            }
            else if (operationInfo is TypedOperationInfo)
            {
                operationItem             = new TypedServiceOperationListItem();
                operationItem.Validating += new CancelEventHandler(ServiceOperationValidating);
                operationItem.Name        = operationInfo.Name;
                ((TypedServiceOperationListItem)operationItem).Operation = operationInfo as TypedOperationInfo;
            }

            serviceContract.SelectionOperation(operationItem);
        }
예제 #3
0
        public void AddServiceOperation(OperationInfoBase operationInfo, Activity implementingActivity)
        {
            if (operationInfo == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo");
            }

            TypedOperationInfo typedOperationInfo    = operationInfo as TypedOperationInfo;
            OperationInfo      workflowOperationInfo = operationInfo as OperationInfo;
            string             contractName          = operationInfo.GetContractFullName(null);

            // Do not add operation if the contractName is not valid. Not throwing here gives the user to fix
            // a broken contract/operation by selecting a different operation from the UI.
            if (String.IsNullOrEmpty(contractName))
            {
                return;
            }
            ServiceContractListItem serviceContract = this.serviceContracts.Find(contractName);

            if (typedOperationInfo != null)
            {
                if (serviceContract == null)
                {
                    serviceContract                  = new ServiceContractListItem(this.operationsListBox);
                    serviceContract.Validating      += new CancelEventHandler(ServiceContractValidating);
                    serviceContract.Name             = contractName;
                    serviceContract.ContractType     = typedOperationInfo.ContractType;
                    serviceContract.IsCustomContract = false;
                    AddServiceContract(serviceContract);
                }

                TypedServiceOperationListItem operationItem = new TypedServiceOperationListItem();
                operationItem.Validating += new CancelEventHandler(ServiceOperationValidating);
                operationItem.Name        = typedOperationInfo.Name;
                operationItem.Operation   = typedOperationInfo;

                operationItem.ImplementingActivities.Add(implementingActivity);
                serviceContract.AddOperation(operationItem);
            }
            else if (workflowOperationInfo != null)
            {
                if (serviceContract == null)
                {
                    serviceContract                  = new ServiceContractListItem(this.operationsListBox);
                    serviceContract.Validating      += new CancelEventHandler(ServiceContractValidating);
                    serviceContract.Name             = workflowOperationInfo.ContractName;
                    serviceContract.IsCustomContract = true;
                    AddServiceContract(serviceContract);
                }
                WorkflowServiceOperationListItem workflowOperationItem = new WorkflowServiceOperationListItem();
                workflowOperationItem.Validating += new CancelEventHandler(ServiceOperationValidating);
                workflowOperationItem.Operation   = workflowOperationInfo;
                workflowOperationItem.ImplementingActivities.Add(implementingActivity);
                serviceContract.AddOperation(workflowOperationItem);
            }
        }
        public void AddServiceOperation(OperationInfoBase operationInfo, Activity implementingActivity)
        {
            if (operationInfo == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("operationInfo");
            }

            TypedOperationInfo typedOperationInfo = operationInfo as TypedOperationInfo;
            OperationInfo workflowOperationInfo = operationInfo as OperationInfo;
            string contractName = operationInfo.GetContractFullName(null);
            // Do not add operation if the contractName is not valid. Not throwing here gives the user to fix 
            // a broken contract/operation by selecting a different operation from the UI.
            if (String.IsNullOrEmpty(contractName))
            {
                return;
            }
            ServiceContractListItem serviceContract = this.serviceContracts.Find(contractName);

            if (typedOperationInfo != null)
            {
                if (serviceContract == null)
                {
                    serviceContract = new ServiceContractListItem(this.operationsListBox);
                    serviceContract.Validating += new CancelEventHandler(ServiceContractValidating);
                    serviceContract.Name = contractName;
                    serviceContract.ContractType = typedOperationInfo.ContractType;
                    serviceContract.IsCustomContract = false;
                    AddServiceContract(serviceContract);
                }

                TypedServiceOperationListItem operationItem = new TypedServiceOperationListItem();
                operationItem.Validating += new CancelEventHandler(ServiceOperationValidating);
                operationItem.Name = typedOperationInfo.Name;
                operationItem.Operation = typedOperationInfo;

                operationItem.ImplementingActivities.Add(implementingActivity);
                serviceContract.AddOperation(operationItem);
            }
            else if (workflowOperationInfo != null)
            {
                if (serviceContract == null)
                {
                    serviceContract = new ServiceContractListItem(this.operationsListBox);
                    serviceContract.Validating += new CancelEventHandler(ServiceContractValidating);
                    serviceContract.Name = workflowOperationInfo.ContractName;
                    serviceContract.IsCustomContract = true;
                    AddServiceContract(serviceContract);
                }
                WorkflowServiceOperationListItem workflowOperationItem = new WorkflowServiceOperationListItem();
                workflowOperationItem.Validating += new CancelEventHandler(ServiceOperationValidating);
                workflowOperationItem.Operation = workflowOperationInfo;
                workflowOperationItem.ImplementingActivities.Add(implementingActivity);
                serviceContract.AddOperation(workflowOperationItem);
            }

        }
예제 #5
0
        private void AddServiceContract(ServiceContractListItem serviceContractListItem)
        {
            String key = serviceContractListItem.Name;

            if (this.serviceContracts.Find(key) == null)
            {
                RemoveHelpListItem();
                serviceContracts.Add(serviceContractListItem);
                operationsListBox.Items.Add(serviceContractListItem);
            }
        }
예제 #6
0
        void contractNameTextBox_Validated(object sender, EventArgs e)
        {
            ServiceContractListItem contractListItem = (ServiceContractListItem)this.Item;

            UpdateImplementingActivities(contractListItem);
            // finally notify other observers of this change
            if (this.ItemChanged != null)
            {
                this.ItemChanged.Invoke(this, null);
            }
        }
예제 #7
0
        private void addOperationButton_Click(object sender, EventArgs e)
        {
            ServiceContractListItem serviceContractListItem = this.operationsListBox.SelectedItem as ServiceContractListItem;

            Fx.Assert(serviceContractListItem != null, "service contract list item cannot be null");
            Fx.Assert(serviceContractListItem.IsCustomContract, " this should work only on a custom contract item");
            WorkflowServiceOperationListItem newWorkflowServiceOperationListItem = serviceContractListItem.CreateOperation();

            newWorkflowServiceOperationListItem.Validating += new CancelEventHandler(ServiceOperationValidating);
            this.AddServiceOperation(newWorkflowServiceOperationListItem);
            serviceContractListItem.SelectionOperation(newWorkflowServiceOperationListItem);
        }
예제 #8
0
        private void AddServiceOperation(ServiceOperationListItem serviceOperation)
        {
            if (serviceOperation == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("serviceOperation");
            }
            String key = serviceOperation.ContractName;
            ServiceContractListItem serviceContract = this.serviceContracts.Find(key);

            serviceContract.AddOperation(serviceOperation);
            serviceContract.SelectionOperation(serviceOperation);
        }
예제 #9
0
 private void UpdateImplementingActivities(ServiceContractListItem listItem)
 {
     foreach (WorkflowServiceOperationListItem workflowOperationListItem in listItem.Operations)
     {
         Fx.Assert(workflowOperationListItem != null, "Operations inside an editable contract should only be workflow first operations");
         workflowOperationListItem.Operation.ContractName = listItem.Name;
         // update the activities implementing the operation too
         foreach (Activity activity in workflowOperationListItem.ImplementingActivities)
         {
             PropertyDescriptorUtils.SetPropertyValue(this.ServiceProvider, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(activity), activity, workflowOperationListItem.Operation.Clone());
         }
     }
 }
예제 #10
0
        void NewContractButtonClicked(object sender, EventArgs e)
        {
            ServiceContractListItem contractItem = this.serviceContracts.CreateWithUniqueName();

            contractItem.Validating      += new CancelEventHandler(ServiceContractValidating);
            contractItem.IsCustomContract = true;
            this.AddServiceContract(contractItem);
            WorkflowServiceOperationListItem newWorkflowServiceOperationListItem = contractItem.CreateOperation();

            newWorkflowServiceOperationListItem.Validating += new CancelEventHandler(ServiceOperationValidating);
            this.AddServiceOperation(newWorkflowServiceOperationListItem);
            contractItem.SelectionOperation(newWorkflowServiceOperationListItem);
        }
        private void UpdateImplementingActivities(ServiceContractListItem listItem)
        {
            foreach (WorkflowServiceOperationListItem workflowOperationListItem in listItem.Operations)
            {
                Fx.Assert(workflowOperationListItem != null, "Operations inside an editable contract should only be workflow first operations");
                workflowOperationListItem.Operation.ContractName = listItem.Name;
                // update the activities implementing the operation too
                foreach (Activity activity in workflowOperationListItem.ImplementingActivities)
                {
                    PropertyDescriptorUtils.SetPropertyValue(this.ServiceProvider, ServiceOperationHelpers.GetServiceOperationInfoPropertyDescriptor(activity), activity, workflowOperationListItem.Operation.Clone());
                }

            }
        }
예제 #12
0
        public override void UpdateView()
        {
            ServiceContractListItem listItem = this.Item as ServiceContractListItem;

            Fx.Assert(listItem != null, "listItem needs to be a ServiceContractListItem");
            contractNameTextBox.Text     = listItem.Name;
            contractNameTextBox.Enabled  = true;
            contractNameTextBox.ReadOnly = true;
            if (listItem.IsCustomContract)
            {
                this.contractNameTextBox.ReadOnly    = false;
                this.contractNameTextBox.Validated  += new EventHandler(contractNameTextBox_Validated);
                this.contractNameTextBox.Validating += new CancelEventHandler(contractNameTextBox_Validating);
            }
            base.UpdateView();
        }
예제 #13
0
        void contractNameTextBox_Validating(object sender, CancelEventArgs e)
        {
            ServiceContractListItem contractListItem = (ServiceContractListItem)this.Item;
            string oldName = contractListItem.Name;

            contractListItem.Name = this.contractNameTextBox.Text;
            if (contractListItem.Validating != null)
            {
                contractListItem.Validating.Invoke(contractListItem, e);
            }
            if (e.Cancel)
            {
                this.contractNameTextBox.Text = oldName;
                contractListItem.Name         = oldName;
                e.Cancel = false;
            }
        }
예제 #14
0
        void ServiceOperationValidating(object sender, CancelEventArgs e)
        {
            ServiceOperationListItem serviceOperationListItem = (ServiceOperationListItem)sender;
            string newOperationName = serviceOperationListItem.Name;
            string contractName     = serviceOperationListItem.ContractName;

            if (string.IsNullOrEmpty(newOperationName))
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.OperationNameCannotBeEmpty);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }

            Fx.Assert(!string.IsNullOrEmpty(contractName), "contract name should be valid to run this check");
            ServiceContractListItem contractListItem = serviceContracts.Find(contractName);

            Fx.Assert(contractListItem != null, "contract should be present in the list to run this check");

            // operation names must be unique inside a contract
            bool duplicatesFound = false;

            foreach (ServiceOperationListItem foundOperation in contractListItem.Operations)
            {
                if (foundOperation == serviceOperationListItem)
                {
                    continue;
                }
                if (foundOperation.Name.Equals(newOperationName))
                {
                    duplicatesFound = true;
                    break;
                }
            }
            if (duplicatesFound)
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.OperationNameMustBeUnique);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
예제 #15
0
        void ServiceContractValidating(object sender, CancelEventArgs e)
        {
            ServiceContractListItem serviceContractListItem = (ServiceContractListItem)sender;

            if (string.IsNullOrEmpty(serviceContractListItem.Name))
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.ContractNameCannotBeEmpty);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
            bool duplicatesFound = false;

            foreach (ServiceContractListItem foundContract in serviceContracts)
            {
                if (foundContract == serviceContractListItem)
                {
                    continue;
                }

                // allow reimport of existing imported contracts
                if (!serviceContractListItem.IsCustomContract && serviceContractListItem.ContractType.Equals(foundContract.ContractType))
                {
                    continue;
                }

                if (foundContract.Name.Equals(serviceContractListItem.Name))
                {
                    duplicatesFound = true;
                    break;
                }
            }
            // contract names must be unique
            if (duplicatesFound)
            {
                e.Cancel = true;
                string errorString = SR2.GetString(SR2.ContractNameMustBeUnique);
                DesignerHelpers.ShowMessage(this.serviceProvider, errorString, System.Workflow.ComponentModel.Design.DR.GetString(System.Workflow.ComponentModel.Design.DR.WorkflowDesignerTitle), MessageBoxButtons.OK,
                                            MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
        }
예제 #16
0
        void ImportContractButtonClicked(object sender, EventArgs e)
        {
            using (TypeBrowserDialog typeBrowserDialog = new TypeBrowserDialog(serviceProvider as IServiceProvider, new ServiceContractsTypeFilterProvider(), "System.String"))
            {
                typeBrowserDialog.ShowDialog();
                if (typeBrowserDialog.SelectedType != null)
                {
                    ServiceContractListItem contractItem = new ServiceContractListItem(this.operationsListBox);
                    contractItem.Validating      += new CancelEventHandler(ServiceContractValidating);
                    contractItem.Name             = typeBrowserDialog.SelectedType.FullName;
                    contractItem.ContractType     = typeBrowserDialog.SelectedType;
                    contractItem.IsCustomContract = false;
                    CancelEventArgs cancelEventArgs = new CancelEventArgs();
                    contractItem.Validating.Invoke(contractItem, cancelEventArgs);
                    if (cancelEventArgs.Cancel)
                    {
                        return;
                    }
                    AddServiceContract(contractItem);

                    ImportContract(typeBrowserDialog.SelectedType);
                }
            }
        }
 private void AddServiceContract(ServiceContractListItem serviceContractListItem)
 {
     String key = serviceContractListItem.Name;
     if (this.serviceContracts.Find(key) == null)
     {
         RemoveHelpListItem();
         serviceContracts.Add(serviceContractListItem);
         operationsListBox.Items.Add(serviceContractListItem);
     }
 }
        void ImportContractButtonClicked(object sender, EventArgs e)
        {
            using (TypeBrowserDialog typeBrowserDialog = new TypeBrowserDialog(serviceProvider as IServiceProvider, new ServiceContractsTypeFilterProvider(), "System.String"))
            {
                typeBrowserDialog.ShowDialog();
                if (typeBrowserDialog.SelectedType != null)
                {
                    ServiceContractListItem contractItem = new ServiceContractListItem(this.operationsListBox);
                    contractItem.Validating += new CancelEventHandler(ServiceContractValidating);
                    contractItem.Name = typeBrowserDialog.SelectedType.FullName;
                    contractItem.ContractType = typeBrowserDialog.SelectedType;
                    contractItem.IsCustomContract = false;
                    CancelEventArgs cancelEventArgs = new CancelEventArgs();
                    contractItem.Validating.Invoke(contractItem, cancelEventArgs);
                    if (cancelEventArgs.Cancel)
                    {
                        return;
                    }
                    AddServiceContract(contractItem);

                    ImportContract(typeBrowserDialog.SelectedType);
                }
            }
        }