public ActionResult Index(HttpPostedFileBase file) { if (file.ContentLength > 0) { try { PublishSettings settings = new PublishSettings(file.InputStream); string fileName = settings.SiteName + ".publishSettings"; var path = Path.Combine(Environment.Instance.SiteReplicatorPath, fileName); file.SaveAs(path); Replicator.Instance.Repository.AddSite(path); // Trigger a deployment since we just added a new target site Replicator.Instance.TriggerDeployment(); } catch (IOException) { // todo: error handling } } return(RedirectToAction("Index")); }
public async Task PublishAsync <TEvent>(TEvent @event, PublishSettings <Event <TEvent> > settings = null) { using (var hubClient = _hubClientFactory.Create(EndpointId.Generate())) { await hubClient.PublishAsync(new Event <TEvent>(@event, _id), settings); } }
public static PublishSettings WithFileBackingStore(this PublishSettings publishSettings, string fileRepositoryPath = "MessageBackingStore") { publishSettings.BackingStoreMethod = BackingStoreMethod.FileSystem; publishSettings.FileRepositoryPath = fileRepositoryPath; return(publishSettings); }
public void PublishService_SendBatch_CallSerializer() { var moqProducerSettings = new ProducerSettings() { Producer = A.Fake <IProducer>() }; var moqSerializer = A.Fake <ISerializer <string> >(); var moqPublishSettings = new PublishSettings <string>() { Serializer = moqSerializer }; var moqOptionsSnapshot = A.Fake <IOptionsSnapshot <PublishSettings <string> > >(); A.CallTo(() => moqOptionsSnapshot.Get(A <string> ._)).Returns(moqPublishSettings); var publishSerivce = new PublishService <string>(moqProducerSettings, moqOptionsSnapshot, "topicName"); publishSerivce.SendBatch("test msg", "test msg1", "test msg2"); A.CallTo( () => moqSerializer.Serialize(A <string> .That.IsSameAs("test msg")) ).MustHaveHappenedOnceExactly(); A.CallTo( () => moqSerializer.Serialize(A <string> .That.IsSameAs("test msg1")) ).MustHaveHappenedOnceExactly(); A.CallTo( () => moqSerializer.Serialize(A <string> .That.IsSameAs("test msg2")) ).MustHaveHappenedOnceExactly(); }
public void PublishService_Send_CallProducer() { var moqProducer = A.Fake <IProducer>(); var moqProducerSettings = new ProducerSettings() { Producer = moqProducer }; var moqSerializer = A.Fake <ISerializer <string> >(); A.CallTo(() => moqSerializer.Serialize(A <string> ._)) .Returns(new byte[] { 0x0, 0x1, 0x2 }); var moqPublishSettings = new PublishSettings <string>() { Serializer = moqSerializer }; var moqOptionsSnapshot = A.Fake <IOptionsSnapshot <PublishSettings <string> > >(); A.CallTo(() => moqOptionsSnapshot.Get(A <string> ._)).Returns(moqPublishSettings); var publishSerivce = new PublishService <string>(moqProducerSettings, moqOptionsSnapshot, "topicName"); publishSerivce.Send("test msg"); A.CallTo(() => moqProducer.Send("topicName", A <byte[]> .That.IsSameSequenceAs(new byte[] { 0x0, 0x1, 0x2 }))) .MustHaveHappenedOnceExactly(); }
public ListenerBuilder <TCommand> Dispatch <TCommand>(TCommand command, PublishSettings <Event <TCommand> > publishSettings) { return(new ListenerBuilder <TCommand>( command, publishSettings, _hubClientFactory, _defaultSerializerFactory)); }
public void Can_Read_Publish_Settings_File() { var doc = OpenSampleFile(); var settings = new PublishSettings(doc, "sample.publishsettings"); Assert.Equal(settings.Name, "Sample"); Assert.Equal(settings.Id, "e5a20609-d80f-4d64-b0e6-dc75fa9a4250"); Assert.Equal(settings.Filename, "sample.publishsettings"); Assert.NotNull(settings.Certificate); }
public ListenerBuilder <TCommand> Dispatch <TCommand>(TCommand command, IEventSerializer <Event <TCommand> > serializer = null) { var settings = new PublishSettings <Event <TCommand> > { DestinationEndpointId = _commandEndpointId, Serializer = serializer }; return(_actionBuilder.Dispatch(command, settings)); }
public async Task PublishAsync <TEvent>(TEvent @event, IEventSerializer <Event <TEvent> > serializer = null) { var settings = new PublishSettings <Event <TEvent> > { DestinationEndpointId = _queryEndpointId, Serializer = serializer }; await _context.PublishAsync(@event, settings); }
public async Task LoadSampleFileShouldWork() { PublishSettings publishSettings = await PublishSettings.Load(GetTestFile("sample.PublishSettings")); Assert.NotNull(publishSettings); Assert.Equal("$deploy-test", publishSettings.Username); Assert.Equal("deploy-test", publishSettings.SiteName); Assert.Equal("testPw", publishSettings.Password); Assert.Equal("deploy-test.scm.hosting.local:443", publishSettings.ComputerName); }
public ListenerBuilder( TAction action, PublishSettings <Event <TAction> > publishSettings, IHubClientFactory hubClientFactory, IEventSerializerFactory defaultSerializerFactory) { _action = action; _publishSettings = publishSettings; _hubClientFactory = hubClientFactory; _defaultSerializerFactory = defaultSerializerFactory; }
public static IUnconfirmedMessageRepository Create(PublishSettings publishSettings) { switch (publishSettings.BackingStoreMethod) { case BackingStoreMethod.FileSystem: return(new UnconfirmedMessageFileRepository(publishSettings.FileRepositoryPath)); default: return(new UnconfirmedMessageMemoryRepository()); } }
public ChooseSingleStartTimeControl(PublishSettings settings) : this() { publishSettings = settings; SetPublishControlsVisibility(settings.Template.ShouldPublishAt, settings.Template.ShouldPublishAt); shouldOverridePublishAtCheckbox.Checked = false; explanationTextbox.Visible = false; }
private static PublishSettings ToPublishSettings(XElement element) { var settings = new PublishSettings { Id = Get(element, "Id"), Name = Get(element, "Name"), ServiceUrl = GetUri(element, "ServiceManagementUrl"), Certificate = GetCertificate(element, "ManagementCertificate") }; return(settings); }
public static PublishSettings UsePublisherConfirms(this PublishSettings publishSettings, string publisherId) { publishSettings.PublisherId = publisherId; publishSettings.UsePublisherConfirms = true; if (publishSettings.Confirmer == null) { publishSettings.Confirmer = new Confirmer(); } return(publishSettings); }
public async Task EmitAsync <TEvent>(TEvent @event, IEventSerializer <TEvent> serializer = null) { using (var hubClient = _hubClientFactory.Create(EndpointId.Generate())) { var settings = new PublishSettings <TEvent> { DestinationEndpointId = _id, Serializer = serializer }; await hubClient.PublishAsync(@event, settings); } }
// BL-10840 When the Harvester is getting AndroidPublishSettings, we want to use the settings // for BloomLibrary, since the book has been uploaded using those settings for text and audio // languages. private static HashSet <string> GetLanguagesToInclude(PublishSettings settings) { var dictToUse = Program.RunningHarvesterMode ? settings.BloomLibrary.TextLangs : settings.BloomPub.TextLangs; // The following problem can happen if running in Harvester and 'ForBloomLibrary' isn't set up. // So just use 'ForBloomPUB', which should be set up. if (dictToUse == null) { dictToUse = settings.BloomPub.TextLangs; } // If it's still null, bail. if (dictToUse == null) { return(new HashSet <string>()); } return(new HashSet <string>(dictToUse.Where(kvp => kvp.Value.IsIncluded()).Select(kvp => kvp.Key))); }
private string SetBaseOptions(string publishSettingsPath, out DeploymentBaseOptions deploymentBaseOptions) { PublishSettings publishSettings = new PublishSettings(publishSettingsPath); deploymentBaseOptions = new DeploymentBaseOptions { ComputerName = publishSettings.ComputerName, UserName = publishSettings.Username, Password = publishSettings.Password, AuthenticationType = publishSettings.UseNTLM ? "ntlm" : "basic", }; if (publishSettings.AllowUntrusted) { ServicePointManager.ServerCertificateValidationCallback = AllowCertificateCallback; } return publishSettings.SiteName; }
public string SaveAndPublish(string tcm) { string response = string.Empty; try { // Add tcm: prefix to id tcm = "tcm:" + tcm; // Get settings for publish preferences PublishSettings settings = this.Plugin.Settings.Get <PublishSettings>(); // Check if we are the user that is modifying this item var pageData = this.Client.Read(tcm, new ReadOptions()) as PageData; if (pageData != null) { // Save and checkin for publishing //this.Client.Save(pageData, null); //pageData = (PageData)this.Client.CheckIn(tcm, true, "Saved and published", new ReadOptions()); // Publish the page to the configured Pub Targets response = this.PublishPage(tcm, pageData, settings.PublishPrio ?? string.Empty, settings.PublishTargetNamesCsv ?? string.Empty); //this.Client.CheckOut(tcm, false, null); } else { throw new ArgumentException("Could save page, it is not checked out by user: " + tcm); } } catch (Exception ex) { throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message)); /* * StringBuilder sb = new StringBuilder(); * sb.AppendLine(ex.Message); * sb.AppendLine(ex.Source); * sb.AppendLine(ex.StackTrace); * return sb.ToString(); */ } return(response); }
private string SetBaseOptions(string publishSettingsPath, out DeploymentBaseOptions deploymentBaseOptions) { PublishSettings publishSettings = new PublishSettings(publishSettingsPath); deploymentBaseOptions = new DeploymentBaseOptions { ComputerName = publishSettings.ComputerName, UserName = publishSettings.Username, Password = publishSettings.Password, AuthenticationType = publishSettings.AuthenticationType }; if (publishSettings.AllowUntrusted) { ServicePointManager.ServerCertificateValidationCallback = AllowCertificateCallback; } return(publishSettings.SiteName); }
public void LoadPublishSettings_AllSettings_Works() { var input = @"{""audioVideo"": {""motion"":true, ""pageTurnDelay"":2500, ""format"":""feature"", ""playerSettings"": ""{\""lang\"":\""fr\"",\""imageDescriptions\"":true}""}, ""bloomPUB"": {""motion"": true, ""textLangs"": {""baa"":""Include"",""es"":""Exclude""}, ""audioLangs"": { ""baa"":""IncludeByDefault"",""es"":""ExcludeByDefault""}, ""signLangs"": { ""asl"":""Include""}}, ""epub"": {""howToPublishImageDescriptions"":1, ""removeFontSizes"":true}, ""bloomLibrary"": {""textLangs"": {""def"":""Include"",""xyz"":""Exclude"", ""abc"":""ExcludeByDefault""}, ""audioLangs"": { ""def"":""IncludeByDefault"",""xyz"":""ExcludeByDefault""}, ""signLangs"": { ""asl"":""Include""}}}" ; var ps = PublishSettings.FromString(input); Assert.That(ps.AudioVideo.Format, Is.EqualTo("feature")); Assert.That(ps.AudioVideo.Motion, Is.True); Assert.That(ps.AudioVideo.PageTurnDelay, Is.EqualTo(2500)); Assert.That(ps.AudioVideo.PlayerSettings, Is.EqualTo("{\"lang\":\"fr\",\"imageDescriptions\":true}")); Assert.That(ps.BloomPub.Motion, Is.True); Assert.That(ps.BloomPub.TextLangs["baa"], Is.EqualTo(InclusionSetting.Include)); Assert.That(ps.BloomPub.TextLangs["es"], Is.EqualTo(InclusionSetting.Exclude)); Assert.That(ps.BloomPub.AudioLangs["baa"], Is.EqualTo(InclusionSetting.IncludeByDefault)); Assert.That(ps.BloomPub.AudioLangs["es"], Is.EqualTo(InclusionSetting.ExcludeByDefault)); Assert.That(ps.BloomPub.SignLangs["asl"], Is.EqualTo(InclusionSetting.Include)); Assert.That(ps.Epub.HowToPublishImageDescriptions, Is.EqualTo(BookInfo.HowToPublishImageDescriptions.OnPage)); Assert.That(ps.Epub.RemoveFontSizes, Is.True); Assert.That(ps.BloomLibrary.TextLangs["def"], Is.EqualTo(InclusionSetting.Include)); Assert.That(ps.BloomLibrary.TextLangs["xyz"], Is.EqualTo(InclusionSetting.Exclude)); Assert.That(ps.BloomLibrary.TextLangs["abc"], Is.EqualTo(InclusionSetting.ExcludeByDefault)); Assert.That(ps.BloomLibrary.AudioLangs["def"], Is.EqualTo(InclusionSetting.IncludeByDefault)); Assert.That(ps.BloomLibrary.AudioLangs["xyz"], Is.EqualTo(InclusionSetting.ExcludeByDefault)); Assert.That(ps.BloomLibrary.SignLangs["asl"], Is.EqualTo(InclusionSetting.Include)); }
public static PublishSettings WithPublishRetryInterval(this PublishSettings publishSettings, int intevalMilliseconds) { publishSettings.PublishRetryInterval = intevalMilliseconds; return(publishSettings); }
/// <inheritdoc /> public DeploymentChangeSummary Deploy(PublishSettings settings) { if (settings == null) { throw new ArgumentNullException("settings"); } if (settings.SourcePath == null) { throw new ArgumentNullException("settings.SourcePath"); } DeploymentBaseOptions sourceOptions = new DeploymentBaseOptions(); DeploymentBaseOptions destOptions = this.GetBaseOptions(settings); FilePath sourcePath = settings.SourcePath.MakeAbsolute(_Environment); string destPath = settings.SiteName; destOptions.TraceLevel = settings.TraceLevel; destOptions.Trace += OnTraceEvent; DeploymentWellKnownProvider sourceProvider = DeploymentWellKnownProvider.ContentPath; DeploymentWellKnownProvider destProvider = DeploymentWellKnownProvider.Auto; //If a target path was specified, it could be virtual or physical if (settings.DestinationPath != null) { if (System.IO.Path.IsPathRooted(settings.DestinationPath.FullPath)) { // If it's rooted (e.g. d:\home\site\foo), use DirPath sourceProvider = DeploymentWellKnownProvider.DirPath; destProvider = DeploymentWellKnownProvider.DirPath; destPath = settings.DestinationPath.FullPath; } else { // It's virtual, so append it to what we got from the publish profile destPath += "/" + settings.DestinationPath.FullPath; } } //If the content path is a zip file, use the Package provider if (sourcePath.GetExtension().Equals(".zip", StringComparison.OrdinalIgnoreCase)) { // For some reason, we can't combine a zip with a physical target path if (destProvider == DeploymentWellKnownProvider.DirPath) { throw new Exception("A source zip file can't be used with a physical target path"); } sourceProvider = DeploymentWellKnownProvider.Package; } //Sync Options DeploymentSyncOptions syncOptions = new DeploymentSyncOptions { DoNotDelete = !settings.Delete, WhatIf = settings.WhatIf }; //Deploy _Log.Debug(Verbosity.Normal, "Deploying Website..."); _Log.Debug(Verbosity.Normal, String.Format("-siteName '{0}'", settings.SiteName)); _Log.Debug(Verbosity.Normal, String.Format("-destination '{0}'", settings.PublishUrl)); _Log.Debug(Verbosity.Normal, String.Format("-source '{0}'", sourcePath.FullPath)); _Log.Debug(""); using (var deploymentObject = DeploymentManager.CreateObject(sourceProvider, sourcePath.FullPath, sourceOptions)) { return deploymentObject.SyncTo(destProvider, destPath, destOptions, syncOptions); } }
public async Task Publish() { Console.WriteLine("Publish started..."); foreach (string file in Directory.EnumerateFiles(Directory.GetCurrentDirectory(), "*.csproj", SearchOption.AllDirectories)) { string fileName = Path.GetFileName(file); if (fileName == $"{_projectName}.csproj") { projectFile = fileName; projectFolder = Path.GetDirectoryName(file); } } if (string.IsNullOrEmpty(projectFile)) { Console.WriteLine("The project file cannot be found!"); return; } string profilePath = Path.IsPathRooted(_profile) ? _profile : Path.Combine(projectFolder, _profile); PublishSettings settings = JsonSerializer.Deserialize <PublishSettings>(await File.ReadAllTextAsync(profilePath)); XmlSerializer serializer = new(typeof(PublisherProject)); TextReader reader = new StringReader(await File.ReadAllTextAsync(Path.Combine(projectFolder, projectFile))); PublisherProject propertyGroup = (PublisherProject)serializer.Deserialize(reader); // Publish Process process = new(); process.StartInfo.FileName = "dotnet"; process.StartInfo.Arguments = $"publish {Path.Combine(projectFolder, projectFile)} -c Release -f {propertyGroup.PropertyGroup.TargetFramework}"; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); process.WaitForExit(); if (process.ExitCode != 0) { return; } // Stop service using (var client = new SshClient(settings.Host, settings.Username, settings.Password)) { client.Connect(); string commandStr = $"sc stop \"{settings.ServiceName}\""; Console.WriteLine(commandStr); SshCommand command = client.RunCommand(commandStr); Console.WriteLine(command.Result); client.Disconnect(); if (command.ExitStatus != 0 && command.ExitStatus != 1062) { return; } } // Upload files using (SftpClient client = new(settings.Host, settings.Username, settings.Password)) { client.Connect(); UploadDirectory(client, Path.Combine(projectFolder, "bin", "Release", propertyGroup.PropertyGroup.TargetFramework, "publish"), settings.ServerFolder); client.Disconnect(); } // Start service using (var client = new SshClient(settings.Host, settings.Username, settings.Password)) { client.Connect(); string commandStr = $"sc start \"{settings.ServiceName}\""; Console.WriteLine(commandStr); SshCommand command = client.RunCommand(commandStr); Console.WriteLine(command.Result); client.Disconnect(); if (command.ExitStatus != 0) { return; } } Console.WriteLine("Publish Succeeded."); }
public PublishOperation(Site localSite, string filename, ContentAndDbMigrationControl control) { _localSite = localSite; _publishSettings = localSite.PublishProfile; _writer = new StreamWriter(filename); _writer.AutoFlush = true; _control = control; }
private static void Main(string[] args) { var src = "../../../../Shipwreck.ClickOnce.Manifest.TestApp/bin/Release"; var applicationFiles = "../../../publish/Application Files/TestApp_1_2_3_4"; var pfx = "../../../../Shipwreck.ClickOnce.Manifest.TestApp/TestApp.pfx"; var pw = "password"; //string pfx = null, pw = null; { var settings = new ApplicationManifestSettings() { FromDirectory = src, ToDirectory = applicationFiles, GeneratesLauncher = true, Version = new Version(1, 2, 3, 5), DeleteDirectory = true, Overwrite = true, CertificateFileName = pfx, CertificatePassword = pw, }; settings.Include.Add("!**/*.xml"); settings.Include.Add("!System.Data.SQLite.dll.config"); new ApplicationManifestGenerator(settings).Generate(); } { var settings = new DeploymentManifestSettings() { FromDirectory = applicationFiles, ToDirectory = "../../../publish/", Overwrite = true, ApplicationName = "TestApp", Publisher = "Test Publisher", SuiteName = "Test Suite", Product = "Test Product", SupportUrl = "http://never.shipwreck.jp/support", ErrorReportUrl = "http://never.shipwreck.jp/errorReport", Install = true, CreateDesktopShortcut = true, CertificateFileName = pfx, CertificatePassword = pw, }; new DeploymentManifestGenerator(settings).Generate(); } { var settings = new PublishSettings() { FromDirectory = src, ToDirectory = "../../../publish/auto/", Version = new Version(2, 3, 4, 5), DeleteDirectory = true, Overwrite = true, ApplicationName = "TestApp2", Publisher = "Test Publisher", SuiteName = "Test Suite", Product = "Test Product", SupportUrl = "http://never.shipwreck.jp/support", ErrorReportUrl = "http://never.shipwreck.jp/errorReport", Install = true, CreateDesktopShortcut = true, CertificateFileName = pfx, CertificatePassword = pw, }.AddIncludes("!**/*.xml", "!System.Data.SQLite.dll.config"); new ApplicationPublisher(settings).Generate(); } Console.ReadKey(); }
public static void Initialize(string pubRoot) { settings = PublishSettings.Load (pubRoot); }
public static PublishSettings WithTimerCheckInteval(this PublishSettings publishSettings, int intevalMilliseconds) { publishSettings.TimerCheckInterval = intevalMilliseconds; return(publishSettings); }
public static PublishSettings WithTestNacks(this PublishSettings publishSettings, int testNacks) { publishSettings.TestNacks = testNacks; return(publishSettings); }
internal static void ImportSettingsFile(string settings, string pubRoot) { string oldroot = PublishManager.settings.RepoRoot; //save this always XmlSerializer pubSerializer = new XmlSerializer(typeof(PublishSettings)); if (File.Exists(settings) == false) return; TextReader r = new StreamReader(settings); PublishSettings s = (PublishSettings)pubSerializer.Deserialize(r); r.Close(); s.RepoRoot = oldroot; PublishManager.settings = s; s.Save(pubRoot); }
public PublishSettingsModel(string filePath) { _settings = new PublishSettings(filePath); }
public static PublishSettings WithGetBatchSize(this PublishSettings publishSettings, int getBatchSize) { publishSettings.GetStoredMessagesBatchSize = getBatchSize; return(publishSettings); }
public static PublishSettings WithMaxSuccessiveFailures(this PublishSettings publishSettings, int maxSuccessiveFailures) { publishSettings.MaxSuccessiveFailures = maxSuccessiveFailures; return(publishSettings); }
//Helers private DeploymentBaseOptions GetBaseOptions(PublishSettings settings) { DeploymentBaseOptions options = new DeploymentBaseOptions { ComputerName = settings.PublishUrl, UserName = settings.Username, Password = settings.Password, AuthenticationType = settings.NTLM ? "ntlm" : "basic" }; if (settings.AllowUntrusted) { ServicePointManager.ServerCertificateValidationCallback = OnCertificateValidation; } return options; }
public static IServiceBusConfigurator UsePublisherConfirms(this IServiceBusConfigurator configurator, PublishSettings publishSettings) { var confirmer = publishSettings.Confirmer; configurator.UseRabbitMq(conf => conf.UsePublisherConfirms(confirmer.RecordPublicationSuccess, confirmer.RecordPublicationFailure, publishSettings.TestNacks)); return(configurator); }
public static PublishSettings WithProcessBufferedMessagesInterval(this PublishSettings publishSettings, int intevalMilliseconds) { publishSettings.ProcessBufferedMessagesInterval = intevalMilliseconds; return(publishSettings); }