public int AddArtifact(Artifact artifact)
 {
     var client = ClientHelper.GetClient(authorizator);
     HttpResponseMessage response = client.Post(Url("Artifacts/"), new ObjectContent<Artifact>(artifact, JsonValueMediaTypeFormatter.DefaultMediaType));
     ClientHelper.HandleHTTPErrorCode(response);
     return response.Content.ReadAs<int>();
 }
Esempio n. 2
0
 public ReferenceInfo(Artifact.Artifact artifact)
 {
     path = artifact.FileInfo.FullName;
     fileName = artifact.FileInfo.Name;
     version = artifact.Version;
     this.artifact = artifact;
 }
Esempio n. 3
0
		public void TestSaveFields()
		{
            string sRepositoryUrl = TestServerInfo.CombineUrlWithSPServer("/sites/UnitTests/Docs/TestArtifact");
            string sTestDocUrl = TestServerInfo.CombineUrlWithSPServer("/sites/UnitTests/ContentTypeTests/SimpleTestDocForUploadingFields.docx");
            Repository r = new Repository(TestServerInfo.SPTestServerName, sRepositoryUrl);
            Artifact a = new Artifact(new Uri(sTestDocUrl), r);
		}
Esempio n. 4
0
 public void UpdateArtifact(string contextUId, string artifactUId, Artifact artifact)
 {
     if (artifactUId != artifact.ArtifactUId || contextUId != artifact.ContextUId)
         throw new WebFaultException(System.Net.HttpStatusCode.BadRequest);
     VerifyPermision(artifact);
     artifactRepository.SaveArtifact(artifact);
 }
Esempio n. 5
0
 public int AddArtifact(Artifact artifact)
 {
     VerifyPermision(artifact);
     artifactRepository.SaveArtifact(artifact);
     int count = UpdateCounters(artifact);
     return count;
 }
        public void GetById_Fails_If_throws_exception_or_returns_null()
        {
            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Desc",
                ImagePath = "none"
            };

            var repo = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            repo.Insert(artifact);

            var session = new BidSession()
            {
                Artifact = artifact,
                Date = DateTime.Now
            };

            var sut = ObjectFactory.Get<IRepository<BidSession, Guid>>();
            sut.Insert(session);

            var result = sut.GetById(session.Id);
            Assert.NotNull(result);
            Assert.AreEqual(session.Id,result.Id);
        }
        private void CreateBidSession(out Buyer currentBuyer, out BidSession bidSession)
        {
            var buyer = new Buyer()
            {
                Name = "Ertan",
                Surname = "Ergun"
            };
            var repoBuyer = ObjectFactory.Get<IRepository<Buyer, Guid>>();
            repoBuyer.Insert(buyer);

            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Desc",
                ImagePath = "none"
            };

            var repoArtifact = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            repoArtifact.Insert(artifact);

            var session = new BidSession()
            {
                Artifact = artifact,
                Date = DateTime.Now
            };

            var repoSession = ObjectFactory.Get<IRepository<BidSession, Guid>>();
            repoSession.Insert(session);

            bidSession = session;
            currentBuyer = buyer;
        }
        public void TestArtifactIsNotEqual()
        {
            Artifact artefact = new Artifact();
            artefact.ResourceUri = "https://repository.sonatype.org/service/local/repositories/ossrh-snapshot/content/org/openengsb/framework/openengsb-framework/2.6.0-SNAPSHOT/openengsb-framework-2.6.0-SNAPSHOT-src.zip";
            artefact.GroupId = "org.openengsb.framework";
            artefact.ArtifactId = "openengsb-framework";
            artefact.Version = "2.6.0-SNAPSHOT";
            artefact.Packaging = "zip";
            artefact.Extension = "zip";
            artefact.RepoId = "ossrh-snapshot";
            artefact.ContextId = "ossrh-snapshot";
            artefact.ArtifactLink = "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=ossrh-snapshot&amp;g=org.openengsb.framework&amp;a=openengsb-framework&amp;v=2.6.0-SNAPSHOT&amp;e=zip&amp;c=src";

            Artifact artefactNotEqual = new Artifact();
            artefactNotEqual.ResourceUri = "https://repository.sonatype.org/service/local/repositories/ossrh-snapshot/content/org/openengsb/framework/openengsb-framework/2.6.0-SNAPSHOT/openengsb-framework-2.6.0-SNAPSHOT-src.zip";
            artefactNotEqual.GroupId = "org.openengsb.framework";
            artefactNotEqual.ArtifactId = "openengsb-framework";
            artefactNotEqual.Version = "2.6.0-SNAPSHOT";
            artefactNotEqual.Packaging = "zip";
            artefactNotEqual.Extension = "zip";
            artefactNotEqual.RepoId = "ossrh-snapshot";
            artefactNotEqual.ContextId = "ossrh-snapshot";
            artefactNotEqual.ArtifactLink = "https://repository.sonatype.org/service/local/artifact/maven/redirect?r=ossrh-snapshot&amp;g=org.openengsb.framework&amp;a=openengsb-framework&amp;v=2.6.0-SNAPSHOT&amp;e=zip&amp;c=src";
            artefactNotEqual.PomLink = "DIFFRENT TO ARTEFACT1";
            Assert.AreNotEqual<Artifact>(artefact, artefactNotEqual);
        }
 public void TestIftwoArtifactWithDifferentSpezialVersionValuesReturn1WhenCompared()
 {
     Artifact ar = new Artifact();
     ar.Version = "3.0.0-SNAPSHOT-20130705";
     Artifact ar2 = new Artifact();
     ar2.Version = "3.0.0-SNAPSHOT-20130706";
     Assert.AreEqual(ar2.CompareTo(ar), 1);
 }
 public void TestIftwoArtifactWhereOneVersionIsNullReturnMinus1WhenCompared()
 {
     Artifact ar = new Artifact();
     ar.Version = "3.0.0";
     Artifact ar2 = new Artifact();
     ar2.Version = null;
     Assert.AreEqual(ar.CompareTo(ar2), 1);
 }
 public void TestIftwoArtifactWithDifferentValuesReturn1WhenCompared()
 {
     Artifact ar = new Artifact();
     ar.Version = "3.0.0";
     Artifact ar2 = new Artifact();
     ar2.Version = "2.0.0";
     Assert.AreEqual(ar.CompareTo(ar2), 1);
 }
 public void TestIftwoArtifactWhereTheOthersVersionIsNullReturn1WhenCompared()
 {
     Artifact ar = new Artifact();
     ar.Version = null;
     Artifact ar2 = new Artifact();
     ar2.Version = "2.0.0";
     Assert.AreEqual(ar.CompareTo(ar2), -1);
 }
Esempio n. 13
0
        public void RarityTest()
        {
            var common =	new Artifact(2 + (1 * 6) + (0 * 216));
            var uncommon =	new Artifact(2 + (0 * 6) + (0 * 216));
            var rare =		new Artifact(0 + (0 * 6) + (0 * 216));

            Assert.AreEqual(Rarity.Common, common.rarity);
            Assert.AreEqual(Rarity.Uncommon, uncommon.rarity);
            Assert.AreEqual(Rarity.Rare, rare.rarity);
        }
Esempio n. 14
0
        public static string GetArtifactReferenceFilePath(Artifact.Artifact artifact, string referenceFolder)
        {
            string artifactReferenceFolder = GetArtifactReferenceFolder(artifact, referenceFolder);
            Directory.CreateDirectory(artifactReferenceFolder);

            string artifactReferenceFilePath = Path.Combine(artifactReferenceFolder,
                String.Concat(artifact.ArtifactId, artifact.FileInfo.Extension));

            return artifactReferenceFilePath;
        }
