public async Task <IActionResult> Remove(
            [FromForm] RemoveRequest removeRequest)
        {
            try
            {
                if (removeRequest.source == null)
                {
                    return(BadRequest("Remove target is not specified"));
                }

                var result = await _fileSystemService
                             .RemoveAsync(
                    new RemoveState(new NPath(removeRequest.source)));

                if (result == null)
                {
                    throw new SystemException("Unable to process remove");
                }

                return(Json(result));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }
Example #2
0
        /// <summary>
        ///     Remove an item from the cache. If cacheOnly == false the item is also removed
        ///     from the underlying persistent storage
        /// </summary>
        /// <typeparam name="TItemType"></typeparam>
        /// <param name="primaryKeyValue"></param>
        private void InternalRemove <TItemType>(object primaryKeyValue)
        {
            var description = RegisterTypeIfNeeded(typeof(TItemType)).AsTypeDescription;

            KeyValue primaryKey;

            if (primaryKeyValue is KeyValue kv)
            {
                primaryKey = kv;
            }
            else
            {
                primaryKey = description.MakePrimaryKeyValue(primaryKeyValue);
            }

            var request = new RemoveRequest(typeof(TItemType), primaryKey);


            var response = Channel.SendRequest(request);

            if (response is ExceptionResponse exResponse)
            {
                throw new CacheException("Error while removing an object from the cache", exResponse.Message,
                                         exResponse.CallStack);
            }
        }
        public static void UpdatePackage()
        {
            float progress = 0F;

            PackageInfo info = PackageInfo.FindForAssembly(typeof(NativePackageUpdate).Assembly);

            RemoveRequest removeRequest = Client.Remove(info.packageId);

            while (!removeRequest.IsCompleted)
            {
                EditorUtility.DisplayProgressBar(_titleLabel, _infoLabel, Mathf.Clamp(progress += 0.01F, 0F, .5F));
                Thread.Sleep(100);
            }
            EditorUtility.DisplayProgressBar(_titleLabel, _infoLabel, .5F);

            AddRequest addRequest = Client.Add(info.packageId);

            while (!addRequest.IsCompleted)
            {
                EditorUtility.DisplayProgressBar(_titleLabel, _infoLabel, Mathf.Clamp(progress += 0.01F, .5F, 1F));
                Thread.Sleep(100);
            }
            EditorUtility.DisplayProgressBar(_titleLabel, _infoLabel, 1F);
            Thread.Sleep(100);

            EditorUtility.ClearProgressBar();
        }
Example #4
0
        public JsonResult RemoveTag(RemoveRequest Request)
        {
            try
            {
                using (var context = new EnrampageEntities())
                {
                    var tag = context.Tags.FirstOrDefault(t => t.Id == Request.Id);

                    if (tag == null)
                    {
                        return(Json(new ApiResponse(false, "Tag not found.")));
                    }

                    if (tag.UserId != CurrentUser.UserId() && !CurrentUser.Admin())
                    {
                        return(Json(new ApiResponse(false, "Tag not created by you.")));
                    }

                    tag.Rants.Clear();
                    context.Tags.Remove(tag);
                    context.SaveChanges();
                }

                return(Json(new ApiResponse(true, "Tag removed successfully.")));
            }
            catch (Exception Ex)
            {
                LogHelper.Log(Ex);
                return(Json(new ApiResponse(false, "Failed to remove tag.")));
            }
        }
Example #5
0
        public JsonResult RemoveRant(RemoveRequest Request)
        {
            try
            {
                using (var context = new EnrampageEntities())
                {
                    var rant = context.Rants.FirstOrDefault(r => r.Id == Request.Id);

                    if (rant == null)
                    {
                        return(Json(new ApiResponse(false, "Rant not found.")));
                    }

                    if (rant.UserId != CurrentUser.UserId() && !CurrentUser.Admin())
                    {
                        return(Json(new ApiResponse(false, "Rant not post by you.")));
                    }

                    rant.Tags.Clear();
                    context.Reports.RemoveRange(rant.Reports);
                    context.Rants.Remove(rant);
                    context.SaveChanges();
                }

                return(Json(new ApiResponse(true, "Rant removed successfully.")));
            }
            catch (Exception Ex)
            {
                LogHelper.Log(Ex);
                return(Json(new ApiResponse(false, "Failed to remove rant.")));
            }
        }
Example #6
0
        private static void OnUpdate()
        {
            if (!m_removeRequest.IsCompleted)
            {
                return;
            }

            if (m_removeRequest.Status == StatusCode.Success)
            {
                m_removedPackageNames.Add(m_removeRequest.PackageIdOrName);
            }

            if (0 < m_packageNameQueue.Count)
            {
                var packageName = m_packageNameQueue.Dequeue();
                m_removeRequest = Client.Remove(packageName);
            }
            else
            {
                m_packageNameQueue = null;
                m_removeRequest    = null;

                EditorApplication.update -= OnUpdate;
                EditorApplication.UnlockReloadAssemblies();

                m_onComplete?.Invoke(m_removedPackageNames.ToArray());
                m_onComplete = null;

                m_removedPackageNames.Clear();
                m_removedPackageNames = null;
            }
        }
Example #7
0
        public override async Task <RemoveReply> Remove(RemoveRequest request, ServerCallContext context)
        {
            Comment co = await commentsService.FindAsync(request.Id);

            var user = context.GetHttpContext().User;
            var authorizationResult = await authorizationService.AuthorizeAsync(user, co, Policies.EditDeleteComment);

            if (authorizationResult.Succeeded)
            {
                co = await commentsService.RemoveAsync(request.Id);

                return(new RemoveReply()
                {
                    Id = co.Id, PhotoId = co.PhotoId, Subject = co.Subject, UserName = co.UserName, Body = co.Body, SubmittedOn = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(co.SubmittedOn.ToUniversalTime())
                });
            }
            else
            {
                //found on https://docs.microsoft.com/en-us/dotnet/architecture/grpc-for-wcf-developers/error-handling
                var metadata = new Metadata {
                    { "User", user.Identity.Name }
                };
                throw new RpcException(new Status(StatusCode.PermissionDenied, "Permission denied"), metadata);
            }
        }
Example #8
0
        //uninstall the package
        private void UninstallPackage(string packageName)
        {
            uninstallRequest = UnityEditor.PackageManager.Client.Remove(Packages.Find((x) => x.displayName == packageName).packageName);

            //subscribe to UninstallPackageProgress for updates
            EditorApplication.update += UninstallPackageProgress;
        }
Example #9
0
        static void RemoveProgress()
        {
            if (_removeRequest.IsCompleted)
            {
                switch (_removeRequest.Status)
                {
                case StatusCode.Failure:        // couldn't remove package
                    Debug.LogError("Couldn't remove package '" + _removeRequest.PackageIdOrName + "': " + _addRequest.Error.message);
                    break;

                case StatusCode.InProgress:
                    break;

                case StatusCode.Success:
                    Debug.Log("removed package: " + _removeRequest.PackageIdOrName);
                    break;
                }

                if (packagesQueue.Count > 0)
                {
                    var nextRequestStr = packagesQueue.Dequeue();
                    Debug.Log("Requesting removal of '" + nextRequestStr + "'.");
                    _removeRequest = Client.Remove(nextRequestStr.packageId);
                }
                else        // no more packages to remove
                {
                    EditorApplication.update -= RemoveProgress;
                    EditorApplication.UnlockReloadAssemblies();
                }
            }
        }
Example #10
0
        public void RemoveApiTest_Tag()
        {
            var options = new RemoveOptions
            {
                FileInfo       = TestFiles.Docx.ToFileInfo(),
                SearchCriteria = new SearchCriteria
                {
                    TagOptions = new TagOptions
                    {
                        ExactTag = new Tag
                        {
                            Name     = "Created",
                            Category = "Time"
                        }
                    }
                }
            };

            var request = new RemoveRequest(options);

            var result = MetadataApi.Remove(request);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Path);
            Assert.IsNotEmpty(result.Url);
            Assert.Greater(result.RemovedCount, 0);
        }
