/// <summary>
        /// Validate function for all VPScenarioIDAndRawResultsService commands
        /// </summary>
        /// <param name="validationContext">System.ComponentModel.DataAnnotations.ValidationContext (Describes the context in which a validation check is performed.)</param>
        /// <param name="actionDBType">[ActionDBTypeEnum] (CSSPEnums.ActionDBTypeEnum.html) action type to validate</param>
        /// <returns>IEnumerable of ValidationResult (Where ValidationResult is a container for the results of a validation request.)</returns>
        private IEnumerable <ValidationResult> Validate(ValidationContext validationContext, ActionDBTypeEnum actionDBType)
        {
            string retStr = "";
            Enums  enums  = new Enums(LanguageRequest);
            VPScenarioIDAndRawResults vpScenarioIDAndRawResults = validationContext.ObjectInstance as VPScenarioIDAndRawResults;

            vpScenarioIDAndRawResults.HasErrors = false;

            if (vpScenarioIDAndRawResults.VPScenarioID < 1)
            {
                vpScenarioIDAndRawResults.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._MinValueIs_, "VPScenarioID", "1"), new[] { "VPScenarioID" }));
            }

            if (string.IsNullOrWhiteSpace(vpScenarioIDAndRawResults.RawResults))
            {
                vpScenarioIDAndRawResults.HasErrors = true;
                yield return(new ValidationResult(string.Format(CSSPServicesRes._IsRequired, "RawResults"), new[] { "RawResults" }));
            }

            //RawResults has no StringLength Attribute

            retStr = "";      // added to stop compiling CSSPError
            if (retStr != "") // will never be true
            {
                vpScenarioIDAndRawResults.HasErrors = true;
                yield return(new ValidationResult("AAA", new[] { "AAA" }));
            }
        }
コード例 #2
0
        private VPScenarioIDAndRawResults GetFilledRandomVPScenarioIDAndRawResults(string OmitPropName)
        {
            VPScenarioIDAndRawResults vpScenarioIDAndRawResults = new VPScenarioIDAndRawResults();

            if (OmitPropName != "VPScenarioID")
            {
                vpScenarioIDAndRawResults.VPScenarioID = GetRandomInt(1, 11);
            }
            if (OmitPropName != "RawResults")
            {
                vpScenarioIDAndRawResults.RawResults = GetRandomString("", 20);
            }

            return(vpScenarioIDAndRawResults);
        }
コード例 #3
0
        public JsonResult SaveVPScenarioRawResultsJSON(VPScenarioIDAndRawResults vpScenarioIDAndRawResults)
        {
            // used for the VPAuto Desktop application

            // anybody can get this information
            // No login required

            IPrincipal user = new GenericPrincipal(new GenericIdentity("*****@*****.**", "Forms"), null);

            VPScenarioService vpScenarioService = new VPScenarioService(LanguageEnum.en, user);

            //int VPScenarioID = int.Parse(uploadString.Substring(0, uploadString.IndexOf("|||")));
            //string RawResults = uploadString.Substring(uploadString.IndexOf("|||") + 3);

            VPScenarioModel vpScenarioModel = vpScenarioService.PostSaveResultsInDB(vpScenarioIDAndRawResults.VPScenarioID, vpScenarioIDAndRawResults.RawResults);

            return(Json(vpScenarioModel.Error, JsonRequestBehavior.AllowGet));
        }
コード例 #4
0
ファイル: VPAuthTest.cs プロジェクト: ECCC-CSSP/VPAuto
        public void SaveResultsInDB()
        {
            VPAuto vpAuth = new VPAuto();

            StringBuilder sb = new StringBuilder();

            FileInfo fi = new FileInfo(@"C:\CSSP latest code\VPAuto\VPAuto.Tests\VPResult.txt");

            StreamReader sr = fi.OpenText();

            string FileText = sr.ReadToEnd();

            sr.Close();

            string baseAddress = vpAuth._TextBoxSaveSite.Text;

            //string baseAddress = "http://localhost:11562/en-CA/VisualPlumes/SaveVPScenarioRawResultsJSON";

            VPScenarioIDAndRawResults vpScenarioIDAndRawResults = new VPScenarioIDAndRawResults();

            vpScenarioIDAndRawResults.VPScenarioID = 1;
            vpScenarioIDAndRawResults.RawResults   = FileText;

            string parsedContent = JsonConvert.SerializeObject(vpScenarioIDAndRawResults);

            //string uploadString = "1|||" + FileText;

            WebClient webClient = new WebClient();

            webClient.Headers.Add(HttpRequestHeader.ContentType, "application/json;charset=utf-8");

            // Act
            string RetFromWebClient = webClient.UploadString(baseAddress, "POST", parsedContent);

            //string RetFromWebClient = webClient.UploadString(baseAddress, "POST", uploadString);

            // Assert
            Assert.AreEqual("\"\"", RetFromWebClient);
        }
コード例 #5
0
 public VPScenarioIDAndRawResultsTest()
 {
     vPScenarioIDAndRawResults = new VPScenarioIDAndRawResults();
 }