Esempio n. 15
0
        public void JSON()
        {
            GameDB.InitCodecs();

            var obj = new Artifact(0);
            var json = Jboy.Json.WriteObject(obj);
            var objClone = Jboy.Json.ReadObject<Artifact>(json);

            Assert.IsTrue(obj.id == objClone.id);
        }
Esempio n. 16
0
 public static string GetArtifactReferenceFolder(Artifact.Artifact artifact, string referenceFolder)
 {
     //modified artifactFolder to match the .dll searched in NPanday.ProjectImporter.Digest.Model.Reference.cs
     string artifactFolder = Path.Combine(
         referenceFolder,
         string.Format("{0}\\{1}-{2}",
             artifact.GroupId,
             artifact.ArtifactId,
             artifact.Version));
     return artifactFolder;
 }
Esempio n. 17
0
        public void TestGetArtifactById( )
        {
            Repository repo = new Repository( "TestRepository", "LibraryUrl" );
            Artifact artifact = new Artifact( "myserver/MyArtifact.docx", repo );

            repo.AddArtifact( artifact );

			IArtifact foundArtifact = repo.GetArtifactById( "myserver/MyArtifact.docx", "" );
			Assert.IsNotNull(foundArtifact);
            Assert.AreEqual( foundArtifact.Id, artifact.Id );
        }
Esempio n. 18
0
		public void TestVersions()
		{
            string sRepositoryUrl = TestServerInfo.CombineUrlWithSPServer("/sites/UnitTests/Docs/TestArtifact");
            string sTestDocUrl = TestServerInfo.CombineUrlWithSPServer("/sites/UnitTests/Docs/TestArtifact/ThisDocumentHas5Versions.docx");
            Repository r = new Repository(TestServerInfo.SPTestServerName, sRepositoryUrl);
            Artifact a = new Artifact(new Uri(sTestDocUrl), r);

			Assert.IsNotNull(a.Versions);
			Assert.AreEqual("5", a.VersionLabel);
			Assert.AreEqual(5, a.Versions.Count);
		}
        public void Insert_Fails_If_throws_exception()
        {
            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Desc",
                ImagePath = "none"
            };

            var sut = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            sut.Insert(artifact);
        }
Esempio n. 20
0
    public static bool AnalyzeArtifact(Artifact artifact)
    {
        if (State.CurrentAP < State.AnalyzeArtifactAPCost) return false;

        State.CurrentAP -= State.AnalyzeArtifactAPCost;
        //artifact.Status = ArtifactStatus.Analyzing;
        artifact.Status = ArtifactStatus.Analyzed;
        State.Wiring += artifact.Wiring;
        State.Alloy += artifact.Alloy;
        State.Chips += artifact.Chips;
        return true;
    }
Esempio n. 21
0
        public void TestGetArtifactById_CaseInsensitivity( )
        {
            Repository repo = new Repository( "TestRepository", "LibraryUrl" );
            Artifact artifact = new Artifact( "MYSERVER/MyArtifact.docx", repo );

            repo.AddArtifact( artifact );

            IArtifact foundArtifact = repo.GetArtifactById( "myserver/MyArtifact.docx", "" );
            Assert.IsNotNull( foundArtifact );
            Assert.AreEqual( foundArtifact.Id, artifact.Id );

            foundArtifact = repo.GetArtifactById( "myserver/myartifact.docx", "" );
            Assert.IsNull( foundArtifact ); // want to keep case sensitivity for document part
        }
        public void Update_Fails_If_throws_exception()
        {
            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Desc",
                ImagePath = "none"
            };

            var sut = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            sut.Insert(artifact);

            artifact.Description = string.Format("{0} {1}", artifact.Description, "Updated");
            sut.Update(artifact);
        }
        public void CreateSession_Fails_if_throws_exception()
        {
            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Desc",
                ImagePath = "none"
            };

            var repo = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            repo.Insert(artifact);

            var sut = ObjectFactory.Get<IBidSessionManager>();
            sut.CreateSession(artifact);
        }
Esempio n. 24
0
        public static DateTime GetArtifactTimestamp(Artifact.Artifact artifact)
        {
            // try maven-metadata-${repoId}.xml or maven-metadata-local.xml
            string localRepoArtifactFolder = artifact.FileInfo.Directory.FullName;
            string[] metadataFilePaths = Directory.GetFiles(localRepoArtifactFolder, "maven-metadata-*.xml");

            DateTime metadataTimestamp;
            if (!TryGetArtifactTimestampFromMetadataFiles(metadataFilePaths, out metadataTimestamp))
            {
                // if that fails, get the file's timestamp)
                metadataTimestamp = new FileInfo(artifact.FileInfo.FullName).LastWriteTimeUtc;
            }

            return metadataTimestamp;
        }
        public override Color GetBackColor(Artifact issue, Color def)
        {
            if (issue.Type == ArtifactType.Defect)
                return Color.LightCoral;

            if (issue.Type == ArtifactType.Task)
            {
                if(issue.Parent.Type == ArtifactType.Defect)
                    return Color.MistyRose;

                return Color.LightGreen;
            }

            return def;
        }
        /// <summary>
        /// Function to save artifact details.
        /// </summary>
        /// <param name="artifact">artifact information.</param>
        public void InsertOrUpdate(Artifact artifact)
        {
            if (artifact == null)
            {
                throw new ArgumentNullException(ArtifactConstant);
            }

            if (artifact.ArtifactID == default(int))
            {
                this.unitOfWork.Context.Entry(artifact).State = EntityState.Added;
            }
            else
            {
                this.unitOfWork.Context.Entry(artifact).State = EntityState.Modified;
            }
        }
        public void Delete_Fails_If_throws_exception_or_returns_not_null()
        {
            var buyer = new Buyer()
            {
                Name = "Ertan",
                Surname = "Ergun"
            };
            var repoBuyer = ObjectFactory.Get<IRepository<Buyer, Guid>>();
            repoBuyer.Insert(buyer);

            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Desc",
                ImagePath = "none"
            };

            var repoArtifact = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            repoArtifact.Insert(artifact);

            var session = new BidSession()
            {
                Artifact = artifact,
                Date = DateTime.Now
            };

            var repoSession = ObjectFactory.Get<IRepository<BidSession, Guid>>();
            repoSession.Insert(session);

            var history = new BidHistory()
            {
                Buyer = buyer,
                Session = session,
                Bid = 1
            };

            var sut = ObjectFactory.Get<IRepository<BidHistory, Guid>>();
            sut.Insert(history);

            var result = sut.GetById(history.Id);
            Assert.NotNull(result);
            Assert.AreEqual(history.Id, result.Id);

            sut.Delete(history);
            result = sut.GetById(history.Id);
            Assert.Null(result);
        }
        public void SaveArtifact(Artifact artifact)
        {
            using (var context = new ScrumFactoryEntities(this.connectionString)) {

                Artifact oldArtifact = context.Artifacts.SingleOrDefault(a => a.ArtifactUId == artifact.ArtifactUId);

                if (oldArtifact == null)
                    context.Artifacts.AddObject(artifact);
                else {
                    context.AttachTo("Artifacts", oldArtifact);
                    context.ApplyCurrentValues<Artifact>("Artifacts", artifact);
                }

                context.SaveChanges();

            };
        }
        public void RegisterArtifact_Fails_if_cannot_create_new_artifact()
        {
            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Test",
                ImagePath = "image",
                IsDeleted = false
            };

            var sut = ObjectFactory.Get<IArtifactManager>();
            sut.RegisterArtifact(artifact);

            var repo = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            var result = repo.GetById(artifact.Id);

            Assert.NotNull(result);
            Assert.AreEqual(artifact.Id, result.Id);
        }
        public void Delete_Fails_If_throws_exception_or_returns_not_null()
        {
            var artifact = new Artifact()
            {
                Name = "Test",
                Description = "Desc",
                ImagePath = "none"
            };

            var sut = ObjectFactory.Get<IRepository<Artifact, Guid>>();
            sut.Insert(artifact);

            var result = sut.GetById(artifact.Id);
            Assert.NotNull(result);
            Assert.AreEqual(artifact.Id, result.Id);

            sut.Delete(artifact);
            result = sut.GetById(artifact.Id);
            Assert.Null(result);
        }
        public void Test_NewArtifactIsValid()
        {
            Artifact art = new Artifact();

            Assert.True(art != null);
        }
