/// <summary> /// SUBMISSIONS automatically approved /// </summary> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void AutoApproveSubmission(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { try { string autoApproveSubmission = "0"; var autoApproveSubmission1 = ConfigurationManager.AppSettings["AutoApproveSubmission"]; if (autoApproveSubmission1 != null && !string.IsNullOrEmpty(autoApproveSubmission1)) { autoApproveSubmission = autoApproveSubmission1; } if (autoApproveSubmission.ToLower().Trim() != "1") { return; } bool IsApprovedOrg = false; if (polinatorInformation.IsApproved.HasValue) { IsApprovedOrg = polinatorInformation.IsApproved.Value; } polinatorInformation.IsApproved = true; //polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; //submit change mydb.SaveChanges(); } catch (Exception ex) { Pollinator.Common.Logger.Error("Error occured at " + typeof(Account_Register).Name + ".AutoApproveSubmission(...). ", ex); } }
private void SetInfoForMap(UserDetail userDetail, PolinatorInformation polinatorInformation) { string sAddress = string.Empty; if (!string.IsNullOrEmpty(polinatorInformation.LandscapeStreet)) { sAddress += ", " + polinatorInformation.LandscapeStreet; } if (!string.IsNullOrEmpty(polinatorInformation.LandscapeCity)) { sAddress += ", " + polinatorInformation.LandscapeCity; } if (!string.IsNullOrEmpty(polinatorInformation.LandscapeState)) { sAddress += ", " + polinatorInformation.LandscapeState; } if (!string.IsNullOrEmpty(polinatorInformation.LandscapeZipcode)) { sAddress += ", " + polinatorInformation.LandscapeZipcode; } if (sAddress.Length > 2) { sAddress = sAddress.Substring(2); } this.Address = Server.HtmlEncode(sAddress); this.PollinatorName = Server.HtmlEncode(userDetail.FirstName); this.organizationDescription = Server.HtmlEncode(polinatorInformation.Description); }
private void GetValueFromControl(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) { usr.Email = txtEmail.Text; } //Table 1 :user detail userDetail.FirstName = txtFirstName.Text; userDetail.PhoneNumber = txtPhoneNumber.Text; polinatorInformation.PollinatorType = Int32.Parse(drPollinatorType.SelectedValue); //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtOrganizationName.Text; polinatorInformation.PollinatorSize = Int32.Parse(drPollinatorSize.SelectedValue); string pass = txtPassword.Text; polinatorInformation.LandscapeStreet = txtLandscapeStreet.Text; polinatorInformation.LandscapeCity = txtLandscapeCity.Text; polinatorInformation.LandscapeState = txtLandscapeState.Text; polinatorInformation.LandscapeZipcode = txtLandscapeZipcode.Text; polinatorInformation.LandscapeCountry = drCountry.SelectedValue; polinatorInformation.PhotoUrl = txtPhotoUrl.Text; polinatorInformation.YoutubeUrl = txtYoutubeUrl.Text; polinatorInformation.Description = orgDescription.Text; }
private void SetValueToControlPremium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) { //txtUserName.Text = usr.UserName; txtEmail.Text = usr.Email; } //Table 1 :user detail //HiddenPremiumLevel.Value = userDetail.MembershipLevel.ToString(); txtFirstName.Text = userDetail.FirstName; txtLastName.Text = userDetail.LastName; txtPhoneNumber.Text = userDetail.PhoneNumber; txtOrganizationName.Text = userDetail.OrganizationName; //Table 2: polinatorInformation txtOrganizationName.Text = polinatorInformation.OrganizationName; txtLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtLandscapeCity.Text = polinatorInformation.LandscapeCity; txtLandscapeState.Text = polinatorInformation.LandscapeState; txtLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; txtPhotoUrl.Text = polinatorInformation.PhotoUrl; txtYoutubeUrl.Text = polinatorInformation.YoutubeUrl; //premium info txtWebsite.Text = polinatorInformation.Website; try { BindPollinatorSize(ddlPollinatorSize); ddlPollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); } catch (Exception) { } try { BindPollinatorType(ddlPollinatorType); ddlPollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); } catch (Exception) {} txtDescription.Text = polinatorInformation.Description; txtBillingAddress.Text = polinatorInformation.BillingAddress; txtBillingCity.Text = polinatorInformation.BillingCity; txtBillingState.Text = polinatorInformation.BillingState; txtBillingZipcode.Text = polinatorInformation.BillingZipcode; txtPaymentFullName.Text = polinatorInformation.PaymentFullName; txtPaymentAddress.Text = polinatorInformation.PaymentAddress; txtPaymentState.Text = polinatorInformation.PaymentState; txtPaymentCardNumber.Text = polinatorInformation.PaymentCardNumber; string photoUrl = Utility.ValidateImage(polinatorInformation.PhotoUrl); imgPhotoP.ImageUrl = photoUrl; //if (String.IsNullOrEmpty(photoUrl)) // imgPhoto.Visible = false; }
private void SetPhoto(PolinatorInformation polinatorInformation) { string photoUrls = string.Empty; if (polinatorInformation.PhotoUrl != null) { photoUrls = polinatorInformation.PhotoUrl.Trim(); } txtNorPhotoUrl.Text = photoUrls; txtPrePhotoUrl.Text = photoUrls; if (!string.IsNullOrEmpty(photoUrls)) { string[] arrPhoto = photoUrls.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); numPhoto.Text = String.Format("({0} {1})", arrPhoto.Length.ToString(), arrPhoto.Length > 1 ? "photos" : "photo"); numPhotoN.Text = String.Format("({0} {1})", arrPhoto.Length.ToString(), arrPhoto.Length > 1 ? "photos" : "photo"); var firstUrl = Utility.ValidateImage(arrPhoto[0].Trim()); imgPhoto.ImageUrl = firstUrl; if (string.IsNullOrEmpty(firstUrl)) { imgPhoto.Style["display"] = "none"; imgPhotoP.Style["display"] = "none"; } } else { numPhoto.Style["display"] = "none"; numPhotoN.Style["display"] = "none"; imgPhoto.Style["display"] = "none"; imgPhotoP.Style["display"] = "none"; } }
/// <summary> /// User Normal: collect data from controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void GetInfoFromFormNormal(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { // usr.UserName = txtUserNameP.Text; if (usr != null) { usr.Email = txtNorEmail.Text; } //Table 1 :user detail userDetail.MembershipLevel = 0;//Normal userDetail.FirstName = txtNorFirstName.Text.Trim(); userDetail.LastName = txtNorLastName.Text.Trim(); userDetail.PhoneNumber = txtNorPhoneNumber.Text.Trim(); //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtNorOrganizationName.Text.Trim(); polinatorInformation.PollinatorType = Int32.Parse(ddlNorPollinatorType.SelectedValue); polinatorInformation.PollinatorSize = Int32.Parse(ddlNorPollinatorSize.SelectedValue); polinatorInformation.LandscapeStreet = txtNorLandscapeStreet.Text.Trim(); polinatorInformation.LandscapeCity = txtNorLandscapeCity.Text.Trim(); polinatorInformation.LandscapeState = txtNorLandscapeState.Text.Trim(); polinatorInformation.LandscapeZipcode = txtNorLandscapeZipcode.Text.Trim(); polinatorInformation.LandscapeCountry = ddlNorCountry.SelectedValue.Trim(); polinatorInformation.PhotoUrl = txtNorPhotoUrl.Text.Trim(); polinatorInformation.YoutubeUrl = txtNorYoutubeUrl.Text.Trim(); //get lat, lng polinatorInformation.Latitude = decimal.Parse(hdnLat.Value); polinatorInformation.Longitude = decimal.Parse(hdnLng.Value); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { //ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); if (!Context.User.Identity.IsAuthenticated || !Roles.IsUserInRole(Utility.RoleName.Members.ToString())) { Response.Redirect("~/ShareMap.aspx"); } //var fn = GetUserFirstName(); MembershipUser usr = Membership.GetUser(UserID); var userDetail = GetUser(); if (userDetail == null) { userDetail = new UserDetail(); } var polinatorInformation = GetPolinatorInfo(); if (polinatorInformation == null) { polinatorInformation = new PolinatorInformation(); } SetValueToControlPremium(usr, userDetail, polinatorInformation); } catch (Exception ex) { Pollinator.Common.Logger.Error("Error occured at " + typeof(Members_UserUpdate).Name + ".Page_Load(). Exception:" + ex.Message); } } }
/// <summary> /// User Premium: load data from DB into controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void LoadDataToFormPremium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { //divRowRegNormal.Visible = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='none';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='inline'; SetVariablesOfUploadControl('1');", true); HiddenMemberLevel.Value = "1"; if (usr != null) { txtPreUserName.Text = usr.UserName; txtPreEmail.Text = usr.Email; } //Table 1 :user detail txtPreFirstName.Text = userDetail.FirstName; txtPreLastName.Text = userDetail.LastName; txtPrePhoneNumber.Text = userDetail.PhoneNumber; //txtPreOrganizationName.Text = userDetail.OrganizationName; //Table 2: polinatorInformation txtPreOrganizationName.Text = polinatorInformation.OrganizationName; txtPreLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtPreLandscapeCity.Text = polinatorInformation.LandscapeCity; txtPreLandscapeState.Text = polinatorInformation.LandscapeState; txtPreLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; //txtPrePhotoUrl.Text = polinatorInformation.PhotoUrl; //txtPreYoutubeUrl.Text = polinatorInformation.YoutubeUrl; //premium info txtPreWebsite.Text = polinatorInformation.Website; BindPollinatorSize(ddlPrePollinatorSize); ddlPrePollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); BindPollinatorType(ddlPrePollinatorType); ddlPrePollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindCountry(ddlPreCountry); ddlPreCountry.SelectedValue = polinatorInformation.LandscapeCountry.ToString(); txtPreDescription.Text = polinatorInformation.Description; txtPreBillingAddress.Text = polinatorInformation.BillingAddress; txtPreBillingCity.Text = polinatorInformation.BillingCity; txtPreBillingState.Text = polinatorInformation.BillingState; txtPreBillingZipcode.Text = polinatorInformation.BillingZipcode; SetPhoto(polinatorInformation); SetVideo(polinatorInformation); //load lat, lng, txtPosition hdnLat.Value = polinatorInformation.Latitude.ToString(); hdnLng.Value = polinatorInformation.Longitude.ToString(); txtPrePosition.Text = polinatorInformation.Latitude.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "showvideo", "displayVideoWithOutValidate('#" + txtPreYoutubeUrl.ClientID + "');", true); }
protected void btnUpdate_Click(object sender, EventArgs e) { try { MembershipUser usr = Membership.GetUser(UserID); var userDetail = GetUser(); if (userDetail == null) { userDetail = new UserDetail(); } var polinatorInformation = GetPolinatorInfo(); if (polinatorInformation == null) { polinatorInformation = new PolinatorInformation(); } //status polinatorInformation.IsApproved = false;//reset IsApproved = 0 polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; //get new values from form and set to object to update GetValueFromControlPrenium(usr, userDetail, polinatorInformation); if (usr != null) { Membership.UpdateUser(usr); } mydb.SaveChanges(); //StatusMessage.Text = "<strong>Update successful!</strong>"; //GoToAlertMessage(panelSuccessMessage); ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); //Response.Redirect("~/ShareMap.aspx"); } catch (Exception ex) { Response.Write(ex.ToString()); Pollinator.Common.Logger.Error("Error occured at " + typeof(Members_UserUpdate).Name + ".btnUpdate_Click(). Exception:" + ex.Message); GoToAlertMessage(panelErrorMessage); } }
private void SetVideo(PolinatorInformation polinatorInformation) { string youtubeUrls = string.Empty; if (polinatorInformation.YoutubeUrl != null) { youtubeUrls = polinatorInformation.YoutubeUrl.Trim(); } txtYoutubeUrl.Text = youtubeUrls; if (!string.IsNullOrEmpty(youtubeUrls)) { string[] arrVideo = youtubeUrls.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); numVideo.Text = String.Format("({0} {1})", arrVideo.Length.ToString(), arrVideo.Length > 1 ? "videos" : "video"); } else { numVideo.Style["display"] = "none"; } }
/// <summary> /// User Premium: collect data from controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void GetInfoFromFormPrenium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) { usr.Email = txtPreEmail.Text; } //Table 1 :user detail userDetail.MembershipLevel = 1;//premium userDetail.FirstName = txtPreFirstName.Text.Trim(); userDetail.LastName = txtPreLastName.Text.Trim(); userDetail.PhoneNumber = txtPrePhoneNumber.Text.Trim(); //userDetail.OrganizationName = txtPreOrganizationName.Text.Trim(); //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtPreOrganizationName.Text.Trim(); polinatorInformation.PollinatorSize = Int32.Parse(ddlPrePollinatorSize.SelectedValue); polinatorInformation.LandscapeStreet = txtPreLandscapeStreet.Text.Trim(); polinatorInformation.LandscapeCity = txtPreLandscapeCity.Text.Trim(); polinatorInformation.LandscapeState = txtPreLandscapeState.Text.Trim(); polinatorInformation.LandscapeZipcode = txtPreLandscapeZipcode.Text.Trim(); polinatorInformation.LandscapeCountry = ddlPreCountry.SelectedValue; polinatorInformation.PhotoUrl = txtPrePhotoUrl.Text.Trim(); polinatorInformation.YoutubeUrl = txtPreYoutubeUrl.Text.Trim(); //premium info polinatorInformation.Website = txtPreWebsite.Text.Trim(); polinatorInformation.PollinatorType = Int32.Parse(ddlPrePollinatorType.SelectedValue); polinatorInformation.Description = txtPreDescription.Text.Trim(); polinatorInformation.BillingAddress = txtPreBillingAddress.Text.Trim(); polinatorInformation.BillingCity = txtPreBillingCity.Text.Trim(); polinatorInformation.BillingState = txtPreBillingState.Text.Trim(); polinatorInformation.BillingZipcode = txtPreBillingZipcode.Text.Trim(); //get lat, lng polinatorInformation.Latitude = decimal.Parse(hdnLat.Value); polinatorInformation.Longitude = decimal.Parse(hdnLng.Value); }
protected void btnUpdate_Click(object sender, EventArgs e) { try { MembershipUser usr = Membership.GetUser(UserID); var userDetail = GetUser(); if (userDetail==null) userDetail = new UserDetail(); var polinatorInformation = GetPolinatorInfo(); if (polinatorInformation == null) polinatorInformation = new PolinatorInformation(); //status polinatorInformation.IsApproved = false;//reset IsApproved = 0 polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; //get new values from form and set to object to update GetValueFromControlPrenium(usr, userDetail, polinatorInformation); if (usr != null) Membership.UpdateUser(usr); mydb.SaveChanges(); //StatusMessage.Text = "<strong>Update successful!</strong>"; //GoToAlertMessage(panelSuccessMessage); ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); //Response.Redirect("~/ShareMap.aspx"); } catch (Exception ex) { Response.Write(ex.ToString()); Pollinator.Common.Logger.Error("Error occured at " + typeof(Members_UserUpdate).Name + ".btnUpdate_Click(). Exception:" + ex.Message); GoToAlertMessage(panelErrorMessage); } }
private void SetValueToControl(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { txtUserName.Text = UserName; if (usr != null) { txtEmail.Text = usr.Email; } //Table 1 :user detail txtFirstName.Text = userDetail.FirstName; txtPhoneNumber.Text = userDetail.PhoneNumber; //Table 2: polinatorInformation txtOrganizationName.Text = polinatorInformation.OrganizationName; BindPollinatorType(drPollinatorType); drPollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindPollinatorSize(drPollinatorSize); drPollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); txtLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtLandscapeCity.Text = polinatorInformation.LandscapeCity; txtLandscapeState.Text = polinatorInformation.LandscapeState; txtLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; BindCountry(drCountry); drCountry.SelectedValue = polinatorInformation.LandscapeCountry; orgDescription.Text = polinatorInformation.Description; txtPhotoUrl.Attributes.Add("readonly", "readonly"); txtPhotoUrl.Attributes.Add("tabindex", "-1"); SetPhoto(polinatorInformation); txtYoutubeUrl.Attributes.Add("readonly", "readonly"); txtYoutubeUrl.Attributes.Add("tabindex", "-1"); SetVideo(polinatorInformation); }
protected void btnUpdate_Click(object sender, EventArgs e) { try { byte memberLevel = byte.Parse(HiddenMemberLevel.Value); if (memberLevel == 1)//upgrade from Normal to Premium { //premium ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='none';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='inline';", true); } else { //normal ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='inline';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='none';", true); } //user MembershipUser usr = System.Web.Security.Membership.GetUser(UserID); var userDetail = GetUserDetail(); if (userDetail == null) userDetail = new UserDetail(); var polinatorInformation = GetPolinatorInformation(); if (polinatorInformation == null) polinatorInformation = new PolinatorInformation(); //status polinatorInformation.IsApproved = false;//reset IsApproved = 0 polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; //get new values from form and set to object to update if (memberLevel == 1 && userDetail.MembershipLevel == 0)//upgrade from Normal to Premium { //add info into UserDetail table var tempUserPaymentOld = (from tempUP in mydb.TempUserPayments where tempUP.UserId == UserID select tempUP).FirstOrDefault(); if (tempUserPaymentOld != null) mydb.TempUserPayments.Remove(tempUserPaymentOld); TempUserPayment tempUserPayment = new TempUserPayment(); tempUserPayment.UserId = UserID; //membership(user) tempUserPayment.Email = txtPreEmail.Text; //userDetail.MembershipLevel(have 2 levels): 0 is free; 1 is premium tempUserPayment.MembershipLevel = 1;//Premium tempUserPayment.FirstName = txtPreFirstName.Text; tempUserPayment.LastName = txtPreLastName.Text; tempUserPayment.PhoneNumber = txtPrePhoneNumber.Text; //tempUserPayment.OrganizationName = txtPreOrganizationName.Text; //table2: UserDetail tempUserPayment.OrganizationName = txtPreOrganizationName.Text; tempUserPayment.PollinatorSize = Int32.Parse(ddlPrePollinatorSize.SelectedValue); tempUserPayment.PollinatorType = Int32.Parse(ddlPrePollinatorType.SelectedValue); tempUserPayment.LandscapeStreet = txtPreLandscapeStreet.Text; tempUserPayment.LandscapeCity = txtPreLandscapeCity.Text; tempUserPayment.LandscapeState = txtPreLandscapeState.Text; tempUserPayment.LandscapeZipcode = txtPreLandscapeZipcode.Text; tempUserPayment.LandscapeCountry = ddlPreCountry.SelectedValue; tempUserPayment.PhotoUrl = txtPrePhotoUrl.Text; tempUserPayment.YoutubeUrl = txtPreYoutubeUrl.Text; tempUserPayment.Website = txtPreWebsite.Text; tempUserPayment.Description = txtPreDescription.Text; tempUserPayment.BillingAddress = txtPreBillingAddress.Text; tempUserPayment.BillingCity = txtPreBillingCity.Text; tempUserPayment.BillingState = txtPreBillingState.Text; ; tempUserPayment.BillingZipcode = txtPreBillingZipcode.Text; //save lat, long tempUserPayment.Latitude = decimal.Parse(hdnLat.Value); tempUserPayment.Longitude = decimal.Parse(hdnLng.Value); //save userfolder //if (!string.IsNullOrEmpty(tempUserPayment.PhotoUrl)) //{ // string filePath = tempUserPayment.PhotoUrl.Split(';')[0]; // if (!string.IsNullOrEmpty(filePath)) // { // int index1 = filePath.LastIndexOf('/'); // if (index1 > 0) // { // filePath = filePath.Substring(0, index1).Trim(); // index1 = filePath.LastIndexOf('/'); // if (index1 > 0) // filePath = filePath.Substring(index1+1, filePath.Length-index1).Trim(); // tempUserPayment.UserFolder = HttpUtility.HtmlDecode(filePath); // } // } //} //createProcess //tempUserPayment.CreateProcess = 1; //tempUserPayment.CreateDate = DateTime.Now; //save to TempUserPayments table mydb.TempUserPayments.Add(tempUserPayment); mydb.SaveChanges();//submit temp table //Payment: send request to Paypal if (tempUserPayment != null) { // get business account email from config string PaypalEmail = ConfigurationManager.AppSettings["PaypalSeller"]; // get variable environment from config bool SandboxEnvi = bool.Parse(ConfigurationManager.AppSettings["SandboxEnvironment"]); // get price from config string PaypalPrice = ConfigurationManager.AppSettings["PaypalPrice"]; // Callback url to handle process when payement is successful string ReturnUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/Members/Manage.aspx?payer=" + UserID; // Callback url to handle process when IPN Paypal service notify string NotifyUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/HandlerIPN.ashx"; // Callback url to handle process when payment is cancel string CancelUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/Members/Manage.aspx?payc=" + UserID; //name of product string PaypalItemName = ConfigurationManager.AppSettings["PaypalItemName"]; //custom parram contain temp information of New User string custom = UserID + ";password;change";//CreateUserWizard2.ContinueDestinationPageUrl; //end custom //Pollinator.Common.Logger.Information("Paypal Manage 2 ReturnUrl= " + ReturnUrl); // generate a html form paypal IPN string string PaypalFormHtmlStr = "<form target='_parent' name='_xclick' action='" + ((SandboxEnvi) ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr") + "' method='post'>" + "<input type='hidden' name='cmd' value='_xclick'>" + "<input type='hidden' name='business' value='" + PaypalEmail + "'>" + "<input type='hidden' name='payer_email' value='" + PaypalEmail + "'>" + "<input type='hidden' name='currency_code' value='USD'>" + "<input type='hidden' name='item_name' value='" + PaypalItemName + "'>" + "<input type='hidden' name='amount' value='" + PaypalPrice + "'>" + "<input type='hidden' name='custom' value='" + custom + "' />" + "<input type='hidden' name='return' value='" + ReturnUrl + "'>" + "<input type='hidden' name='notify_url' value='" + NotifyUrl + "'>" + "<input type='hidden' name='cancel_url' value='" + CancelUrl + "'>" + "<input type='image' id='paypal_btn' src='' border='0' name='submit' alt=''> </form>"; //Pollinator.Common.Logger.Information("Paypal Manage 3 PaypalFormHtmlStr= " + PaypalFormHtmlStr); //payment //string ExternalPaymemtlUrl = ConfigurationManager.AppSettings["ExternalPaymemtlUrl"]; //if (!String.IsNullOrEmpty(ExternalPaymemtlUrl))//external payment //{ // tempUserPayment.PaypalFormHtmlStr = PaypalFormHtmlStr; // mydb.SaveChanges(); // //redirect to external paymemt page // ScriptManager.RegisterStartupScript(this, this.GetType(), "popupWaitxxxx", "document.getElementById('MainContent_HyperLink123').click();", true); // //string urlRedirect = string.Format("{0}?userID={1}", ExternalPaymemtlUrl, tempUserPayment.UserId); // //ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", " window.location.replace(\"" + urlRedirect + "\");", true); //} //else // ScriptManager.RegisterStartupScript(this, this.GetType(), "paypal", "document.getElementById('paypal_container').innerHTML = \"" + PaypalFormHtmlStr + "\" ; document.getElementById('paypal_btn').click() ;", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "paypal", "document.getElementById('paypal_container').innerHTML = \"" + PaypalFormHtmlStr + "\" ; document.getElementById('paypal_btn').click() ;", true); } //show please wait... popup ScriptManager.RegisterStartupScript(this, this.GetType(), "popupWait", "document.getElementById('showProcessbar').click();", true); } else { if (memberLevel == 0) GetInfoFromFormNormal(usr, userDetail, polinatorInformation); else GetInfoFromFormPrenium(usr, userDetail, polinatorInformation); if (usr != null) System.Web.Security.Membership.UpdateUser(usr); mydb.SaveChanges();//submit changed to DB //Auto Approved AutoApproveSubmission(usr, userDetail, polinatorInformation); ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); } //Response.Redirect("~/ShareMap.aspx"); } catch (Exception ex) { byte memberLevel = byte.Parse(HiddenMemberLevel.Value); if (memberLevel == 1)//upgrade from Normal to Premium { //premium ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='none';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='inline';", true); } else { //normal ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='inline';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='none';", true); } //Response.Write(ex.ToString()); Pollinator.Common.Logger.Error("Error occured at " + typeof(Members_Manage).Name + ".btnUpdate_Click()", ex); GoToAlertMessage(panelErrorMessage); } }
private void GetValueFromControlPrenium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) usr.Email = txtEmail.Text; //Table 1 :user detail userDetail.MembershipLevel = 1;//premium userDetail.FirstName = txtFirstName.Text; userDetail.LastName = txtLastName.Text; userDetail.PhoneNumber = txtPhoneNumber.Text; userDetail.OrganizationName = txtOrganizationName.Text; //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtOrganizationName.Text; polinatorInformation.PollinatorSize = Int32.Parse(ddlPollinatorSize.SelectedValue); polinatorInformation.LandscapeStreet = txtLandscapeStreet.Text; polinatorInformation.LandscapeCity = txtLandscapeCity.Text; polinatorInformation.LandscapeState = txtLandscapeState.Text; polinatorInformation.LandscapeZipcode = txtLandscapeZipcode.Text; polinatorInformation.PhotoUrl = txtPhotoUrl.Text; polinatorInformation.YoutubeUrl = txtYoutubeUrl.Text; //premium info polinatorInformation.Website = txtWebsite.Text; polinatorInformation.PollinatorType = Int32.Parse(ddlPollinatorType.SelectedValue); polinatorInformation.Description = txtDescription.Text; polinatorInformation.BillingAddress = txtBillingAddress.Text; polinatorInformation.BillingCity = txtBillingCity.Text; polinatorInformation.BillingState = txtBillingState.Text; polinatorInformation.BillingZipcode = txtBillingZipcode.Text; polinatorInformation.PaymentFullName = txtPaymentFullName.Text; polinatorInformation.PaymentAddress = txtPaymentAddress.Text; polinatorInformation.PaymentState = txtPaymentState.Text; polinatorInformation.PaymentCardNumber = txtPaymentCardNumber.Text; }
/// <summary> /// User Premium: collect data from controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void GetInfoFromFormPrenium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) usr.Email = txtPreEmail.Text; //Table 1 :user detail userDetail.MembershipLevel = 1;//premium userDetail.FirstName = txtPreFirstName.Text.Trim(); userDetail.LastName = txtPreLastName.Text.Trim(); userDetail.PhoneNumber = txtPrePhoneNumber.Text.Trim(); //userDetail.OrganizationName = txtPreOrganizationName.Text.Trim(); //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtPreOrganizationName.Text.Trim(); polinatorInformation.PollinatorSize = Int32.Parse(ddlPrePollinatorSize.SelectedValue); polinatorInformation.LandscapeStreet = txtPreLandscapeStreet.Text.Trim(); polinatorInformation.LandscapeCity = txtPreLandscapeCity.Text.Trim(); polinatorInformation.LandscapeState = txtPreLandscapeState.Text.Trim(); polinatorInformation.LandscapeZipcode = txtPreLandscapeZipcode.Text.Trim(); polinatorInformation.LandscapeCountry = ddlPreCountry.SelectedValue; polinatorInformation.PhotoUrl = txtPrePhotoUrl.Text.Trim(); polinatorInformation.YoutubeUrl = txtPreYoutubeUrl.Text.Trim(); //premium info polinatorInformation.Website = txtPreWebsite.Text.Trim(); polinatorInformation.PollinatorType = Int32.Parse(ddlPrePollinatorType.SelectedValue); polinatorInformation.Description = txtPreDescription.Text.Trim(); polinatorInformation.BillingAddress = txtPreBillingAddress.Text.Trim(); polinatorInformation.BillingCity = txtPreBillingCity.Text.Trim(); polinatorInformation.BillingState = txtPreBillingState.Text.Trim(); polinatorInformation.BillingZipcode = txtPreBillingZipcode.Text.Trim(); //get lat, lng polinatorInformation.Latitude = decimal.Parse(hdnLat.Value); polinatorInformation.Longitude = decimal.Parse(hdnLng.Value); }
/// <summary> /// User Premium: load data from DB into controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void LoadDataToFormPremium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { //divRowRegNormal.Visible = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='none';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='inline'; SetVariablesOfUploadControl('1');", true); HiddenMemberLevel.Value = "1"; if (usr != null) { txtPreUserName.Text = usr.UserName; txtPreEmail.Text = usr.Email; } //Table 1 :user detail txtPreFirstName.Text = userDetail.FirstName; txtPreLastName.Text = userDetail.LastName; txtPrePhoneNumber.Text = userDetail.PhoneNumber; //txtPreOrganizationName.Text = userDetail.OrganizationName; //Table 2: polinatorInformation txtPreOrganizationName.Text = polinatorInformation.OrganizationName; txtPreLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtPreLandscapeCity.Text = polinatorInformation.LandscapeCity; txtPreLandscapeState.Text = polinatorInformation.LandscapeState; txtPreLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; //txtPrePhotoUrl.Text = polinatorInformation.PhotoUrl; //txtPreYoutubeUrl.Text = polinatorInformation.YoutubeUrl; //premium info txtPreWebsite.Text = polinatorInformation.Website; BindPollinatorSize(ddlPrePollinatorSize); ddlPrePollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); BindPollinatorType(ddlPrePollinatorType); ddlPrePollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindCountry(ddlPreCountry); ddlPreCountry.SelectedValue = polinatorInformation.LandscapeCountry.ToString(); txtPreDescription.Text = polinatorInformation.Description; txtPreBillingAddress.Text = polinatorInformation.BillingAddress; txtPreBillingCity.Text = polinatorInformation.BillingCity; txtPreBillingState.Text = polinatorInformation.BillingState; txtPreBillingZipcode.Text = polinatorInformation.BillingZipcode; SetPhoto(polinatorInformation); SetVideo(polinatorInformation); //load lat, lng, txtPosition hdnLat.Value = polinatorInformation.Latitude.ToString(); hdnLng.Value = polinatorInformation.Longitude.ToString(); txtPrePosition.Text = polinatorInformation.Latitude.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "showvideo", "displayVideoWithOutValidate('#" + txtPreYoutubeUrl.ClientID + "');", true); }
private void SetValueToControlPremium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { divRowRegNormal.Visible = false; if (usr != null) { txtUserNameP.Text = usr.UserName; txtEmailP.Text = usr.Email; } //Table 1 :user detail txtFirstNameP.Text = userDetail.FirstName; txtLastNameP.Text = userDetail.LastName; //txtPhoneNumberP.Text = userDetail.PhoneNumber; //Table 2: polinatorInformation txtOrganizationNameP.Text = polinatorInformation.OrganizationName; txtLandscapeStreetP.Text = polinatorInformation.LandscapeStreet; txtLandscapeCityP.Text = polinatorInformation.LandscapeCity; txtLandscapeStateP.Text = polinatorInformation.LandscapeState; txtLandscapeZipcodeP.Text = polinatorInformation.LandscapeZipcode; BindCountry(drCountryP); drCountryP.SelectedValue = polinatorInformation.LandscapeCountry; txtPhotoUrlP.Attributes.Add("readonly", "readonly"); txtPhotoUrlP.Attributes.Add("tabindex", "-1"); PremiumSetPhoto(polinatorInformation); txtYoutubeUrlP.Attributes.Add("readonly", "readonly"); txtYoutubeUrlP.Attributes.Add("tabindex", "-1"); PreniumSetVideo(polinatorInformation); //premium info txtWebsiteP.Text = polinatorInformation.Website; BindPollinatorSize(drPollinatorSizeP); drPollinatorSizeP.SelectedValue = polinatorInformation.PollinatorSize.ToString(); BindPollinatorType(drPollinatorTypeP); drPollinatorTypeP.SelectedValue = polinatorInformation.PollinatorType.ToString(); txtOrganizationDescriptionP.Text = polinatorInformation.Description; txtBillingAddress.Text = polinatorInformation.BillingAddress; txtBillingCity.Text = polinatorInformation.BillingCity; txtBillingState.Text = polinatorInformation.BillingState; txtBillingZipcode.Text = polinatorInformation.BillingZipcode; }
/// <summary> /// SUBMISSIONS automatically approved /// </summary> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void AutoApproveSubmission(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { try { string autoApproveSubmission = "0"; var autoApproveSubmission1 = ConfigurationManager.AppSettings["AutoApproveSubmission"]; if (autoApproveSubmission1 != null && !string.IsNullOrEmpty(autoApproveSubmission1)) autoApproveSubmission = autoApproveSubmission1; if (autoApproveSubmission.ToLower().Trim() != "1") return; bool IsApprovedOrg = false; if (polinatorInformation.IsApproved.HasValue) IsApprovedOrg = polinatorInformation.IsApproved.Value; polinatorInformation.IsApproved = true; polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; //submit change mydb.SaveChanges(); } catch (Exception ex) { Pollinator.Common.Logger.Error("Error occured at " + typeof(Members_Manage).Name + ".AutoApproveSubmission(...). ", ex); } }
protected void btnUpdate_Click(object sender, EventArgs e) { int progress = 0; string userName = string.Empty; UserDetail userDetail = new UserDetail(); PolinatorInformation polinatorInformation = new PolinatorInformation(); Label lblErrorMessage = ((Label)LoginView1.FindControl("lblErrorMessage")); lblErrorMessage.Text = ""; try { //Create new User //userName = ((TextBox)LoginView1.FindControl("txtUserName")).Text; //string password = ((TextBox)LoginView1.FindControl("txtPassword")).Text; string password = string.Empty; string email = ((TextBox)LoginView1.FindControl("txtEmail")).Text; string passwordQuestion = "Q?"; string passwordAnswer = "A"; bool isApproved = true; MembershipCreateStatus status; string messError = string.Empty; //auto gen UserName, Password if (string.IsNullOrEmpty(userName)) { userName = Utility.CreateRandomUserName(0); } if (string.IsNullOrEmpty(password)) { password = Utility.CreateRandomPassword(10); } //Exec create System.Web.Security.Membership.CreateUser(userName, password, email, passwordQuestion, passwordAnswer, isApproved, out status); //status if (status == MembershipCreateStatus.Success) { progress = 1; } else { lblErrorMessage.Text = GetErrorMessage(status); return; } // Get the UserId of the just-added user MembershipUser newUser = System.Web.Security.Membership.GetUser(userName); Guid newUserId = (Guid)newUser.ProviderUserKey; //add usser to Members role if (!Roles.RoleExists(roleMembersName)) { Roles.CreateRole(roleMembersName); } Roles.AddUserToRole(userName, roleMembersName); //Get Profile Data Entered by user in CUW control //table1: UserDetail userDetail.UserId = newUserId; userDetail.MembershipLevel = 0;//Normal userDetail.FirstName = ((TextBox)LoginView1.FindControl("txtFirstName")).Text; userDetail.LastName = ((TextBox)LoginView1.FindControl("txtLastName")).Text; userDetail.PhoneNumber = ((TextBox)LoginView1.FindControl("txtPhoneNumber")).Text; //table2: PolinatorInformation polinatorInformation.UserId = newUserId; polinatorInformation.ExpireDate = DateTime.Now.AddDays(30);//expire after 30 days //Pollinator Information polinatorInformation.OrganizationName = ((TextBox)LoginView1.FindControl("txtOrganizationName")).Text; polinatorInformation.LandscapeStreet = ((TextBox)LoginView1.FindControl("txtLandscapeStreet")).Text; polinatorInformation.LandscapeCity = ((TextBox)LoginView1.FindControl("txtLandscapeCity")).Text; polinatorInformation.LandscapeState = ((TextBox)LoginView1.FindControl("txtLandscapeState")).Text; polinatorInformation.LandscapeZipcode = ((TextBox)LoginView1.FindControl("txtLandscapeZipcode")).Text; //country polinatorInformation.LandscapeCountry = ((DropDownList)LoginView1.FindControl("ddlCountry")).SelectedValue; //size, type polinatorInformation.PollinatorSize = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPollinatorSize")).SelectedValue); polinatorInformation.PollinatorType = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPollinatorType")).SelectedValue); polinatorInformation.PhotoUrl = ((TextBox)LoginView1.FindControl("txtPhotoUrl")).Text; polinatorInformation.YoutubeUrl = ((TextBox)LoginView1.FindControl("txtYoutubeUrl")).Text; //save lat, long polinatorInformation.Latitude = decimal.Parse(hdnLat.Value); polinatorInformation.Longitude = decimal.Parse(hdnLng.Value); //update more 2 field, support PollinatorInfomation polinatorInformation.IsNew = true; polinatorInformation.LastUpdated = DateTime.Now; //save to 2 tables mydb.UserDetails.Add(userDetail); mydb.PolinatorInformations.Add(polinatorInformation); mydb.SaveChanges(); progress = 2;//set progress to step 2(added 2 tables) //set isApproved in Membership //newUser.IsApproved = true; //Membership.UpdateUser(newUser); //send mail default of aspnet SendRegisterEmailDefaultAspNet(newUser, userDetail, polinatorInformation, password); //Send emails asynchronously in background //SendRegisterEmail(userDetail, polinatorInformation); //Auto Approved AutoApproveSubmission(newUser, userDetail, polinatorInformation); progress = 3;//set progress to step 3(Approved) //Fixed bug: Auto sign in //if (System.Web.Security.Membership.ValidateUser(userName, password)) // FormsAuthentication.SetAuthCookie(userName, createPersistentCookie: false); //show popup string continueUrl = "~/Default"; if (!OpenAuth.IsLocalUrl(continueUrl)) { continueUrl = "~/"; } linkReturnToMap.NavigateUrl = continueUrl; ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); } catch (Exception ex) { //rollback if (progress == 1)//have just created User { System.Web.Security.Membership.DeleteUser(userName, true); } else if (progress == 2)//have created User, UserDetail, PollinatorInformation { System.Web.Security.Membership.DeleteUser(userName, true); if (userDetail.UserId != null) { mydb.UserDetails.Remove(userDetail); mydb.SaveChanges(); } if (polinatorInformation.UserId != null) { mydb.PolinatorInformations.Remove(polinatorInformation); mydb.SaveChanges(); } } //show error mess lblErrorMessage.Text = ex.Message; //write log Pollinator.Common.Logger.Error("Occured in function: " + typeof(Account_Register).Name + ".CreateUserWizard1_CreatedUser()", ex); //Response.Redirect("~/Default"); } }
private void SetInfoForMap(UserDetail userDetail, PolinatorInformation polinatorInformation) { string sAddress = string.Empty; if (!string.IsNullOrEmpty(polinatorInformation.LandscapeStreet)) sAddress += ", " + polinatorInformation.LandscapeStreet; if (!string.IsNullOrEmpty(polinatorInformation.LandscapeCity)) sAddress += ", " + polinatorInformation.LandscapeCity; if (!string.IsNullOrEmpty(polinatorInformation.LandscapeState)) sAddress += ", " + polinatorInformation.LandscapeState; if (!string.IsNullOrEmpty(polinatorInformation.LandscapeZipcode)) sAddress += ", " + polinatorInformation.LandscapeZipcode; if (sAddress.Length > 2) { sAddress = sAddress.Substring(2); } this.Address = Server.HtmlEncode(sAddress); this.PollinatorName = Server.HtmlEncode(userDetail.FirstName); }
private void WriteDB(List <ImportFields> listdata, string sourceData) { if (IS_WRITE_DB) { var csv = new StringBuilder(); var newLine = "FirstName,OrganizationName,Email,PollinatorSize,PollinatorType,LandscapeStreet,LandscapeCity,LandscapeState,LandscapeCountry,LandscapeZipcode,PhotoUrl,Latitude,Longitude,Premium,FuzyLocation,UserId" + Environment.NewLine; csv.Append(newLine); ImportFields writedata; UserDetail userDetail; PolinatorInformation polinatorInformation; Guid userId; int numRecord = listdata.Count; for (int i = 0; i < numRecord; i++) { writedata = listdata.ElementAt(i); /* if (writedata.PollinatorSize == 0) * writedata.PollinatorSize = 1; * if (writedata.PollinatorType == 0) * writedata.PollinatorType = 1;*/ if (writedata.LandscapeZipcode.Length > 15) { writedata.LandscapeZipcode = writedata.LandscapeZipcode.Substring(0, 15); } userDetail = new UserDetail(); polinatorInformation = new PolinatorInformation(); if (string.IsNullOrEmpty(writedata.UserId)) { /* if (!string.IsNullOrEmpty(writedata.Email)) * { * string usename = writedata.FirstName + "Username"; * string password = writedata.FirstName + "Password"; * * var usr = Membership.GetUser(usename); * if (usr == null) * { * usr = Membership.CreateUser(usename, password, writedata.Email); * // userId = (Guid)usr.ProviderUserKey; * } * * userId = (Guid)usr.ProviderUserKey; * } * else*/ userId = Guid.NewGuid(); } else { userId = new Guid(writedata.UserId); } userDetail.UserId = userId; userDetail.FirstName = writedata.FirstName; userDetail.MembershipLevel = writedata.Premium; //Table 2: polinatorInformation polinatorInformation.UserId = userId; polinatorInformation.OrganizationName = writedata.OrganizationName; polinatorInformation.PollinatorSize = writedata.PollinatorSize; polinatorInformation.PollinatorType = writedata.PollinatorType; polinatorInformation.LandscapeStreet = writedata.LandscapeStreet; if (polinatorInformation.LandscapeStreet == null) { polinatorInformation.LandscapeStreet = string.Empty; } polinatorInformation.LandscapeCity = writedata.LandscapeCity; polinatorInformation.LandscapeState = writedata.LandscapeState; polinatorInformation.LandscapeZipcode = writedata.LandscapeZipcode; polinatorInformation.LandscapeCountry = writedata.LandscapeCountry; polinatorInformation.PhotoUrl = writedata.PhotoUrl; polinatorInformation.YoutubeUrl = writedata.YoutubeUrl; polinatorInformation.IsApproved = true; polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; polinatorInformation.FuzyLocation = writedata.FuzyLocation; if (writedata.Latitude.HasValue && writedata.Longitude.HasValue) { polinatorInformation.Latitude = (decimal)writedata.Latitude; polinatorInformation.Longitude = (decimal)writedata.Longitude; } else { polinatorInformation.FuzyLocation = true; } polinatorInformation.SourceData = sourceData; if (string.IsNullOrEmpty(writedata.UserId)) { //int RowId = objPollinatorDA.Insert(TABLE_ID, objPollinator); // polinatorInformation.RowId = RowId; writedata = listdata.ElementAt(i); newLine = string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\",\"{13}\",\"{14}\",\"{15}\",{16}", writedata.FirstName, writedata.OrganizationName, writedata.Email, writedata.PollinatorSize, writedata.PollinatorType, writedata.LandscapeStreet, writedata.LandscapeCity, writedata.LandscapeState, writedata.LandscapeCountry, writedata.LandscapeZipcode, writedata.PhotoUrl, writedata.Latitude, writedata.Longitude, writedata.Premium, writedata.FuzyLocation, userId, Environment.NewLine); csv.Append(newLine); } mydb.UserDetails.Add(userDetail); mydb.PolinatorInformations.Add(polinatorInformation); } string uploadFolder = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; string sDirPath = Request.PhysicalApplicationPath + uploadFolder; File.WriteAllText(sDirPath + @"\oldSystem_writeDBresult.csv", csv.ToString()); try { mydb.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } } }
private void SetValueToControl(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { txtUserName.Text = UserName; if (usr != null) txtEmail.Text = usr.Email; //Table 1 :user detail txtFirstName.Text = userDetail.FirstName; txtPhoneNumber.Text = userDetail.PhoneNumber; //Table 2: polinatorInformation txtOrganizationName.Text = polinatorInformation.OrganizationName; BindPollinatorType(drPollinatorType); drPollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindPollinatorSize(drPollinatorSize); drPollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); txtLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtLandscapeCity.Text = polinatorInformation.LandscapeCity; txtLandscapeState.Text = polinatorInformation.LandscapeState; txtLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; BindCountry(drCountry); drCountry.SelectedValue = polinatorInformation.LandscapeCountry; orgDescription.Text = polinatorInformation.Description; txtPhotoUrl.Attributes.Add("readonly", "readonly"); txtPhotoUrl.Attributes.Add("tabindex", "-1"); SetPhoto(polinatorInformation); txtYoutubeUrl.Attributes.Add("readonly", "readonly"); txtYoutubeUrl.Attributes.Add("tabindex", "-1"); SetVideo(polinatorInformation); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { try { //ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); if (!Context.User.Identity.IsAuthenticated || !Roles.IsUserInRole(Utility.RoleName.Members.ToString())) { Response.Redirect("~/ShareMap.aspx"); } //var fn = GetUserFirstName(); MembershipUser usr = Membership.GetUser(UserID); var userDetail = GetUser(); if (userDetail == null) userDetail = new UserDetail(); var polinatorInformation = GetPolinatorInfo(); if (polinatorInformation == null) polinatorInformation = new PolinatorInformation(); SetValueToControlPremium(usr, userDetail, polinatorInformation); } catch (Exception ex) { Pollinator.Common.Logger.Error("Error occured at " + typeof(Members_UserUpdate).Name + ".Page_Load(). Exception:" + ex.Message); } } }
protected void btnPreUpdate_Click(object sender, EventArgs e) { int progress = 0; string userName = string.Empty; UserDetail userDetail = new UserDetail(); PolinatorInformation polinatorInformation = new PolinatorInformation(); Label lblPreErrorMessage = ((Label)LoginView1.FindControl("lblPreErrorMessage")); lblPreErrorMessage.Text = ""; try { //Create new User userName = ((TextBox)LoginView1.FindControl("txtPreUserName")).Text; string password = ((TextBox)LoginView1.FindControl("txtPrePassword")).Text; string email = ((TextBox)LoginView1.FindControl("txtPreEmail")).Text; string passwordQuestion = "Q?"; string passwordAnswer = "A"; bool isApproved = true; MembershipCreateStatus status; //auto gen UserName, Password if client not input UserName,Password if (string.IsNullOrEmpty(userName)) userName = Utility.CreateRandomUserName(0); if (string.IsNullOrEmpty(password)) password = Utility.CreateRandomPassword(10); //Exec create System.Web.Security.Membership.CreateUser(userName, password, email, passwordQuestion, passwordAnswer, isApproved, out status); //status if (status == MembershipCreateStatus.Success) progress = 1; else { lblPreErrorMessage.Text = GetErrorMessage(status); return; } // Get the UserId of the just-added user MembershipUser newUser = System.Web.Security.Membership.GetUser(userName); Guid newUserId = (Guid)newUser.ProviderUserKey; //add new Usser to Members role if (!Roles.RoleExists(roleMembersName)) Roles.CreateRole(roleMembersName); Roles.AddUserToRole(userName, roleMembersName); //add info into UserDetail table var tempUserPaymentOld = (from tempUP in mydb.TempUserPayments where tempUP.UserId == newUserId select tempUP).FirstOrDefault(); if (tempUserPaymentOld != null) mydb.TempUserPayments.Remove(tempUserPaymentOld); TempUserPayment tempUserPayment = new TempUserPayment(); tempUserPayment.UserId = newUserId; tempUserPayment.Email = newUser.Email; //userDetail.MembershipLevel(have 2 levels): 0 is free; 1 is premium tempUserPayment.MembershipLevel = 1;//Premium tempUserPayment.FirstName = ((TextBox)LoginView1.FindControl("txtPreFirstName")).Text; tempUserPayment.LastName = ((TextBox)LoginView1.FindControl("txtPreLastName")).Text; tempUserPayment.PhoneNumber = ((TextBox)LoginView1.FindControl("txtPrePhoneNumber")).Text; //table2: UserDetail //PolinatorInformation polinatorInformation = new PolinatorInformation(); //polinatorInformation.UserId = newUserId; tempUserPayment.OrganizationName = ((TextBox)LoginView1.FindControl("txtPreOrganizationName")).Text; tempUserPayment.LandscapeStreet = ((TextBox)LoginView1.FindControl("txtPreLandscapeStreet")).Text; tempUserPayment.LandscapeCity = ((TextBox)LoginView1.FindControl("txtPreLandscapeCity")).Text; tempUserPayment.LandscapeState = ((TextBox)LoginView1.FindControl("txtPreLandscapeState")).Text; tempUserPayment.LandscapeZipcode = ((TextBox)LoginView1.FindControl("txtPreLandscapeZipcode")).Text; //country tempUserPayment.LandscapeCountry = ((DropDownList)LoginView1.FindControl("ddlPreCountry")).SelectedValue; //size, type tempUserPayment.PollinatorSize = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPrePollinatorSize")).SelectedValue); tempUserPayment.PollinatorType = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPrePollinatorType")).SelectedValue); tempUserPayment.PhotoUrl = ((TextBox)LoginView1.FindControl("txtPrePhotoUrl")).Text; tempUserPayment.YoutubeUrl = ((TextBox)LoginView1.FindControl("txtPreYoutubeUrl")).Text; tempUserPayment.Website = ((TextBox)LoginView1.FindControl("txtPreWebsite")).Text; tempUserPayment.Description = ((TextBox)LoginView1.FindControl("txtPreDescription")).Text; tempUserPayment.BillingAddress = ((TextBox)LoginView1.FindControl("txtPreBillingAddress")).Text; tempUserPayment.BillingCity = ((TextBox)LoginView1.FindControl("txtPreBillingCity")).Text; tempUserPayment.BillingState = ((TextBox)LoginView1.FindControl("txtPreBillingState")).Text; tempUserPayment.BillingZipcode = ((TextBox)LoginView1.FindControl("txtPreBillingZipcode")).Text; //save lat, long tempUserPayment.Latitude = decimal.Parse(hdnLat.Value); tempUserPayment.Longitude = decimal.Parse(hdnLng.Value); //save to TempUserPayments table mydb.TempUserPayments.Add(tempUserPayment); mydb.SaveChanges(); progress = 2;//set progress to step 2 //Payment: send request to Paypal //CreateUserWizard2.Visible = false; if (tempUserPayment != null) { //create cookie password string cookieSubName = HttpUtility.HtmlEncode(newUserId.ToString()+"pw"); string cookieSubValue = HttpUtility.HtmlEncode(password); Response.Cookies[newUserId.ToString()][cookieSubName] = cookieSubValue; Response.Cookies[newUserId.ToString()].Expires = DateTime.Now.AddHours(1); // get business account email from config string PaypalEmail = ConfigurationManager.AppSettings["PaypalSeller"]; //get payer email that user's email string PayerEmail = tempUserPayment.Email; // get variable environment from config bool SandboxEnvi = bool.Parse(ConfigurationManager.AppSettings["SandboxEnvironment"]); // get price from config string PaypalPrice = ConfigurationManager.AppSettings["PaypalPrice"]; // Callback url to handle process when payement is successful string ReturnUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/ShareMap?payer=" + newUserId; // Callback url to handle process when IPN Paypal service notify string NotifyUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/HandlerIPN.ashx"; // Callback url to handle process when payment is cancel string CancelUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/ShareMap?payc=" + newUserId; //name of product string PaypalItemName = ConfigurationManager.AppSettings["PaypalItemName"]; //custom parram contain temp information of New User string custom = newUserId + ";" + password + ";add";//CreateUserWizard2.ContinueDestinationPageUrl; //for case test demo link included in a frame of client's domain string backUrl = ConfigurationManager.AppSettings["BackUrl"]+"?Step=12"; if (!String.IsNullOrEmpty(backUrl)) ReturnUrl += "&backUrl=" + backUrl; // generate a html form paypal IPN string string PaypalFormHtmlStr = "<form target='_parent' name='_xclick' action='" + ((SandboxEnvi) ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr") + "' method='post'>" + "<input type='hidden' name='cmd' value='_xclick'>" + "<input type='hidden' name='business' value='" + PaypalEmail + "'>" + "<input type='hidden' name='payer_email' value='" + PayerEmail + "'>" + "<input type='hidden' name='currency_code' value='USD'>" + "<input type='hidden' name='item_name' value='" + PaypalItemName + "'>" + "<input type='hidden' name='amount' value='" + PaypalPrice + "'>" + "<input type='hidden' name='custom' value='" + custom + "' />" + "<input type='hidden' name='return' value='" + ReturnUrl + "'>" + "<input type='hidden' name='notify_url' value='" + NotifyUrl + "'>" + "<input type='hidden' name='cancel_url' value='" + CancelUrl + "'>" + "<input type='image' id='paypal_btn' src='' border='0' name='submit' alt=''> </form>"; ScriptManager.RegisterStartupScript(this, this.GetType(), "paypal", "document.getElementById('paypal_container').innerHTML = \"" + PaypalFormHtmlStr + "\" ; document.getElementById('paypal_btn').click() ;", true); } //show process bar ScriptManager.RegisterStartupScript(this, this.GetType(), "popupWait", "document.getElementById('showProcessbar').click();", true); } catch (Exception ex) { //rollback if (progress == 1)//have just created User System.Web.Security.Membership.DeleteUser(userName, true); //show error message lblPreErrorMessage.Text = ex.Message; //write log Pollinator.Common.Logger.Error("Occured in function: " + typeof(Account_Register).Name + ".CreateUserWizard2_CreatedUser()", ex); //Response.Redirect("~/Default"); } }
private void SetValueToControlPremium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) { //txtUserName.Text = usr.UserName; txtEmail.Text = usr.Email; } //Table 1 :user detail //HiddenPremiumLevel.Value = userDetail.MembershipLevel.ToString(); txtFirstName.Text = userDetail.FirstName; txtLastName.Text = userDetail.LastName; txtPhoneNumber.Text = userDetail.PhoneNumber; txtOrganizationName.Text = userDetail.OrganizationName; //Table 2: polinatorInformation txtOrganizationName.Text = polinatorInformation.OrganizationName; txtLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtLandscapeCity.Text = polinatorInformation.LandscapeCity; txtLandscapeState.Text = polinatorInformation.LandscapeState; txtLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; txtPhotoUrl.Text = polinatorInformation.PhotoUrl; txtYoutubeUrl.Text = polinatorInformation.YoutubeUrl; //premium info txtWebsite.Text = polinatorInformation.Website; try { BindPollinatorSize(ddlPollinatorSize); ddlPollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); } catch (Exception) { } try { BindPollinatorType(ddlPollinatorType); ddlPollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); } catch (Exception){} txtDescription.Text = polinatorInformation.Description; txtBillingAddress.Text = polinatorInformation.BillingAddress; txtBillingCity.Text = polinatorInformation.BillingCity; txtBillingState.Text = polinatorInformation.BillingState; txtBillingZipcode.Text = polinatorInformation.BillingZipcode; txtPaymentFullName.Text = polinatorInformation.PaymentFullName; txtPaymentAddress.Text = polinatorInformation.PaymentAddress; txtPaymentState.Text = polinatorInformation.PaymentState; txtPaymentCardNumber.Text = polinatorInformation.PaymentCardNumber; string photoUrl = Utility.ValidateImage(polinatorInformation.PhotoUrl); imgPhotoP.ImageUrl = photoUrl; //if (String.IsNullOrEmpty(photoUrl)) // imgPhoto.Visible = false; }
private void GetValueFromControlNormal(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) usr.Email = txtEmail.Text; //Table 1 :user detail userDetail.FirstName = txtFirstName.Text; userDetail.LastName = txtLastName.Text; userDetail.PhoneNumber = txtPhoneNumber.Text; polinatorInformation.PollinatorType = Int32.Parse(drPollinatorType.SelectedValue); //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtOrganizationName.Text; polinatorInformation.PollinatorSize = Int32.Parse(drPollinatorSize.SelectedValue); polinatorInformation.LandscapeStreet = txtLandscapeStreet.Text; polinatorInformation.LandscapeCity = txtLandscapeCity.Text; polinatorInformation.LandscapeState = txtLandscapeState.Text; polinatorInformation.LandscapeZipcode = txtLandscapeZipcode.Text; polinatorInformation.LandscapeCountry = drCountry.SelectedValue; polinatorInformation.PhotoUrl = txtPhotoUrl.Text; polinatorInformation.YoutubeUrl = txtYoutubeUrl.Text; }
protected void btnPreUpdate_Click(object sender, EventArgs e) { int progress = 0; string userName = string.Empty; UserDetail userDetail = new UserDetail(); PolinatorInformation polinatorInformation = new PolinatorInformation(); Label lblPreErrorMessage = ((Label)LoginView1.FindControl("lblPreErrorMessage")); lblPreErrorMessage.Text = ""; try { //Create new User userName = ((TextBox)LoginView1.FindControl("txtPreUserName")).Text; string password = ((TextBox)LoginView1.FindControl("txtPrePassword")).Text; string email = ((TextBox)LoginView1.FindControl("txtPreEmail")).Text; string passwordQuestion = "Q?"; string passwordAnswer = "A"; bool isApproved = true; MembershipCreateStatus status; //auto gen UserName, Password if client not input UserName,Password if (string.IsNullOrEmpty(userName)) { userName = Utility.CreateRandomUserName(0); } if (string.IsNullOrEmpty(password)) { password = Utility.CreateRandomPassword(10); } //Exec create System.Web.Security.Membership.CreateUser(userName, password, email, passwordQuestion, passwordAnswer, isApproved, out status); //status if (status == MembershipCreateStatus.Success) { progress = 1; } else { lblPreErrorMessage.Text = GetErrorMessage(status); return; } // Get the UserId of the just-added user MembershipUser newUser = System.Web.Security.Membership.GetUser(userName); Guid newUserId = (Guid)newUser.ProviderUserKey; //add new Usser to Members role if (!Roles.RoleExists(roleMembersName)) { Roles.CreateRole(roleMembersName); } Roles.AddUserToRole(userName, roleMembersName); //add info into UserDetail table var tempUserPaymentOld = (from tempUP in mydb.TempUserPayments where tempUP.UserId == newUserId select tempUP).FirstOrDefault(); if (tempUserPaymentOld != null) { mydb.TempUserPayments.Remove(tempUserPaymentOld); } TempUserPayment tempUserPayment = new TempUserPayment(); tempUserPayment.UserId = newUserId; tempUserPayment.Email = newUser.Email; //userDetail.MembershipLevel(have 2 levels): 0 is free; 1 is premium tempUserPayment.MembershipLevel = 1;//Premium tempUserPayment.FirstName = ((TextBox)LoginView1.FindControl("txtPreFirstName")).Text; tempUserPayment.LastName = ((TextBox)LoginView1.FindControl("txtPreLastName")).Text; tempUserPayment.PhoneNumber = ((TextBox)LoginView1.FindControl("txtPrePhoneNumber")).Text; //table2: UserDetail //PolinatorInformation polinatorInformation = new PolinatorInformation(); //polinatorInformation.UserId = newUserId; tempUserPayment.OrganizationName = ((TextBox)LoginView1.FindControl("txtPreOrganizationName")).Text; tempUserPayment.LandscapeStreet = ((TextBox)LoginView1.FindControl("txtPreLandscapeStreet")).Text; tempUserPayment.LandscapeCity = ((TextBox)LoginView1.FindControl("txtPreLandscapeCity")).Text; tempUserPayment.LandscapeState = ((TextBox)LoginView1.FindControl("txtPreLandscapeState")).Text; tempUserPayment.LandscapeZipcode = ((TextBox)LoginView1.FindControl("txtPreLandscapeZipcode")).Text; //country tempUserPayment.LandscapeCountry = ((DropDownList)LoginView1.FindControl("ddlPreCountry")).SelectedValue; //size, type tempUserPayment.PollinatorSize = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPrePollinatorSize")).SelectedValue); tempUserPayment.PollinatorType = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPrePollinatorType")).SelectedValue); tempUserPayment.PhotoUrl = ((TextBox)LoginView1.FindControl("txtPrePhotoUrl")).Text; tempUserPayment.YoutubeUrl = ((TextBox)LoginView1.FindControl("txtPreYoutubeUrl")).Text; tempUserPayment.Website = ((TextBox)LoginView1.FindControl("txtPreWebsite")).Text; tempUserPayment.Description = ((TextBox)LoginView1.FindControl("txtPreDescription")).Text; tempUserPayment.BillingAddress = ((TextBox)LoginView1.FindControl("txtPreBillingAddress")).Text; tempUserPayment.BillingCity = ((TextBox)LoginView1.FindControl("txtPreBillingCity")).Text; tempUserPayment.BillingState = ((TextBox)LoginView1.FindControl("txtPreBillingState")).Text; tempUserPayment.BillingZipcode = ((TextBox)LoginView1.FindControl("txtPreBillingZipcode")).Text; //save lat, long tempUserPayment.Latitude = decimal.Parse(hdnLat.Value); tempUserPayment.Longitude = decimal.Parse(hdnLng.Value); //save to TempUserPayments table mydb.TempUserPayments.Add(tempUserPayment); mydb.SaveChanges(); progress = 2;//set progress to step 2 //Payment: send request to Paypal //CreateUserWizard2.Visible = false; if (tempUserPayment != null) { //create cookie password string cookieSubName = HttpUtility.HtmlEncode(newUserId.ToString() + "pw"); string cookieSubValue = HttpUtility.HtmlEncode(password); Response.Cookies[newUserId.ToString()][cookieSubName] = cookieSubValue; Response.Cookies[newUserId.ToString()].Expires = DateTime.Now.AddHours(1); // get business account email from config string PaypalEmail = ConfigurationManager.AppSettings["PaypalSeller"]; //get payer email that user's email string PayerEmail = tempUserPayment.Email; // get variable environment from config bool SandboxEnvi = bool.Parse(ConfigurationManager.AppSettings["SandboxEnvironment"]); // get price from config string PaypalPrice = ConfigurationManager.AppSettings["PaypalPrice"]; // Callback url to handle process when payement is successful string ReturnUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/ShareMap?payer=" + newUserId; // Callback url to handle process when IPN Paypal service notify string NotifyUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/HandlerIPN.ashx"; // Callback url to handle process when payment is cancel string CancelUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/ShareMap?payc=" + newUserId; //name of product string PaypalItemName = ConfigurationManager.AppSettings["PaypalItemName"]; //custom parram contain temp information of New User string custom = newUserId + ";" + password + ";add";//CreateUserWizard2.ContinueDestinationPageUrl; //for case test demo link included in a frame of client's domain string backUrl = ConfigurationManager.AppSettings["BackUrl"] + "?Step=12"; if (!String.IsNullOrEmpty(backUrl)) { ReturnUrl += "&backUrl=" + backUrl; } // generate a html form paypal IPN string string PaypalFormHtmlStr = "<form target='_parent' name='_xclick' action='" + ((SandboxEnvi) ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr") + "' method='post'>" + "<input type='hidden' name='cmd' value='_xclick'>" + "<input type='hidden' name='business' value='" + PaypalEmail + "'>" + "<input type='hidden' name='payer_email' value='" + PayerEmail + "'>" + "<input type='hidden' name='currency_code' value='USD'>" + "<input type='hidden' name='item_name' value='" + PaypalItemName + "'>" + "<input type='hidden' name='amount' value='" + PaypalPrice + "'>" + "<input type='hidden' name='custom' value='" + custom + "' />" + "<input type='hidden' name='return' value='" + ReturnUrl + "'>" + "<input type='hidden' name='notify_url' value='" + NotifyUrl + "'>" + "<input type='hidden' name='cancel_url' value='" + CancelUrl + "'>" + "<input type='image' id='paypal_btn' src='' border='0' name='submit' alt=''> </form>"; ScriptManager.RegisterStartupScript(this, this.GetType(), "paypal", "document.getElementById('paypal_container').innerHTML = \"" + PaypalFormHtmlStr + "\" ; document.getElementById('paypal_btn').click() ;", true); } //show process bar ScriptManager.RegisterStartupScript(this, this.GetType(), "popupWait", "document.getElementById('showProcessbar').click();", true); } catch (Exception ex) { //rollback if (progress == 1)//have just created User { System.Web.Security.Membership.DeleteUser(userName, true); } //show error message lblPreErrorMessage.Text = ex.Message; //write log Pollinator.Common.Logger.Error("Occured in function: " + typeof(Account_Register).Name + ".CreateUserWizard2_CreatedUser()", ex); //Response.Redirect("~/Default"); } }
private void GetValueFromControlPrenium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) usr.Email = txtEmailP.Text; //Table 1 :user detail userDetail.FirstName = txtFirstNameP.Text; userDetail.LastName = txtLastNameP.Text; userDetail.PhoneNumber = txtPhoneNumberP.Text; //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtOrganizationNameP.Text; polinatorInformation.PollinatorSize = Int32.Parse(drPollinatorSizeP.SelectedValue); polinatorInformation.LandscapeStreet = txtLandscapeStreetP.Text; polinatorInformation.LandscapeCity = txtLandscapeCityP.Text; polinatorInformation.LandscapeState = txtLandscapeStateP.Text; polinatorInformation.LandscapeZipcode = txtLandscapeZipcodeP.Text; polinatorInformation.LandscapeCountry = drCountryP.SelectedValue; polinatorInformation.PhotoUrl = txtPhotoUrlP.Text; polinatorInformation.YoutubeUrl = txtYoutubeUrlP.Text; //premium info polinatorInformation.Website = txtWebsiteP.Text; polinatorInformation.PollinatorType = Int32.Parse(drPollinatorTypeP.SelectedValue); polinatorInformation.Description = txtOrganizationDescriptionP.Text; polinatorInformation.BillingAddress = txtBillingAddress.Text; polinatorInformation.BillingCity = txtBillingCity.Text; polinatorInformation.BillingState = txtBillingState.Text; polinatorInformation.BillingZipcode = txtBillingZipcode.Text; }
private static void SetLalngByAddress(ImportExportFields writedata, PolinatorInformation polinatorInformation) { string physicalLocation; GoogleGeoCoder geoCoder = new GoogleGeoCoder(); bool getLocation = false; Address[] matchAddress = null; int numTry = 0; while (!getLocation && numTry < 5) { try { numTry++; physicalLocation = writedata.LandscapeStreet + " " + writedata.LandscapeZipcode + " " + writedata.LandscapeCity + " " + writedata.LandscapeState + " " + writedata.LandscapeCountry; matchAddress = geoCoder.GeoCode(physicalLocation).ToArray(); getLocation = true; break; } catch (Exception ex) { System.Threading.Thread.Sleep(2000); } } if (matchAddress != null && matchAddress.Length > 0) { polinatorInformation.Latitude = (decimal)matchAddress[0].Coordinates.Latitude; polinatorInformation.Longitude = (decimal)matchAddress[0].Coordinates.Longitude; if (matchAddress.Length > 1) polinatorInformation.FuzyLocation = true; } }
private void SetValueToControlNormal(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { divRowRegPremium.Visible = false; txtUserName.Text = UserName; if (usr != null) txtEmail.Text = usr.Email; //Table 1 :user detail txtFirstName.Text = userDetail.FirstName; txtLastName.Text = userDetail.LastName; txtPhoneNumber.Text = userDetail.PhoneNumber; //Table 2: polinatorInformation txtOrganizationName.Text = polinatorInformation.OrganizationName; BindPollinatorType(drPollinatorType); drPollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindPollinatorSize(drPollinatorSize); drPollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); txtLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtLandscapeCity.Text = polinatorInformation.LandscapeCity; txtLandscapeState.Text = polinatorInformation.LandscapeState; txtLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; BindCountry(drCountry); drCountry.SelectedValue = polinatorInformation.LandscapeCountry; txtYoutubeUrl.Text = polinatorInformation.YoutubeUrl; string photoUrl = Utility.ValidateImage(polinatorInformation.PhotoUrl); this.txtPhotoUrl.Text = photoUrl; imgPhoto.ImageUrl = photoUrl; if (!string.IsNullOrEmpty(photoUrl)) { this.linAddPhoto.InnerText = "Change photo"; this.dontDeletePreImage.Value = "1"; } }
protected void btnUpdate_Click(object sender, EventArgs e) { int progress = 0; string userName = string.Empty; UserDetail userDetail = new UserDetail(); PolinatorInformation polinatorInformation = new PolinatorInformation(); Label lblErrorMessage = ((Label)LoginView1.FindControl("lblErrorMessage")); lblErrorMessage.Text = ""; try { //Create new User //userName = ((TextBox)LoginView1.FindControl("txtUserName")).Text; //string password = ((TextBox)LoginView1.FindControl("txtPassword")).Text; string password = string.Empty; string email = ((TextBox)LoginView1.FindControl("txtEmail")).Text; string passwordQuestion = "Q?"; string passwordAnswer = "A"; bool isApproved = true; MembershipCreateStatus status; string messError = string.Empty; //auto gen UserName, Password if (string.IsNullOrEmpty(userName)) userName = Utility.CreateRandomUserName(0); if (string.IsNullOrEmpty(password)) password = Utility.CreateRandomPassword(10); //Exec create System.Web.Security.Membership.CreateUser(userName, password, email, passwordQuestion, passwordAnswer, isApproved, out status); //status if (status == MembershipCreateStatus.Success) progress = 1; else { lblErrorMessage.Text = GetErrorMessage(status); return; } // Get the UserId of the just-added user MembershipUser newUser = System.Web.Security.Membership.GetUser(userName); Guid newUserId = (Guid)newUser.ProviderUserKey; //add usser to Members role if (!Roles.RoleExists(roleMembersName)) Roles.CreateRole(roleMembersName); Roles.AddUserToRole(userName, roleMembersName); //Get Profile Data Entered by user in CUW control //table1: UserDetail userDetail.UserId = newUserId; userDetail.MembershipLevel = 0;//Normal userDetail.FirstName = ((TextBox)LoginView1.FindControl("txtFirstName")).Text; userDetail.LastName = ((TextBox)LoginView1.FindControl("txtLastName")).Text; userDetail.PhoneNumber = ((TextBox)LoginView1.FindControl("txtPhoneNumber")).Text; //table2: PolinatorInformation polinatorInformation.UserId = newUserId; polinatorInformation.ExpireDate = DateTime.Now.AddDays(30);//expire after 30 days //Pollinator Information polinatorInformation.OrganizationName = ((TextBox)LoginView1.FindControl("txtOrganizationName")).Text; polinatorInformation.LandscapeStreet = ((TextBox)LoginView1.FindControl("txtLandscapeStreet")).Text; polinatorInformation.LandscapeCity = ((TextBox)LoginView1.FindControl("txtLandscapeCity")).Text; polinatorInformation.LandscapeState = ((TextBox)LoginView1.FindControl("txtLandscapeState")).Text; polinatorInformation.LandscapeZipcode = ((TextBox)LoginView1.FindControl("txtLandscapeZipcode")).Text; //country polinatorInformation.LandscapeCountry = ((DropDownList)LoginView1.FindControl("ddlCountry")).SelectedValue; //size, type polinatorInformation.PollinatorSize = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPollinatorSize")).SelectedValue); polinatorInformation.PollinatorType = Int32.Parse(((DropDownList)LoginView1.FindControl("ddlPollinatorType")).SelectedValue); polinatorInformation.PhotoUrl = ((TextBox)LoginView1.FindControl("txtPhotoUrl")).Text; polinatorInformation.YoutubeUrl = ((TextBox)LoginView1.FindControl("txtYoutubeUrl")).Text; //save lat, long polinatorInformation.Latitude = decimal.Parse(hdnLat.Value); polinatorInformation.Longitude = decimal.Parse(hdnLng.Value); //update more 2 field, support PollinatorInfomation polinatorInformation.IsNew = true; polinatorInformation.LastUpdated = DateTime.Now; //save to 2 tables mydb.UserDetails.Add(userDetail); mydb.PolinatorInformations.Add(polinatorInformation); mydb.SaveChanges(); progress = 2;//set progress to step 2(added 2 tables) //set isApproved in Membership //newUser.IsApproved = true; //Membership.UpdateUser(newUser); //send mail default of aspnet SendRegisterEmailDefaultAspNet(newUser, userDetail, polinatorInformation, password); //Send emails asynchronously in background //SendRegisterEmail(userDetail, polinatorInformation); //Auto Approved AutoApproveSubmission(newUser, userDetail, polinatorInformation); progress = 3;//set progress to step 3(Approved) //Fixed bug: Auto sign in //if (System.Web.Security.Membership.ValidateUser(userName, password)) // FormsAuthentication.SetAuthCookie(userName, createPersistentCookie: false); //show popup string continueUrl = "~/Default"; if (!OpenAuth.IsLocalUrl(continueUrl)) continueUrl = "~/"; linkReturnToMap.NavigateUrl = continueUrl; ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); } catch (Exception ex) { //rollback if (progress == 1)//have just created User System.Web.Security.Membership.DeleteUser(userName, true); else if (progress == 2)//have created User, UserDetail, PollinatorInformation { System.Web.Security.Membership.DeleteUser(userName, true); if (userDetail.UserId != null) { mydb.UserDetails.Remove(userDetail); mydb.SaveChanges(); } if (polinatorInformation.UserId != null) { mydb.PolinatorInformations.Remove(polinatorInformation); mydb.SaveChanges(); } } //show error mess lblErrorMessage.Text = ex.Message; //write log Pollinator.Common.Logger.Error("Occured in function: " + typeof(Account_Register).Name + ".CreateUserWizard1_CreatedUser()", ex); //Response.Redirect("~/Default"); } }
private void WriteDB(List<ImportFields> listdata, string sourceData) { if (IS_WRITE_DB) { var csv = new StringBuilder(); var newLine = "FirstName,OrganizationName,Email,PollinatorSize,PollinatorType,LandscapeStreet,LandscapeCity,LandscapeState,LandscapeCountry,LandscapeZipcode,PhotoUrl,Latitude,Longitude,Premium,FuzyLocation,UserId" + Environment.NewLine; csv.Append(newLine); ImportFields writedata; UserDetail userDetail; PolinatorInformation polinatorInformation; Guid userId; int numRecord = listdata.Count; for (int i = 0; i < numRecord; i++) { writedata = listdata.ElementAt(i); /* if (writedata.PollinatorSize == 0) writedata.PollinatorSize = 1; if (writedata.PollinatorType == 0) writedata.PollinatorType = 1;*/ if (writedata.LandscapeZipcode.Length > 15) writedata.LandscapeZipcode = writedata.LandscapeZipcode.Substring(0, 15); userDetail = new UserDetail(); polinatorInformation = new PolinatorInformation(); if (string.IsNullOrEmpty(writedata.UserId)) { /* if (!string.IsNullOrEmpty(writedata.Email)) { string usename = writedata.FirstName + "Username"; string password = writedata.FirstName + "Password"; var usr = Membership.GetUser(usename); if (usr == null) { usr = Membership.CreateUser(usename, password, writedata.Email); // userId = (Guid)usr.ProviderUserKey; } userId = (Guid)usr.ProviderUserKey; } else*/ userId = Guid.NewGuid(); } else { userId = new Guid(writedata.UserId); } userDetail.UserId = userId; userDetail.FirstName = writedata.FirstName; userDetail.MembershipLevel = writedata.Premium; //Table 2: polinatorInformation polinatorInformation.UserId = userId; polinatorInformation.OrganizationName = writedata.OrganizationName; polinatorInformation.PollinatorSize = writedata.PollinatorSize; polinatorInformation.PollinatorType = writedata.PollinatorType; polinatorInformation.LandscapeStreet = writedata.LandscapeStreet; if (polinatorInformation.LandscapeStreet == null) polinatorInformation.LandscapeStreet = string.Empty; polinatorInformation.LandscapeCity = writedata.LandscapeCity; polinatorInformation.LandscapeState = writedata.LandscapeState; polinatorInformation.LandscapeZipcode = writedata.LandscapeZipcode; polinatorInformation.LandscapeCountry = writedata.LandscapeCountry; polinatorInformation.PhotoUrl = writedata.PhotoUrl; polinatorInformation.YoutubeUrl = writedata.YoutubeUrl; polinatorInformation.IsApproved = true; polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; polinatorInformation.FuzyLocation = writedata.FuzyLocation; if (writedata.Latitude.HasValue && writedata.Longitude.HasValue) { polinatorInformation.Latitude = (decimal)writedata.Latitude; polinatorInformation.Longitude = (decimal)writedata.Longitude; } else polinatorInformation.FuzyLocation = true; polinatorInformation.SourceData = sourceData; if (string.IsNullOrEmpty(writedata.UserId)) { //int RowId = objPollinatorDA.Insert(TABLE_ID, objPollinator); // polinatorInformation.RowId = RowId; writedata = listdata.ElementAt(i); newLine = string.Format("\"{0}\",\"{1}\",\"{2}\",\"{3}\",\"{4}\",\"{5}\",\"{6}\",\"{7}\",\"{8}\",\"{9}\",\"{10}\",\"{11}\",\"{12}\",\"{13}\",\"{14}\",\"{15}\",{16}", writedata.FirstName, writedata.OrganizationName, writedata.Email, writedata.PollinatorSize, writedata.PollinatorType, writedata.LandscapeStreet, writedata.LandscapeCity, writedata.LandscapeState, writedata.LandscapeCountry, writedata.LandscapeZipcode, writedata.PhotoUrl, writedata.Latitude, writedata.Longitude, writedata.Premium, writedata.FuzyLocation, userId, Environment.NewLine); csv.Append(newLine); } mydb.UserDetails.Add(userDetail); mydb.PolinatorInformations.Add(polinatorInformation); } string uploadFolder = System.Configuration.ConfigurationManager.AppSettings["FolderPath"]; string sDirPath = Request.PhysicalApplicationPath + uploadFolder; File.WriteAllText(sDirPath + @"\oldSystem_writeDBresult.csv", csv.ToString()); try { mydb.SaveChanges(); } catch (DbEntityValidationException e) { foreach (var eve in e.EntityValidationErrors) { Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); foreach (var ve in eve.ValidationErrors) { Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw; } } }
/// <summary> /// User Normal: load data from DB into controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void LoadDataToFormNormal(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { //divRowRegPremium.Visible = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='inline';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='none'; SetVariablesOfUploadControl('0');", true); HiddenMemberLevel.Value = "0"; txtNorUserName.Text = UserName; if (usr != null) { txtNorEmail.Text = usr.Email; } //Table 1 :user detail txtNorFirstName.Text = userDetail.FirstName; txtNorLastName.Text = userDetail.LastName; txtNorPhoneNumber.Text = userDetail.PhoneNumber; //Table 2: polinatorInformation // txtNorOrganizationName.Text = polinatorInformation.OrganizationName ; BindPollinatorSize(ddlNorPollinatorSize); ddlNorPollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); BindPollinatorType(ddlNorPollinatorType); ddlNorPollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindCountry(ddlNorCountry); ddlNorCountry.SelectedValue = polinatorInformation.LandscapeCountry.ToString(); //Pollinator Information txtNorOrganizationName.Text = polinatorInformation.OrganizationName; txtNorLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtNorLandscapeCity.Text = polinatorInformation.LandscapeCity; txtNorLandscapeState.Text = polinatorInformation.LandscapeState; txtNorLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; txtNorPhotoUrl.Text = polinatorInformation.PhotoUrl.Trim(); txtNorYoutubeUrl.Text = polinatorInformation.YoutubeUrl.Trim(); txtOrganizationDescription.Text = polinatorInformation.Description; //thumbnail //string photoUrl = ""; //try //{ // photoUrl = Utility.ValidateImage(polinatorInformation.PhotoUrl); //} //catch (Exception ex){} //if (!string.IsNullOrEmpty(photoUrl)) // imgPhoto.ImageUrl = photoUrl; SetPhoto(polinatorInformation); SetVideo(polinatorInformation); //load lat, lng, txtPosition hdnLat.Value = polinatorInformation.Latitude.ToString(); hdnLng.Value = polinatorInformation.Longitude.ToString(); txtPosition.Text = polinatorInformation.Latitude.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "showvideo", "displayVideoWithOutValidate('#" + txtNorYoutubeUrl.ClientID + "');", true); }
/// <summary> /// User Normal: collect data from controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void GetInfoFromFormNormal(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { // usr.UserName = txtUserNameP.Text; if (usr != null) usr.Email = txtNorEmail.Text; //Table 1 :user detail userDetail.MembershipLevel = 0;//Normal userDetail.FirstName = txtNorFirstName.Text.Trim(); userDetail.LastName = txtNorLastName.Text.Trim(); userDetail.PhoneNumber = txtNorPhoneNumber.Text.Trim(); //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtNorOrganizationName.Text.Trim(); polinatorInformation.PollinatorType = Int32.Parse(ddlNorPollinatorType.SelectedValue); polinatorInformation.PollinatorSize = Int32.Parse(ddlNorPollinatorSize.SelectedValue); polinatorInformation.LandscapeStreet = txtNorLandscapeStreet.Text.Trim(); polinatorInformation.LandscapeCity = txtNorLandscapeCity.Text.Trim(); polinatorInformation.LandscapeState = txtNorLandscapeState.Text.Trim(); polinatorInformation.LandscapeZipcode = txtNorLandscapeZipcode.Text.Trim(); polinatorInformation.LandscapeCountry = ddlNorCountry.SelectedValue.Trim(); polinatorInformation.PhotoUrl = txtNorPhotoUrl.Text.Trim(); polinatorInformation.YoutubeUrl = txtNorYoutubeUrl.Text.Trim(); //get lat, lng polinatorInformation.Latitude = decimal.Parse(hdnLat.Value); polinatorInformation.Longitude = decimal.Parse(hdnLng.Value); }
protected void btnUpdate_Click(object sender, EventArgs e) { try { byte memberLevel = byte.Parse(HiddenMemberLevel.Value); if (memberLevel == 1)//upgrade from Normal to Premium { //premium ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='none';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='inline';", true); } else //normal { ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='inline';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='none';", true); } //user MembershipUser usr = System.Web.Security.Membership.GetUser(UserID); var userDetail = GetUserDetail(); if (userDetail == null) { userDetail = new UserDetail(); } var polinatorInformation = GetPolinatorInformation(); if (polinatorInformation == null) { polinatorInformation = new PolinatorInformation(); } //status polinatorInformation.IsApproved = false;//reset IsApproved = 0 polinatorInformation.IsNew = false; polinatorInformation.LastUpdated = DateTime.Now; //get new values from form and set to object to update if (memberLevel == 1 && userDetail.MembershipLevel == 0)//upgrade from Normal to Premium { //add info into UserDetail table var tempUserPaymentOld = (from tempUP in mydb.TempUserPayments where tempUP.UserId == UserID select tempUP).FirstOrDefault(); if (tempUserPaymentOld != null) { mydb.TempUserPayments.Remove(tempUserPaymentOld); } TempUserPayment tempUserPayment = new TempUserPayment(); tempUserPayment.UserId = UserID; //membership(user) tempUserPayment.Email = txtPreEmail.Text; //userDetail.MembershipLevel(have 2 levels): 0 is free; 1 is premium tempUserPayment.MembershipLevel = 1;//Premium tempUserPayment.FirstName = txtPreFirstName.Text; tempUserPayment.LastName = txtPreLastName.Text; tempUserPayment.PhoneNumber = txtPrePhoneNumber.Text; //tempUserPayment.OrganizationName = txtPreOrganizationName.Text; //table2: UserDetail tempUserPayment.OrganizationName = txtPreOrganizationName.Text; tempUserPayment.PollinatorSize = Int32.Parse(ddlPrePollinatorSize.SelectedValue); tempUserPayment.PollinatorType = Int32.Parse(ddlPrePollinatorType.SelectedValue); tempUserPayment.LandscapeStreet = txtPreLandscapeStreet.Text; tempUserPayment.LandscapeCity = txtPreLandscapeCity.Text; tempUserPayment.LandscapeState = txtPreLandscapeState.Text; tempUserPayment.LandscapeZipcode = txtPreLandscapeZipcode.Text; tempUserPayment.LandscapeCountry = ddlPreCountry.SelectedValue; tempUserPayment.PhotoUrl = txtPrePhotoUrl.Text; tempUserPayment.YoutubeUrl = txtPreYoutubeUrl.Text; tempUserPayment.Website = txtPreWebsite.Text; tempUserPayment.Description = txtPreDescription.Text; tempUserPayment.BillingAddress = txtPreBillingAddress.Text; tempUserPayment.BillingCity = txtPreBillingCity.Text; tempUserPayment.BillingState = txtPreBillingState.Text;; tempUserPayment.BillingZipcode = txtPreBillingZipcode.Text; //save lat, long tempUserPayment.Latitude = decimal.Parse(hdnLat.Value); tempUserPayment.Longitude = decimal.Parse(hdnLng.Value); //save userfolder //if (!string.IsNullOrEmpty(tempUserPayment.PhotoUrl)) //{ // string filePath = tempUserPayment.PhotoUrl.Split(';')[0]; // if (!string.IsNullOrEmpty(filePath)) // { // int index1 = filePath.LastIndexOf('/'); // if (index1 > 0) // { // filePath = filePath.Substring(0, index1).Trim(); // index1 = filePath.LastIndexOf('/'); // if (index1 > 0) // filePath = filePath.Substring(index1+1, filePath.Length-index1).Trim(); // tempUserPayment.UserFolder = HttpUtility.HtmlDecode(filePath); // } // } //} //createProcess //tempUserPayment.CreateProcess = 1; //tempUserPayment.CreateDate = DateTime.Now; //save to TempUserPayments table mydb.TempUserPayments.Add(tempUserPayment); mydb.SaveChanges();//submit temp table //Payment: send request to Paypal if (tempUserPayment != null) { // get business account email from config string PaypalEmail = ConfigurationManager.AppSettings["PaypalSeller"]; // get variable environment from config bool SandboxEnvi = bool.Parse(ConfigurationManager.AppSettings["SandboxEnvironment"]); // get price from config string PaypalPrice = ConfigurationManager.AppSettings["PaypalPrice"]; // Callback url to handle process when payement is successful string ReturnUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/Members/Manage.aspx?payer=" + UserID; // Callback url to handle process when IPN Paypal service notify string NotifyUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/HandlerIPN.ashx"; // Callback url to handle process when payment is cancel string CancelUrl = "http://" + HttpContext.Current.Request["HTTP_HOST"] + "/Members/Manage.aspx?payc=" + UserID; //name of product string PaypalItemName = ConfigurationManager.AppSettings["PaypalItemName"]; //custom parram contain temp information of New User string custom = UserID + ";password;change";//CreateUserWizard2.ContinueDestinationPageUrl; //end custom //Pollinator.Common.Logger.Information("Paypal Manage 2 ReturnUrl= " + ReturnUrl); // generate a html form paypal IPN string string PaypalFormHtmlStr = "<form target='_parent' name='_xclick' action='" + ((SandboxEnvi) ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr") + "' method='post'>" + "<input type='hidden' name='cmd' value='_xclick'>" + "<input type='hidden' name='business' value='" + PaypalEmail + "'>" + "<input type='hidden' name='payer_email' value='" + PaypalEmail + "'>" + "<input type='hidden' name='currency_code' value='USD'>" + "<input type='hidden' name='item_name' value='" + PaypalItemName + "'>" + "<input type='hidden' name='amount' value='" + PaypalPrice + "'>" + "<input type='hidden' name='custom' value='" + custom + "' />" + "<input type='hidden' name='return' value='" + ReturnUrl + "'>" + "<input type='hidden' name='notify_url' value='" + NotifyUrl + "'>" + "<input type='hidden' name='cancel_url' value='" + CancelUrl + "'>" + "<input type='image' id='paypal_btn' src='' border='0' name='submit' alt=''> </form>"; //Pollinator.Common.Logger.Information("Paypal Manage 3 PaypalFormHtmlStr= " + PaypalFormHtmlStr); //payment //string ExternalPaymemtlUrl = ConfigurationManager.AppSettings["ExternalPaymemtlUrl"]; //if (!String.IsNullOrEmpty(ExternalPaymemtlUrl))//external payment //{ // tempUserPayment.PaypalFormHtmlStr = PaypalFormHtmlStr; // mydb.SaveChanges(); // //redirect to external paymemt page // ScriptManager.RegisterStartupScript(this, this.GetType(), "popupWaitxxxx", "document.getElementById('MainContent_HyperLink123').click();", true); // //string urlRedirect = string.Format("{0}?userID={1}", ExternalPaymemtlUrl, tempUserPayment.UserId); // //ScriptManager.RegisterStartupScript(this, this.GetType(), "redirect", " window.location.replace(\"" + urlRedirect + "\");", true); //} //else // ScriptManager.RegisterStartupScript(this, this.GetType(), "paypal", "document.getElementById('paypal_container').innerHTML = \"" + PaypalFormHtmlStr + "\" ; document.getElementById('paypal_btn').click() ;", true); ScriptManager.RegisterStartupScript(this, this.GetType(), "paypal", "document.getElementById('paypal_container').innerHTML = \"" + PaypalFormHtmlStr + "\" ; document.getElementById('paypal_btn').click() ;", true); } //show please wait... popup ScriptManager.RegisterStartupScript(this, this.GetType(), "popupWait", "document.getElementById('showProcessbar').click();", true); } else { if (memberLevel == 0) { GetInfoFromFormNormal(usr, userDetail, polinatorInformation); } else { GetInfoFromFormPrenium(usr, userDetail, polinatorInformation); } if (usr != null) { System.Web.Security.Membership.UpdateUser(usr); } mydb.SaveChanges();//submit changed to DB //Auto Approved AutoApproveSubmission(usr, userDetail, polinatorInformation); ScriptManager.RegisterStartupScript(this, this.GetType(), "popup", "document.getElementById('confirm_pop').click();", true); } //Response.Redirect("~/ShareMap.aspx"); } catch (Exception ex) { byte memberLevel = byte.Parse(HiddenMemberLevel.Value); if (memberLevel == 1)//upgrade from Normal to Premium { //premium ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='none';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='inline';", true); } else { //normal ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='inline';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='none';", true); } //Response.Write(ex.ToString()); Pollinator.Common.Logger.Error("Error occured at " + typeof(Members_Manage).Name + ".btnUpdate_Click()", ex); GoToAlertMessage(panelErrorMessage); } }
/// <summary> /// User Normal: load data from DB into controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void LoadDataToFormNormal(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { //divRowRegPremium.Visible = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='inline';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='none'; SetVariablesOfUploadControl('0');", true); HiddenMemberLevel.Value = "0"; txtNorUserName.Text = UserName; if (usr != null) txtNorEmail.Text = usr.Email; //Table 1 :user detail txtNorFirstName.Text = userDetail.FirstName; txtNorLastName.Text = userDetail.LastName; txtNorPhoneNumber.Text = userDetail.PhoneNumber; //Table 2: polinatorInformation // txtNorOrganizationName.Text = polinatorInformation.OrganizationName ; BindPollinatorSize(ddlNorPollinatorSize); ddlNorPollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); BindPollinatorType(ddlNorPollinatorType); ddlNorPollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindCountry(ddlNorCountry); ddlNorCountry.SelectedValue = polinatorInformation.LandscapeCountry.ToString(); //Pollinator Information txtNorOrganizationName.Text = polinatorInformation.OrganizationName; txtNorLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtNorLandscapeCity.Text = polinatorInformation.LandscapeCity; txtNorLandscapeState.Text = polinatorInformation.LandscapeState; txtNorLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; txtNorPhotoUrl.Text = polinatorInformation.PhotoUrl.Trim(); txtNorYoutubeUrl.Text = polinatorInformation.YoutubeUrl.Trim(); txtOrganizationDescription.Text = polinatorInformation.Description; //thumbnail //string photoUrl = ""; //try //{ // photoUrl = Utility.ValidateImage(polinatorInformation.PhotoUrl); //} //catch (Exception ex){} //if (!string.IsNullOrEmpty(photoUrl)) // imgPhoto.ImageUrl = photoUrl; SetPhoto(polinatorInformation); SetVideo(polinatorInformation); //load lat, lng, txtPosition hdnLat.Value = polinatorInformation.Latitude.ToString(); hdnLng.Value = polinatorInformation.Longitude.ToString(); txtPosition.Text = polinatorInformation.Latitude.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "showvideo", "displayVideoWithOutValidate('#" + txtNorYoutubeUrl.ClientID + "');", true); }
private void GetValueFromControlPrenium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { if (usr != null) { usr.Email = txtEmail.Text; } //Table 1 :user detail userDetail.MembershipLevel = 1;//premium userDetail.FirstName = txtFirstName.Text; userDetail.LastName = txtLastName.Text; userDetail.PhoneNumber = txtPhoneNumber.Text; userDetail.OrganizationName = txtOrganizationName.Text; //Table 2: polinatorInformation polinatorInformation.OrganizationName = txtOrganizationName.Text; polinatorInformation.PollinatorSize = Int32.Parse(ddlPollinatorSize.SelectedValue); polinatorInformation.LandscapeStreet = txtLandscapeStreet.Text; polinatorInformation.LandscapeCity = txtLandscapeCity.Text; polinatorInformation.LandscapeState = txtLandscapeState.Text; polinatorInformation.LandscapeZipcode = txtLandscapeZipcode.Text; polinatorInformation.PhotoUrl = txtPhotoUrl.Text; polinatorInformation.YoutubeUrl = txtYoutubeUrl.Text; //premium info polinatorInformation.Website = txtWebsite.Text; polinatorInformation.PollinatorType = Int32.Parse(ddlPollinatorType.SelectedValue); polinatorInformation.Description = txtDescription.Text; polinatorInformation.BillingAddress = txtBillingAddress.Text; polinatorInformation.BillingCity = txtBillingCity.Text; polinatorInformation.BillingState = txtBillingState.Text; polinatorInformation.BillingZipcode = txtBillingZipcode.Text; polinatorInformation.PaymentFullName = txtPaymentFullName.Text; polinatorInformation.PaymentAddress = txtPaymentAddress.Text; polinatorInformation.PaymentState = txtPaymentState.Text; polinatorInformation.PaymentCardNumber = txtPaymentCardNumber.Text; }
private void SetPhoto(PolinatorInformation polinatorInformation) { string photoUrls = string.Empty; if (polinatorInformation.PhotoUrl != null) photoUrls = polinatorInformation.PhotoUrl.Trim(); txtNorPhotoUrl.Text = photoUrls; txtPrePhotoUrl.Text = photoUrls; if (!string.IsNullOrEmpty(photoUrls)) { string[] arrPhoto = photoUrls.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); numPhoto.Text = String.Format("({0} {1})", arrPhoto.Length.ToString(), arrPhoto.Length > 1 ? "photos" : "photo"); numPhotoN.Text = String.Format("({0} {1})", arrPhoto.Length.ToString(), arrPhoto.Length > 1 ? "photos" : "photo"); var firstUrl = Utility.ValidateImage(arrPhoto[0].Trim()); imgPhoto.ImageUrl = firstUrl; if (string.IsNullOrEmpty(firstUrl)) { imgPhoto.Style["display"] = "none"; imgPhotoP.Style["display"] = "none"; } } else { numPhoto.Style["display"] = "none"; numPhotoN.Style["display"] = "none"; imgPhoto.Style["display"] = "none"; imgPhotoP.Style["display"] = "none"; } }
/// <summary> /// User Premium: load data from DB into controls on form /// </summary> /// <param name="usr"></param> /// <param name="userDetail"></param> /// <param name="polinatorInformation"></param> private void LoadDataToFormPremium(MembershipUser usr, UserDetail userDetail, PolinatorInformation polinatorInformation) { //divRowRegNormal.Visible = false; ScriptManager.RegisterStartupScript(this, this.GetType(), "js", "document.getElementById('" + divRowRegNormal.ClientID + "').style.display='none';" + "document.getElementById('" + divRowRegPremium.ClientID + "').style.display='inline'; SetVariablesOfUploadControl('1');", true); HiddenMemberLevel.Value = "1"; if (usr != null) { txtPreUserName.Text = usr.UserName; txtPreEmail.Text = usr.Email; } //Table 1 :user detail txtPreFirstName.Text = userDetail.FirstName; txtPreLastName.Text = userDetail.LastName; txtPrePhoneNumber.Text = userDetail.PhoneNumber; //txtPreOrganizationName.Text = userDetail.OrganizationName; //Table 2: polinatorInformation txtPreOrganizationName.Text = polinatorInformation.OrganizationName; txtPreLandscapeStreet.Text = polinatorInformation.LandscapeStreet; txtPreLandscapeCity.Text = polinatorInformation.LandscapeCity; txtPreLandscapeState.Text = polinatorInformation.LandscapeState; txtPreLandscapeZipcode.Text = polinatorInformation.LandscapeZipcode; //txtPrePhotoUrl.Text = polinatorInformation.PhotoUrl; //txtPreYoutubeUrl.Text = polinatorInformation.YoutubeUrl; //premium info txtPreWebsite.Text = polinatorInformation.Website; BindPollinatorSize(ddlPrePollinatorSize); ddlPrePollinatorSize.SelectedValue = polinatorInformation.PollinatorSize.ToString(); BindPollinatorType(ddlPrePollinatorType); ddlPrePollinatorType.SelectedValue = polinatorInformation.PollinatorType.ToString(); BindCountry(ddlPreCountry); ddlPreCountry.SelectedValue = polinatorInformation.LandscapeCountry.ToString(); txtPreDescription.Text = polinatorInformation.Description; txtPreBillingAddress.Text = polinatorInformation.BillingAddress; txtPreBillingCity.Text = polinatorInformation.BillingCity; txtPreBillingState.Text = polinatorInformation.BillingState; txtPreBillingZipcode.Text = polinatorInformation.BillingZipcode; //thumbnail string photoUrl = Utility.ValidateImage(polinatorInformation.PhotoUrl); imgPhotoP.ImageUrl = photoUrl; string photoUrls = string.Empty; if (polinatorInformation.PhotoUrl != null) photoUrls = polinatorInformation.PhotoUrl.Trim(); txtPrePhotoUrl.Text = photoUrls; if (!string.IsNullOrEmpty(photoUrls)) { string[] arrPhoto = photoUrls.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); numPhoto.Text = String.Format("({0} {1})", arrPhoto.Length.ToString(), arrPhoto.Length > 1 ? "photos" : "photo"); var firstUrl = Utility.ValidateImage(arrPhoto[0].Trim()); imgPhotoP.ImageUrl = firstUrl; if (string.IsNullOrEmpty(firstUrl)) { imgPhotoP.Style["display"] = "none"; } } else imgPhotoP.Style["display"] = "none"; string youtubeUrls = string.Empty; if (polinatorInformation.YoutubeUrl != null) youtubeUrls = polinatorInformation.YoutubeUrl.Trim(); txtPreYoutubeUrl.Text = youtubeUrls; if (!string.IsNullOrEmpty(youtubeUrls)) { string[] arrVideo = youtubeUrls.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); numVideo.Text = String.Format("({0} {1})", arrVideo.Length.ToString(), arrVideo.Length > 1 ? "videos": "video"); } else { numVideo.Style["display"] = "none"; } //load lat, lng, txtPosition hdnLat.Value = polinatorInformation.Latitude.ToString(); hdnLng.Value = polinatorInformation.Longitude.ToString(); txtPrePosition.Text = polinatorInformation.Latitude.ToString(); ScriptManager.RegisterStartupScript(this, this.GetType(), "showvideo", "displayVideoWithOutValidate('#" + txtPreYoutubeUrl.ClientID + "');", true); //txtPrePaymentFullName.Text = polinatorInformation.PaymentFullName; //txtPrePaymentAddress.Text = polinatorInformation.PaymentAddress; //txtPrePaymentState.Text = polinatorInformation.PaymentState; //txtPrePaymentCardNumber.Text = polinatorInformation.PaymentCardNumber; //string photoUrl = Utility.ValidateImage(polinatorInformation.PhotoUrl); //imgPhoto.ImageUrl = photoUrl; //if (String.IsNullOrEmpty(photoUrl)) // imgPhoto.Visible = false; }
private void SetVideo(PolinatorInformation polinatorInformation) { string youtubeUrls = string.Empty; if (polinatorInformation.YoutubeUrl != null) youtubeUrls = polinatorInformation.YoutubeUrl.Trim(); txtPreYoutubeUrl.Text = youtubeUrls; txtNorYoutubeUrl.Text = youtubeUrls; if (!string.IsNullOrEmpty(youtubeUrls)) { string[] arrVideo = youtubeUrls.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries); numVideo.Text = String.Format("({0} {1})", arrVideo.Length.ToString(), arrVideo.Length > 1 ? "videos" : "video"); numVideoN.Text = String.Format("({0} {1})", arrVideo.Length.ToString(), arrVideo.Length > 1 ? "videos" : "video"); } else { numVideo.Style["display"] = "none"; numVideoN.Style["display"] = "none"; } }
/// <summary> /// send email using default of aspnet /// </summary> /// <param name="usr"></param> /// <param name="userInfo"></param> /// <param name="pollinator"></param> private void SendRegisterEmailDefaultAspNet(MembershipUser usr, UserDetail userInfo, PolinatorInformation pollinator, string password) { if (usr == null) return; //get template String content = string.Empty; Uri uri = HttpContext.Current.Request.Url; string webAppUrl = uri.GetLeftPart(UriPartial.Authority); //Return both host and port String path = Request.PhysicalApplicationPath + "\\EmailTemplates\\RegisterEmail.html"; using (StreamReader reader = File.OpenText(path)) { content = reader.ReadToEnd(); // Load the content from your file... if (userInfo.MembershipLevel == 0) { content = content.Replace("<tr><td>User name:</td><td>{UserName}</td></tr>",""); content = content.Replace("<tr><td>Password:</td><td>{Password}</td></tr>",""); content = content.Replace(@"<a href=""{LogonLink}""><strong>Click Here to Log On</strong></a><br /><br />",""); } content = content.Replace("{RegisterName}", userInfo.FirstName); content = content.Replace("{UserName}", usr.UserName); content = content.Replace("{Password}", password); content = content.Replace("{UserType}", userInfo.MembershipLevel == 0 ? "NORMAL" : "PREMIUM"); content = content.Replace("{ShareMapUrl}", webAppUrl + "/ShareMap"); content = content.Replace("{OrganizationName}", pollinator.OrganizationName); content = content.Replace("{PhoneNumber}", userInfo.PhoneNumber); content = content.Replace("{LandscapeStreet}", pollinator.LandscapeStreet); content = content.Replace("{LandscapeCity}", pollinator.LandscapeCity); content = content.Replace("{LandscapeState}", pollinator.LandscapeState); content = content.Replace("{LandscapeZipcode}", pollinator.LandscapeZipcode); content = content.Replace("{PollinatorSize}", pollinator.PollinatorSize.ToString()); content = content.Replace("{PollinatorType}", pollinator.PollinatorType.ToString()); content = content.Replace("{LogonLink}", webAppUrl + "/ShareMap#login_form"); var webAppPath = WebHelper.FullyQualifiedApplicationPath; content = content.Replace("{SiteLogo}", webAppPath + WebHelper.SiteLogo); } //send for New User MailMessage myMail = new MailMessage(); myMail.From = new MailAddress(Utility.EmailConfiguration.WebMasterEmail, "Pollinator - Share Map"); myMail.To.Add(usr.Email); myMail.Subject = "Thank you for registering with S.H.A.R.E!"; myMail.IsBodyHtml = true; myMail.Body = content; SmtpClient smtp = new SmtpClient(); smtp.Send(myMail); //send reminder for Admin path = Request.PhysicalApplicationPath + "\\EmailTemplates\\RegisterEmailAdmin.html"; using (StreamReader reader = File.OpenText(path)) { content = reader.ReadToEnd(); // Load the content from your file... } foreach (var adminEmail in GetListAdmin()) { var adminName = adminEmail.Substring(0, adminEmail.IndexOf("@")); content = content.Replace("{AdminName}", adminName); content = content.Replace("{RegisterName}", userInfo.FirstName); content = content.Replace("{UserName}", usr.UserName); content = content.Replace("{UserType}", userInfo.MembershipLevel == 0 ? "NORMAL" : "PREMIUM"); content = content.Replace("{ShareMapUrl}", webAppUrl + "/ShareMap"); content = content.Replace("{OrganizationName}", pollinator.OrganizationName); content = content.Replace("{PhoneNumber}", userInfo.PhoneNumber); content = content.Replace("{LandscapeStreet}", pollinator.LandscapeStreet); content = content.Replace("{LandscapeCity}", pollinator.LandscapeCity); content = content.Replace("{LandscapeState}", pollinator.LandscapeState); content = content.Replace("{LandscapeZipcode}", pollinator.LandscapeZipcode); content = content.Replace("{PollinatorSize}", pollinator.PollinatorSize.ToString()); content = content.Replace("{PollinatorType}", pollinator.PollinatorType.ToString()); content = content.Replace("{LogonLink}", webAppUrl + "/ShareMap#login_form"); content = content.Replace("{PollinatorLink}", webAppUrl + "/Admin/PollinatorInformation?user="******"{UserListLink}", webAppUrl + "/Admin/Users"); var webAppPath = WebHelper.FullyQualifiedApplicationPath; content = content.Replace("{SiteLogo}", webAppPath + WebHelper.SiteLogo); //send for admin MailMessage myAdminMail = new MailMessage(); myAdminMail.From = new MailAddress(Utility.EmailConfiguration.WebMasterEmail, "Pollinator - Share Map"); myAdminMail.To.Add(adminEmail); myAdminMail.Subject = "New register on S.H.A.R.E!"; myAdminMail.IsBodyHtml = true; myAdminMail.Body = content; SmtpClient smtpAdmin = new SmtpClient(); smtpAdmin.Send(myAdminMail); } }
/// <summary> /// Final step, Import Data Into Database /// </summary> /// <param name="listRowImport">list needed import</param> /// <param name="actionForExistedData">3 option: skip, new, overwrite. default is null(new)</param> /// Create by: Hoai Phuong private void ImportDataIntoDatabase(List<ImportExportFields> listRowImport, string actionForExistedData = null) { //set status navigator bar: current active step = 3(import) SetStatusNavigationBar(3); //show please wait... popup //ScriptManager.RegisterStartupScript(this, this.GetType(), "popupWait", "document.getElementById('showProcessbar').click();", true); //lblErrorMess.Text = "Đang import vào sql db..."; divExistedData.Visible = false; memberLevel = MemberLevel; DateTime createdDate = DateTime.Now; ImportExportFields writedata; Membership userDB; UserDetail userDetail; PolinatorInformation polinatorInformation; Guid userId; int numImport = 0; int numSkipExist = 0; List<string> listAddUserName = new List<string>(); int numRecord = listRowImport.Count; for (int i = 0; i < numRecord; i++) { writedata = listRowImport.ElementAt(i); userDetail = new UserDetail(); polinatorInformation = new PolinatorInformation(); if (writedata.IsExistedData && actionForExistedData == "skip") { numSkipExist++; continue; } numImport++; if (!writedata.IsExistedData || actionForExistedData == "new") { if (!string.IsNullOrEmpty(writedata.Email)) { //generate new user //auto gen UserName, Password string userName = Utility.CreateRandomUserName(0); string password = Utility.CreateRandomPassword(10); listAddUserName.Add(userName); //Exec create userId = (Guid)System.Web.Security.Membership.CreateUser(userName, password, writedata.Email).ProviderUserKey; } else userId = Guid.NewGuid(); } else { //if (writedata.UserId != Guid.Empty) // userId = writedata.UserId; //else userId = writedata.ExistedUserId; if (!string.IsNullOrEmpty(writedata.Email)) { userDB = (from us in mydb.Memberships where us.UserId == userId select us).FirstOrDefault(); userDB.Email = writedata.Email; } userDetail = (from ud in mydb.UserDetails where ud.UserId == userId select ud).FirstOrDefault(); polinatorInformation = (from pi in mydb.PolinatorInformations where pi.UserId == userId select pi).FirstOrDefault(); } userDetail.UserId = userId; userDetail.FirstName = writedata.FirstName; userDetail.LastName = writedata.LastName; userDetail.MembershipLevel = memberLevel; userDetail.PhoneNumber = writedata.PhoneNumber; //Table 2: polinatorInformation polinatorInformation.UserId = userId; polinatorInformation.OrganizationName = writedata.OrganizationName; polinatorInformation.Description = writedata.OrganizationDescription; polinatorInformation.PollinatorSize = writedata.PollinatorSize; polinatorInformation.PollinatorType = writedata.PollinatorType; polinatorInformation.LandscapeStreet = writedata.LandscapeStreet; polinatorInformation.LandscapeCity = writedata.LandscapeCity; polinatorInformation.LandscapeState = writedata.LandscapeState; polinatorInformation.LandscapeZipcode = writedata.LandscapeZipcode; polinatorInformation.LandscapeCountry = writedata.LandscapeCountry; polinatorInformation.Website = writedata.Website; polinatorInformation.IsApproved = true; polinatorInformation.IsNew = false; polinatorInformation.CreatedDate = createdDate; polinatorInformation.LastUpdated = createdDate; if (writedata.Latitude.HasValue && writedata.Longitude.HasValue) { polinatorInformation.Latitude = (decimal)writedata.Latitude; polinatorInformation.Longitude = (decimal)writedata.Longitude; } else { SetLalngByAddress(writedata, polinatorInformation); } polinatorInformation.SourceData = sourceData; if (!writedata.IsExistedData || actionForExistedData == "new") { mydb.UserDetails.Add(userDetail); mydb.PolinatorInformations.Add(polinatorInformation); } } try { mydb.SaveChanges(); //show successfully panel lblMess.Visible = false; this.divImportSuccessful.Visible = true; this.lblTotalDataRecord.Text = TotalRecord.ToString(); this.lblNumImported.Text = numImport.ToString(); this.lblNumNotImported.Text = (TotalInvalidRecord + numSkipExist).ToString(); this.lblNumInvalid.Text = TotalInvalidRecord.ToString(); this.lblNumSkipExist.Text = numSkipExist.ToString(); //show/hide link download log file if (TotalInvalidRecord == 0) lnkFinishInvalidLog.Visible = false; else lnkFinishInvalidLog.Visible = true; if (numSkipExist == 0) lnkFinishSkipLog.Visible = false; else lnkFinishSkipLog.Visible = true; //Write log var logContent = new StringBuilder(); logContent.Append(string.Format("Total data records: {0}{1}", TotalRecord.ToString(), Environment.NewLine)); logContent.Append(string.Format("Records imported: {0}{1}", numImport.ToString(), Environment.NewLine)); logContent.Append(string.Format("Records ignored: {0}{1}", (TotalInvalidRecord + numSkipExist).ToString(), Environment.NewLine)); logContent.Append(string.Format(" - Invalid records: {0}{1}", TotalInvalidRecord.ToString(), Environment.NewLine)); logContent.Append(string.Format(" - Manually skipped: {0}{1}", numSkipExist.ToString(), Environment.NewLine)); string fileName = "ImportSuccessful" + System.DateTime.Now.ToString("_yyMMdd_hhmm") + ".txt"; ImportExportUltility.WriteFile(Request, fileName, logContent.ToString()); //set status navigator bar: current active step = 3(Finish) SetStatusNavigationBar(4); } catch (Exception e) { //Delete added udername try { for (int i = 0; i < listAddUserName.Count; i++) { System.Web.Security.Membership.DeleteUser(listAddUserName[i]); } } catch { } //Write log fie WriteImportFailLog(e); SetStatusNavigationBar(4); //show error panel this.divImportFail.Visible = true; } }
/// <summary> /// send email using default of aspnet /// </summary> /// <param name="usr"></param> /// <param name="userInfo"></param> /// <param name="pollinator"></param> private void SendRegisterEmailDefaultAspNet(MembershipUser usr, UserDetail userInfo, PolinatorInformation pollinator, string password) { if (usr == null) { return; } //get template String content = string.Empty; Uri uri = HttpContext.Current.Request.Url; string webAppUrl = uri.GetLeftPart(UriPartial.Authority); //Return both host and port String path = Request.PhysicalApplicationPath + "\\EmailTemplates\\RegisterEmail.html"; using (StreamReader reader = File.OpenText(path)) { content = reader.ReadToEnd(); // Load the content from your file... if (userInfo.MembershipLevel == 0) { content = content.Replace("<tr><td>User name:</td><td>{UserName}</td></tr>", ""); content = content.Replace("<tr><td>Password:</td><td>{Password}</td></tr>", ""); content = content.Replace(@"<a href=""{LogonLink}""><strong>Click Here to Log On</strong></a><br /><br />", ""); } content = content.Replace("{RegisterName}", userInfo.FirstName); content = content.Replace("{UserName}", usr.UserName); content = content.Replace("{Password}", password); content = content.Replace("{UserType}", userInfo.MembershipLevel == 0 ? "NORMAL" : "PREMIUM"); content = content.Replace("{ShareMapUrl}", webAppUrl + "/ShareMap"); content = content.Replace("{OrganizationName}", pollinator.OrganizationName); content = content.Replace("{PhoneNumber}", userInfo.PhoneNumber); content = content.Replace("{LandscapeStreet}", pollinator.LandscapeStreet); content = content.Replace("{LandscapeCity}", pollinator.LandscapeCity); content = content.Replace("{LandscapeState}", pollinator.LandscapeState); content = content.Replace("{LandscapeZipcode}", pollinator.LandscapeZipcode); content = content.Replace("{PollinatorSize}", pollinator.PollinatorSize.ToString()); content = content.Replace("{PollinatorType}", pollinator.PollinatorType.ToString()); content = content.Replace("{LogonLink}", webAppUrl + "/ShareMap#login_form"); var webAppPath = WebHelper.FullyQualifiedApplicationPath; content = content.Replace("{SiteLogo}", webAppPath + WebHelper.SiteLogo); } //send for New User MailMessage myMail = new MailMessage(); myMail.From = new MailAddress(Utility.EmailConfiguration.WebMasterEmail, "Pollinator - Share Map"); myMail.To.Add(usr.Email); myMail.Subject = "Thank you for registering with S.H.A.R.E!"; myMail.IsBodyHtml = true; myMail.Body = content; SmtpClient smtp = new SmtpClient(); smtp.Send(myMail); //send reminder for Admin path = Request.PhysicalApplicationPath + "\\EmailTemplates\\RegisterEmailAdmin.html"; using (StreamReader reader = File.OpenText(path)) { content = reader.ReadToEnd(); // Load the content from your file... } foreach (var adminEmail in GetListAdmin()) { var adminName = adminEmail.Substring(0, adminEmail.IndexOf("@")); content = content.Replace("{AdminName}", adminName); content = content.Replace("{RegisterName}", userInfo.FirstName); content = content.Replace("{UserName}", usr.UserName); content = content.Replace("{UserType}", userInfo.MembershipLevel == 0 ? "NORMAL" : "PREMIUM"); content = content.Replace("{ShareMapUrl}", webAppUrl + "/ShareMap"); content = content.Replace("{OrganizationName}", pollinator.OrganizationName); content = content.Replace("{PhoneNumber}", userInfo.PhoneNumber); content = content.Replace("{LandscapeStreet}", pollinator.LandscapeStreet); content = content.Replace("{LandscapeCity}", pollinator.LandscapeCity); content = content.Replace("{LandscapeState}", pollinator.LandscapeState); content = content.Replace("{LandscapeZipcode}", pollinator.LandscapeZipcode); content = content.Replace("{PollinatorSize}", pollinator.PollinatorSize.ToString()); content = content.Replace("{PollinatorType}", pollinator.PollinatorType.ToString()); content = content.Replace("{LogonLink}", webAppUrl + "/ShareMap#login_form"); content = content.Replace("{PollinatorLink}", webAppUrl + "/Admin/PollinatorInformation?user="******"{UserListLink}", webAppUrl + "/Admin/Users"); var webAppPath = WebHelper.FullyQualifiedApplicationPath; content = content.Replace("{SiteLogo}", webAppPath + WebHelper.SiteLogo); //send for admin MailMessage myAdminMail = new MailMessage(); myAdminMail.From = new MailAddress(Utility.EmailConfiguration.WebMasterEmail, "Pollinator - Share Map"); myAdminMail.To.Add(adminEmail); myAdminMail.Subject = "New register on S.H.A.R.E!"; myAdminMail.IsBodyHtml = true; myAdminMail.Body = content; SmtpClient smtpAdmin = new SmtpClient(); smtpAdmin.Send(myAdminMail); } }