public void Init()
        {
            SetupMockServices();

            var appSettingsConfig = new AppSettingsConfig()
            {
                LogEndpointOverride = false
            };

            var logValidationRulesConfig = new LogValidationRulesConfig()
            {
                SeverityRegex        = "^(ERROR|INFO|WARNING)$",
                PositiveNumbersRegex = "^[0-9]\\d*$",
                BuildVersionRegex    = "^[1-9]{1}[0-9]*([.][0-9]*){1,2}?$",
                OperationSystemRegex = "^(IOS|Android-Google|Android-Huawei|Unknown)$",
                DeviceOSVersionRegex = "[1-9]{1}[0-9]{0,2}([.][0-9]{1,3}){1,2}?$",
                MaxTextFieldLength   = 500,
            };

            _controller = new LoggingController(_logMessageValidator.Object, _logger.Object, logValidationRulesConfig, appSettingsConfig)
            {
                ControllerContext = new ControllerContext()
                {
                    HttpContext = MakeFakeContext(true).Object
                }
            };
        }
Exemplo n.º 2
0
        public void LogOperationWasSuccessful()
        {
            var service       = new LoggingController();
            var wasSuccessful = service.LogAndGetSuccessStatus();

            Assert.That(wasSuccessful, Is.True);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update override method called by Unity editor. The update cycle looks
        /// for any action events that were generated in the OnGUI method by the
        /// user and takes action on those events.
        /// </summary>
        void Update()
        {
            if (pluginDataDirty)
            {
                pluginDataDirty = false;
                RefreshPluginDataForWindow();
            }

            while (installPlugins.Count > 0)
            {
                var          pluginKey = installPlugins.Pop();
                ResponseCode rc        = ProjectManagerController.InstallPlugin(pluginKey);
                if (ResponseCode.PLUGIN_NOT_INSTALLED == rc)
                {
                    EditorUtility.DisplayDialog("Plugin Install Error",
                                                "There was a problem installing the selected plugin.",
                                                "Ok");
                    LoggingController.LogError(
                        string.Format("Could not install plugin with key {0}." +
                                      "Got {1} response code.", pluginKey, rc));
                }
                else
                {
                    pluginDataDirty = true;
                }
                installingPlugins.Remove(pluginKey);
            }

            while (moreInfoPlugins.Count > 0)
            {
                var pluginKey = moreInfoPlugins.Pop();
                var plugin    = PluginManagerController.GetPluginForVersionlessKey(
                    PluginManagerController.VersionedPluginKeyToVersionless(pluginKey));
                // popup with full description
                EditorUtility.DisplayDialog(
                    string.Format("{0}", plugin.MetaData.artifactId),
                    plugin.Description.languages[0].fullDesc,
                    "Ok");
            }

            while (uninstallPlugins.Count > 0)
            {
                var          pluginKey = uninstallPlugins.Pop();
                ResponseCode rc        = ProjectManagerController.UninstallPlugin(pluginKey);
                if (ResponseCode.PLUGIN_NOT_REMOVED == rc)
                {
                    EditorUtility.DisplayDialog("Plugin Uninstall Error",
                                                "There was a problem removing the selected plugin.",
                                                "Ok");
                    LoggingController.LogError(
                        string.Format("Could not uninstall plugin with key {0}." +
                                      "Got {1} response code.", pluginKey, rc));
                }
                else
                {
                    pluginDataDirty = true;
                }
                uninstallingPlugins.Remove(pluginKey);
            }
        }
Exemplo n.º 4
0
        public ActionResult Edit(CreateProductHistoryViewModel model)
        {
            var            productHistoryToUpdate = new ProductHistory();
            ProductHistory newProductHistory      = new ProductHistory()
            {
                ProductID = model.ProductID,
                HistoryID = model.HistoryID,
                Comment   = model.Comment,
                Date      = model.DateTimeNow,
                UserID    = model.Email
            };
            var  product = _unityOfWork.Product.getProductWithHistory(model.ProductID);
            long id      = product.ID;

            // find history entry in list of histories
            foreach (var productHistory in product.ProductHistories)
            {
                // a unique history entry is given by ProductID, HistoryID, Date
                if (productHistory.Date.ToString() == model.DateTimeNow.ToString() && model.OldHistoryID == productHistory.HistoryID && model.Email == productHistory.UserID)
                {
                    productHistoryToUpdate = productHistory;
                    break;
                }
            }
            product.ProductHistories.Remove(productHistoryToUpdate);
            product.ProductHistories.Add(newProductHistory);
            _unityOfWork.Product.Update(product);
            _unityOfWork.Save();
            newProductHistory.User   = null;
            newProductHistory.UserID = null;
            LoggingController.writeLog(newProductHistory, User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), this.ControllerContext.RouteData.Values["controller"].ToString());
            return(RedirectToAction("Details", new { id = id }));
        }
