示例#1
0
 void IEnviromentSetable.CancelEnv(IEnviroment enviroment)
 {
     if (tempSensor.enviroment == enviroment)
     {
         tempSensor.enviroment = null;
     }
 }
示例#2
0
        internal override object eval(IEnviroment env)
        {
            var value = id.eval(env);

            if (value is NativeFunction nfunc)
            {
                if (nfunc.numOfParameters > 0)
                {
                    object[] parms = new object[nfunc.numOfParameters];
                    if (postfix.Name == "postfix")
                    {
                        for (int i = 0; i < parms.Length; i++)
                        {
                            parms[i] = (postfix as ASTTree).childs[i].eval(env);
                        }
                    }
                    else
                    {
                        parms[0] = postfix.eval(env);
                    }
                    return(nfunc.invoke(parms));
                }
                return(nfunc.invoke(null));
            }
            return(value);
        }
示例#3
0
        internal override object eval(IEnviroment env)
        {
            switch (token.type)
            {
            case Token.TokenType.Number:
                if (token.value.Contains('.'))
                {
                    return(double.Parse(token.value));
                }
                else
                {
                    return(int.Parse(token.value));
                }

            case Token.TokenType.String:
                return(token.value);

            case Token.TokenType.Identifier:
                return(env.Get(token.value));

            case Token.TokenType.Other:
            case Token.TokenType.EOF:
                return(null);
            }
            return(base.eval(env));
        }
 public Component(
     IEnviroment env,
     IConfiguration cfg)
 {
     _env = env;
     _cfg = cfg;
 }
示例#5
0
 public override void CancelEnv(IEnviroment enviroment)
 {
     if (VtmDev.TemSensorEnv == enviroment)
     {
         VtmDev.TemSensorEnv = null;
     }
 }
示例#6
0
 public UserManagementApi()
 {
     _setting    = new Setting();
     _logging    = new Logging();
     _env        = new SpartanEnvironment.Environment();
     _configPath = _setting.CreateModuleSetting("usermanagement");
     SetDbParameters();
 }
示例#7
0
        public LoginPage()
        {
            InitializeComponent();

            communicator = ClassLoader.Instance.GetElement <ICommunication>();
            enviroment   = ClassLoader.Instance.GetElement <IEnviroment>();

            DataContext = loginPageModel;
        }
示例#8
0
        public Window1()
        {
            InitializeComponent();

            _communication = ClassLoader.Instance.GetElement <ICommunication>();
            _enviroment    = ClassLoader.Instance.GetElement <IEnviroment>();

            fillElementsTrash();
        }
示例#9
0
        IEnviroment _enviroment;       //User

        public MainWindow()
        {
            InitializeComponent();
            //client = new Client("BaseURL"); //Здесь вылетит, потому что URL неизвестен
            ////MediaSource.Source = new Uri(System.IO.Path.GetFullPath("Resources/giphy.gif")); //??

            _communication = ClassLoader.Instance.GetElement <ICommunication>();
            _enviroment    = ClassLoader.Instance.GetElement <IEnviroment>();
        }
示例#10
0
        internal override object eval(IEnviroment env)
        {
            object r = null;

            while ((int)condition.eval(env) > 0)
            {
                r = block.eval(env);
            }
            return(r);
        }
        public void TestUserManagementSettings()
        {
            _env = new Environment();
            _env.SetUserVariable("Environment", "Development");
            var _ums            = new UserManagementApi();
            var _testConnection = _ums.ConnectionString;
            var _testEnvString  = _ums.Environment;

            Assert.IsTrue(_testEnvString.Equals("Development"));
            Assert.IsTrue(!string.IsNullOrWhiteSpace(_testConnection), "No Connection found");
        }
示例#12
0
        public SectionViewModel()
        {
            _communication = ClassLoader.Instance.GetElement <ICommunication>();
            _enviroment    = ClassLoader.Instance.GetElement <IEnviroment>();
            _database      = ClassLoader.Instance.GetElement <IDatabase>();

            AddCommand = new ClickCommand(OnAddCommand);

            token       = _enviroment.UserToken;
            currentUser = _communication.GetUserDetails(token, new CancellationTokenSource().Token);
        }
