public void TestCopyMoveFile()
        {
            var testFile = TestFiles.Docx;

            // Create temp folder
            var cRequest = new CreateFolderRequest("temp");
            FolderApi.CreateFolder(cRequest);

            // Copy file
            var destPath = $"temp/{testFile.FileName}";
            var request = new CopyFileRequest(testFile.FullName, destPath);
            FileApi.CopyFile(request);

            // Check copied file
            var eRequest = new ObjectExistsRequest(destPath);
            var eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Move file
            var newDestPath = $"temp/{testFile.FileName.Replace(".", "_1.")}";
            var mRequest = new MoveFileRequest(destPath, newDestPath);
            FileApi.MoveFile(mRequest);

            // Check moved file
            eRequest = new ObjectExistsRequest(newDestPath);
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Delete temp folder
            var delRequest = new DeleteFolderRequest("temp", null, true);
            FolderApi.DeleteFolder(delRequest);
        }
        /// <summary>
        /// Move file
        /// </summary>
        /// <param name="request">Request. <see cref="MoveFileRequest" /></param>
        public void MoveFile(MoveFileRequest request)
        {
            // verify the required parameter 'srcPath' is set
            if (request.SrcPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'srcPath' when calling MoveFile");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetApiRootUrl() + "/assembly/storage/file/move/{srcPath}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddPathParameter(resourcePath, "srcPath", request.SrcPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destPath", request.DestPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "srcStorageName", request.SrcStorageName);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destStorageName", request.DestStorageName);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "versionId", request.VersionId);

            var response = this.apiInvoker.InvokeApi(
                resourcePath,
                "PUT",
                null,
                null,
                null);
        }
Exemplo n.º 3
0
        public HttpResponseMessage MoveFile(MoveFileRequest moveFileRequest)
        {
            var groupId    = this.FindGroupId(this.Request);
            var moduleId   = this.Request.FindModuleId();
            var moduleMode = new SettingsManager(moduleId, groupId).Mode;

            ItemsManager.Instance.MoveFile(moveFileRequest.SourceFileId, moveFileRequest.DestinationFolderId, moduleMode, groupId);
            return(this.Request.CreateResponse(HttpStatusCode.OK, new { Status = 0 }));
        }
Exemplo n.º 4
0
        public void Test_MoveFileEntry_Success()
        {
            var request = new MoveFileRequest(FakeToken, FakeRepoId, "/test/file.txt", FakeRepoId, "/newdir/");
            var message = new HttpResponseMessage(HttpStatusCode.MovedPermanently)
            {
                Content = new StringContent("\"success\"")
            };

            Assert.IsTrue(request.WasSuccessful(message));
        }
Exemplo n.º 5
0
        /// <summary>
        ///     Move the given file
        /// </summary>
        /// <param name="libraryId">The id of the library th file is in</param>
        /// <param name="filePath">The full path of the file</param>
        /// <param name="targetLibraryId">The id of the library to move this file to</param>
        /// <param name="targetDirectory">The directory to move this file to</param>
        /// <returns>A value which indicates if the action was successful</returns>
        public async Task <bool> MoveFile(string libraryId, string filePath, string targetLibraryId, string targetDirectory)
        {
            libraryId.ThrowOnNull(nameof(libraryId));
            filePath.ThrowOnNull(nameof(filePath));
            targetLibraryId.ThrowOnNull(nameof(targetLibraryId));
            targetDirectory.ThrowOnNull(nameof(targetDirectory));

            var request = new MoveFileRequest(AuthToken, libraryId, filePath, targetLibraryId, targetDirectory);

            return(await _webConnection.SendRequestAsync(ServerUri, request));
        }
