public JsonResult RegistUser(string text) { var ajaxResult = new AjaxResult(); var rows = text.Replace("\r\n", "\n").Split('\n'); var nowDisplayRole = HogwartsSettingUtility.GetSetting(HogwartsSettingUtility.NowDisplayRole); var email = nowDisplayRole + @"@obic.co.jp"; var registCounter = 0; foreach (var row in rows) { if (row == string.Empty) { continue; } try { var columns = row.Split('\t'); UserUtility.CreateUser(columns[0], columns[1], email, "P@ssw0rd", nowDisplayRole); registCounter++; } catch (Exception e) { ajaxResult.Message = e.Message; } } ajaxResult.ResultData = registCounter.ToString() + "人登録しました"; ajaxResult.Result = true; return(ajaxResult.GetJsonRsult()); }
private void createRolesandUsers() { UserUtility.CreateRole("Admin"); UserUtility.CreateRole("52th"); UserUtility.CreateRole("53th"); UserUtility.CreateRole("54th"); UserUtility.CreateRole("55th"); UserUtility.CreateRole("56th"); UserUtility.CreateRole("57th"); UserUtility.CreateRole("58th"); UserUtility.CreateRole("59th"); UserUtility.CreateRole("60th"); HogwartsSettingUtility.CreateHogwartsSettingInitialize(HogwartsSettingUtility.NowDisplayRole, "Sample"); HogwartsSettingUtility.CreateHogwartsSettingInitialize(HogwartsSettingUtility.NowLecture, null); UserUtility.CreateUser("manager", "manager", "*****@*****.**", "P@ssw0rd", "Admin"); UserUtility.CreateRole("Sample"); UserUtility.CreateUser("sample1", "sample1", "*****@*****.**", "P@ssw0rd", "Sample"); UserUtility.CreateUser("sample2", "sample2", "*****@*****.**", "P@ssw0rd", "Sample"); UserUtility.CreateUser("sample3", "sample3", "*****@*****.**", "P@ssw0rd", "Sample"); UserUtility.CreateUser("sample4", "sample4", "*****@*****.**", "P@ssw0rd", "Sample"); UserUtility.CreateUser("sample5", "sample5", "*****@*****.**", "P@ssw0rd", "Sample"); }
public void LoginWithGoodCredentialsReturnsUser() { dynamic json = new { UserInfo = UserUtility.CreateUser("*****@*****.**", "John Smith"), Token = Guid.NewGuid(), ValidityStart = DateTime.Now.ToUniversalTime().ToString("o"), ValidityLimit = DateTime.Now.ToUniversalTime().AddMinutes(10).ToString("o") }; string content = JsonConvert.SerializeObject(json); Mock <HttpWebRequest> mockWebRequest = FakeWebRequest.CreateRequestWithResponse(content); mockWebRequest.SetupSet(r => r.Method = "POST").Verifiable(); mockWebRequest.SetupSet(r => r.ContentType = "application/json").Verifiable(); User user = request.Login("*****@*****.**", "aproplan").GetAwaiter().GetResult(); UriBuilder uriBuilder = new UriBuilder("https://api.aproplan.com/rest/simpleloginsecure"); string expectedUrl = AproplanApiUtility.BuildRestUrl(request.ApiRootUrl, "simpleloginsecure", request.ApiVersion, request.RequesterId); dynamic requestData = AproplanApiUtility.GetRequestData <ExpandoObject>(mockWebRequest); Assert.AreEqual(expectedUrl, FakeWebRequest.Instance.UriCalled[0].ToString()); Assert.AreEqual(json.UserInfo.Id, user.Id); Assert.AreEqual("*****@*****.**", requestData.alias); Assert.AreEqual("aproplan", requestData.pass); Assert.AreEqual(json.UserInfo.Id, request.CurrentUser.Id); Assert.AreEqual(DateTime.Parse(json.ValidityStart).ToLocalTime(), request.TokenInfo.ValidityStart); Assert.AreEqual(DateTime.Parse(json.ValidityLimit).ToLocalTime(), request.TokenInfo.ValidityLimit); mockWebRequest.Verify(); }
public static List <FormTemplate> GetFakeSimpleFormTemplates() { User user = UserUtility.CreateUser("*****@*****.**", "John Smith"); List <FormTemplate> fakeTemplates = new List <FormTemplate> { new FormTemplate { Id = Guid.NewGuid(), Type = FormType.Quality, Subject = "Template 1", MustDisplayElementsCode = true, Creator = user }, new FormTemplate { Id = Guid.NewGuid(), Type = FormType.Safety, Subject = "Template 2", MustDisplayElementsCode = true, Creator = user }, new FormTemplate { Id = Guid.NewGuid(), Type = FormType.Quality, Subject = "Template 3", MustDisplayElementsCode = false, Creator = user }, new FormTemplate { Id = Guid.NewGuid(), Type = FormType.Safety, Subject = "Template 4", MustDisplayElementsCode = false, Creator = user }, new FormTemplate { Id = Guid.NewGuid(), Type = FormType.Environment, Subject = "Template 5", MustDisplayElementsCode = true, Creator = user } }; return(fakeTemplates); }
public static FormTemplate GetFakeCompleteFormTemplate() { User user = UserUtility.CreateUser("*****@*****.**", "John Smith"); FormTemplate template = new FormTemplate { Id = Guid.NewGuid(), Type = FormType.Quality, Subject = "Template 1", MustDisplayElementsCode = true, Creator = user }; template.SectionRules = new List <FormSectionRule>(); template.SectionRules.Add(new FormSectionRule { Id = Guid.NewGuid(), Description = "Section 1", Code = "S1" }); template.Questions = new List <FormQuestion>(); template.Questions.Add(new FormQuestion { ItemType = FormItemType.PredefinedString, Title = "Question 1", Code = "S1.1", DisplayOrder = 1, Template = "{\"title\":\"Question 1\",\"description\":\"\", \"type\":\"string\", \"format\":null,\"availableChoices\":null,\"enum\":[\"OK\", \"NOK\"],\"max -length\":null,\"minimum\":null,\"maximum\":null,\"pattern\":null}", FormTemplateID = template.Id, SectionRuleId = template.SectionRules[0].Id, }); template.Questions.Add(new FormQuestion { ItemType = FormItemType.PredefinedString, Title = "Question 2", Code = "S1.2", DisplayOrder = 2, Template = "{\"title\":\"Question 2\",\"description\":\"\", \"type\":\"string\", \"format\":null,\"availableChoices\":null,\"enum\":[\"OK\", \"NOK\"],\"max -length\":null,\"minimum\":null,\"maximum\":null,\"pattern\":null}", FormTemplateID = template.Id, SectionRuleId = template.SectionRules[0].Id, VisibleCondition = new FilterProperty { ItemId = template.Questions[0].Id, Value = "Yes" } }); template.SectionRules.Add(new FormSectionRule { Id = Guid.NewGuid(), Description = "Section 2", Code = "S2", VisibleCondition = new FilterProperty { ItemId = template.Questions[1].Id, Value = "No" } }); template.Questions.Add(new FormQuestion { ItemType = FormItemType.FreeText, Title = "Question 3", Code = "S2.1", DisplayOrder = 3, Template = "{\"title\":\"Question 3\",\"description\":\"\", \"type\":\"string\", \"format\":null,\"availableChoices\":null,\"max -length\":null,\"minimum\":null,\"maximum\":null,\"pattern\":null}", FormTemplateID = template.Id, SectionRuleId = template.SectionRules[0].Id }); return(template); }