Beispiel #1
0
            public async Task Delete_ProcessAsync(int seqid, TProtocol iprot, TProtocol oprot, CancellationToken cancellationToken)
            {
                var args = new DeleteArgs();
                await args.ReadAsync(iprot, cancellationToken);

                await iprot.ReadMessageEndAsync(cancellationToken);

                var result = new DeleteResult();

                try
                {
                    result.Success = await _iAsync.DeleteAsync(args.Id, cancellationToken);

                    await oprot.WriteMessageBeginAsync(new TMessage("Delete", TMessageType.Reply, seqid), cancellationToken);

                    await result.WriteAsync(oprot, cancellationToken);
                }
                catch (TTransportException)
                {
                    throw;
                }
                catch (Exception ex)
                {
                    Console.Error.WriteLine("Error occurred in processor:");
                    Console.Error.WriteLine(ex.ToString());
                    var x = new TApplicationException(TApplicationException.ExceptionType.InternalError, " Internal error.");
                    await oprot.WriteMessageBeginAsync(new TMessage("Delete", TMessageType.Exception, seqid), cancellationToken);

                    await x.WriteAsync(oprot, cancellationToken);
                }
                await oprot.WriteMessageEndAsync(cancellationToken);

                await oprot.Transport.FlushAsync(cancellationToken);
            }
