コード例 #1
0
        /// <summary>
        /// 连接数据库
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_Ok_Click(object sender, EventArgs e)
        {
            conn.DbType   = "Oracle";
            conn.Alias    = cbb_Database.Text;
            conn.Database = cbb_Database.Text;
            conn.Username = txb_Username.Text;
            conn.Password = txb_Password.Text;

            IAdoService adoService   = new OracleService();
            string      errorMessage = adoService.Test(conn);

            if (!string.IsNullOrEmpty(errorMessage))
            {
                MessageBox.Show(errorMessage);
                return;
            }
            else
            {
                Dictionary <string, string> keyValues = new Dictionary <string, string>();
                keyValues.Add("Database", this.conn.Database);
                keyValues.Add("Username", this.conn.Username);
                keyValues.Add("Password", this.conn.Password);
                Helper.SetAppSetting(keyValues);
                this.DialogResult = DialogResult.OK;
            }
        }
コード例 #2
0
ファイル: Creature.cs プロジェクト: Guimcha/TheOracle
        public static Creature GenerateNewCreature(IServiceProvider serviceProvider, ulong ChannelId, CreatureEnvironment environment)
        {
            var           creature = new Creature(serviceProvider, ChannelId);
            OracleService oracles  = serviceProvider.GetRequiredService <OracleService>();
            Random        rnd      = BotRandom.Instance;

            if (environment == CreatureEnvironment.None)
            {
                Enum.TryParse(oracles.RandomRow("Creature Environment", GameName.Starforged, rnd).Description, out environment);
            }

            creature.BasicForm           = oracles.RandomOracleResult($"Basic Form {environment}", serviceProvider, GameName.Starforged, rnd);
            creature.Environment         = environment;
            creature.EncounteredBehavior = oracles.RandomOracleResult("Creature Behavior", serviceProvider, GameName.Starforged, rnd);

            int firstLookCount = rnd.Next(2, 4); //random.Next doesn't include the max value

            for (int i = 0; i < firstLookCount; i++)
            {
                creature.FirstLook.AddRandomOracleRow("Creature First Look", GameName.Starforged, serviceProvider, ChannelId, rnd);
            }

            creature.Scale = oracles.RandomOracleResult($"Creature Scale", serviceProvider, GameName.Starforged, rnd);

            return(creature);
        }
コード例 #3
0
 public NpcCommands(DiscordSocketClient client, OracleService oracleService, ServiceProvider provider)
 {
     //Add client via DI, needed for reaction events
     Client          = client;
     OracleService   = oracleService;
     serviceProvider = provider;
 }
コード例 #4
0
ファイル: OracleRollerTests.cs プロジェクト: rsek/TheOracle
        public void BuildRollResultsTest()
        {
            var oracleService = new OracleService();

            oracleService.RandomRow("Action", GameName.Ironsworn);
            oracleService.RandomRow("Theme", GameName.Ironsworn);

            Assert.ThrowsException <ArgumentException>(() => oracleService.RandomRow("Action"));
        }
コード例 #5
0
        public void TestCreateOracleResponseTx()
        {
            var snapshot = Blockchain.Singleton.GetSnapshot();

            var executionFactor = NativeContract.Policy.GetExecFeeFactor(snapshot);

            Assert.AreEqual(executionFactor, (uint)30);
            var feePerByte = NativeContract.Policy.GetFeePerByte(snapshot);

            Assert.AreEqual(feePerByte, (uint)1000);

            OracleRequest request = new OracleRequest
            {
                OriginalTxid     = UInt256.Zero,
                GasForResponse   = 100000000 * 1,
                Url              = "https://127.0.0.1/test",
                Filter           = "",
                CallbackContract = UInt160.Zero,
                CallbackMethod   = "callback",
                UserData         = System.Array.Empty <byte>()
            };
            byte Prefix_Transaction = 11;

            snapshot.Add(NativeContract.Ledger.CreateStorageKey(Prefix_Transaction, request.OriginalTxid), new StorageItem(new TransactionState()
            {
                BlockIndex  = 1,
                Transaction = new Transaction()
                {
                    ValidUntilBlock = 1
                }
            }));
            OracleResponse response = new OracleResponse()
            {
                Id = 1, Code = OracleResponseCode.Success, Result = new byte[] { 0x00 }
            };

            ECPoint[] oracleNodes = new ECPoint[] { ECCurve.Secp256r1.G };
            var       tx          = OracleService.CreateResponseTx(snapshot, request, response, oracleNodes);

            Assert.AreEqual(167, tx.Size);
            Assert.AreEqual(2216640, tx.NetworkFee);
            Assert.AreEqual(97783360, tx.SystemFee);

            // case (2) The size of attribute exceed the maximum limit

            request.GasForResponse = 0_10000000;
            response.Result        = new byte[10250];
            tx = OracleService.CreateResponseTx(snapshot, request, response, oracleNodes);
            Assert.AreEqual(166, tx.Size);
            Assert.AreEqual(OracleResponseCode.InsufficientFunds, response.Code);
            Assert.AreEqual(2215640, tx.NetworkFee);
            Assert.AreEqual(7784360, tx.SystemFee);
        }