示例#13
0
        public static object DoScript(IEnviroment env, string str)
        {
            var lexer = new Lexer();
            var p     = new BaseParser();

            lexer.Read(str);
            var tree  = p.Parse(lexer);
            var value = tree.eval(env);

            return(value);
        }
示例#14
0
        public BooksViewModel()
        {
            AddCommand = new ClickCommand(OnAddCommand);
            AddCommand.SetCanExecuted(true);

            _communication = ClassLoader.Instance.GetElement <ICommunication>();
            _enviroment    = ClassLoader.Instance.GetElement <IEnviroment>();
            _database      = ClassLoader.Instance.GetElement <IDatabase>();

            token       = _enviroment.UserToken;
            currentUser = _communication.GetUserDetails(token, new CancellationTokenSource().Token);

            _database.GetBooks(currentUser.ID).ToList().ForEach(f => Books.Add(f));
        }
示例#15
0
        internal override object eval(IEnviroment env)
        {
            var state = (int)condition.eval(env);

            if (state > 0)
            {
                return(ifBlock.eval(env));
            }
            else if (hasElse)
            {
                return(elseBlock.eval(env));
            }
            return(state);
        }
示例#16
0
        internal override object eval(IEnviroment env)
        {
            object value = null;

            foreach (var c in childs)
            {
                if (c is ASTLeaf aSTLeaf && aSTLeaf.token.type == Token.TokenType.EOF)
                {
                    continue;
                }
                value = c.eval(env);
            }
            return(value);
        }
        public CalendarsModel(
            IEnviroment env,
            Action <CalendarsModel> cmdApply,
            Action <CalendarsModel> cmdCancel)
        {
            Contract.Assert(env != null);
            Contract.Assert(cmdApply != null);
            Contract.Assert(cmdCancel != null);

            CmdCancel = cmdCancel;
            if (env.FoldersSource.Folders.Count > 0)
            {
                CmdApply = cmdApply;
            }
            _calendars = new Lazy <ObservableCollection <CalendarModel> >(() => new ObservableCollection <CalendarModel>(env.FoldersSource.Folders.Select(_ => new CalendarModel(_, env))));
        }
示例#18
0
        internal override object eval(IEnviroment env)
        {
            var op    = ((ASTLeaf)childs[1]).StrValue;
            var right = childs[2].eval(env);

            if (op == "=")
            {
                if (childs[0] is ASTLeaf name && name.token.type == Token.TokenType.Identifier)
                {
                    env.Set(name.StrValue, right);
                    return(right);
                }
                throw new Exception("can only assignment to var");
            }

            var left = childs[0].eval(env);

            if (op == "+=")
            {
                if (childs[0] is ASTLeaf name && name.token.type == Token.TokenType.Identifier)
                {
                    var v = computeOp(left, right, "+");
                    env.Set(name.StrValue, v);
                    return(v);
                }
                throw new Exception("can only assignment to var");
            }
            if (op == "-=")
            {
                if (childs[0] is ASTLeaf name && name.token.type == Token.TokenType.Identifier)
                {
                    var v = computeOp(left, right, "-");
                    env.Set(name.StrValue, v);
                    return(v);
                }
                throw new Exception("can only assignment to var");
            }
            return(computeOp(left, right, op));
        }
示例#19
0
        public CalendarsAndCategoriesModel(
            IEnviroment env,
            Action <CalendarsAndCategoriesModel> cmdApply,
            Action <CalendarsAndCategoriesModel> cmdCancel)
        {
            Contract.Assert(env != null);
            Contract.Assert(cmdApply != null);
            Contract.Assert(cmdCancel != null);

            CmdCancel = cmdCancel;
            env.FoldersSource.Folders.ForEach(folder => _calendars.Add(new CalendarModel(folder, env)));

            if (_calendars.Count == 0)
            {
                return;
            }

            CmdApply = cmdApply;
            _calendars.ForEach(_ => {
                _.SelectedChanged += calendar =>
                {
                    if (calendar.IsSelected)
                    {
                        calendar.Categories.ForEach(_categories.Add);
                    }
                    else
                    {
                        calendar.Categories.ForEachFunc(_categories.Remove);
                    }
                };
                if (_.IsSelected)
                {
                    _.Categories.ForEach(_categories.Add);
                }
            });
        }
示例#20
0
 internal virtual object eval(IEnviroment env)
 {
     throw new Exception("error!");
 }
