/// <summary>
        /// Demonstrates calling a task sequence
        /// </summary>
        /// <param name="createdProject">project</param>
        /// <param name="settings">user project settings</param>
        private void RunTasksSequence(FileBasedProject createdProject, LocalProjectSettings settings)
        {
            Language targetLanguage = new Language(settings.TargetLanguage);
            List <TaskStatusEventArgs> taskStatusEventArgsList = new List <TaskStatusEventArgs>();
            List <MessageEventArgs>    messageEventArgsList    = new List <MessageEventArgs>();

            ProjectFile[] projectFiles = createdProject.GetSourceLanguageFiles();

            createdProject.AddBilingualReferenceFiles(GetBilingualFileMappings(new Language[] { targetLanguage }, projectFiles, settings.PreviousVersionPath));

            TaskSequence taskSequence = createdProject.RunAutomaticTasks(projectFiles.GetIds(), TaskSequences.Prepare);

            createdProject.Save();
        }
        /// <summary>
        /// Create basic project from scratch, not using templates
        /// </summary>
        public FileBasedProject CreateProject(LocalProjectSettings settings)
        {
            FileBasedProject result;

            try
            {
                ////Create new project object
                FileBasedProject createdProject = new FileBasedProject(
                    this.GetProjectInfo(
                        settings.ProjectName,
                        new Language(settings.SourceLanguage),
                        new Language[] { new Language(settings.TargetLanguage) }));

                ////Add files
                createdProject.AddFolderWithFiles(settings.InputFolder, true);


                ////Add TM's which will be used in the project
                this.AddMasterTM(createdProject, settings.PathToMasterTM);

                ////Adapt some project settings
                this.AdaptProjectSettings(createdProject);

                ////Add termbase
                this.AddTermbase(createdProject, settings.TermbasePath, settings.SourceLanguage, settings.TargetLanguage);

                ////Start the tasks
                this.RunTasks(createdProject, settings);

                ////Create project package to be sent to translator
                this.CreateProjectPackage(createdProject, new Language(settings.TargetLanguage), settings.PackageOutputPath);

                ////missing - getting translated files.
                createdProject.Save();

                result = createdProject;
                ////project is saved but not listed in Studio, this is by design.
            }
            catch (Exception ex)
            {
                result = null;
                throw new Exception("Problem during project creation", ex);
            }

            return(result);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="createdProject">A project you have created</param>
        /// <param name="settings">Settings containing initial input parameters</param>
        private void RunTasks(FileBasedProject createdProject, LocalProjectSettings settings)
        {
            Language targetLanguage = new Language(settings.TargetLanguage);
            List <TaskStatusEventArgs> taskStatusEventArgsList = new List <TaskStatusEventArgs>();
            List <MessageEventArgs>    messageEventArgsList    = new List <MessageEventArgs>();

            // set up  perfect match
            ProjectFile[] projectFiles = createdProject.GetSourceLanguageFiles();
            createdProject.AddBilingualReferenceFiles(GetBilingualFileMappings(new Language[] { targetLanguage }, projectFiles, settings.PreviousVersionPath));

            // scan files
            AutomaticTask automaticTask = this.RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.Scan,
                taskStatusEventArgsList,
                messageEventArgsList);

            this.CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // convert files
            automaticTask = this.RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.ConvertToTranslatableFormat,
                taskStatusEventArgsList,
                messageEventArgsList);

            this.CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // copy files to target languages
            automaticTask = this.RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.CopyToTargetLanguages,
                taskStatusEventArgsList,
                messageEventArgsList);

            this.CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // from now on use target language files
            projectFiles = createdProject.GetTargetLanguageFiles(targetLanguage);

            // Apply Perfect Match
            automaticTask = this.RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.PerfectMatch,
                taskStatusEventArgsList,
                messageEventArgsList);

            this.CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // analyze files
            automaticTask = this.RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.AnalyzeFiles,
                taskStatusEventArgsList,
                messageEventArgsList);

            this.CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // translate files
            automaticTask = this.RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.PreTranslateFiles,
                taskStatusEventArgsList,
                messageEventArgsList);

            this.CheckEvents(taskStatusEventArgsList, messageEventArgsList);

            // populate project TM
            automaticTask = this.RunTasks(
                createdProject,
                projectFiles,
                AutomaticTaskTemplateIds.PopulateProjectTranslationMemories,
                taskStatusEventArgsList,
                messageEventArgsList);

            this.CheckEvents(taskStatusEventArgsList, messageEventArgsList);
        }