コード例 #1
0
        /// <summary>
        /// Builds a <see cref="FilterDefinition{BsonDocument}" /> corresponding to the <see cref="ArtifactId" /> supplied
        /// </summary>
        /// <param name="eventType">An <see cref="ArtifactId" /> of an event type</param>
        /// <returns>A <see cref="FilterDefinition{BsonDocument}" /> corresponding to the <see cref="ArtifactId" /></returns>
        public static FilterDefinition <BsonDocument> ToFilter(this ArtifactId eventType)
        {
            var builder = Builders <BsonDocument> .Filter;
            var filter  = builder.Eq(Constants.QUERY_EVENT_ARTIFACT, eventType.Value);

            return(filter);
        }
コード例 #2
0
ファイル: AggregateRoots.cs プロジェクト: dolittle/Runtime
    /// <inheritdoc/>
    public Task <AggregateRoot> IncrementVersionFor(
        IClientSessionHandle transaction,
        EventSourceId eventSource,
        ArtifactId aggregateRoot,
        AggregateRootVersion expectedVersion,
        AggregateRootVersion nextVersion,
        CancellationToken cancellationToken)
    {
        _logger.IncrementingVersionForAggregate(aggregateRoot, eventSource);
        ThrowIfNextVersionIsNotGreaterThanExpectedVersion(eventSource, aggregateRoot, expectedVersion, nextVersion);

        if (expectedVersion == AggregateRootVersion.Initial)
        {
            return(WriteFirstAggregateRootDocument(
                       transaction,
                       eventSource,
                       aggregateRoot,
                       expectedVersion,
                       nextVersion,
                       cancellationToken));
        }
        else
        {
            return(UpdateExistingAggregateRootDocument(
                       transaction,
                       eventSource,
                       aggregateRoot,
                       expectedVersion,
                       nextVersion,
                       cancellationToken));
        }
    }
コード例 #3
0
        /// <summary>
        /// Handle whispers to the scholar.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public override bool WhisperReceive(GameLiving source, GameLiving target, string text)
        {
            if (base.WhisperReceive(source, target, text))
            {
                return(true);
            }

            // ReSharper disable once UsePatternMatching
            GamePlayer player = source as GamePlayer;

            if (player == null || !(target is Scholar scholar))
            {
                return(false);
            }

            if (Step == 1 && text.ToLower() == ArtifactId.ToLower())
            {
                string reply = "Oh, the mysterious Stone of Atlantis. Do you have the scrolls on it? I've found a few that allude to its true nature, but haven't found anything with any detail.";
                scholar.TurnTo(player);
                scholar.SayTo(player, eChatLoc.CL_PopupWindow, reply);
                Step = 2;
                return(true);
            }

            return(false);
        }
コード例 #4
0
 /// <inheritdoc />
 public SingleEventTypeEventStream FetchAllEventsOfTypeAfter(ArtifactId eventType, CommitSequenceNumber commit)
 {
     using (var es = _database.GetContext())
     {
         return(GetStreamFromEvents(es.Events.Where(e => e.EventArtifact == eventType && e.CommitId > (long)commit.Value).OrderBy(e => e.CommitId)));
     }
 }
コード例 #5
0
        /// <summary>
        /// Handle whispers to the scholar.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public override bool WhisperReceive(GameLiving source, GameLiving target, string text)
        {
            if (base.WhisperReceive(source, target, text))
            {
                return(true);
            }

            // ReSharper disable once UsePatternMatching
            GamePlayer player = source as GamePlayer;

            if (player == null || !(target is Scholar scholar))
            {
                return(false);
            }

            if (Step == 1 && text.ToLower() == ArtifactId.ToLower())
            {
                string reply = "The Arms of the Winds! If I only had Anthos\' Fish Skin. It is important that I have the scales, since Anthos trapped the magic of the Arms of the Winds in the Skin. If you have lost the skin, and I hope you haven\'t, you will have to go find the scales again and bring them to me.";
                scholar.TurnTo(player);
                scholar.SayTo(player, eChatLoc.CL_PopupWindow, reply);
                Step = 2;
                return(true);
            }

            return(false);
        }