示例#21
0
 public SignInViewModel()
 {
     SignIn         = new ClickCommand(OnExecuted);
     _communication = ClassLoader.Instance.GetElement <ICommunication>();
     _enviroment    = ClassLoader.Instance.GetElement <IEnviroment>();
 }
示例#22
0
 public override void SetEnv(IEnviroment enviroment)
 {
     VtmDev.TemSensorEnv = enviroment;
 }
示例#23
0
 public void Setup()
 {
     _sut = new ClassicEnviroment();
 }
        public async System.Threading.Tasks.Task TestAddNewUserByUserNameAsync()
        {
            _env   = new Environment();
            _users = new UserManagementApi();
            _env.SetUserVariable("Environment", "Development");
            _user = new User
            {
                //1- Create Dummy User
                Id           = System.Guid.Parse("F037567D-54BC-4044-A6F4-66A7E85A0E34"),
                UserName     = "******",
                GivenName    = "carlos",
                SurName      = "perez",
                PasswordHash = "TestGoog!e1",
                Email        = "*****@*****.**"
            };

            //2- Delete records
            await _users.DeleteAllUsers();

            await _users.DeleteRoles();


            //3- Add User Records
            var _userResponse = await _users.AddOrUpdateUserWithUserName(_user);

            Assert.IsTrue(_userResponse.Status.Equals("ok"), _userResponse.Msg);

            //4- Update User - changed username and same password
            _user.UserName     = "******";
            _user.PasswordHash = "TestGoog!e1";
            _userResponse      = await _users.AddOrUpdateUserWithUserName(_user);

            Assert.IsTrue(_userResponse.Status.Equals("ok"), _userResponse.Msg);

            //5- Lock The Account
            _userResponse = await _users.SetLockState(_user.Id, "This account is locked due to payments", true);

            Assert.IsTrue(_userResponse.LockEnabled, _userResponse.Msg);

            System.Threading.Thread.Sleep(500);

            //5- Unlock The Account
            _userResponse = await _users.SetLockState(_user.Id, "Payments Received for $200", false);

            Assert.IsTrue(!_userResponse.LockEnabled, _userResponse.Msg);

            //6- Disable the account and verify
            System.Threading.Thread.Sleep(500);
            _userResponse = await _users.SetActiveState(_user.Id, "Deleting the Account for Temp reasons!", false);

            Assert.IsTrue(!_userResponse.IsActive, "failed to disable the user account");


            //7- Enable the account and verify
            System.Threading.Thread.Sleep(500);
            _userResponse = await _users.SetActiveState(_user.Id, "Found the Problem. Account was enable after receiving the email from Peter", true);

            Assert.IsTrue(_userResponse.IsActive, "failed to enable the user account");

            //8- Find User By UserName
            _userResponse = await _users.GetUserByUserName("cperez1");

            Assert.IsTrue((_userResponse.Status.Equals("ok") && _userResponse.Email.Equals("*****@*****.**")), _userResponse.Msg);

            //9- Find User By Email
            _userResponse = await _users.GetUserByEmail("*****@*****.**");

            Assert.IsTrue((_userResponse.Status.Equals("ok") && _userResponse.UserName.Equals("cperez1")), _userResponse.Msg);

            //10- Delete the User Account
            _userResponse = await _users.DeleteUserAccount(_user.Id, "Testing Delete Account");

            var _userList = await _users.GetActiveUsers();

            Assert.IsTrue(_userList.Count == 0, "Failed to Delete Account");

            //11- Set the Account Active again
            _userResponse = await _users.SetActiveState(_user.Id, "User is back", true);

            Assert.IsTrue(_userResponse.IsActive, "failed to enable the user account");

            //12- Reset Password- Mismatch Error
            _userResponse = await _users.ResetPassword(_user.Email, "TestGoog!e3", "TestGoog!e2");

            Assert.IsTrue(_userResponse.Status.Equals("error"), _userResponse.Msg);

            //12- Reset Password- Mismatch and change password
            _userResponse = await _users.ResetPassword(_user.Email, "TestGoog!e1", "TestGoog!e2");

            Assert.IsTrue(_userResponse.Status.Equals("ok"), _userResponse.Msg);

            //13- Login with New password
            _userResponse = await _users.LoginByEmail(_user.Email, "TestGoog!e2");

            Assert.IsTrue(_userResponse.Status.Equals("ok"), _userResponse.Msg);

            //14- Login with invalid params
            _userResponse = await _users.LoginByEmail(_user.Email, "");

            Assert.IsTrue(_userResponse.Status.Equals("error"), _userResponse.Msg);

            //15- Login with invalid email
            _userResponse = await _users.LoginByEmail("123@", "TestGoog!e2");

            Assert.IsTrue(_userResponse.Status.Equals("error"), _userResponse.Msg);

            //16- Login with old password
            _userResponse = await _users.LoginByEmail(_user.Email, "TestGoog!e1");

            Assert.IsTrue(_userResponse.Status.Equals("error"), _userResponse.Msg);

            //17- Login with New password...again
            var loginemail = new LoginEmail
            {
                Email    = _user.Email,
                Password = "******"
            };

            _userResponse = await _users.LoginByEmail(loginemail);

            Assert.IsTrue(_userResponse.Status.Equals("ok"), _userResponse.Msg);

            //18- Login by UserName
            var userlogin = new LoginUser
            {
                UserName = _user.UserName,
                Password = "******"
            };

            _userResponse = await _users.LoginByUserName(userlogin);

            Assert.IsTrue(_userResponse.Status.Equals("ok"), _userResponse.Msg);

            //19- Verify User Counts
            _userList = await _users.GetActiveUsers();

            Assert.IsTrue(_userList.Count > 0, "Failed to Retrived All Users");

            //ROLES::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //20- Add Roles
            var _roleName = "anonymous user";
            var _role     = await _users.AddRole(_roleName);

            Assert.IsTrue(_role.RoleName.Equals(_roleName), $"unable to add new role: {_roleName}");

            //21- Add Roles
            _roleName = "authenticated user";
            _role     = await _users.AddRole(_roleName);

            Assert.IsTrue(_role.RoleName.Equals(_roleName), $"unable to add new role: {_roleName}");

            //22- make sure no duplicate names are added
            _roleName = "authenticated user";
            _role     = await _users.AddRole(_roleName);

            Assert.IsTrue(_role.RoleName.Equals(_roleName), $"unable to add new role: {_roleName}");

            //23- Add Roles
            _roleName = "administrator";
            _role     = await _users.AddRole(_roleName);

            Assert.IsTrue(_role.RoleName.Equals(_roleName), $"unable to add new role: {_roleName}");
            var updateId = _role.Id;

            //24- Add dummy role to delete
            _roleName = "dummy";
            _role     = await _users.AddRole(_roleName);

            Assert.IsTrue(_role.RoleName.Equals(_roleName), $"unable to add new role: {_roleName}");

            _role = await _users.GetRole(_role.Id);

            Assert.IsTrue(_role.IsActive, $"unable to get role: {_role.Id}");


            _roleName = "dummy";
            await _users.DeleteRole(_role.Id);

            _role = await _users.GetRoleByName("dummy");

            Assert.IsTrue(_role == null, $"unable to delete dummy");

            //25- Update Role
            _roleName = "administrator2";
            _role     = await _users.UpdateRole(updateId, "administrator2");

            Assert.IsTrue(_role.RoleName.Equals(_roleName));

            //26- Register a New User with email (may consider deleting "user")
            _userResponse = await _users.Register("*****@*****.**", "JP632tilla1!", "carlos perez");

            Assert.IsTrue(_userResponse.Status.Equals("ok"), _userResponse.Msg);
        }
示例#25
0
 public Component(IEnviroment env)
 {
     _env = env;
 }
示例#26
0
 void IEnviromentSetable.SetEnv(IEnviroment enviroment)
 {
     tempSensor.enviroment = enviroment;
 }
示例#27
0
 public abstract void SetEnv(IEnviroment enviroment);
示例#28
0
 public abstract void CancelEnv(IEnviroment enviroment);
示例#29
0
 public SyncService()
 {
     _communication = ClassLoader.Instance.GetElement <ICommunication>();
     _enviroment    = ClassLoader.Instance.GetElement <IEnviroment>();
     _database      = ClassLoader.Instance.GetElement <IDatabase>();
 }
示例#30
0
 public EnviromentController(IEnviroment _enviroment, ILogger <EnviromentController> _logger)
 {
     enviroment = _enviroment;
     logger     = _logger;
 }