Exemplo n.º 6
0
        /// <summary>
        /// Move file
        /// </summary>
        /// <param name="request">Request. <see cref="MoveFileRequest" /></param>
        /// <returns><see cref=""/></returns>
        public void MoveFile(MoveFileRequest request)
        {
            // verify the required parameter 'srcPath' is set
            if (request.srcPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'srcPath' when calling MoveFile");
            }

            // verify the required parameter 'destPath' is set
            if (request.destPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'destPath' when calling MoveFile");
            }

            // create path and map variables
            var resourcePath = this.configuration.GetApiRootUrl() + "/ocr/storage/file/move/{srcPath}";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = UrlHelper.AddPathParameter(resourcePath, "srcPath", request.srcPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destPath", request.destPath);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "srcStorageName", request.srcStorageName);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "destStorageName", request.destStorageName);
            resourcePath = UrlHelper.AddQueryParameterToUrl(resourcePath, "versionId", request.versionId);

            try
            {
                var response = this.apiInvoker.InvokeApi <string>(
                    resourcePath,
                    "PUT",
                    null,
                    null,
                    null);
                if (response != null)
                {
                    return;
                }

                return;
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return;
                }

                throw;
            }
        }
        public static void Run()
        {
            var apiInstance = new FileApi(Constants.GetConfig());

            try
            {
                var request = new MoveFileRequest("one-page1.docx", "Annotationdocs1/one-page1.docx", Constants.MyStorage, Constants.MyStorage);

                apiInstance.MoveFile(request);
                Console.WriteLine("Expected response type is Void: 'one-page1.docx' file moved to 'Annotationdocs1/one-page1.docx'.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FileApi: " + e.Message);
            }
        }
Exemplo n.º 8
0
        public MoveFileResponse MoveFile(MoveFileRequest request)
        {
            MoveFileResponse response = new MoveFileResponse();

            try
            {
                response = FileManagerService.RemoteFileCommand(request).Action();
            }
            catch (Exception ex)
            {
                response.Code = "0001";
                response.Code = ex.Message;
            }

            return(response);
        }
        public static void Run()
        {
            var configuration = new Configuration(Common.MyAppSid, Common.MyAppKey);
            var apiInstance   = new FileApi(configuration);

            try
            {
                var request = new MoveFileRequest("viewerdocs/one-page1.docx", "viewerdocs1/one-page1.docx", Common.MyStorage, Common.MyStorage);

                apiInstance.MoveFile(request);
                Console.WriteLine("Expected response type is Void: 'viewerdocs/one-page1.docx' file moved to 'viewerdocs1/one-page1.docx'.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception while calling FileApi: " + e.Message);
            }
        }
        public void TestMoveFile()
        {
            string remoteFileName = "TestMoveFileSrc.docx";

            this.UploadFileToStorage(
                remoteDataFolder + "/" + remoteFileName,
                null,
                null,
                File.ReadAllBytes(LocalTestDataFolder + localFile)
                );

            var request = new MoveFileRequest(
                destPath: BaseTestOutPath + "/TestMoveFileDest_" + CreateRandomGuid + ".docx",
                srcPath: remoteDataFolder + "/" + remoteFileName
                );

            this.WordsApi.MoveFile(request);
        }
