protected void loadPageInfo(int space_id) { int content_type_id = (int)qSoc_ContentType.Types.Campaign; string list_html = string.Empty; if (space_id > 0) { var list = qSoc_SpaceAssociation.GetSpaceAssociationsByContentTypeAndSpace(content_type_id, space_id); if (list != null) { foreach (var l in list) { qSoc_Campaign item = new qSoc_Campaign(l.ReferenceID); list_html += "<li><a href=\"/manage/campaigns/campaign-details.aspx?campaignID=" + item.CampaignID + "\">" + item.CampaignName + "</a></li>"; } litList.Text = list_html; } } else { var list = qSoc_SpaceAssociation.GetSpaceAssociationsByContentType(content_type_id); if (list != null) { foreach (var l in list) { qSoc_Campaign item = new qSoc_Campaign(l.ReferenceID); list_html += "<li><a href=\"program-details.aspx?campaignID=" + item.CampaignID + "\">" + item.CampaignName + "</a></li>"; } litList.Text = list_html; } } }
protected string AddCampaignUserPreference(qSoc_Campaign campaign, qPtl_User user, int scope_id) { string return_did = string.Empty; int campaign_did = qCom_CampaignDID.GetNextAvailableCampaignPhoneNumber(campaign.CampaignID); if (campaign_did > 0) { qCom_CampaignDID did = new qCom_CampaignDID(campaign_did); if (did != null) { if (did.CampaignDID > 0) { qCom_UserCampaignPreference u_pref = new qCom_UserCampaignPreference(); u_pref.DID = did.DID; u_pref.UserID = user.UserID; u_pref.Available = "Yes"; u_pref.ScopeID = scope_id; u_pref.Created = DateTime.Now; u_pref.CreatedBy = user.UserID; u_pref.LastModified = DateTime.Now; u_pref.LastModifiedBy = user.UserID; u_pref.MarkAsDelete = 0; u_pref.CampaignID = campaign.CampaignID; u_pref.Insert(); return_did = did.DID; } } } return return_did; }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { int campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); if (campaign_id == 0) campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); CampaignHeader.CampaignID = campaign_id; CampaignHeader.Campaign = campaign; // load core objects var pref = qRpt_CampaignReportPreference.GetCampaignReportPreferenceByCampaignID(campaign_id); var a_report = qRpt_CampaignOverviewReport.GetCampaignOverviewByCampaignID(campaign_id); List<CampaignReport> s_report = new List<CampaignReport>(); s_report = qRpt_CampaignReport.GenerateCampaignReportSummary(campaign_id); List<CampaignUserReport> u_report = new List<CampaignUserReport>(); u_report = qRpt_CampaignReport.GenerateCampaignUserList(campaign_id); displayData(pref, campaign, a_report, s_report, u_report); } }
protected void loadControls(int space_id, int reference_id) { string list_html = string.Empty; qSoc_Campaign campaign = new qSoc_Campaign(reference_id); CampaignSelector.CampaignName = campaign.CampaignName; if (!Page.IsPostBack) { } }
protected void loadPageInfo(int space_id) { string list_html = string.Empty; var list = qSoc_Campaign.GetGenerallyAvailableCampaigns(); if (list != null) { foreach (var l in list) { qSoc_Campaign item = new qSoc_Campaign(l.CampaignID); list_html += "<li><a href=\"/manage/campaigns/campaign-details.aspx?campaignID=" + item.CampaignID + "\">" + item.CampaignName + "</a></li>"; } litList.Text = list_html; } }
protected void loadControls(int space_id, int reference_id) { string list_html = string.Empty; qSoc_Campaign campaign = new qSoc_Campaign(reference_id); CampaignSelector.CampaignName = campaign.CampaignName; if (!Page.IsPostBack) { qSoc_Element html = new qSoc_Element("campaign-pages"); if (html != null) { if (html.ElementID > 0) litMainContent.Text = html.HTML; } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { hplBackTop.NavigateUrl = "campaign-edit.aspx?campaignID=" + Request.QueryString["campaignID"]; hplBackBottom.NavigateUrl = "campaign-edit.aspx?campaignID=" + Request.QueryString["campaignID"]; hplRefreshBottom.NavigateUrl = Request.Url.ToString(); hplRefreshTop.NavigateUrl = Request.Url.ToString(); if (!String.IsNullOrEmpty(Request.QueryString["campaignID"])) { campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); lblTitle.Text = campaign.CampaignName + " - Activities"; } } }
protected void displayData(qRpt_CampaignReportPreference pref, qSoc_Campaign campaign, qRpt_CampaignOverviewReport a_report, List<CampaignReport> s_report, List<CampaignUserReport> u_report) { // summary if (pref.AnalyzedOverview == true) { //litDateReportGenerated.Text = "<br /><strong>Information last updated:</strong> " + a_report.LastTimeCompiled; campaignsidebar.Visible = true; CampaignSidebarRaw.Visible = false; campaignsidebar.Report = a_report; } else { //litDateReportGenerated.Text = "<br /><strong>Information last updated:</strong> " + DateTime.Now; campaignsidebar.Visible = false; CampaignSidebarRaw.Visible = true; CampaignSidebarRaw.S_Report = s_report; CampaignSidebarRaw.Report = a_report; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { } hplRegister.NavigateUrl = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Register_RegisterPage"]); string hplBack_custom = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Site_PublicHomePage"]); string login_nav = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Register_LoginExtraNav"]); if (!String.IsNullOrEmpty(login_nav)) { if (login_nav == "false") plhLoginExtraNav.Visible = false; } if (!String.IsNullOrEmpty(hplBack_custom)) hplBack.NavigateUrl = hplBack_custom; else hplBack.NavigateUrl = "~/default.aspx"; this.cmdLogin.ServerClick += new System.EventHandler(this.cmdLogin_ServerClick); // check to see if matches space string reg_code = string.Empty; if (!String.IsNullOrEmpty(Request.QueryString["code"])) { reg_code = Request.QueryString["code"]; qSoc_Campaign campaign = new qSoc_Campaign(reg_code); if (campaign.CampaignID > 0) { plhSpaceCode.Visible = true; txtSpaceCode.Text = reg_code; lblSpaceDescription.Text = "<br><span class=\"label label-success\"><i class=\"icon-ok\"></i> " + campaign.CampaignName + " channel.</span><br>"; } } int user_id = Convert.ToInt32(Context.Items["UserID"]); if (user_id > 0) Response.Redirect("~/utilities/manage-user-access.aspx"); }
protected void btnSignUp_Click(object sender, EventArgs e) { Page.Validate("register"); if (Page.IsValid) { string sqlCode = string.Empty; string returnMessage = string.Empty; qDbs_SQLcode sql = new qDbs_SQLcode(); string register_mode = "new"; int existing_user_id = 0; int scope_id = 1; // would have to be changed to support multiple organizations on a single platform int role_id = 0; int moderator_role_id = 0; if (!String.IsNullOrEmpty(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Register_ModeratorRoleID"]))) moderator_role_id = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_ModeratorRoleID"]); // **************************************************** // STEP 1: DETERMINE IF USER IS ALREADY A LIMITED MOBILE USER if (plhMobileNumber.Visible == true) { //Determine if upgrade of mobile account or new registration qPtl_UserProfile mobile_test = qPtl_UserProfile.GetProfileByMobileNumber(txtMobileNumber.Text); if (mobile_test != null) { if (mobile_test.UserID > 0) { // make sure that the user is eligible for upgrade from mobile only status qPtl_User eval_user = new qPtl_User(mobile_test.UserID); if (eval_user.HighestRole == "Mobile") { register_mode = "update"; existing_user_id = mobile_test.UserID; } } else { register_mode = "new"; } } else { register_mode = "new"; } } // **************************************************** // STEP 2a: Mode == new; then add new user string currAvailableStatus = string.Empty; currAvailableStatus = "Yes"; if (register_mode == "new") { qPtl_User new_user = new qPtl_User(); new_user.Available = "Yes"; new_user.ScopeID = scope_id; new_user.Created = DateTime.Now; new_user.CreatedBy = 0; new_user.LastModified = DateTime.Now; new_user.LastModifiedBy = 0; new_user.MarkAsDelete = 0; new_user.Status = ""; // used to include a default message for their status, now leave blank new_user.FirstName = txtFirstName.Text; new_user.LastName = txtLastName.Text; new_user.Email = txtEmail.Text; new_user.UserName = txtUserName.Text; string password_for_storing = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1"); new_user.Password = password_for_storing; new_user.AccountStatus = "Active"; new_user.Insert(); existing_user_id = new_user.UserID; DateTime DOB; try { DOB = new DateTime(int.Parse(ddlYear.SelectedValue), int.Parse(ddlMonth.SelectedValue), int.Parse(ddlDay.SelectedValue)); ;//Convert.ToDateTime(ddlMonth.SelectedValue + "/" + ddlDay.SelectedValue + "/" + ddlYear.SelectedValue); } catch { // no valid date so use default value DOB = new DateTime(1900, 1, 1); ////Convert.ToDateTime("1/1/1900"); } qPtl_UserProfile new_profile = new qPtl_UserProfile(); new_profile.UserID = existing_user_id; new_profile.ScopeID = scope_id; new_profile.Available = "Yes"; new_profile.Created = DateTime.Now; new_profile.CreatedBy = existing_user_id; new_profile.LastModified = DateTime.Now; new_profile.LastModifiedBy = existing_user_id; new_profile.MarkAsDelete = 0; new_profile.Style = "default"; new_profile.Visibility = "all"; new_profile.Gender = ddlGender.SelectedValue; new_profile.DOB = DOB; if (plhRace.Visible == true) { string race = string.Empty; int n = 0; foreach (ListItem item in cblRace.Items) { if (item.Selected) { if (n > 0) { race += "," + item.Value; } else { race += item.Value; } n++; } } n = 0; new_profile.Race = race; } new_profile.Insert(); } qPtl_User user = new qPtl_User(existing_user_id); // STEP 2b: Mode == update; then update mobile info //mode mobile = update existing account if (register_mode == "update") { user.FirstName = txtFirstName.Text; user.LastName = txtLastName.Text; user.UserName = txtEmail.Text; user.Email = txtEmail.Text; string password_for_storing = FormsAuthentication.HashPasswordForStoringInConfigFile(txtPassword.Text, "sha1"); user.Password = password_for_storing; user.AccountStatus = "Mobile Verification Pending"; user.Update(); } // **************************************************** // STEP 3: Process invitation & perform invitation-specific work // OPTION #1 -- an invitation is required as part of the registration process and a collection of additional actions are related to that string code = string.Empty; string process_code_mode = string.Empty; if (plhInvitation.Visible == true) { code = txtInvitationCode.Text; if (String.IsNullOrEmpty(process_code_mode)) process_code_mode = "invitation"; // deal with default/null values } else if (plhSpaceCode.Visible == true) { code = txtSpaceCode.Text; if (String.IsNullOrEmpty(process_code_mode)) { qSoc_Space space = new qSoc_Space(code); if (space.SpaceID > 0) { process_code_mode = "space"; } else { qSoc_Campaign campaign = new qSoc_Campaign(code); if (campaign.CampaignID > 0) { process_code_mode = "campaign"; } } } } if (!String.IsNullOrEmpty(code) && process_code_mode == "invitation") { //Process invitation int invitationID = 0; qPtl_Invitation invite = null; invite = new qPtl_Invitation(code); invitationID = invite.InvitationID; role_id = invite.RoleID; // update invitation records as necessary if (invite.InvitationAudience == "family") { invite.UserID = user.UserID; invite.InvitationStatus = "Redeemed"; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; } else if (invite.InvitationAudience == "individual") { invite.UserID = user.UserID; invite.InvitationStatus = "Redeemed"; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; } else if (invite.InvitationAudience == "group") { invite.UserID = user.UserID; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; if (invite.MaxRedemptions > 0 && invite.CurrRedemptions >= invite.MaxRedemptions) invite.InvitationStatus = "Redeemed"; } else if (invite.InvitationAudience == "moderated group") { invite.UserID = user.UserID; invite.LastModified = DateTime.Now; invite.LastModifiedBy = user.UserID; invite.CurrRedemptions = invite.CurrRedemptions + 1; if (invite.MaxRedemptions > 0 && invite.CurrRedemptions >= invite.MaxRedemptions) invite.InvitationStatus = "Redeemed"; } invite.Update(); // add possible space associated with invitation & space-specific elements if (invite.SpaceID > 0) { qSoc_Space space = new qSoc_Space(invite.SpaceID); if (space != null) { if (space.SpaceID > 0) { qSoc_UserSpace u_space = new qSoc_UserSpace(); u_space.ScopeID = scope_id; u_space.Available = "Yes"; u_space.Created = DateTime.Now; u_space.CreatedBy = user.UserID; u_space.LastModified = DateTime.Now; u_space.LastModifiedBy = user.UserID; u_space.MarkAsDelete = 0; u_space.UserID = user.UserID; u_space.SpaceID = space.SpaceID; u_space.PrimarySpace = true; if (role_id == moderator_role_id) u_space.SpaceRole = "Moderator"; u_space.Insert(); } if (space.SchoolID > 0) { qOrg_UserSchool school = new qOrg_UserSchool(); school.UserID = user.UserID; school.SchoolID = space.SchoolID; school.Insert(); } // set space to visibile in directory it not already visible if (space.VisibleInDirectory == "No") { space.VisibleInDirectory = "Yes"; space.Update(); } // add campaign -- includes check to insure that campaigns aren't added twice AddSpaceCampaigns(space, user, scope_id); } } // add possible campaign associated with invitation -- includes check to insure that campaigns aren't added twice if (invite.CampaignID > 0) { qSoc_UserCampaign checkc = new qSoc_UserCampaign(user.UserID, invite.CampaignID); if (checkc.UserCampaignID == 0) { AddUserCampaign(invite.CampaignID, scope_id, user); } } if (invite.FunctionalRoleID > 0) { sqlCode = "INSERT INTO qLrn_UserFunctionalRoles ([UserID],[FunctionalRoleID]) VALUES(" + user.UserID + "," + invite.FunctionalRoleID + ")"; sql.ExecuteSQL(sqlCode); UserFunctions.AddUserTrainingsByFunctionalRole(user.UserID, invite.FunctionalRoleID); } } else { // else use default role types int teen_max_age = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_TeenMaxAge"]); qPtl_UserProfile profile = new qPtl_UserProfile(user.UserID); if (profile.Age <= teen_max_age) role_id = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_TeenRoleID"]); else role_id = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Register_ParentRoleID"]); } // OPTION #2 -- User might have entered a registration code; this will assign them to a space which might have one or more associated campaigns if (!String.IsNullOrEmpty(code) && process_code_mode == "space") { if (!string.IsNullOrEmpty(code)) { qSoc_Space space = new qSoc_Space(code); if (space != null) { if (space.SpaceID > 0) { qSoc_UserSpace u_space = new qSoc_UserSpace(); u_space.ScopeID = scope_id; u_space.Available = "Yes"; u_space.Created = DateTime.Now; u_space.CreatedBy = user.UserID; u_space.LastModified = DateTime.Now; u_space.LastModifiedBy = user.UserID; u_space.MarkAsDelete = 0; u_space.UserID = user.UserID; u_space.SpaceID = space.SpaceID; u_space.PrimarySpace = true; if (role_id == moderator_role_id) u_space.SpaceRole = "Moderator"; u_space.Insert(); } space_redirect = true; new_space_id = space.SpaceID; AddSpaceCampaigns(space, user, scope_id); } } } else if (!String.IsNullOrEmpty(code) && process_code_mode == "campaign") { qSoc_Campaign campaign = new qSoc_Campaign(code); AddUserCampaign(campaign.CampaignID, scope_id, user); } // **************************************************** // STEP 4: Add School Information if (plhSchool.Visible == true) { string school_name = string.Empty; string school_other_name = string.Empty; if (radCBSearch.Visible == true) school_name = radCBSearch.SelectedValue; else { school_other_name = txtSchoolOther.Text; school_name = "Other"; } var school = qOrg_School.GetSchoolFromAutoPopulateDropdown(school_name); if (school != null) { if (school.SchoolID > 0) { qOrg_UserSchool user_school = new qOrg_UserSchool(); user_school.Available = "Yes"; user_school.ScopeID = scope_id; user_school.Created = DateTime.Now; user_school.CreatedBy = user.UserID; user_school.LastModified = DateTime.Now; user_school.LastModifiedBy = user.UserID; user_school.MarkAsDelete = 0; user_school.UserID = user.UserID; user_school.SchoolID = school.SchoolID; user_school.OtherName = school_other_name; user_school.Insert(); // see if this school is already a space var school_space = qSoc_Space.GetSpacesBySchool(school.SchoolID); qSoc_Space curr_space = new qSoc_Space(); if (school_space == null) { qSoc_Space new_space = new qSoc_Space(); new_space.ScopeID = scope_id; new_space.Available = "Yes"; new_space.Created = DateTime.Now; new_space.CreatedBy = 0; new_space.LastModified = DateTime.Now; new_space.LastModifiedBy = 0; new_space.MarkAsDelete = 0; new_space.SpaceName = school.School; new_space.SpaceShortName = school.School; new_space.SpaceType = "school"; new_space.AccessMode = "open"; new_space.VisibleInDirectory = "Yes"; new_space.SpaceCategoryID = 1; new_space.SchoolID = school.SchoolID; new_space.Insert(); school_space = new_space; } if (school_space != null) { qSoc_UserSpace s_space = new qSoc_UserSpace(); s_space.ScopeID = scope_id; s_space.Available = "Yes"; s_space.Created = DateTime.Now; s_space.CreatedBy = user.UserID; s_space.LastModified = DateTime.Now; s_space.LastModifiedBy = user.UserID; s_space.MarkAsDelete = 0; s_space.UserID = user.UserID; s_space.SpaceID = school_space.SpaceID; s_space.PrimarySpace = true; if (role_id == moderator_role_id) s_space.SpaceRole = "Moderator"; s_space.Insert(); } } } } // **************************************************** // STEP 5: Add User Role & Supporting Role Structures // Add role /* qPtl_UserRole role = new qPtl_UserRole(); role.UserID = user.UserID; role.RoleID = role_id; role.Insert(); */ sqlCode = "INSERT INTO qPtl_UserRoles ([UserID],[RoleID]) VALUES(" + user.UserID + "," + role_id + ")"; sql.ExecuteSQL(sqlCode); // Add possible role actions for the new user role AddRoleAction(role_id, scope_id, user); // Add possible role campaigns AddRoleCampaigns(role_id, scope_id, user); // Redundancy check -- write Highest Level into qPtl_User table in case DB trigger not working qPtl_Role role = new qPtl_Role(role_id); user.HighestRank = role.RoleRank; user.HighestRole = role.RoleName; user.Update(); // **************************************************** // STEP 6: User Utilties to finalize/prep account // Add username folder for images string rootLocation = Server.MapPath("~/") + "user_data\\"; if (!Directory.Exists(rootLocation + user.UserName)) Directory.CreateDirectory(rootLocation + user.UserName); // Create default album qSoc_Album album = new qSoc_Album(); album.ScopeID = scope_id; album.Available = "Yes"; album.Created = DateTime.Now; album.CreatedBy = user.UserID; album.LastModified = DateTime.Now; album.LastModifiedBy = user.UserID; album.MarkAsDelete = 0; album.UserID = user.UserID; album.Name = "My Pics"; album.Insert(); // Add communications preferences if (register_mode == "new") { qCom_UserPreference connect = new qCom_UserPreference(); connect.UserID = user.UserID; connect.Created = DateTime.Now; connect.CreatedBy = user.UserID; connect.LastModified = DateTime.Now; connect.LastModifiedBy = user.UserID; connect.Available = "Yes"; connect.ScopeID = 1; connect.MarkAsDelete = 0; connect.OkBulkEmail = "Yes"; connect.OkEmail = "Yes"; connect.OkSms = "Yes"; connect.LanguageID = 1; connect.Insert(); } qCom_UserPreference user_connect = qCom_UserPreference.GetUserPreference(user.UserID); user_connect.OkBulkEmail = "Yes"; user_connect.OkEmail = "Yes"; user_connect.Update(); // **************************************************** // STEP 7: Log user in and redirect to account setup page/ // initial session created -- will last for 24 hours before timing out qPtl_Sessions session = new qPtl_Sessions(); session.Created = DateTime.Now; session.StartTime = DateTime.Now; session.LastTimeSeen = DateTime.Now; session.ScopeID = user.ScopeID; session.UserID = user.UserID; session.BrowserType = Request.Browser.Browser; session.ComputerType = Request.Browser.Platform; session.Insert(); int sessionID = session.SessionID; int scopeID = user.ScopeID; var u_roles = qPtl_UserRole_View.GetUserRoles(user.UserID); string role_list = string.Empty; if (u_roles != null) { foreach (var u in u_roles) { role_list += string.Format("{0},", u.RoleName, ","); } } role_list.TrimEnd(','); string userData = string.Format("{0};{1};{2}", sessionID, role_list, scopeID); FormsAuthenticationTicket tkt; string cookiestr; HttpCookie ck; tkt = new FormsAuthenticationTicket(1, user.UserID.ToString(), DateTime.Now, DateTime.Now.AddMinutes(3600), false, userData); cookiestr = FormsAuthentication.Encrypt(tkt); ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr); ck.Path = FormsAuthentication.FormsCookiePath; Response.Cookies.Add(ck); HttpCookie cookie2 = new HttpCookie("UserID", Convert.ToString(user.UserID)); if (tkt.IsPersistent) { cookie2.Expires = tkt.Expiration.AddMinutes(3605); } Response.Cookies.Add(cookie2); if (space_redirect == true && new_space_id > 0) Response.Redirect("~/utilities/manage-user-access.aspx?mode=registration&spaceID=" + new_space_id); else Response.Redirect("~/utilities/manage-user-access.aspx?mode=registration"); } }
protected void loadControls(int space_id, int reference_id) { string list_html = string.Empty; qSoc_Campaign campaign = new qSoc_Campaign(reference_id); if (!Page.IsPostBack) { var report = qRpt_CampaignOverviewReport.GetCampaignOverviewByCampaignID(reference_id); string roles = Convert.ToString(Context.Items["UserRoles"]); if (report != null) { if (report.CampaignReportOverviewID > 0) { } } /* if (Request.QueryString["mode"] == "edit") { plhEdit.Visible = true; plhRead.Visible = false; btnEdit.Visible = false; btnSave.Visible = true; } else { if (roles.Contains("Site Admin")) btnEdit.Visible = true; else btnEdit.Visible = false; plhEdit.Visible = false; plhRead.Visible = true; } */ } }
protected void btnSave_OnClick(object sender, System.EventArgs e) { Page.Validate("form"); if (Page.IsValid) { int user_id = Convert.ToInt32(Context.Items["UserID"]); int campaign_id = 0; if (!String.IsNullOrEmpty(Request.QueryString["campaignID"])) { campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); campaign.LastModified = DateTime.Now; campaign.LastModifiedBy = Convert.ToInt32(Context.Items["UserID"]); campaign.MarkAsDelete = 0; campaign.CampaignName = txtCampaignName.Text; campaign.Description = txtCampaignDescription.Text; campaign.Available = rblAvailableNew.SelectedValue; campaign.Code = txtCode.Text; campaign.Keyword = txtKeyword.Text; campaign.Update(); campaign_id = campaign.CampaignID; } else { qSoc_Campaign campaign = new qSoc_Campaign(); campaign.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); campaign.Created = DateTime.Now; campaign.CreatedBy = Convert.ToInt32(Context.Items["UserID"]); campaign.LastModified = DateTime.Now; campaign.LastModifiedBy = Convert.ToInt32(Context.Items["UserID"]); campaign.MarkAsDelete = 0; campaign.CampaignName = txtCampaignName.Text; campaign.Description = txtCampaignDescription.Text; campaign.Available = rblAvailableNew.SelectedValue; campaign.TotalDays = 0; campaign.Code = txtCode.Text; campaign.Keyword = txtKeyword.Text; campaign.Insert(); campaign_id = campaign.CampaignID; } Response.Redirect("~/manage/site/learning/campaign-edit.aspx?campaignID=" + campaign_id); } }
protected void btnCreateCampaignRedirect_Click(object sender, EventArgs e) { // see if redirect exists, if yes -- then delete, else -- create int campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); qPtl_Redirect redirect = new qPtl_Redirect("/" + campaign.Code + "/"); if (redirect != null) { if (redirect.RedirectID > 0) { redirect.DeleteRedirect(redirect.RedirectID); } else { int user_id = Convert.ToInt32(Context.Items["UserID"]); qPtl_Redirect n_redirect = new qPtl_Redirect(); n_redirect.Available = "Yes"; n_redirect.MarkAsDelete = 0; n_redirect.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); n_redirect.Created = DateTime.Now; n_redirect.CreatedBy = user_id; n_redirect.LastModified = DateTime.Now; n_redirect.LastModifiedBy = user_id; n_redirect.EntryURL = "/" + campaign.Code + "/"; n_redirect.RedirectURL = base_path + "/public/campaigns/campaign-start.aspx?campaignID=" + campaign_id + "&keyword=" + campaign.Keyword; n_redirect.Insert(); } Response.Redirect("~/manage/site/learning/campaign-edit.aspx?campaignID=" + campaign_id); } }
protected void Page_Load(object sender, EventArgs e) { int curr_space_id = 0; if (Page.IsPostBack) { DropDownList space_list = (DropDownList) Master.FindControl("ddlSpaces"); curr_space_id = Convert.ToInt32(space_list.SelectedValue); } else { curr_space_id = Convert.ToInt32(Session["manage_space_id"]); } int reference_id = Convert.ToInt32(Request.QueryString["campaignID"]); campaign_id = reference_id; loadControls(curr_space_id, reference_id); campaignsidebar.CampaignID = campaign_id; if (campaign_id == 0) campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); CampaignHeader.CampaignID = campaign_id; CampaignHeader.Campaign = campaign; // load core objects var pref = qRpt_CampaignReportPreference.GetCampaignReportPreferenceByCampaignID(campaign_id); var a_report = qRpt_CampaignOverviewReport.GetCampaignOverviewByCampaignID(campaign_id); List<CampaignReport> s_report = new List<CampaignReport>(); s_report = qRpt_CampaignReport.GenerateCampaignReportSummary(campaign_id); List<CampaignUserReport> u_report = new List<CampaignUserReport>(); u_report = qRpt_CampaignReport.GenerateCampaignUserList(campaign_id); displayData(pref, campaign, a_report, s_report, u_report); }
protected void AddSpaceCampaigns(qSoc_Space space, qPtl_User user, int scope_id) { //Add space campaigns string sqlCode = string.Empty; string returnMessage = string.Empty; qDbs_SQLcode sql = new qDbs_SQLcode(); sqlCode = string.Format("SELECT * FROM qSoc_SpaceCampaigns WHERE SpaceID = " + space.SpaceID + " AND Available = 'Yes' AND ScopeID = " + scope_id); int campaignID = 0; string progressMode = string.Empty; using (SqlDataReader sReader = sql.GetDataReader(sqlCode)) { if (sReader.HasRows) { while (sReader.Read()) { campaignID = Convert.ToInt32(sReader["CampaignID"]); qSoc_UserCampaign checkc = new qSoc_UserCampaign(user.UserID, campaignID); if (checkc.UserCampaignID == 0) { //create campaign for user qSoc_Campaign campaign = new qSoc_Campaign(campaignID); AddUserCampaign(campaign.CampaignID, scope_id, user); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (!String.IsNullOrEmpty(Request.QueryString["contactID"])) { populateCampaigns(); contact_id = Convert.ToInt32(Request.QueryString["contactID"]); ViewState.Add("vsContactID", contact_id); qCom_Contact contact = new qCom_Contact(contact_id); lblTitle.Text = "Edit Contact (ID: " + contact.ContactID + ")"; txtFirstName.Text = contact.FirstName; txtLastName.Text = contact.LastName; txtEmail.Text = contact.Email; txtKeywords.Text = contact.Keywords; txtSource.Text = contact.Source; rblOkEmail.SelectedValue = contact.OKEmail; txtPartner.Text = contact.Partner; txtMainGroup.Text = Convert.ToString(contact.MainGroup); txtSubGroup.Text = Convert.ToString(contact.SubGroup); rblAvailable.SelectedValue = contact.Available; txtCustomHTMLElement.Text = contact.CustomHTMLElement; if (!String.IsNullOrEmpty(Convert.ToString(contact.Unsubscribed))) rdtUnsubscribed.SelectedDate = Convert.ToDateTime(contact.Unsubscribed); if (!String.IsNullOrEmpty(Convert.ToString(contact.UnsubscribedCampaignID))) { qSoc_Campaign campaign = new qSoc_Campaign(contact.UnsubscribedCampaignID); ddlCampaigns.SelectedValue = Convert.ToString(contact.UnsubscribedCampaignID); if (campaign.CampaignID > 0) { litUnsubscribedCampaignInfo.Text = "Unsubscribed from campaign: " + campaign.CampaignName; } } if (!String.IsNullOrEmpty(Convert.ToString(contact.ReportedAsSpam))) rdtReportedAsSpam.SelectedDate = Convert.ToDateTime(contact.ReportedAsSpam); if (!String.IsNullOrEmpty(Convert.ToString(contact.ReportedAsSpam))) { if (!String.IsNullOrEmpty(Convert.ToString(contact.ReportedAsSpamCampaignID))) { qSoc_Campaign campaign = new qSoc_Campaign(contact.ReportedAsSpamCampaignID); ddlCampaignsSPAM.SelectedValue = Convert.ToString(contact.ReportedAsSpamCampaignID); if (campaign.CampaignID > 0) { litReportedAsSPAMCampaignInfo.Text = "Reported as SPAM from campaign <strong>" + campaign.CampaignName + "</strong> at <strong>" + contact.ReportedAsSpam + "</strong>"; } } else { litReportedAsSPAMCampaignInfo.Text = "Reported as SPAM at <strong>" + contact.ReportedAsSpam + "</strong>"; } } if (Convert.ToString(Request.QueryString["mode"]) == "add-successful") { lblMessage.Text = "*** Record Successfully Added ***"; } } else { lblTitle.Text = "New Contact"; btnDelete.Visible = false; rblAvailable.SelectedValue = "Yes"; plhTools.Visible = false; } } if (String.IsNullOrEmpty(Convert.ToString(contact_id))) contact_id = (Int32)ViewState["vsContactID"]; }
protected void displayData(qRpt_CampaignReportPreference pref, qSoc_Campaign campaign, qRpt_CampaignOverviewReport a_report, List<CampaignReport> s_report, List<CampaignUserReport> u_report) { // summary if (pref.AnalyzedOverview == true) { //litDateReportGenerated.Text = "<br /><strong>Information last updated:</strong> " + a_report.LastTimeCompiled; campaignsidebar.Visible = true; CampaignSidebarRaw.Visible = false; CampaignSummaryAnalyzed.Visible = true; CampaignSummaryRaw.Visible = false; CampaignSummaryAnalyzed.Pref = pref; CampaignSummaryAnalyzed.Campaign = campaign; CampaignSummaryAnalyzed.Report = a_report; campaignsidebar.Report = a_report; } else { //litDateReportGenerated.Text = "<br /><strong>Information last updated:</strong> " + DateTime.Now; campaignsidebar.Visible = false; CampaignSidebarRaw.Visible = true; CampaignSummaryAnalyzed.Visible = false; CampaignSummaryRaw.Visible = true; CampaignSummaryRaw.Pref = pref; CampaignSummaryRaw.Campaign = campaign; CampaignSummaryRaw.S_Report = s_report; CampaignSidebarRaw.S_Report = s_report; CampaignSidebarRaw.Report = a_report; } if (pref.Language == true) { CampaignLanguage.Visible = true; CampaignLanguage.U_Report = u_report; } else CampaignLanguage.Visible = false; if (pref.MostRecentEnrolled == true) { CampaignMostRecentEnrolled.Visible = true; CampaignMostRecentEnrolled.CampaignID = campaign_id; } else CampaignMostRecentEnrolled.Visible = false; if (pref.HTMLReport == true) { CampaignHTMLReport.Visible = true; CampaignHTMLReport.Report = a_report; } else CampaignHTMLReport.Visible = false; if (pref.HealthKits == true) { CampaignMostRecentHealthKits.Visible = true; CampaignMostRecentHealthKits.CampaignID = campaign_id; } else CampaignMostRecentHealthKits.Visible = false; if (pref.EnrollmentTrend == true) { CampaignEnrollmentTrend.Visible = true; CampaignEnrollmentTrend.CampaignID = campaign_id; } else CampaignEnrollmentTrend.Visible = false; }
protected void displayData(qRpt_CampaignReportPreference pref, qSoc_Campaign campaign, qRpt_CampaignOverviewReport a_report, List <CampaignReport> s_report, List <CampaignUserReport> u_report) { // summary if (pref.AnalyzedOverview == true) { //litDateReportGenerated.Text = "<br /><strong>Information last updated:</strong> " + a_report.LastTimeCompiled; campaignsidebar.Visible = true; CampaignSidebarRaw.Visible = false; CampaignSummaryAnalyzed.Visible = true; CampaignSummaryRaw.Visible = false; CampaignSummaryAnalyzed.Pref = pref; CampaignSummaryAnalyzed.Campaign = campaign; CampaignSummaryAnalyzed.Report = a_report; campaignsidebar.Report = a_report; } else { //litDateReportGenerated.Text = "<br /><strong>Information last updated:</strong> " + DateTime.Now; campaignsidebar.Visible = false; CampaignSidebarRaw.Visible = true; CampaignSummaryAnalyzed.Visible = false; CampaignSummaryRaw.Visible = true; CampaignSummaryRaw.Pref = pref; CampaignSummaryRaw.Campaign = campaign; CampaignSummaryRaw.S_Report = s_report; CampaignSidebarRaw.S_Report = s_report; CampaignSidebarRaw.Report = a_report; } if (pref.Language == true) { CampaignLanguage.Visible = true; CampaignLanguage.U_Report = u_report; } else { CampaignLanguage.Visible = false; } if (pref.MostRecentEnrolled == true) { CampaignMostRecentEnrolled.Visible = true; CampaignMostRecentEnrolled.CampaignID = campaign_id; } else { CampaignMostRecentEnrolled.Visible = false; } if (pref.HTMLReport == true) { CampaignHTMLReport.Visible = true; CampaignHTMLReport.Report = a_report; } else { CampaignHTMLReport.Visible = false; } if (pref.HealthKits == true) { CampaignMostRecentHealthKits.Visible = true; CampaignMostRecentHealthKits.CampaignID = campaign_id; } else { CampaignMostRecentHealthKits.Visible = false; } if (pref.EnrollmentTrend == true) { CampaignEnrollmentTrend.Visible = true; CampaignEnrollmentTrend.CampaignID = campaign_id; } else { CampaignEnrollmentTrend.Visible = false; } }
protected void btnEnroll_Click(object sender, EventArgs e) { // run check for mobile text if (!String.IsNullOrEmpty(lblCampaignID.Text)) { campaign_id = Convert.ToInt32(lblCampaignID.Text); } return_url = lblReturnURL.Text; string mobile_number = txtMobileNumber.Text; bool error_occurred = false; bool phone_belongs_to_another_user = false; // check to see if this number is already being used by another user int curr_user_id = Convert.ToInt32(Context.Items["UserID"]); int scope_id = Convert.ToInt32(Context.Items["ScopeID"]); var check_user = qPtl_User.GetUserByPhone(txtMobileNumber.Text, scope_id); if (check_user.UserID > 0) { if (check_user.UserID != curr_user_id) { error_occurred = true; phone_belongs_to_another_user = true; } } // replace characters if (mobile_number.Contains("-")) mobile_number = mobile_number.Replace("-", ""); if (mobile_number.Contains(".")) mobile_number = mobile_number.Replace(".", ""); if (mobile_number.Contains("/")) mobile_number = mobile_number.Replace("/", ""); if (mobile_number.Contains("(")) mobile_number = mobile_number.Replace("(", ""); if (mobile_number.Contains(")")) mobile_number = mobile_number.Replace(")", ""); if (mobile_number.Contains("*")) mobile_number = mobile_number.Replace("*", ""); if (mobile_number.Contains(" ")) mobile_number = mobile_number.Replace(" ", ""); try { string first_char = mobile_number.Substring(0, 1); if (mobile_number.Length == 11 && first_char == "1") mobile_number = mobile_number.Substring(1, 10); } catch { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } if (String.IsNullOrEmpty(mobile_number)) { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } string pat_m = @"^[0-9]{10}$"; Regex r_m = new Regex(pat_m, RegexOptions.IgnoreCase); Match m_m = r_m.Match(mobile_number); if (!m_m.Success) { error_occurred = true; litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; } if (error_occurred == false) { if (btnEnroll.Text == "Turn Off Text Messages") { qCom_UserPreference pref = new qCom_UserPreference(curr_user_id); pref.OkSms = "No"; pref.Update(); } else { // save phone number to profile qPtl_UserProfile profile = new qPtl_UserProfile(curr_user_id); if (profile.Phone1Type == "Mobile") { profile.Phone1 = string.Empty; profile.Phone1Type = string.Empty; } if (profile.Phone2Type == "Mobile") { profile.Phone2 = string.Empty; profile.Phone2Type = string.Empty; } profile.Phone1 = txtMobileNumber.Text; profile.Phone1Type = "Mobile"; profile.Update(); // add new mobile verification code to qCom_UserPreferences var pref = qCom_UserPreference.GetUserPreference(curr_user_id); int new_pin = qCom_UserPreference.GenerateMobilePIN(); if (pref != null) { if (pref.UserID > 0) { pref.MobilePIN = Convert.ToString(new_pin); pref.Update(); } } else { qCom_UserPreference pref2 = new qCom_UserPreference(); pref2.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); pref2.Available = "Yes"; pref2.Created = DateTime.Now; pref2.CreatedBy = curr_user_id; pref2.LastModified = DateTime.Now; pref2.LastModifiedBy = curr_user_id; pref2.UserID = curr_user_id; pref2.OkBulkEmail = "Yes"; pref2.OkSms = "Yes"; pref2.OkEmail = "Yes"; pref2.MobilePIN = Convert.ToString(new_pin); pref2.Insert(); } // get correct DID string alt_did = string.Empty; // see if user has custom record var camp_pref = qCom_UserCampaignPreference.GetUserCampaignPreferences(campaign_id, curr_user_id); if (camp_pref != null) alt_did = camp_pref.DID; else { // see if campaign has available dedicated DIDs qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); qPtl_User user = new qPtl_User(curr_user_id); alt_did = AddCampaignUserPreference(campaign, user, scope_id); if (String.IsNullOrEmpty(alt_did)) alt_did = System.Configuration.ConfigurationManager.AppSettings["SMSDid"]; } string alt_pin_message_uri = string.Empty; var c_pref = qCom_CampaignPreference.GetCampaignPreferences(campaign_id); if (c_pref != null) { if (c_pref.CampaignPreferenceID > 0) { alt_pin_message_uri = c_pref.MobileVerifySMSURI; } } // send mobile pin qCom_UserPreference.SendMobilePIN(Convert.ToString(new_pin), curr_user_id, alt_did, alt_pin_message_uri); plhManage.Visible = false; plhVerify.Visible = true; } } else { if (phone_belongs_to_another_user == true) litMsg.Text = "<br><br>* This phone number belongs to another user."; } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { populateSchoolDistricts(); if (!String.IsNullOrEmpty(Convert.ToString(Context.Items["UserID"]))) { qPtl_User curr_user = new qPtl_User(Convert.ToInt32(Context.Items["UserID"])); if (curr_user.UserID > 0) Response.Redirect("~/utilities/manage-user-access.aspx"); } if (invitation_required == true) plhInvitation.Visible = true; else plhInvitation.Visible = false; if (space_code_available == true && invitation_required == false) plhSpaceCode.Visible = true; else plhSpaceCode.Visible = false; if (sms_available == true) plhMobileAvailable.Visible = false; // HACK - always set to false else plhMobileAvailable.Visible = false; if (race_available == true) plhRace.Visible = true; else plhRace.Visible = false; if (school_available == true) { plhSchool.Visible = true; plhSchoolInfo.Visible = false; } else { plhSchool.Visible = false; } // see if registration code passed string reg_code = string.Empty; // check to see if matches space if (!String.IsNullOrEmpty(Request.QueryString["code"])) { reg_code = Request.QueryString["code"]; qSoc_Space space = new qSoc_Space(reg_code); if (space.SpaceID > 0) { txtSpaceCode.Text = reg_code; lblSpaceDescription.Text = "<br><span class=\"label label-success\"><i class=\"icon-ok\"></i> " + space.SpaceShortName + " group.</span><br>"; } // if no space match, then check to see if it matches a campaign if (space.SpaceID == 0) { qSoc_Campaign campaign = new qSoc_Campaign(reg_code); if (campaign.CampaignID > 0) { txtSpaceCode.Text = reg_code; lblSpaceDescription.Text = "<br><span class=\"label label-success\"><i class=\"icon-ok\"></i> " + campaign.CampaignName + " channel.</span><br>"; } } } // populate the year dropdown DateTime currDate = DateTime.Now; int currYear = Convert.ToInt32(currDate.Year); int startYear = Convert.ToInt32(currDate.Year) - 108; DataTable dtYears = new DataTable(); DataColumn year = new DataColumn("Year"); year.DataType = System.Type.GetType("System.Int32"); dtYears.Columns.Add(year); for (int i = startYear; i <= currYear; i++) { DataRow row = dtYears.NewRow(); row[year] = i; dtYears.Rows.Add(row); } dtYears.DefaultView.Sort = "Year DESC"; ddlYear.DataSource = dtYears; ddlYear.DataTextField = "Year"; ddlYear.DataValueField = "Year"; ddlYear.DataBind(); ddlYear.Items.Insert(0, new ListItem("", string.Empty)); ddlMonth.SelectedIndex = 0; ddlDay.SelectedIndex = 0; ddlYear.SelectedIndex = 0; // configure gender string gender_options = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Register_SupportedGenderValues"]); ddlGender.Items.FindByValue("Intersex").Enabled = false; ddlGender.Items.FindByValue("Transgender").Enabled = false; if (gender_options.Contains("Intersex")) ddlGender.Items.FindByValue("Intersex").Enabled = true; if (gender_options.Contains("Transgender")) ddlGender.Items.FindByValue("Transgender").Enabled = true; // look for custom home value string hplBack_custom = Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Site_PublicHomePage"]); if (!String.IsNullOrEmpty(hplBack_custom)) hplBack.NavigateUrl = hplBack_custom; else hplBack.NavigateUrl = "~/default.aspx"; } }
private void cmdLogin_ServerClick(object sender, System.EventArgs e) { if (ValidateUser(txtUserName.Value, txtUserPass.Value)) { qPtl_User user = new qPtl_User(txtUserName.Value); qPtl_Sessions session = new qPtl_Sessions(); session.Created = DateTime.Now; session.StartTime = DateTime.Now; session.LastTimeSeen = DateTime.Now; session.ScopeID = user.ScopeID; session.UserID = user.UserID; session.BrowserType = Request.Browser.Browser; session.ComputerType = Request.Browser.Platform; session.Insert(); int sessionID = session.SessionID; int scopeID = user.ScopeID; var u_roles = qPtl_UserRole_View.GetUserRoles(user.UserID); string role_list = string.Empty; if (u_roles != null) { foreach (var u in u_roles) { role_list += string.Format("{0},", u.RoleName, ","); } } role_list.TrimEnd(','); // see if there is a campaign code string reg_code = string.Empty; string custom_redirect = string.Empty; if (!String.IsNullOrEmpty(txtSpaceCode.Text)) { reg_code = txtSpaceCode.Text; qSoc_Campaign campaign = new qSoc_Campaign(reg_code); if (campaign.CampaignID > 0) { // see if already enrolled var exist_campaign = qSoc_UserCampaign.GetUserCampaign(user.UserID, campaign.CampaignID); if (exist_campaign != null) { if (exist_campaign.UserCampaignID > 0) { exist_campaign.DeleteUserCampaign(campaign.CampaignID, user.UserID); exist_campaign.DeleteUserCampaignActions(campaign.CampaignID, user.UserID); } } AddUserCampaign(campaign.CampaignID, user.ScopeID, user); custom_redirect = "~/social/learning/campaigns/campaign-details.aspx?campaignID=" + campaign.CampaignID; } } string userData = string.Format("{0};{1};{2}", sessionID, role_list, scopeID); FormsAuthenticationTicket tkt; string cookiestr; HttpCookie ck; int timeout_minutes = 480; // default shorter timeout (8 hours) int timeout_extended_minutes = 1440; // default extended timeout (1 day) int logout_minutes = 0; if (!String.IsNullOrEmpty(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Site_LoginTimeOut"]))) timeout_minutes = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Site_LoginTimeOut"]); else if (!String.IsNullOrEmpty(Convert.ToString(System.Configuration.ConfigurationManager.AppSettings["Site_ExtendedLoginTimeOut"]))) timeout_extended_minutes = Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["Site_ExtendedLoginTimeOut"]); if (chkLeaveLoggedIn.Checked) logout_minutes = timeout_extended_minutes; else logout_minutes = timeout_minutes; tkt = new FormsAuthenticationTicket(1, user.UserID.ToString(), DateTime.Now, DateTime.Now.AddMinutes(logout_minutes), true, userData); cookiestr = FormsAuthentication.Encrypt(tkt); ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr); //if (chkPersistCookie.Checked) //ck.Expires = tkt.Expiration; ck.Path = FormsAuthentication.FormsCookiePath; Response.Cookies.Add(ck); HttpCookie cookie2 = new HttpCookie("UserID", Convert.ToString(user.UserID)); if (tkt.IsPersistent) { cookie2.Expires = tkt.Expiration.AddMinutes(logout_minutes+5); } Response.Cookies.Add(cookie2); string strRedirect; strRedirect = Request["ReturnUrl"]; if (strRedirect == null) strRedirect = "~/utilities/manage-user-access.aspx"; if (!String.IsNullOrEmpty(custom_redirect)) strRedirect = custom_redirect; Response.Redirect(strRedirect, true); } else lblMsg.Text = "<br><br>Your username or password is not correct. Please try again."; }
protected void AddRoleCampaigns(int role_id, int scope_id, qPtl_User user) { //Add role campaigns string sqlCode = string.Empty; string returnMessage = string.Empty; qDbs_SQLcode sql = new qDbs_SQLcode(); sqlCode = string.Format("SELECT * FROM qSoc_RoleCampaigns WHERE RoleID = " + role_id + " AND Available = 'Yes' AND ScopeID = " + scope_id); int campaignID = 0; string progressMode = string.Empty; using (SqlDataReader sReader = sql.GetDataReader(sqlCode)) { if (sReader.HasRows) { while (sReader.Read()) { campaignID = Convert.ToInt32(sReader["CampaignID"]); qSoc_UserCampaign checkc = new qSoc_UserCampaign(user.UserID, campaignID); if (checkc.UserCampaignID == 0) { //create campaign for user qSoc_UserCampaign campaign = new qSoc_UserCampaign(); qSoc_Campaign cam = new qSoc_Campaign(campaign.CampaignID); campaign.ScopeID = 1; campaign.CampaignID = campaignID; campaign.Available = "Yes"; campaign.Created = DateTime.Now; campaign.CreatedBy = user.UserID; campaign.UserID = user.UserID; campaign.CampaignStatus = "In Progress"; // following parameters are defaults based on these campaigns being created associated to user roles and not spaces campaign.SpaceID = 0; campaign.EnrollmentType = "role"; campaign.Enrolled = DateTime.Now; if (cam.SetupRequired != true) { campaign.CampaignStart = DateTime.Now; } //add campaign actions int j = 0; var cActions = qSoc_CampaignAction.GetCampaignActions(campaignID); foreach (var i in cActions) { // get values qSoc_UserCampaignAction cUserAction = new qSoc_UserCampaignAction(); cUserAction.UserID = user.UserID; cUserAction.ScopeID = 1; cUserAction.Available = "Yes"; cUserAction.Created = DateTime.Now; cUserAction.CreatedBy = 0; cUserAction.CampaignActionID = i.CampaignActionID; if (j == 0) { cUserAction.Status = "In Progress"; campaign.CurrentCampaignActionID = i.CampaignActionID; } else { cUserAction.Status = "Not Started"; } cUserAction.Insert(); j++; } // create campaign record now that have current campaign actionID campaign.Insert(); } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (campaign_id == 0) campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); var report = qRpt_CampaignOverviewReport.GetCampaignOverviewByCampaignID(campaign_id); litCampaignName.Text = campaign.CampaignName; litDateReportGenerated.Text = "<br /><strong>Report Generated:</strong> " + Convert.ToString(DateTime.Now) + " based on data last compiled on " + report.LastTimeCompiled; if (Request.QueryString["mode"] == "print") { datStartDate.Visible = false; datEndDate.Visible = false; start_date = Convert.ToDateTime(Request.QueryString["startDate"]); end_date = Convert.ToDateTime(Request.QueryString["endDate"]); litStartDate.Text = start_date.ToString("d"); litEndDate.Text = end_date.ToString("d"); btnDownloadPDF.Visible = false; reformatTablesForPrinting(); displayInlineHelp(); } else { if (!String.IsNullOrEmpty(Convert.ToString(report.StartAvailable))) datStartDate.SelectedDate = report.StartAvailable; else datStartDate.SelectedDate = DateTime.Now.AddDays(-7); if (!String.IsNullOrEmpty(Convert.ToString(report.EndAvailable))) datStartDate.SelectedDate = report.EndAvailable; else datEndDate.SelectedDate = DateTime.Now; // short-term hack -- do not allow date evaluations datStartDate.Visible = false; datEndDate.Visible = false; start_date = Convert.ToDateTime(datStartDate.SelectedDate); end_date = Convert.ToDateTime(datEndDate.SelectedDate); litStartDate.Text = start_date.ToString("d"); litEndDate.Text = end_date.ToString("d"); } displayData(report, campaign); } }
protected void displayData(qRpt_CampaignOverviewReport report, qSoc_Campaign campaign) { // summary litSummaryTotalEnrolled.Text = Convert.ToString(report.Enroll_NumWeb + report.Enroll_NumSMS + report.Enroll_NumApp); litSummaryTotalDays.Text = Convert.ToString(campaign.TotalDays) + " days"; litSummaryCancelled.Text = Convert.ToString(report.Learn_NumCancelled); string start_available = string.Empty; string end_available = string.Empty; if (report.StartAvailable.HasValue) start_available = report.StartAvailable.Value.ToString("d"); else start_available = "not set"; if (report.EndAvailable.HasValue) end_available = report.EndAvailable.Value.ToString("d"); else end_available = "not set"; litSummaryAvailableDates.Text = start_available + " - " + end_available; litSummaryWaitingToStart.Text = Convert.ToString(report.Enroll_NumWaiting); litSummaryInProgress.Text = Convert.ToString(report.Enroll_NumInProgress); litSummaryFinished.Text = Convert.ToString(report.Enroll_NumFinished); // enrollment litEnrollmentContactsAvailable.Text = Convert.ToString(report.Invite_NumContactsAvailable); litEnrollmentContactsInvited.Text = Convert.ToString(report.Invite_NumUniqueInvites); decimal total_enrolled = (report.Enroll_NumWeb + report.Enroll_NumSMS + report.Enroll_NumApp); litEnrollmentNumInvitationsSent.Text = Convert.ToString(report.Invite_NumEmail + report.Invite_NumMail + report.Invite_NumSMS); ; litEnrollmentNumVisitsEnrollment.Text = Convert.ToString(report.Enroll_VisitedEnrollment); litEnrollmentWeb.Text = Convert.ToString(report.Enroll_NumWeb); litEnrollmentSMS.Text = Convert.ToString(report.Enroll_NumSMS); litEnrollmentMobileApp.Text = Convert.ToString(report.Enroll_NumApp); decimal conversion_rate_invited = 0; if (report.Invite_NumUniqueInvites > 0) { conversion_rate_invited = (total_enrolled / report.Invite_NumUniqueInvites ); litEnrollmentConversionRateInvites.Text = Convert.ToString(Math.Round(conversion_rate_invited * 100, 2)) + "%"; } else litEnrollmentConversionRateInvites.Text = "0"; decimal conversion_rate_visits = 0; if (report.Enroll_VisitedEnrollment > 0) { conversion_rate_visits = (total_enrolled / report.Enroll_VisitedEnrollment); litEnrollmentConversionRateVisits.Text = Convert.ToString(Math.Round(conversion_rate_visits * 100, 2)) + "%"; } else litEnrollmentConversionRateVisits.Text = "0"; // description litCampaignDescription.Text = campaign.Description; // email litEmailNumSent.Text = Convert.ToString(report.Email_NumSent); litEmailUniqueContacts.Text = Convert.ToString(report.Invite_NumUniqueInvites); litEmailBounce.Text = Convert.ToString(report.Email_NumBounce); litEmailNumRead.Text = Convert.ToString(report.Email_NumRead); decimal num_sent = Convert.ToDecimal(report.Email_NumSent); decimal num_read = Convert.ToDecimal(report.Email_NumRead); decimal num_click = Convert.ToDecimal(report.Email_NumClick); decimal read_rate = Math.Round(Convert.ToDecimal(num_read / num_sent) * 100, 2); decimal adjusted_num_read = Math.Round(Convert.ToDecimal(num_read * report.Email_NumReadMultiplier), 0); decimal adjusted_read_rate = Math.Round(Convert.ToDecimal((num_read * report.Email_NumReadMultiplier) / num_sent) * 100, 2); litEmailReadRate.Text = Convert.ToString(read_rate) + "%"; litEmailReadRateMultiplier.Text = Convert.ToString(report.Email_NumReadMultiplier); litEmailReadRateAdjusted.Text = Convert.ToString(adjusted_read_rate) + "%"; litEmailsReadAdjusted.Text = Convert.ToString(adjusted_num_read); litEmailClicks.Text = Convert.ToString(report.Email_NumClick); litEmailClickRate.Text = Convert.ToString(Math.Round(Convert.ToDecimal(num_click / adjusted_num_read) * 100, 2)) + "%"; litEmailUnsubscribes.Text = Convert.ToString(report.Email_NumUnsubscribe); litEmailSpam.Text = Convert.ToString(report.Email_NumSpam); // messaging litMessagingMessagesPossible.Text = Convert.ToString(report.Learn_NumMessagesPossible); litMessagingMessagesMandatory.Text = Convert.ToString(report.Learn_NumMessagesMandatory); litMessagingNumSent.Text = Convert.ToString(report.Learn_NumMessagesSent); litMessagingNumReceived.Text = Convert.ToString(report.Learn_NumMessagesReceived); decimal avg_message_per_user = Decimal.Add(report.Learn_NumMessagesSent, report.Learn_NumMessagesReceived) / total_enrolled; litMessagingAvgNumberPerMember.Text = Convert.ToString(Math.Round(avg_message_per_user, 0)); // stop section litSTOPNum.Text = Convert.ToString(report.Learn_NumCancelled); litSTOPAvgDay.Text = "day " + Convert.ToString(report.Learn_CancelledAvgDay) + " out of " + campaign.TotalDays; litSTOPEarliestDay.Text = "day " + Convert.ToString(report.Learn_CancelledEarliestDay); litSTOPLatestDay.Text = "day " + Convert.ToString(report.Learn_CancelledLatestDay); // learning section litLearningNumInfo.Text = Convert.ToString(report.Learn_NumInfoQuestions); litLearningNumAttitude.Text = Convert.ToString(report.Learn_NumAttitudeQuestions); litLearningNumBehavior.Text = Convert.ToString(report.Learn_NumBehaviorQuestions); litLearningPreTestInfo.Text = Convert.ToString(report.Learn_PreAssInfo); litLearningPostTestInfo.Text = Convert.ToString(report.Learn_PostAssInfo); decimal avg_info = 0; if (report.Learn_NumInfoQuestions > 0) { avg_info = Decimal.Subtract(report.Learn_PostAssInfo, report.Learn_PreAssInfo); if (avg_info > 0) litLearningAvgInfo.Text = "<strong>+ " + Convert.ToString(avg_info) + " or " + Convert.ToString(Math.Round(avg_info*100, 2)) + "% <i class=\"icon-circle-arrow-up\"></i></strong>"; else litLearningAvgInfo.Text = "- " + Convert.ToString(avg_info) + " or " + Convert.ToString(Math.Round(avg_info*100, 2)) + "% <i class=\"icon-circle-arrow-down\"></i>"; } else { litLearningPreTestInfo.Text = "--"; litLearningPostTestInfo.Text = "--"; litLearningAvgInfo.Text = "--"; } decimal avg_attitude = 0; if (report.Learn_NumAttitudeQuestions > 0) { avg_attitude = Decimal.Subtract(report.Learn_PostAssAttitude, report.Learn_PreAssAttitude); if (avg_attitude > 0) litLearningAvgAttitude.Text = "<strong>+ " + Convert.ToString(avg_attitude) + " or " + Convert.ToString(Math.Round(avg_attitude * 100, 2)) + "% <i class=\"icon-circle-arrow-up\"></i></strong>"; else litLearningAvgAttitude.Text = "- " + Convert.ToString(avg_attitude) + " or " + Convert.ToString(Math.Round(avg_attitude * 100, 2)) + "% <i class=\"icon-circle-arrow-down\"></i>"; } else { litLearningPreTestAttitude.Text = "--"; litLearningPostTestAttitude.Text = "--"; litLearningAvgAttitude.Text = "--"; } decimal avg_behavior = 0; if (report.Learn_NumBehaviorQuestions > 0) { avg_behavior = Decimal.Subtract(report.Learn_PostAssBehavior, report.Learn_PreAssBehavior); if (avg_behavior > 0) litLearningAvgBehavior.Text = "<strong>+ " + Convert.ToString(avg_behavior) + " or " + Convert.ToString(Math.Round(avg_behavior * 100, 2)) + "% <i class=\"icon-circle-arrow-up\"></i></strong>"; else litLearningAvgBehavior.Text = "- " + Convert.ToString(avg_behavior) + " or " + Convert.ToString(Math.Round(avg_behavior * 100, 2)) + "% <i class=\"icon-circle-arrow-down\"></i>"; } else { litLearningPreTestBehavior.Text = "--"; litLearningPostTestBehavior.Text = "--"; litLearningAvgBehavior.Text = "--"; } }
protected void btnDelete_Click(object sender, EventArgs e) { campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); campaign.Available = "No"; campaign.MarkAsDelete = 1; campaign.Update(); // loop through all users and delete their campaign records var campaign_users = qSoc_UserCampaign_View.GetCampaignUsers(campaign_id); if (campaign_users != null) { foreach (var u in campaign_users) { //qSoc_UserCamapign.DeleteUserCampaign(u.UserID, u.CampaignID); // add class level logic to remove all campaign actions/activities } } Response.Redirect("~/manage/site/learning/campaigns-list.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (campaign_id > 0) { CampaignAllEnrolledScrolling.CampaignID = campaign_id; CampaignAllEnrolledScrolling.SMSOk = true; qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); if (!String.IsNullOrEmpty(Request.QueryString["userID"])) { int user_id = Convert.ToInt32(Request.QueryString["userID"]); qPtl_User user = new qPtl_User(user_id); litRecipientList.Text = "This message will be sent to a single enrolled member of: <strong>" + campaign.CampaignName + "</strong><br><br><strong>Campaign Member</strong><br>Username = "******"This message will be sent to all enrolled members of: <strong>" + campaign.CampaignName + "</strong><br><strong>Campaign Members</strong>"; plhLimitByDays.Visible = true; } populateCampaignMessages(campaign_id); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { // configure library string[] library_path = new string[] { "~/resources/campaigns/" + campaign_id + "/" }; fxpCampaignLibrary.Configuration.ViewPaths = library_path; fxpCampaignLibrary.Configuration.MaxUploadFileSize = 256000000; fxpCampaignLibrary.Configuration.UploadPaths = library_path; fxpCampaignLibrary.Configuration.DeletePaths = library_path; hplBackTop.NavigateUrl = "campaigns-list.aspx"; hplBackBottom.NavigateUrl = "campaigns-list.aspx"; hplRefreshBottom.NavigateUrl = Request.Url.ToString(); //hplRefreshTop.NavigateUrl = Request.Url.ToString(); if (!String.IsNullOrEmpty(Request.QueryString["campaignID"])) { campaign_id = Convert.ToInt32(Request.QueryString["campaignID"]); qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); txtCampaignName.Text = campaign.CampaignName; txtCampaignDescription.Text = campaign.Description; lblPostedTime.Text = Convert.ToString(campaign.Created); lblTitle.Text = "Edit Campaign (ID: " + campaign.CampaignID + ")"; rblAvailableNew.Text = campaign.Available; lblNumberUserActivities.Text = Convert.ToString(campaign.NumUserActivities); lblTotalDays.Text = Convert.ToString(campaign.TotalDays); txtCode.Text = campaign.Code; txtKeyword.Text = campaign.Keyword; lblQuickLauchURL.Text = "<i>not created yet</i>"; if (!String.IsNullOrEmpty(campaign.Code)) { qPtl_Redirect redirect = new qPtl_Redirect("/" + campaign.Code + "/"); if (redirect != null) { if (redirect.RedirectID > 0) { lblQuickLauchURL.Text = base_path + campaign.Code; btnCreateCampaignRedirect.Text = "Delete URL"; } } } else { lblQuickLauchURL.Text = "<i>You must first save a registration code to create a quick launch url</i>"; btnCreateCampaignRedirect.Visible = false; } qPtl_User user = new qPtl_User(campaign.LastModifiedBy); user_id = user.UserID; username = user.UserName; qPtl_User reviewed_by = new qPtl_User(campaign.LastModifiedBy); lblPostedTime.Text = " at " + campaign.LastModified; plhMoreInfo.Visible = true; string delivery_options = string.Empty; if (campaign.SMS == "Yes") delivery_options += " <i class=\"glyphicon-phone\"></i> Text Messaging (SMS)"; if (campaign.Mobile == "Yes") { if (!String.IsNullOrEmpty(delivery_options)) delivery_options += " "; delivery_options += "<i class=\"glyphicon-iphone\"></i> Mobile App"; } if (campaign.Browser == "Yes") { if (!String.IsNullOrEmpty(delivery_options)) delivery_options += " "; delivery_options += "<i class=\"glyphicon-display\"></i> Browser"; } if (campaign.Email == "Yes") { if (!String.IsNullOrEmpty(delivery_options)) delivery_options += " "; delivery_options += "<i class=\"icon-envelope\"></i></i> Email"; } lblDeliveryModes.Text = delivery_options; if (campaign.Browser == "Yes") chkBrowser.Enabled = true; else { chkBrowser.Enabled = false; chkBrowser.Text = "<i>Browser - Not Available for this campaign</i>"; } if (campaign.Mobile == "Yes") chkMobile.Enabled = true; else { chkMobile.Enabled = false; chkMobile.Text = "<i>Mobile App - Not Available for this campaign</i>"; } if (campaign.SMS == "Yes") chkSMS.Enabled = true; else { chkSMS.Enabled = false; chkSMS.Text = "<i>SMS - Not Available for this campaign</i>"; } if (campaign.Email == "Yes") chkEmail.Enabled = true; else { chkEmail.Enabled = false; chkEmail.Text = "<i>Email - Not Available for this campaign</i>"; } } else { lblTitle.Text = "Create New Campaign"; rblAvailableNew.Text = "Yes"; plhMoreInfo.Visible = false; plhTools.Visible = false; } } }
protected void btnEnroll_Click(object sender, EventArgs e) { // run check for mobile text if (!String.IsNullOrEmpty(lblCampaignID.Text)) { campaign_id = Convert.ToInt32(lblCampaignID.Text); } return_url = lblReturnURL.Text; string mobile_number = txtMobileNumber.Text; bool error_occurred = false; bool phone_belongs_to_another_user = false; // check to see if this number is already being used by another user int curr_user_id = Convert.ToInt32(Context.Items["UserID"]); int scope_id = Convert.ToInt32(Context.Items["ScopeID"]); var check_user = qPtl_User.GetUserByPhone(txtMobileNumber.Text, scope_id); if (check_user.UserID > 0) { if (check_user.UserID != curr_user_id) { error_occurred = true; phone_belongs_to_another_user = true; } } // replace characters if (mobile_number.Contains("-")) { mobile_number = mobile_number.Replace("-", ""); } if (mobile_number.Contains(".")) { mobile_number = mobile_number.Replace(".", ""); } if (mobile_number.Contains("/")) { mobile_number = mobile_number.Replace("/", ""); } if (mobile_number.Contains("(")) { mobile_number = mobile_number.Replace("(", ""); } if (mobile_number.Contains(")")) { mobile_number = mobile_number.Replace(")", ""); } if (mobile_number.Contains("*")) { mobile_number = mobile_number.Replace("*", ""); } if (mobile_number.Contains(" ")) { mobile_number = mobile_number.Replace(" ", ""); } try { string first_char = mobile_number.Substring(0, 1); if (mobile_number.Length == 11 && first_char == "1") { mobile_number = mobile_number.Substring(1, 10); } } catch { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } if (String.IsNullOrEmpty(mobile_number)) { litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; error_occurred = true; } string pat_m = @"^[0-9]{10}$"; Regex r_m = new Regex(pat_m, RegexOptions.IgnoreCase); Match m_m = r_m.Match(mobile_number); if (!m_m.Success) { error_occurred = true; litMsg.Text = "<br><br>* Make sure to enter a 10 digit phone number"; } if (error_occurred == false) { if (btnEnroll.Text == "Turn Off Text Messages") { qCom_UserPreference pref = new qCom_UserPreference(curr_user_id); pref.OkSms = "No"; pref.Update(); } else { // save phone number to profile qPtl_UserProfile profile = new qPtl_UserProfile(curr_user_id); if (profile.Phone1Type == "Mobile") { profile.Phone1 = string.Empty; profile.Phone1Type = string.Empty; } if (profile.Phone2Type == "Mobile") { profile.Phone2 = string.Empty; profile.Phone2Type = string.Empty; } profile.Phone1 = txtMobileNumber.Text; profile.Phone1Type = "Mobile"; profile.Update(); // add new mobile verification code to qCom_UserPreferences var pref = qCom_UserPreference.GetUserPreference(curr_user_id); int new_pin = qCom_UserPreference.GenerateMobilePIN(); if (pref != null) { if (pref.UserID > 0) { pref.MobilePIN = Convert.ToString(new_pin); pref.Update(); } } else { qCom_UserPreference pref2 = new qCom_UserPreference(); pref2.ScopeID = Convert.ToInt32(Context.Items["ScopeID"]); pref2.Available = "Yes"; pref2.Created = DateTime.Now; pref2.CreatedBy = curr_user_id; pref2.LastModified = DateTime.Now; pref2.LastModifiedBy = curr_user_id; pref2.UserID = curr_user_id; pref2.OkBulkEmail = "Yes"; pref2.OkSms = "Yes"; pref2.OkEmail = "Yes"; pref2.MobilePIN = Convert.ToString(new_pin); pref2.Insert(); } // get correct DID string alt_did = string.Empty; // see if user has custom record var camp_pref = qCom_UserCampaignPreference.GetUserCampaignPreferences(campaign_id, curr_user_id); if (camp_pref != null) { alt_did = camp_pref.DID; } else { // see if campaign has available dedicated DIDs qSoc_Campaign campaign = new qSoc_Campaign(campaign_id); qPtl_User user = new qPtl_User(curr_user_id); alt_did = AddCampaignUserPreference(campaign, user, scope_id); if (String.IsNullOrEmpty(alt_did)) { alt_did = System.Configuration.ConfigurationManager.AppSettings["SMSDid"]; } } string alt_pin_message_uri = string.Empty; var c_pref = qCom_CampaignPreference.GetCampaignPreferences(campaign_id); if (c_pref != null) { if (c_pref.CampaignPreferenceID > 0) { alt_pin_message_uri = c_pref.MobileVerifySMSURI; } } // send mobile pin qCom_UserPreference.SendMobilePIN(Convert.ToString(new_pin), curr_user_id, alt_did, alt_pin_message_uri); plhManage.Visible = false; plhVerify.Visible = true; } } else { if (phone_belongs_to_another_user == true) { litMsg.Text = "<br><br>* This phone number belongs to another user."; } } }