Example #11
0
        public HttpResponseMessage Remove(RemoveRequest request)
        {
            bool result;

            try
            {
                if (request.Id > 0)
                {
                    result = PersonsService <BasePerson> .Instance.RemovePerson(request.Id);
                }
                else if (!string.IsNullOrEmpty(request.PhoneNumber))
                {
                    result = PersonsService <BasePerson> .Instance.RemovePerson(request.PhoneNumber);
                }
                else
                {
                    return(new HttpResponseMessage()
                    {
                        Content = new StringContent("Invalid request")
                    });
                }

                return(new HttpResponseMessage()
                {
                    Content = new StringContent(result.ToString())
                });
            }
            catch (Exception ex)
            {
                return(new HttpResponseMessage()
                {
                    Content = new StringContent(ex.Message)
                });
            }
        }
        /// <summary>
        /// Removes a package from the Package Manager.
        /// </summary>
        /// <param name="package">A string representing the package to be removed.</param>
        public static async void RemovePackage(string package)
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode == false)
            {
                if (IsPackageLoaded(package))
                {
                    RemoveRequest removeRequest = Client.Remove(package);
                    Debug.Log($"Removing {package}.");

                    while (removeRequest.IsCompleted == false)
                    {
                        await Task.Delay(100);
                    }

                    if (removeRequest.Status >= StatusCode.Failure)
                    {
                        Debug.LogError($"There was an error trying to enable '{package}' - Error Code: [{removeRequest.Error.errorCode}] .\n{removeRequest.Error.message}");
                    }
                    else
                    {
                        OnPackageDisabled?.Invoke(null, new PackageDisabledEventArgs(removeRequest.PackageIdOrName));
                        Debug.Log($"The package '{removeRequest.PackageIdOrName} has been removed");
                    }
                }
            }
        }
