public OctopusAsyncRepository(IOctopusAsyncClient client, RepositoryScope repositoryScope = null) { Client = client; Scope = repositoryScope ?? RepositoryScope.Unspecified(); Accounts = new AccountRepository(this); ActionTemplates = new ActionTemplateRepository(this); Artifacts = new ArtifactRepository(this); Backups = new BackupRepository(this); BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(this); CertificateConfiguration = new CertificateConfigurationRepository(this); Certificates = new CertificateRepository(this); Channels = new ChannelRepository(this); CommunityActionTemplates = new CommunityActionTemplateRepository(this); Configuration = new ConfigurationRepository(this); DashboardConfigurations = new DashboardConfigurationRepository(this); Dashboards = new DashboardRepository(this); Defects = new DefectsRepository(this); DeploymentProcesses = new DeploymentProcessRepository(this); Deployments = new DeploymentRepository(this); Environments = new EnvironmentRepository(this); Events = new EventRepository(this); FeaturesConfiguration = new FeaturesConfigurationRepository(this); Feeds = new FeedRepository(this); Interruptions = new InterruptionRepository(this); LibraryVariableSets = new LibraryVariableSetRepository(this); Lifecycles = new LifecyclesRepository(this); MachinePolicies = new MachinePolicyRepository(this); MachineRoles = new MachineRoleRepository(this); Machines = new MachineRepository(this); Migrations = new MigrationRepository(this); OctopusServerNodes = new OctopusServerNodeRepository(this); PerformanceConfiguration = new PerformanceConfigurationRepository(this); PackageMetadataRepository = new PackageMetadataRepository(this); ProjectGroups = new ProjectGroupRepository(this); Projects = new ProjectRepository(this); ProjectTriggers = new ProjectTriggerRepository(this); Proxies = new ProxyRepository(this); Releases = new ReleaseRepository(this); RetentionPolicies = new RetentionPolicyRepository(this); Schedulers = new SchedulerRepository(this); ServerStatus = new ServerStatusRepository(this); Spaces = new SpaceRepository(this); Subscriptions = new SubscriptionRepository(this); TagSets = new TagSetRepository(this); Tasks = new TaskRepository(this); Teams = new TeamsRepository(this); Tenants = new TenantRepository(this); TenantVariables = new TenantVariablesRepository(this); UserInvites = new UserInvitesRepository(this); UserRoles = new UserRolesRepository(this); Users = new UserRepository(this); VariableSets = new VariableSetRepository(this); Workers = new WorkerRepository(this); WorkerPools = new WorkerPoolRepository(this); ScopedUserRoles = new ScopedUserRoleRepository(this); UserPermissions = new UserPermissionsRepository(this); loadRootResource = new Lazy <Task <RootResource> >(LoadRootDocumentInner, true); loadSpaceRootResource = new Lazy <Task <SpaceRootResource> >(LoadSpaceRootDocumentInner, true); }
public void Setup() { _artifactDao = Substitute.For <IArtifactDao>(); Func <HttpRequestMessage> fakeFunc = () => FakeHttpMessageBuilder.CreateFakeHttpMessage(); _modelFactory = new ModelFactory(new ObjectDifferenceManager(), fakeFunc); _artifactRepo = new ArtifactRepository(_artifactDao, _modelFactory); _fixture = new Fixture(); }
/// <summary> /// Initializes a new instance of the ArtifactService class. /// </summary> /// <param name="unitOfWork">UnitOfWork information</param> public ArtifactService(UnitOfWork unitOfWork) { if (unitOfWork == null) { throw new ArgumentNullException(UnitOfWorkConst); } this.unitOfWork = unitOfWork; this.artifactRepository = new ArtifactRepository(this.unitOfWork); }
public async Task FakeSeedArtifacts() { await InitDb(); var artifactRepository = new ArtifactRepository(_db); var artifacts = new List <Artifact>(); artifacts.Add(new Artifact { Path = "CoolPlanePath", Title = "F16", FileName = "F16.pdf", FileType = "pdf", DateAdded = DateTime.Now, Active = true }); artifacts.Add(new Artifact { Path = "satellite", Title = "702 MP Satellite", FileName = "mpsatellite.pdf", FileType = "pdf", DateAdded = DateTime.Now, Active = true }); artifacts.Add(new Artifact { Path = "Brochure", Title = "Brochure", FileName = "Brochure.pdf", FileType = "pdf", DateAdded = DateTime.Now, Active = true }); artifacts.Add(new Artifact { Path = "MSF13", Title = "MSF13-0126", FileName = "msf13.png", FileType = "png", DateAdded = DateTime.Now, Active = true }); foreach (Artifact artifact in artifacts) { await artifactRepository.SaveAsync(artifact); } }
public static DataGridWorkspaceAuditService SetUpWorkspaceAuditService(IAuditLogObjectManagerFactory auditLogObjectManagerFactory) { var connectionFactory = TestUtilities.GetIntegrationConnectionFactory(); var loggerMock = TestUtilities.GetMockLogger(); var dataGridService = new DataGridService(auditLogObjectManagerFactory, new DataGridConditionBuilder(), new DataGridResponseAuditMapper(loggerMock.Object), loggerMock.Object); var artifactRepository = new ArtifactRepository(connectionFactory); var dataGridSettingsService = new DataGridSettingsService(artifactRepository, loggerMock.Object); var hourRepository = new HourRepository(connectionFactory); var dataGridWorkspaceAuditService = new DataGridWorkspaceAuditService(dataGridSettingsService, artifactRepository, dataGridService, hourRepository); return(dataGridWorkspaceAuditService); }
public OctopusAsyncRepository(IOctopusAsyncClient client) { this.Client = client; Accounts = new AccountRepository(client); ActionTemplates = new ActionTemplateRepository(client); Artifacts = new ArtifactRepository(client); Backups = new BackupRepository(client); BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client); CertificateConfiguration = new CertificateConfigurationRepository(client); Certificates = new CertificateRepository(client); Channels = new ChannelRepository(client); CommunityActionTemplates = new CommunityActionTemplateRepository(client); Configuration = new ConfigurationRepository(client); DashboardConfigurations = new DashboardConfigurationRepository(client); Dashboards = new DashboardRepository(client); Defects = new DefectsRepository(client); DeploymentProcesses = new DeploymentProcessRepository(client); Deployments = new DeploymentRepository(client); Environments = new EnvironmentRepository(client); Events = new EventRepository(client); FeaturesConfiguration = new FeaturesConfigurationRepository(client); Feeds = new FeedRepository(client); Interruptions = new InterruptionRepository(client); LibraryVariableSets = new LibraryVariableSetRepository(client); Lifecycles = new LifecyclesRepository(client); MachinePolicies = new MachinePolicyRepository(client); MachineRoles = new MachineRoleRepository(client); Machines = new MachineRepository(client); Migrations = new MigrationRepository(client); OctopusServerNodes = new OctopusServerNodeRepository(client); PerformanceConfiguration = new PerformanceConfigurationRepository(client); ProjectGroups = new ProjectGroupRepository(client); Projects = new ProjectRepository(client); ProjectTriggers = new ProjectTriggerRepository(client); Proxies = new ProxyRepository(client); Releases = new ReleaseRepository(client); RetentionPolicies = new RetentionPolicyRepository(client); Schedulers = new SchedulerRepository(client); ServerStatus = new ServerStatusRepository(client); Subscriptions = new SubscriptionRepository(client); TagSets = new TagSetRepository(client); Tasks = new TaskRepository(client); Teams = new TeamsRepository(client); Tenants = new TenantRepository(client); TenantVariables = new TenantVariablesRepository(client); UserRoles = new UserRolesRepository(client); Users = new UserRepository(client); VariableSets = new VariableSetRepository(client); Workers = new WorkerRepository(client); WorkerPools = new WorkerPoolRepository(client); }
/// <summary> /// /// </summary> /// <param name="reqparam"></param> /// <returns></returns> public RESPONSE_FINDARTIFACT FindArtifact(REQUEST_FINDARTIFACT reqparam) { var rsp = new RESPONSE_FINDARTIFACT(); IList <Artifact> artifact = null; using (var dbc = new AppDbContext()) { var repo = new ArtifactRepository(dbc); switch (reqparam.TargetType) { case FINDTARGET_SELECTOR.CATEGORY: var r = repo.FindByCategory(new Category { Id = reqparam.TargetId }); artifact = new List <Artifact>(r.ToArray().OrderBy(p => p.Title)); rsp.Success = true; break; case FINDTARGET_SELECTOR.TAG: var rtags = repo.FindByTag(new Tag { Id = reqparam.TargetId }); artifact = new List <Artifact>(rtags.ToArray().OrderBy(p => p.Title)); rsp.Success = true; break; default: rsp.Success = false; rsp.Message = "不明な取得条件です"; break; } } if (artifact != null) { foreach (var prop in artifact) { var mapped = Mapper.Map <DataArtifact>(prop); rsp.Artifacts.Add(mapped); } } return(rsp); }
public RESPONSE_LOADARTIFACT LoadArtifact(REQUEST_LOADARTIFACT reqparam) { var rsp = new RESPONSE_LOADARTIFACT(); using (var dbc = new AppDbContext()) { var repo = new ArtifactRepository(dbc); var artifact = repo.Load(reqparam.TargetArtifactId); var mapped = Mapper.Map <DataArtifact>(artifact); rsp.Artifact = mapped; var filePath = Path.Combine(artifact.FileMappingInfo.Workspace.PhysicalPath, artifact.FileMappingInfo.MappingFilePath); rsp.FilePath = filePath; } return(rsp); }
public OctopusRepository(IOctopusClient client) { this.Client = client; Feeds = new FeedRepository(client); Backups = new BackupRepository(client); Machines = new MachineRepository(client); MachineRoles = new MachineRoleRepository(client); MachinePolicies = new MachinePolicyRepository(client); Subscriptions = new SubscriptionRepository(client); Environments = new EnvironmentRepository(client); Events = new EventRepository(client); FeaturesConfiguration = new FeaturesConfigurationRepository(client); ProjectGroups = new ProjectGroupRepository(client); Projects = new ProjectRepository(client); Proxies = new ProxyRepository(client); Tasks = new TaskRepository(client); Users = new UserRepository(client); VariableSets = new VariableSetRepository(client); LibraryVariableSets = new LibraryVariableSetRepository(client); DeploymentProcesses = new DeploymentProcessRepository(client); Releases = new ReleaseRepository(client); Deployments = new DeploymentRepository(client); Certificates = new CertificateRepository(client); Dashboards = new DashboardRepository(client); DashboardConfigurations = new DashboardConfigurationRepository(client); Artifacts = new ArtifactRepository(client); Interruptions = new InterruptionRepository(client); ServerStatus = new ServerStatusRepository(client); UserRoles = new UserRolesRepository(client); Teams = new TeamsRepository(client); RetentionPolicies = new RetentionPolicyRepository(client); Accounts = new AccountRepository(client); Defects = new DefectsRepository(client); Lifecycles = new LifecyclesRepository(client); OctopusServerNodes = new OctopusServerNodeRepository(client); Channels = new ChannelRepository(client); ProjectTriggers = new ProjectTriggerRepository(client); Schedulers = new SchedulerRepository(client); Tenants = new TenantRepository(client); TagSets = new TagSetRepository(client); BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(client); ActionTemplates = new ActionTemplateRepository(client); CommunityActionTemplates = new CommunityActionTemplateRepository(client); }
private Artifact ReadByFileMappingInfo(FileMappingInfo fileMappingInfo, DbContext dbcontext) { var repo = new ArtifactRepository(dbcontext); return(repo.LoadByFileMappingInfo(fileMappingInfo)); }
static void Main(string[] args) { LogManager.Configuration = new XmlLoggingConfiguration($"{AppContext.BaseDirectory}nlog.config"); var logger = LogManager.GetLogger("openrmf_msg_checklist"); // Create a new connection factory to create a connection. ConnectionFactory cf = new ConnectionFactory(); // add the options for the server, reconnecting, and the handler events Options opts = ConnectionFactory.GetDefaultOptions(); opts.MaxReconnect = -1; opts.ReconnectWait = 2000; opts.Name = "openrmf-msg-checklist"; opts.Url = Environment.GetEnvironmentVariable("NATSSERVERURL"); opts.AsyncErrorEventHandler += (sender, events) => { logger.Info("NATS client error. Server: {0}. Message: {1}. Subject: {2}", events.Conn.ConnectedUrl, events.Error, events.Subscription.Subject); }; opts.ServerDiscoveredEventHandler += (sender, events) => { logger.Info("A new server has joined the cluster: {0}", events.Conn.DiscoveredServers); }; opts.ClosedEventHandler += (sender, events) => { logger.Info("Connection Closed: {0}", events.Conn.ConnectedUrl); }; opts.ReconnectedEventHandler += (sender, events) => { logger.Info("Connection Reconnected: {0}", events.Conn.ConnectedUrl); }; opts.DisconnectedEventHandler += (sender, events) => { logger.Info("Connection Disconnected: {0}", events.Conn.ConnectedUrl); }; // Creates a live connection to the NATS Server with the above options IConnection c = cf.CreateConnection(opts); // send back a checklist based on an individual ID EventHandler <MsgHandlerEventArgs> readChecklist = (sender, natsargs) => { try { // print the message logger.Info("New NATS subject: {0}", natsargs.Message.Subject); logger.Info("New NATS data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); Artifact art = new Artifact(); // setup the MongoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the MongoDB repo connection ArtifactRepository _artifactRepo = new ArtifactRepository(s); art = _artifactRepo.GetArtifact(Encoding.UTF8.GetString(natsargs.Message.Data)).Result; // when you serialize the \\ slash JSON chokes, so replace and regular \\ with 4 \\\\ art.rawChecklist = art.rawChecklist.Replace("\\", "\\\\"); // now serialize the class into a string to compress and send string msg = JsonConvert.SerializeObject(art); // publish back out on the reply line to the calling publisher logger.Info("Sending back compressed Checklist Data"); c.Publish(natsargs.Message.Reply, Encoding.UTF8.GetBytes(Compression.CompressString(msg))); c.Flush(); // flush the line } catch (Exception ex) { // log it here logger.Error(ex, "Error retrieving checklist record for artifactId {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } }; // send back a checklist listing based on the system ID EventHandler <MsgHandlerEventArgs> readSystemChecklists = (sender, natsargs) => { try { // print the message logger.Info("NATS Msg Checklists: {0}", natsargs.Message.Subject); logger.Info("NATS Msg system data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); IEnumerable <Artifact> arts; // setup the MondoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the database repo ArtifactRepository _artifactRepo = new ArtifactRepository(s); arts = _artifactRepo.GetSystemArtifacts(Encoding.UTF8.GetString(natsargs.Message.Data)).Result; // remove the rawChecklist as we do not need all that data, just the main metadata for listing foreach (Artifact a in arts) { a.rawChecklist = ""; } // now publish it back out w/ the reply subject string msg = JsonConvert.SerializeObject(arts); // publish back out on the reply line to the calling publisher logger.Info("Sending back compressed Checklist Data"); c.Publish(natsargs.Message.Reply, Encoding.UTF8.GetBytes(Compression.CompressString(msg))); c.Flush(); // flush the line } catch (Exception ex) { // log it here logger.Error(ex, "Error retrieving checklist record for artifactId {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } }; // The simple way to create an asynchronous subscriber // is to simply pass the event in. Messages will start // arriving immediately. logger.Info("setting up the openRMF checklist subscription"); IAsyncSubscription asyncNew = c.SubscribeAsync("openrmf.checklist.read", readChecklist); logger.Info("setting up the openRMF system checklist listing subscription"); IAsyncSubscription asyncNewSystemChecklists = c.SubscribeAsync("openrmf.system.checklists.read", readSystemChecklists); }
public void SetUp() { this.connectionFactory = TestUtilities.GetIntegrationConnectionFactory(); this.artifactRepository = new ArtifactRepository(connectionFactory); }
private IList <Item> TryFinishMission(MissionInProgress missionInProgress) { if (!missionInProgress.IsMissionFinished) { return(null); } lock (LockObject) { //mission is finished var mission = missionInProgress.myMission; var missionBonus = MissionAdministrator.GetOrAddMissionBonus(missionInProgress.character, mission.missionCategory, missionInProgress.MissionLevel, missionInProgress.myLocation.Agent); Logger.Info("++ Mission is finished " + missionInProgress); var successData = new Dictionary <string, object> { { k.bonusMultiplier, missionBonus.BonusMultiplier }, { "rawBonusMultiplier", (int)Math.Round(missionBonus.RawMultiplier * 100.0) }, { "bonusLevel", missionBonus.Bonus } }; var rewardItems = missionInProgress.SpawnRewardItems(out MissionLocation locationUsed); //online gang members var charactersToInform = missionInProgress.GetAffectedCharacters(); //mission participants var participants = missionInProgress.GetParticipantsVerbose().ToList(); participants = missionInProgress.FilterParticipants(participants); var ep = missionInProgress.CalculateEp(); var epDict = new Dictionary <string, object>(); var count = 0; foreach (var participant in participants) { var oneMansEp = 0; if (ep > 0) { oneMansEp = participant.AddExtensionPointsBoostAndLog(EpForActivityType.Mission, ep); } var oneEpEntry = new Dictionary <string, object> { { k.characterID, participant.Id }, { k.points, oneMansEp } }; epDict.Add("ep" + count++, oneEpEntry); } missionInProgress.GetRewardDivider(participants, out double rewardFraction, out int rewardDivider); successData.Add(k.nofGangMembers, participants.Count); missionInProgress.IncreaseStanding(rewardFraction, participants, charactersToInform, successData); //pay the fee missionInProgress.PayOutMission(rewardFraction, participants, charactersToInform, successData); var isTempTeleportEnabled = false; if (mission.MissionLevel == -1 || mission.behaviourType == MissionBehaviourType.Random) { //set teleport timer missionInProgress.EnableTeleportOnSuccess(participants, missionInProgress.myLocation.ZoneConfig.Id); isTempTeleportEnabled = true; } missionInProgress.WriteSuccessLogAllTargets(); missionInProgress.CleanUpAllTargets(); ArtifactRepository.DeleteArtifactsByMissionGuid(missionInProgress.missionGuid); //write mission log - mission completed missionInProgress.SetSuccessToMissionLog(true).ThrowIfError(); AdvanceBonusInGang(participants, missionInProgress); //remove mission MissionAdministrator.RemoveMissionInProgress(missionInProgress); if (mission.ValidSuccessMissionIdSet) { Logger.Info("++ Begin triggering a mission on success. triggered missionId:" + mission.MissionIdOnSuccess); Transaction.Current.OnCommited(() => { //trigger a new mission with the current location StartAsync(missionInProgress.character, missionInProgress.spreadInGang, mission.MissionIdOnSuccess, missionInProgress.myLocation, missionInProgress.MissionLevel); }); } //add to ram cache AddToFinishedMissions(missionInProgress.character, missionInProgress.MissionId); var resultDict = new Dictionary <string, object> { { k.mission, missionInProgress.ToDictionary() }, { "successData", successData }, { "teleportEnabled", (isTempTeleportEnabled ? 1 : 0) }, { k.extensionPoints, epDict }, }; //reply mission status if (rewardItems.Any()) { resultDict.Add(k.reward, rewardItems.ToDictionary("r", r => r.BaseInfoToDictionary())); if (locationUsed != null) { resultDict.Add("rewardLocation", locationUsed.id); } } missionInProgress.DeleteParticipants(); Transaction.Current.OnCommited(() => Message.Builder.SetCommand(Commands.MissionDone).WithData(resultDict).ToCharacters(charactersToInform).Send()); Logger.Info("++ mission is finished. " + missionInProgress); return(rewardItems); } }
static void Main(string[] args) { LogManager.Configuration = new XmlLoggingConfiguration($"{AppContext.BaseDirectory}nlog.config"); var logger = LogManager.GetLogger("openrmf_msg_system"); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("LOGLEVEL"))) // default { LogManager.Configuration.Variables["logLevel"] = "Warn"; } else if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("LOGLEVEL"))) { switch (Environment.GetEnvironmentVariable("LOGLEVEL")) { case "5": LogManager.Configuration.Variables["logLevel"] = "Critical"; break; case "4": LogManager.Configuration.Variables["logLevel"] = "Error"; break; case "3": LogManager.Configuration.Variables["logLevel"] = "Warn"; break; case "2": LogManager.Configuration.Variables["logLevel"] = "Info"; break; case "1": LogManager.Configuration.Variables["logLevel"] = "Debug"; break; case "0": LogManager.Configuration.Variables["logLevel"] = "Trace"; break; default: LogManager.Configuration.Variables["logLevel"] = "Warn"; break; } } LogManager.ReconfigExistingLoggers(); // Create a new connection factory to create a connection. ConnectionFactory cf = new ConnectionFactory(); // add the options for the server, reconnecting, and the handler events Options opts = ConnectionFactory.GetDefaultOptions(); opts.MaxReconnect = -1; opts.ReconnectWait = 2000; opts.Name = "openrmf-msg-system"; opts.Url = Environment.GetEnvironmentVariable("NATSSERVERURL"); opts.AsyncErrorEventHandler += (sender, events) => { logger.Info("NATS client error. Server: {0}. Message: {1}. Subject: {2}", events.Conn.ConnectedUrl, events.Error, events.Subscription.Subject); }; opts.ServerDiscoveredEventHandler += (sender, events) => { logger.Info("A new server has joined the cluster: {0}", events.Conn.DiscoveredServers); }; opts.ClosedEventHandler += (sender, events) => { logger.Info("Connection Closed: {0}", events.Conn.ConnectedUrl); }; opts.ReconnectedEventHandler += (sender, events) => { logger.Info("Connection Reconnected: {0}", events.Conn.ConnectedUrl); }; opts.DisconnectedEventHandler += (sender, events) => { logger.Info("Connection Disconnected: {0}", events.Conn.ConnectedUrl); }; // Creates a live connection to the NATS Server with the above options IConnection c = cf.CreateConnection(opts); // update all artifact records w/ the new title of the system // we save the title here for quicker data display when pulling a checklist record and metadata // openrmf.system.update.{systemGroupId} -- update the title in the body for the Artifacts (used for quicker reading) EventHandler <MsgHandlerEventArgs> updateSystemChecklistTitles = (sender, natsargs) => { try { // print the message logger.Info("NATS Msg Checklists: {0}", natsargs.Message.Subject); logger.Info("NATS Msg system data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); SystemGroup sg; // setup the MondoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the database repo for systems SystemGroupRepository _systemGroupRepo = new SystemGroupRepository(s); // setup the database repo for the Artifacts to cycle through ArtifactRepository _artifactRepo = new ArtifactRepository(s); string systemGroupId = natsargs.Message.Subject.Replace("openrmf.system.update.", ""); string systemTitle = Encoding.UTF8.GetString(natsargs.Message.Data); bool artifactUpdate; if (!string.IsNullOrEmpty(systemGroupId) && !string.IsNullOrEmpty(systemTitle)) { sg = _systemGroupRepo.GetSystemGroup(systemGroupId).Result; if (sg != null) { IEnumerable <Artifact> arts; arts = _artifactRepo.GetSystemArtifacts(systemGroupId).Result; foreach (Artifact a in arts) { // pull each record, update the systemTitle, save the artifact a.systemTitle = systemTitle; artifactUpdate = _artifactRepo.UpdateArtifact(a.InternalId.ToString(), a).Result; if (!artifactUpdate) { logger.Warn("Warning: did not update the system title in Artifacts {0}: {1}", a.InternalId.ToString(), systemTitle); } } } else { logger.Warn("Warning: Invalid System Group ID when updating the system title in artifacts {0}", natsargs.Message.Subject); } } else { logger.Warn("Warning: No System Group ID or Title when updating the system title in system {0} title {1}", natsargs.Message.Subject, Encoding.UTF8.GetString(natsargs.Message.Data)); } } catch (Exception ex) { // log it here logger.Error(ex, "Error retrieving system group record for system group id {0}", natsargs.Message.Subject); } }; // update the # of checklists up or down based on the add or delete // openrmf.system.count.add -- increment the # of checklists in a system // openrmf.system.count.delete -- decrement the # of checklists in a system EventHandler <MsgHandlerEventArgs> updateSystemChecklistCount = (sender, natsargs) => { try { // print the message logger.Info("NATS Msg Checklists: {0}", natsargs.Message.Subject); logger.Info("NATS Msg system data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); SystemGroup sg; // setup the MondoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the database repo SystemGroupRepository _systemGroupRepo = new SystemGroupRepository(s); sg = _systemGroupRepo.GetSystemGroup(Encoding.UTF8.GetString(natsargs.Message.Data)).Result; if (sg != null) { if (natsargs.Message.Subject.EndsWith(".add")) { var result = _systemGroupRepo.IncreaseSystemGroupCount(sg.InternalId.ToString()); } else if (natsargs.Message.Subject.EndsWith(".delete")) { var myresult = _systemGroupRepo.DecreaseSystemGroupCount(sg.InternalId.ToString()); } } else { logger.Warn("Warning: bad System Group ID when updating the checklist count {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } } catch (Exception ex) { // log it here logger.Error(ex, "Error retrieving system group record for system group id {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } }; // update the date for the last system compliance ran EventHandler <MsgHandlerEventArgs> updateSystemComplianceDate = (sender, natsargs) => { try { // print the message logger.Info("NATS Msg Checklists: {0}", natsargs.Message.Subject); logger.Info("NATS Msg system data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); SystemGroup sg; // setup the MondoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the database repo SystemGroupRepository _systemGroupRepo = new SystemGroupRepository(s); sg = _systemGroupRepo.GetSystemGroup(Encoding.UTF8.GetString(natsargs.Message.Data)).Result; if (sg != null) { sg.lastComplianceCheck = DateTime.Now; // update the date and get back to work! var result = _systemGroupRepo.UpdateSystemGroup(Encoding.UTF8.GetString(natsargs.Message.Data), sg); } else { logger.Warn("Warning: bad System Group ID when updating the system group for Compliance Generation date {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } } catch (Exception ex) { // log it here logger.Error(ex, "Error updating the system group record for the Compliance Generation date {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } }; // openrmf.system.compliance EventHandler <MsgHandlerEventArgs> getSystemGroupRecord = (sender, natsargs) => { try { // print the message logger.Info("NATS Msg Checklists: {0}", natsargs.Message.Subject); logger.Info("NATS Msg system data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); SystemGroup sg; // setup the MondoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the database repo SystemGroupRepository _systemGroupRepo = new SystemGroupRepository(s); sg = _systemGroupRepo.GetSystemGroup(Encoding.UTF8.GetString(natsargs.Message.Data)).Result; if (sg != null) { sg.rawNessusFile = ""; string msg = JsonConvert.SerializeObject(sg); // publish back out on the reply line to the calling publisher logger.Info("Sending back compressed System Group Record"); c.Publish(natsargs.Message.Reply, Encoding.UTF8.GetBytes(Compression.CompressString(msg))); c.Flush(); // flush the line } else { logger.Warn("Warning: bad System Group ID when requesting a System Group record {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); c.Publish(natsargs.Message.Reply, Encoding.UTF8.GetBytes(Compression.CompressString(JsonConvert.SerializeObject(new SystemGroup())))); c.Flush(); // flush the line } } catch (Exception ex) { // log it here logger.Error(ex, "Error updating the system group record for the Compliance Generation date {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } }; // send back a checklist based on an individual ID EventHandler <MsgHandlerEventArgs> readChecklist = (sender, natsargs) => { try { // print the message logger.Info("New NATS subject: {0}", natsargs.Message.Subject); logger.Info("New NATS data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); Artifact art = new Artifact(); // setup the MongoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the MongoDB repo connection ArtifactRepository _artifactRepo = new ArtifactRepository(s); art = _artifactRepo.GetArtifact(Encoding.UTF8.GetString(natsargs.Message.Data)).Result; // when you serialize the \\ slash JSON chokes, so replace and regular \\ with 4 \\\\ art.rawChecklist = art.rawChecklist.Replace("\\", "\\\\"); // now serialize the class into a string to compress and send string msg = JsonConvert.SerializeObject(art); // publish back out on the reply line to the calling publisher logger.Info("Sending back compressed Checklist Data"); c.Publish(natsargs.Message.Reply, Encoding.UTF8.GetBytes(Compression.CompressString(msg))); c.Flush(); // flush the line } catch (Exception ex) { // log it here logger.Error(ex, "Error retrieving checklist record for artifactId {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } }; // send back a checklist listing based on the system ID EventHandler <MsgHandlerEventArgs> readSystemChecklists = (sender, natsargs) => { try { // print the message logger.Info("NATS Msg Checklists: {0}", natsargs.Message.Subject); logger.Info("NATS Msg system data: {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); IEnumerable <Artifact> arts; // setup the MondoDB connection Settings s = new Settings(); if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("DBTYPE")) || Environment.GetEnvironmentVariable("DBTYPE").ToLower() == "mongo") { s.ConnectionString = Environment.GetEnvironmentVariable("DBCONNECTION"); s.Database = Environment.GetEnvironmentVariable("DB"); } // setup the database repo ArtifactRepository _artifactRepo = new ArtifactRepository(s); arts = _artifactRepo.GetSystemArtifacts(Encoding.UTF8.GetString(natsargs.Message.Data)).Result; // remove the rawChecklist as we do not need all that data, just the main metadata for listing foreach (Artifact a in arts) { a.rawChecklist = ""; } // now publish it back out w/ the reply subject string msg = JsonConvert.SerializeObject(arts); // publish back out on the reply line to the calling publisher logger.Info("Sending back compressed Checklist Data"); c.Publish(natsargs.Message.Reply, Encoding.UTF8.GetBytes(Compression.CompressString(msg))); c.Flush(); // flush the line } catch (Exception ex) { // log it here logger.Error(ex, "Error retrieving checklist record for artifactId {0}", Encoding.UTF8.GetString(natsargs.Message.Data)); } }; logger.Info("setting up the OpenRMF System Update on Title subscription"); IAsyncSubscription asyncSystemChecklistTitle = c.SubscribeAsync("openrmf.system.update.>", updateSystemChecklistTitles); logger.Info("setting up the OpenRMF System # checklists subscription"); IAsyncSubscription asyncSystemChecklistCount = c.SubscribeAsync("openrmf.system.count.>", updateSystemChecklistCount); logger.Info("setting up the OpenRMF System Compliance generation date"); IAsyncSubscription asyncSystemComplianceDate = c.SubscribeAsync("openrmf.system.compliance", updateSystemComplianceDate); logger.Info("setting up the OpenRMF System subscription"); IAsyncSubscription asyncSystemGroupRecord = c.SubscribeAsync("openrmf.system", getSystemGroupRecord); // moved from the msg checklist in v1.8 logger.Info("setting up the openRMF checklist subscription"); IAsyncSubscription asyncNew = c.SubscribeAsync("openrmf.checklist.read", readChecklist); logger.Info("setting up the openRMF system checklist listing subscription"); IAsyncSubscription asyncNewSystemChecklists = c.SubscribeAsync("openrmf.system.checklists.read", readSystemChecklists); }
protected override void Execute(CodeActivityContext context) { IWorkflowContext workflowContext = context.GetExtension <IWorkflowContext>(); ParameterStack pstack = context.GetValue <ParameterStack>(this.Parameter); var target = pstack.GetValue <FileMappingInfo>(ActivityParameterStack.TARGET); Mogami.Model.Category category = null; if (pstack.ContainsKey(ActivityParameterStack.CATEGORY)) { category = pstack.GetValue <Mogami.Model.Category>(ActivityParameterStack.CATEGORY); } var outputname = context.GetValue <string>(OutputName); // Guard Ensure.That(target).IsNotNull(); // FileMappingInfoがArtifactとの関連が存在する場合、 // 新規のArtifactは作成できないので、例外を投げる。 if (target.Id != 0L) { var r = new ArtifactRepository(workflowContext.DbContext); var a = r.LoadByFileMappingInfo(target); if (a != null) { throw new ApplicationException("すでに作成済みのFileMappingInfoです。"); } } if (category == null) { var catrepo = new CategoryRepository(workflowContext.DbContext); var appcat = catrepo.Load(3L); if (appcat == null) { throw new ApplicationException(); } } var tokens = target.MappingFilePath.Split(new string[] { @"\" }, StringSplitOptions.None); var sttokens = new Stack <string>(tokens); var title = sttokens.Pop(); // 現Verでは画像のみ、メタ情報を生成できる。 // (それ以外のファイルは、例外を投げる) if (target.Mimetype == "image/png") { var repo = new ImageArtifactRepository(workflowContext.DbContext); var entity = new ImageArtifact { Title = title, IdentifyKey = RandomAlphameric.RandomAlphanumeric(10), FileMappingInfo = target, ImageHeight = -1, // 未実装 ImageWidth = -1, // 未実装 }; if (category != null) { entity.Category = new T_Artifact2Category() { Artifact = entity, Category = category, OrderNo = 1 } } ; repo.Add(entity); pstack.SetValue(outputname, entity); } else { throw new ApplicationException("処理不能なMIMEタイプです"); } } #endregion メソッド }
public OctopusRepository(IOctopusClient client, RepositoryScope repositoryScope = null) { #if FULL_FRAMEWORK LocationChecker.CheckAssemblyLocation(); #endif Client = client; Scope = repositoryScope ?? RepositoryScope.Unspecified(); Accounts = new AccountRepository(this); ActionTemplates = new ActionTemplateRepository(this); Artifacts = new ArtifactRepository(this); Backups = new BackupRepository(this); BuiltInPackageRepository = new BuiltInPackageRepositoryRepository(this); BuildInformationRepository = new BuildInformationRepository(this); CertificateConfiguration = new CertificateConfigurationRepository(this); Certificates = new CertificateRepository(this); Channels = new ChannelRepository(this); CommunityActionTemplates = new CommunityActionTemplateRepository(this); Configuration = new ConfigurationRepository(this); DashboardConfigurations = new DashboardConfigurationRepository(this); Dashboards = new DashboardRepository(this); Defects = new DefectsRepository(this); DeploymentProcesses = new DeploymentProcessRepository(this); DeploymentSettings = new DeploymentSettingsRepository(this); Deployments = new DeploymentRepository(this); Environments = new EnvironmentRepository(this); Events = new EventRepository(this); FeaturesConfiguration = new FeaturesConfigurationRepository(this); Feeds = new FeedRepository(this); Interruptions = new InterruptionRepository(this); LibraryVariableSets = new LibraryVariableSetRepository(this); Lifecycles = new LifecyclesRepository(this); Licenses = new LicensesRepository(this); MachinePolicies = new MachinePolicyRepository(this); MachineRoles = new MachineRoleRepository(this); Machines = new MachineRepository(this); Migrations = new MigrationRepository(this); OctopusServerNodes = new OctopusServerNodeRepository(this); PerformanceConfiguration = new PerformanceConfigurationRepository(this); ProjectGroups = new ProjectGroupRepository(this); Projects = new ProjectRepository(this); Runbooks = new RunbookRepository(this); RunbookProcesses = new RunbookProcessRepository(this); RunbookSnapshots = new RunbookSnapshotRepository(this); RunbookRuns = new RunbookRunRepository(this); ProjectTriggers = new ProjectTriggerRepository(this); Proxies = new ProxyRepository(this); Releases = new ReleaseRepository(this); RetentionPolicies = new RetentionPolicyRepository(this); Schedulers = new SchedulerRepository(this); ServerStatus = new ServerStatusRepository(this); Spaces = new SpaceRepository(this); Subscriptions = new SubscriptionRepository(this); TagSets = new TagSetRepository(this); Tasks = new TaskRepository(this); Teams = new TeamsRepository(this); TelemetryConfigurationRepository = new TelemetryConfigurationRepository(this); Tenants = new TenantRepository(this); TenantVariables = new TenantVariablesRepository(this); UserRoles = new UserRolesRepository(this); Users = new UserRepository(this); VariableSets = new VariableSetRepository(this); Workers = new WorkerRepository(this); WorkerPools = new WorkerPoolRepository(this); ScopedUserRoles = new ScopedUserRoleRepository(this); UserPermissions = new UserPermissionsRepository(this); UserTeams = new UserTeamsRepository(this); UserInvites = new UserInvitesRepository(this); UpgradeConfiguration = new UpgradeConfigurationRepository(this); loadRootResource = new Lazy <RootResource>(LoadRootDocumentInner, true); loadSpaceRootResource = new Lazy <SpaceRootResource>(LoadSpaceRootDocumentInner, true); }