Exemplo n.º 1
0
        public async Task endpoint_invocation___returns_true_for_api_response_and_empty_parameter_endpoint()
        {
            var controller = new StandardController();

            var context = new ApiRequestContext
            {
                RequestAborted = new CancellationToken(false),
                Request        = new ApiRequestInfo
                {
                    InvocationContext = new ApiInvocationContext
                    {
                        ControllerInstance = controller,
                    }
                },
                Routing = new ApiRoutingInfo
                {
                    Route = new ApiRoutingItem
                    {
                        Location = new ApiEndpointLocation(
                            controller: controller.GetType(),
                            methodInfo: controller.GetType().GetMethod(nameof(controller.DefaultFullApiResponseEndpoint)),
                            httpMethod: null)
                    }
                }
            };

            var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false);

            processed.Should().BeTrue();

            context.Response.Should().NotBeNull();
            context.Response.ResponseObject.Should().NotBeNull();
            context.Response.ResponseObject.Should().BeOfType <int>();
            context.Response.ResponseObject.Should().Be(200);
        }
Exemplo n.º 2
0
        public async Task GetStandardAsync_Calls_StandardService_GetStandard()
        {
            var standardCode       = "547";
            var standardName       = "Broadcast and Media Systems Technician";
            var StandardSectorCode = "11";

            var standard = new StandardModel
            {
                StandardCode       = standardCode,
                StandardName       = standardName,
                StandardSectorCode = StandardSectorCode
            };

            var serviceMock = new Mock <IStandardService>();

            serviceMock
            .Setup(m => m.GetStandard(standardCode))
            .ReturnsAsync(standard);

            var controller = new StandardController(serviceMock.Object);
            var result     = await controller.GetStandardAsync(standardCode);

            serviceMock.Verify(m => m.GetStandard(standardCode), Times.Once);
            result.Should().BeEquivalentTo(standard);
        }
Exemplo n.º 3
0
        public void Controller_Methods_SaveAllCategoriesPerformed()
        {
            // Prepare and Execute:
            var obj = new StandardController(new Mock <IForm>().Object, new Mock <IStorage>().Object);

            obj.SaveAll();
        }
Exemplo n.º 4
0
        public static void Main()
        {
            Application.SetHighDpiMode(HighDpiMode.SystemAware);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Configure main logic:
            var factory    = new MessageBoxFactory();
            var mainForm   = new DataGridViewMain();
            var controller = new StandardController(mainForm, null);

#if !DEBUG
            try
            {
                controller.LoadApp();
            }
            catch (Exception a)
            {
                factory.ShowMessageBox(EMessageBox.Standard,
                                       string.Format(Resources.UnknownExceptionMessage, a.Message),
                                       Settings.Default.AppName,
                                       MessageBoxButtons.OK,
                                       MessageBoxIcon.Error);

                return;
            }
#else
            controller.LoadApp();
#endif

            Application.Run(mainForm);
        }
Exemplo n.º 5
0
        public void Controller_Fields_FormFieldSetProperly()
        {
            // Prepare and Execute:
            var obj = new StandardController(new Mock <IForm>().Object, new Mock <IStorage>().Object);

            // Verify:
            Assert.IsTrue(obj.ActiveForm != null);
        }
Exemplo n.º 6
0
        public void Controller_Fields_DataInputDialogSetProperly()
        {
            // Prepare and Execute:
            var obj = new StandardController(new Mock <IForm>().Object, new Mock <IStorage>().Object);

            // Verify:
            Assert.IsTrue(obj.DataInputDialog != null);
        }
Exemplo n.º 7
0
        public void Controller_Methods_LoadMethodSetsAllCategoriesFromSettings()
        {
            // Prepare:
            var obj = new StandardController(new Mock <IForm>().Object, new Mock <IStorage>().Object);

            // Execute:
            obj.LoadApp();
            // Verify:
        }
        private void fillddlStandardComplete()
        {
            ddlStandard.DataSource     = StandardController.GetAll();
            ddlStandard.DataTextField  = "Name";
            ddlStandard.DataValueField = "StandardKey";
            ddlStandard.DataBind();

            ddlStandard.Items.RemoveAt(4);
        }
Exemplo n.º 9
0
        public void Controller_Methods_AboutAppShownProperly()
        {
            // Prepare:
            var form = new Mock <IForm>();
            var obj  = new StandardController(form.Object, new Mock <IStorage>().Object);

            // Execute:
            obj.ShowAboutWindow();
            // Verify:
        }
Exemplo n.º 10
0
        public void Controller_Methods_NewFormLoadedProperly()
        {
            // Prepare:
            var form    = new Mock <IForm>();
            var obj     = new StandardController(form.Object, new Mock <IStorage>().Object);
            var newForm = new Mock <IForm>();

            // Execute:
            obj.LoadNewSettings(newForm.Object);
            // Verify:
            //Assert.AreEqual(newStorage.Object, obj.ActiveStorage);
        }