Example #13
0
        public void RemoveApiTest_PropertyNameRegex()
        {
            var options = new RemoveOptions
            {
                FileInfo       = TestFiles.Docx.ToFileInfo(),
                SearchCriteria = new SearchCriteria
                {
                    NameOptions = new NameOptions
                    {
                        Value        = "^[N]ame[A-Z].*",
                        MatchOptions = new MatchOptions
                        {
                            IsRegex = true
                        }
                    }
                }
            };

            var request = new RemoveRequest(options);

            var result = MetadataApi.Remove(request);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Path);
            Assert.IsNotEmpty(result.Url);
            Assert.Greater(result.RemovedCount, 0);
        }
Example #14
0
        public void RemoveApiTest_PropertyNameExactPhrase()
        {
            var options = new RemoveOptions
            {
                FileInfo       = TestFiles.Docx.ToFileInfo(),
                SearchCriteria = new SearchCriteria
                {
                    NameOptions = new NameOptions
                    {
                        Value        = "NameOfApplication",
                        MatchOptions = new MatchOptions
                        {
                            ExactPhrase = true
                        }
                    }
                }
            };

            var request = new RemoveRequest(options);

            var result = MetadataApi.Remove(request);

            Assert.IsNotNull(result);
            Assert.IsNotEmpty(result.Path);
            Assert.IsNotEmpty(result.Url);
            Assert.Greater(result.RemovedCount, 0);
        }
Example #15
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new PagesApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath = "WordProcessing/four-pages.docx"
                };

                var options = new RemoveOptions
                {
                    FileInfo   = fileInfo,
                    OutputPath = "Output/remove-pages.docx",
                    Pages      = new List <int?> {
                        2, 4
                    }
                };
                var request = new RemoveRequest(options);

                var response = apiInstance.Remove(request);

                Console.WriteLine("Output file path: " + response.Path);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling api: " + e.Message);
            }
        }
