Ejemplo n.º 1
0
 /// <summary>
 /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider"
 /// /> and <see cref="ignoreCase" />
 /// </summary>
 /// <param name="sourceValue">the value to convert into an instance of <see cref="DeleteStatus" />.</param>
 /// <returns>
 /// an instance of <see cref="DeleteStatus" />, or <c>null</c> if there is no suitable conversion.
 /// </returns>
 public static object ConvertFrom(dynamic sourceValue)
 {
     if (null == sourceValue)
     {
         return(null);
     }
     try
     {
         DeleteTask.FromJsonString(typeof(string) == sourceValue.GetType() ? sourceValue : sourceValue.ToJsonString());
     }
     catch
     {
         // Unable to use JSON pattern
     }
     try
     {
         return(new DeleteTask
         {
             ApiVersion = sourceValue.ApiVersion,
             Spec = sourceValue.Spec,
             Status = sourceValue.Status,
             Metadata = sourceValue.Metadata,
         });
     }
     catch
     {
     }
     return(null);
 }
Ejemplo n.º 2
0
        public object Delete(DeleteTask message)
        {
            using (var db = _connectionFactory.Open())
            {
                var task = db.Select <Task>(x => x.SessionId == message.SessionId && x.Id == message.TaskId);

                if (task == null)
                {
                    return new HttpResult()
                           {
                               StatusCode = HttpStatusCode.NotFound
                           }
                }
                ;

                try
                {
                    db.Delete(task);
                }
                catch (Exception)
                {
                    throw;
                }

                return(this.Get(new Tasks()
                {
                    SessionId = message.SessionId
                }));
            }
        }
    }