Exemplo n.º 11
0
        public void endpoint_invocation___model_lookup_tests()
        {
            var controller = new StandardController();

            var uriModel = new StandardModel
            {
                IntProp = 204
            };

            var bodyModel = new StandardNullableModel
            {
                IntProp = 301
            };

            var context = new ApiRequestContext
            {
                RequestAborted = new CancellationToken(false),
                Request        = new ApiRequestInfo
                {
                    InvocationContext = new ApiInvocationContext
                    {
                        ControllerInstance = controller,
                        UriModel           = uriModel,
                        BodyModel          = bodyModel,
                    }
                }
            };


            // Test model lookup methods
            var models = context.Request.InvocationContext.Models();

            models.Should().NotBeNull();
            models.Should().HaveCount(2);
            models.Should().Contain(uriModel);
            models.Should().Contain(bodyModel);

            var foundUriModel = context.Request.InvocationContext.Models <StandardModel>().FirstOrDefault();

            foundUriModel.Should().NotBeNull();
            foundUriModel.Should().BeSameAs(uriModel);

            var foundBodyModel = context.Request.InvocationContext.Models <StandardNullableModel>().FirstOrDefault();

            foundBodyModel.Should().NotBeNull();
            foundBodyModel.Should().BeSameAs(bodyModel);

            var baseModels = context.Request.InvocationContext.Models <StandardModelBase>();

            baseModels.Should().NotBeNull();
            baseModels.Should().HaveCount(2);
        }
Exemplo n.º 12
0
        public ActionResult Index(string jobsid)
        {
            if (jobsid != null && jobsid.Trim() != "")
            {
                var check_date = db.tb_jobs.Where(w => w.service_order_no == jobsid && w.is_delete == 0).FirstOrDefault();
                if (check_date != null)
                {
                    var engineer_data = (from e in db.tb_engineer where e.is_delete == 0 && check_date.engineer_id == e.id select e);
                    var store_data    = db.tb_store.Where(w => w.id == engineer_data.FirstOrDefault().site_id&& w.is_delete == 0).FirstOrDefault();
                    if (Convert.ToDateTime(check_date.appointment_datetime).Date == DateTime.Today.Date && check_date.appointment_to_datetime != null && store_data != null)
                    {
                        var data = (from j in db.tb_jobs
                                    where j.is_delete == 0 && j.service_order_no == jobsid
                                    select new index
                        {
                            //phone_mobile = j.phone_mobile,
                            service_order_no = j.service_order_no,
                            appointment_datetime = j.appointment_datetime,
                            appointment_to_datetime = j.appointment_to_datetime,
                            customer_lat = j.customer_lat,
                            customer_long = j.customer_long,
                            customer_fullname = j.customer_fullname,
                            customer_mobile = j.phone_mobile,
                            status_job = j.status_job,
                            engi = engineer_data.FirstOrDefault(),
                            phone_office = store_data.tel1 != null ? store_data.tel1 : store_data.tel2 != null ? store_data.tel2 : store_data.tel3
                        }).FirstOrDefault();

                        if (data.status_job != 2 && data.status_job != 4)
                        {
                            ViewData["job_engi"] = data;
                            StandardController service_con = new StandardController();
                            string             key_azure   = service_con.GetKeyAzure();
                            ViewData["Key_Azure"] = key_azure;

                            //get IP , Stamp
                            var ip_client = byi_common.common.GetIPAddress();
                            check_date.ip_customer   = ip_client;
                            check_date.date_customer = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, zone);
                            db.tb_jobs.AddOrUpdate(check_date);
                            db.SaveChanges();

                            return(View());
                        }
                        return(View("Error"));
                    }
                    return(View("Error"));
                }
                return(View("Error"));
            }
            return(View("Error"));
        }
Exemplo n.º 13
0
        public void Controller_Methods_ChangeSelectedTaskPerformed()
        {
            // Prepare:
            var form     = new Mock <IForm>();
            var obj      = new StandardController(form.Object, new Mock <IStorage>().Object);
            var category = new Mock <ITask>();

            form.Setup(x => x.SetCurrentTaskSelected(category.Object));
            // Execute:
            obj.ChangeSelectedTask(category.Object);
            // Verify:
            form.Verify(x => x.SetCurrentTaskSelected(category.Object));
        }
Exemplo n.º 14
0
    public void StandardController(bool pc, int controllerNr)
    {
        currentControl      = Instantiate(prefabStandardController, loadControllerTo);
        currentControl.name = id + " Standard";

        hasCurrentControl = true;

        stController = currentControl.GetComponent <StandardController>();
        stController.SetupButtons(pc, controllerNr);
        stController.StartMenu(characterClassMenu);

        playerMenuController.SetActive(false);
        OpenPlayerSelection();
    }
Exemplo n.º 15
0
        public void Controller_DataControlMethods_QueringCategoryListWorksProperly()
        {
            // Prepare:
            var name = "Category";
            var obj  = new StandardController(new Mock <IForm>().Object, new Mock <IStorage>().Object);
            var mock = new Mock <ICategory>();

            mock.Setup(x => x.Name).Returns(name);
            obj.Categories.Add(mock.Object);
            // Execute:
            var result = obj.QueryCategory(name);

            // Verify:
            Assert.AreEqual(mock.Object, result);
        }