Beispiel #2
0
        protected override void DoExecute(CommandResult <string[]> result)
        {
            Assert.ArgumentNotNull(result, "result");

            var name = this.Name;

            Assert.ArgumentNotNullOrEmpty(name, "name");

            var profile          = Profile.Read();
            var connectionString = profile.GetValidConnectionString();

            InstanceManager.Initialize();
            var instance = InstanceManager.Instances.FirstOrDefault(x => x.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            Ensure.IsNotNull(instance, "instance is not found");

            PipelineManager.Initialize(XmlDocumentEx.LoadXml(PipelinesConfig.Contents).DocumentElement);

            var deleteArgs = new DeleteArgs(instance, connectionString);
            var controller = new AggregatePipelineController();

            PipelineManager.StartPipeline("delete", deleteArgs, controller, false);

            result.Success = !string.IsNullOrEmpty(controller.Message);
            result.Message = controller.Message;
            result.Data    = controller.GetMessages().ToArray();
        }
Beispiel #3
0
 public static void Main(string[] args)
 {
     switch (args[0])
     {
         case "install":
             InstallArgs installArgs = new InstallArgs(args);
             InstallProcess installProcess = new InstallProcess();
             installProcess.Execute(installArgs);
             break;
         case "delete":
             DeleteArgs deleteArgs = new DeleteArgs(args);
             DeleteProcess deleteProcess = new DeleteProcess();
             deleteProcess.Execute(deleteArgs);
             break;
         case "export":
             var exportArgs = new ExportArgs(args);
             var exportProcess = new ExportProcess();
             exportProcess.Execute(exportArgs);
             break;
         case "import":
             var importArgs = new ImportArgs(args);
             var importProcess = new ImportProcess();
             importProcess.Execute(importArgs);
             break;
     }
 }
        public async Task <IActionResult> Delete([FromBody] DeleteArgs args)
        {
            if (!await Scheduler.DeleteCalendar(args.Name))
            {
                throw new InvalidOperationException("Cannot delete calendar " + args.Name);
            }

            return(NoContent());
        }
Beispiel #5
0
        public void Delete(DeleteArgs opt)
        {
            if (Processor.Hosts.ContainsKey(opt.Name))
            {
                Processor.Hosts.Remove(opt.Name);
            }

            opt.Result.Message = string.Format("host entry removed for {0} @ {1}", opt.Name, opt.Address);
        }
Beispiel #6
0
 public void OnClick(Window mainWindow, Instance instance)
 {
     if (instance != null)
     {
         var connectionString = ProfileManager.GetConnectionString();
         var args             = new DeleteArgs(instance, connectionString);
         args.OnCompleted += () => mainWindow.Dispatcher.Invoke(() => OnPipelineCompleted(args.RootPath));
         var index = MainWindowHelper.GetListItemID(instance.ID);
         WizardPipelineManager.Start("delete", mainWindow, args, null, (ignore) => OnWizardCompleted(index), () => null);
     }
 }
        private void OnPipelineCompleted(DeleteArgs args)
        {
            var root = new DirectoryInfo(args.RootPath);

            if (root.Exists && root.GetFiles("*", SearchOption.AllDirectories).Length > 0)
            {
                FileSystem.FileSystem.Local.Directory.TryDelete(args.RootPath);
            }

            args.HasInstallationBeenCompleted = true;
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            if (instance != null)
            {
                var connectionString = ProfileManager.GetConnectionString();
                var args             = new DeleteArgs(instance, connectionString);
                args.OnCompleted += () => mainWindow.Dispatcher.Invoke(() => OnPipelineCompleted(args));
                var index = MainWindowHelper.GetListItemID(instance.ID);
                int version;
                if (int.TryParse(instance.Product.ShortVersion, out version) && version < 90)
                {
                    WizardPipelineManager.Start("delete", mainWindow, args, null, (ignore) => OnWizardCompleted(index, args.HasInstallationBeenCompleted), () => null);
                }
                else
                {
                    string uninstallPath    = string.Empty;
                    SitecoreEnvironment env = SitecoreEnvironmentHelper.GetExistingSitecoreEnvironment(instance.Name);
                    if (!string.IsNullOrEmpty(env?.UnInstallDataPath))
                    {
                        uninstallPath = env.UnInstallDataPath;
                    }
                    else
                    {
                        foreach (string installName in Directory.GetDirectories(ApplicationManager.UnInstallParamsFolder).OrderByDescending(s => s.Length))
                        {
                            if (instance.Name.StartsWith(Path.GetFileName(installName)))
                            {
                                uninstallPath = installName;
                                break;
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(uninstallPath))
                    {
                        WindowHelper.ShowMessage("UnInstall files not found.");
                        return;
                    }

                    Delete9WizardArgs delete9WizardArgsargs = new Delete9WizardArgs(instance, connectionString, uninstallPath);
                    WizardPipelineManager.Start("delete9", mainWindow, null, null, (ignore) => OnWizardCompleted(index, delete9WizardArgsargs.HasInstallationBeenCompleted), () => delete9WizardArgsargs);
                }
            }
        }
Beispiel #9
0
        protected override void DoExecute(Instance instance, CommandResult <string[]> result)
        {
            Assert.ArgumentNotNull(instance, nameof(instance));
            Assert.ArgumentNotNull(result, nameof(result));

            var profile          = Profile.Read();
            var connectionString = profile.GetValidConnectionString();

            PipelineManager.Initialize(XmlDocumentEx.LoadXml(PipelinesConfig.Contents).DocumentElement);

            var deleteArgs = new DeleteArgs(instance, connectionString);
            var controller = new AggregatePipelineController();

            PipelineManager.StartPipeline("delete", deleteArgs, controller, false);

            result.Success = !string.IsNullOrEmpty(controller.Message);
            result.Message = controller.Message;
            result.Data    = controller.GetMessages().ToArray();
        }
Beispiel #10
0
        protected override void Process(DeleteArgs args)
        {
            Assert.ArgumentNotNull(args, "args");

            var localMachine = Registry.LocalMachine;

            Assert.IsNotNull(localMachine, "localMachine");

            var sitecoreKey = localMachine.OpenSubKey("SOFTWARE\\Wow6432Node\\Sitecore CMS", true);

            if (sitecoreKey == null)
            {
                return;
            }

            foreach (var subKeyName in sitecoreKey.GetSubKeyNames())
            {
                Assert.IsNotNull(subKeyName, "subKeyName");
                var subKey = sitecoreKey.OpenSubKey(subKeyName);

                if (subKey == null)
                {
                    continue;
                }

                var siteName          = subKey.GetValue("IISSiteName") as string ?? string.Empty;
                var instanceDirectory = (subKey.GetValue("InstanceDirectory") as string ?? string.Empty).TrimEnd('\\');

                if (!siteName.Equals(args.InstanceName, StringComparison.OrdinalIgnoreCase))
                {
                    if (!instanceDirectory.Equals(args.Instance.RootPath.TrimEnd('\\'), StringComparison.OrdinalIgnoreCase))
                    {
                        continue;
                    }
                }

                Log.Info(string.Format("Deleting {0}\\{1} key from registry", "SOFTWARE\\Wow6432Node\\Sitecore CMS", subKeyName), this);
                sitecoreKey.DeleteSubKey(subKeyName);
                break;
            }
        }
Beispiel #11
0
        public static void Main(string[] args)
        {
            switch (args[0])
            {
            case "install":
                InstallArgs    installArgs    = new InstallArgs(args);
                InstallProcess installProcess = new InstallProcess();
                installProcess.Execute(installArgs);
                break;

            case "delete":
                DeleteArgs    deleteArgs    = new DeleteArgs(args);
                DeleteProcess deleteProcess = new DeleteProcess();
                deleteProcess.Execute(deleteArgs);
                break;

            case "export":
                var exportArgs    = new ExportArgs(args);
                var exportProcess = new ExportProcess();
                exportProcess.Execute(exportArgs);
                break;
            }
        }
Beispiel #12
0
            public async Task <bool> DeleteAsync(int id, CancellationToken cancellationToken)
            {
                await OutputProtocol.WriteMessageBeginAsync(new TMessage("Delete", TMessageType.Call, SeqId), cancellationToken);

                var args = new DeleteArgs();

                args.Id = id;

                await args.WriteAsync(OutputProtocol, cancellationToken);

                await OutputProtocol.WriteMessageEndAsync(cancellationToken);

                await OutputProtocol.Transport.FlushAsync(cancellationToken);

                var msg = await InputProtocol.ReadMessageBeginAsync(cancellationToken);

                if (msg.Type == TMessageType.Exception)
                {
                    var x = await TApplicationException.ReadAsync(InputProtocol, cancellationToken);

                    await InputProtocol.ReadMessageEndAsync(cancellationToken);

                    throw x;
                }

                var result = new DeleteResult();
                await result.ReadAsync(InputProtocol, cancellationToken);

                await InputProtocol.ReadMessageEndAsync(cancellationToken);

                if (result.__isset.success)
                {
                    return(result.Success);
                }
                throw new TApplicationException(TApplicationException.ExceptionType.MissingResult, "Delete failed: unknown result");
            }
        /// <summary>
        /// Gets the view models.
        /// </summary>
        /// <param name="entity">The entity object.</param>
        /// <returns>The generated view models.</returns>
        public async Task <IList <ItemGroup> > GetViewModels(SitefinityDataEntity entity)
        {
            var viewModels = new List <ItemGroup>();
            var itemType   = "pressreleases";
            var provider   = "OpenAccessProvider";

            // when using the OData client, the url is automatically prefixed with the value of web the service and the sitefinity instance url
            // we use an expand the get the related image

            var getAllArgs = new GetAllArgs
            {
                // required parameter, specifies the items to work with
                Type = itemType
            };

            // optional parameter, specifies the fields to be returned, if not specified
            // the default service response fields will be returned
            getAllArgs.Fields.Add("Title");

            // "*" returns all the fields, even those that are available when requesting a single item only
            // getAllArgs.Fields.Add("*");

            // specifies the related fields to be included in the response (like related data or parent relationships)
            if (!entity.HideImage)
            {
                getAllArgs.Fields.Add("RelatedMediaSingle");
            }

            // optional parameter, specifies the maximum items to be returned
            getAllArgs.Take = 20;

            // optional parameter, specifies the items to be skipped
            getAllArgs.Skip = 0;

            // optional paramteter, specifies an ordering clause
            getAllArgs.OrderBy.Add(new OrderBy()
            {
                Name = "Title",
                Type = OrderType.Ascending
            });

            // optional parameter, specifies if the total count of the items should be returned
            getAllArgs.Count = true;

            // optional parameter, if nothing is specified, the default for the site will be used
            getAllArgs.Provider = provider;

            // The generic parameter here is a plain DTO for a one to one relationship with the model on the server
            // It contains a representation for every kind of field that is currently supported by the system
            getAllArgs.Filter = null;
            var responseWithoutFilter = await this.service.GetItems <Item>(getAllArgs).ConfigureAwait(true);

            viewModels.Add(new ItemGroup()
            {
                Name  = "Items without filter",
                Items = responseWithoutFilter.Items.Select(x => this.GetItemViewModel(x)).ToArray(),
            });

            getAllArgs.Filter = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.Operators.Equal
            };

            var responseWithBasicFilter = await this.service.GetItems <Item>(getAllArgs).ConfigureAwait(true);

            viewModels.Add(new ItemGroup()
            {
                Name  = "Items with simple filter",
                Items = responseWithBasicFilter.Items.Select(x => this.GetItemViewModel(x)).ToArray(),
            });

            var filterTitle = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.Operators.Equal,
            };

            var filterTitle2 = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.Operators.NotEqual,
            };

            var filterTitle3 = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.StringOperators.StartsWith,
            };

            var filterTitle4 = new FilterClause()
            {
                FieldName  = "Title",
                FieldValue = "test",
                Operator   = FilterClause.StringOperators.EndsWith,
            };

            var filtersByTitle = new CombinedFilter()
            {
                Operator     = CombinedFilter.LogicalOperators.Or,
                ChildFilters = new FilterClause[] { filterTitle, filterTitle2 },
            };

            var filtersByTitleWithStringOperators = new CombinedFilter()
            {
                Operator     = CombinedFilter.LogicalOperators.Or,
                ChildFilters = new FilterClause[] { filterTitle3, filterTitle4 },
            };

            var multipleFiltersCombined = new CombinedFilter
            {
                Operator     = CombinedFilter.LogicalOperators.And,
                ChildFilters = new CombinedFilter[] { filtersByTitle, filtersByTitleWithStringOperators },
            };

            getAllArgs.Filter = multipleFiltersCombined;
            var responseWithComplexFilter = await this.service.GetItems <Item>(getAllArgs).ConfigureAwait(true);

            viewModels.Add(new ItemGroup()
            {
                Name  = "Items with complex filter",
                Items = responseWithComplexFilter.Items.Select(x => this.GetItemViewModel(x)).ToArray(),
            });

            // in order to execute /create/read/update operations a token must be acquired from the web server
            var createItemArgs = new CreateArgs()
            {
                // required parameter, specifies the items to work with
                Type = itemType,

                // required parameter, specifies the data to be passed to the server
                Data = new Item()
                {
                    Title                = "Test",
                    DateAndTime          = DateTime.UtcNow,
                    Number               = 123456,
                    ChoicesSingle        = SingleChoice.FirstChoice,
                    ChociesMultiple      = MultipleChoice.FirstChoice | MultipleChoice.SecondChoice,
                    LongText             = "LongText",
                    ShortText            = "ShortText",
                    ArrayOfGuids         = new [] { Guid.NewGuid() },
                    GUIDField            = Guid.NewGuid(),
                    MetaTitle            = "Test",
                    MetaDescription      = "Test",
                    OpenGraphDescription = "Test",
                    OpenGraphTitle       = "Test",
                    Tags    = new [] { Guid.NewGuid() },
                    UrlName = "test" + Guid.NewGuid().ToString(),
                    YesNo   = true,

                    // related, properties are added through relation request
                    // RelatedMediaSingle
                },

                // optional parameter, if nothing is specified, the default for the site will be used
                Provider = provider
            };

            try
            {
                // reference to documentation on how to retrieve bearer tokens
                // https://www.progress.com/documentation/sitefinity-cms/request-access-token-for-calling-web-services
                var token = "Bearer ...";
                createItemArgs.AdditionalHeaders.Add(HeaderNames.Authorization, token);

                var createResponse = await this.service.CreateItem <Item>(createItemArgs);

                var getSingleArgs = new GetItemArgs()
                {
                    // required parameter, specifies the id of the item to update
                    Id = createResponse.Id.ToString(),

                    // required parameter, specifies the items to work with
                    Type = itemType,

                    // optional parameter, if nothing is specified, the default for the site will be used
                    Provider = provider
                };

                var getSingleResponse = await this.service.GetItem <Item>(getSingleArgs);

                var updateArgs = new UpdateArgs()
                {
                    // required parameter, specifies the id of the item to update
                    Id = getSingleResponse.Id.ToString(),

                    // required parameter, specifies the items to work with
                    Type = itemType,

                    // required parameter, specifies the data to be passed to the server
                    Data = new Item()
                    {
                        Title = "updated title",
                    },

                    // optional parameter, if nothing is specified, the default for the site will be used
                    Provider = provider
                };
                updateArgs.AdditionalHeaders.Add(HeaderNames.Authorization, token);

                await this.service.UpdateItem(updateArgs);

                var deleteArgs = new DeleteArgs()
                {
                    // required parameter, specifies the id of the item to update
                    Id = getSingleResponse.Id.ToString(),

                    // required parameter, specifies the items to work with
                    Type = itemType,

                    // optional parameter, if nothing is specified, the default for the site will be used
                    Provider = provider
                };

                deleteArgs.AdditionalHeaders.Add(HeaderNames.Authorization, token);

                await this.service.DeleteItem(deleteArgs);
            }
            catch (ErrorCodeException error)
            {
                this.logger.LogError($"Cannot create/update/delete items. Actual error is {error.Message}");
            }

            return(viewModels);
        }