Ejemplo n.º 1
0
        public void Activate(string processId, SearchSettingsWrapperElastic settings, CancellationToken token)
        {
            try
            {
                var service = serviceQuery.Get(settings.ServiceId);
                service.Status = (int)ServiceStatusEnum.Busy;
                serviceQuery.Update(service.Id, service);

                var globalStoreSearch = new GlobalStoreSearch {
                    SearchSettingsWrapper = settings
                };

                GlobalStore.ActivatedSearches.Add(settings.ServiceId, globalStoreSearch);

                processHandler.Finished(processId, string.Format(ServiceResources.SuccessfullyActivated_0_Service_1, ServiceTypeEnum.Search, service.Name));
                service.Status = (int)ServiceStatusEnum.Active;
                serviceQuery.Update(service.Id, service);
            }
            catch (Exception ex)
            {
                var service = serviceQuery.Get(settings.ServiceId);
                service.Status = (int)ServiceStatusEnum.Prepared;
                serviceQuery.Update(service.Id, service);
                if (GlobalStore.ActivatedSearches.IsExist(settings.ServiceId))
                {
                    GlobalStore.ActivatedSearches.Remove(settings.ServiceId);
                }
                if (ex.InnerException != null && ex.InnerException is OperationCanceledException)
                {
                    processHandler.Cancelled(processId);
                }
                else
                {
                    processHandler.Interrupted(processId, ex);
                }
                GC.Collect();
            }
        }
 public void Add(string id, GlobalStoreSearch classifier)
 {
     SearchDictionary.Add(id, classifier);
 }