Exemplo n.º 16
0
        public void Controller_Methods_LoadMethodSetsCompletedTasksCategoryProperly(int checkIndex, string categoryName)
        {
            // Prepare:
            var obj          = new StandardController(new Mock <IForm>().Object, new Mock <IStorage>().Object);
            var categoryMock = new Mock <ICategory>();

            categoryMock.Setup(x => x.Name).Returns(categoryName);
            categoryMock.Setup(x => x.Tasks).Returns(new List <ITask>());
            // Execute:
            obj.LoadApp();
            // Verify:
            var result = obj.Categories[checkIndex].EqualsNames(categoryName);

            Assert.IsTrue(result);
        }
        private void FillddlStandardForCourse()
        {
            ddlStandard.Items.Clear();
            ddlStandard.DataSource     = StandardController.GetAllStandardWhitCourse();
            ddlStandard.DataTextField  = "Name";
            ddlStandard.DataValueField = "StandardKey";
            ddlStandard.DataBind();

            ddlStandard.SelectedValue = "26c2d21c-68e2-427a-8e0c-5df9ba8eae95";

            ddlCourse.Items.Clear();
            ddlCourse.DataSource     = CourseController.GetAllCourseByStandardKey(ddlStandard.SelectedValue);
            ddlCourse.DataTextField  = "Name";
            ddlCourse.DataValueField = "StandardCourseKey";
            ddlCourse.DataBind();
        }
Exemplo n.º 18
0
        public void Controller_Methods_HidesCompletedTaskListInUI()
        { // TODO: Something wrong with mocks here.
            // Prepare:
            var name     = "Completed";
            var form     = new Mock <IForm>();
            var obj      = new StandardController(form.Object, new Mock <IStorage>().Object);
            var category = new Mock <ICategory>();

            category.Setup(x => x.Name).Returns(name);
            category.Setup(x => x.Tasks).Returns(new List <ITask>());
            form.Setup(x => x.DeleteCategoryFromDisplay(category.Object));
            // Execute:
            obj.HideCompletedTaskList();
            // Verify:
            form.Verify(x => x.DeleteCategoryFromDisplay(category.Object));
        }
Exemplo n.º 19
0
        public async Task endpoint_invocation___returns_true_for_api_response_and_uri_and_body_parameter_and_extra_parameters_endpoint()
        {
            var controller = new StandardController();

            var uriModel = new StandardModel
            {
                IntProp = 204
            };

            var bodyModel = new StandardNullableModel
            {
                IntProp = 301
            };

            var context = new ApiRequestContext
            {
                RequestAborted = new CancellationToken(false),
                Request        = new ApiRequestInfo
                {
                    InvocationContext = new ApiInvocationContext
                    {
                        ControllerInstance = controller,
                        UriModel           = uriModel,
                        BodyModel          = bodyModel
                    }
                },
                Routing = new ApiRoutingInfo
                {
                    Route = new ApiRoutingItem
                    {
                        Location = new ApiEndpointLocation(
                            controller: controller.GetType(),
                            methodInfo: controller.GetType().GetMethod(nameof(controller.DefaultFullApiResponseEndpointWithUriParameterAndBodyParameterAndExtraParameters)),
                            httpMethod: null)
                    }
                }
            };

            var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false);

            processed.Should().BeTrue();

            context.Response.Should().NotBeNull();
            context.Response.StatusCode.Should().Be(200);
            context.Response.ResponseObject.Should().BeOfType <int>();
            context.Response.ResponseObject.Should().Be(301);
        }
Exemplo n.º 20
0
    public void StartTestLevel(int level)
    {
        GameObject playerLoad = GameObject.Find("PlayerLoader");

        if (playerLoad != null)
        {
            GameObject         firstController = Instantiate(prefabTestController, playerLoad.transform);
            StandardController stController    = firstController.GetComponent <StandardController>();
            stController.SetupButtons(true, 0);

            GameObject         secondController = Instantiate(prefabTestController, playerLoad.transform);
            StandardController stController2    = secondController.GetComponent <StandardController>();
            stController2.SetupButtons(false, 1);
        }

        SceneManager.LoadScene(2, LoadSceneMode.Additive);
    }
        public async Task logoutv2()
        {
            var std = new StandardController();

            //HttpClient client = new HttpClient();
            //client.BaseAddress = new Uri(url_logout);
            ////client.DefaultRequestHeaders.Accept.Clear();
            ////client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            //HttpResponseMessage response = await client.GetAsync(url_logout);
            //string responseContent = await response.Content.ReadAsStringAsync();

            FormsAuthentication.SignOut();
            string url_logout = ConfigurationManager.AppSettings["Child_URL"] + "member/Logoutv2";


            Response.Redirect(url_logout);
        }
Exemplo n.º 22
0
    // Return to control selection
    public void ReturnToController()
    {
        stController    = null;
        phoneConnection = null;
        phonecontrol    = false;

        Destroy(currentControl);
        currentControl = null;

        hasCurrentControl = false;

        backgroundImage.enabled = true;

        playerMenuLoadConnection.SetActive(false);
        playerMenuCharacters.SetActive(false);
        playerMenuController.SetActive(true);

        parentCode.UpdateNavigation(false, this);
    }
Exemplo n.º 23
0
        public void Controller_DataControlMethods_QueringTaskListWorksProperly()
        {
            // Prepare:
            var nameTask     = "Task";
            var nameCategory = "Category";
            var list         = new List <ITask>();
            var obj          = new StandardController(new Mock <IForm>().Object, new Mock <IStorage>().Object);
            var mockTask     = new Mock <ITask>();
            var mockCategory = new Mock <ICategory>();

            mockTask.Setup(x => x.Name).Returns(nameTask);
            mockTask.Setup(x => x.Category).Returns(nameCategory);
            list.Add(mockTask.Object);
            mockCategory.Setup(x => x.Name).Returns(nameCategory);
            mockCategory.Setup(x => x.Tasks).Returns(list);
            obj.Categories.Add(mockCategory.Object);
            // Execute:
            var result = obj.QueryTask(nameTask);

            // Verify:
            Assert.AreEqual(mockTask.Object, result);
        }
