//public string[] ToCommonSpec(ServiceSpec spec, string dir) //{ // throw new NotImplementedException(); //} //public ServiceSpec FromCommonSpec(string spec, ServiceSpecType targetType) //{ // var generator = IdlGenerator.GetInstance(targetType); // Assembly asm = Assembly.LoadFrom(spec); // generator.Generate(asm); // ServiceSpec serviceSpec = new ServiceSpec(); // // FIXME // serviceSpec.SType = targetType; // serviceSpec.Directory = "."; // serviceSpec.MainSpecFile = ""; // serviceSpec.ReferencedSpecFiles = null; // return serviceSpec; //} public FlowErrorCode GenerateServiceClient( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { if (!spec.IsRdsnRpc) { throw new NotImplementedException(); } linkInfo = new LinkageInfo(); var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); if ( SystemHelper.RunProcess("php.exe", Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " + Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " binary layer3") != 0) { return(FlowErrorCode.ProcessStartFailed); } linkInfo.Sources.Add(Path.Combine(dir, "GProtoBinaryHelper.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".client.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs")); linkInfo.DynamicLibraries.Add(Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "lib", "Google.Protobuf.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.IO.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.runtime.dll")); return(FlowErrorCode.Success); }
public async Task RunAsync() { var skypeId = ConfigurationManager.AppSettings["Trouter_SkypeId"]; var password = ConfigurationManager.AppSettings["Trouter_Password"]; var applicationName = ConfigurationManager.AppSettings["Trouter_ApplicationName"]; var userAgent = ConfigurationManager.AppSettings["Trouter_UserAgent"]; var token = SkypeTokenClient.ConstructSkypeToken( skypeId: skypeId, password: password, useTestEnvironment: false, scope: string.Empty, applicationName: applicationName).Result; m_logger = new ConsoleLogger(); // Uncomment for debugging // m_logger.HttpRequestResponseNeedsToBeLogged = true; EventChannel = new TrouterBasedEventChannel(m_logger, token, userAgent); // Prepare platform var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, new Guid(QuickSamplesConfig.AAD_ClientId)); var platform = new ClientPlatform(platformSettings, m_logger); // Prepare endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId)); var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, EventChannel); var loggingContext = new LoggingContext(Guid.NewGuid()); await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); // Meeting configuration var meetingConfiguration = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + " test meeting"); // Schedule meeting var adhocMeeting = await applicationEndpoint.Application.CreateAdhocMeetingAsync(loggingContext, meetingConfiguration).ConfigureAwait(false); WriteToConsoleInColor("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); WriteToConsoleInColor("ad hoc meeting join url : " + adhocMeeting.JoinUrl); // Get all the events related to join meeting through Trouter's uri platformSettings.SetCustomizedCallbackurl(new Uri(EventChannel.CallbackUri)); // Start joining the meeting var invitation = await adhocMeeting.JoinAdhocMeeting(loggingContext, null).ConfigureAwait(false); // Wait for the join to complete await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false); invitation.RelatedConversation.HandleParticipantChange += Conversation_HandleParticipantChange; WriteToConsoleInColor("Showing roaster udpates for 5 minutes for meeting : " + adhocMeeting.JoinUrl); // Wait 5 minutes before exiting. // Since we have registered Conversation_HandleParticipantChange, we will continue to show participant changes in the // meeting for this duration. await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false); }
// TODO: return the correct path of compiler in Linux platform public static string GetCompilerPath(ServiceSpecType t, ClientPlatform p = ClientPlatform.Windows) { var path = ""; var prefix = Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/windows"); switch(t) { case ServiceSpecType.proto: path = Path.Combine(prefix, "protoc.exe"); break; case ServiceSpecType.thrift: path = Path.Combine(prefix, "thrift.exe"); break; case ServiceSpecType.bond_3_0: path = Path.Combine(prefix, "bondc.exe"); break; default: break; } if (File.Exists(path)) { return path; } Console.WriteLine($"Cannot find {t.ToString()} compiler at path: {path}!"); return ""; }
public TsVersion(string rawVersion, string platform, ClientPlatform platformType, ulong build) { Version = rawVersion; Platform = platform; PlatformType = platformType; Build = build; }
public VersionSign(string name, string platform, ClientPlatform platformType, string sign) { Name = name; Sign = sign; Platform = platformType; PlatformName = platform; }
// TODO: return the correct path of compiler in Linux platform public static string GetCompilerPath(ServiceSpecType t, ClientPlatform p = ClientPlatform.Windows) { var path = ""; var prefix = Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/windows"); switch (t) { case ServiceSpecType.proto: path = Path.Combine(prefix, "protoc.exe"); break; case ServiceSpecType.thrift: path = Path.Combine(prefix, "thrift.exe"); break; case ServiceSpecType.bond_3_0: path = Path.Combine(prefix, "bondc.exe"); break; default: break; } if (File.Exists(path)) { return(path); } Console.WriteLine($"Cannot find {t.ToString()} compiler at path: {path}!"); return(""); }
public static MockApplicationEndpointData CreateApplicationEndpoint() { Logger.RegisterLogger(new ConsoleLogger()); var platformSettings = new ClientPlatformSettings( DiscoverUri, AADClientId, AppTokenCertThumbprint, null, TestHelper.IsInternalApp); var restfulClient = new MockRestfulClient(); var restfulClientFactory = new Mock <IRestfulClientFactory>(); restfulClientFactory .Setup(foo => foo.GetRestfulClient(It.IsAny <OAuthTokenIdentifier>(), It.IsAny <ITokenProvider>())) .Returns(restfulClient); var platform = new ClientPlatform(platformSettings, new ConsoleLogger()); platform.RestfulClientFactory = restfulClientFactory.Object; var endpointSettings = new ApplicationEndpointSettings(ApplicationEndpointUri); var mockEventChannel = new Mock <IEventChannel>(); return(new MockApplicationEndpointData() { EventChannel = mockEventChannel, RestfulClientFactory = restfulClientFactory, RestfulClient = restfulClient, ClientPlatform = platform, ApplicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, mockEventChannel.Object) }); }
private object BuildParameter(string entityid, string application, ClientPlatform platform, IApplicationResponse response, string popupmode, ApplicationMetadata applicationMetadata) { object parameters; if (response is ActionRedirectResponse) { var actionResponse = (ActionRedirectResponse)response; var queryString = actionResponse.Parameters == null ? null : String.Join("&", actionResponse.Parameters.ToArray()); parameters = new { actionToRedirect = actionResponse.Action, controllerToRedirect = actionResponse.Controller, queryString = queryString, popupmode = popupmode ?? "none", message = response.SuccessMessage }; } else { parameters = new { application = application, popupmode = popupmode ?? "none", queryString = BuildQueryString(response, entityid, application, platform, applicationMetadata, popupmode), message = response.SuccessMessage }; } return(parameters); }
//public string[] ToCommonSpec(ServiceSpec spec, string dir) //{ // throw new NotImplementedException(); //} //public ServiceSpec FromCommonSpec(string spec, ServiceSpecType targetType) //{ // var generator = IdlGenerator.GetInstance(targetType); // Assembly asm = Assembly.LoadFrom(spec); // generator.Generate(asm); // ServiceSpec serviceSpec = new ServiceSpec(); // // FIXME // serviceSpec.SType = targetType; // serviceSpec.Directory = "."; // serviceSpec.MainSpecFile = ""; // serviceSpec.ReferencedSpecFiles = null; // return serviceSpec; //} public FlowErrorCode GenerateServiceClient( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { if (!spec.IsRdsnRpc) throw new NotImplementedException(); linkInfo = new LinkageInfo(); var appName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); if ( SystemHelper.RunProcess("php.exe", Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "bin/dsn.generate_code.php") + " " + Path.Combine(spec.Directory, spec.MainSpecFile) + " csharp " + dir + " binary layer3") != 0) return FlowErrorCode.ProcessStartFailed; linkInfo.Sources.Add(Path.Combine(dir, "GProtoBinaryHelper.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".client.cs")); linkInfo.Sources.Add(Path.Combine(dir, appName + ".code.definition.cs")); linkInfo.DynamicLibraries.Add(Path.Combine(Environment.GetEnvironmentVariable("DSN_ROOT"), "lib", "Google.Protobuf.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.IO.dll")); linkInfo.DynamicLibraries.Add(Path.Combine("System.runtime.dll")); return FlowErrorCode.Success; }
public async Task RunAsync(Uri callbackUri) { m_logger = new SampleAppLogger(); // Uncomment for debugging // m_logger.HttpRequestResponseNeedsToBeLogged = true; // Prepare platform var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, new Guid(QuickSamplesConfig.AAD_ClientId)); var platform = new ClientPlatform(platformSettings, m_logger); // You can hook up your own implementation of IEventChannel here IEventChannel eventChannel = WebEventChannel.WebEventChannel.Instance; // Prepare endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId)); var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel); var loggingContext = new LoggingContext(Guid.NewGuid()); await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); // Meeting configuration var meetingConfiguration = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + " test meeting"); // Schedule meeting var adhocMeeting = await applicationEndpoint.Application.CreateAdhocMeetingAsync(meetingConfiguration, loggingContext).ConfigureAwait(false); WriteToConsoleInColor("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); WriteToConsoleInColor("ad hoc meeting join url : " + adhocMeeting.JoinUrl); // Get all the events related to join meeting through our custom callback uri platformSettings.SetCustomizedCallbackurl(callbackUri); // Start joining the meeting ICommunication communication = applicationEndpoint.Application.Communication; if (!communication.CanJoinAdhocMeeting(adhocMeeting)) { throw new Exception("Cannot join adhoc meeting"); } var invitation = await communication.JoinAdhocMeetingAsync(adhocMeeting, null, loggingContext).ConfigureAwait(false); // Wait for the join to complete await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false); invitation.RelatedConversation.HandleParticipantChange += Conversation_HandleParticipantChange; WriteToConsoleInColor("Showing roaster udpates for 5 minutes for meeting : " + adhocMeeting.JoinUrl); // Wait 5 minutes before exiting. // Since we have registered Conversation_HandleParticipantChange, we will continue to show participant changes in the // meeting for this duration. await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false); await WebEventChannel.WebEventChannel.Instance.TryStopAsync().ConfigureAwait(false); }
public void Post(ClientPlatform platform, string notification_id) { if(platform != 0 && notification_id != null) { _notificationService.AddNewClient(platform, notification_id); } else { _logger.Warn("Notification registering called. Missing parameter"); } }
public IApplicationResponse Put([FromUri] string application, [FromUri] string id, [NotNull] JObject json, ClientPlatform platform, string currentSchemaKey = null, string nextSchemaKey = null, bool mockmaximo = false) { var schemaKey = _nextSchemaRouter.GetSchemaKeyFromString(application, currentSchemaKey, platform); ContextLookuper.FillContext(schemaKey); var nextschemaKey = _nextSchemaRouter.GetSchemaKeyFromString(application, nextSchemaKey, platform); return(DoExecute(application, json, id, OperationConstants.CRUD_UPDATE, schemaKey, mockmaximo, nextschemaKey, platform)); }
public MenuDefinition Menu(ClientPlatform platform) { if (_cachedMenu.ContainsKey(platform)) { return(_cachedMenu[platform]); } var unsecureMenu = MetadataProvider.Menu(platform); if (unsecureMenu == null) { Log.Warn(String.Format(MenuNotFound, platform)); return(null); } var secureLeafs = new List <MenuBaseDefinition>(); if (unsecureMenu.Leafs != null) { foreach (var leaf in unsecureMenu.Leafs) { if (!Login.Equals("swadmin") && leaf.Role != null && (Roles == null || !Roles.Any(r => r.Active && r.Name == leaf.Role))) { Log.DebugFormat("ignoring leaf {0} for user {1} due to absence of role {2}", leaf.Id, Login, leaf.Role); continue; } if (leaf is MenuContainerDefinition) { var secured = ((MenuContainerDefinition)leaf).Secure(this); if (secured != null) { secureLeafs.Add(secured); } } else { secureLeafs.Add(leaf); } } } if (!secureLeafs.Any()) { Log.Warn(String.Format(BlankUser, Login)); } var menuDefinition = new MenuDefinition(secureLeafs, unsecureMenu.MainMenuDisplacement.ToString(), unsecureMenu.ItemindexId); try { _cachedMenu.Add(platform, menuDefinition); // ReSharper disable once EmptyGeneralCatchClause } catch { //No op } return(menuDefinition); }
private object BuildErrorParameter(string entityid, string application, ClientPlatform platform, string popupmode, ApplicationMetadata applicationMetadata, Exception e) { return(new { application = application, popupmode = popupmode ?? "none", queryString = BuildQueryString(null, entityid, application, platform, applicationMetadata, popupmode), message = "Error: " + e.Message, messageType = "error" }); }
public FlowErrorCode GenerateServiceSketch( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { linkInfo = null; return(FlowErrorCode.Success); }
/// <summary> /// The initialize application endpoint function /// </summary> public async Task InitializeApplicationEndpointAsync( string applicationEndpointUri, string callbackUriFormat, string resourcesUriFormat, string audienceUri, string aadClientId, string aadClientSecret, string appTokenCertThumbprint, string instanceId, bool isSandBoxEnvionment = false, bool logFullHttpRequestResponse = true) { this.InstanceId = instanceId; this.ResourceUriFormat = resourcesUriFormat; this.CallbackUriFormat = callbackUriFormat; var logger = IOCHelper.Resolve <IPlatformServiceLogger>(); logger.HttpRequestResponseNeedsToBeLogged = logFullHttpRequestResponse; ClientPlatformSettings platformSettings = null; if (!string.IsNullOrEmpty(appTokenCertThumbprint)) { platformSettings = new ClientPlatformSettings( Guid.Parse(aadClientId), appTokenCertThumbprint, isSandBoxEnvionment ); } else if (!string.IsNullOrEmpty(aadClientSecret)) { platformSettings = new ClientPlatformSettings( aadClientSecret, Guid.Parse(aadClientId), isSandBoxEnvionment ); } else { throw new InvalidOperationException("Should provide at least one prarameter in aadClientSecret and appTokenCertThumbprint"); } var platform = new ClientPlatform(platformSettings, logger); var endpointSettings = new ApplicationEndpointSettings(new SipUri(applicationEndpointUri)); ApplicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, null); var loggingContext = new LoggingContext(Guid.NewGuid()); await ApplicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await ApplicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); }
internal MenuDefinition InitializeMenu(ClientPlatform platform, Stream streamValidator = null) { try { using (var stream = MetadataParsingUtils.GetStream(streamValidator, String.Format(MenuPattern, platform.ToString().ToLower()))) { return(stream == null ? null : new XmlMenuMetadataParser().Parse(stream)); } } catch (Exception) { Log.Warn(String.Format("menu.{0}.xml not found", platform)); } return(null); }
public VersionSign(string name, ClientPlatform platform, string sign) { if (platform == ClientPlatform.Other) { throw new ArgumentException(nameof(platform)); } Name = name; Sign = sign; Platform = platform; PlatformName = Platforms[(int)platform]; }
public async Task RunAsync(Uri callbackUri) { var targetUserId = ConfigurationManager.AppSettings["Skype_TargetUserId"]; m_logger = new SampleAppLogger(); // Uncomment for debugging // m_logger.HttpRequestResponseNeedsToBeLogged = true; // You can hook up your own implementation of IEventChannel here IEventChannel eventChannel = WebEventChannel.WebEventChannel.Instance; // Prepare platform var platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, new Guid(QuickSamplesConfig.AAD_ClientId)); var platform = new ClientPlatform(platformSettings, m_logger); // Prepare endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId)); var applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel); var loggingContext = new LoggingContext(Guid.NewGuid()); await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); // Get all the events related to join meeting through our custom callback uri platformSettings.SetCustomizedCallbackurl(callbackUri); WriteToConsoleInColor("Start to send messaging invitation"); var invitation = await applicationEndpoint.Application.Communication.StartMessagingAsync( "Subject", new SipUri(targetUserId), null, loggingContext).ConfigureAwait(false); // Wait for user to accept the invitation var conversation = await invitation.WaitForInviteCompleteAsync().ConfigureAwait(false); conversation.HandleParticipantChange += Conversation_HandleParticipantChange; conversation.MessagingCall.IncomingMessageReceived += Handle_IncomingMessage; // Send the initial message await conversation.MessagingCall.SendMessageAsync("Hello World!", loggingContext).ConfigureAwait(false); WriteToConsoleInColor("Staying in the conversation for 5 minutes"); // Wait 5 minutes before exiting // Since we registered callbacks, we will continue to show message logs await Task.Delay(TimeSpan.FromMinutes(5)).ConfigureAwait(false); await WebEventChannel.WebEventChannel.Instance.TryStopAsync().ConfigureAwait(false); }
public async Task Run() { ConsoleLogger logger = new ConsoleLogger(); logger.HttpRequestResponseNeedsToBeLogged = true; //Set to true if you want to log all http request and responses //Prepare platform //For all public developers ClientPlatformSettings platformSettings = new ClientPlatformSettings( QuickSamplesConfig.AAD_ClientSecret, Guid.Parse(QuickSamplesConfig.AAD_ClientId), false ); var platform = new ClientPlatform(platformSettings, logger); //Prepare endpoint var eventChannel = new FakeEventChannel(); var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId)); ApplicationEndpoint applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel); var loggingContext = new LoggingContext(Guid.NewGuid()); await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); //Schedule meeting var adhocMeeting = await applicationEndpoint.Application.GetAdhocMeetingResourceAsync(loggingContext, new AdhocMeetingInput { AccessLevel = AccessLevel.Everyone, Subject = Guid.NewGuid().ToString("N") + "testMeeting" }); logger.Information("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); logger.Information("ad hoc meeting join url : " + adhocMeeting.JoinUrl); //Get anon join token AnonymousApplicationTokenResource anonToken = await applicationEndpoint.Application.GetAnonApplicationTokenAsync(loggingContext, new AnonymousApplicationTokenInput { ApplicationSessionId = Guid.NewGuid().ToString(), //Should be unique everytime AllowedOrigins = "https://contoso.com;https://litware.com;http://www.microsoftstore.com/store/msusa/en_US/home", //Fill your own web site, For allow cross domain using MeetingUrl = adhocMeeting.JoinUrl } ); logger.Information("Get anon token : " + anonToken.AuthToken); logger.Information("Get discover url for web SDK : " + anonToken.AnonymousApplicationsDiscover.Href); }
/// <summary> /// The initialize application endpoint function /// </summary> public async Task InitializeApplicationEndpointAsync( string discoverUri, string applicationEndpointUri, string callbackUriFormat, string resourcesUriFormat, string aadClientId, string aadClientSecret, string aadAuthorityUri, string aadCertThumbprint, string instanceId, bool logFullHttpRequestResponse) { this.InstanceId = instanceId; this.ResourceUriFormat = resourcesUriFormat; this.CallbackUriFormat = callbackUriFormat; var logger = IOCHelper.Resolve <IPlatformServiceLogger>(); logger.HttpRequestResponseNeedsToBeLogged = logFullHttpRequestResponse; ClientPlatformSettings platformSettings; if (aadClientSecret.Length > 0) { // AAD auth to app using client secret platformSettings = new ClientPlatformSettings( new System.Uri(discoverUri), Guid.Parse(aadClientId), null, aadClientSecret ); } else { // AAD auth to app using cert platformSettings = new ClientPlatformSettings( new System.Uri(discoverUri), Guid.Parse(aadClientId), aadCertThumbprint ); } var platform = new ClientPlatform(platformSettings, logger); var endpointSettings = new ApplicationEndpointSettings(new SipUri(applicationEndpointUri)); ApplicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, null); var loggingContext = new LoggingContext(Guid.NewGuid()); await ApplicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await ApplicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); }
public void AddNewClient(ClientPlatform platform, string notificationId) { if(!BddContext.NotificationClients.Any(c => notificationId.Equals(c.NotificationID))) { var notificationClient = new NotificationClient { Platform = platform, NotificationID = notificationId }; BddContext.NotificationClients.Add(notificationClient); BddContext.SaveChanges(); } }
public MenuAndTopNav Get(ClientPlatform platform) { try { var user = SecurityFacade.CurrentUser(); var isSysAdmin = user.Roles.Any(r => r.Name == "sysadmin") || ApplicationConfiguration.IsLocal(); var isClientAdmin = user.Roles.Any(r => r.Name == "clientadmin") || ApplicationConfiguration.IsLocal(); var securedMenu = user.Menu(platform); return(new MenuAndTopNav(securedMenu, isSysAdmin, isClientAdmin)); } catch (InvalidOperationException) { FormsAuthentication.SignOut(); return(new MenuAndTopNav(MetadataProvider.Menu(platform), false, false)); } }
public void SaveMenu([NotNull] Stream data, ClientPlatform platform = ClientPlatform.Web) { try { var newMenu = new MenuXmlInitializer().InitializeMenu(platform, data); using (var stream = File.Create(MenuXmlInitializer.GetMenuPath(platform))) { data.CopyTo(stream); stream.Flush(); } _menus[platform] = newMenu; } catch (Exception e) { Log.Error("error saving menu", e); throw; } }
public IEnumerable <object> Get(ClientPlatform platform) { try { InMemoryUser user = SecurityFacade.CurrentUser(); return(from application in user.Applications(platform) select new { application.Id, application.Name, application.Title }); } catch (InvalidOperationException) { FormsAuthentication.SignOut(); return(Enumerable.Empty <object>()); } }
//TODO: have u considered creating an object, much like DataRequestAdapter, for combining these parameters? // ==> This could be set in shared project and reused by the Ipad App. // ==> On Angular, we could create a .js class also (still lots to do there...) /// <summary> /// API Method to handle Delete operations /// </summary> public IApplicationResponse Delete([NotNull] string application, [NotNull] string id, ClientPlatform platform, [NotNull] string currentSchemaKey, string nextSchemaKey = null, bool mockmaximo = false) { var schemaKey = _nextSchemaRouter.GetSchemaKeyFromString(application, currentSchemaKey, platform); ContextLookuper.FillContext(schemaKey); var nextschemaKey = _nextSchemaRouter.GetSchemaKeyFromString(application, nextSchemaKey, platform); var response = DoExecute(application, new JObject(), id, OperationConstants.CRUD_DELETE, schemaKey, mockmaximo, nextschemaKey, platform); var defaultMsg = String.Format("{0} {1} deleted successfully", application, id); response.SuccessMessage = _i18NResolver.I18NValue("general.defaultcommands.delete.confirmmsg", defaultMsg, null, new object[] { application, id }); return(response); }
static void Main(string[] args) { Dictionary <string, string> skypeAuthSettings = new Dictionary <string, string>() { { "AAD_ClientId", "" }, { "AAD_ClientSecret", "" }, { "ApplicationEndpointId", "" }, { "DiscoverUri", "https://api.skypeforbusiness.com/platformservice/discover?Region=northamerica" } }; var logger = new StringLogger(); try { ClientPlatformSettings platformSettings = new ClientPlatformSettings(new Uri(skypeAuthSettings["DiscoverUri"]), new Guid(skypeAuthSettings["AAD_ClientId"]), null, skypeAuthSettings["AAD_ClientSecret"], false); var platform = new ClientPlatform(platformSettings, logger); //Prepare endpoint var endpointSettings = new ApplicationEndpointSettings(new SipUri(skypeAuthSettings["ApplicationEndpointId"])); ApplicationEndpoint applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, null); var loggingContext = new LoggingContext(Guid.NewGuid()); applicationEndpoint.InitializeAsync().GetAwaiter().GetResult(); applicationEndpoint.InitializeApplicationAsync().GetAwaiter().GetResult(); //Schedule meeting var input = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + "testMeeting"); var adhocMeeting = applicationEndpoint.Application.CreateAdhocMeetingAsync(input, loggingContext).Result; Console.WriteLine("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); Console.WriteLine("ad hoc meeting join url : " + adhocMeeting.JoinUrl); //Get anon join token IAnonymousApplicationToken anonToken = applicationEndpoint.Application.GetAnonApplicationTokenForMeetingAsync(adhocMeeting.JoinUrl, "https://contoso.com;https://litware.com;http://www.microsoftstore.com/store/msusa/en_US/home<https://urldefense.proofpoint.com/v2/url?u=https-3A__contoso.com-3Bhttps-3A_litware.com-3Bhttp-3A_www.microsoftstore.com_store_msusa_en-5FUS_home&d=DwMGaQ&c=Bi8ZWNNcZUBhi-AHLorvrkVH0ArnzxTAZ7C8kNcJoZo&r=uycUjr279qo0kuj5jNiyFqi9adZMUkMtmsdo99NlvRQ&m=7jet88f1Tbswi73IIaQYzhITPDlxR_mzF2flXNxdbwQ&s=ozm8LVnKFoAyQtSX8KWnm56u950cmjrR5fvfEpP1SfM&e=>", Guid.NewGuid().ToString(), loggingContext).Result; Console.WriteLine("Get anon token : " + anonToken.AuthToken); Console.WriteLine("Get discover url for web SDK : " + anonToken.AnonymousApplicationsDiscoverUri); } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
private AppEntranceDto CheckPlatformThenAdd(ClientPlatform clientPlatform, List <AppEntranceDto> result, AppEntrance item) { if (item.IsFolder) { var dto = _mapper.Map <AppEntranceDto>(item); result.Add(dto); return(dto); } if (item.Uris?.ContainsKey(clientPlatform) == true) { var dto = _mapper.Map <AppEntranceDto>(item); dto.Uri = item.Uris[clientPlatform]; result.Add(dto); return(dto); } return(null); }
public ApplicationMetadataPolicyApplier([NotNull] CompleteApplicationMetadataDefinition application, ApplicationMetadataSchemaKey schemaKey, [NotNull] InMemoryUser user, ClientPlatform platform) { if (application == null) { throw new ArgumentNullException("application"); } if (user == null) { throw new ArgumentNullException("user"); } _application = application; _user = user; _schemaKey = schemaKey; _platform = platform; _result = new Lazy <ApplicationMetadata>(ApplyImpl); }
public async Task <ActionResult <List <AppEntranceDto> > > GetAll(ClientPlatform clientPlatform, string clientId = Client.DefaultId) { try { var input = new GetAppEntrancesInput { ClientId = clientId, UserRoles = GetUserRoles().ToList(), ClientPlatform = clientPlatform, }; return(await _workbenchAppService.GetAppEntrancesAsync(input)); } catch (Exception ex) { return(BadRequest(LogError(_logger, ex))); } }
private void InitializeEndpoint() { _platformSettings = new ClientPlatformSettings(null, _aadClientId, null, _aadClientSecret, true); var platform = new ClientPlatform(_platformSettings, Logger); _eventChannel = new FakeEventChannel(); var endpointSettings = new ApplicationEndpointSettings(_applicationEndpointId); _applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, _eventChannel); _applicationEndpoint.InitializeAsync(null).GetAwaiter().GetResult(); _applicationEndpoint.InitializeApplicationAsync(null).GetAwaiter().GetResult(); if (_applicationEndpoint.Application != null) { _isInitialized = true; } }
public async Task Run() { var logger = new SampleAppLogger(); logger.HttpRequestResponseNeedsToBeLogged = true; //Set to true if you want to log all http request and responses //Prepare platform ClientPlatformSettings platformSettings = new ClientPlatformSettings(QuickSamplesConfig.AAD_ClientSecret, Guid.Parse(QuickSamplesConfig.AAD_ClientId)); var platform = new ClientPlatform(platformSettings, logger); //Prepare endpoint var eventChannel = new FakeEventChannel(); var endpointSettings = new ApplicationEndpointSettings(new SipUri(QuickSamplesConfig.ApplicationEndpointId)); ApplicationEndpoint applicationEndpoint = new ApplicationEndpoint(platform, endpointSettings, eventChannel); var loggingContext = new LoggingContext(Guid.NewGuid()); await applicationEndpoint.InitializeAsync(loggingContext).ConfigureAwait(false); await applicationEndpoint.InitializeApplicationAsync(loggingContext).ConfigureAwait(false); //Schedule meeting var input = new AdhocMeetingCreationInput(Guid.NewGuid().ToString("N") + "testMeeting"); var adhocMeeting = await applicationEndpoint.Application.CreateAdhocMeetingAsync(loggingContext, input).ConfigureAwait(false); logger.Information("ad hoc meeting uri : " + adhocMeeting.OnlineMeetingUri); logger.Information("ad hoc meeting join url : " + adhocMeeting.JoinUrl); //Get anon join token IAnonymousApplicationToken anonToken = await applicationEndpoint.Application.GetAnonApplicationTokenForMeetingAsync( loggingContext, adhocMeeting.JoinUrl, "https://contoso.com;https://litware.com;http://www.microsoftstore.com/store/msusa/en_US/home", //Fill your own web site, For allow cross domain using Guid.NewGuid().ToString() //Should be unique everytime ).ConfigureAwait(false); logger.Information("Get anon token : " + anonToken.AuthToken); logger.Information("Get discover url for web SDK : " + anonToken.AnonymousApplicationsDiscoverUri.ToString()); Console.ForegroundColor = ConsoleColor.Green; logger.Information("RemoteAdvisor sample completed successfully!"); Console.ResetColor(); }
public async Task<RequestHeader> GetPackageAsync(ClientPlatform platform) { var method = UpdateMethod.GetVersion; var context = method.ToString(); this.LogRequest(context); await this.TransferHandler.WriteAsync(this.Id, (byte)method); var data = BitConverter.GetBytes((int)platform); this.LogRequest(data, context); await this.TransferHandler.WriteAsync(data); var bytes = await this.TransferHandler.ReadAsync(); this.LogResponse(bytes, context); if (bytes.Length != Constants.NoDataBytes.Length) { return new RequestHeader().Setup(new MemoryStream(bytes)); } return null; }
public ActionResult Input([NotNull] string application, string json, ClientPlatform platform, [NotNull] string currentSchemaKey, string nextSchemaKey) { var user = SecurityFacade.CurrentUser(); Log.Info("receiving ie9 attachment request"); var currentSchema = _nextSchemaRouter.GetSchemaKeyFromString(application, currentSchemaKey, platform); var applicationMetadata = MetadataProvider .Application(application) .ApplyPolicies(currentSchema, user, ClientPlatform.Web); var queryStrings = HttpUtility.ParseQueryString(Request.UrlReferrer.Query); var popupmode = queryStrings["popupmode"]; var datamap = JObject.Parse(json); var entityId = datamap[applicationMetadata.Schema.IdFieldName].ToString(); try { PopulateFilesInJson(datamap, String.IsNullOrWhiteSpace(entityId)); PopulateInputsInJson(datamap); var mockMaximo = MockingUtils.IsMockingMaximoModeActive(datamap); IApplicationResponse response; if (String.IsNullOrWhiteSpace(entityId)) { Log.DebugFormat("redirecting to datacontroller post with datamap " + datamap); response = _dataController.Post(application, datamap, platform, currentSchemaKey, nextSchemaKey, mockMaximo); } else { Log.DebugFormat("redirecting to datacontroller put"); response = _dataController.Put(application, entityId, datamap, platform, currentSchemaKey, nextSchemaKey, mockMaximo); } return(RedirectToAction("RedirectToAction", "Home", BuildParameter(entityId, application, platform, response, popupmode, applicationMetadata))); } catch (Exception e) { var rootException = ExceptionUtil.DigRootException(e); //TODO: handle error properly Log.Error(rootException, e); return(RedirectToAction("RedirectToAction", "Home", BuildErrorParameter(entityId, application, platform, popupmode, applicationMetadata, e))); } }
/// <summary> /// API Method to handle Insert operations /// </summary> public IApplicationResponse Post([NotNull] string application, JObject json, ClientPlatform platform, [NotNull] string currentSchemaKey, string nextSchemaKey = null, bool mockmaximo = false) { Log.InfoFormat("PERFORMANCE - Data controller POST started at {0}.", DateTime.Now); var before = Stopwatch.StartNew(); if (Log.IsDebugEnabled) { Log.DebugFormat("json received: " + json.ToString()); } var schemaKey = _nextSchemaRouter.GetSchemaKeyFromString(application, currentSchemaKey, platform); ContextLookuper.FillContext(schemaKey); var nextschemaKey = _nextSchemaRouter.GetSchemaKeyFromString(application, nextSchemaKey, platform); var response = DoExecute(application, json, null, OperationConstants.CRUD_CREATE, schemaKey, mockmaximo, nextschemaKey, platform); var msDelta = LoggingUtil.MsDelta(before); Log.InfoFormat("PERFORMANCE - Data controller POST executed in {0} ms.", msDelta); return(response); }
private async Task<RequestPackage> LoadPackageAsync(ClientPlatform platform, string version) { var file = new FileInfo(_paths[(int)platform]); using (var fs = file.OpenRead()) { var buffer = MemoryPool.Get80KBuffer(); try { using (var ms = new MemoryStream((int)file.Length)) { int readBytes; while ((readBytes = await fs.ReadAsync(buffer, 0, buffer.Length)) != 0) { await ms.WriteAsync(buffer, 0, readBytes); } return new RequestPackage(new RequestHeader(platform, Version.Parse(version), string.Empty, string.Empty), ms.GetBuffer()); } } finally { MemoryPool.Return80KBuffer(buffer); } } }
private static int FolderIndex(ClientPlatform platform, LogCategory category) { return ((int)platform * Categories) + (int)category; }
public FlowErrorCode GenerateServiceSketch( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { linkInfo = null; return FlowErrorCode.Success; }
public FlowErrorCode GenerateServiceSketch( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { var compiler = LanguageHelper.GetCompilerPath(GetType()); linkInfo = new LinkageInfo(); if (compiler == "") { return FlowErrorCode.SpecCompilerNotFound; } if (platform != ClientPlatform.Windows) { Console.WriteLine("Bond compiler only supports windows platform!"); return FlowErrorCode.PlatformNotSupported; } // hack for C# for the time being if (lang == ClientLanguage.Client_CSharp) { linkInfo.IncludeDirectories.Add(dir); linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List<string>() { "Microsoft.Bond.dll", "Microsoft.Bond.Rpc.dll", "Microsoft.Bond.Interfaces.dll", "Microsoft.Bond.TypeProvider.dll", }); linkInfo.Sources = FromAllSpecToSources( Path.Combine(spec.Directory, spec.MainSpecFile), spec.ReferencedSpecFiles.Select(rs => Path.Combine(spec.Directory, rs)), dir, new[] { GeneratedFileType.TYPES, GeneratedFileType.SERVICES }, new[] { GeneratedFileType.TYPES } ) .Select(Path.GetFileName) .ToList(); return FlowErrorCode.Success; } var arguments = new List<string> { " ", "/" + GetLanguageName(lang), "/I:" + spec.Directory, "/O:" + dir, Path.Combine(spec.Directory, spec.MainSpecFile) }; if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) == 0) { switch (lang) { case ClientLanguage.Client_CSharp: { linkInfo.IncludeDirectories.Add(dir); linkInfo.LibraryPaths.Add(Directory.GetParent(compiler).FullName); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List<string>() { "Microsoft.Bond.dll", "Microsoft.Bond.Rpc.dll", "Microsoft.Bond.Interfaces.dll", "Microsoft.Bond.TypeProvider.dll", }); var specName = Path.GetFileNameWithoutExtension(spec.MainSpecFile); var searchPattern = specName + "_*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName)); break; } case ClientLanguage.Client_CPlusPlus: { var bondHeaders = Path.GetPathRoot(compiler); linkInfo.IncludeDirectories.Add(dir); linkInfo.IncludeDirectories.Add(bondHeaders); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15)); break; } case ClientLanguage.Client_Java: { // FIXME: when generate java code, bondc will generate a subdir linkInfo.IncludeDirectories.Add(dir); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(dir, searchPattern, SearchOption.AllDirectories, 15)); break; } default: break; } return FlowErrorCode.Success; } else { return FlowErrorCode.ExceptionError; } }
public LogCategoryViewModel(ClientPlatform platform, LogCategory category, string icon) { if (icon == null) throw new ArgumentNullException("icon"); Platform = platform; this.Category = category; this.Icon = icon; }
private async Task SavePackageAsync(ClientPlatform platform, RequestPackage package) { using (var fs = File.OpenWrite(_paths[(int)platform])) { var buffer = MemoryPool.Get80KBuffer(); try { using (var ms = new MemoryStream(package.Data)) { int readBytes; while ((readBytes = ms.Read(buffer, 0, buffer.Length)) != 0) { await fs.WriteAsync(buffer, 0, readBytes); } } } finally { MemoryPool.Return80KBuffer(buffer); } } await this.SavePackageConfigAsync(); }
public FlowErrorCode GenerateServiceClient( ServiceSpec spec, string dir, ClientLanguage lang, ClientPlatform platform, out LinkageInfo linkInfo ) { if (spec.IsRdsnRpc) { return GenerateRdsnClient(spec, dir, out linkInfo); } var compiler = LanguageHelper.GetCompilerPath(GetType(), platform); linkInfo = new LinkageInfo(); if (compiler == "") { return FlowErrorCode.SpecCompilerNotFound; } var arguments = new List<string>(); var languageName = GetLanguageName(lang); arguments.Add(" "); arguments.Add("--" + languageName); arguments.Add("-r"); arguments.Add("-out " + dir); arguments.Add(Path.Combine(spec.Directory, spec.MainSpecFile)); if (SystemHelper.RunProcess(compiler, string.Join(" ", arguments)) != 0) return FlowErrorCode.ExceptionError; // generally, thrift.exe will generate a folder in the name of the mainspec's namespace to the output dir,e.g. gen-csharp // all language libraries are availabe in the source code of thrift project, placed in the thrift\\lib\\{language} dir // in Tron project, we place thrift compiler at "external\\thrift\\bin", and place the libraries in at"external\\thrift\\lib\\{language}" switch (lang) { case ClientLanguage.Client_CSharp: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\csharp")); linkInfo.LibraryPaths.Add(dir); linkInfo.DynamicLibraries.AddRange(new List<string> { "Thrift.dll" }); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15).Select(Path.GetFileName)); break; } case ClientLanguage.Client_CPlusPlus: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\cpp")); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15)); break; } case ClientLanguage.Client_Java: { var sourceDir = Path.Combine(dir, "gen-" + languageName); linkInfo.IncludeDirectories.Add(sourceDir); linkInfo.LibraryPaths.Add(sourceDir); linkInfo.LibraryPaths.Add(Path.Combine(Directory.GetParent(compiler).FullName, "lib\\java")); var searchPattern = "*." + LanguageHelper.GetSourceExtension(lang); linkInfo.Sources.AddRange(SystemHelper.GetFilesByLastWrite(sourceDir, searchPattern, SearchOption.AllDirectories, 15)); break; } default: break; } return FlowErrorCode.Success; }