Example #16
0
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new MetadataApi(configuration);

            try
            {
                var fileInfo = new FileInfo
                {
                    FilePath    = "documents/input.doc",
                    StorageName = Common.MyStorage
                };

                var options = new RemoveOptions
                {
                    FileInfo       = fileInfo,
                    SearchCriteria = new SearchCriteria
                    {
                        NameOptions = new NameOptions
                        {
                            Value = "Application"
                        }
                    }
                };

                var request = new RemoveRequest(options);

                var response = apiInstance.Remove(request);
                Console.WriteLine("Resultant file path: " + response.Path);
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling MetadataApi: " + e.Message);
            }
        }
        public void Remove_Watermark_Incorrect_Password()
        {
            var testFile = TestFiles.PasswordProtected;
            var options  = new RemoveOptions
            {
                FileInfo = new FileInfo
                {
                    FilePath = testFile.FullName,
                    Password = "******"
                },
                ImageSearchCriteria = new ImageSearchCriteria
                {
                    ImageFileInfo = TestFiles.SampleWatermarkTransparent.ToFileInfo()
                },
                TextSearchCriteria = new TextSearchCriteria
                {
                    SearchText = "Watermark text"
                },
                OutputFolder = "removed_watermarks"
            };

            var request = new RemoveRequest(options);
            var ex      = Assert.Throws <ApiException>(() => { WatermarkApi.Remove(request); });

            Assert.AreEqual($"Password provided for file '{testFile.FullName}' is incorrect.", ex.Message);
        }
