Пример #1
0
        protected WordGatheringTaskBase(ITaskConfiguration config,
                                        LexEntryRepository lexEntryRepository,
                                        ViewTemplate viewTemplate,
                                        TaskMemoryRepository taskMemoryRepository)
            : base(config,
                   lexEntryRepository, taskMemoryRepository)
        {
            if (viewTemplate == null)
            {
                throw new ArgumentNullException("viewTemplate");
            }

            _viewTemplate             = viewTemplate;
            _lexicalFormWritingSystem =
                viewTemplate.GetDefaultWritingSystemForField(Field.FieldNames.EntryLexicalForm.ToString());

            var glossField = _viewTemplate.GetField(LexSense.WellKnownProperties.Gloss);

            if (glossField == null)
            {
                _glossMeaningField = false;
            }
            else
            {
                _glossMeaningField = glossField.IsMeaningField;
            }
        }
Пример #2
0
        public bool AreEquivalent(ITaskConfiguration taskConfiguration)
        {
            var task = taskConfiguration as MissingInfoConfiguration;

            if (task == null)
            {
                return(false);
            }

            if (task.TaskName != TaskName)
            {
                return(false);
            }

            if (task.MissingInfoFieldName != MissingInfoFieldName)
            {
                return(false);
            }

            if (task.Label != Label)
            {
                return(false);
            }

            return(true);
        }
 public DefaultTaskConfigurationControl(ITaskConfiguration config, bool haveSetupControls)
 {
     _config = config;
     InitializeComponent();
     _description.Text   = config.Description;
     _setupLabel.Visible = haveSetupControls;
 }
Пример #4
0
        public TaskExecution(ITask task, DateTime startTime, ITaskConfiguration configuration = null)
        {
            _task = task;
            _logs = new List <ILog>();

            TaskExecutionId = Guid.NewGuid();
            StartTime       = startTime;
            Configuration   = configuration;
            Status          = TaskStatus.Initial;
        }
Пример #5
0
        public ITaskExecution Create(string taskName, DateTime dateTime, ITaskConfiguration configuration = null)
        {
            var task = _taskRegistry.Tasks.FirstOrDefault(x => x.Key == taskName);

            if (task.Key != null)
            {
                return(new TaskExecution((ITask)Activator.CreateInstance(task.Value), dateTime, configuration));
            }

            return(null);
        }
        /// <summary>
        /// Image Dequeue Setup
        /// </summary>
        /// <param name="config"></param>
        public ImageDequeueSetup(ITaskConfiguration config)
        {
            if (null == config)
            {
                throw new ArgumentNullException("config");
            }

            this.Images           = config.Versions.Images;
            this.Name             = config.StorageElements.Queue;
            this.Priority         = config.Priority;
            this.connectionString = config.ConnectionString;
        }
Пример #7
0
        public TaskBase(ITaskConfiguration config,
                        LexEntryRepository lexEntryRepository,
                        TaskMemoryRepository taskMemoryRepository)
        {
            if (config.Label == null)
            {
                throw new ArgumentNullException("label");
            }
            if (config.LongLabel == null)
            {
                throw new ArgumentNullException("longLabel");
            }
            if (config.Description == null)
            {
                throw new ArgumentNullException("description");
            }
            if (config.RemainingCountText == null)
            {
                throw new ArgumentNullException("remainingCountText");
            }
            if (config.ReferenceCountText == null)
            {
                throw new ArgumentNullException("referenceCountText");
            }
            if (lexEntryRepository == null)
            {
                throw new ArgumentNullException("lexEntryRepository");
            }
            _lexEntryRepository = lexEntryRepository;
            _taskMemory         = taskMemoryRepository.FindOrCreateSettingsByTaskId(config.TaskName);

            // convert any amount of whitespace to one space
            Regex rgx = new Regex("\\s+");

            _label              = rgx.Replace(config.Label.Trim(), " ");
            _longLabel          = rgx.Replace(config.LongLabel.Trim(), " ");
            _description        = rgx.Replace(config.Description.Trim(), " ");
            _remainingCountText = rgx.Replace(config.RemainingCountText.Trim(), " ");
            _referenceCountText = rgx.Replace(config.ReferenceCountText.Trim(), " ");
            _isPinned           = config.IsPinned;

//            _cachePath = WeSayWordsProject.Project.PathToCache;
//            _cacheFilePath = Path.Combine(_cachePath, MakeSafeName(Label + ".cache"));
//
//            ReadCacheFile();

            _remainingCount = _taskMemory.Get("RemainingCount", CountNotComputed);
            _referenceCount = _taskMemory.Get("ReferenceCount", CountNotComputed);
        }