Esempio n. 32
0
 protected void ReceiveArtifactReward(int itemId)
 {
     artifactReward = new Artifact(itemId);
     Log("Received artifact reward: " + artifactReward.id);
 }
Esempio n. 33
0
    private void RefreshDesc(Artifact data)
    {
        this.mTxName.set_text(GameDataUtils.GetChineseContent(data.name, false));
        ResourceManager.SetSprite(this.mRectIcon.GetComponent <Image>(), GameDataUtils.GetIcon(this.mGodData.model));
        string text  = string.Empty;
        string text2 = string.Empty;

        Artifact.SystemparameterPair systemparameterPair = data.systemParameter.Find((Artifact.SystemparameterPair e) => e.key == EntityWorld.Instance.EntSelf.TypeID);
        if (systemparameterPair != null || data.system == 5)
        {
            switch (data.system)
            {
            case 1:
            {
                Skill skill = DataReader <Skill> .Get(systemparameterPair.value);

                if (skill != null)
                {
                    text  = "激活技能:" + GameDataUtils.GetChineseContent(skill.name, false);
                    text2 = GameDataUtils.GetChineseContent(skill.describeId, false);
                }
                break;
            }

            case 2:
            {
                Runes runes = DataReader <Runes> .Get(systemparameterPair.value);

                Runes_basic runes_basic = DataReader <Runes_basic> .Get(systemparameterPair.value);

                if (runes != null && runes_basic != null)
                {
                    text  = "激活符文:" + GameDataUtils.GetChineseContent(runes_basic.name, false);
                    text2 = GameDataUtils.GetChineseContent(runes.desc, false);
                }
                break;
            }

            case 3:
            {
                SystemOpen systemOpen = DataReader <SystemOpen> .Get(systemparameterPair.value);

                if (systemOpen != null)
                {
                    text2 = GameDataUtils.GetChineseContent(systemOpen.bewrite, false);
                }
                break;
            }

            case 4:
            {
                ArtifactSkill artifactSkill = DataReader <ArtifactSkill> .Get(systemparameterPair.value);

                if (artifactSkill != null)
                {
                    text  = "激活被动:" + GameDataUtils.GetChineseContent(artifactSkill.name, false);
                    text2 = GameDataUtils.GetChineseContent(artifactSkill.desc, false);
                }
                break;
            }

            case 5:
                text  = "激活属性:" + GameDataUtils.GetChineseContent(data.skillName, false);
                text2 = GameDataUtils.GetChineseContent(data.skillExplain, false);
                break;
            }
        }
        this.mTxTitle.set_text(text);
        this.mTxContent.set_text(text2);
    }
Esempio n. 34
0
        private void SetOptionAndArtifact(string key, string value)
        {
            SetOption(key, value);

            Artifact?.Invoke(this, new ArtifactEventArgs(key, value));
        }
Esempio n. 35
0
 public ExeAssembler(Artifact artifact, string sourceFullPath, string destinationFullPath, AssembleOptions options, TaskLoggingHelper log)
     : base(artifact, sourceFullPath, destinationFullPath, options, log)
 {
 }
        public void RemapIndicesVisitor_RemapsNestedFilesProperly()
        {
            // This run has a single result that points to a doubly nested file.
            var baselineRun = new Run
            {
                Tool = new Tool {
                    Driver = new ToolComponent {
                        Name = "Test Tool"
                    }
                },
                Artifacts = new List <Artifact>
                {
                    new Artifact {
                        Location = new ArtifactLocation {
                            Index = 0
                        }, Contents = new ArtifactContent {
                            Text = "1"
                        }
                    },
                    new Artifact {
                        Location = new ArtifactLocation {
                            Index = 1
                        }, Contents = new ArtifactContent {
                            Text = "1.2"
                        }, ParentIndex = 0
                    },
                    new Artifact {
                        Location = new ArtifactLocation {
                            Index = 2
                        }, Contents = new ArtifactContent {
                            Text = "1.2.3."
                        }, ParentIndex = 1
                    }
                },
                Results = new List <Result>
                {
                    new Result
                    {
                        Locations = new List <Location>
                        {
                            new Location
                            {
                                PhysicalLocation = new PhysicalLocation
                                {
                                    ArtifactLocation = new ArtifactLocation
                                    {
                                        Index = 2
                                    }
                                }
                            }
                        }
                    }
                }
            };

            // This run has a single result pointing to a single file location.
            var currentRun = new Run
            {
                Tool = new Tool {
                    Driver = new ToolComponent {
                        Name = "Test Tool"
                    }
                },
                Artifacts = new List <Artifact>
                {
                    new Artifact {
                        Location = new ArtifactLocation {
                            Index = 0
                        }, Contents = new ArtifactContent {
                            Text = "New"
                        }
                    },
                    new Artifact {
                        Location = new ArtifactLocation {
                            Index = 1
                        }, Contents = new ArtifactContent {
                            Text = "Child of new"
                        }, ParentIndex = 0
                    },
                },
                Results = new List <Result>
                {
                    new Result
                    {
                        Locations = new List <Location>
                        {
                            new Location
                            {
                                PhysicalLocation = new PhysicalLocation
                                {
                                    ArtifactLocation = new ArtifactLocation
                                    {
                                        Index = 0
                                    }
                                }
                            }
                        }
                    }
                }
            };

            Run mergedRun = currentRun.DeepClone();

            // How does this remapping work? First, we initialize the indices remapper
            // with a set of existing files (analagous to the files list of the most
            // recent log in a baselining situation). Next, visit a set of results
            // from the baseline itself, providing the historical set of file data
            // objects from the baseline. The visit does two things: 1) updates the
            // visitor files table with the superset of file data objects between
            // the baseline and current run, 2) updates individual results from the
            // baseline so that their file index values are correct.

            // 1. At this point the merged run consists of a copy of the current run.
            //    After visitor construction, we should see that the visitor's
            //    CurrentFiles property is equivalent to mergedRun.Files. The visitor
            //    has also been initialized with a dictionary that uses the complete
            //    file hierarchy as a key into the files array
            var visitor = new RemapIndicesVisitor(mergedRun.Artifacts, currentLogicalLocations: null);

            visitor.CurrentArtifacts.Should().BeEquivalentTo(mergedRun.Artifacts);
            visitor.RemappedArtifacts.Count.Should().Be(mergedRun.Artifacts.Count);


            // 2. We set HistoricalFiles to point to the old files array from the
            //    baseline run, then visit each baseline result. After each result
            //    visit, any file data objects (including parent files) for the
            //    result have been added to visitor.CurrentFiles, if missing. Each
            //    result fileIndex data is updated. We move the updated result
            //    objects to the merged run.

            // Various operations mutate state. We will make a copy so that we can
            // compare our ulitmate results to an unaltered original baseline.
            Run baselineRunCopy = baselineRun.DeepClone();

            visitor.HistoricalFiles = baselineRunCopy.Artifacts;
            foreach (Result result in baselineRunCopy.Results)
            {
                visitor.VisitResult(result);
                mergedRun.Results.Add(result);
            }

            // 3. After completing the results array visit, we'll grab the
            //    files array that represents all merged files from the runs.
            mergedRun.Artifacts = visitor.CurrentArtifacts;

            // The artifacts in the merged run are the union of the artifacts from the baseline and
            // current runs. In this test case, there are no artifacts in common between the two
            // runs, so the number of artifacts in the merged run is just the sum of the baseline
            // and current runs.
            mergedRun.Artifacts.Count.Should().Be(baselineRun.Artifacts.Count + currentRun.Artifacts.Count);

            // Every artifact in the merged run's artifacts array has an index that points to its
            // own location in the array, even though the artifacts that came from the baseline run
            // originally resided at a different index.
            for (int i = 0; i < mergedRun.Artifacts.Count; i++)
            {
                mergedRun.Artifacts[i].Location.Index.Should().Be(i);
            }

            // The artifacts from the current run are in the same place as before. The artifacts
            // from the baseline run have moved to the end of the merged array. Verify this by
            // matching up their text contents.
            for (int i = 0; i < currentRun.Artifacts.Count; i++)
            {
                int oldIndex = i;
                int newIndex = i;

                currentRun.Artifacts[oldIndex].Contents.Text.Should().Be(mergedRun.Artifacts[newIndex].Contents.Text);
            }

            for (int i = 0; i < baselineRun.Artifacts.Count; i++)
            {
                int oldIndex = i;
                int newIndex = i + currentRun.Artifacts.Count;

                baselineRun.Artifacts[oldIndex].Contents.Text.Should().Be(mergedRun.Artifacts[newIndex].Contents.Text);
            }

            // The artifact index in the merged run's results have been adjusted as well.
            for (int i = 0; i < currentRun.Results.Count; ++i)
            {
                int oldIndex = currentRun.Results[i].Locations[0].PhysicalLocation.ArtifactLocation.Index;
                int newIndex = mergedRun.Results[i].Locations[0].PhysicalLocation.ArtifactLocation.Index;

                mergedRun.Artifacts[newIndex].Contents.Text.Should().Be(currentRun.Artifacts[oldIndex].Contents.Text);
            }

            // Verify that the parent index chain for the nested artifacts was updated properly
            // Recall that visitor placed the artifacts from the baseline run at the end of the
            // merged run's artifacts array, and that in this test case, the artifacts in the
            // baseline run were arranged with the most nested artifact at the end.
            Artifact artifact = mergedRun.Artifacts[mergedRun.Artifacts.Count - 1];

            artifact.ParentIndex.Should().Be(3);
            artifact = mergedRun.Artifacts[artifact.ParentIndex];

            artifact.ParentIndex.Should().Be(2);
            artifact = mergedRun.Artifacts[artifact.ParentIndex];

            artifact.ParentIndex.Should().Be(-1);
        }
Esempio n. 37
0
 public static UserPrize FromArtifact(Artifact artifact) => default;
 // Used to trigger an effect upon consuming Ammunition.
 // Triggered: when consuming an Ammunition-type Artifact, after reducing its Quantity.
 // artifactConsumed - ammunition that is being consumed.
 public virtual void OnConsumed(Artifact artifactConsumed)
 {
 }
Esempio n. 39
0
        public void RemapIndicesVisitor_RemapsNestedFilesProperly()
        {
            // This run has a single result that points to a doubly nested file
            Run baselineRun = CreateRunWithNestedFilesForTesting();

            // This run has a single result pointing to a single file location
            var currentRun = new Run()
            {
                Tool = new Tool {
                    Driver = new ToolComponent {
                        Name = "Test Tool"
                    }
                },
                Artifacts = new List <Artifact>
                {
                    new Artifact {
                        Location = new ArtifactLocation {
                            Index = 0
                        }, Contents = new ArtifactContent {
                            Text = "New"
                        }
                    },
                },
                Results = new List <Result>
                {
                    new Result
                    {
                        Locations = new List <Location>
                        {
                            new Location
                            {
                                PhysicalLocation = new PhysicalLocation
                                {
                                    ArtifactLocation = new ArtifactLocation
                                    {
                                        Index = 0
                                    }
                                }
                            }
                        }
                    }
                }
            };

            Run mergedRun = currentRun.DeepClone();

            // How does this remapping work? First, we initialize the indices remapper
            // with a set of existing files (analagous to the files list of the most
            // recent log in a baselining situation). Next, visit a set of results
            // from the baseline itself, providing the historical set of file data
            // objects from the baseline. The visit does two things: 1) updates the
            // visitor files table with the superset of file data objects between
            // the baseline and current run, 2) updates individual results from the
            // baseline so that their file index values are correct.

            // 1. At this point the merged run consists of a copy of the current run.
            //    After visitor construction, we should see that the visitor's
            //    CurrentFiles property is equivalent to mergedRun.Files. The visitor
            //    has also been initialized with a dictionary that uses the complete
            //    file hierarchy as a key into the files array
            var visitor = new RemapIndicesVisitor(mergedRun.Artifacts);

            visitor.CurrentFiles.Should().BeEquivalentTo(mergedRun.Artifacts);
            visitor.RemappedFiles.Count.Should().Be(mergedRun.Artifacts.Count);


            // 2. We set HistoricalFiles to point to the old files array from the
            //    baseline run, then visit each baseline result. After each result
            //    visit, any file data objects (including parent files) for the
            //    result have been added to visitor.CurrentFiles, if missing. Each
            //    result fileIndex data is updated. We move the updated result
            //    objects to the merged run.

            // Various operations mutate state. We will make a copy so that we can
            // compare our ulitmate results to an unaltered original baseline
            var baselineRunCopy = baselineRun.DeepClone();

            visitor.HistoricalFiles = baselineRunCopy.Artifacts;
            foreach (Result result in baselineRunCopy.Results)
            {
                visitor.VisitResult(result);
                mergedRun.Results.Add(result);
            }

            // 3. After completing the results array visit, we'll grab the
            //    files array that represents all merged files from the runs.
            mergedRun.Artifacts = visitor.CurrentFiles;

            // We expect the merged files to be a superset of file data objects from the two runs
            mergedRun.Artifacts.Count.Should().Be(baselineRun.Artifacts.Count + currentRun.Artifacts.Count);

            // We expect that every merged file data has a corrected file index
            for (int i = 0; i < mergedRun.Artifacts.Count; i++)
            {
                mergedRun.Artifacts[i].Location.Index.Should().Be(i);
            }

            // We should see that the file index of the result we added should be pushed out by 1,
            // to account for the second run's file data objects being appended to the single
            // file data object in the first run.
            mergedRun.Artifacts[mergedRun.Results[0].Locations[0].PhysicalLocation.ArtifactLocation.Index].Contents.Text.Should()
            .Be(currentRun.Artifacts[currentRun.Results[0].Locations[0].PhysicalLocation.ArtifactLocation.Index].Contents.Text);

            // Similarly, we expect that all file data objects from the first run have been offset by one
            for (int i = 0; i < 3; i++)
            {
                baselineRun.Artifacts[i].Contents.Text.Should().Be(mergedRun.Artifacts[i + 1].Contents.Text);
            }

            // Finally, we should ensure that the parent index chain was updated properly on merging
            Artifact fileData = mergedRun.Artifacts[mergedRun.Results[1].Locations[0].PhysicalLocation.ArtifactLocation.Index];

            // Most nested
            fileData.ParentIndex.Should().Be(2);
            mergedRun.Artifacts[fileData.ParentIndex].ParentIndex.Should().Be(1);
            mergedRun.Artifacts[mergedRun.Artifacts[fileData.ParentIndex].ParentIndex].ParentIndex.Should().Be(-1);
        }
        public static bool TryResolve(Product product, Version version, OSPlatform os, out Artifact artifact)
        {
            var p            = product.Moniker;
            var downloadPath = $"{ArtifactsUrl}/downloads/{product}";
            var archive      = $"{p}-{version}-{OsMonikers.CurrentPlatformPackageSuffix()}.{product.Extension}";

            if (!product.PlatformDependant || version <= product.PlatformSuffixAfter)
            {
                archive = $"{p}-{version}.{product.Extension}";
            }

            var downloadUrl = $"{downloadPath}/{archive}";

            artifact = new Artifact(product, version, downloadUrl, ArtifactBuildState.Released, null);
            return(true);
        }
 private void SetCurrentData()
 {
     GodWeaponProgressManager.< SetCurrentData > c__AnonStoreyB6 <SetCurrentData> c__AnonStoreyB = new GodWeaponProgressManager.< SetCurrentData > c__AnonStoreyB6();
     this.CurSystemData    = null;
     this.CurGodWeaponData = null;
Esempio n. 42
0
 Task GetBudgetAsync([Dense] Artifact artifact, double relics, int currentLevel = 0)
 {
     relics       = relics.Clamp(0, double.MaxValue);
     currentLevel = currentLevel.Clamp(0, artifact.MaxLevel ?? int.MaxValue);
     return(ShowArtifactAsync(artifact, currentLevel, artifact.BudgetArtifact(relics, currentLevel)));
 }
Esempio n. 43
0
        private void MenuBrowser_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            if (e.Url.Scheme == "masterplan")
            {
                e.Cancel = true;

                if (e.Url.LocalPath == "new")
                {
                    OnNewProjectClicked();
                }

                if (e.Url.LocalPath == "open")
                {
                    OnOpenProjectClicked();
                }

                if (e.Url.LocalPath == "last")
                {
                    OnOpenLastProjectClicked();
                }

                if (e.Url.LocalPath == "delve")
                {
                    OnDelveClicked();
                }

                if (e.Url.LocalPath == "genesis")
                {
                    Creature c = new Creature();
                    c.Name = "New Creature";

                    Masterplan.UI.CreatureBuilderForm dlg = new Masterplan.UI.CreatureBuilderForm(c);
                    dlg.ShowDialog();
                }

                if (e.Url.LocalPath == "exodus")
                {
                    CreatureTemplate ct = new CreatureTemplate();
                    ct.Name = "New Template";

                    Masterplan.UI.CreatureTemplateBuilderForm dlg = new Masterplan.UI.CreatureTemplateBuilderForm(ct);
                    dlg.ShowDialog();
                }

                if (e.Url.LocalPath == "minos")
                {
                    Trap trap = new Trap();
                    trap.Name = "New Trap";
                    trap.Attacks.Add(new TrapAttack());

                    Masterplan.UI.TrapBuilderForm dlg = new Masterplan.UI.TrapBuilderForm(trap);
                    dlg.ShowDialog();
                }

                if (e.Url.LocalPath == "excalibur")
                {
                    MagicItem mi = new MagicItem();
                    mi.Name = "New Magic Item";

                    Masterplan.UI.MagicItemBuilderForm dlg = new Masterplan.UI.MagicItemBuilderForm(mi);
                    dlg.ShowDialog();
                }

                if (e.Url.LocalPath == "indiana")
                {
                    Artifact a = new Artifact();
                    a.Name = "New Artifact";

                    Masterplan.UI.ArtifactBuilderForm dlg = new Masterplan.UI.ArtifactBuilderForm(a);
                    dlg.ShowDialog();
                }

                if (e.Url.LocalPath == "manual")
                {
                    open_manual();
                }
            }
        }