Exemplo n.º 5
0
 protected void logoutBtn_Click(object sender, EventArgs e)
 {
     Session.Abandon();
     LoggingController.InsertLogout();
     FormsAuthentication.SignOut();
     Response.Redirect("login.aspx");
 }
Exemplo n.º 6
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (this._loggingController != null)
     {
         this._loggingController.Dispose();
         this._loggingController = null;
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (_loggingController != null)
     {
         _loggingController.Dispose();
         _loggingController = null;
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (this._loggingController != null)
     {
         this._loggingController.Dispose();
         this._loggingController = null;
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
 /// </summary>
 public void Dispose()
 {
     if (_loggingController != null)
     {
         _loggingController.Dispose();
         _loggingController = null;
     }
 }
        public void GivenAllErrorLogsGetMethod_WhenReceivesCorrectQuery_ThenFireMediatorSendMethod()
        {
            var mockMediator      = Substitute.For <IMediator>();
            var loggingController = new LoggingController(mockMediator);

            loggingController.GetAllErrorLogs();

            mockMediator.Received().Send(Arg.Any <AllErrorLogsQuery>());
        }
Exemplo n.º 11
0
        /// <summary>
        /// Construct a sink that saves logs to the specified storage account.
        /// </summary>
        /// <param name="applicationInsightsComponentId">The ID that determines the application component under which your data appears in Application Insights.</param>
        /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        public ApplicationInsightsSink(string applicationInsightsComponentId, IFormatProvider formatProvider)
        {
            if (applicationInsightsComponentId == null) throw new ArgumentNullException("applicationInsightsComponentId");
            if (string.IsNullOrWhiteSpace(applicationInsightsComponentId)) throw new ArgumentOutOfRangeException("applicationInsightsComponentId", "Cannot be empty.");

            _formatProvider = formatProvider;

            _loggingController = LoggingController.CreateLoggingController(applicationInsightsComponentId);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Construct a sink that saves logs to the specified storage account.
        /// </summary>
        /// <param name="applicationInsightsComponentId">The ID that determines the application component under which your data appears in Application Insights.</param>
        /// <param name="formatProvider">Supplies culture-specific formatting information, or null.</param>
        public ApplicationInsightsSink(string applicationInsightsComponentId, IFormatProvider formatProvider)
        {
            if (applicationInsightsComponentId == null)
            {
                throw new ArgumentNullException("applicationInsightsComponentId");
            }
            if (string.IsNullOrWhiteSpace(applicationInsightsComponentId))
            {
                throw new ArgumentOutOfRangeException("applicationInsightsComponentId", "Cannot be empty.");
            }

            _formatProvider = formatProvider;

            _loggingController = LoggingController.CreateLoggingController(applicationInsightsComponentId);
        }
Exemplo n.º 13
0
        protected override void Initialize()
        {
            Model = new TestModel();

            var references = new References();

            _loggingController = new LoggingController();

            _moqLoggingPersistence = new Mock <ILoggingPersistence>();
            _loggingPersistence    = _moqLoggingPersistence.Object;

            references.Put(new Descriptor("pip-services-logging", "persistence", "memory", "default", "1.0"), _loggingPersistence);
            references.Put(new Descriptor("pip-services-logging", "controller", "default", "default", "1.0"), _loggingController);

            _loggingController.SetReferences(references);
        }
Exemplo n.º 14
0
        public void LogSomething_Should_Log_Expected_Messages()
        {
            // Arrange
            var loggerMock           = new Mock <ILogger <LoggingController> >();
            var dateTimeProviderMock = new Mock <IDateTimeProvider>();

            dateTimeProviderMock.Setup(x => x.Now).Returns(new DateTime(2020, 10, 13, 10, 0, 0));
            var sut = new LoggingController(loggerMock.Object, dateTimeProviderMock.Object);

            // Act
            sut.LogSomething();

            // Assert
            loggerMock.VerifyLogging("Something", LogLevel.Information)
            .VerifyLogging("Log something called in 10/13/2020 10:00:00", LogLevel.Warning);
        }
Exemplo n.º 15
0
        public void PostLoggingMessageBadRequest()
        {
            var controller = new LoggingController
            {
                Request       = new System.Net.Http.HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };


            loggingMessage testMsg = new loggingMessage();

            testMsg.sender = "Doc Brown";
            HttpResponseMessage result = controller.postMessage(testMsg);

            Assert.AreEqual(System.Net.HttpStatusCode.BadRequest, result.StatusCode);
            Assert.AreEqual("Please submit a message value", result.Content.ReadAsAsync <HttpError>().Result.Message);
        }
Exemplo n.º 16
0
        public void PostLoggingMessageOK()
        {
            var controller = new LoggingController
            {
                Request       = new System.Net.Http.HttpRequestMessage(),
                Configuration = new HttpConfiguration()
            };


            loggingMessage testMsg = new loggingMessage();

            testMsg.msg = "Howdy world!!";
            HttpResponseMessage result = controller.postMessage(testMsg);
            var resultText             = result.Content as ObjectContent;

            Assert.AreEqual(System.Net.HttpStatusCode.OK, result.StatusCode);
            Assert.AreEqual(testMsg, resultText.Value);
        }
Exemplo n.º 17
0
        public void Setup()
        {
            AppSettings appSettings = new AppSettings();

            appSettings.Secret = "pintusharmaqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqweqwe";

            _userService    = new Mock <IUserService>();
            _mailService    = new Mock <IMailService>();
            _loggingService = new Mock <ILoggingService>();
            _utility        = new Mock <IUtility>();
            Helper.Utility  = _utility.Object;

            _authenticationService = new AuthenticationService(_userService.Object, _mailService.Object, appSettings);
            _controller            = new LoggingController(_loggingService.Object, _authenticationService);

            // Initializes the database with a valid user with pincode
            User mockUser = new User("13439332", "*****@*****.**", 24.0);

            mockUser.UpdatePincode("1234", DateTime.Now.AddDays(365));
            _userService.Setup(x => x.ValidatePincode(mockUser.Email, "1234")).Returns(mockUser);
            _userService.Setup(x => x.Get(mockUser.Email)).Returns(mockUser);
        }
Exemplo n.º 18
0
        public ActionResult Delete(int productId, string userId, DateTime date, int historyId)
        {
            var productHistoryToDelete = new ProductHistory();
            var product = _unityOfWork.Product.getProductWithHistory(productId);
            int id      = productId;

            foreach (var productHistory in product.ProductHistories)
            {
                if (date.ToString() == productHistory.Date.ToString() && historyId == productHistory.HistoryID && userId == productHistory.UserID)
                {
                    productHistoryToDelete = productHistory;
                    break;
                }
            }
            product.ProductHistories.Remove(productHistoryToDelete);
            _unityOfWork.Product.Update(product);
            _unityOfWork.Save();
            productHistoryToDelete.User   = null;
            productHistoryToDelete.UserID = null;
            LoggingController.writeLog(productHistoryToDelete, User.Identity.Name, this.ControllerContext.RouteData.Values["action"].ToString(), this.ControllerContext.RouteData.Values["controller"].ToString());
            return(RedirectToAction("Details", new { id = id }));
        }
    // Use this for initialization
    void Start()
    {
        timer = 0.0f;
        //Fetches the controller for the visualization object
        controller = VisualizationObject.GetComponent(typeof(VizController)) as VizController;


        //Fetches actual text of the text game objects
        instructionTextMesh = instructText.GetComponent<TextMesh>();
	    remainingCounterTextMesh = counterText.GetComponent<TextMesh>();
        counterText.SetActive(false);

        meter = MeterObject.GetComponent<MeterController>();
        meter.SetStatus(false);

        // Initializes the logger to the singleton instance
        logger = LoggingController.Instance;

        instructionPanel.SetActive(false);
        VisualizationObject.SetActive(false);

        vizObjInitPos = VisualizationObject.transform.position;
        vizObjInitRot = VisualizationObject.transform.rotation.eulerAngles;

        headObjInitPos = head.transform.position;
        headObjInitRot = head.transform.rotation.eulerAngles;

        textArray = logger.LoadText("pilot_text");


        pilotIndex = -1;

        

        /* Block of code for generating random data sets
         * 
         * string ratios = "";
        for (int type = 1; type < 6; type++)
        {
            for (int i = 0; i < 10; i++)
            {
                int barOne, barTwo;
                System.Random rand = new System.Random();
                string[] temp;


                string tempStr = controller.GenerateBar(9, type, rand);
                Debug.Log(tempStr);
                temp = tempStr.Split('|');
                string fileName = String.Format("2D_T{0}_{1}", type, i);

                controller.WriteDataFile(fileName, temp[0]);
                barOne = Int32.Parse(temp[1]);
                barTwo = Int32.Parse(temp[2]);
                ratios += fileName + ": " + ((barOne > barTwo) ? barTwo / barOne : barOne / barTwo) + "\n";
            }
        }
        controller.WriteDataFile("ratios2D", ratios);
        */

        TextAsset templateText = Resources.Load("2D_Spec_Template") as TextAsset;
        if (templateText == null)
        {
            Debug.Log("ERROR - NULL TEMPLATE");
        }

        templateString = templateText.text.Split('|');
        
        Vector3[] transOptions = new Vector3[3];
        transOptions[0] = new Vector3(-0.5f, 0.5f, -0.5f);
        transOptions[1] = new Vector3(0.5f, 0.5f, -0.5f);
        transOptions[2] = new Vector3(0.5f, 0.5f, 0.5f);


        rotations = new Vector3[NUM_EXPERIMENTS];
        translations = new Vector3[NUM_EXPERIMENTS];
        fileNames = new string[NUM_EXPERIMENTS];

        System.Random rand = new System.Random();

        for (int i = 0; i < 30; i++)
        {
            string fileNameOne = "2D_T1_", fileNameTwo = "2D_T3_";

            int type = i % 6;
            int j = 0;

            switch (type)
            {
                case 0:
                    //curDataFile = rand.Next(19) + 1;
                    


                    rotations[i] = Vector3.zero;
                    rotations[i + 30] = Vector3.zero;

                    translations[i] = Vector3.zero;
                    translations[i + 30] = Vector3.zero; 
                    break;
                case 1:
                    rotations[i] = Vector3.zero;
                    rotations[i + 30] = Vector3.zero;


                    j = rand.Next(3);
                    translations[i] = transOptions[j];
                    translations[i + 30] = transOptions[j];
                    break;
                case 2:
                    rotations[i] = new Vector3(0, 30, 0);
                    rotations[i + 30] = new Vector3(0, 30, 0);

                    translations[i] = Vector3.zero;
                    translations[i + 30] = Vector3.zero;
                    break;
                case 3:
                    rotations[i] = new Vector3(-30, 0, 0);
                    rotations[i + 30] = new Vector3(-30, 0, 0);

                    translations[i] = Vector3.zero;
                    translations[i + 30] = Vector3.zero;
                    break;
                case 4:
                    rotations[i] = new Vector3(-30, 0, 0);
                    rotations[i + 30] = new Vector3(-30, 0, 0);
                    
                    j = rand.Next(3);
                    translations[i] = transOptions[j];
                    translations[i + 30] = transOptions[j];
                    break;
                case 5:
                    rotations[i] = new Vector3(0, 30, 0);
                    rotations[i + 30] = new Vector3(0, 30, 0);

                    j = rand.Next(3);
                    translations[i] = transOptions[j];
                    translations[i + 30] = transOptions[j];
                    break;
            }

            fileNames[i] = fileNameOne + rand.Next(20);
            fileNames[i + 30] = fileNameTwo + rand.Next(20);


        }

        if (RANDOMIZE)
        {
            Array.Sort(fileNames, RandomSort);
            for (int t = 0; t < NUM_EXPERIMENTS; t++)
            {
                Debug.Log(fileNames[t]);
            }
            Array.Sort(rotations, RandomSort);
            Array.Sort(translations, RandomSort);
        }
    }
Exemplo n.º 20
0
    // Use this for initialization
    void Start()
    {
        timer = 0.0f;
        //Fetches the controller for the visualization object
        controller = VisualizationObject.GetComponent(typeof(VizController)) as VizController;

        //Fetches actual text of the text game objects
        instructionTextMesh = instructText.GetComponent <TextMesh>();

        instructionPanel.SetActive(false);
        VisualizationObject.SetActive(false);

        vizObjInitPos = VisualizationObject.transform.position;
        vizObjInitRot = VisualizationObject.transform.rotation;

        // Initializes the logger to the singleton instance
        logger = LoggingController.Instance;

        meter = MeterObject.GetComponent <MeterController>();

        textArray = logger.LoadText("tutorial_text");

        tutorialIndex = -1;



        /* Block of code for generating random data sets
         *
         * string ratios = "";
         * for (int type = 1; type < 6; type++)
         * {
         *  for (int i = 10; i < 20; i++)
         *  {
         *      int barOne, barTwo;
         *      System.Random rand = new System.Random();
         *      string[] temp;
         *
         *
         *      string tempStr = controller.GenerateBar(9, type, rand);
         *      Debug.Log(tempStr);
         *      temp = tempStr.Split('|');
         *      string fileName = String.Format("2D_T{0}_{1}", type, i);
         *
         *      controller.WriteDataFile(fileName, temp[0]);
         *      barOne = Int32.Parse(temp[1]);
         *      barTwo = Int32.Parse(temp[2]);
         *      ratios += fileName + ": " + ((barOne > barTwo) ? barTwo / barOne : barOne / barTwo) + "\n";
         *  }
         * }
         * controller.WriteDataFile("ratios2D_PilotStudies", ratios);
         */

        TextAsset templateText = Resources.Load("2D_Spec_Template") as TextAsset;

        if (templateText == null)
        {
            Debug.Log("ERROR - NULL TEMPLATE");
        }

        templateString = templateText.text.Split('|');
    }
Exemplo n.º 21
0
 public BeatSyncFeedReaderLogger(LoggingController controller)
     : this()
 {
     LogController = controller;
 }
Exemplo n.º 22
0
        /// <summary>
        /// Update override method called by Unity editor. The update cycle looks
        /// for any action events that were generated in the OnGUI method by the
        /// user and takes action on those events.
        /// </summary>
        void Update()
        {
            if (registryDataDirty)
            {
                LoggingController.Log("plugin data marked dirty - refreshing...");
                registryDataDirty = false;
                RegistryManagerController.RefreshRegistryCache();
                EditorUtility.SetDirty(this);
            }

            while (installRegistry.Count > 0)
            {
                var regUriStr = installRegistry.Pop();
                try {
                    ResponseCode rc = RegistryManagerController.AddRegistry(new Uri(regUriStr));
                    if (ResponseCode.REGISTRY_ADDED == rc)
                    {
                        registryDataDirty = true;
                    }
                    else if (ResponseCode.REGISTRY_ALREADY_PRESENT == rc)
                    {
                        EditorUtility.DisplayDialog("Registry Already Present",
                                                    "The registry was NOT added since it" +
                                                    "is already known.",
                                                    "Ok");
                    }
                    else
                    {
                        EditorUtility.DisplayDialog("Registry Location Not Valid",
                                                    string.Format(
                                                        "The registry cannot be added. An " +
                                                        "error has occured using the provided " +
                                                        "location.\n\n{0}", rc),
                                                    "Ok");
                    }
                } catch (Exception e) {
                    // failure - bad data
                    EditorUtility.DisplayDialog("Registry Location Processing Error",
                                                string.Format("A processing exception was " +
                                                              "generated while trying to add {0}." +
                                                              "\n\n{1}", regUriStr, e),
                                                "Ok");
                }
            }

            while (uninstallRegistry.Count > 0)
            {
                var regUriStr = uninstallRegistry.Pop();
                if (EditorUtility.DisplayDialog("Confirm Delete Registry",
                                                "Are you sure you want to delete the registry?",
                                                "Yes Delete It!",
                                                "Cancel"))
                {
                    ResponseCode rc = RegistryManagerController
                                      .RemoveRegistry(new Uri(regUriStr));
                    registryDataDirty = true;
                    if (ResponseCode.REGISTRY_NOT_FOUND == rc)
                    {
                        EditorUtility.DisplayDialog("Registry Not Found!",
                                                    "There was a problem while trying to " +
                                                    "remove the registry. It was not " +
                                                    "found when we tried to remove it."
                                                    , "Ok");
                    }
                }
            }
        }