Пример #8
0
        public DictionaryBrowseEditTaskConfigControl(ITaskConfiguration config)
            : base(config, true)
        {
            InitializeComponent();
            switch (Configuration.MeaningField)
            {
            case "definition":
                _definition.Checked = true;
                break;

            case "gloss":
                _gloss.Checked = true;
                break;
            }
        }
Пример #9
0
        protected WordGatheringTaskBase(ITaskConfiguration config,
                                        LexEntryRepository lexEntryRepository,
                                        ViewTemplate viewTemplate,
                                        TaskMemoryRepository taskMemoryRepository)
            : base(config,
                   lexEntryRepository, taskMemoryRepository)
        {
            if (viewTemplate == null)
            {
                throw new ArgumentNullException("viewTemplate");
            }

            _viewTemplate             = viewTemplate;
            _lexicalFormWritingSystem =
                viewTemplate.GetDefaultWritingSystemForField(Field.FieldNames.EntryLexicalForm.ToString());
        }
Пример #10
0
        static public Control Create(IComponentContext diContainer, ITaskConfiguration config)
        {
            //nb: I tried but didn't figure out how to make autofac select the correct
            //control based on the type of the configuration:
            //            if(diContainer.TryResolve<ITaskConfigurationControl>(out x, new TypedParameter(config.GetType(), config)))


            if (config.GetType() == typeof(MissingInfoConfiguration))
            {
                return(diContainer.Resolve <MissingInfoTaskConfigControl>(new TypedParameter(config.GetType(), config)));
            }
            if (config.TaskName == "GatherWordsBySemanticDomains")
            {
                return(new GatherBySemDomTaskConfigControl(config));
            }
            return(new DefaultTaskConfigurationControl(config, false));
        }
Пример #11
0
        public bool AreEquivalent(ITaskConfiguration taskConfiguration)
        {
            var task = taskConfiguration as MissingInfoConfiguration;

            if (task == null)
            {
                return(false);
            }

            if (task.TaskName != TaskName)
            {
                return(false);
            }

            if (task.MissingInfoFieldName != MissingInfoFieldName)
            {
                // The field of "Add Meanings" will be definition or gloss depending what the meaning field is
                // the default config has it as definition so must be considered as equivalent to gloss
                if (task.MissingInfoFieldName == LexSense.WellKnownProperties.Definition)
                {
                    if (MissingInfoFieldName != LexSense.WellKnownProperties.Gloss)
                    {
                        return(false);
                    }
                }
                else if (task.MissingInfoFieldName == LexSense.WellKnownProperties.Gloss)
                {
                    if (MissingInfoFieldName != LexSense.WellKnownProperties.Definition)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }

            if (task.Label != Label)
            {
                return(false);
            }

            return(true);
        }
Пример #12
0
        private void GetTasks(string xml, IComponentContext context, List <ITaskConfiguration> configs)
        {
            XPathDocument     doc                  = new XPathDocument(new StringReader(xml));
            XPathNavigator    navigator            = doc.CreateNavigator();
            XPathNodeIterator taskListNodeIterator = navigator.Select("configuration/tasks/task");

            foreach (XPathNavigator taskNode in taskListNodeIterator)
            {
                ITaskConfiguration configuration = CreateTaskConfiguration(context, _taskTypes, taskNode);
                if (configuration != null)
                {
                    if (!configs.Exists(t => t.AreEquivalent(configuration)))
                    {
                        configs.Add(configuration);
                    }
                }
            }
        }
Пример #13
0
		private static ITask CreateTask(IContext context, ITaskConfiguration config)
		{
			try
			{
				//make the task itself, handing it this configuration object.
				//its other constructor arguments come "automatically" out of the context
				return context.Resolve<ITask>(config.TaskName, new Parameter[] { new NamedParameter("config", config) });
			}
			catch (Exception e)
			{
				string message = e.Message;
				while (e.InnerException != null) //the user will see this, so lets dive down to the actual cause
				{
					e = e.InnerException;
					message = e.Message;
				}
				return new FailedLoadTask(config.TaskName, "", message);
			}
		}
Пример #14
0
 private static ITask CreateTask(IComponentContext context, ITaskConfiguration config)
 {
     try
     {
         //make the task itself, handing it this configuration object.
         //its other constructor arguments come "automatically" out of the context
         return(context.ResolveNamed <ITask>(config.TaskName, new Parameter[] { new NamedParameter("config", config) }));
     }
     catch (Exception e)
     {
         string message = e.Message;
         while (e.InnerException != null)                 //the user will see this, so lets dive down to the actual cause
         {
             e       = e.InnerException;
             message = e.Message;
         }
         return(new FailedLoadTask(config.TaskName, "", message));
     }
 }
Пример #15
0
		public TaskBase(ITaskConfiguration config,
						LexEntryRepository lexEntryRepository)
		{
			if (config.Label == null)
			{
				throw new ArgumentNullException("label");
			}
			if (config.LongLabel == null)
			{
				throw new ArgumentNullException("longLabel");
			}
			if (config.Description == null)
			{
				throw new ArgumentNullException("description");
			}
			if (config.RemainingCountText == null)
			{
				throw new ArgumentNullException("remainingCountText");
			}
			if (config.ReferenceCountText == null)
			{
				throw new ArgumentNullException("referenceCountText");
			}
			if (lexEntryRepository == null)
			{
				throw new ArgumentNullException("lexEntryRepository");
			}
			_lexEntryRepository = lexEntryRepository;
			// convert any amount of whitespace to one space
			Regex rgx = new Regex("\\s+");
			_label = rgx.Replace (config.Label.Trim(), " ");
			_longLabel = rgx.Replace (config.LongLabel.Trim(), " ");
			_description = rgx.Replace (config.Description.Trim(), " ");
			_remainingCountText = rgx.Replace (config.RemainingCountText.Trim(), " ");
			_referenceCountText = rgx.Replace (config.ReferenceCountText.Trim(), " ");
			_isPinned = config.IsPinned;

			_cachePath = WeSayWordsProject.Project.PathToCache;
			_cacheFilePath = Path.Combine(_cachePath, MakeSafeName(Label + ".cache"));

			ReadCacheFile();
		}
Пример #16
0
        private void Configure(string configFile)
        {
            if (configFile != null && !File.Exists(configFile))
            {
                ColorConsole.WriteLine($"{configFile} does not exist.".Red());
                ColorConsole.WriteLine("Using default configuration.".Red());
                configFile = null;
            }

            if (configFile == null)
            {
                configFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".todo.json");
            }

            IServiceCollection serviceCollection = new ServiceCollection();

            serviceCollection
            .AddApplication()
            .AddInfrastructure(configFile);

            Services      = serviceCollection.BuildServiceProvider();
            Mediator      = Services.GetService <IMediator>();
            Configuration = Services.GetService <ITaskConfiguration>();
        }