コード例 #6
0
        public NpcCommands(DiscordSocketClient client, OracleService oracleService, ServiceProvider provider)
        {
            //Add client via DI, needed for reaction events
            Client          = client;
            OracleService   = oracleService;
            serviceProvider = provider;

            if (!serviceProvider.GetRequiredService <HookedEvents>().NPCReationsLoaded)
            {
                serviceProvider.GetRequiredService <HookedEvents>().NPCReationsLoaded = true;
                var types = AppDomain.CurrentDomain.GetAssemblies()
                            .SelectMany(s => s.GetTypes())
                            .Where(p => typeof(INpcGenerator).IsAssignableFrom(p) && !p.IsInterface);
                foreach (var type in types)
                {
                    Activator.CreateInstance(type, provider);
                }
            }
        }
コード例 #7
0
        public void TestFilter()
        {
            var json = @"{
  'Stores': [
    'Lambton Quay',
    'Willis Street'
  ],
  'Manufacturers': [
    {
      'Name': 'Acme Co',
      'Products': [
        {
          'Name': 'Anvil',
          'Price': 50
        }
      ]
    },
    {
      'Name': 'Contoso',
      'Products': [
        {
          'Name': 'Elbow Grease',
          'Price': 99.95
        },
        {
          'Name': 'Headlight Fluid',
          'Price': 4
        }
      ]
    }
  ]
}";

            Assert.AreEqual(@"[""Acme Co""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[0].Name")));
            Assert.AreEqual("[50]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[0].Products[0].Price")));
            Assert.AreEqual(@"[""Elbow Grease""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[1].Products[0].Name")));
            Assert.AreEqual(@"[{""Name"":""Elbow Grease"",""Price"":99.95}]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "Manufacturers[1].Products[0]")));
        }
