Beispiel #1
0
        public void TestCopyToAnotherNasImpersonationTask()
        {
            var filesToCopy = new List <string>
            {
                @"\\nasv0034\WAPFileTest\GoodNas\Folder1",
                @"\\nasv0034\WAPFileTest\GoodNas\APSET1761.JPG",
                @"\\nasv0034\WAPFileTest\GoodNas\IST databases 042415.xlsx"
            };
            var task   = new CopyToAnotherNasImpersonationTask(filesToCopy, @"\\nasv0034\WAPFileTest\GoodNas\Folder2");
            var result = task.Execute();

            Assert.IsTrue(result);
        }
Beispiel #2
0
        public async Task <HttpResponseMessage> CopyToAnotherNasDrive()
        {
            if (!await _requestExtractor.Extract(Request))
            {
                return(Helper.CreateResponseMessage(_requestExtractor.Response.StatusCode,
                                                    _requestExtractor.Response.Message));
            }


            var nonFileData = _requestExtractor.NonFileData;
            //Get NAS Path
            var           targetCopyFolder = string.Empty;
            List <string> itemsToCopy      = new List <string>();

            if (nonFileData != null)
            {
                targetCopyFolder = nonFileData.GetValues(0)[0];
                if (nonFileData.Count > 1)
                {
                    itemsToCopy = nonFileData.GetValues(1).ToList();
                }
            }
            var nasIdentity = _credential.GetCurrentCredential(Request);

            try
            {
                var impersonationTask = new CopyToAnotherNasImpersonationTask(itemsToCopy, targetCopyFolder);
                _impersonator.ExecuteTask(impersonationTask, nasIdentity.UserId, nasIdentity.UserPassword, Domain);
                return(Helper.CreateResponseMessage(HttpStatusCode.OK, "Copy operation completed successfully"));
            }
            catch (Exception ex)
            {
                return(Helper.CreateResponseMessage(HttpStatusCode.Forbidden,
                                                    $"Error:{ex.Message}"));
            }
        }