public WorkbookPublisher(PublisherSettings publisherSettings, DataSourceCredentials creds, ILoggerFactory loggerFactory) { _publisherSettings = publisherSettings; _dbCreds = creds; _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <WorkbookPublisher>(); }
public VerificationResult Verify(PublisherSettings settings) { var request = AssemblaUtils.CreateLoadSpacesRequest(settings); using (request.GetResponse()) return(new VerificationResult()); }
public List <Field> GetDependentFields(PublisherSettings settings, string parentFieldName, string parentFieldValue) { // Simulate connecting... Thread.Sleep(1000); if (parentFieldName != "project") { return(new List <Field>()); } return(new List <Field> { new Field { Name = "priority", DisplayName = "Priority", DisplayOrder = 3, FieldType = FieldType.Dropdown, ShowInSubmissionScreen = true, AcceptedValues = new List <AcceptedValue> { new AcceptedValue { Id = "1", Value = parentFieldValue == "1" ? "Major" : "High" }, new AcceptedValue { Id = "2", Value = "Medium" }, new AcceptedValue { Id = "3", Value = parentFieldValue == "1" ? "Minor" : "Low" }, } } }); }
public List <Field> GetIndependentFields(PublisherSettings settings) { // Simulate connecting... Thread.Sleep(1000); return(new List <Field> { new Field { Name = "project", DisplayName = "Project", DisplayOrder = 1, IsFoundationField = true, HasDependentFields = true, FieldType = FieldType.Dropdown, AcceptedValues = new List <AcceptedValue> { new AcceptedValue { Id = "1", Value = "qTrace" }, new AcceptedValue { Id = "2", Value = "qTest" }, } }, new Field { Name = "date", DisplayName = "Due Date", DisplayOrder = 2, ShowInSubmissionScreen = true, FieldType = FieldType.Date, IsDefaultValueEditable = false } }); }
public List<Field> GetDependentFields(PublisherSettings settings, string parentFieldName, string parentFieldValue) { // Simulate connecting... Thread.Sleep(1000); if (parentFieldName != "project") return new List<Field>(); return new List<Field> { new Field { Name = "priority", DisplayName = "Priority", DisplayOrder = 3, FieldType = FieldType.Dropdown, ShowInSubmissionScreen = true, AcceptedValues = new List<AcceptedValue> { new AcceptedValue { Id = "1", Value = parentFieldValue == "1" ? "Major" : "High" }, new AcceptedValue { Id = "2", Value = "Medium" }, new AcceptedValue { Id = "3", Value = parentFieldValue == "1" ? "Minor" : "Low" }, } } }; }
public void CallSettings_Client() { string projectId = _fixture.ProjectId; string topicId = _fixture.CreateTopicId(); // Sample: CallSettings_ClientWide // Create a default PublisherSettings, with a custom header for calls to all RPC methods. PublisherSettings publisherSettings = new PublisherSettings { CallSettings = new CallSettings { Headers = new Metadata { { "ClientVersion", "1.0.0" } }, } }; PublisherClient client = PublisherClient.Create(settings: publisherSettings); // Format topicName from the projectId and topicId. string topicName = PublisherClient.FormatTopicName(projectId, topicId); // The custom 'ClientVersion' header will be included in the RPC call, due to // the client being configured with 'publishersettings' above. Topic topic = client.CreateTopic(topicName); // End sample }
public List<Field> GetIndependentFields(PublisherSettings settings) { // Simulate connecting... Thread.Sleep(1000); return new List<Field> { new Field { Name = "project", DisplayName = "Project", DisplayOrder = 1, IsFoundationField = true, HasDependentFields = true, FieldType = FieldType.Dropdown, AcceptedValues = new List<AcceptedValue> { new AcceptedValue { Id = "1", Value = "qTrace" }, new AcceptedValue { Id = "2", Value = "qTest" }, } }, new Field { Name = "date", DisplayName = "Due Date", DisplayOrder = 2, ShowInSubmissionScreen = true, FieldType = FieldType.Date, IsDefaultValueEditable = false } }; }
public TradeConfirmationsPublisher( PublisherSettings settings, ILogger <TradeConfirmationsPublisher> logger) { _settings = settings; _logger = logger; }
protected virtual TimeSpan GetDefaultRequestTimeout(Type requestType, PublisherSettings publisherSettings) { var timeout = publisherSettings.Timeout ?? settings.RequestResponse.Timeout; Log.DebugFormat("Applying default timeout {0} for message type {1}", timeout, requestType); return(timeout); }
public OrderBooksUpdatesReportPublisher( PublisherSettings settings, ILogFactory logFactory) { _logFactory = logFactory; _settings = settings; }
public void GetMessagePartition() { // arrange var publisherA = new PublisherSettings(); new PublisherBuilder <MessageA>(publisherA) .PartitionProvider((m, t) => 10); var publisherB = new PublisherSettings(); new PublisherBuilder <MessageB>(publisherB); MbSettings.Publishers.Add(publisherA); MbSettings.Publishers.Add(publisherB); var msgA = new MessageA(); var msgB = new MessageB(); // act var msgAPartition = KafkaMb.Value.Public_GetMessagePartition(msgA.GetType(), msgA, "topic1"); var msgBPartition = KafkaMb.Value.Public_GetMessagePartition(msgB.GetType(), msgB, "topic1"); // assert msgAPartition.Should().Be(10); msgBPartition.Should().Be(-1); }
public void GetMessageKey() { // arrange var publisherA = new PublisherSettings(); new PublisherBuilder <MessageA>(publisherA) .KeyProvider((m, t) => m.Key); var publisherB = new PublisherSettings(); new PublisherBuilder <MessageB>(publisherB); MbSettings.Publishers.Add(publisherA); MbSettings.Publishers.Add(publisherB); var msgA = new MessageA(); var msgB = new MessageB(); // act var msgAKey = KafkaMb.Value.Public_GetMessageKey(msgA.GetType(), msgA, "topic1"); var msgBKey = KafkaMb.Value.Public_GetMessageKey(msgB.GetType(), msgB, "topic1"); // assert msgAKey.Should().BeSameAs(msgA.Key); msgBKey.Should().BeNull(); }
public LogSharkRunner(LogSharkConfiguration config, MetricsModule metricsModule, ILoggerFactory loggerFactory) { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture; _loggerFactory = loggerFactory; _logger = loggerFactory.CreateLogger <LogSharkRunner>(); _config = config; _processingNotificationsCollector = new ProcessingNotificationsCollector(_config.NumberOfErrorDetailsToKeep); if (_config.PublishWorkbooks) { var tableauServerInfo = new TableauServerInfo( _config.TableauServerUrl, _config.TableauServerSite, _config.TableauServerUsername, _config.TableauServerPassword, _config.TableauServerTimeout); _publisherSettings = new PublisherSettings( tableauServerInfo, _config.GroupsToProvideWithDefaultPermissions, _config.ApplyPluginProvidedTagsToWorkbooks, _config.ParentProjectId, _config.ParentProjectName); } _metricsModule = metricsModule; }
private IPublisherClient CreatePublisher(UnityProject project, UnityUser user) { // This is the public name of the Source Project you want to export (it doesn't have to be unique). string sourceName = $"{project.Name}_markers"; // This identifies the Source Project you want to export and must be unique and persistent over multiple publishing sessions. string baseIdString = $"{project.ProjectId}_markers"; string sourceId; using (MD5 md5 = MD5.Create()) { byte[] hash = md5.ComputeHash(Encoding.Default.GetBytes(baseIdString)); sourceId = new Guid(hash).ToString(); } var version = Regex.Replace(Application.version, "[^0-9.]", ""); //Create the publisher settings for the client m_PublisherSettings = new PublisherSettings(project, user) { PluginName = Application.productName + " MarkerPublisher", //TODO: Use Reflect DLL version PluginVersion = Version.Parse(version), LengthUnit = LengthUnit.Meters, AxisInversion = AxisInversion.None }; // Create a Publisher Client, that will allow us to publish data into the selected Unity Project. return(Publisher.OpenClient(sourceName, sourceId, m_PublisherSettings, false)); }
public PublishingResult Publish( PublisherSettings settings, PublishingRecord record, AttachmentFunc createAttachments) { Space selectedSpace = null; bool uploadAttachmentToDropbox = false; var selectedSpaceLock = new object(); // open submission screen Context.ExecuteOnUIThread(() => { var view = new SpacePromptView { IsConnectedToDropbox = Context.IsDropboxConnected, Spaces = new ObservableCollection <Space>(AssemblaUtils.LoadSpaces(settings)) }; lock (selectedSpaceLock) { if (view.ShowDialog() == true) { selectedSpace = view.SelectedSpace; uploadAttachmentToDropbox = view.UploadAttachmentToDropbox; } } }); if (selectedSpace == null) { return(null); } Context.ShowProgressIndicator(message: "Starting..."); try { var attachments = new Dictionary <string, bool>(); // Generate the attachments before starting background thread if (uploadAttachmentToDropbox) { foreach (var file in ExportAttachmentToDropbox(createAttachments)) { attachments.Add(file, true); } } else { foreach (var file in createAttachments()) { attachments.Add(file, false); } } // Automate browser in a worker thread Task.Factory.StartNew(() => AssemblaUtils.Automate(settings, record, attachments, selectedSpace.Id)); } finally { Context.HideProgressIndicator(); } return(null); }
public WorkbookPublisher(LogSharkConfiguration config, PublisherSettings publisherSettings, DataSourceCredentials creds, ILoggerFactory loggerFactory) { _config = config; _publisherSettings = publisherSettings; _dbCreds = creds; _loggerFactory = loggerFactory; _logger = _loggerFactory.CreateLogger <WorkbookPublisher>(); }
public InternalOrderBookPublisher( PublisherSettings settings, string instanceName, ILogFactory logFactory) { _logFactory = logFactory; _settings = settings; _instanceName = instanceName; }
public PublishingResult Publish(PublisherSettings settings, PublishingRecord record, IDictionary <string, string[]> fieldsValues, List <Attachment> attachments) { Task.Factory.StartNew(() => AssemblaUtils.Automate( settings, record, attachments, fieldsValues["Space"][0])); return(null); }
public PublishingResult Publish(PublisherSettings settings, PublishingRecord record, IDictionary<string, string[]> fieldsValues, List<Attachment> attachments) { Task.Factory.StartNew(() => AssemblaUtils.Automate( settings, record, attachments, fieldsValues["Space"][0])); return null; }
public PublishingResult Publish( PublisherSettings settings, PublishingRecord record, AttachmentFunc createAttachments) { Space selectedSpace = null; bool uploadAttachmentToDropbox = false; var selectedSpaceLock = new object(); // open submission screen Context.ExecuteOnUIThread(() => { var view = new SpacePromptView { IsConnectedToDropbox = Context.IsDropboxConnected, Spaces = new ObservableCollection<Space>(AssemblaUtils.LoadSpaces(settings)) }; lock (selectedSpaceLock) { if (view.ShowDialog() == true) { selectedSpace = view.SelectedSpace; uploadAttachmentToDropbox = view.UploadAttachmentToDropbox; } } }); if (selectedSpace == null) return null; Context.ShowProgressIndicator(message: "Starting..."); try { var attachments = new Dictionary<string, bool>(); // Generate the attachments before starting background thread if (uploadAttachmentToDropbox) { foreach (var file in ExportAttachmentToDropbox(createAttachments)) { attachments.Add(file, true); } } else { foreach(var file in createAttachments()) { attachments.Add(file, false); } } // Automate browser in a worker thread Task.Factory.StartNew(() => AssemblaUtils.Automate(settings, record, attachments, selectedSpace.Id)); } finally { Context.HideProgressIndicator(); } return null; }
protected virtual string GetDefaultTopic(Type messageType, PublisherSettings publisherSettings) { var topic = publisherSettings.DefaultTopic; if (topic == null) { throw new PublishMessageBusException($"An attempt to produce message of type {messageType} without specifying topic, but there was no default topic configured. Double check your configuration."); } Log.DebugFormat("Applying default topic {0} for message type {1}", topic, messageType); return(topic); }
/// <summary> /// Instantiate with the specified settings. /// </summary> /// <param name="clientCount">Optional. /// The number of <see cref="PublisherClient"/>s to create and use within a <see cref="SimplePublisher"/> instance.</param> /// <param name="publisherSettings">Optional. The settings to use when creating <see cref="PublisherClient"/> instances.</param> /// <param name="credentials">Optional. Credentials to use when creating <see cref="PublisherClient"/> instances.</param> /// <param name="serviceEndpoint">Optional. /// The <see cref="ServiceEndpoint"/> to use when creating <see cref="PublisherClient"/> instances.</param> public ClientCreationSettings( int?clientCount = null, PublisherSettings publisherSettings = null, ChannelCredentials credentials = null, ServiceEndpoint serviceEndpoint = null) { ClientCount = clientCount; PublisherSettings = publisherSettings; Credentials = credentials; ServiceEndpoint = serviceEndpoint; }
public void GetPartitionProvider_ReturnsNull_ByDefault() { // arrange var ps = new PublisherSettings(); // act var partitionProvider = ps.GetPartitionProvider(); // assert partitionProvider.Should().BeNull(); }
public VerificationResult Verify(PublisherSettings settings) { Context.ShowProgressIndicator(message: "Connecting to Assembla..."); try { var request = AssemblaUtils.CreateLoadSpacesRequest(settings); using (request.GetResponse()) return(new VerificationResult()); } finally { Context.HideProgressIndicator(); } }
public VerificationResult Verify(PublisherSettings settings) { // Simulate connecting... Thread.Sleep(1000); if (settings.UserName == "qtrace" && settings.Password == "qtrace") { return(new VerificationResult()); } throw new Exception("Not authenticated!"); }
public VerificationResult Verify(PublisherSettings settings) { Context.ShowProgressIndicator(message: "Connecting to FTP..."); try { var ftpRequest = CreateRequest(settings.Url, WebRequestMethods.Ftp.ListDirectory, settings); using (ftpRequest.GetResponse()) {} return(new VerificationResult()); } finally { Context.HideProgressIndicator(); } }
private void Upload(PublisherSettings settings, string filePath) { var uri = settings.Url + (settings.Url.EndsWith("/") ? string.Empty : "/") + Path.GetFileName(filePath); var ftpRequest = CreateRequest(uri, WebRequestMethods.Ftp.UploadFile, settings); using (Stream writer = ftpRequest.GetRequestStream()) { var fileContent = File.ReadAllBytes(filePath); writer.Write(fileContent, 0, fileContent.Length); } }
public VerificationResult Verify(PublisherSettings settings) { Context.ShowProgressIndicator(message: "Connecting to FTP..."); try { var ftpRequest = CreateRequest(settings.Url, WebRequestMethods.Ftp.ListDirectory, settings); using (ftpRequest.GetResponse()) {} return new VerificationResult(); } finally { Context.HideProgressIndicator(); } }
public static HttpWebRequest CreateLoadSpacesRequest(PublisherSettings settings) { string url = string.Format("{0}/spaces/my_spaces", settings.Url); var request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = settings.TimeoutInMillis; request.Accept = "application/xml"; request.ContentType = "application/xml"; request.Credentials = new NetworkCredential( settings.UserName, settings.Password); return request; }
private static FtpWebRequest CreateRequest( string uri, string method, PublisherSettings settings) { var ftpRequest = (FtpWebRequest)WebRequest.Create(uri); ftpRequest.Credentials = new NetworkCredential(settings.UserName, settings.Password); ftpRequest.UsePassive = settings.CustomSettingsFieldsValues["Mode"] == "Passive"; ftpRequest.EnableSsl = bool.Parse(settings.CustomSettingsFieldsValues["Ssl"]); ftpRequest.Timeout = settings.TimeoutInMillis; ftpRequest.Method = method; return(ftpRequest); }
public static HttpWebRequest CreateLoadSpacesRequest(PublisherSettings settings) { string url = string.Format("{0}/spaces/my_spaces", settings.Url); var request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = settings.TimeoutInMillis; request.Accept = "application/xml"; request.ContentType = "application/xml"; request.Credentials = new NetworkCredential( settings.UserName, settings.Password); return(request); }
public static List<Space> LoadSpaces(PublisherSettings settings) { var request = CreateLoadSpacesRequest(settings); using (var response = request.GetResponse()) using (var responseStream = response.GetResponseStream()) { var document = XDocument.Load(responseStream); return (from space in document.Root.Elements("space") select new Space { Id = space.Element("wiki-name").Value, Name = space.Element("name").Value }).ToList(); } }
public static List <Space> LoadSpaces(PublisherSettings settings) { var request = CreateLoadSpacesRequest(settings); using (var response = request.GetResponse()) using (var responseStream = response.GetResponseStream()) { var document = XDocument.Load(responseStream); return((from space in document.Root.Elements("space") select new Space { Id = space.Element("wiki-name").Value, Name = space.Element("name").Value }).ToList()); } }
public PublishingResult Publish( PublisherSettings settings, PublishingRecord record, IDictionary <string, string[]> fieldsValues, List <Attachment> attachments) { // Simulate connecting... Thread.Sleep(1000); return(new PublishingResult { RecordId = new Random().Next(1, 100).ToString(), Message = "Published successfully!" }); }
void CustomizePublisherSettings(PublisherSettings settings) { settings.LengthUnit = LengthUnit.Meters; settings.AxisInversion = AxisInversion.None; // Provide rules if we can find them in a rules file const string rulesFileName = "rules.json"; var assemblyPath = Assembly.GetExecutingAssembly().Location; var assemblyRulesPath = Path.Combine(Path.GetDirectoryName(assemblyPath), rulesFileName); if (File.Exists(assemblyRulesPath)) { settings.Rules = File.ReadAllText(assemblyRulesPath); } }
public List<Field> GetIndependentFields(PublisherSettings settings) { return new List<Field> { new Field { Name = "Space", DisplayName = "Space", FieldType = FieldType.Dropdown, IsEditable = true, IsFoundationField = true, AcceptedValues = (from s in AssemblaUtils.LoadSpaces(settings) select new AcceptedValue {Id = s.Id, Value = s.Name} ).ToList() } }; }
public static void RegisterEventPublishingService <T>( this ContainerBuilder builder, PublisherSettings settings) where T : ITransactionEvent { builder .Register(ctx => new JsonRabbitPublisher <T> ( ctx.Resolve <ILogFactory>(), settings.ConnectionString, Context.GetEndpointName <T>() )) .As <IRabbitPublisher <T> >() .SingleInstance(); }
public PublishingResult Publish(PublisherSettings settings, PublishingRecord record, AttachmentFunc createAttachments) { Context.ShowProgressIndicator(message: "Publishing to FTP..."); try { var tasks = from attachment in createAttachments() select Task.Factory.StartNew(() => Upload(settings, attachment)); Task.WaitAll(tasks.ToArray()); return new PublishingResult(); } catch (AggregateException e) { throw new PublishingException(e.InnerExceptions[0].Message, e.InnerExceptions[0]); } finally { Context.HideProgressIndicator(); } }
public void CallSettings_Overrides() { string projectId = _fixture.ProjectId; string topicId = _fixture.CreateTopicId(); DateTime deadline = DateTime.MaxValue; CancellationToken cancellationToken = new CancellationTokenSource().Token; // Sample: CallSettings_Overrides // Create a default PublisherSettings, with customizations for CreateTopic RPCs: // * A custom "ClientVersion" header. // * A custom 5-second timeout Timing. // * No cancellation token. PublisherSettings publisherSettings = new PublisherSettings(); publisherSettings.CreateTopicSettings.Headers = new Metadata { { "ClientVersion", "1.0.0" } }; publisherSettings.CreateTopicSettings.Timing = CallTiming.FromTimeout(TimeSpan.FromSeconds(5)); publisherSettings.CreateTopicSettings.CancellationToken = CancellationToken.None; // Override the above Timing and CancellationToken in the client-wide CallSettings; // the Headers are not overridden. publisherSettings.CallSettings = new CallSettings { Timing = CallTiming.FromDeadline(deadline), CancellationToken = CancellationToken.None, }; // Create the client with the configured publisherSettings PublisherClient client = PublisherClient.Create(settings: publisherSettings); // Format topicName from the projectId and topicId. string topicName = PublisherClient.FormatTopicName(projectId, topicId); // Call CreateTopic(). Override only the CancellationToken, using a per-RPC-method CallSettings. // The CallSettings used during this RPC invocation is: // * A custom "ClientVersion" header. // * A Timing deadline of 'deadline' (*not* the overridden 5-second timeout). // * The CancellationToken 'cancellationToken' (*not* CancellationToken.None). Topic topic = client.CreateTopic(topicName, new CallSettings { CancellationToken = cancellationToken }); // End sample }
public static void Automate(PublisherSettings settings, PublishingRecord record, IDictionary<string, bool> attachments, string spaceId) { try { // Launch a FireFox instance var driver = new FirefoxDriver(); // How long WebDriver will wait for an element to exist in the DOM before timeout driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 20)); // Go to login page, fill in credentials and click Login driver.Navigate().GoToUrl(string.Format("{0}/login", settings.Url)); driver.FindElement(By.Name("user[login]")).SendKeys(settings.UserName); driver.FindElement(By.Name("user[password]")).SendKeys(settings.Password); driver.FindElement(By.Name("commit")).Click(); // Go to ticket page, fill in summary and description driver.Navigate().GoToUrl(string.Format("{0}/spaces/{1}/tickets/new", settings.Url, spaceId)); driver.FindElement(By.Name("ticket[summary]")).SendKeys(record.Title); // append link-only attachment to defect summary string summary = record.Summary + ToEmbeddedLinks(attachments.Where(x => x.Value).Select(x => x.Key).ToArray()); driver.FindElement(By.Name("ticket[description]")).SendKeys(ReplaceMarkers(record.Summary)); // Add attachments int i = 0; foreach (var attachment in attachments.Where(x => !x.Value)) { // Click the "Add attachments" link driver.FindElement(By.ClassName("item-attachment")).Click(); // Fill file path to the file upload control driver.FindElement(By.Name(string.Format("ticket[new_attachment_attributes][{0}][file]", ++i))) .SendKeys(attachment.Key); } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public VerificationResult Verify(PublisherSettings settings) { var request = AssemblaUtils.CreateLoadSpacesRequest(settings); using (request.GetResponse()) return new VerificationResult(); }
private static FtpWebRequest CreateRequest( string uri, string method, PublisherSettings settings) { var ftpRequest = (FtpWebRequest) WebRequest.Create(uri); ftpRequest.Credentials = new NetworkCredential(settings.UserName, settings.Password); ftpRequest.UsePassive = settings.CustomSettingsFieldsValues["Mode"] == "Passive"; ftpRequest.EnableSsl = bool.Parse(settings.CustomSettingsFieldsValues["Ssl"]); ftpRequest.Timeout = settings.TimeoutInMillis; ftpRequest.Method = method; return ftpRequest; }
public VerificationResult Verify(PublisherSettings settings) { Context.ShowProgressIndicator(message: "Connecting to Assembla..."); try { var request = AssemblaUtils.CreateLoadSpacesRequest(settings); using (request.GetResponse()) return new VerificationResult(); } finally { Context.HideProgressIndicator(); } }
public VerificationResult Verify(PublisherSettings settings) { // Simulate connecting... Thread.Sleep(1000); if (settings.UserName == "qtrace" && settings.Password == "qtrace") return new VerificationResult(); throw new Exception("Not authenticated!"); }
public List<Field> GetDependentFields(PublisherSettings settings, string parentFieldName, string parentFieldValue) { throw new NotImplementedException(); }
public PublishingResult Publish( PublisherSettings settings, PublishingRecord record, IDictionary<string, string[]> fieldsValues, List<Attachment> attachments) { // Simulate connecting... Thread.Sleep(1000); return new PublishingResult { RecordId = new Random().Next(1, 100).ToString(), Message = "Published successfully!" }; }