Exemplo n.º 24
0
        public async Task endpoint_invocation___returns_true_for_void_and_empty_parameter_endpoint()
        {
            var controller = new StandardController();

            var context = new ApiRequestContext
            {
                RequestAborted = new System.Threading.CancellationToken(false),
                Request        = new ApiRequestInfo
                {
                    InvocationContext = new ApiInvocationContext
                    {
                        ControllerInstance = controller,
                        //ControllerMethod = controller.GetType().GetMethod(nameof(controller.DefaultEndpoint))
                    }
                }
            };

            var processed = await context.ProcessHttpEndpointInvocation().ConfigureAwait(false);

            processed.Should().BeTrue();

            context.Response.Should().NotBeNull();
            context.Response.ResponseObject.Should().BeNull();
        }
Exemplo n.º 25
0
    // Start is called before the first frame update
    void Start()
    {
        playerload       = GameObject.Find("PlayerLoader");
        parentCharacters = transform.Find("Characters");
        settings         = new SettingsLevel(moveSpeed, jumpSpeed, gravity, distanceRangerAttack);

        if (playerload != null)
        {
            foreach (Transform child in playerBoardUI)
            {
                Destroy(child.gameObject);
            }

            int i = 0;
            foreach (Transform child in playerload.transform)
            {
                Vector3    spawnPoint    = new Vector3(0, 2.5f, 0);
                Quaternion rotationPoint = Quaternion.identity;

                Transform transformSpawnPoint = parentSpawnPointCharacters.GetChild(i);
                if (transformSpawnPoint != null)
                {
                    spawnPoint    = transformSpawnPoint.position;
                    rotationPoint = transformSpawnPoint.rotation;
                }

                StandardController stController = child.GetComponent <StandardController>();
                if (stController != null)
                {
                    GameObject character = stController.StartGame(parentCharacters, spawnPoint, rotationPoint, settings);

                    GameObject scoreUI = Instantiate(prefabPlayerScore, playerBoardUI);

                    PlayerManager pManager = character.GetComponent <PlayerManager>();
                    pManager.killsNeeded = killsNeeded;

                    PlayerUI uiPlayer = scoreUI.GetComponent <PlayerUI>();
                    uiPlayer.SetPlayer(pManager);
                    uiPlayer.ShowBells();
                }

                ClientServerConnection phoneConnection = child.GetComponent <ClientServerConnection>();
                if (phoneConnection != null)
                {
                    GameObject character = phoneConnection.StartGame(parentCharacters, spawnPoint, rotationPoint, settings);

                    GameObject scoreUI = Instantiate(prefabPlayerScore, playerBoardUI);

                    PlayerManager pManager = character.GetComponent <PlayerManager>();
                    pManager.killsNeeded = killsNeeded;

                    PlayerUI uiPlayer = scoreUI.GetComponent <PlayerUI>();
                    uiPlayer.SetPlayer(pManager);
                    uiPlayer.ShowBells();
                }

                i++;
            }
        }

        // Switch menu clients
        Server.StartGame();

        // Show message
        StartCoroutine(ShowMessage());

        pickups.SearchForPlayers();

        if (FadeInOut.screen != null)
        {
            FadeInOut.screen.FadeIn();
        }
    }