コード例 #6
0
 protected static Contracts.CommittedAggregateEvents.Types.CommittedAggregateEvent with_committed_event(
     string content,
     EventLogSequenceNumber event_log_sequence_number,
     ArtifactId event_type_id,
     ArtifactGeneration event_type_generation,
     bool isPublic)
 => new()
コード例 #7
0
    public override void Run()
    {
        WorkItemStore store     = Driver.TeamFoundationServer.GetService(typeof(WorkItemStore)) as WorkItemStore;
        ILinking      linking   = Driver.TeamFoundationServer.GetService(typeof(ILinking)) as ILinking;
        int           changeSet = 1;

        // Get URI for changeset
        ArtifactId changeSetId = new ArtifactId();

        changeSetId.Tool           = "VersionControl";
        changeSetId.ArtifactType   = "ChangeSet";
        changeSetId.ToolSpecificId = changeSet.ToString();
        string changeSetUri = LinkingUtilities.EncodeUri(changeSetId);

        // Get referencing artifacts for given changeset
        Artifact[] artifacts = linking.GetReferencingArtifacts(new string[] { changeSetUri }, null);

        foreach (Artifact artifact in artifacts)
        {
            Console.WriteLine(artifact.ToString());
            ArtifactId artifactId = LinkingUtilities.DecodeUri(artifact.Uri);
            if (String.Equals(artifactId.Tool, "WorkItemTracking", StringComparison.OrdinalIgnoreCase))
            {
                WorkItem wi = store.GetWorkItem(Convert.ToInt32(artifactId.ToolSpecificId));
                Console.WriteLine(wi);
            }
        }
    }
コード例 #8
0
ファイル: Cloudsong.cs プロジェクト: Los-Ojos/DOLSharp-1127
        /// <summary>
        /// Handle whispers to the scholar.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public override bool WhisperReceive(GameLiving source, GameLiving target, string text)
        {
            if (base.WhisperReceive(source, target, text))
            {
                return(true);
            }

            if (!(source is GamePlayer player) || !(target is Scholar scholar))
            {
                return(false);
            }

            if (Step == 1)
            {
                if (text.ToLower() == ArtifactId.ToLower())
                {
                    string reply = "Do you have the story that goes with Cloudsong? I\'d very much like to read it. If you don\'t, go, get the scrolls and use them. Then, when you\'ve translated them into a book, return the book to me, and I will give you the artifact. Do you have the [story]?";
                    scholar.TurnTo(player);
                    scholar.SayTo(player, eChatLoc.CL_PopupWindow, reply);
                    Step = 2;
                    return(true);
                }
            }

            if (text.ToLower() == "story" && Step > 1)
            {
                scholar.TurnTo(player);
                scholar.SayTo(player, eChatLoc.CL_PopupWindow,
                              "Well, hand me the story. If you don't have it, go out and get it!");
                return(true);
            }

            return(false);
        }
コード例 #9
0
        /// <summary>
        /// Handle whispers to the scholar.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public override bool WhisperReceive(GameLiving source, GameLiving target, string text)
        {
            if (base.WhisperReceive(source, target, text))
            {
                return(true);
            }

            GamePlayer player = (GamePlayer)source;

            if (player == null || !(target is Scholar scholar))
            {
                return(false);
            }

            if (Step == 1 && text.ToLower() == ArtifactId.ToLower())
            {
                string reply = "Oh, the mysterious Ring of Unyielding Will. Do you have the scrolls on it? I've found a few that allude to its true nature, but haven't found anything with any detail.";
                scholar.TurnTo(player);
                scholar.SayTo(player, eChatLoc.CL_PopupWindow, reply);
                Step = 2;
                return(true);
            }

            return(false);
        }