コード例 #8
0
        public void TestFilter()
        {
            var json = @"{
  ""Stores"": [
    ""Lambton Quay"",
    ""Willis Street""
  ],
  ""Manufacturers"": [
    {
      ""Name"": ""Acme Co"",
      ""Products"": [
        {
          ""Name"": ""Anvil"",
          ""Price"": 50
        }
      ]
    },
    {
      ""Name"": ""Contoso"",
      ""Products"": [
        {
          ""Name"": ""Elbow Grease"",
          ""Price"": 99.95
        },
        {
          ""Name"": ""Headlight Fluid"",
          ""Price"": 4
        }
      ]
    }
  ]
}";

            Assert.AreEqual(@"[""Acme Co""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "$.Manufacturers[0].Name")));
            Assert.AreEqual("[50]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "$.Manufacturers[0].Products[0].Price")));
            Assert.AreEqual(@"[""Elbow Grease""]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "$.Manufacturers[1].Products[0].Name")));
            Assert.AreEqual(@"[{""Name"":""Elbow Grease"",""Price"":99.95}]", Utility.StrictUTF8.GetString(OracleService.Filter(json, "$.Manufacturers[1].Products[0]")));
        }
コード例 #9
0
ファイル: DelveInfo.cs プロジェクト: Guimcha/TheOracle
        public static DelveInfo FromInput(DelveService delveService, OracleService oracles, string themeInput, string domainInput, string siteNameInput, string siteObjective, string siteRankInput)
        {
            var delveInfo     = new DelveInfo();
            var themeItems    = themeInput.Split(',');
            var domainItems   = domainInput.Split(',');
            var randomAliases = DelveResources.RandomAliases.Split(',').ToList();
            int randomThemes  = 0;
            int randomDomains = 0;

            delveInfo.SiteObjective = siteObjective;

            ChallengeRankHelper.TryParse(siteRankInput, out ChallengeRank cr);
            if (cr == ChallengeRank.None && int.TryParse(siteRankInput, out int rankNumber))
            {
                if (rankNumber == 1)
                {
                    cr = ChallengeRank.Troublesome;
                }
                if (rankNumber == 2)
                {
                    cr = ChallengeRank.Dangerous;
                }
                if (rankNumber == 3)
                {
                    cr = ChallengeRank.Formidable;
                }
                if (rankNumber == 4)
                {
                    cr = ChallengeRank.Extreme;
                }
                if (rankNumber == 5)
                {
                    cr = ChallengeRank.Epic;
                }
            }
            delveInfo.Rank = cr;

            for (int i = 0; i < themeItems.Length; i++)
            {
                themeItems[i] = themeItems[i].Trim();
                if (randomAliases.Any(alias => alias.Equals(themeItems[i], StringComparison.OrdinalIgnoreCase)))
                {
                    randomThemes++;
                    continue;
                }

                var matchingTheme = delveService.Themes.Find(t => t.DelveSiteTheme.Equals(themeItems[i], StringComparison.OrdinalIgnoreCase));
                if (matchingTheme != null)
                {
                    delveInfo.Themes.Add(matchingTheme);
                    continue;
                }

                if (int.TryParse(themeItems[i], out int themeValue) && themeValue - 1 < delveService.Themes.Count)
                {
                    delveInfo.Themes.Add(delveService.Themes[themeValue - 1]);
                    continue;
                }

                throw new ArgumentException(String.Format(DelveResources.UnknownThemeError, themeItems[i]));
            }

            for (int i = 0; i < domainItems.Length; i++)
            {
                domainItems[i] = domainItems[i].Trim();
                if (randomAliases.Any(alias => alias.Equals(domainItems[i], StringComparison.OrdinalIgnoreCase)))
                {
                    randomDomains++;
                    continue;
                }

                var matchingDomain = delveService.Domains.Find(d => d.DelveSiteDomain.Equals(domainItems[i], StringComparison.OrdinalIgnoreCase));
                if (matchingDomain != null)
                {
                    delveInfo.Domains.Add(matchingDomain);
                    continue;
                }

                if (int.TryParse(domainItems[i], out int domainValue) && domainValue - 1 < delveService.Domains.Count)
                {
                    delveInfo.Domains.Add(delveService.Domains[domainValue - 1]);
                    continue;
                }

                throw new ArgumentException(String.Format(DelveResources.UnknownDomainError, domainItems[i]));
            }

            for (int i = 0; i < randomThemes; i++)
            {
                delveInfo.AddRandomTheme(delveService);
            }
            for (int i = 0; i < randomDomains; i++)
            {
                delveInfo.AddRandomDomain(delveService);
            }

            if (randomAliases.Any(alias => alias.Equals(siteNameInput, StringComparison.OrdinalIgnoreCase)))
            {
                var roller = new OracleRoller(oracles, GameName.Ironsworn);
                roller.BuildRollResults("Site Name Format");
                siteNameInput = roller.RollResultList.First().Result.Description;
                string place = roller.BuildRollResults($"Site Name Place {delveInfo.Domains.First().DelveSiteDomain}").RollResultList.First().Result.Description;
                siteNameInput = siteNameInput.Replace("{Place}", place);
            }
            delveInfo.SiteName = siteNameInput;

            return(delveInfo);
        }
コード例 #10
0
 public Oracle(Web3 _web3)
 {
     web3    = _web3;
     receipt = OracleService.DeployContractAndWaitForReceiptAsync(web3, deploymentOracle).Result;
     service = new OracleService(web3, receipt.ContractAddress);
 }
コード例 #11
0
 public DelveInfoBuilder(DelveService delveService, OracleService oracles)
 {
     DelveService = delveService;
     Oracles      = oracles;
 }
コード例 #12
0
 public D_Inventario_Jac(OracleService _oracleService, SqlServerService _sqlServerService)
 {
     oracleService    = _oracleService;
     sqlServerService = _sqlServerService;
 }