Esempio n. 44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventMetadata"/> class.
 /// </summary>
 /// <param name="eventId">An <see cref="EventId"/> that uniquely identifies this event.</param>
 /// <param name="versionedEventSource">The <see cref="VersionedEventSource" /> that this event applies to.</param>
 /// <param name="correlationId">A <see cref="CorrelationId" /> to relate this event to other artifacts and actions within the system.</param>
 /// <param name="artifact">The <see cref="Artifact" /> that represents this event.</param>
 /// <param name="occurred">A timestamp in the form of a <see cref="DateTimeOffset" /> recording when the <see cref="IEvent" /> occurred.</param>
 /// <param name="originalContext">The <see cref="OriginalContext" /> of the <see cref="IEvent" />.</param>
 public EventMetadata(EventId eventId, VersionedEventSource versionedEventSource, CorrelationId correlationId, Artifact artifact, DateTimeOffset occurred, OriginalContext originalContext)
 {
     Id = eventId;
     VersionedEventSource = versionedEventSource;
     CorrelationId        = correlationId;
     Artifact             = artifact;
     Occurred             = occurred;
     OriginalContext      = originalContext;
 }
Esempio n. 45
0
        private static Run CreateRun(
            IEnumerable <string> analysisTargets,
            OptionallyEmittedData dataToInsert,
            OptionallyEmittedData dataToRemove,
            IEnumerable <string> invocationTokensToRedact,
            IEnumerable <string> invocationPropertiesToLog,
            string defaultFileEncoding = null,
            IDictionary <string, HashData> filePathToHashDataMap = null)
        {
            var run = new Run
            {
                Invocations     = new List <Invocation>(),
                DefaultEncoding = defaultFileEncoding
            };

            if (analysisTargets != null)
            {
                run.Artifacts = new List <Artifact>();

                foreach (string target in analysisTargets)
                {
                    Uri uri = new Uri(UriHelper.MakeValidUri(target), UriKind.RelativeOrAbsolute);

                    HashData hashData = null;
                    if (dataToInsert.HasFlag(OptionallyEmittedData.Hashes))
                    {
                        filePathToHashDataMap?.TryGetValue(target, out hashData);
                    }

                    var fileData = Artifact.Create(
                        new Uri(target, UriKind.RelativeOrAbsolute),
                        dataToInsert,
                        hashData: hashData);

                    var fileLocation = new ArtifactLocation
                    {
                        Uri = uri
                    };

                    fileData.Location = fileLocation;

                    // This call will insert the file object into run.Files if not already present
                    fileData.Location.Index = run.GetFileIndex(
                        fileData.Location,
                        addToFilesTableIfNotPresent: true,
                        dataToInsert: dataToInsert,
                        encoding: null,
                        hashData: hashData);
                }
            }

            var invocation = Invocation.Create(
                emitMachineEnvironment: dataToInsert.HasFlag(OptionallyEmittedData.EnvironmentVariables),
                emitTimestamps: !dataToRemove.HasFlag(OptionallyEmittedData.NondeterministicProperties),
                invocationPropertiesToLog);

            // TODO we should actually redact across the complete log file context
            // by a dedicated rewriting visitor or some other approach.

            if (invocationTokensToRedact != null)
            {
                invocation.CommandLine = Redact(invocation.CommandLine, invocationTokensToRedact);
                invocation.Machine     = Redact(invocation.Machine, invocationTokensToRedact);
                invocation.Account     = Redact(invocation.Account, invocationTokensToRedact);

                if (invocation.WorkingDirectory != null)
                {
                    invocation.WorkingDirectory.Uri = Redact(invocation.WorkingDirectory.Uri, invocationTokensToRedact);
                }

                if (invocation.EnvironmentVariables != null)
                {
                    string[] keys = invocation.EnvironmentVariables.Keys.ToArray();

                    foreach (string key in keys)
                    {
                        string value = invocation.EnvironmentVariables[key];
                        invocation.EnvironmentVariables[key] = Redact(value, invocationTokensToRedact);
                    }
                }
            }

            run.Invocations.Add(invocation);
            return(run);
        }
        private static OrderSensitiveValueComparisonList <Artifact> ConstructFilesChain(IList <Artifact> existingFiles, Artifact currentFile)
        {
            var fileChain = new OrderSensitiveValueComparisonList <Artifact>(Artifact.ValueComparer);

            int parentIndex;

            do
            {
                currentFile = currentFile.DeepClone();
                parentIndex = currentFile.ParentIndex;

                // Index information is entirely irrelevant for the identity of nested files,
                // as each element of the chain could be stored at arbitrary locations in
                // the run.files table. And so we elide this information.
                currentFile.ParentIndex = -1;
                if (currentFile.Location != null)
                {
                    currentFile.Location.Index = -1;
                }

                fileChain.Add(currentFile);

                if (parentIndex != -1)
                {
                    currentFile = existingFiles[parentIndex];
                }
            } while (parentIndex != -1);

            return(fileChain);
        }