コード例 #10
0
        public static EventSourceKey get_event_source_key(EventSourceId event_source_id = null, ArtifactId artifact_id = null)
        {
            var es = event_source_id ?? EventSourceId.New();
            var a  = artifact_id ?? ArtifactId.New();

            return(new EventSourceKey(es, a));
        }
コード例 #11
0
        internal override void Export(string table)
        {
            base.Export(table);

            table = GetType().Name;

            var vals = new List <object>
            {
                Id,
                HfId.DBExport(),
                HfId_Slayer.DBExport(),
                SlayerRace.DBExport(),
                SlayerCaste.DBExport(HistoricalFigure.Castes),
                ArtifiactId_SlayerItem.DBExport(),
                ArtifactId_SlayerShooterItem.DBExport(),
                Cause.DBExport(Causes),
                SiteId.DBExport(),
                SubregionId.DBExport(),
                FeatureLayerId.DBExport(),
                ItemID.DBExport(),
                ArtifactId.DBExport(),
                ItemType.DBExport(Item.ItemTypes),
                ItemSubType.DBExport(Item.ItemSubTypes),
                Mat.DBExport(Item.Materials),
                BowItem.DBExport(),
                BowArtifactId.DBExport(),
                BowItemType.DBExport(Item.ItemTypes),
                BowItemSubType.DBExport(Item.ItemSubTypes),
                BowMat.DBExport(Item.Materials)
            };

            Database.ExportWorldItem(table, vals);
        }
コード例 #12
0
 /// <inheritdoc />
 public SingleEventTypeEventStream FetchAllEventsOfType(ArtifactId eventType)
 {
     using (var es = _database.GetContext())
     {
         return(GetStreamFromEvents(es.Events.Where(e => e.EventArtifact == eventType).OrderBy(e => e.CommitId)));
     }
 }
コード例 #13
0
        /// <inheritdoc />
        public SingleEventTypeEventStream FetchAllEventsOfType(ArtifactId eventType)
        {
            var sqlQuery = "SELECT * FROM c WHERE ARRAY_CONTAINS(c.events, { \"event_artifact\": \"" + eventType.Value + "\"}, true)";
            var query    = QueryCommitsFor(sqlQuery);
            var commits  = GetCommits(query, $"Fetching events of type: {eventType}");

            return(GetEventsFromCommits(commits, eventType));
        }
コード例 #14
0
        /// <inheritdoc />
        public SingleEventTypeEventStream FetchAllEventsOfTypeAfter(ArtifactId eventType, CommitSequenceNumber commit)
        {
            var sqlQuery = $"SELECT * FROM c WHERE ARRAY_CONTAINS(c.events, {{ \"event_artifact\": \"{ eventType.Value }\" }}, true) AND c.commit > {commit.Value}";
            var query    = QueryCommitsFor(sqlQuery);
            var commits  = GetCommits(query, $"Fetching events of type: {eventType} after { commit.Value }");

            return(GetEventsFromCommits(commits, eventType));
        }
コード例 #15
0
 public static CommittedEvent single() => new CommittedEvent(
     EventLogSequenceNumber.Initial,
     DateTimeOffset.UtcNow,
     EventSourceId.New(),
     execution_contexts.create(),
     new Artifact(ArtifactId.New(), ArtifactGeneration.First),
     false,
     "{\"something\":42}");
コード例 #16
0
 /// <inheritdoc />
 public SingleEventTypeEventStream GetUnprocessedEvents(ArtifactId eventType, CommittedEventVersion committedEventVersion)
 {
     using (var eventStore = _getEventStore())
     {
         var eventStream = eventStore.FetchAllEventsOfTypeAfter(eventType, committedEventVersion.Major);
         return(new SingleEventTypeEventStream(eventStream.Where(e => e.Version > committedEventVersion)));
     }
 }
コード例 #17
0
 public static CommittedEvent single(uint event_log_sequence_number) => new CommittedEvent(
     event_log_sequence_number,
     DateTimeOffset.UtcNow,
     EventSourceId.New(),
     execution_contexts.create(),
     new Artifact(ArtifactId.New(), ArtifactGeneration.First),
     false,
     "{\"something\":42}");
