private static string ValidateUser(UserInfo user) { try { string errorMessage = string.Empty; if (string.IsNullOrEmpty(user.Email)) { errorMessage += "Email is required. <br />"; } else { string emailRegEx = @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z"; if (Regex.IsMatch(user.Email, emailRegEx, RegexOptions.IgnoreCase) == false) { errorMessage += "Please provide valid email.<br />"; } } if (user.GroupUsers.Count <= 0) { errorMessage += "Error loading user groups. <br />"; } return(errorMessage); } catch (Exception ex) { DBCommands.RecordError(ex); return("Error validating user."); } }
public static void UpdatePassword(UpdateAccount model, out string errorMessage, bool isTest = false) { try { IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); errorMessage = string.Empty; if (model.NewPassword.Length < 9) { errorMessage = "Password must be at least 9 characters and have a special character"; } else if (model.CurrentPassword == model.NewPassword) { errorMessage = "New password must be different from the current password."; } else if (model.NewPassword != model.RepeatPassword) { errorMessage = "New password and repeated password does not match."; } else if (membershipTools.UpdatePassword(model.UserName, model.NewPassword) == false) { errorMessage = "Error updating account."; } } catch (Exception ex) { DBCommands.RecordError(ex); errorMessage = ex.Message; } }
public static void RetrieveUsers() { IDataReader reader = DBCommands.RetrieveUsers(); while (reader.Read()) { int id = Int32.Parse(reader[0].ToString()); string firstname = reader[1].ToString(); string lastname = reader[2].ToString(); string email = reader[3].ToString(); string password = reader[4].ToString(); IDataReader userReader = DBCommands.RetrieveStudentPromo(email, password); if (userReader != null) { userReader.Read(); int idPromo = Int32.Parse(userReader[0].ToString()); CreateStudent(id, firstname, lastname, email, password, GPromo.GetPromo(idPromo)); } else { CreateTeacher(id, firstname, lastname, email, password); } } }
public static List <FeatureRequested> RequestedFeaturesByBusiness(int businessID, bool isUnitTest = false) { List <FeatureRequested> features = new List <FeatureRequested>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); DataTable featureTable = sprocCalls.BusinessRequestedFeature(businessID); FeatureRequested requestFeature; foreach (DataRow row in featureTable.Rows) { requestFeature = new FeatureRequested(); requestFeature.Active = Convert.ToBoolean(row["Active"]); requestFeature.AppRequestID = Convert.ToInt32(row["AppRequestID"]); requestFeature.AssignedTo = (row["AssignedTo"] != DBNull.Value) ? UserManager.GetUserByName(row["AssignedTo"].ToString()) : null; requestFeature.DateRequested = (row["DateRequested"] != DBNull.Value) ? Convert.ToDateTime(row["DateRequested"]) : (DateTime?)null; requestFeature.DevStatus = (row["DevStatus"] != DBNull.Value) ? row["DevStatus"].ToString() : ""; requestFeature.FeatureRequestedID = Convert.ToInt32(row["FeatureRequestedID"]); requestFeature.RequestedFeature = FeatureGetByID(Convert.ToInt32(row["FeatureID"])); features.Add(requestFeature); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(features); }
public static List <UserInfo> GetAllUsers(bool isTest = false) { List <UserInfo> allUsers = new List <UserInfo>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); DataTable userTable = sprocCalls.UserInfoGetAll(); UserInfo user; foreach (DataRow row in userTable.Rows) { user = new UserInfo(); user.UserInfoID = Convert.ToInt32(row["UserInfoID"]); user.UserName = row["UserName"].ToString(); user.Email = row["Email"].ToString(); user.ProfileImage = row["ProfileImage"].ToString(); user.GroupUsers = GetGroupsByUserName(user.UserName, sprocCalls); allUsers.Add(user); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(allUsers); }
public static List <Features> GetAllFeatures(bool allActive, bool isUnitTest = false) { List <Features> allFeatures = new List <Features>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); DataTable featureTable = sprocCalls.FeaturesGetAll(); foreach (DataRow row in featureTable.Rows) { Features feature = new Features(); feature.Active = allActive; feature.FeatureDescription = (row["FeatureDescription"] != DBNull.Value) ? row["FeatureDescription"].ToString() : ""; feature.FeatureID = Convert.ToInt32(row["FeatureID"]); feature.FeatureName = row["FeatureName"].ToString(); feature.MainFeature = Convert.ToBoolean(row["MainFeature"]); allFeatures.Add(feature); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(allFeatures); }
public static List <AppRequest> AppRequestsGetAll(bool isUnitTest = false) { List <AppRequest> appRequests = new List <AppRequest>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); DataTable requestTable = sprocCalls.AppRequestsGetAll(); AppRequest request; foreach (DataRow row in requestTable.Rows) { request = new AppRequest(); request.Active = Convert.ToBoolean(row["Active"]); request.AppBusiness = sprocCalls.GetBusinessByID(Convert.ToInt32(row["BusinessID"])); request.AppRequestID = Convert.ToInt32(row["AppRequestID"]); request.DateRequested = Convert.ToDateTime(row["DateRequested"]); request.DevStatus = (row["DevStatus"] != DBNull.Value) ? row["DevStatus"].ToString() : ""; appRequests.Add(request); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(appRequests); }
public static List <UserGroups> GroupsGetAll(bool isTest = false) { List <UserGroups> groupList = new List <UserGroups>(); try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); DataTable groupTable = sprocCalls.UserGroupsGetActive(); UserGroups group; foreach (DataRow row in groupTable.Rows) { group = new UserGroups(); group.Active = false; group.GroupLevel = Convert.ToInt32(row["GroupLevel"]); group.GroupName = row["GroupName"].ToString(); group.UserGroupID = Convert.ToInt32(row["UserGroupID"]); groupList.Add(group); } } catch (Exception ex) { DBCommands.RecordError(ex); } return(groupList); }
public ScriptFilesComparerBase CreateScriptFilesComparer <TScriptFileType>(DBCommands dbCommands, string folderPath) where TScriptFileType : ScriptFileTypeBase, new() { DBExecutedFiles dbExecutedFiles = new DBExecutedFiles(dbCommands, ScriptFileTypeBase.Create <TScriptFileType>()); ScriptFilesComparerBase scriptFilesComparer = null; if (typeof(TScriptFileType) == typeof(IncrementalScriptFileType)) { FileSystemScriptFiles fileSystemScriptFiles = new FileSystemScriptFiles(_fileChecksum, ScriptFileTypeBase.Create <TScriptFileType>(), folderPath); scriptFilesComparer = new IncrementalScriptFilesComparer(fileSystemScriptFiles, dbExecutedFiles); } else if (typeof(TScriptFileType) == typeof(RepeatableScriptFileType)) { FileSystemScriptFiles fileSystemScriptFiles = new FileSystemScriptFiles(_fileChecksum, ScriptFileTypeBase.Create <TScriptFileType>(), folderPath); scriptFilesComparer = new RepeatableScriptFilesComparer(fileSystemScriptFiles, dbExecutedFiles); } else if (typeof(TScriptFileType) == typeof(DevDummyDataScriptFileType)) { FileSystemScriptFiles fileSystemScriptFiles = new FileSystemScriptFiles(_fileChecksum, ScriptFileTypeBase.Create <TScriptFileType>(), folderPath); scriptFilesComparer = new DevDummyDataScriptFilesComparer(fileSystemScriptFiles, dbExecutedFiles); } return(scriptFilesComparer); }
public static SurveyDet GetSurveyDetail(int wrid) { SurveyDet det = null; List <SqlParameter> sqlParams = new List <SqlParameter>(); sqlParams.Add(new SqlParameter("@WRNumber", (Object)wrid)); DataSet ds = DBCommands.GetData("spn_GetSurvey_2_customersurvey", sqlParams); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { //populate wr fieds det = new SurveyDet(); DataRow row = ds.Tables[0].Rows[0]; //det.WRNumber = Convert.ToInt32(row["WRnumber"].ToString()); det.WONumber = Convert.ToInt32(row["WOnumber"].ToString()); det.CreatedOn = Convert.ToDateTime(row["DateTime"].ToString()); //if (row["RequesterPhone"].ToString() != "") //{ det.RequesterPhone = row["RequesterPhone"].ToString(); } ////det.CreatedOn = Convert.ToDateTime(row["CreatedOn"].ToString()); //det.RequestedOn = Convert.ToDateTime(row["Requested"].ToString()); //det.RequestedBy = row["RequestedBy"].ToString(); //if (row["Shop"].ToString() != "") //{ det.Shop = row["Shop"].ToString(); } //if (row["Status"].ToString() != "") //{ det.Status = row["Status"].ToString(); } //if (row["Descriptions"].ToString() != "") //{ det.Description = row["Descriptions"].ToString(); } //if (row["Building"].ToString() != "") //{ det.Building = row["Building"].ToString(); } //if (row["Property"].ToString() != "") //{ det.Property = row["Property"].ToString(); } //if (row["Room"].ToString() != "") //{ det.Room = row["Room"].ToString(); } if (row["Comments"].ToString() != "") { det.Comments = row["Comments"].ToString(); } det.Question5Ans = Convert.ToInt32(row["Question5"].ToString()); if (row["Question1"].ToString() != "") { det.Question1Ans = Convert.ToInt32(row["Question1"].ToString()); } if (row["Question2"].ToString() != "") { det.Question2Ans = Convert.ToInt32(row["Question2"].ToString()); } if (row["Question3"].ToString() != "") { det.Question3Ans = Convert.ToInt32(row["Question3"].ToString()); } } return(det); }
public static int FeatureInsert(Features feature, out string errorMessage, bool isUnitTest = false) { int id = -1; try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(isUnitTest); IEmailTools emailTools = AppTools.InitEmailTools(isUnitTest); errorMessage = ValidateFeature(feature); if (string.IsNullOrEmpty(errorMessage)) { id = sprocCalls.FeaturesInsert(feature); if (id <= 0) { errorMessage = "Error inserting new feature " + feature.FeatureName + "."; } //else // emailTools.SendToAll("New Feature created : " + feature.FeatureName + "<br />Description : " + feature.FeatureDescription); } } catch (Exception ex) { errorMessage = ex.Message; DBCommands.RecordError(ex); } return(id); }
public bool SendEmail(string to, string body) { try { MailAddress mailFrom = new MailAddress("*****@*****.**", "202MobileService"); MailAddress mailTo = new MailAddress(to, to); SmtpClient client = new SmtpClient(); client.Host = "smtp.gmail.com"; client.Port = 587; client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential(mailFrom.Address, "hide"); MailMessage message = new MailMessage(mailFrom, mailTo); message.Subject = "Message from Abundant Life!"; message.Body = body; message.IsBodyHtml = true; client.Send(message); return(true); } catch (Exception ex) { DBCommands.RecordError(ex); return(false); } }
public ActionResult insertPlan(/*[FromQuery] TokenSignature token*/) { PlansModel model = new PlansModel() { address = "test", planName = "test", regionID = 1, serializedPlan = Encoding.Unicode.GetBytes("TestTEST") }; try { DBCommands.PlansInsertValues("Plans", new object[] { "test", 1, "test", false, Encoding.Unicode.GetBytes("TestTest") }); return(Ok("ok")); } catch (Exception e) { return(Ok(e.Message)); } }
public static void RecoverPassword(RecoverModel model, out string errorMessage, bool isTest = false) { try { IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); IEmailTools emailTools = AppTools.InitEmailTools(isTest); errorMessage = string.Empty; if (model.Email == membershipTools.GetUserEmail(model.UserName)) { string tempPassword = Membership.GeneratePassword(9, 1); if (membershipTools.SetTempPassword(model.UserName, tempPassword) == false) { errorMessage = "Error updating account"; } string emailBody = BuildRecoverBody(model.UserName, tempPassword); if (emailTools.SendEmail(emailBody, model.Email) == false) { errorMessage = "Error sending recover email."; } } else { errorMessage = "Email and username is not valid."; } } catch (Exception ex) { DBCommands.RecordError(ex); errorMessage = ex.Message; } }
// Check si modification ou nouvel utilisateur public void CreateUser() { if (!String.IsNullOrEmpty(firstname.text) && !String.IsNullOrEmpty(lastname.text) && !String.IsNullOrEmpty(email.text) && !String.IsNullOrEmpty(password.text)) { User currentUser; // Prof if (String.Equals(status.captionText.text, "Prof.")) { int id = DBCommands.InsertTeacher(lastname.text, firstname.text, email.text, password.text); currentUser = GUser.CreateTeacher(id, firstname.text, lastname.text, email.text, password.text); GApp.SetPrefUser(firstname.text, lastname.text, email.text, password.text, "Prof.", "", "", "", "2019-02-11"); } // Student else { Promo p = GPromo.GetPromo(1, promo.captionText.text); int id = DBCommands.InsertStudent(firstname.text, lastname.text, p.Id, email.text, password.text); currentUser = GUser.CreateStudent(id, firstname.text, lastname.text, email.text, password.text, p); GApp.SetPrefUser(firstname.text, lastname.text, email.text, password.text, "Elève", p.Specialty, td.captionText.text, tp.captionText.text, "2019-02-11"); } GApp.ChangeScene(nextScene); } }
public ExecuteScriptBlockStep(DBCommands dbCommands, string scriptBlockToExecute) { dbCommands.ThrowIfNull(nameof(dbCommands)); _dbCommands = dbCommands; _scriptBlockToExecute = scriptBlockToExecute; }
public DBExecutedFiles(DBCommands dbCommands, ScriptFileTypeBase scriptFileType) { _dbCommands = dbCommands; ScriptFileType = scriptFileType; Load(); }
public static ValidationResult AddSurveyDetails(string reqby, string reqphone, string comments, int wrnumber, int Question1Ans, int Question2Ans, int Question3Ans, int Question5Ans) { List <SqlParameter> sqlParams = new List <SqlParameter>(); sqlParams.Add(new SqlParameter("@WRNumber", (Object)wrnumber)); sqlParams.Add(new SqlParameter("@Question1Ans", Question1Ans < 0 ? DBNull.Value : (Object)Question1Ans)); sqlParams.Add(new SqlParameter("@Question2Ans", Question2Ans < 0 ? DBNull.Value : (Object)Question2Ans)); sqlParams.Add(new SqlParameter("@Question3Ans", Question3Ans < 0 ? DBNull.Value : (Object)Question3Ans)); sqlParams.Add(new SqlParameter("@Question5Ans", Question5Ans < 0 ? DBNull.Value : (Object)Question5Ans)); sqlParams.Add(new SqlParameter("@RequestedBy", reqby)); sqlParams.Add(new SqlParameter("@RequesterPhone", (string.IsNullOrEmpty(reqphone)) ? DBNull.Value : (Object)reqphone)); sqlParams.Add(new SqlParameter("@Comments", (string.IsNullOrEmpty(comments)) ? DBNull.Value : (Object)comments)); //SqlParameter outNewWOnum = new SqlParameter("@Res", SqlDbType.Int); //outNewWOnum.Direction = ParameterDirection.Output; //sqlParams.Add(outNewWOnum); ValidationResult vr = DBCommands.ExecuteNonQueryWithResReturn("spn_AddResponse_CustomerSurvey", sqlParams); //if (vr.Success) //{ // //if no error, update id // details.WONumber = Convert.ToInt32(outNewWOnum.Value); // details.ConstructionNum = outConstructionNum.Value.ToString(); //} return(vr); }
public static void UpdateUser(UserInfo user, out string errorMessage, bool isTest = false) { try { errorMessage = ValidateUser(user); if (string.IsNullOrEmpty(errorMessage)) { IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest); if (membershipTools.UpdateUserEmail(user.UserName, user.Email) == false) { errorMessage = "Error updating email."; } if (sprocCalls.UserInfoUpdate(user) == false) { errorMessage = "Error saving user information"; } } } catch (Exception ex) { DBCommands.RecordError(ex); errorMessage = ex.Message; } }
void Start() { DBCommands.OpenDBConnection(); GPromo.RetrievePromos(); GRoom.RetrieveRooms(); GUser.RetrieveUsers(); GLesson.RetrieveLessons(); }
//get work location building list by property public static DataSet BuildingListByProperty(string property) { List <SqlParameter> sqlParams = new List <SqlParameter>(); SqlParameter spProperty = new SqlParameter("@Property", property); sqlParams.Add(spProperty); //get data from database return(DBCommands.GetData("spn_GetBuildingList_Property_59000", sqlParams)); }
public ExecuteScriptsByTypeStep(string fileTypeCode, DBCommands dbCommands, ExecuteSingleFileScriptStepFactory executeSingleFileScriptStepFactory) { dbCommands.ThrowIfNull(nameof(dbCommands)); executeSingleFileScriptStepFactory.ThrowIfNull(nameof(executeSingleFileScriptStepFactory)); _fileTypeCode = fileTypeCode; _dbCommands = dbCommands; _executeSingleFileScriptStepFactory = executeSingleFileScriptStepFactory; }
public ExecuteSingleFileScriptStep(ExecuteScriptBlockStepFactory executeScriptBlockStepFactory, DBCommands dbCommands, string stepName, RuntimeScriptFile scriptFile) { dbCommands.ThrowIfNull(nameof(dbCommands)); _stepName = stepName; _scriptFile = scriptFile; _dbCommands = dbCommands; _executeScriptBlockStepFactory = executeScriptBlockStepFactory; }
public static RequestDet GetSurveyRequestDetail(int id) { RequestDet req = null; List <SqlParameter> sqlParams = new List <SqlParameter>(); sqlParams.Add(new SqlParameter("@WRNumber", (Object)id)); DataSet ds = DBCommands.GetData("spn_GetSurvey_1_customersurvey", sqlParams); if (ds != null && ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0) { //populate wr fieds req = new RequestDet(); DataRow row = ds.Tables[0].Rows[0]; req.WONumber = Convert.ToInt32(row["WOnumber"].ToString()); req.RequestedOn = Convert.ToDateTime(row["Requested"].ToString()); req.RequestedBy = row["RequestedBy"].ToString(); if (row["Comments"].ToString() != "") { req.Comments = row["Comments"].ToString(); } if (row["Descriptions"].ToString() != "") { req.Description = row["Descriptions"].ToString(); } if (row["Building"].ToString() != "") { req.Building = row["Building"].ToString(); } if (row["Shop"].ToString() != "") { req.Shop = row["Shop"].ToString(); } if (row["Property"].ToString() != "") { req.Property = row["Property"].ToString(); } if (row["Status"].ToString() != "") { req.Status = row["Status"].ToString(); } if (row["Room"].ToString() != "") { req.RequesterRoom = row["Room"].ToString(); } if (row["RequesterPhone"].ToString() != "") { req.RequesterPhone = row["RequesterPhone"].ToString(); } } return(req); }
public static bool DeleteUser(string userName, bool isTest = false) { try { IMembershipTools membershipTools = AppTools.InitMembershipTools(isTest); return(membershipTools.DeleteUser(userName)); } catch (Exception ex) { DBCommands.RecordError(ex); return(false); } }
public static void RetrievePromos() { IDataReader reader = DBCommands.RetrievePromos(); while (reader.Read()) { int id = Int32.Parse(reader[0].ToString()); int year = Int32.Parse(reader[1].ToString()); string specialty = reader[2].ToString(); CreatePromo(id, year, specialty); } }
public bool CreateUser(string userName, string email) { try { Membership.CreateUser(userName, "p@ssword1", email); return(true); } catch (Exception ex) { DBCommands.RecordError(ex); return(false); } }
public static void SendAlertToWorkers(bool isTest = false) { try { IEmailTools emailTools = AppTools.InitEmailTools(isTest); emailTools.SendToGroup(2, "A new request has been sent."); emailTools.SendToGroup(3, "A new request has been sent."); } catch (Exception ex) { DBCommands.RecordError(ex); } }
public bool CreateUser(string userName, string email, string password = null) { try { password = (string.IsNullOrEmpty(password)) ? "p@ssword1" : password; Membership.CreateUser(userName, password, email); return(true); } catch (Exception ex) { DBCommands.RecordError(ex); return(false); } }
public static Features FeatureGetByID(int featureID, bool IsUnitTest = false) { Features feature = null; try { ISprocCalls sprocCalls = AppTools.InitSprocCalls(IsUnitTest); feature = sprocCalls.FeatureGetByID(featureID); } catch (Exception ex) { DBCommands.RecordError(ex); } return(feature); }