Ejemplo n.º 3
0
        public IActionResult DeleteTask([FromBody] DeleteTask DeleteTask)
        {
            if (DeleteTask == null)
            {
                return(new JsonResult(new List <object>()
                {
                    new { Error = "no json file", Description = "send a json " }
                }));
            }

            try
            {
                var del = (from e in Context.Tasks
                           where e.GuserId == DeleteTask.GuserId && e.TaskId == DeleteTask.TaskId
                           select e).FirstOrDefault();
                Context.Tasks.Remove(del);
                Context.SaveChanges();
                return(Ok("Task deleted"));
            }
            catch (Exception e)
            {
                return(new JsonResult(new List <object>()
                {
                    new { Error = "invalid Json", Description = "Json sent has invalid key value pair" }
                }));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Removes wrapper assembly from build directory, if wrapper assembly
        /// no longer exists in output directory or is not in sync with build
        /// directory, to force rebuild.
        /// </summary>
        /// <param name="config">The project configuration.</param>
        private void Sync(ConfigurationBase config)
        {
            if (!CopyLocal || !File.Exists(WrapperAssembly))
            {
                // nothing to synchronize
                return;
            }

            // determine path where wrapper assembly should be deployed to
            string outputFile = FileUtils.CombinePaths(config.OutputDir.FullName,
                                                       Path.GetFileName(WrapperAssembly));

            // determine last modification date/time of built wrapper assembly
            DateTime wrapperModTime = File.GetLastWriteTime(WrapperAssembly);

            // rebuild wrapper assembly if output assembly is more recent,
            // or have been removed (by the user) to force a rebuild
            if (FileSet.FindMoreRecentLastWriteTime(outputFile, wrapperModTime) != null)
            {
                // remove wrapper assembly to ensure a rebuild is performed
                DeleteTask deleteTask = new DeleteTask();
                deleteTask.Project = SolutionTask.Project;
                deleteTask.Parent  = SolutionTask;
                deleteTask.InitializeTaskConfiguration();
                deleteTask.File      = new FileInfo(WrapperAssembly);
                deleteTask.Threshold = Level.None; // no output in build log
                deleteTask.Execute();
            }
        }
Ejemplo n.º 5
0
        public IActionResult Delete(int Id)
        {
            var q = new DeleteTask(_configuration);

            q.RemoveTask(Id);
            return(RedirectToAction("YourTasks"));
        }
Ejemplo n.º 6
0
        public void Setup()
        {
            //create base folder for "project"'s local copy
            _workingFolder = Path.Combine(Path.GetTempPath(), "FROM_VSS_DELETE");
            Directory.CreateDirectory(_workingFolder);

            //This item represents the base project item
            _project      = new MockVssItem();
            _project.Name = "TEMPVSSPROJECT";
            _project.SetType((int)VSSItemType.VSSITEM_PROJECT);
            string localProjectPath = _workingFolder;

            Directory.CreateDirectory(localProjectPath);

            //create the instance of the DeleteTask that we will use in the tests
            _deleteTask      = new DeleteTask();
            _deleteTask.Item = _project;
            _deleteTask.Path = "$/" + _project.Name;

            //make the DeleteTask happy by giving it a dummy project file to reference
            XmlDocument doc = new XmlDocument();

            doc.LoadXml("<project name='test'/>");
            _deleteTask.Project = new Project(doc, Level.Info, 0);
        }
Ejemplo n.º 7
0
        public void DeleteTask_Action_Fails()
        {
            // Arrange
            var taskDto = TestHelper.TaskDto();

            GenericServiceResponse <bool> fakeResponse = null;

            mockClientServicesProvider.Setup(x => x.Logger).Returns(mockLogger.Object).Verifiable();
            mockClientServicesProvider.Setup(x => x.TaskService.DeleteTask(taskDto)).Returns(fakeResponse).Verifiable();

            var viewModel = new GenericViewModel();

            var action = new DeleteTask <GenericViewModel>(mockClientServicesProvider.Object)
            {
                OnComplete = model => viewModel = model
            };

            // Act
            var result = action.Invoke(taskDto);

            // Assert
            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(GenericViewModel));
            Assert.IsNotNull(result.Notifications);
            Assert.IsInstanceOfType(result.Notifications, typeof(NotificationCollection));
            Assert.IsTrue(result.Notifications.Count() == 1);
            Assert.IsTrue(result.HasErrors);
            Assert.IsNotNull(result.Success);
            Assert.IsInstanceOfType(result.Success, typeof(bool));
            Assert.IsFalse(result.Success);
        }
Ejemplo n.º 8
0
        public ActionResult DeleteTask(string _TaskId)
        {
            DeleteTask deleteTask = new DeleteTask();

            deleteTask.RemoveTask(Int32.Parse(_TaskId));
            return(Json(_TaskId));
        }
Ejemplo n.º 9
0
        public Unit Handle(DeleteTask command)
        {
            var task = _taskRepository.GetById(command.TaskId);

            _taskRepository.Delete(task);

            return(Unit.Value);
        }
Ejemplo n.º 10
0
 public ActionResult <DeleteTaskResponse> Post(DeleteTask request)
 {
     if (request.Ids != null)
     {
         host.Connection.Delete(GXDeleteArgs.Delete <GXTask>(q => request.Ids.Contains(q.Id)));
         host.SetChange(TargetType.Tasks, DateTime.Now);
     }
     return(new DeleteTaskResponse());
 }
Ejemplo n.º 11
0
        public object Delete(DeleteTask request)
        {
            var entity = request.ConvertTo <Task>();

            return(InTransaction(db =>
            {
                Logic.Remove(entity);
                return new CommonResponse();
            }));
        }
Ejemplo n.º 12
0
        public DataPortalResult Delete(Type objectType, object criteria, DataPortalContext context)
        {
            Thread     t    = new Thread(DoDelete);
            DeleteTask task = new DeleteTask();

            task.ObjectType = objectType;
            task.Criteria   = criteria;
            task.Context    = context;
            t.Start(task);
            t.Join();
            return(task.Result);
        }
Ejemplo n.º 13
0
        public async Task Run_ReturnsNoContentOnSuccess()
        {
            var handler   = new Mock <ICommandHander <DeleteTaskCommand> >();
            var container = new Container();
            var request   = new DefaultHttpRequest(new DefaultHttpContext());
            var listId    = Guid.NewGuid().ToString();
            var taskId    = Guid.NewGuid().ToString();

            handler.Setup(h => h.Execute(It.IsAny <DeleteTaskCommand>())).Returns(Task.CompletedTask);
            container.RegisterInstance(handler.Object);
            container.RegisterInstance(_telemetryClient);
            DeleteTask.Container = container;

            var result = await DeleteTask.Run(request, listId, taskId) as NoContentResult;

            Assert.IsNotNull(result);
        }
Ejemplo n.º 14
0
        public async Task Run_ReturnsServerErrorOnServerError()
        {
            var handler   = new Mock <ICommandHander <DeleteTaskCommand> >();
            var container = new Container();
            var request   = new DefaultHttpRequest(new DefaultHttpContext());
            var listId    = Guid.NewGuid().ToString();
            var taskId    = Guid.NewGuid().ToString();

            handler.Setup(h => h.Execute(It.IsAny <DeleteTaskCommand>()))
            .ThrowsAsync(new Exception());
            container.RegisterInstance(handler.Object);
            container.RegisterInstance(_telemetryClient);
            DeleteTask.Container = container;

            var result = await DeleteTask.Run(request, listId, taskId) as InternalServerErrorResult;

            Assert.IsNotNull(result);
        }
Ejemplo n.º 15
0
        void DoDelete(object state)
        {
            DeleteTask task = null;

            try
            {
                task = state as DeleteTask;
                if (task != null)
                {
                    task.Result = Portal.Delete(task.ObjectType, task.Criteria, task.Context);
                }
            }
            catch (Exception ex)
            {
                if (task != null)
                {
                    task.ResultException = ex;
                }
            }
        }
Ejemplo n.º 16
0
 /// <summary>
 /// hack:删除任务(只在调试中使用)
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Btn_Delete_Click(object sender, RoutedEventArgs e)
 {
     if (MessageBox.Show("是否要进行任务删除处理?", "注意", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         if (Self != null)
         {
             var temp = DeleteTask?.Invoke(Self);
             if (temp == null)
             {
                 MessageBox.Show("未处理任务删除事件");
             }
             if (temp.Success)
             {
                 MessageBox.Show("任务删除处理成功");
             }
             else
             {
                 MessageBox.Show($"任务删除失败:{temp.Msg}");
             }
         }
     }
 }
Ejemplo n.º 17
0
 public IActionResult DeleteTask([FromBody] DeleteTask deleteTask)
 {
     if (deleteTask == null)
     {
         output.status      = "Error";
         output.description = "send a json file";
     }
     else
     {
         try
         {
             var delete = context.tasks.Where(e =>
                                              e.GuserId == deleteTask.guserId && e.TaskId == deleteTask.taskId && !e.Status).FirstOrDefault();
             if (delete == null)
             {
                 output.status      = "Error";
                 output.description = "no task to delete";
             }
             else
             {
                 //this line deletes the row from the database
                 //context.tasks.Remove(del);
                 //status is updated to indicate that the task is completed
                 delete.Status = true;
                 context.SaveChanges();
                 output.status      = "success";
                 output.description = "task deleted successfully";
             }
         }
         catch (Exception e)
         {
             output.status      = "error";
             output.description = e.Message;
         }
     }
     return(new JsonResult(output));
 }
Ejemplo n.º 18
0
        public async Task <DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
        {
            var task =
                new DeleteTask
            {
                Criteria   = criteria,
                Context    = context,
                ObjectType = objectType
            };

            if (isSync)
            {
                DoDelete(task);
            }
            else
            {
                await Task.Factory.StartNew(DoDelete, task);
            }
            if (task.ResultException != null)
            {
                throw task.ResultException;
            }
            return(task.Result);
        }
Ejemplo n.º 19
0
Archivo: Proxy.cs Proyecto: Jaans/csla
 public DataPortalResult Delete(Type objectType, object criteria, DataPortalContext context)
 {
   Thread t = new Thread(DoDelete);
   DeleteTask task = new DeleteTask();
   task.ObjectType = objectType;
   task.Criteria = criteria;
   task.Context = context;
   t.Start(task);
   t.Join();
   return task.Result;
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Converts a single file or group of files.
        /// </summary>
        protected override void ExecuteTask()
        {
            // ensure base directory is set, even if fileset was not initialized
            // from XML
            if (Assemblies.BaseDirectory == null)
            {
                Assemblies.BaseDirectory = new DirectoryInfo(Project.BaseDirectory);
            }
            if (Resources.BaseDirectory == null)
            {
                Resources.BaseDirectory = new DirectoryInfo(Project.BaseDirectory);
            }

            _arguments = "";
            if (Resources.FileNames.Count > 0)
            {
                if (OutputFile != null)
                {
                    throw new BuildException(ResourceUtils.GetString("NA2026"), Location);
                }
                foreach (string filename in Resources.FileNames)
                {
                    FileInfo outputFile = GetOutputFile(new FileInfo(Path.Combine(
                                                                         Path.GetDirectoryName(filename), Resources.GetManifestResourceName(filename))));

                    if (NeedsCompiling(new FileInfo(filename), outputFile))
                    {
                        // ensure output directory exists
                        if (!outputFile.Directory.Exists)
                        {
                            outputFile.Directory.Create();
                        }

                        string cmdLineArg = string.Format(CultureInfo.InvariantCulture,
                                                          " \"{0},{1}\"", filename, outputFile.FullName);

                        // check if adding arguments to compile current resx to
                        // total command line would cause it to exceed maximum
                        // length
                        bool maxCmdLineExceeded = (_arguments.Length + cmdLineArg.Length > _maxCmdLineLength);

                        // if this is the first resx that we're compiling, or the
                        // first one of the next execution of the resgen tool, then
                        // add options to command line
                        if (StringUtils.IsNullOrEmpty(_arguments) || maxCmdLineExceeded)
                        {
                            if (UseSourcePath)
                            {
                                if (SupportsExternalFileReferences)
                                {
                                    cmdLineArg = " /usesourcepath";
                                }
                                else
                                {
                                    Log(Level.Warning, ResourceUtils.GetString(
                                            "String_ResourceCompilerDoesNotSupportExternalReferences"),
                                        Project.TargetFramework.Description);
                                }
                            }

                            cmdLineArg = "/compile" + cmdLineArg;
                        }

                        // if maximum length would have been exceeded by compiling
                        // the current resx file, then first execute the resgen
                        // tool
                        if (maxCmdLineExceeded)
                        {
                            try {
                                // call base class to do the work
                                base.ExecuteTask();
                            } catch {
                                // we only need to remove temporary directory when
                                // an error occurred and if it was actually created
                                if (_workingDirectory != null)
                                {
                                    // delete temporary directory and all files in it
                                    DeleteTask deleteTask = new DeleteTask();
                                    deleteTask.Project = Project;
                                    deleteTask.Parent  = this;
                                    deleteTask.InitializeTaskConfiguration();
                                    deleteTask.Directory = new DirectoryInfo(_workingDirectory);
                                    deleteTask.Threshold = Level.None; // no output in build log
                                    deleteTask.Execute();
                                }

                                // rethrow exception
                                throw;
                            }

                            // reset command line arguments as we've processed them
                            _arguments = string.Empty;
                        }

                        // append command line arguments to compile current resx
                        // file to the total command line
                        AppendArgument(cmdLineArg);
                    }
                }
            }
            else
            {
                // Single file situation
                if (InputFile == null)
                {
                    throw new BuildException(ResourceUtils.GetString("NA2027"), Location);
                }

                FileInfo outputFile = GetOutputFile(InputFile);

                if (NeedsCompiling(InputFile, outputFile))
                {
                    // ensure output directory exists
                    if (!outputFile.Directory.Exists)
                    {
                        outputFile.Directory.Create();
                    }

                    if (UseSourcePath)
                    {
                        if (SupportsExternalFileReferences)
                        {
                            AppendArgument("/usesourcepath");
                        }
                        else
                        {
                            Log(Level.Warning, ResourceUtils.GetString(
                                    "String_ResourceCompilerDoesNotSupportExternalReferences"),
                                Project.TargetFramework.Description);
                        }
                    }

                    AppendArgument(string.Format(CultureInfo.InvariantCulture,
                                                 " \"{0}\" \"{1}\"", InputFile.FullName, outputFile.FullName));
                }
            }

            if (!StringUtils.IsNullOrEmpty(_arguments))
            {
                try {
                    // call base class to do the work
                    base.ExecuteTask();
                } finally {
                    // we only need to remove temporary directory if it was
                    // actually created
                    if (_workingDirectory != null)
                    {
                        // delete temporary directory and all files in it
                        DeleteTask deleteTask = new DeleteTask();
                        deleteTask.Project = Project;
                        deleteTask.Parent  = this;
                        deleteTask.InitializeTaskConfiguration();
                        deleteTask.Directory = new DirectoryInfo(_workingDirectory);
                        deleteTask.Threshold = Level.None; // no output in build log
                        deleteTask.Execute();
                    }
                }
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Converts a single file or group of files.
        /// </summary>
        protected override void ExecuteTask()
        {
            // ensure base directory is set, even if fileset was not initialized
            // from XML
            if (Assemblies.BaseDirectory == null)
            {
                Assemblies.BaseDirectory = new DirectoryInfo(Project.BaseDirectory);
            }
            if (Resources.BaseDirectory == null)
            {
                Resources.BaseDirectory = new DirectoryInfo(Project.BaseDirectory);
            }

            // clear buffer
            _arguments.Length = 0;

            if (Resources.FileNames.Count > 0 || QualifiedResources.Count > 0)
            {
                if (OutputFile != null)
                {
                    throw new BuildException(ResourceUtils.GetString("NA2026"), Location);
                }

                foreach (string fileName in Resources.FileNames)
                {
                    FileInfo inputFile  = new FileInfo(fileName);
                    FileInfo outputFile = GetOutputFile(new FileInfo(Path.Combine(
                                                                         inputFile.DirectoryName, Resources.GetManifestResourceName(fileName))));
                    WriteCommandLineOptions(inputFile, outputFile);
                }

                // used by <solution> task
                foreach (QualifiedResource resource in QualifiedResources)
                {
                    WriteCommandLineOptions(resource.Input, resource.Output);
                }
            }
            else
            {
                // Single file situation
                if (InputFile == null)
                {
                    throw new BuildException(ResourceUtils.GetString("NA2027"), Location);
                }

                FileInfo outputFile = GetOutputFile(InputFile);

                if (NeedsCompiling(InputFile, outputFile))
                {
                    // ensure output directory exists
                    if (!outputFile.Directory.Exists)
                    {
                        outputFile.Directory.Create();
                    }

                    if (UseSourcePath)
                    {
                        if (SupportsExternalFileReferences)
                        {
                            _arguments.Append("/useSourcePath");
                        }
                        else
                        {
                            Log(Level.Warning, ResourceUtils.GetString(
                                    "String_ResourceCompilerDoesNotSupportExternalReferences"),
                                Project.TargetFramework.Description);
                        }
                    }

                    _arguments.Append(string.Format(CultureInfo.InvariantCulture,
                                                    " \"{0}\" \"{1}\"", InputFile.FullName, outputFile.FullName));
                }
            }

            if (_arguments.Length != 0)
            {
                try {
                    // call base class to do the work
                    base.ExecuteTask();
                } finally {
                    // we only need to remove temporary directory if it was
                    // actually created
                    if (_workingDirectory != null)
                    {
                        // delete temporary directory and all files in it
                        DeleteTask deleteTask = new DeleteTask();
                        deleteTask.Project = Project;
                        deleteTask.Parent  = this;
                        deleteTask.InitializeTaskConfiguration();
                        deleteTask.Directory = _workingDirectory;
                        deleteTask.Threshold = Level.None; // no output in build log
                        deleteTask.Execute();
                    }
                }
            }
        }
Ejemplo n.º 22
0
 public async Task <Unit> DeleteTaskAsync([FromBody] DeleteTask deleteTask)
 {
     return(await _mediator.Send(deleteTask));
 }
Ejemplo n.º 23
0
 public async Task<DataPortalResult> Delete(Type objectType, object criteria, DataPortalContext context, bool isSync)
 {
   var task = 
     new DeleteTask
       {
         Criteria = criteria, 
         Context = context, 
         ObjectType = objectType
       };
   if (isSync)
     DoDelete(task);
   else
     await Task.Factory.StartNew(DoDelete, task);
   if (task.ResultException != null)
     throw task.ResultException;
   return task.Result;
 }
        public async Task <IActionResult> DeleteTask([FromRoute] DeleteTask command)
        {
            await _mediator.Send(command);

            return(Deleted());
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Registers or unregisters a single assembly, or a group of assemblies.
        /// </summary>
        protected override void ExecuteTask()
        {
            if (AssemblyFile == null && Assemblies.FileNames.Count == 0)
            {
                return;
            }

            // when reference assembly are specified, we copy all references
            // and all assemblies to a temp directory and run regasm from there
            if (References.FileNames.Count != 0)
            {
                // use a newly created temporary directory as working directory
                BaseDirectory = FileUtils.GetTempDirectory();
            }

            if (Unregister)
            {
                _arguments.Append(" /unregister");
            }
            if (TypeLib != null)
            {
                _arguments.AppendFormat(CultureInfo.InvariantCulture,
                                        " /tlb:\"{0}\"", TypeLib.FullName);
            }
            if (CodeBase)
            {
                _arguments.Append(" /codebase");
            }
            if (RegistryFile != null)
            {
                _arguments.AppendFormat(CultureInfo.InvariantCulture,
                                        " /regfile:\"{0}\"", RegistryFile.FullName);
            }
            if (Registered)
            {
                _arguments.Append(" /registered");
            }
            if (Verbose)
            {
                _arguments.Append(" /verbose");
            }
            else
            {
                _arguments.Append(" /silent");
            }
            _arguments.Append(" /nologo");

            if (AssemblyFile != null)
            {
                Log(Level.Info, "{0} '{1}' for COM Interop",
                    Unregister ? "Unregistering" : "Registering",
                    AssemblyFile.FullName);
                _arguments.AppendFormat(" \"{0}\"", GetAssemblyPath(
                                            AssemblyFile.FullName));
            }
            else
            {
                // display build log message
                Log(Level.Info, "{0} {1} files for COM interop",
                    Unregister ? "UnRegistering" : "Registering",
                    Assemblies.FileNames.Count);

                // add files to command line
                foreach (string path in Assemblies.FileNames)
                {
                    Log(Level.Verbose, "{0} '{1}' for COM Interop",
                        Unregister ? "UnRegistering" : "Registering",
                        path);

                    _arguments.AppendFormat(" \"{0}\"", GetAssemblyPath(path));
                }
            }

            try {
                // call base class to do the work
                base.ExecuteTask();
            } finally {
                // we only need to remove temporary directory if it was
                // actually created
                if (_workingDirectory != null)
                {
                    // delete temporary directory and all files in it
                    DeleteTask deleteTask = new DeleteTask();
                    deleteTask.Project = Project;
                    deleteTask.Parent  = this;
                    deleteTask.InitializeTaskConfiguration();
                    deleteTask.Directory = _workingDirectory;
                    deleteTask.Threshold = Level.None; // no output in build log
                    deleteTask.Execute();
                }
            }
        }
Ejemplo n.º 26
0
        private void WriteCommandLineOptions(FileInfo inputFile, FileInfo outputFile)
        {
            if (!NeedsCompiling(inputFile, outputFile))
            {
                return;
            }

            // ensure output directory exists
            if (!outputFile.Directory.Exists)
            {
                outputFile.Directory.Create();
            }

            string cmdLineArg = string.Format(CultureInfo.InvariantCulture,
                                              "\"{0},{1}\" ", inputFile, outputFile.FullName);

            // check if adding arguments to compile current resx to
            // total command line would cause it to exceed maximum
            // length
            bool maxCmdLineExceeded = (_arguments.Length + cmdLineArg.Length > _maxCmdLineLength);

            // if this is the first resx that we're compiling, or the
            // first one of the next execution of the resgen tool, then
            // add options to command line
            if (_arguments.Length == 0 || maxCmdLineExceeded)
            {
                StringBuilder sb = new StringBuilder();

                // bug #1415272: first write assembly references, to make sure these
                // are taken into account when calculating the length of the command
                // line
                if (SupportsAssemblyReferences)
                {
                    foreach (string assembly in Assemblies.FileNames)
                    {
                        sb.AppendFormat(CultureInfo.InvariantCulture,
                                        "/r:\"{0}\" ", assembly);
                    }
                }

                if (UseSourcePath)
                {
                    if (SupportsExternalFileReferences)
                    {
                        sb.Append("/useSourcePath ");
                    }
                    else
                    {
                        Log(Level.Warning, ResourceUtils.GetString(
                                "String_ResourceCompilerDoesNotSupportExternalReferences"),
                            Project.TargetFramework.Description);
                    }
                }
                sb.Append("/compile ");
                sb.Append(cmdLineArg);
                cmdLineArg = sb.ToString();
            }

            // if maximum length would have been exceeded by compiling
            // the current resx file, then first execute the resgen
            // tool
            if (maxCmdLineExceeded)
            {
                try {
                    // call base class to do the work
                    base.ExecuteTask();
                } catch {
                    // we only need to remove temporary directory when
                    // an error occurred and if it was actually created
                    if (_workingDirectory != null)
                    {
                        // delete temporary directory and all files in it
                        DeleteTask deleteTask = new DeleteTask();
                        deleteTask.Project = Project;
                        deleteTask.Parent  = this;
                        deleteTask.InitializeTaskConfiguration();
                        deleteTask.Directory = _workingDirectory;
                        deleteTask.Threshold = Level.None; // no output in build log
                        deleteTask.Execute();
                    }

                    // rethrow exception
                    throw;
                }

                // reset command line arguments as we've processed them
                _arguments.Length = 0;
            }

            // append command line arguments to compile current resx
            // file to the total command line
            _arguments.Append(cmdLineArg);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Generates the license file.
        /// </summary>
        protected override void ExecuteTask()
        {
            FileInfo licensesFile = null;

            // ensure base directory is set, even if fileset was not initialized
            // from XML
            if (Assemblies.BaseDirectory == null)
            {
                Assemblies.BaseDirectory = new DirectoryInfo(Project.BaseDirectory);
            }

            // get the output .licenses file
            if (OutputFile == null)
            {
                try {
                    licensesFile = new FileInfo(Project.GetFullPath(Target + ".licenses"));
                } catch (Exception ex) {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                           ResourceUtils.GetString("NA2015"), Target), Location, ex);
                }
            }
            else
            {
                licensesFile = OutputFile;
            }

            // make sure the directory for the .licenses file exists
            if (!licensesFile.Directory.Exists)
            {
                licensesFile.Directory.Create();
            }

            // determine whether .licenses file need to be recompiled
            if (!NeedsCompiling(licensesFile))
            {
                return;
            }

            Log(Level.Verbose, ResourceUtils.GetString("String_CompilingLicenseUsingTarget"),
                InputFile.FullName, licensesFile.FullName, Target);

            if (HasCommandLineCompiler)
            {
                // the command line compiler does not allow us to specify the
                // full path to the output file, so we have it create the licenses
                // file in a temp directory, and copy it to its actual output
                // location

                // use a newly created temporary directory as working directory
                BaseDirectory = FileUtils.GetTempDirectory();

                try {
                    // set target assembly for generated licenses file
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/target:\"{0}\"", Target)));
                    // set input filename
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/complist:\"{0}\"", InputFile.FullName)));
                    // set output directory
                    Arguments.Add(new Argument(string.Format(CultureInfo.InvariantCulture,
                                                             "/outdir:\"{0}\"", BaseDirectory.FullName)));
                    // suppress display of startup banner
                    Arguments.Add(new Argument("/nologo"));
                    // adjust verbosity of tool if necessary
                    if (Verbose)
                    {
                        Arguments.Add(new Argument("/v"));
                    }
                    // use command line tool to compile licenses file
                    base.ExecuteTask();

                    // delete any existing output file
                    if (File.Exists(licensesFile.FullName))
                    {
                        File.Delete(licensesFile.FullName);
                    }

                    // copy licenses file to output file (with overwrite)
                    File.Copy(Path.Combine(BaseDirectory.FullName, Target + ".licenses"),
                              licensesFile.FullName, true);
                } finally {
                    // delete temporary directory and all files in it
                    DeleteTask deleteTask = new DeleteTask();
                    deleteTask.Project = Project;
                    deleteTask.Parent  = this;
                    deleteTask.InitializeTaskConfiguration();
                    deleteTask.Directory = BaseDirectory;
                    deleteTask.Threshold = Level.None; // no output in build log
                    deleteTask.Execute();
                }
            }
            else
            {
                // create new domain
#if (NET_4_0)
                AppDomain       newDomain       = AppDomain.CreateDomain("LicenseGatheringDomain");
                LicenseGatherer licenseGatherer = (LicenseGatherer)
                                                  newDomain.CreateInstanceAndUnwrap(typeof(LicenseGatherer).Assembly.FullName,
                                                                                    typeof(LicenseGatherer).FullName, false, BindingFlags.Public | BindingFlags.Instance,
                                                                                    null, new object[0], CultureInfo.InvariantCulture, new object[0]);
#else
                AppDomain newDomain = AppDomain.CreateDomain("LicenseGatheringDomain",
                                                             AppDomain.CurrentDomain.Evidence);
                LicenseGatherer licenseGatherer = (LicenseGatherer)
                                                  newDomain.CreateInstanceAndUnwrap(typeof(LicenseGatherer).Assembly.FullName,
                                                                                    typeof(LicenseGatherer).FullName, false, BindingFlags.Public | BindingFlags.Instance,
                                                                                    null, new object[0], CultureInfo.InvariantCulture, new object[0],
                                                                                    AppDomain.CurrentDomain.Evidence);
#endif
                licenseGatherer.CreateLicenseFile(this, licensesFile.FullName);

                // unload newly created domain
                AppDomain.Unload(newDomain);
            }
        }
