public JsonResult Update(User user) { if (user.PassWordNew != null) { user.PassWord = SMCommon.MD5Endcoding(user.PassWordNew).ToLower(); } return(Json(userDB.Insert(user), JsonRequestBehavior.AllowGet)); }
private PermisionControllerVM getPermisionControllerViewModel() { return(SMCommon.getPermisionControllerViewModel(RouteData.Values["controller"].ToString(), (Session["UserPermission"] as ReturnUserPermission))); }
public ActionResult CheckLogin(string userid, string password) { //--------------------------------------------------------------------- if (Request.HttpMethod == "GET") { return(RedirectToAction("Login")); } //check validation. string errorNotify = ""; if (String.IsNullOrEmpty(userid)) { errorNotify = " Nhập tên đăng nhập/Input UserName."; } if (String.IsNullOrEmpty(password)) { errorNotify += " Nhập mật khẩu/Input password."; } if (!String.IsNullOrEmpty(errorNotify)) { ViewBag.error = errorNotify; return(RedirectToAction("Login")); } var passwordMd5 = SMCommon.MD5Endcoding(password.Trim()).ToLower(); ReturnUser returnUser = (new UserDB()).CheckLogin(userid.Trim(), passwordMd5); if (returnUser.Code == "01") { errorNotify += " Tên đăng nhập hoặc mật khẩu không đúng/UserName or Password is incorrect!"; } if (returnUser.Code == "99") { errorNotify += " Kiểm tra lại đường truyền/Check connection."; } if (!String.IsNullOrEmpty(errorNotify)) { ViewBag.error = " Lỗi đăng nhập/Error Login: "******"Login")); } //Validation is successful. if (returnUser.Code == "00") // exist user. { User user = returnUser.lstUser[0]; MyShareInfo.ID = user.ID; MyShareInfo.UserName = user.UserName; MyShareInfo.PassWord = user.PassWord; MyShareInfo.FullName = user.FullName; MyShareInfo.MobileNumber = user.MobileNumber; MyShareInfo.FactoryID = user.FactoryID; MyShareInfo.RoleID = user.RoleID; //Session["UserLogin"] = user; Session["UserID"] = user.ID; Session["UserName"] = user.UserName; Session["FactoryID"] = user.FactoryID; #region dynamic menu by userid MenuDB menuDB = new MenuDB(); User currentUser = new User() { ID = Convert.ToInt32(Session["UserID"].ToString()) }; ReturnMenuRole returnMenuRole = menuDB.GetMenusByUserID(currentUser); var menuViewModel = new MenuViewModel { returnMenuRole = returnMenuRole, user = currentUser }; Session["MenuPermission"] = menuViewModel; #endregion //Permission Session["UserPermission"] = (new UserDB()).ListAllControllerName_PermissionByUserID(user.ID); return(RedirectToAction("Index")); } return(RedirectToAction("Login")); }
public JsonResult CheckPermission_ByUserNameAndPassword(string userName, string password, string permission) { var passwordMd5 = SMCommon.MD5Endcoding(password.Trim()).ToLower(); return(Json(userDB.CheckPermission_ByUserNameAndPassword(userName, passwordMd5, permission), JsonRequestBehavior.AllowGet)); }
public JsonResult SearchByUserNameAndPassword(string userName, string password) { var passwordMd5 = SMCommon.MD5Endcoding(password.Trim()).ToLower(); return(Json(userDB.SearchByUserNameAndPassword(userName, passwordMd5), JsonRequestBehavior.AllowGet)); }
public JsonResult Insert(User user) { user.PassWord = SMCommon.MD5Endcoding(user.PassWord).ToLower(); return(Json(userDB.Insert(user), JsonRequestBehavior.AllowGet)); }
/// <summary> /// Performs validation of Config options. /// Will log errors and warnings. /// Returns true if no errors were found. /// </summary> /// <returns>True of no errors were found and false otherwise.</returns> public bool Validate() { var errors = false; if (RegexTimeoutSeconds <= 0.0) { LogError($"Invalid RegexTimeoutSeconds {RegexTimeoutSeconds}. Must be greater than 0.0."); errors = true; } if (string.IsNullOrEmpty(InputDirectory)) { LogError("No InputDirectory specified."); errors = true; } if (string.IsNullOrEmpty(InputNameRegex)) { LogError("No InputNameRegex specified."); errors = true; } else if (!IsValidRegex(InputNameRegex)) { LogError($"Invalid regular expression for InputNameRegex: \"{InputNameRegex}\"."); errors = true; } if (string.IsNullOrEmpty(InputChartType)) { LogError("No InputChartType specified."); errors = true; } else { var smChartTypeValid = SMCommon.TryGetChartType(InputChartType, out _); if (!smChartTypeValid) { LogError($"InputChartType \"{InputChartType}\" is not a valid stepmania chart type."); errors = true; } } if (OutputVisualizations && string.IsNullOrEmpty(VisualizationsDirectory)) { LogError("OutputVisualizations is true, but no VisualizationsDirectory specified."); errors = true; } if (string.IsNullOrEmpty(OutputDirectory)) { LogError("No OutputDirectory specified."); errors = true; } if (string.IsNullOrEmpty(DifficultyRegex)) { LogError("No DifficultyRegex specified."); errors = true; } else if (!IsValidRegex(DifficultyRegex)) { LogError($"Invalid regular expression for DifficultyRegex: \"{DifficultyRegex}\"."); errors = true; } if (string.IsNullOrEmpty(OutputChartType)) { LogError("No OutputChartType specified."); errors = true; } if (OutputChartType != null) { var smChartTypeValid = SMCommon.TryGetChartType(OutputChartType, out var smChartType); if (!smChartTypeValid) { LogError($"OutputChartType \"{OutputChartType}\" is not a valid stepmania chart type."); errors = true; } if (PerformedChartConfigs != null) { foreach (var kvp in PerformedChartConfigs) { var pcc = kvp.Value; var pccId = kvp.Key; var desiredWeightsValid = pcc.DesiredArrowWeights != null && pcc.DesiredArrowWeights.ContainsKey(OutputChartType); if (!desiredWeightsValid) { LogError( $"PerformedChartConfig \"{pccId}\": No DesiredArrowWeights specified for \"{OutputChartType}\"."); errors = true; } if (smChartTypeValid && desiredWeightsValid) { var expectedNumArrows = SMCommon.Properties[(int)smChartType].NumInputs; if (pcc.DesiredArrowWeights[OutputChartType].Count != expectedNumArrows) { LogError($"PerformedChartConfig \"{pccId}\": DesiredArrowWeights[\"{OutputChartType}\"] has " + $"{pcc.DesiredArrowWeights[OutputChartType].Count} entries. Expected {expectedNumArrows}."); errors = true; } foreach (var weight in pcc.DesiredArrowWeights[OutputChartType]) { if (weight < 0) { LogError($"PerformedChartConfig \"{pccId}\": Negative weight \"{weight}\" in " + $"DesiredArrowWeights[\"{OutputChartType}\"]."); errors = true; } } } } } } if (PerformedChartConfigs == null || PerformedChartConfigs.Count < 1) { LogError("No PerformedChartConfigs specified. Expected at least one."); errors = true; } if (string.IsNullOrEmpty(DefaultPerformedChartConfig)) { LogError("No DefaultPerformedChartConfig specified."); errors = true; } if (PerformedChartConfigs != null && !string.IsNullOrEmpty(DefaultPerformedChartConfig) && !PerformedChartConfigs.ContainsKey(DefaultPerformedChartConfig)) { LogError($"DefaultPerformedChartConfig \"{DefaultPerformedChartConfig}\" not found in PerformedChartConfigs."); errors = true; } if (PerformedChartConfigs != null) { foreach (var kvp in PerformedChartConfigs) { var pcc = kvp.Value; var pccId = kvp.Key; if (pcc.IndividualStepTighteningMinTimeSeconds < 0.0) { LogError( $"PerformedChartConfig \"{pccId}\": Negative value \"{pcc.IndividualStepTighteningMinTimeSeconds}\" " + "specified for IndividualStepTighteningMinTimeSeconds. Expected non-negative value."); errors = true; } if (pcc.IndividualStepTighteningMaxTimeSeconds < 0.0) { LogError( $"PerformedChartConfig \"{pccId}\": Negative value \"{pcc.IndividualStepTighteningMaxTimeSeconds}\" " + "specified for IndividualStepTighteningMaxTimeSeconds. Expected non-negative value."); errors = true; } if (pcc.IndividualStepTighteningMinTimeSeconds > pcc.IndividualStepTighteningMaxTimeSeconds) { LogError( $"PerformedChartConfig \"{pccId}\": IndividualStepTighteningMinTimeSeconds \"{pcc.IndividualStepTighteningMinTimeSeconds}\" " + $"is greater than IndividualStepTighteningMaxTimeSeconds \"{pcc.IndividualStepTighteningMaxTimeSeconds}\". " + "IndividualStepTighteningMinTimeSeconds must be less than or equal to IndividualStepTighteningMaxTimeSeconds."); errors = true; } if (pcc.LateralTighteningPatternLength < 0) { LogError( $"PerformedChartConfig \"{pccId}\": Negative value \"{pcc.LateralTighteningPatternLength}\" specified for " + "LateralTighteningPatternLength. Expected non-negative value."); errors = true; } if (pcc.LateralTighteningRelativeNPS < 0.0) { LogError( $"PerformedChartConfig \"{pccId}\": Negative value \"{pcc.LateralTighteningRelativeNPS}\" specified for " + "LateralTighteningRelativeNPS. Expected non-negative value."); errors = true; } if (pcc.LateralTighteningAbsoluteNPS < 0.0) { LogError( $"PerformedChartConfig \"{pccId}\": Negative value \"{pcc.LateralTighteningAbsoluteNPS}\" specified for " + "LateralTighteningAbsoluteNPS. Expected non-negative value."); errors = true; } if (pcc.LateralTighteningSpeed < 0.0) { LogError( $"PerformedChartConfig \"{pccId}\": Negative value \"{pcc.LateralTighteningSpeed}\" specified for " + "LateralTighteningSpeed. Expected non-negative value."); errors = true; } } } if (ExpressedChartConfigs == null || ExpressedChartConfigs.Count < 1) { LogError("No ExpressedChartConfigs specified. Expected at least one."); errors = true; } if (string.IsNullOrEmpty(DefaultExpressedChartConfig)) { LogError("No DefaultExpressedChartConfig specified."); errors = true; } if (ExpressedChartConfigs != null && !string.IsNullOrEmpty(DefaultExpressedChartConfig) && !ExpressedChartConfigs.ContainsKey(DefaultExpressedChartConfig)) { LogError($"DefaultExpressedChartConfig \"{DefaultExpressedChartConfig}\" not found in ExpressedChartConfigs."); errors = true; } if (ExpressedChartConfigs != null) { foreach (var kvp in ExpressedChartConfigs) { var ecc = kvp.Value; var eccId = kvp.Key; if (ecc.BalancedBracketsPerMinuteForAggressiveBrackets < 0.0) { LogError($"ExpressedChartConfig \"{eccId}\" BalancedBracketsPerMinuteForAggressiveBrackets " + $" {ecc.BalancedBracketsPerMinuteForAggressiveBrackets} must be non-negative."); errors = true; } if (ecc.BalancedBracketsPerMinuteForNoBrackets < 0.0) { LogError($"ExpressedChartConfig \"{eccId}\" BalancedBracketsPerMinuteForNoBrackets " + $" {ecc.BalancedBracketsPerMinuteForNoBrackets} must be non-negative."); errors = true; } if (ecc.BalancedBracketsPerMinuteForAggressiveBrackets <= ecc.BalancedBracketsPerMinuteForNoBrackets && ecc.BalancedBracketsPerMinuteForAggressiveBrackets != 0.0 && ecc.BalancedBracketsPerMinuteForNoBrackets != 0.0) { LogError($"ExpressedChartConfig \"{eccId}\" BalancedBracketsPerMinuteForAggressiveBrackets" + $" {ecc.BalancedBracketsPerMinuteForAggressiveBrackets} is not greater than" + $" BalancedBracketsPerMinuteForNoBrackets {ecc.BalancedBracketsPerMinuteForNoBrackets}." + " If these values are non-zero, BalancedBracketsPerMinuteForAggressiveBrackets must be" + " greater than BalancedBracketsPerMinuteForNoBrackets."); errors = true; } } } // Validate ExpressedChartConfigRules. if (ExpressedChartConfigRules != null) { for (var i = 0; i < ExpressedChartConfigRules.Length; i++) { var configRule = ExpressedChartConfigRules[i]; if (string.IsNullOrEmpty(configRule.Config)) { LogError($"ExpressedChartConfigRules[{i}] No Config specified."); errors = true; } if (ExpressedChartConfigs != null && !string.IsNullOrEmpty(configRule.Config) && !ExpressedChartConfigs.ContainsKey(configRule.Config)) { LogError( $"ExpressedChartConfigRules[{i}] Config \"{configRule.Config}\" not found in ExpressedChartConfigs."); errors = true; } if (string.IsNullOrEmpty(configRule.FileRegex)) { LogError($"ExpressedChartConfigRules[{i}] No FileRegex specified."); errors = true; } else if (!IsValidRegex(configRule.FileRegex)) { LogError( $"ExpressedChartConfigRules[{i}] Invalid regular expression for FileRegex: \"{configRule.FileRegex}\"."); errors = true; } if (string.IsNullOrEmpty(configRule.DifficultyRegex)) { LogError($"ExpressedChartConfigRules[{i}] No DifficultyRegex specified."); errors = true; } else if (!IsValidRegex(configRule.DifficultyRegex)) { LogError( $"ExpressedChartConfigRules[{i}] Invalid regular expression for DifficultyRegex: \"{configRule.DifficultyRegex}\"."); errors = true; } } } // Validate PerformedChartConfigRules. if (PerformedChartConfigRules != null) { for (var i = 0; i < PerformedChartConfigRules.Length; i++) { var configRule = PerformedChartConfigRules[i]; if (string.IsNullOrEmpty(configRule.Config)) { LogError($"PerformedChartConfigRules[{i}] No Config specified."); errors = true; } if (PerformedChartConfigs != null && !string.IsNullOrEmpty(configRule.Config) && !PerformedChartConfigs.ContainsKey(configRule.Config)) { LogError( $"PerformedChartConfigRules[{i}] Config \"{configRule.Config}\" not found in PerformedChartConfigs."); errors = true; } if (string.IsNullOrEmpty(configRule.FileRegex)) { LogError($"PerformedChartConfigRules[{i}] No FileRegex specified."); errors = true; } else if (!IsValidRegex(configRule.FileRegex)) { LogError( $"PerformedChartConfigRules[{i}] Invalid regular expression for FileRegex: \"{configRule.FileRegex}\"."); errors = true; } if (string.IsNullOrEmpty(configRule.DifficultyRegex)) { LogError($"PerformedChartConfigRules[{i}] No DifficultyRegex specified."); errors = true; } else if (!IsValidRegex(configRule.DifficultyRegex)) { LogError( $"PerformedChartConfigRules[{i}] Invalid regular expression for DifficultyRegex: \"{configRule.DifficultyRegex}\"."); errors = true; } } } // Warn on any missing StepTypeReplacements. var stepTypes = Enum.GetValues(typeof(StepType)).Cast <StepType>().ToList(); foreach (var stepType in stepTypes) { if (!StepTypeReplacements.ContainsKey(stepType) || StepTypeReplacements[stepType].Count == 0) { LogWarn($"No StepTypeReplacements for \"{stepType:G}\"." + " Steps of this type will ignored when generating Performed Charts." + " This will likely result in a failures to generate Performed Charts." + " To ignore this type of step, include an entry for it in StepTypeReplacements and map" + " it to a type of step to use as a replacement."); } } if (LogToFile) { if (string.IsNullOrEmpty(LogDirectory)) { LogError("LogToFile is true, but no LogDirectory specified."); errors = true; } if (LogBufferSizeBytes <= 0) { LogError("Expected a non-negative LogBufferSizeBytes."); errors = true; } } return(!errors); }