Exemplo n.º 11
0
        public MoveFile(MoveFileRequest request)
        {
            ConnectNetDrive();
            _targetPath = request.TargetContainer +
                          (String.IsNullOrEmpty(request.TargetContainer)
                            ? "" : @"\") + request.TargetFileName;
            _currentPath = request.CurrentContainer +
                           (String.IsNullOrEmpty(request.CurrentContainer)
                            ? "" : @"\") + request.CurrentFileName;

            DirectoryInfo di = null;

            if (!Directory.Exists(DefaultNetDrive + _targetPath))
            {
                di = Directory.CreateDirectory(DefaultNetDrive + request.TargetContainer);
            }
            _targetfileName  = request.TargetFileName;
            _currentFileName = request.CurrentFileName;
        }
Exemplo n.º 12
0
        public void Test_MoveFileEntry_Error()
        {
            var request = new MoveFileRequest(FakeToken, FakeRepoId, "/test/file.txt", FakeRepoId, "/newdir/");

            var message = new HttpResponseMessage(HttpStatusCode.Forbidden);

            Assert.IsFalse(request.WasSuccessful(message));

            message = new HttpResponseMessage(HttpStatusCode.BadRequest);
            Assert.IsFalse(request.WasSuccessful(message));

            // there seems to be a bug in the seafile web api
            // as the server returns NotFound even when the renaming was successful
            // so we cannot test this

            // message = new HttpResponseMessage(HttpStatusCode.NotFound);
            // Assert.IsFalse(req.WasSuccessful(m));

            message = new HttpResponseMessage(HttpStatusCode.InternalServerError);
            Assert.IsFalse(request.WasSuccessful(message));
        }
Exemplo n.º 13
0
        public async Task <FileSystemInfoContract> MoveItemAsync(RootName root, FileSystemId source, string moveName, DirectoryId destination, Func <FileSystemInfoLocator> locatorResolver)
        {
            var context = await RequireContextAsync(root);

            var path        = !string.IsNullOrEmpty(moveName) ? destination.Value.TrimEnd('/') + '/' + moveName : destination.Value;
            var moveRequest = new MoveFileRequest()
            {
                From = source.Value, Path = path
            };
            var link = await context.Client.Commands.MoveAsync(moveRequest, CancellationToken.None);

            if (!await OperationProgressAsync(context, link))
            {
                throw new ApplicationException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.OperationFailed, nameof(YandexDisk.Client.Clients.ICommandsClient.MoveAsync)));
            }
            var request = new ResourceRequest()
            {
                Path = path
            };
            var item = await context.Client.MetaInfo.GetInfoAsync(request, CancellationToken.None);

            return(item.ToFileSystemInfoContract());
        }
        public void StorageCopyMoveFile()
        {
            var testFile = TestFiles.PdfStorage.FirstOrDefault(x => x.Name.Equals("01_pages.pdf"));

            // Create temp folder
            var cRequest = new CreateFolderRequest("temp");

            FolderApi.CreateFolder(cRequest);

            // Copy file
            var destPath = $"temp/{testFile.Name}";
            var request  = new CopyFileRequest(testFile.Path, destPath);

            FileApi.CopyFile(request);

            // Check copied file
            var eRequest  = new ObjectExistsRequest(destPath);
            var eResponse = StorageApi.ObjectExists(eRequest);

            Assert.IsTrue(eResponse.Exists);

            // Move file
            var newDestPath = $"temp/{testFile.Path.Replace(".", "_1.")}";
            var mRequest    = new MoveFileRequest(destPath, newDestPath);

            FileApi.MoveFile(mRequest);

            // Check moved file
            eRequest  = new ObjectExistsRequest(newDestPath);
            eResponse = StorageApi.ObjectExists(eRequest);
            Assert.IsTrue(eResponse.Exists);

            // Delete temp folder
            var delRequest = new DeleteFolderRequest("temp", null, true);

            FolderApi.DeleteFolder(delRequest);
        }
Exemplo n.º 15
0
    private bool MoveFile(int nFileId, int nFolderId, out string err)
    {
        string strResultInfo = string.Empty;

        err = string.Empty;

        string sProspectStatus = LoansManager.GetProspectStatusInfo(nFileId);
        string sFileName       = LoansManager.GetProspectFileNameInfo(nFileId); //bug 878

        if (sFileName == "")
        {
            err = "The selected lead does not have a Point file.";
            return(false);
        }

        ServiceManager sm = new ServiceManager();

        using (LP2ServiceClient client = sm.StartServiceClient())
        {
            MoveFileRequest req = new MoveFileRequest();
            req.FileId      = nFileId;
            req.NewFolderId = nFolderId;
            req.hdr         = new ReqHdr();
            req.hdr.UserId  = CurrUser.iUserID;

            MoveFileResponse response = client.MoveFile(req);
            if (response.hdr.Successful)
            {
                return(true);
            }

            // LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo));
            //PageCommon.WriteJsEnd(this, response.hdr.StatusInfo);
            err = response.hdr.StatusInfo;
            return(false);
        }
    }
Exemplo n.º 16
0
        public async Task <FileSystemInfoContract> RenameItemAsync(RootName root, FileSystemId target, string newName, Func <FileSystemInfoLocator> locatorResolver)
        {
            var context = await RequireContextAsync(root);

            var indexOfName = target.Value.LastIndexOf('/');
            var path        = target.Value.Substring(0, indexOfName + 1) + newName;
            var moveRequest = new MoveFileRequest()
            {
                From = target.Value, Path = path
            };
            var link = await context.Client.Commands.MoveAsync(moveRequest, CancellationToken.None);

            if (!await OperationProgressAsync(context, link))
            {
                throw new ApplicationException(string.Format(CultureInfo.CurrentCulture, Properties.Resources.OperationFailed, nameof(ICommandsClient.MoveAsync)));
            }
            var request = new ResourceRequest()
            {
                Path = path
            };
            var item = await context.Client.MetaInfo.GetInfoAsync(request, CancellationToken.None);

            return(item.ToFileSystemInfoContract());
        }
 public Task <Link> MoveAsync(MoveFileRequest request, CancellationToken cancellationToken = default)
 {
     return(PostAsync <CopyFileRequest, object, Link>("resources/move", request, /*requestBody*/ null, cancellationToken));
 }