コード例 #18
0
ファイル: ArtifactPayloadActor.cs プロジェクト: lulzzz/Spin
        protected override Task OnActivate()
        {
            _artifactId = (ArtifactId)ActorKey.Value;

            _storage = _artifactStorageProvider.Create(_artifactId.Namespace)
                       .VerifyNotNull($"Namespace not found for {ActorKey.Value}");

            return(Task.CompletedTask);
        }
コード例 #19
0
ファイル: ArtifactStorage.cs プロジェクト: lulzzz/Spin
        public async Task Set(ArtifactPayload artifactPayload, CancellationToken token = default)
        {
            artifactPayload.VerifyNotNull(nameof(artifactPayload));

            ArtifactId artifactId = new ArtifactId(artifactPayload.Id);

            _logger.LogTrace($"{nameof(Set)}: Writing {artifactId}");
            await _dataLakeStore.Write(RealPath(artifactId), artifactPayload.ToBytes(), true, token);
        }
コード例 #20
0
ファイル: Project.cs プロジェクト: liebharc/BLMEdit
        public override bool Equals(object obj)
        {
            var coordinates = obj as MavenCoordinates;

            return(coordinates != null &&
                   WildCardEquals(GroupId, coordinates.GroupId) &&
                   ArtifactId.Equals(coordinates.ArtifactId, StringComparison.InvariantCultureIgnoreCase) &&
                   (Version == coordinates.Version || Version == "?" || coordinates.Version == "?"));
        }
コード例 #21
0
        /// <summary>
        /// Handle whispers to the scholar.
        /// </summary>
        /// <param name="source"></param>
        /// <param name="target"></param>
        /// <param name="text"></param>
        /// <returns></returns>
        public override bool WhisperReceive(GameLiving source, GameLiving target, string text)
        {
            if (base.WhisperReceive(source, target, text))
            {
                return(true);
            }

            if (!(source is GamePlayer player) || !(target is Scholar scholar))
            {
                return(false);
            }

            if (Step == 1 && text.ToLower() == ArtifactId.ToLower())
            {
                string reply = "The scholars have often remarked about the craftsmanship that went into these bracers. I\'m impressed. I don\'t think we can make anything to compare with it. Hmm. Well, I\'m here to study the lifestyles of Atlanteans through their written words, not their crafts. Hand me the Arbiter\'s Personal Papers please. If you don\'t have it, I suggest you hunt the creatures of Oceanus til you find it.";
                scholar.TurnTo(player);
                scholar.SayTo(player, eChatLoc.CL_PopupWindow, reply);
                Step = 2;
                return(true);
            }
            else if (Step == 3)
            {
                switch (text.ToLower())
                {
                case "strength":
                case "constitution":
                case "dexterity":
                case "quickness":
                case "casting":
                {
                    string versionId = $";;{text.ToLower()}";
                    Dictionary <string, ItemTemplate> versions = ArtifactMgr.GetArtifactVersions(ArtifactId, (eCharacterClass)player.CharacterClass.ID, player.Realm);
                    ItemTemplate template = versions[versionId];
                    if (template == null)
                    {
                        Log.Warn($"Artifact version {versionId} not found");
                        return(false);
                    }

                    if (GiveItem(scholar, player, ArtifactId, template))
                    {
                        string reply = "You have made your choice. Here is your bracer. Do not lose it. It is irreplaceable.";
                        scholar.TurnTo(player);
                        scholar.SayTo(player, eChatLoc.CL_PopupWindow, reply);
                        FinishQuest();
                        return(true);
                    }

                    return(false);
                }
                }

                return(false);
            }

            return(false);
        }
