Пример #1
0
        public void Logics()
        {
            StringBool t = "true";
            StringBool n = "force";
            StringBool f = "false";
            var        s = new[] { t, n, f };
            var        b = new bool?[] { true, null, false };

            for (int i = 0; i < 3; i++)
            {
                Assert.AreEqual(!b[i], (bool?)!s[i]);
            }

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Assert.AreEqual(b[i] & b[j], (bool?)(s[i] & s[j]));
                    Assert.AreEqual(b[i] ^ b[j], (bool?)(s[i] ^ s[j]));
                    Assert.AreEqual(b[i] | b[j], (bool?)(s[i] | s[j]));
                }
            }

            // bool? で && および || は利用できません。
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Assert.AreEqual(b[i] & b[j], (bool?)(s[i] && s[j]));
                    Assert.AreEqual(b[i] | b[j], (bool?)(s[i] || s[j]));
                }
            }
        }
Пример #2
0
        public void Tables()
        {
            StringBool t = "true";
            StringBool n = "force";
            StringBool f = "false";
            var        s = new[] { t, n, f };

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write($"{s[i] && s[j],-8}");
                }
                Console.WriteLine();
            }
            Console.WriteLine();

            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    Console.Write($"{s[i] || s[j],-8}");
                }
                Console.WriteLine();
            }
        }
Пример #3
0
        public void Conditions()
        {
            StringBool t = "true";
            StringBool n = "force";
            StringBool f = "false";

            if (t)
            {
            }
            else
            {
                Assert.Fail();
            }
            if (!t)
            {
                Assert.Fail();
            }
            else
            {
            }
            if (f)
            {
                Assert.Fail();
            }
            else
            {
            }
            if (!f)
            {
            }
            else
            {
                Assert.Fail();
            }
            if (n)
            {
                Assert.Fail();
            }
            else
            {
            }
            if (!n)
            {
                Assert.Fail();
            }
            else
            {
            }

            Assert.AreEqual(1, t ? 1 : 0);
            Assert.AreEqual(0, !t ? 1 : 0);
            Assert.AreEqual(0, f ? 1 : 0);
            Assert.AreEqual(1, !f ? 1 : 0);
            Assert.AreEqual(0, n ? 1 : 0);
            Assert.AreEqual(0, !n ? 1 : 0);
        }
Пример #4
0
        internal static bool ContainRdr(Response response)
        {
            SearchPacketData packetData = response.Data as SearchPacketData;

            if (packetData != null)
            {
                return(StringBool.ZeroToBool(packetData.Contain));
            }
            else
            {
                Logger.Say.PutError("PacketData not a SearchPacketData!!!");
                return(false);
            }
        }
Пример #5
0
        static void Main(string[] args)
        {
            Parameters parameters;

            ReadConfig.GetParameters(out parameters);

            Say.Message += DebugMeth;
            DbFieldsInfo dbFieldsInfo = new DbFieldsInfo();

            dbFieldsInfo.UNameField = parameters.GetNameFieldNumber();
            dbFieldsInfo.UPassField = parameters.GetPwdFieldNumber();
            String           host             = parameters.GetHost().ToString();
            int              port             = parameters.GetPort();
            String           db               = parameters.GetDbName();
            String           uname            = parameters.GetUserName();
            String           pawd             = parameters.GetPassword();
            Boolean          debug            = StringBool.ZeroToBool(parameters.GetDebug());
            DbConnectionInfo dbConnectionInfo = new DbConnectionInfo(host, port, db, uname, pawd);

            _dbClient   = new IrbisDbClient(dbConnectionInfo, dbFieldsInfo, debug);
            _authHelper = new FreeRadiusHelper(_dbClient, debug);

            if (args.Length > 0)
            {
                switch (args[0])
                {
                case "access":
                {
                    if (args.Length == 3)
                    {
                        Access(args);
                    }
                    else
                    {
                        Console.WriteLine("Error args!!! Example:");
                        Console.WriteLine(_examples[Examples.ACCESS]);
                    }
                    break;
                }

                case "loginToDb":
                {
                    if (args.Length == 5)
                    {
                        LoginToDb(args);
                    }
                    else
                    {
                        Console.WriteLine("Error args!!! Example:");
                        Console.WriteLine(_examples[Examples.LOGINDB]);
                    }
                    break;
                }

                case "logoutToDb":
                {
                    if (args.Length == 5)
                    {
                        LogoutToDb(args);
                    }
                    else
                    {
                        Console.WriteLine("Error args!!! Example:");
                        Console.WriteLine(_examples[Examples.LOGOUTDB]);
                    }
                    break;
                }

                case "loginToCsv":
                {
                    if (args.Length == 5)
                    {
                        LoginToCsv(args);
                    }
                    else
                    {
                        Console.WriteLine("Error args!!! Example:");
                        Console.WriteLine(_examples[Examples.LOGINCSV]);
                    }
                    break;
                }

                case "logoutToCsv":
                {
                    if (args.Length == 6)
                    {
                        LogoutToCsv(args);
                    }
                    else
                    {
                        Console.WriteLine("Error args!!! Example:");
                        Console.WriteLine(_examples[Examples.LOGOUTCSV]);
                    }
                    break;
                }

                default:
                    Help();
                    break;
                }
            }
            else
            {
                Help();
            }

            //Console.Write(authHelper.CheckAccount("10010", "1231"));
            //_authHelper.WriteAccountLoginInfo("10010", "10.1.1.1", "ff:ff:ff:ff:ff:ff", "fromscript");
            //_authHelper.WriteAccountLoginInfo("10010", "10.1.1.1", "ff:ff:ff:ff:ff:ff", "fromscript");
        }