Exemplo n.º 26
0
        public void StartRecording()
        {
            source_type = Source.FILE;
            //NEED to run this world-sycnrhonously
            World currentWorld        = metagen_comp.World;
            int   currentTotalUpdates = currentWorld.TotalUpdates;
            Slot  logix_slot          = metagen_comp.World.RootSlot.AddSlot("temporary logix slot");
            bool  added_logix         = false;

            currentWorld.RunSynchronously(() =>
            {
                foreach (var userItem in metagen_comp.userMetaData)
                {
                    User user             = userItem.Key;
                    UserMetadata metadata = userItem.Value;
                    if (!metadata.isRecording || (metagen_comp.LocalUser == user && !metagen_comp.record_local_user))
                    {
                        continue;
                    }
                    RefID user_id = user.ReferenceID;

                    current_tracked_users.Add(user_id);

                    ReferenceRegister <User> userRegister     = logix_slot.AttachComponent <ReferenceRegister <User> >();
                    userRegister.Target.Target                = user;
                    StandardController standardControllerLeft = logix_slot.AttachComponent <FrooxEngine.LogiX.Input.StandardController>();
                    EnumInput <Chirality> nodeEnum            = logix_slot.AttachComponent <EnumInput <Chirality> >();
                    nodeEnum.Value.Value = Chirality.Left;
                    standardControllerLeft.User.Target = userRegister;
                    standardControllerLeft.Node.Target = nodeEnum;
                    SyncRef <ValueStream <bool> > _primaryStreamLeft   = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_primaryStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerLeft);
                    SyncRef <ValueStream <bool> > _secondaryStreamLeft = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_secondaryStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerLeft);
                    SyncRef <ValueStream <bool> > _grabStreamLeft      = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_grabStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerLeft);
                    SyncRef <ValueStream <bool> > _menuStreamLeft      = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_menuStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerLeft);
                    SyncRef <ValueStream <float> > _strengthStreamLeft = (SyncRef <ValueStream <float> >) typeof(StandardController).GetField("_strengthStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerLeft);
                    SyncRef <ValueStream <float2> > _axisStreamLeft    = (SyncRef <ValueStream <float2> >) typeof(StandardController).GetField("_axisStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerLeft);

                    StandardController standardControllerRight = logix_slot.AttachComponent <FrooxEngine.LogiX.Input.StandardController>();
                    EnumInput <Chirality> nodeEnum2            = logix_slot.AttachComponent <EnumInput <Chirality> >();
                    nodeEnum2.Value.Value = Chirality.Right;
                    standardControllerRight.User.Target = userRegister;
                    standardControllerRight.Node.Target = nodeEnum2;
                    SyncRef <ValueStream <bool> > _primaryStreamRight   = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_primaryStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerRight);
                    SyncRef <ValueStream <bool> > _secondaryStreamRight = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_secondaryStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerRight);
                    SyncRef <ValueStream <bool> > _grabStreamRight      = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_grabStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerRight);
                    SyncRef <ValueStream <bool> > _menuStreamRight      = (SyncRef <ValueStream <bool> >) typeof(StandardController).GetField("_menuStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerRight);
                    SyncRef <ValueStream <float> > _strengthStreamRight = (SyncRef <ValueStream <float> >) typeof(StandardController).GetField("_strengthStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerRight);
                    SyncRef <ValueStream <float2> > _axisStreamRight    = (SyncRef <ValueStream <float2> >) typeof(StandardController).GetField("_axisStream", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(standardControllerRight);

                    primaryStreamsRefs[user_id]   = new Tuple <SyncRef <ValueStream <bool> >, SyncRef <ValueStream <bool> > >(_primaryStreamLeft, _primaryStreamRight);
                    secondaryStreamsRefs[user_id] = new Tuple <SyncRef <ValueStream <bool> >, SyncRef <ValueStream <bool> > >(_secondaryStreamLeft, _secondaryStreamRight);
                    grabStreamsRefs[user_id]      = new Tuple <SyncRef <ValueStream <bool> >, SyncRef <ValueStream <bool> > >(_grabStreamLeft, _grabStreamRight);
                    menuStreamsRefs[user_id]      = new Tuple <SyncRef <ValueStream <bool> >, SyncRef <ValueStream <bool> > >(_menuStreamLeft, _menuStreamRight);
                    strengthStreamsRefs[user_id]  = new Tuple <SyncRef <ValueStream <float> >, SyncRef <ValueStream <float> > >(_strengthStreamLeft, _strengthStreamRight);
                    axisStreamsRefs[user_id]      = new Tuple <SyncRef <ValueStream <float2> >, SyncRef <ValueStream <float2> > >(_axisStreamLeft, _axisStreamRight);
                }
                added_logix = true;
                UniLog.Log("Added logix");
            });
            metagen_comp.StartTask(async() =>
            {
                Task task = Task.Run(() =>
                {
                    bool all_streams_not_null        = false;
                    List <RefID> good_tracking_users = new List <RefID>();

                    //UniLog.Log("HO");
                    while (!all_streams_not_null & currentWorld.TotalUpdates <= currentTotalUpdates + 60)
                    {
                        if (!added_logix)
                        {
                            continue;
                        }
                        //UniLog.Log("HI");
                        bool all_user_streams_not_null = true;
                        all_streams_not_null           = true;
                        foreach (RefID user_id in current_tracked_users)
                        {
                            //HMM: why does using .Target here rather than .RawTarget give a NullReferenceException??
                            bool primary_streams_not_null   = (primaryStreamsRefs[user_id].Item1.RawTarget != null) & (primaryStreamsRefs[user_id].Item2.RawTarget != null);
                            bool secondary_streams_not_null = (secondaryStreamsRefs[user_id].Item1.RawTarget != null) & (secondaryStreamsRefs[user_id].Item2.RawTarget != null);
                            bool grab_streams_not_null      = (grabStreamsRefs[user_id].Item1.RawTarget != null) & (grabStreamsRefs[user_id].Item2.RawTarget != null);
                            bool menu_streams_not_null      = (menuStreamsRefs[user_id].Item1.RawTarget != null) & (menuStreamsRefs[user_id].Item2.RawTarget != null);
                            bool strength_streams_not_null  = (strengthStreamsRefs[user_id].Item1.RawTarget != null) & (strengthStreamsRefs[user_id].Item2.RawTarget != null);
                            bool axis_streams_not_null      = (axisStreamsRefs[user_id].Item1.RawTarget != null) & (axisStreamsRefs[user_id].Item2.RawTarget != null);

                            all_user_streams_not_null = primary_streams_not_null & secondary_streams_not_null & grab_streams_not_null & menu_streams_not_null & strength_streams_not_null & axis_streams_not_null;

                            if (all_user_streams_not_null)
                            {
                                if (!good_tracking_users.Contains(user_id))
                                {
                                    good_tracking_users.Add(user_id);
                                    UniLog.Log("Added user " + user_id.ToString());
                                }
                            }

                            all_streams_not_null &= all_user_streams_not_null;
                        }
                    }

                    current_tracked_users = good_tracking_users;

                    //Get CommonToolStreamDriver
                    List <RefID> good_tracking_users2 = new List <RefID>();
                    foreach (RefID user_id in current_tracked_users)
                    {
                        User user = currentWorld.GetUser(user_id);
                        List <CommonToolStreamDriver> commonToolStreamDrivers = user.Root.Slot.GetComponents <CommonToolStreamDriver>();
                        ValueStream <bool> primaryBlockedStreamLeft           = null;
                        ValueStream <bool> secondaryBlockedStreamLeft         = null;
                        ValueStream <bool> laserActiveStreamLeft        = null;
                        ValueStream <bool> showLaserToOthersStreamLeft  = null;
                        ValueStream <float3> laserTargetStreamLeft      = null;
                        ValueStream <float> grabDistanceStreamLeft      = null;
                        ValueStream <bool> primaryBlockedStreamRight    = null;
                        ValueStream <bool> secondaryBlockedStreamRight  = null;
                        ValueStream <bool> laserActiveStreamRight       = null;
                        ValueStream <bool> showLaserToOthersStreamRight = null;
                        ValueStream <float3> laserTargetStreamRight     = null;
                        ValueStream <float> grabDistanceStreamRight     = null;
                        foreach (CommonToolStreamDriver driver in commonToolStreamDrivers)
                        {
                            if (driver.Side.Value == Chirality.Left)
                            {
                                primaryBlockedStreamLeft    = driver.PrimaryBlockedStream.Target;
                                secondaryBlockedStreamLeft  = driver.SecondaryBlockedStream.Target;
                                laserActiveStreamLeft       = driver.LaserActiveStream.Target;
                                showLaserToOthersStreamLeft = driver.ShowLaserToOthersStream.Target;
                                laserTargetStreamLeft       = driver.LaserTargetStream.Target;
                                grabDistanceStreamLeft      = driver.GrabDistanceStream.Target;
                            }
                            else if (driver.Side.Value == Chirality.Right)
                            {
                                primaryBlockedStreamRight    = driver.PrimaryBlockedStream.Target;
                                secondaryBlockedStreamRight  = driver.SecondaryBlockedStream.Target;
                                laserActiveStreamRight       = driver.LaserActiveStream.Target;
                                showLaserToOthersStreamRight = driver.ShowLaserToOthersStream.Target;
                                laserTargetStreamRight       = driver.LaserTargetStream.Target;
                                grabDistanceStreamRight      = driver.GrabDistanceStream.Target;
                            }
                        }
                        bool all_common_tool_streams_not_null = primaryBlockedStreamLeft != null & primaryBlockedStreamRight != null
                                                                & secondaryBlockedStreamLeft != null & secondaryBlockedStreamRight != null
                                                                & laserActiveStreamLeft != null & laserActiveStreamRight != null
                                                                & showLaserToOthersStreamLeft != null & showLaserToOthersStreamRight != null
                                                                & laserTargetStreamLeft != null & laserActiveStreamRight != null
                                                                & grabDistanceStreamLeft != null & grabDistanceStreamRight != null;
                        if (all_common_tool_streams_not_null)
                        {
                            good_tracking_users2.Add(user_id);
                            primaryBlockedStreams[user_id]    = new Tuple <ValueStream <bool>, ValueStream <bool> >(primaryBlockedStreamLeft, primaryBlockedStreamRight);
                            secondaryBlockedStreams[user_id]  = new Tuple <ValueStream <bool>, ValueStream <bool> >(secondaryBlockedStreamLeft, secondaryBlockedStreamRight);
                            laserActiveStreams[user_id]       = new Tuple <ValueStream <bool>, ValueStream <bool> >(laserActiveStreamLeft, laserActiveStreamRight);
                            showLaserToOthersStreams[user_id] = new Tuple <ValueStream <bool>, ValueStream <bool> >(showLaserToOthersStreamLeft, showLaserToOthersStreamRight);
                            laserTargetStreams[user_id]       = new Tuple <ValueStream <float3>, ValueStream <float3> >(laserTargetStreamLeft, laserTargetStreamRight);
                            grabDistanceStreams[user_id]      = new Tuple <ValueStream <float>, ValueStream <float> >(grabDistanceStreamLeft, grabDistanceStreamRight);
                        }
                    }
                    current_tracked_users = good_tracking_users2;
                    foreach (RefID user_id in current_tracked_users)
                    {
                        primaryStreams[user_id]   = new Tuple <ValueStream <bool>, ValueStream <bool> >(primaryStreamsRefs[user_id].Item1.RawTarget, primaryStreamsRefs[user_id].Item2.RawTarget);
                        secondaryStreams[user_id] = new Tuple <ValueStream <bool>, ValueStream <bool> >(secondaryStreamsRefs[user_id].Item1.RawTarget, secondaryStreamsRefs[user_id].Item2.RawTarget);
                        grabStreams[user_id]      = new Tuple <ValueStream <bool>, ValueStream <bool> >(grabStreamsRefs[user_id].Item1.RawTarget, grabStreamsRefs[user_id].Item2.RawTarget);
                        menuStreams[user_id]      = new Tuple <ValueStream <bool>, ValueStream <bool> >(menuStreamsRefs[user_id].Item1.RawTarget, menuStreamsRefs[user_id].Item2.RawTarget);
                        strengthStreams[user_id]  = new Tuple <ValueStream <float>, ValueStream <float> >(strengthStreamsRefs[user_id].Item1.RawTarget, strengthStreamsRefs[user_id].Item2.RawTarget);
                        axisStreams[user_id]      = new Tuple <ValueStream <float2>, ValueStream <float2> >(axisStreamsRefs[user_id].Item1.RawTarget, axisStreamsRefs[user_id].Item2.RawTarget);
                        RegisterUserStream(user_id, "controller_streams");
                    }
                    //Destroy LogiX nodes
                    currentWorld.RunSynchronously(() =>
                    {
                        logix_slot.Destroy();
                    });

                    isRecording = true;
                });

                //await CancelAfterAsync(ct=>task, TimeSpan.FromSeconds(30), CancellationToken.None);
                await task;
            });
        }