Esempio n. 47
0
        void update_parcels()
        {
            ParcelList.Items.Clear();

            foreach (Parcel p in fPoint.Parcels)
            {
                string name = p.Name;
                if (name == "")
                {
                    name = "(undefined parcel)";
                }

                if (p.MagicItemID != Guid.Empty)
                {
                    if (Treasure.PlaceholderIDs.Contains(p.MagicItemID))
                    {
                        // Placeholder
                    }
                    else
                    {
                        MagicItem item = Session.FindMagicItem(p.MagicItemID, SearchType.Global);
                        if (item != null)
                        {
                            name += " (" + item.Info.ToLower() + ")";
                        }
                    }
                }

                if (p.ArtifactID != Guid.Empty)
                {
                    if (Treasure.PlaceholderIDs.Contains(p.ArtifactID))
                    {
                        // Placeholder
                    }
                    else
                    {
                        Artifact item = Session.FindArtifact(p.ArtifactID, SearchType.Global);
                        if (item != null)
                        {
                            name += " (" + item.Tier.ToString().ToLower() + " tier)";
                        }
                    }
                }

                ListViewItem lvi = ParcelList.Items.Add(name);
                lvi.Tag = p;

                if (p.Details != "")
                {
                    lvi.SubItems.Add(p.Details);
                }
                else
                {
                    lvi.SubItems.Add("(no details)");
                }

                Hero hero = null;
                if (p.HeroID != Guid.Empty)
                {
                    hero = Session.Project.FindHero(p.HeroID);
                }

                if (hero != null)
                {
                    lvi.SubItems.Add("Allocated to " + hero.Name);
                }
                else
                {
                    lvi.SubItems.Add("(not allocated to a PC)");
                }
            }

            if (ParcelList.Items.Count == 0)
            {
                ListViewItem lvi = ParcelList.Items.Add("(no parcels)");
                lvi.ForeColor = SystemColors.GrayText;
            }
        }
 public override Artifact VisitArtifact(Artifact node)
 {
     return(base.VisitArtifact(node));
 }
        public override PhysicalLocation VisitPhysicalLocation(PhysicalLocation node)
        {
            if (node.Region == null || node.Region.IsBinaryRegion)
            {
                goto Exit;
            }

            bool insertRegionSnippets      = _dataToInsert.HasFlag(OptionallyEmittedData.RegionSnippets);
            bool overwriteExistingData     = _dataToInsert.HasFlag(OptionallyEmittedData.OverwriteExistingData);
            bool insertContextCodeSnippets = _dataToInsert.HasFlag(OptionallyEmittedData.ContextRegionSnippets);
            bool populateRegionProperties  = _dataToInsert.HasFlag(OptionallyEmittedData.ComprehensiveRegionProperties);

            if (insertRegionSnippets || populateRegionProperties || insertContextCodeSnippets)
            {
                Region           expandedRegion;
                ArtifactLocation artifactLocation = node.ArtifactLocation;

                _fileRegionsCache = _fileRegionsCache ?? new FileRegionsCache(_run);

                if (artifactLocation.Uri == null && artifactLocation.Index >= 0)
                {
                    // Uri is not stored at result level, but we have an index to go look in run.Artifacts
                    // we must pick the ArtifactLocation details from run.artifacts array
                    Artifact artifactFromRun = _run.Artifacts[artifactLocation.Index];
                    artifactLocation = artifactFromRun.Location;
                }

                // If we can resolve a file location to a newly constructed
                // absolute URI, we will prefer that
                if (!artifactLocation.TryReconstructAbsoluteUri(_run.OriginalUriBaseIds, out Uri resolvedUri))
                {
                    resolvedUri = artifactLocation.Uri;
                }

                if (!resolvedUri.IsAbsoluteUri)
                {
                    goto Exit;
                }

                expandedRegion = _fileRegionsCache.PopulateTextRegionProperties(node.Region, resolvedUri, populateSnippet: insertRegionSnippets);

                ArtifactContent originalSnippet = node.Region.Snippet;

                if (populateRegionProperties)
                {
                    node.Region = expandedRegion;
                }

                if (originalSnippet == null || overwriteExistingData)
                {
                    node.Region.Snippet = expandedRegion.Snippet;
                }
                else
                {
                    node.Region.Snippet = originalSnippet;
                }

                if (insertContextCodeSnippets && (node.ContextRegion == null || overwriteExistingData))
                {
                    node.ContextRegion = _fileRegionsCache.ConstructMultilineContextSnippet(expandedRegion, resolvedUri);
                }
            }

Exit:
            return(base.VisitPhysicalLocation(node));
        }
Esempio n. 50
0
 public DllAssembler(Artifact artifact, string sourceFullPath, string destinationFullPath, AssembleOptions options, TaskLoggingHelper log, GacUtil gac)
     :   base(artifact, sourceFullPath, destinationFullPath, options, log)
 {
     m_gac = gac;
 }
Esempio n. 51
0
        public void Artifact_Create_NullUri()
        {
            Action action = () => { Artifact.Create(null, OptionallyEmittedData.None); };

            action.Should().Throw <ArgumentNullException>();
        }
Esempio n. 52
0
        public void Artifact_DeserializeSingleFileRole()
        {
            Artifact actual = JsonConvert.DeserializeObject("{\"roles\":[\"analysisTarget\"]}", typeof(Artifact)) as Artifact;

            actual.Roles.Should().Be(ArtifactRoles.AnalysisTarget);
        }
Esempio n. 53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CommandRequest"/> class.
 /// </summary>
 /// <param name="correlationId"><see cref="CorrelationId"/> for the request.</param>
 /// <param name="artifactId"><see cref="ArtifactId">Identifier</see> of the command.</param>
 /// <param name="generation"><see cref="ArtifactGeneration">Generation</see> of the command.</param>
 /// <param name="content">Content of the command.</param>
 public CommandRequest(CorrelationId correlationId, ArtifactId artifactId, ArtifactGeneration generation, IDictionary <string, object> content)
 {
     CorrelationId = correlationId;
     Type          = new Artifact(artifactId, generation);
     Content       = content;
 }