Exemplo n.º 18
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnDispose_Click(object sender, EventArgs e)
    {
        bool bmove   = false;
        int  nFileId = -1;

        if (!int.TryParse(this.hiSelectedLoan.Value, out nFileId))
        {
            nFileId = -1;
        }
        if (nFileId == -1)
        {
            LPLog.LogMessage(LogType.Logerror, "Invalid file Id: " + this.hiSelectedLoan.Value);
            return;
        }

        int nFolderId = -1;

        if (!int.TryParse(this.hiSelectedFolderId.Value, out nFolderId))
        {
            nFolderId = -1;
        }
        if (nFolderId == -1)
        {
            LPLog.LogMessage(LogType.Logerror, "Invalid folder Id: " + this.hiSelectedFolderId.Value);
            return;
        }


        try
        {
            ServiceManager sm = new ServiceManager();
            using (LP2ServiceClient client = sm.StartServiceClient())
            {
                if (!bmove)
                {
                    DisposeLoanRequest req = new DisposeLoanRequest();
                    req.FileId      = nFileId;
                    req.LoanStatus  = hiSelectedDisposal.Value;
                    req.NewFolderId = nFolderId;
                    req.hdr         = new ReqHdr();
                    req.hdr.UserId  = CurrUser.iUserID;
                    req.StatusDate  = DateTime.Now;

                    DisposeLoanResponse response = client.DisposeLoan(req);
                    if (response.hdr.Successful)
                    {
                        if (WorkflowManager.UpdateLoanStatus(nFileId, hiSelectedDisposal.Value, CurrUser.iUserID))
                        {
                            BindLoanGrid();
                            LPLog.LogMessage(LogType.Loginfo, string.Format("Successfully update loan status, LoanId:{0}, to Status:{1}. ",
                                                                            nFileId, this.hiSelectedDisposal.Value));
                        }
                        else
                        {
                            PageCommon.AlertMsg(this, "Failed to update loan status.");
                            LPLog.LogMessage(LogType.Logerror, string.Format("Failed to update loan status, LoanId:{0}, to Status:{1}.",
                                                                             nFileId, this.hiSelectedDisposal.Value));
                        }
                    }
                    else
                    {
                        LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo));
                        PageCommon.AlertMsg(this, response.hdr.StatusInfo);
                    }
                }
                else
                {
                    MoveFileRequest req = new MoveFileRequest();
                    req.FileId      = nFileId;
                    req.NewFolderId = nFolderId;
                    req.hdr         = new ReqHdr();
                    req.hdr.UserId  = CurrUser.iUserID;

                    MoveFileResponse response = client.MoveFile(req);
                    if (response.hdr.Successful)
                    {
                    }
                    else
                    {
                        LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo));
                        PageCommon.AlertMsg(this, response.hdr.StatusInfo);
                    }
                }
            }
        }
        catch (System.ServiceModel.EndpointNotFoundException ee)
        {
            LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ee.Message));
            PageCommon.AlertMsg(this, "Failed to move the Point file, reason: Point Manager is not running.");
        }
        catch (Exception ex)
        {
            LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ex.Message));
            PageCommon.AlertMsg(this, ex.Message);
        }
    }
        /// <summary>
        /// Move file or folder on Disk from one path to another and wait until operation is done
        /// </summary>
        public static async Task MoveAndWaitAsync([NotNull] this ICommandsClient client, [NotNull] MoveFileRequest request, CancellationToken cancellationToken = default(CancellationToken), TimeSpan?pullPeriod = null)
        {
            var link = await client.MoveAsync(request, cancellationToken).ConfigureAwait(false);

            if (link.HttpStatusCode == HttpStatusCode.Accepted)
            {
                await client.WaitOperationAsync(link, cancellationToken, pullPeriod).ConfigureAwait(false);
            }
        }
 public static Task MoveAndWaitAsync([NotNull] this ICommandsClient client, [NotNull] MoveFileRequest request, CancellationToken cancellationToken, int pullPeriod)
 {
     return(MoveAndWaitAsync(client, request, cancellationToken, TimeSpan.FromSeconds(pullPeriod)));
 }
