private void WarmUpCodeGeneratorDependencyManager() { if (null != OnSolutionOpeningTask) { return; } lock (_lock) { if (null != OnSolutionOpeningTask) { return; } OnSolutionOpeningTask = _taskFactory.StartNew( () => { using (new LoggingActivity("HandleSolutionOpening")) try { _visualStudioCodeGenerator.GenerateCode( _codeGeneratorContextFactory .GenerateContext(s => s.GetValidPMixinFiles())) .MapParallel(_responseFileWriter.WriteCodeGeneratorResponse); } catch (Exception exc) { _log.Error("Exception in WarmUpCodeGeneratorDependencyManager", exc); } }); } }
public void Handle(CheckIntervalElapsedMessage message) { if (Interlocked.CompareExchange(ref _ticket, 1, 0) == 0) { _taskFactory.StartNew(() => { try { if (!_pluginMetadata.IsSyncronizableProfile) { return; } foreach (var account in _collection) { try { if (account.Profiles.Empty()) { continue; } var queueName = _transport.GetQueueName(account.Name.Value); var queueIsNotOverloaded = MsmqHelper.QueueIsNotOverloaded(queueName, "Failed to count messages in queue for account '{0}'" .Fmt(account.Name.Value), 10); if (!queueIsNotOverloaded) { continue; } foreach (var profile in account.Profiles) { var lastSyncDate = profile.Get <LastSyncDate>().FirstOrDefault(); if (IsTimeToSyncronize(profile, lastSyncDate) && profile.Initialized) { _bus.SetOut(profile.ConvertToPluginProfile().Name); _bus.SetOut(account.Name); _bus.SendLocal(lastSyncDate != null ? new TickMessage(lastSyncDate.Value) : new TickMessage(null)); ObjectFactory.GetInstance <ILogManager>().GetLogger(GetType()).Info("TickMesage sent"); profile.Get <LastSyncDate>().ReplaceWith(new LastSyncDate(CurrentDate.Value)); } } } catch (Exception e) { LogManager.GetLogger(GetType()) .Error(string.Format("Failed to send tick message for account '{0}'", account.Name.Value), e); } } } finally { Interlocked.Decrement(ref _ticket); } }); } }
private void GenerateCode(FilePath classFullPath, string eventName) { _taskFactory.StartNew(() => { pMixinsOnSolutionOpenCodeGenerator.OnSolutionOpeningTask.Wait(); using (new LoggingActivity("GenerateCode - " + eventName + " -- " + classFullPath)) try { //Generate code for the file saved var currentFileContext = _codeGeneratorContextFactory.GenerateContext( s => s.GetValidPMixinFiles() .Where(f => f.FileName.Equals(classFullPath))) .ToArray(); if (currentFileContext.Length == 0) { _log.InfoFormat("No code will be genereated for [{0}]", classFullPath); _responseFileWriter.ClearCodeBehindForSourceFile(classFullPath); } else { _visualStudioCodeGenerator .GenerateCode(currentFileContext) .Map(_responseFileWriter.WriteCodeGeneratorResponse); } //Generate code for dependencies var filesToUpdate = _codeGeneratorDependencyManager.GetFilesThatDependOn(classFullPath); if (_log.IsDebugEnabled) { _log.DebugFormat("Will update [{0}]", string.Join(Environment.NewLine, filesToUpdate.Select(x => x.FileName))); } _visualStudioCodeGenerator .GenerateCode( _codeGeneratorContextFactory.GenerateContext(filesToUpdate)) .MapParallel(_responseFileWriter.WriteCodeGeneratorResponse); } catch (Exception exc) { _log.Error("Exception in HandleProjectItemSaved", exc); } }); }