Esempio n. 54
0
        public void Artifact_DeserializeMultipleFileRoles()
        {
            Artifact actual = JsonConvert.DeserializeObject("{\"roles\":[\"responseFile\",\"resultFile\"]}", typeof(Artifact)) as Artifact;

            actual.Roles.Should().Be(ArtifactRoles.ResponseFile | ArtifactRoles.ResultFile);
        }
Esempio n. 55
0
 protected string GetDestinationFullPath(Artifact artifact)
 {
     return(Path.Combine(Options.OutputFolder, artifact.ProjectRelativePath));
 }
Esempio n. 56
0
        public void Awake()
        {
            Debug.Log("MVP: Proceeding to check for mod compatibility...");
            //Check if Mods are loaded.
            hasClayMan     = AssetLoaderAndChecker.CheckForMod("com.Moffein.ClayMen");
            hasAncientWisp = AssetLoaderAndChecker.CheckForMod("com.Moffein.AncientWisp");
            hasArchWisp    = AssetLoaderAndChecker.CheckForMod("com.Nebby1999.ArchaicWisps");
            hasMysticItems = AssetLoaderAndChecker.CheckForMod("com.themysticsword.mysticsitems");
            Debug.Log("MVP: Mod Compat Checker finished.");
            //Register Hooks
            Debug.Log("MVP: Proceeding to create custom hooks...");
            RegisterHooks();
            Debug.Log("MVP: Hook creation finished.");
            //Load Monster Variant Assets
            Debug.Log("MVP: Proceeding to load Assets...");
            AssetLoaderAndChecker.LoadAssets();
            //Initializes Config
            Debug.Log("MVP: Proceeding to initialize the Config File.");
            ConfigLoader.SetupConfigLoader(Config);
            //Initializes variant spawn chances
            ConfigLoader.ReadConfig(Config);
            Debug.Log("MVP: Config creation finished.");
            //Make sure config values aren't invalid.
            if (ConfigLoader.EnableConfigcheck)
            {
                Debug.Log("MVP: " + ConfigLoader.EnableConfigCheckConfig.Definition.Key + "Is set to True, proceeding to check for bad values in the config...");
                AssetLoaderAndChecker.PreventBadValues(Config);
            }
            else
            {
                Debug.Log("MVP: " + ConfigLoader.EnableConfigCheckConfig.Definition.Key + "Is set to False, skipping to skill registration...");
            }
            //Registers skills
            Debug.Log("MVP: Proceeding to register Monster Variants Skills...");
            SubClasses.Skills.CustomSkills.RegisterSkills();
            Debug.Log("MVP: Monster Variants Skills registered...");
            //Register Artifact of Variance
            if (ConfigLoader.EnableArtifactOfVariance)
            {
                Debug.Log("MVP: Proceeding to Register the Artifact of Variance");
                Artifact.InitializeArtifact();
                Debug.Log("MVP: Artifact Registered...");
            }
            Debug.Log("MVP: Proceeding to register prefabs");
            //Registers Prefabs... hopefully?
            var Prefabs = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(PrefabBase)));

            foreach (var prefabType in Prefabs)
            {
                PrefabBase prefab = (PrefabBase)System.Activator.CreateInstance(prefabType);
                prefab.Init();
            }
            //Initializes custom items for monster variants, thanks Komrade for the boilerplate! <3
            var ItemTypes = Assembly.GetExecutingAssembly().GetTypes().Where(type => !type.IsAbstract && type.IsSubclassOf(typeof(MVPItemBase)));

            foreach (var itemType in ItemTypes)
            {
                MVPItemBase item = (MVPItemBase)System.Activator.CreateInstance(itemType);

                if (ValidateItem(item, Items))
                {
                    item.Init();
                }
            }
            //main hook
            On.RoR2.DeathRewards.OnKilledServer += (orig, self, DamageReport) => {
                foreach (VariantHandler enemy in DamageReport.victimBody.GetComponents <VariantHandler>())
                {
                    if (enemy.isVariant && (DamageReport.victimTeamIndex == (TeamIndex)2))
                    {
                        if (ConfigLoader.CertainVariantsSpawnMoreEnemies)
                        {
                            TrySpawnEnemy(DamageReport.victimBody);
                        }
                        if (ConfigLoader.EnableItemRewards)
                        {
                            if (Run.instance.isRunStopwatchPaused && ConfigLoader.HiddenRealmItemdropBehavior != "Unchanged")
                            {
                                if (ConfigLoader.HiddenRealmItemdropBehavior == "Halved")
                                {
                                    int rng = UnityEngine.Random.Range(1, 20);
                                    if (rng > 10)
                                    {
                                        ExtraRewards.TryExtraReward(enemy, DamageReport.victimBody, DamageReport.attackerBody);
                                    }
                                }
                                else //(Hidden Realm item drop behavior is "Never")
                                {
                                }
                            }
                            else
                            {
                                ExtraRewards.TryExtraReward(enemy, DamageReport.victimBody, DamageReport.attackerBody);
                            }
                        }
                        if (ConfigLoader.EnableGoldRewards)
                        {
                            uint multipliedGold = MultiplyGold.MultiplyMoney(self.goldReward, enemy);
                            self.goldReward = multipliedGold;
                        }
                        if (ConfigLoader.EnableXPRewards)
                        {
                            uint multipliedXP = MultiplyXP.MultiplyExperience(self.expReward, enemy);
                            self.expReward = multipliedXP;
                        }
                    }
                }
                orig(self, DamageReport);
            };
        }
        private Stream GetContentStream(Uri uri, out Encoding encoding)
        {
            Stream stream = null;

            encoding = null;
            string           failureReason = null;
            IList <Artifact> files         = _currentV2Run.Artifacts;

            if (uri != null && files != null && _v1FileKeyToV2IndexMap != null)
            {
                if (_v1FileKeyToV2IndexMap.TryGetValue(uri.OriginalString, out int index))
                {
                    Artifact fileData = files[index];

                    // We need the encoding because the content might have been transcoded to UTF-8
                    string encodingName = fileData.Encoding ?? _currentV2Run.DefaultEncoding;
                    encoding = GetFileEncoding(encodingName);

                    if (encoding != null)
                    {
                        if (fileData.Contents?.Binary != null)
                        {
                            // Embedded binary file content

                            byte[] content = Convert.FromBase64String(fileData.Contents.Binary);
                            stream = new MemoryStream(content);
                        }
                        else if (fileData.Contents?.Text != null)
                        {
                            // Embedded text file content

                            byte[] content = encoding.GetBytes(fileData.Contents.Text);
                            stream = new MemoryStream(content);
                        }
                        else if (uri.IsAbsoluteUri && uri.Scheme == Uri.UriSchemeFile && File.Exists(uri.LocalPath))
                        {
                            // External source file

                            try
                            {
                                stream = new FileStream(uri.LocalPath, FileMode.Open);
                            }
                            catch (FileNotFoundException ex)
                            {
                                failureReason = $"File '{uri.LocalPath}' could not be found: {ex.ToString()}";
                            }
                            catch (IOException ex)
                            {
                                failureReason = $"File '{uri.LocalPath}' could not be read: {ex.ToString()}";
                            }
                            catch (SecurityException ex)
                            {
                                failureReason = $"File '{uri.LocalPath}' could not be accessed: {ex.ToString()}";
                            }
                            catch (UnauthorizedAccessException ex)
                            {
                                failureReason = $"File '{uri.LocalPath}' could not be accessed: {ex.ToString()}";
                            }
                        }
                    }
                    else
                    {
                        failureReason = $"Encoding for file '{uri.OriginalString}' could not be determined";
                    }
                }
            }

            if (stream == null && failureReason == null)
            {
                failureReason = $"File '{uri.LocalPath}' could not be opened";
            }

            if (failureReason != null)
            {
                // If we get here, we were unable to determine region character offset, so we have to warn the caller
                // TODO: add a warning to the list
            }

            return(stream);
        }
