Exemplo n.º 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;
            }
        }
Exemplo n.º 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;
 }
Exemplo n.º 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;
        }
Exemplo n.º 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;
        }
Exemplo n.º 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);
        }
Exemplo n.º 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;
            }
        }
Exemplo n.º 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());
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
                    }
                }
            }
        }
Exemplo n.º 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);
			}
		}
Exemplo n.º 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));
     }
 }
Exemplo n.º 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();
		}
Exemplo n.º 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>();
        }
Exemplo n.º 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]];
			}
		}
Exemplo n.º 18
0
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is GatherWordListConfig && WordListFileName == ((GatherWordListConfig)taskConfiguration).WordListFileName);
 }
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is DictionaryBrowseAndEditConfiguration);
 }
Exemplo n.º 20
0
 public ArchiveTasksCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Exemplo n.º 21
0
 public GatherBySemDomTaskConfigControl(ITaskConfiguration config)
     : base(config, true)
 {
     InitializeComponent();
     _showMeaningField.Checked = Configuration.ShowMeaningField;
 }
Exemplo n.º 22
0
 public void Execute(ITaskConfiguration configuration)
 {
     Execute((MessageTaskConfiguration)configuration);
 }
Exemplo n.º 23
0
 public AddPriorityCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Exemplo n.º 24
0
 public ITaskExecution Create(string taskName, ITaskConfiguration configuration = null)
 {
     return(Create(taskName, DateTime.Now, configuration));
 }
Exemplo n.º 25
0
 public DeprioritizeCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Exemplo n.º 26
0
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is NotesBrowserConfig);
 }
Exemplo n.º 27
0
		public bool AreEquivalent(ITaskConfiguration taskConfiguration)
		{
			return taskConfiguration is GatherBySemanticDomainConfig;
		}
Exemplo n.º 28
0
 public bool AreEquivalent(ITaskConfiguration taskConfiguration)
 {
     return(taskConfiguration is AddPicturesConfig);
 }
Exemplo n.º 29
0
 public TaskExecution(ITask task, ITaskConfiguration configuration = null) : this(task, DateTime.Now, configuration)
 {
 }
Exemplo n.º 30
0
 public bool DoShowTask(ITaskConfiguration task)
 {
     return(task.Label != "Dashboard");
 }
Exemplo n.º 31
0
 public DeleteTaskCommandHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }
Exemplo n.º 32
0
 public void Execute(ITaskConfiguration configuration)
 {
 }
Exemplo n.º 33
0
 public TaskQueryHandler(ITaskFile taskFile, ITaskConfiguration config)
 {
     _taskFile = taskFile;
     _config   = config;
 }