public MetadataService(IMetadataProviderService defaultMetadataService) { #if DEBUG if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(Constants.ENVIRONMENT_ATTACHDEBUGGER))) { System.Diagnostics.Debugger.Launch(); } #endif if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable(Constants.ENVIRONMENT_CACHEMEATADATA))) { Console.WriteLine(Constants.CONSOLE_METADATA); var manager = new RecyclableMemoryStreamManager(); using (var stream = manager.GetStream()) { using (var writer = new StreamWriter(stream, Encoding.UTF8, 1024, true)) { string line = Console.ReadLine(); while (line != Constants.CONSOLE_ENDSTREAM && line != null) { writer.WriteLine(line); line = Console.ReadLine(); } } stream.Position = 0; var serializer = new DataContractSerializer(typeof(OrganizationMetadata)); using (var xmlreader = XmlReader.Create(stream, new XmlReaderSettings())) { cachedMetadata = (OrganizationMetadata)serializer.ReadObject(xmlreader); } } } this.defaultMetadataService = defaultMetadataService; }
public override void Queue() { IContactSource source = ServiceManager.SourceManager.ActiveSource as IContactSource; if (!source.IsDownloadingAllowed) { return; } DBusActivity activity = Contact.DispatchManager.Get <DBusActivity> (Contact, MetadataProviderService.BusName); if (activity != null) { IMetadataProviderService service = activity.GetDBusObject <IMetadataProviderService> (MetadataProviderService.BusName, MetadataProviderService.ObjectPath); if (service != null) { base.Queue(); ThreadAssist.Spawn(delegate { lock (sync) { try { service.DownloadFile(long.Parse(Key.Name), "audio/mpeg"); } catch (Exception e) { Log.Warning(e); } } }); } } }
public MetadataProviderService(IMetadataProviderService defaultService, IDictionary <string, string> paramters) { MakeReadonlyFieldsEditable = ConfigHelper.GetAppSettingOrDefault("MakeReadonlyFieldsEditable", false); Metadata = defaultService.LoadMetadata(); var prop = typeof(AttributeMetadata).GetProperty("IsValidForCreate", BindingFlags.Public | BindingFlags.Instance); foreach (var att in Metadata.Entities.SelectMany(entity => entity.Attributes)) { switch (att.LogicalName) { case "modifiedonbehalfby": case "createdonbehalfby": case "overriddencreatedon": prop.SetValue(att, true); break; case "createdby": case "createdon": case "modifiedby": case "modifiedon": case "owningbusinessunit": case "owningteam": case "owninguser": if (MakeReadonlyFieldsEditable) { prop.SetValue(att, true); } break; } } }
public MetadataProviderService(IMetadataProviderService defaultService, IDictionary<string, string> paramters) { MakeReadonlyFieldsEditable = ConfigHelper.GetAppSettingOrDefault("MakeReadonlyFieldsEditable", false); Metadata = defaultService.LoadMetadata(); var prop = typeof(AttributeMetadata).GetProperty("IsValidForCreate", BindingFlags.Public | BindingFlags.Instance); foreach (var att in Metadata.Entities.SelectMany(entity => entity.Attributes)) { switch (att.LogicalName) { case "modifiedonbehalfby": case "createdonbehalfby": case "overriddencreatedon": prop.SetValue(att, true); break; case "createdby": case "createdon": case "modifiedby": case "modifiedon": case "owningbusinessunit": case "owningteam": case "owninguser": if (MakeReadonlyFieldsEditable) { prop.SetValue(att, true); } break; } } }
internal ReopenRequestedNotificationBuilder(IMapper mapper, IApplicationUriHelper uriHelper, ICostStageRevisionService costStageRevisionService, IMetadataProviderService metadataProviderService, AppSettings appSettings, EFContext efContext, IRegionsService regionsService) : base(mapper, uriHelper, costStageRevisionService, metadataProviderService, appSettings, efContext, regionsService) { }
public MetadataProvider(IMetadataProviderService defaultService, IDictionary <string, string> parameters) { DefaultService = defaultService; OrganizationService = GetOrganizationService(parameters); SerializeMetadata = true; ReadSerializedMetadata = true; FilePath = "metadata.json"; }
private void LoadPlaylists() { if (CurrentActivity == null) { return; } else if (CurrentActivity.State != ActivityState.Connected) { Hyena.Log.Debug(String.Format("activity state {0} is invalid.", CurrentActivity.State)); return; } else if (CurrentState != State.LoadedMetadata) { Hyena.Log.Debug(String.Format("state {0} is invalid.", CurrentState)); return; } try { IMetadataProviderService service = CurrentActivity.GetDBusObject <IMetadataProviderService> (MetadataProviderService.BusName, MetadataProviderService.ObjectPath); int [] playlist_ids = service.GetPlaylistIds(LibraryType.Music); download_monitor.Reset(); if (playlist_ids.Length == 0) { CurrentState = State.Loaded; } else { foreach (int id in playlist_ids) { string playlist_path = service.CreatePlaylistProvider(id).ToString(); IPlaylistProvider playlist_provider = CurrentActivity.GetDBusObject <IPlaylistProvider> (PlaylistProvider.BusName, playlist_path); LibraryDownload download = new LibraryDownload(); download_monitor.Add(playlist_path, download); //download_monitor.AssociateObject (playlist_path, new ContactPlaylistSource (playlist_provider.GetName (), this)); download.ProcessIncomingPayloads(delegate(object sender, object [] o) { OnPlaylistTracksDownloaded(new DownloadedTracksEventArgs(sender as LibraryDownload, o, playlist_provider.GetName())); }); playlist_provider.ChunkReady += OnPlaylistChunkReady; playlist_provider.GetChunks(chunk_length); } download_monitor.Start(); } } catch (Exception e) { Hyena.Log.Warning(e); ResetState(); OnError(new TubeManagerErrorEventArgs(ErrorReason.ErrorDuringPlaylistLoad)); } }
internal ReminderPendingTechnicalNotificationBuilder(IMapper mapper, IApplicationUriHelper uriHelper, ICostStageRevisionService costStageRevisionService, IMetadataProviderService metadataProviderService, IApprovalService approvalService, AppSettings appSettings, EFContext efContext, IRegionsService regionsService) : base(mapper, uriHelper, costStageRevisionService, metadataProviderService, appSettings, efContext, regionsService) { _approvalService = approvalService; }
public void TestInitialise() { metadataProviderService = Substitute.For <IMetadataProviderService>(); organizationMetadata = Substitute.For <IOrganizationMetadata>(); metadataProviderService.LoadMetadata().Returns(organizationMetadata); serviceProvider.GetService(typeof(IMetadataProviderService)).Returns(metadataProviderService); filterService.GenerateAttribute(Arg.Any <AttributeMetadata>(), serviceProvider).Returns(true); parameters = new Dictionary <string, string> { }; sut = new CodeFilteringService(filterService, parameters); }
// ReSharper disable once UnusedParameter.Local public BaseMetadataProviderService(IMetadataProviderService defaultService, IDictionary <string, string> parameters) { if (ConfigHelper.GetAppSettingOrDefault("WaitForAttachedDebugger", false)) { while (!Debugger.IsAttached) { Console.WriteLine("[**** Waiting For Debugger ****]"); Thread.Sleep(3000); } } DefaultService = defaultService; FilePath = ConfigHelper.GetAppSettingOrDefault("SerializedMetadataFilePath", "metadata.xml"); }
public void CustomizeCodeDom(CodeCompileUnit codeCompileUnit, IServiceProvider services) { if (codeCompileUnit == null) { throw new ArgumentNullException(nameof(codeCompileUnit)); } if (services == null) { throw new ArgumentNullException(nameof(services)); } Console.WriteLine(string.Empty); Console.WriteLine("Generating code is in progress."); ReferencedOptionSetNames = new List <string>(); ICodeWriterFilterService codeWriterFilterService = (ICodeWriterFilterService)services.GetService(typeof(ICodeWriterFilterService)); IMetadataProviderService metadataProviderService = (IMetadataProviderService)services.GetService(typeof(IMetadataProviderService)); IOrganizationMetadata organizationMetadata = metadataProviderService.LoadMetadata(); // ServiceHelper.IntersectionEntityList = organizationMetadata.Entities.Where(x => x.IsIntersect == true).ToList(); foreach (CodeNamespace codeNamespace in codeCompileUnit.Namespaces) { foreach (EntityInfo entityInfo in ServiceHelper.EntityList) { EntityMetadata entityMetadata = entityInfo.EntityMetadata; CodeTypeDeclaration codeTypeDeclaration = codeNamespace .Types .OfType <CodeTypeDeclaration>() .FirstOrDefault(codeType => codeType.Name.ToUpperInvariant() == entityMetadata.SchemaName.ToUpperInvariant()); GenerateMultiSelectOptionSets(codeNamespace, codeTypeDeclaration, entityMetadata); GenerateOptionSets(codeNamespace, codeTypeDeclaration, entityMetadata); GenerateSetterForReadOnlyFields(codeTypeDeclaration, entityMetadata); } } ExcludeNonReferencedGlobalOptionSets(codeCompileUnit, organizationMetadata); GenerateFieldStructures(codeCompileUnit); GenerateCodeFiles(codeCompileUnit); CleanupNamespaces(codeCompileUnit); Console.WriteLine("Generating code completed successfully."); }
internal RecalledNotificationBuilder(IMapper mapper, IApplicationUriHelper uriHelper, ICostStageRevisionService costStageRevisionService, IApprovalService approvalService, ICostFormService costFormService, ICustomObjectDataService customObjectDataService, IMetadataProviderService metadataProviderService, AppSettings appSettings, EFContext efContext, IRegionsService regionsService) : base(mapper, uriHelper, costStageRevisionService, metadataProviderService, appSettings, efContext, regionsService) { _costStageRevisionService = costStageRevisionService; _approvalService = approvalService; _costFormService = costFormService; _customObjectDataService = customObjectDataService; }
internal CodeGenerationServiceProvider( ITypeMappingService typeMappingService , ICodeGenerationService codeGenerationService , ICodeWriterFilterService codeFilterService , IMetadataProviderService metadataProviderService , INamingService namingService ) { this.TypeMappingService = typeMappingService; this.CodeGenerationService = codeGenerationService; this.CodeWriterFilterService = codeFilterService; this.MetadataProviderService = metadataProviderService; this.NamingService = namingService; }
protected NotificationBuilderBase(IMapper mapper, IApplicationUriHelper uriHelper, ICostStageRevisionService costStageRevisionService, IMetadataProviderService metadataProviderService, AppSettings appSettings, EFContext efContext, IRegionsService regionsService) { Mapper = mapper; _uriHelper = uriHelper; CostStageRevisionService = costStageRevisionService; MetadataProviderService = metadataProviderService; AppSettings = appSettings; EFContext = efContext; RegionsService = regionsService; }
public void TestInitialise() { metadataProviderService = Substitute.For <IMetadataProviderService>(); organizationMetadata = Substitute.For <IOrganizationMetadata>(); metadataProviderService.LoadMetadata().Returns(organizationMetadata); serviceProvider.GetService(typeof(IMetadataProviderService)).Returns(metadataProviderService); namingService = Substitute.For <INamingService>(); parameters = new Dictionary <string, string> { { "UseDisplayNames", true.ToString() } }; testMetadata = new TestMetadata(filterService); organizationMetadata.Entities.Returns(testMetadata.ToArray()); sut = new CodeNamingService(namingService, parameters); }
public EmailNotificationBuilder(IMapper mapper, IApplicationUriHelper uriHelper, ICostStageRevisionService costStageRevisionService, IApprovalService approvalService, IRegionsService regionsService, IOptions <AppSettings> appSettings, ICostFormService costFormService, ICustomObjectDataService customObjectDataService, IPgPaymentService pgPaymentService, ICostStageService costStageService, IMetadataProviderService metadataProviderService, EFContext efContext) { _mapper = mapper; _uriHelper = uriHelper; _costStageRevisionService = costStageRevisionService; _approvalService = approvalService; _regionsService = regionsService; _costFormService = costFormService; _customObjectDataService = customObjectDataService; _pgPaymentService = pgPaymentService; _costStageService = costStageService; _metadataProviderService = metadataProviderService; _efContext = efContext; _appSettings = appSettings.Value; }
private void LoadData() { Hyena.Log.Debug("TubeManager.LoadData ()"); if (CurrentState >= State.LoadingMetadata) { return; } else if (CurrentActivity == null) { return; } else if (CurrentActivity.State != ActivityState.Connected) { Hyena.Log.Debug(String.Format("activity state {0} is invalid.", CurrentActivity.State)); return; } IMetadataProviderService service = CurrentActivity.GetDBusObject <IMetadataProviderService> (MetadataProviderService.BusName, MetadataProviderService.ObjectPath); if (service == null) { Hyena.Log.Debug("ContactSource.LoadData found service null"); return; } try { // call MetadataProviderService.PermissionGranted () asynchronously to prevent blocking the UI // when Telepathy tubes are slow if (CurrentState <= State.Waiting) { Hyena.Log.Debug("Setting to waiting state"); CurrentState = State.Waiting; permission_caller = new GetBoolPropertyCaller(service.PermissionGranted); permission_caller.BeginInvoke(new AsyncCallback(delegate(IAsyncResult result) { if (CurrentState != State.Waiting) { return; } GetBoolPropertyCaller caller = (GetBoolPropertyCaller)result.AsyncState; bool granted = caller.EndInvoke(result); if (granted) { CurrentState = State.PermissionGranted; } else { CurrentState = State.PermissionNotGranted; } LoadData(); }), permission_caller); } else if (CurrentState == State.PermissionGranted) { service.DownloadingAllowedChanged += delegate(bool allowed) { IsDownloadingAllowed = allowed; }; // determine if downloading is allowed asynchronously downloading_caller = new GetBoolPropertyCaller(service.DownloadsAllowed); downloading_caller.BeginInvoke(new AsyncCallback(delegate(IAsyncResult result) { GetBoolPropertyCaller caller = (GetBoolPropertyCaller)result.AsyncState; IsDownloadingAllowed = caller.EndInvoke(result); }), downloading_caller); // clean up any residual tracks download_monitor.Reset(); CurrentState = State.LoadingMetadata; string metadata_path = service.CreateMetadataProvider(LibraryType.Music).ToString(); IMetadataProvider library_provider = CurrentActivity.GetDBusObject <IMetadataProvider> (MetadataProvider.BusName, metadata_path); LibraryDownload download = new LibraryDownload(); download_monitor.Add(metadata_path, download); download.ProcessIncomingPayloads(delegate(object sender, object [] o) { OnTracksDownloaded(new DownloadedTracksEventArgs(sender as LibraryDownload, o)); }); library_provider.ChunkReady += OnLibraryChunkReady; library_provider.GetChunks(chunk_length); download_monitor.Start(); } else if (CurrentState == State.PermissionNotGranted) { CurrentState = State.Waiting; service.PermissionSet += OnPermissionSet; service.RequestPermission(); } } catch (Exception e) { Hyena.Log.Warning(e); ResetState(); OnError(new TubeManagerErrorEventArgs(ErrorReason.ErrorDuringLoad)); } }
internal SharedCustomizeCodeDomService(System.IO.StreamWriter writer, IMetadataProviderService meta) { this.writer = writer; this.meta = meta; }
public BaseMetadataProviderService(IMetadataProviderService defaultService, IDictionary <string, string> parameters) { DefaultService = defaultService; FilePath = ConfigHelper.GetAppSettingOrDefault("SerializedMetadataFilePath", "metadata.xml"); }
public MetadataProviderService(IMetadataProviderService defaultService, IDictionary <string, string> parameters) : base(defaultService, parameters) { MakeReadonlyFieldsEditable = ConfigHelper.GetAppSettingOrDefault("MakeReadonlyFieldsEditable", false); }