Example #18
0
    static void Progress()
    {
        if (myRequest.IsCompleted)
        {
            if (myRequest.Status == StatusCode.Success)
            {
                Debug.Log("Removed: " + myRequest.PackageIdOrName);
            }
            else if (myRequest.Status >= StatusCode.Failure)
            {
                Debug.Log(myRequest.Error.message);
            }

            if (myQueue.Count > 0)
            {
                string strNextReq = myQueue.Dequeue();
                Debug.Log("Removing: " + strNextReq);
                myRequest = Client.Remove(strNextReq);
            }
            else
            {
                EditorApplication.update -= Progress;
                EditorApplication.UnlockReloadAssemblies();
            }
        }
    }
        public void Remove_Watermark_Without_Options()
        {
            var request = new RemoveRequest(null);
            var ex      = Assert.Throws <ApiException>(() => { WatermarkApi.Remove(request); });

            Assert.AreEqual("Missing required parameter 'options' when calling Remove", ex.Message);
        }
        /// <summary>
        /// Remove metadata from document using search criteria.
        /// </summary>
        /// <param name="request">Request. <see cref="RemoveRequest" /></param>
        /// <returns><see cref="RemoveResult"/></returns>
        public RemoveResult Remove(RemoveRequest request)
        {
            // verify the required parameter 'options' is set
            if (request.options == null)
            {
                throw new ApiException(400, "Missing required parameter 'options' when calling Remove");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetServerUrl() + "/metadata/remove";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            var postBody = SerializationHelper.Serialize(request.options); // http body (model) parameter
            var response = this.apiInvoker.InvokeApi(
                resourcePath,
                "POST",
                postBody,
                null,
                null);

            if (response != null)
            {
                return((RemoveResult)SerializationHelper.Deserialize(response, typeof(RemoveResult)));
            }

            return(null);
        }
Example #21
0
 public void Handle(RemoveRequest message)
 {
     if (SelectedItem != null)
     {
         _eventAggregator.SendMessage(new RemoveDocumentById(SelectedItem.Id));
     }
 }
Example #22
0
            private void OnProcessRemoveResult(RemoveRequest request)
            {
                var installedPackage = GetInstalledPackageInfo(request.PackageIdOrName);

                if (installedPackage == null)
                {
                    return;
                }
                m_InstalledPackageInfos.Remove(installedPackage.name);
                OnPackageInfosUpdated(new PackageInfo[] { installedPackage });

                PackageManagerExtensions.ExtensionCallback(() =>
                {
                    foreach (var extension in PackageManagerExtensions.Extensions)
                    {
                        extension.OnPackageRemoved(installedPackage);
                    }
                });

                if (IsPreviewInstalled(installedPackage))
                {
                    OnInstalledPreviewPackagesChanged();
                }

                // do a list offline to refresh all the dependencies
                List(true);
            }
Example #23
0
        public void RemoveApiTest()
        {
            var testFile = TestFiles.Docx;
            var options  = new RemoveOptions
            {
                FileInfo       = testFile.ToFileInfo(),
                SearchCriteria = new SearchCriteria
                {
                    TagOptions = new TagOptions
                    {
                        ExactTag = new Tag
                        {
                            Name     = "Title",
                            Category = "Content"
                        }
                    }
                }
            };

            var request = new RemoveRequest(options);

            var result = MetadataApi.Remove(request);

            Assert.IsNotNull(result);
            Assert.Greater(result.RemovedCount, 0);
        }
Example #24
0
 private async Task DoRemove()
 {
     if (!await RemoveRequest.Handle(Unit.Default))
     {
         return;
     }
     _messageBus.SendMessage(new CategoryDeleteEvent(_category, this));
 }
        public override async Task <ResultModel> Remove(RemoveRequest request, ServerCallContext context)
        {
            var command = DeleteProductCommand.CreateInstance(Guid.Parse(request.Id));

            var resultModel = (await this.mediator.Send(command, context.CancellationToken)).ToProtoResultModel();

            return(resultModel);
        }
Example #26
0
        // Keyboard input handling -each keypress can be interpreted as
        // a control command.
        void KeyboardControl()
        {
            while (true)
            {
                switch (Console.ReadKey(true).Key)
                {
                case ConsoleKey.T:
                    transportFunction.PrintRouteTable();
                    break;

                case ConsoleKey.A:
                    LRM.PrintAssignments();
                    break;

                case ConsoleKey.P:
                    if (Log.IsPaused)
                    {
                        Log.Unpause();
                    }
                    else
                    {
                        Log.Pause();
                    }
                    break;

#if DEBUG
                case ConsoleKey.Enter:
                    MPLSPacket testPacket = new MPLSPacket(new int[] { 2137 }, "This is a test MPLSMessage.");
                    transportFunction.EnqueuePacketOnFirstQueue(testPacket);
                    break;

                case ConsoleKey.U:
                    NHLFEntry        entry         = new NHLFEntry(10, 1, 17, true, 2, new int[] { 35 });
                    AddUpdateRequest testUpdateReq = new AddUpdateRequest("Helo it me", mgmtLocalPort, 2137, entry);
                    SendManagementMsg(mgmtLocalPort, testUpdateReq);
                    break;

                case ConsoleKey.R:
                    RemoveRequest testRemoveReq = new RemoveRequest("Helo it me", mgmtLocalPort, 2137, 10);
                    SendManagementMsg(mgmtLocalPort, testRemoveReq);
                    break;

                case ConsoleKey.L:
                    AllocateRequest testAllocReq = new AllocateRequest(id, mgmtLocalPort, allocCounter++, 1, 30, 1);
                    SendManagementMsg(mgmtLocalPort, testAllocReq);
                    break;

                case ConsoleKey.D:
                    DeallocateRequest testDeallocReq = new DeallocateRequest(id, mgmtLocalPort, allocCounter--, 1);
                    SendManagementMsg(mgmtLocalPort, testDeallocReq);
                    break;
#endif
                default:
                    break;
                }
            }
        }
Example #27
0
        public override async Task <RemoveReply> Remove(RemoveRequest request, ServerCallContext context)
        {
            Comment c = await commentsService.RemoveAsync(request.Id);

            return(new RemoveReply()
            {
                Id = c.Id, PhotoId = c.PhotoId, Subject = c.Subject, UserName = c.UserName, Body = c.Body, SubmittedOn = Google.Protobuf.WellKnownTypes.Timestamp.FromDateTime(c.SubmittedOn.ToUniversalTime())
            });
        }
Example #28
0
        private void XiaomiPackageControlGUI()
        {
            EditorGUI.BeginDisabledGroup(!IsVersionInitialized || packmanOperationRunning);

            if (!xiaomiPackageInstalled)
            {
                if (GUILayout.Button("Add", GUILayout.Width(60)))
                {
                    if (packmanOperationRunning)
                    {
                        return;
                    }

                    AddRequest add = Client.Add(LatestXiaomiPackageId);
                    requestList.Add(new RequestQueueItem(add, PackmanOperationType.Add));
                    System.Console.WriteLine("Adding: " + LatestXiaomiPackageId);
                    packmanOperationRunning = true;
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                if (!string.IsNullOrEmpty(latestXiaomiPackageVersion) && currentXiaomiPackageVersion != latestXiaomiPackageVersion)
                {
                    if (GUILayout.Button("Update", GUILayout.Width(60)))
                    {
                        if (packmanOperationRunning)
                        {
                            return;
                        }

                        if (EditorUtility.DisplayDialog("Update Xiaomi SDK", "Are you sure you want to update to " + latestXiaomiPackageVersion + " ?", "Yes", "No"))
                        {
                            AddRequest add = Client.Add(LatestXiaomiPackageId);
                            requestList.Add(new RequestQueueItem(add, PackmanOperationType.Add));
                            System.Console.WriteLine("Updating to: " + LatestXiaomiPackageId);
                            packmanOperationRunning = true;
                        }
                    }
                }
                if (GUILayout.Button("Remove", GUILayout.Width(60)))
                {
                    if (packmanOperationRunning)
                    {
                        return;
                    }

                    RemoveRequest remove = Client.Remove(xiaomiPackageName);
                    requestList.Add(new RequestQueueItem(remove, PackmanOperationType.Remove));
                    System.Console.WriteLine("Removing Xiaomi Package: " + CurrentXiaomiPackageId);
                    packmanOperationRunning = true;
                }
                GUILayout.EndHorizontal();
            }

            EditorGUI.EndDisabledGroup();
        }
        public void StreamUnstreamMessagesOneByOne()
        {
            var schema = TypedSchemaFactory.FromType(typeof(CacheableTypeOk));

            var qbuilder = new QueryBuilder(typeof(CacheableTypeOk));

            var put  = new PutRequest(typeof(CacheableTypeOk));
            var item = new CacheableTypeOk(3, 1003, "AHA", new DateTime(2010, 10, 02), 8);

            var typeDescription =
                TypedSchemaFactory.FromType(typeof(CacheableTypeOk));

            put.Items.Add(PackedObject.Pack(item, schema));

            var remove = new RemoveRequest(typeof(CacheableTypeOk), new KeyValue(1, schema.PrimaryKeyField));

            var register = new RegisterTypeRequest(typeDescription);

            using (var stream = new MemoryStream())
            {
                //request
                Streamer.ToStream(stream, new GetRequest(qbuilder.FromSql("select from CacheableTypeOk where IndexKeyValue > 1000")));
                Streamer.ToStream(stream, put);
                Streamer.ToStream(stream, remove);
                Streamer.ToStream(stream, register);

                //response
                Streamer.ToStream(stream, new NullResponse());
                Streamer.ToStream(stream, new ExceptionResponse(new Exception("fake exception")));
                Streamer.ToStream(stream, new ServerDescriptionResponse());

                stream.Seek(0, SeekOrigin.Begin);
                object reloaded = Streamer.FromStream <Request>(stream);
                Assert.IsTrue(reloaded is GetRequest);

                //request
                reloaded = Streamer.FromStream <Request>(stream);
                Assert.IsTrue(reloaded is PutRequest);

                reloaded = Streamer.FromStream <Request>(stream);
                Assert.IsTrue(reloaded is RemoveRequest);

                reloaded = Streamer.FromStream <Request>(stream);
                Assert.IsTrue(reloaded is RegisterTypeRequest);

                ////response
                reloaded = Streamer.FromStream <Response>(stream);
                Assert.IsTrue(reloaded is NullResponse);

                reloaded = Streamer.FromStream <Response>(stream);
                Assert.IsTrue(reloaded is ExceptionResponse);

                reloaded = Streamer.FromStream <Response>(stream);
                Assert.IsTrue(reloaded is ServerDescriptionResponse);
            }
        }
Example #30
0
        public override Task <ToDoItem> Remove(RemoveRequest request, ServerCallContext context)
        {
            var result = _repository.Remove(request.Id);

            if (result == null)
            {
                throw new RpcException(new Status(StatusCode.NotFound, "Task not found"));
            }
            return(Task.FromResult(result));
        }