コード例 #22
0
        static IEnumerable <CommittedEventEnvelope> get_events_from(ArtifactId artifactId, CommitSequenceNumber commit)
        {
            var committed_event_streams = processors.committed_event_streams();
            var events = committed_event_streams.SelectMany(c => c.Events.Select(e => e.ToCommittedEventEnvelope(c.Sequence)))
                         .Where(e => e.Metadata.Artifact.Id == artifactId)
                         .OrderBy(c => c.Version);

            return(events.Where(e => e.Version.Major >= commit).ToList());
        }
コード例 #23
0
        public GetArtifactIdResponse GetArtifactID(GetArtifactIdRequest request)
        {
            //throw new NotImplementedException("test");
            var artifactId = new ArtifactId {
                Id = request.EMail
            };

            return(new GetArtifactIdResponse(artifactId));
        }
コード例 #24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CouldNotDeserializeEvent"/> class.
 /// </summary>
 /// <param name="artifact">The <see cref="ArtifactId"/> of the Artifact.</param>
 /// <param name="eventType">The Type of the event.</param>
 /// <param name="content">The content of the event.</param>
 /// <param name="sequenceNumber">The Events position in the event log.</param>
 /// <param name="ex">The catched exception which made deserialization impossible in the first place.</param>
 public CouldNotDeserializeEvent(
     ArtifactId artifact,
     Type eventType,
     string content,
     ulong sequenceNumber,
     Exception ex)
     : base($"Couldn't deserialize artifact '{artifact}' to event '{eventType}' with EventLogSequenceNumber '{sequenceNumber}' and content '{content}'. Original occurred exception:{Environment.NewLine}{ex}")
 {
 }
コード例 #25
0
        private void BuildJavaFiles()
        {
            var javaPath = $"{CurrentDirectory}/../native_library/android/dummyane/src/main/java";

            foreach (var subDir in new DirectoryInfo(javaPath).GetDirectories())
            {
                subDir.Delete(true);
            }

            foreach (var s in GroupId.Split("."))
            {
                javaPath = javaPath + "/" + s;
                if (!Directory.Exists(javaPath))
                {
                    Directory.CreateDirectory(javaPath);
                }
            }

            var artifactIdSafe = ArtifactId.Replace("-", "_");

            File.WriteAllText($"{javaPath}/DummyANE.java",
                              $"package {GroupId}.{artifactIdSafe};public class DummyANE {{}}");

            var startInfo = new ProcessStartInfo(Shell)
            {
                CreateNoWindow   = false,
                UseShellExecute  = false,
                WorkingDirectory = $"{CurrentDirectory}/../native_library/android",
                WindowStyle      = ProcessWindowStyle.Hidden,
                Arguments        = $"{Gradlew} clean"
            };

            try {
                using var exeProcess = Process.Start(startInfo);
                exeProcess?.WaitForExit();
            }
            catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                return;
            }

            startInfo.Arguments = $"{Gradlew} build";
            try {
                using var exeProcess = Process.Start(startInfo);
                exeProcess?.WaitForExit();
            }
            catch (Exception e) {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(e.Message);
                return;
            }

            Console.ResetColor();
        }
コード例 #26
0
    async Task <AggregateRootWithTenantScopedInstances> GetByArtifactIdFor(ArtifactId aggregateRootId, Func <TenantId, bool> shouldFetchForTenant)
    {
        if (!_aggregateRoots.TryGet(aggregateRootId, out var aggregateRoot))
        {
            aggregateRoot = new AggregateRoot(new AggregateRootId(aggregateRootId, ArtifactGeneration.First));
        }

        var instances = await GetFor(new[] { aggregateRoot }, shouldFetchForTenant).ConfigureAwait(false);

        return(instances.First());
    }
コード例 #27
0
ファイル: ArtifactController.cs プロジェクト: lulzzz/Spin
        public async Task <IActionResult> Get(string id)
        {
            ArtifactPayload?record = await _acticleStoreService.Get(ArtifactId.FromBase64(id));

            if (record == null)
            {
                return(NotFound());
            }

            return(Ok(record));
        }
