예제 #1
0
        private async Task GetSdkMessageFiltersAsync(IOrganizationServiceExtented service)
        {
            var repository = new SdkMessageFilterRepository(service);

            var filters = await repository.GetAllAsync(new ColumnSet(SdkMessageFilter.Schema.Attributes.sdkmessageid, SdkMessageFilter.Schema.Attributes.primaryobjecttypecode, SdkMessageFilter.Schema.Attributes.secondaryobjecttypecode, SdkMessageFilter.Schema.Attributes.availability));

            if (!_cacheMessageFilters.ContainsKey(service.ConnectionData.ConnectionId))
            {
                _cacheMessageFilters.Add(service.ConnectionData.ConnectionId, filters);
            }
        }
예제 #2
0
        private async Task AddingPluginStepForType(ConnectionData connectionData, CommonConfiguration commonConfig, string pluginTypeName)
        {
            if (string.IsNullOrEmpty(pluginTypeName))
            {
                this._iWriteToOutput.WriteToOutput(connectionData, "PluginType Name is empty.");
                return;
            }

            var service = await ConnectAndWriteToOutputAsync(connectionData);

            if (service == null)
            {
                return;
            }

            var repository = new PluginTypeRepository(service);

            var pluginType = await repository.FindPluginTypeAsync(pluginTypeName);

            if (pluginType == null)
            {
                pluginType = await repository.FindPluginTypeByLikeNameAsync(pluginTypeName);
            }

            if (pluginType == null)
            {
                this._iWriteToOutput.WriteToOutput(connectionData, "PluginType not founded by name {0}.", pluginTypeName);

                WindowHelper.OpenPluginTypeExplorer(
                    this._iWriteToOutput
                    , service
                    , commonConfig
                    , pluginTypeName
                    );

                return;
            }

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.GettingMessages);

            var repositoryFilters = new SdkMessageFilterRepository(service);

            List <SdkMessageFilter> filters = await repositoryFilters.GetAllAsync(new ColumnSet(SdkMessageFilter.Schema.Attributes.sdkmessageid, SdkMessageFilter.Schema.Attributes.primaryobjecttypecode, SdkMessageFilter.Schema.Attributes.secondaryobjecttypecode, SdkMessageFilter.Schema.Attributes.availability));

            this._iWriteToOutput.WriteToOutput(connectionData, Properties.OutputStrings.GettingMessagesCompleted);

            var step = new SdkMessageProcessingStep()
            {
                EventHandler = pluginType.ToEntityReference(),
            };

            System.Threading.Thread worker = new System.Threading.Thread(() =>
            {
                try
                {
                    var form = new WindowSdkMessageProcessingStep(_iWriteToOutput, service, filters, step);

                    form.ShowDialog();
                }
                catch (Exception ex)
                {
                    DTEHelper.WriteExceptionToOutput(null, ex);
                }
            });

            worker.SetApartmentState(System.Threading.ApartmentState.STA);

            worker.Start();
        }