Ejemplo n.º 28
0
 private void MenuItemDeleteTask_OnClick(object sender, RoutedEventArgs e)
 {
     CommonMethods.WorkWithTables.Delete(thisTask, httpClientProvider.GetDatabaseTaskEditor(), task => task.TaskId, () => DeleteTask?.Invoke(this, default(EventArgs)));
 }
Ejemplo n.º 29
0
 public ExecutionResult DeleteTask(DeleteTask command)
 {
     return(Execute(command));
 }
Ejemplo n.º 30
0
 public void DeleteFile(string path)
 {
     DeleteTask t = new DeleteTask(path);
     t.Run();
     this.history.Push(t);
 }
Ejemplo n.º 31
0
        /// <summary>
        /// Executes the task.
        /// </summary>
        /// <exception cref="BuildException">
        /// Project build failed.
        /// </exception>
        protected override void ExecuteTask()
        {
            Log(Level.Info, "Starting solution build.");

            if (SolutionFile != null)
            {
                if (!SolutionFile.Exists)
                {
                    throw new BuildException(string.Format(CultureInfo.InvariantCulture,
                                                           "Couldn't find solution file '{0}'.", SolutionFile.FullName),
                                             Location);
                }
            }

            if (Projects.FileNames.Count > 0)
            {
                Log(Level.Verbose, "Included projects:");
                foreach (string projectFile in Projects.FileNames)
                {
                    Log(Level.Verbose, " - {0}", projectFile);
                }
            }

            if (ReferenceProjects.FileNames.Count > 0)
            {
                Log(Level.Verbose, "Reference projects:");
                foreach (string projectFile in ReferenceProjects.FileNames)
                {
                    Log(Level.Verbose, " - {0}", projectFile);
                }
            }

            string basePath = null;

            try {
                using (TempFileCollection tfc = new TempFileCollection()) {
                    // store the temp dir so we can clean it up later
                    basePath = tfc.BasePath;

                    // ensure temp directory exists
                    if (!Directory.Exists(tfc.BasePath))
                    {
                        Directory.CreateDirectory(tfc.BasePath);
                    }

                    // create temporary domain
                    PermissionSet tempDomainPermSet = new PermissionSet(PermissionState.Unrestricted);

                    AppDomain temporaryDomain = AppDomain.CreateDomain("temporaryDomain", AppDomain.CurrentDomain.Evidence,
                                                                       AppDomain.CurrentDomain.SetupInformation, tempDomainPermSet);

                    try {
                        ReferencesResolver referencesResolver =
                            ((ReferencesResolver)temporaryDomain.CreateInstanceFrom(Assembly.GetExecutingAssembly().Location,
                                                                                    typeof(ReferencesResolver).FullName).Unwrap());

                        using (GacCache gacCache = new GacCache(this.Project)) {
                            SolutionBase sln = SolutionFactory.LoadSolution(this,
                                                                            tfc, gacCache, referencesResolver);
                            if (!sln.Compile(_configuration))
                            {
                                throw new BuildException("Project build failed.", Location);
                            }
                        }
                    } finally {
                        // unload temporary domain
                        AppDomain.Unload(temporaryDomain);
                    }
                }
            } finally {
                if (basePath != null && Directory.Exists(basePath))
                {
                    Log(Level.Debug, "Cleaning up temp folder '{0}'.", basePath);

                    // delete temporary directory and all files in it
                    DeleteTask deleteTask = new DeleteTask();
                    deleteTask.Project = Project;
                    deleteTask.Parent  = this;
                    deleteTask.InitializeTaskConfiguration();
                    deleteTask.Directory = new DirectoryInfo(basePath);
                    deleteTask.Threshold = Level.None; // no output in build log
                    deleteTask.Execute();
                }
            }
        }
Ejemplo n.º 32
0
        void DoDelete(object state)
        {
            DeleteTask task = state as DeleteTask;

            task.Result = Portal.Delete(task.ObjectType, task.Criteria, task.Context);
        }