Exemplo n.º 27
0
        public void Arrange()
        {
            _mockApiClient                = new Mock <IApplicationApiClient>();
            _mockOrgApiClient             = new Mock <IOrganisationsApiClient>();
            _mockQnaApiClient             = new Mock <IQnaApiClient>();
            _mockContactsApiClient        = new Mock <IContactsApiClient>();
            _mockStandardVersionApiClient = new Mock <IStandardVersionClient>();
            _mockHttpContextAccessor      = new Mock <IHttpContextAccessor>();
            _mockApplicationService       = new Mock <IApplicationService>();
            _mockConfig = new Mock <IWebConfiguration>();

            _mockHttpContextAccessor
            .Setup(r => r.HttpContext)
            .Returns(SetupHttpContextSubAuthorityClaim());

            _mockApiClient
            .Setup(r => r.GetApplication(It.IsAny <Guid>()))
            .ReturnsAsync(new ApplicationResponse()
            {
                ApplicationStatus = ApplicationStatus.InProgress,
                ApplyData         = new ApplyData()
                {
                    Sequences = new List <ApplySequence>()
                    {
                        new ApplySequence()
                        {
                            IsActive   = true,
                            SequenceNo = ApplyConst.STANDARD_SEQUENCE_NO,
                            Status     = ApplicationSequenceStatus.Draft
                        }
                    }
                }
            });

            _mockApiClient
            .Setup(r => r.GetAllWithdrawnApplicationsForStandard(It.IsAny <Guid>(), It.IsAny <int>()))
            .ReturnsAsync(new List <ApplicationResponse>()
            {
                new ApplicationResponse {
                    StandardCode = 59, StandardApplicationType = StandardApplicationTypes.VersionWithdrawal
                },
                new ApplicationResponse {
                    StandardCode = 131, StandardApplicationType = StandardApplicationTypes.StandardWithdrawal
                },
                new ApplicationResponse {
                    StandardCode = 354, StandardApplicationType = StandardApplicationTypes.VersionWithdrawal
                },
            });

            _mockApiClient
            .Setup(r => r.GetStandardApplications(It.IsAny <Guid>()))
            .ReturnsAsync(new List <ApplicationResponse>());

            _mockQnaApiClient
            .Setup(r => r.GetApplicationData(It.IsAny <Guid>()))
            .ReturnsAsync(new ApplicationData()
            {
                OrganisationReferenceId = "12345"
            });

            _mockOrgApiClient
            .Setup(r => r.GetEpaOrganisationById(It.IsAny <String>()))
            .ReturnsAsync(new EpaOrganisation()
            {
                OrganisationId = "12345"
            });

            _mockOrgApiClient
            .Setup(r => r.GetEpaOrganisation(It.IsAny <String>()))
            .ReturnsAsync(new EpaOrganisation()
            {
                OrganisationId = "12345"
            });

            _mockOrgApiClient
            .Setup(r => r.GetOrganisationStandardsByOrganisation(It.IsAny <String>()))
            .ReturnsAsync(new List <OrganisationStandardSummary>());

            _mockApiClient
            .Setup(r => r.GetAllWithdrawnApplicationsForStandard(It.IsAny <Guid>(), It.IsAny <int?>()))
            .ReturnsAsync(new List <ApplicationResponse>());

            _mockApiClient
            .Setup(r => r.GetPreviousApplicationsForStandard(It.IsAny <Guid>(), It.IsAny <string>()))
            .ReturnsAsync(new List <ApplicationResponse>());

            _sut = new StandardController(_mockApiClient.Object, _mockOrgApiClient.Object, _mockQnaApiClient.Object,
                                          _mockContactsApiClient.Object, _mockStandardVersionApiClient.Object, _mockApplicationService.Object, _mockHttpContextAccessor.Object, _mockConfig.Object)
            {
                TempData = new TempDataDictionary(new DefaultHttpContext(), Mock.Of <ITempDataProvider>())
            };
        }
        public async Task <ActionResult> btn_login(string username, string password, string capcha, bool remember)
        {
            string strreturn  = "";
            var    value      = "false";
            var    check_role = false;

            if (Session["randomStr"] != null)
            {
                string getSession = Session["randomStr"].ToString();
                var    list_role  = Roles.GetRolesForUser(username);
                if (list_role.Length > 0)
                {
                    for (var i = 0; i < list_role.Length; i++)
                    {
                        if (list_role[i] != "" && list_role[i] != "engineer")
                        {
                            check_role = true;
                        }
                    }
                }

                if (check_role)
                {
                    if (Membership.ValidateUser(username, password) && capcha == getSession)
                    {
                        var    dnow          = DateTime.Now.AddDays(1);
                        string formsAuthSalt = Membership.GeneratePassword(20, 2);
                        // string userData = string.Join("|", GetCustomUserRoles());

                        FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
                            1,                                                      // ticket version
                            username,                                               // authenticated username
                            DateTime.Now,                                           // issueDate
                            new DateTime(dnow.Year, dnow.Month, dnow.Day, 0, 5, 0), // expiryDate
                            true,                                                   // true to persist across browser sessions
                            formsAuthSalt,                                          // can be used to store additional user data
                            FormsAuthentication.FormsCookiePath);                   // the path for the cookie

                        // Encrypt the ticket using the machine key
                        string encryptedTicket = FormsAuthentication.Encrypt(ticket);

                        // Add the cookie to the request to save it

                        HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
                        cookie.Expires = remember ? DateTime.Now.AddDays(30) : DateTime.Now.AddDays(1);

                        cookie.HttpOnly = true;
                        cookie.Secure   = true;

                        Response.Cookies.Add(cookie);

                        // Your redirect logic
                        // Response.Redirect(FormsAuthentication.GetRedirectUrl(username, chkremember.Checked));

                        MembershipUser user = Membership.GetUser(username);
                        user.Comment = formsAuthSalt;
                        Membership.UpdateUser(user);
                        value = "true";


                        // login child site
                        if (Roles.IsUserInRole(username, "admin") || Roles.IsUserInRole(username, "admin_installer"))
                        {
                            var std   = new StandardController();
                            var model = new
                            {
                                data = std.GetBodyLogin(username, password, remember)
                            };

                            //string apiUrl = ConfigurationManager.AppSettings["Child_URL"] + "member/login";
                            string url = ConfigurationManager.AppSettings["Child_URL"] + "member/login?token=" + std.GetBodyLogin(username, password, remember);
                            strreturn = "{ \"status\"  : \"1\" ,  \"autourl\" : \"" + url + "\"}";

                            // Response.Redirect(apiUrl);
                            //   HttpClient client = new HttpClient();
                            //client.BaseAddress = new Uri(apiUrl);
                            //client.DefaultRequestHeaders.Accept.Clear();
                            //client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

                            ////var json = JsonConvert.SerializeObject(model);
                            ////var json_body = new StringContent(json, Encoding.UTF8, "application/json");
                            ////HttpResponseMessage response = await client.PostAsync(apiUrl, json_body);
                            //HttpResponseMessage response = await client.GetAsync(apiUrl);
                            //string responseContent = await response.Content.ReadAsStringAsync();
                        }
                        else
                        {
                            strreturn = "{ \"status\"  : \"3\" ,  \"autourl\" : \"" + "" + "\"}";
                        }
                    }
                }
                else
                {
                    strreturn = "{ \"status\"  : \"2\" ,  \"autourl\" : \"" + "" + "\"}";
                    //value = "engineer";
                }
            }
            else
            {
                // value = "false";
                strreturn = "{ \"status\"  : \"0\" ,  \"autourl\" : \"" + "" + "\"}";
            }

            //  return value;
            return(Content(strreturn, "application/json"));
        }
        public ActionResult edit(string id)
        {
            GetDataFromDb();

            Guid check_Guid;
            bool isValid = Guid.TryParse(id, out check_Guid);

            if (isValid)
            {
                Guid newGuid = Guid.Parse(id);
                if (User.IsInRole("admin"))
                {
                    var obj_list_en = (from e in db.tb_engineer
                                       where e.en_guid == newGuid && e.is_delete == 0
                                       select e).FirstOrDefault();

                    if (obj_list_en != null)
                    {
                        ViewData["Data"] = obj_list_en;
                    }
                    else
                    {
                        var url = ConfigurationManager.AppSettings["Base_URL"].ToString() + "engineer/all";
                        Response.Redirect(url);
                    }
                }
                else
                {
                    var getName = User.Identity.Name;

                    var  CheckUser   = Membership.GetUser(getName).ProviderUserKey;
                    Guid convertGuid = new Guid(CheckUser.ToString());
                    var  idStore     = db.tb_mapping_store.Where(w => w.account_guid == convertGuid).Select(s => s.site_id).FirstOrDefault();

                    var obj_list_en = (from e in db.tb_engineer
                                       where e.site_id == idStore && e.en_guid == newGuid && e.is_delete == 0
                                       select e).FirstOrDefault();

                    if (obj_list_en != null)
                    {
                        ViewData["Data"] = obj_list_en;
                    }
                    else
                    {
                        //wait redirect
                        var url = ConfigurationManager.AppSettings["Base_URL"].ToString() + "engineer/all";
                        Response.Redirect(url);
                    }
                }
            }
            else
            {
                var url = ConfigurationManager.AppSettings["Base_URL"].ToString() + "engineer/all";
                Response.Redirect(url);
            }

            ViewData["Azure_Path"] = ConfigurationManager.AppSettings["Azure_url"];
            StandardController service_con = new StandardController();
            string             key_azure   = service_con.GetKeyAzure();

            ViewData["Key_Azure"] = key_azure;

            return(View());
        }