Exemplo n.º 21
0
 public static MoveFile RemoteFileCommand(MoveFileRequest request)
 {
     return(new MoveFile(request));
 }
Exemplo n.º 22
0
        protected void btnSel_Click(object sender, EventArgs e)
        {
            string sFolderID = "0";

            // return selected record as XML
            foreach (GridViewRow row in gvFolder.Rows)
            {
                CheckBox ckbSelected = row.FindControl("ckbSelected") as CheckBox;
                if (ckbSelected.Checked)
                {
                    if (!string.IsNullOrEmpty(_strPstatus) && _strPstatus == "1")
                    {
                        //ClientFun("callback", string.Format("callBack('{0}','{1}');", gvFolder.DataKeys[row.RowIndex].Value, _strPstatus));
                        sFolderID = gvFolder.DataKeys[row.RowIndex].Value.ToString();
                        //return;
                    }
                    //ClientFun("callback", string.Format("callBack('{0}');", gvFolder.DataKeys[row.RowIndex].Value.ToString()));
                    sFolderID = gvFolder.DataKeys[row.RowIndex].Value.ToString();
                    //return;
                }
            }

            BLL.Loans LoansManager = new BLL.Loans();

            string sProspectStatus = "";

            try
            {
                sProspectStatus = LoansManager.GetProspectStatusInfo(Convert.ToInt32(this.strFileId));
                string sFileName = LoansManager.GetProspectFileNameInfo(Convert.ToInt32(this.strFileId));  //bug 878
                if (sFileName == "")
                {
                    //PageCommon.AlertMsg(this, string.Format("The selected loan does not have a Point file. Please export the loan to a Point file using the Lead Detail page and try again."));
                    PageCommon.WriteJsEnd(this, "The selected loan does not have a Point file. Please export the loan to a Point file using the Lead Detail page and try again.", "window.parent.CloseGlobalPopup();");
                    return;
                }
            }
            catch
            {
                LPLog.LogMessage(LogType.Logerror, "Invalid loan status: " + sProspectStatus);
                return;
            }
            try
            {
                ServiceManager sm = new ServiceManager();
                using (LP2ServiceClient client = sm.StartServiceClient())
                {
                    MoveFileRequest req = new MoveFileRequest();
                    req.FileId = Convert.ToInt32(this.strFileId);
                    //           req.LoanStatus = lse;
                    req.NewFolderId = Convert.ToInt32(sFolderID);
                    req.hdr         = new ReqHdr();
                    req.hdr.UserId  = CurrUser.iUserID;
                    //           req.StatusDate = DateTime.Now;

                    MoveFileResponse response = client.MoveFile(req);
                    if (response.hdr.Successful)
                    {
                        PageCommon.WriteJsEnd(this, "", "window.parent.CloseGlobalPopup();");
                    }
                    else
                    {
                        LPLog.LogMessage(LogType.Logerror, string.Format("Failed to move file:{0}", response.hdr.StatusInfo));
                        //PageCommon.AlertMsg(this, response.hdr.StatusInfo);
                        //ClientFun("callback", "");
                        PageCommon.WriteJsEnd(this, response.hdr.StatusInfo, "window.parent.CloseGlobalPopup();");
                    }
                }
            }
            catch (System.ServiceModel.EndpointNotFoundException ee)
            {
                LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ee.Message));
                //PageCommon.AlertMsg(this, "Failed to move the Point file, reason: Point Manager is not running.");
                //ClientFun("callback", "");
                PageCommon.WriteJsEnd(this, "Failed to move the Point file, reason: Point Manager is not running.", "window.parent.CloseGlobalPopup();");
            }
            catch (Exception ex)
            {
                LPLog.LogMessage(LogType.Logerror, string.Format("Faield to move file:{0}", ex.Message));
                PageCommon.WriteJsEnd(this, ex.Message, "window.parent.CloseGlobalPopup();");
            }
        }