コード例 #28
0
        int HandleArtifactOfType(ArtifactType artifactType, BoundedContextTopology boundedContextConfiguration, MutableAritfactsDictionary artifactsDictionary, List <string> nonMatchingArtifacts)
        {
            var targetProperty = artifactType.TargetPropertyExpression.GetPropertyInfo();

            var newArtifacts = 0;
            var artifacts    = _artifacts.Where(_ => artifactType.Type.IsAssignableFrom(_));

            foreach (var artifact in artifacts)
            {
                var feature = boundedContextConfiguration.FindMatchingFeature(artifact.Namespace, nonMatchingArtifacts);
                if (feature.Value != null)
                {
                    MutableArtifactsByTypeDictionary artifactsByType;
                    if (!artifactsDictionary.TryGetValue(feature.Key, out artifactsByType))
                    {
                        artifactsByType = artifactsDictionary[feature.Key] = new Dictionary <PropertyInfo, Dictionary <ArtifactId, ArtifactDefinition> >();
                    }

                    Dictionary <ArtifactId, ArtifactDefinition> mutableArtifacts;
                    if (!artifactsByType.TryGetValue(targetProperty, out mutableArtifacts))
                    {
                        mutableArtifacts = artifactsByType[targetProperty] = new Dictionary <ArtifactId, ArtifactDefinition>();
                    }

                    if (!mutableArtifacts.Any(_ => _.Value.Type.GetActualType() == artifact))
                    {
                        var artifactObject = new Dolittle.Artifacts.Artifact(ArtifactId.New(), ArtifactGeneration.First);
                        if (artifact.HasAttribute <ArtifactAttribute>())
                        {
                            artifactObject = (artifact.GetTypeInfo().GetCustomAttributes(typeof(ArtifactAttribute), false).First() as ArtifactAttribute).Artifact;
                        }

                        AddNewArtifact(artifactObject, artifact, mutableArtifacts, artifactType.TypeName);
                        newArtifacts++;
                    }
                    else
                    {
                        if (artifact.HasAttribute <ArtifactAttribute>())
                        {
                            var artifactObject = (artifact.GetTypeInfo().GetCustomAttributes(typeof(ArtifactAttribute), false).First() as ArtifactAttribute).Artifact;

                            var existingArtifact = mutableArtifacts.Single(_ => _.Value.Type.GetActualType() == artifact);
                            if (!existingArtifact.Key.Value.Equals(artifactObject.Id.Value))
                            {
                                mutableArtifacts.Remove(existingArtifact.Key);
                                AddNewArtifact(artifactObject, artifact, mutableArtifacts, artifactType.TypeName);
                                newArtifacts++;
                            }
                        }
                    }
                }
            }
            return(newArtifacts);
        }
コード例 #29
0
 /// <inheritdoc />
 public SingleEventTypeEventStream FetchAllEventsOfType(ArtifactId eventType)
 {
     return(new SingleEventTypeEventStream(FetchAllEvents().Where(_ => _serializer.FromJsonBytes <EventMetadata>(_.Event.Metadata).Event.Artifact.Id.Equals(eventType)).Select(_ => {
         var data = _serializer.PropertyBagFromJsonBytes(_.Event.Data);
         var metadata = _serializer.FromJsonBytes <EventMetadata>(_.Event.Metadata);
         return new CommittedEventEnvelope(
             metadata.Commit.Sequence,
             metadata.Event,
             data
             );
     })));
 }
コード例 #30
0
ファイル: ArtifactPayloadTests.cs プロジェクト: lulzzz/Spin
        public void GivenPayloadSource_ShouldRoundTrip()
        {
            ArtifactId artifactId = new ArtifactId("namespace/file.ext");
            string     payload    = "This is the payload";

            byte[] payloadBytes = Encoding.UTF8.GetBytes(payload);

            ArtifactPayload artifactPayload = payloadBytes.ToArtifactPayload(artifactId);

            byte[] fromPayload = artifactPayload.ToBytes();
            Enumerable.SequenceEqual(payloadBytes, fromPayload).Should().BeTrue();
        }