Esempio n. 58
0
        public override Response Execute()
        {
            Artifact   activeArtifact    = this.ActiveArtifact;
            int        activeWorkspaceId = this.Helper.GetActiveCaseID();
            string     currentUser       = this.Helper.GetAuthenticationManager().UserInfo.FullName;
            IDBContext dbcontext         = this.Helper.GetDBContext(activeWorkspaceId);
            bool       result            = true;
            ConsoleEventHandlerComment consoleEventHandler = new ConsoleEventHandlerComment();
            Response retVal = new Response()
            {
                Success = true,
                Message = String.Empty
            };

            //verify if the comment has a parent
            if (!(ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()] == null))
            {
                int parentCommentId = (int)ActiveArtifact.Fields[RELATED_COMMENT_FIELD.ToString()].Value.Value;
                kCura.Relativity.Client.DTOs.RDO parentComment = new kCura.Relativity.Client.DTOs.RDO(parentCommentId);
                using (kCura.Relativity.Client.IRSAPIClient client =
                           this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(ExecutionIdentity.System))
                {
                    int workspaceId = this.Helper.GetActiveCaseID();
                    client.APIOptions.WorkspaceID = workspaceId;
                    parentComment = client.Repositories.RDO.ReadSingle(parentCommentId);

                    client.APIOptions.WorkspaceID = -1;
                    kCura.Relativity.Client.DTOs.User userComment = new kCura.Relativity.Client.DTOs.User(parentComment.SystemCreatedBy.ArtifactID);
                    userComment = client.Repositories.User.ReadSingle(parentComment.SystemCreatedBy.ArtifactID);


                    if (ActiveArtifact.IsNew)
                    {
                        MailMessage email     = new MailMessage();
                        string      userEmail = userComment.EmailAddress;
                        string      author    = this.Helper.GetAuthenticationManager().UserInfo.FullName;
                        email.To.Add(new MailAddress(userEmail));
                        // sentEmailNew(email, author);
                    }
                }
            }
            else
            {
                using (kCura.Relativity.Client.IRSAPIClient client =
                           this.Helper.GetServicesManager().CreateProxy <kCura.Relativity.Client.IRSAPIClient>(ExecutionIdentity.System))
                {
                    string type        = string.Empty;
                    int    workspaceId = this.Helper.GetActiveCaseID();
                    client.APIOptions.WorkspaceID = workspaceId;
                    CORE.BLL.Service.RSAPIService.CommentRSAPIService commentRSAPIService = new CORE.BLL.Service.RSAPIService.CommentRSAPIService(client);
                    CORE.DAL.Entities.Comment comment     = commentRSAPIService.Get(ActiveArtifact.ArtifactID);
                    ChoiceCollection          typeChoices = (ChoiceCollection)this.ActiveArtifact.Fields[COMMENT_TYPE_FIELD_GUID.ToString()].Value.Value;
                    foreach (Choice typeC in typeChoices)
                    {
                        type = typeC.Name;
                    }
                    comment.TypeChoosed = type;
                    auditComment(comment, ActiveArtifact.IsNew, this.Helper.GetDBContext(workspaceId));
                }
            }


            try
            {
                ChoiceCollection typeChoices = (ChoiceCollection)this.ActiveArtifact.Fields[COMMENT_TYPE_FIELD_GUID.ToString()].Value.Value;

                foreach (Choice typeChoice in typeChoices)
                {
                    if (typeChoice.Name.Equals("Error"))
                    {
                        result = consoleEventHandler.insertJob(dbcontext, currentUser, activeArtifact);
                    }
                    else
                    {
                        result = consoleEventHandler.deleteJob(dbcontext, activeArtifact.ArtifactID);
                    }
                }
            }
            catch (Exception e)
            {
                retVal.Success = false;
                retVal.Message = e.Message;
            }
            return(retVal);
        }
Esempio n. 59
0
 internal void OnArtifactRemoved(Artifact a, Project project)
 {
     ++_version;
 }
Esempio n. 60
0
    //

    private void ChangeMode(InfoMode nmode)
    {
        if (mode != nmode)
        {
            //prev mode            
            switch (mode)
            {
                case InfoMode.Expeditions:
                    selectedExpedition = null;
                    expeditionButtonImage.overrideSprite = null;
                    break;
                case InfoMode.Crews:
                    selectedCrew = null;
                    crewButtonImage.overrideSprite = null;
                    break;
                case InfoMode.Artifacts:
                    selectedArtifact = null;
                    artifactButtonImage.overrideSprite = null;
                    break;
            }
            mode = nmode;
            if (activeObserver != null) activeObserver.SetActive(false);
            
            switch (mode)
            {
                case InfoMode.Crews:
                    {
                        listController.PrepareList(crewsData);
                        crewButtonImage.overrideSprite = PoolMaster.gui_overridingSprite;

                        if (Crew.crewsList.Count != 0)
                        {
                            if (selectedCrew == null) SelectItem(0);
                        }
                        else
                        {
                            if (activeObserver != null)
                            {
                                activeObserver.SetActive(false);
                                activeObserver = null;
                            }
                            listController.ChangeEmptyLabelText(Localization.GetPhrase(LocalizedPhrase.NoCrews));
                        }
                        lastDrawnActionHash = Crew.listChangesMarkerValue;
                        if (!listController.isActiveAndEnabled) listController.gameObject.SetActive(true);
                        break;
                    }
                case InfoMode.Artifacts:
                    {
                        listController.PrepareList(artifactsData);
                        artifactButtonImage.overrideSprite = PoolMaster.gui_overridingSprite;

                        if (Artifact.artifactsList.Count != 0)
                        {
                            if (selectedArtifact == null) SelectItem(0);
                        }
                        else
                        {
                            if (activeObserver != null)
                            {
                                activeObserver.SetActive(false);
                                activeObserver = null;
                            }
                            listController.ChangeEmptyLabelText(Localization.GetPhrase(LocalizedPhrase.NoArtifacts));
                        }
                        lastDrawnActionHash = Artifact.listChangesMarkerValue;
                        if (!listController.isActiveAndEnabled) listController.gameObject.SetActive(true);
                        break;
                    }
                case InfoMode.Expeditions:
                    {
                        listController.PrepareList(expeditionsData);
                        expeditionButtonImage.overrideSprite = PoolMaster.gui_overridingSprite;

                        if (Expedition.expeditionsList.Count != 0)
                        {                           
                            if (selectedExpedition == null) SelectItem(0);
                        }
                        else
                        {
                            if (activeObserver != null)
                            {
                                activeObserver.SetActive(false);
                                activeObserver = null;
                            }
                            listController.ChangeEmptyLabelText(Localization.GetPhrase(LocalizedPhrase.NoExpeditions));
                        }
                        lastDrawnActionHash = Expedition.listChangesMarker;
                        if (!listController.isActiveAndEnabled) listController.gameObject.SetActive(true);
                        break;
                    }
                case InfoMode.Inactive:
                    if (listController.isActiveAndEnabled) listController.gameObject.SetActive(false);
                    lastDrawnActionHash = -1;
                    break;
            }
        }
    }