Пример #17
0
		protected WordGatheringTaskBase(ITaskConfiguration config,
										LexEntryRepository lexEntryRepository,
										ViewTemplate viewTemplate)
				: base( config,
						lexEntryRepository)
		{
			if (viewTemplate == null)
			{
				throw new ArgumentNullException("viewTemplate");
			}

			_viewTemplate = viewTemplate;
			Field lexicalFormField =
					viewTemplate.GetField(Field.FieldNames.EntryLexicalForm.ToString());
			WritingSystemCollection writingSystems = BasilProject.Project.WritingSystems;
			if (lexicalFormField == null || lexicalFormField.WritingSystemIds.Count < 1)
			{
				_lexicalFormWritingSystem = writingSystems.UnknownVernacularWritingSystem;
			}
			else
			{
				_lexicalFormWritingSystem = writingSystems[lexicalFormField.WritingSystemIds[0]];
			}
		}
Пример #18
0
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is GatherWordListConfig && WordListFileName == ((GatherWordListConfig)taskConfiguration).WordListFileName);
 }
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is DictionaryBrowseAndEditConfiguration);
 }
Пример #20
0
 public ArchiveTasksCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Пример #21
0
 public GatherBySemDomTaskConfigControl(ITaskConfiguration config)
     : base(config, true)
 {
     InitializeComponent();
     _showMeaningField.Checked = Configuration.ShowMeaningField;
 }
Пример #22
0
 public void Execute(ITaskConfiguration configuration)
 {
     Execute((MessageTaskConfiguration)configuration);
 }
Пример #23
0
 public AddPriorityCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Пример #24
0
 public ITaskExecution Create(string taskName, ITaskConfiguration configuration = null)
 {
     return(Create(taskName, DateTime.Now, configuration));
 }
Пример #25
0
 public DeprioritizeCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Пример #26
0
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is NotesBrowserConfig);
 }
Пример #27
0
		public bool AreEquivalent(ITaskConfiguration taskConfiguration)
		{
			return taskConfiguration is GatherBySemanticDomainConfig;
		}
Пример #28
0
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is AddPicturesConfig);
 }
Пример #29
0
 public TaskExecution(ITask task, ITaskConfiguration configuration = null) : this(task, DateTime.Now, configuration)
 {
 }
Пример #30
0
 public bool DoShowTask(ITaskConfiguration task)
 {
     return(task.Label != "Dashboard");
 }
Пример #31
0
 public DeleteTaskCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Пример #32
0
 public void Execute(ITaskConfiguration configuration)
 {
 }
Пример #33
0
 public TaskQueryHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }