protected void DisplayEconomicImportance(object sender, EventArgs e) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { int cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_use_id) from taxonomy_use where economic_usage_code not in ('CPC','FWT','FWE')"), 0); econcnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(distinct taxonomy_species_id) from taxonomy_use where economic_usage_code not in ('CPC','FWT','FWE')"), 0); taxeconcnt = string.Format("{0:n0}", cnt1); } } pnlIndex.Visible = false; pnlSumm.Visible = false; pnlIntro.Visible = false; pnlHist.Visible = false; pnlScope.Visible = false; pnlScient.Visible = false; pnlCommon.Visible = false; pnlEcon.Visible = true; pnlDistrib.Visible = false; pnlLiter.Visible = false; pnlSpec.Visible = false; pnlBasis.Visible = false; pnlConcl.Visible = false; pnlAcknowl.Visible = false; pnlRefer.Visible = false; pnlSymb.Visible = false; }
protected void DisplayDistribution(object sender, EventArgs e) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { int cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_geography_map_id) from taxonomy_geography_map"), 0); distcnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(distinct taxonomy_species_id) from taxonomy_geography_map"), 0); taxdistcnt = string.Format("{0:n0}", cnt1); } } pnlIndex.Visible = false; pnlSumm.Visible = false; pnlIntro.Visible = false; pnlHist.Visible = false; pnlScope.Visible = false; pnlScient.Visible = false; pnlCommon.Visible = false; pnlEcon.Visible = false; pnlDistrib.Visible = true; pnlLiter.Visible = false; pnlSpec.Visible = false; pnlBasis.Visible = false; pnlConcl.Visible = false; pnlAcknowl.Visible = false; pnlRefer.Visible = false; pnlSymb.Visible = false; }
protected void DisplayScope(object sender, EventArgs e) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { int cnt = Toolkit.ToInt32(dm.ReadValue(@" select count(distinct a.taxonomy_species_id) from accession a join cooperator c on a.owned_by = c.cooperator_id join site s on c.site_id = s.site_id where s.site_short_name not in ('INACTIVE','NSSB')"), 0); acctaxcnt = string.Format("{0:n0}", cnt); } } pnlIndex.Visible = false; pnlSumm.Visible = false; pnlIntro.Visible = false; pnlHist.Visible = false; pnlScope.Visible = true; pnlScient.Visible = false; pnlCommon.Visible = false; pnlEcon.Visible = false; pnlDistrib.Visible = false; pnlLiter.Visible = false; pnlSpec.Visible = false; pnlBasis.Visible = false; pnlConcl.Visible = false; pnlAcknowl.Visible = false; pnlRefer.Visible = false; pnlSymb.Visible = false; }
private void bindCitation(int id) { pnlLiterature.Visible = false; using (SecureData sd = UserManager.GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { DataTable dt = dm.Read(@" select c.*, l.abbreviation from citation c left join literature l on c.literature_id = l.literature_id where citation_id = :cid", new DataParameters(":cid", id)); if (dt.Rows.Count > 0) { pnlCitation.Visible = true; DataRow dr = dt.Rows[0]; lblCitation.Text = dr["author_name"] + "<br />" + dr["citation_title"] + "<br />" + dr["abbreviation"] + " " + dr["reference"] + " " + dr["citation_year"] + "<br />"; } rptCitation.DataSource = sd.GetData("web_crop_citation_accession", ":citationid=" + id, 0, 0).Tables["web_crop_citation_accession"]; rptCitation.DataBind(); } } }
private void bindData3(int traitID, string value) { DataTable dt = null; using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { string traitName = dm.ReadValue(@"select coded_name from crop_trait where crop_trait_id = :ctid", new DataParameters(":ctid", traitID, DbType.Int32)).ToString(); string cropName = dm.ReadValue(@"select name from crop where crop_id = (select crop_id from crop_trait where crop_trait_id = :ctid)", new DataParameters(":ctid", traitID, DbType.Int32)).ToString(); if (traitName != "") { var low = value.Split(';')[0]; var up = value.Split(';')[1]; lblDesc.Text = cropName + " accessions with values between " + low + " and " + up + " for descriptor " + traitName; dt = sd.GetData("web_descriptor_value_accession3", ":traitid=" + traitID + ";:low=" + low + ";:up=" + up, 0, 0).Tables["web_descriptor_value_accession3"]; gvAccession.DataSource = dt; gvAccession.DataBind(); } } } }
private void bindData1(int traitID, int codeID) { DataTable dt = null; using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { string traitName = dm.ReadValue(@"select coded_name from crop_trait where crop_trait_id = :ctid", new DataParameters(":ctid", traitID, DbType.Int32)).ToString(); string cropName = dm.ReadValue(@"select name from crop where crop_id = (select crop_id from crop_trait where crop_trait_id = :ctid)", new DataParameters(":ctid", traitID, DbType.Int32)).ToString(); string codeValue = dm.ReadValue(@"select code from crop_trait_code where crop_trait_code_id = :ctcid", new DataParameters(":ctcid", codeID, DbType.Int32)).ToString(); string codeDesc = dm.ReadValue(@"select description from crop_trait_code_lang where crop_trait_code_id = :ctcid and sys_lang_id = :langid", new DataParameters(":ctcid", codeID, DbType.Int32, ":langid", sd.LanguageID, DbType.Int32)).ToString(); if (traitName != "") { lblDesc.Text = cropName + " accessions with code " + codeValue + " (" + codeDesc + ") for descriptor " + traitName; dt = sd.GetData("web_descriptor_value_accession1", ":traitid=" + traitID + ";:codeid=" + codeID, 0, 0).Tables["web_descriptor_value_accession1"]; gvAccession.DataSource = dt; gvAccession.DataBind(); } } } }
private void bindData(int traitID, int methodID) { DataTable dt = null; using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { traitName = dm.ReadValue(@"select coded_name from crop_trait where crop_trait_id = :ctid", new DataParameters(":ctid", traitID, DbType.Int32)).ToString(); methodName = dm.ReadValue(@"select name from method where method_id = :mid", new DataParameters(":mid", methodID, DbType.Int32)).ToString(); if (methodName != "" & traitName != "") { lblDesc.Text = traitName + " in study " + methodName; dt = sd.GetData("web_method_descriptor_accession", ":traitid=" + traitID + ";:methodid=" + methodID, 0, 0).Tables["web_method_descriptor_accession"]; gvAccession.DataSource = dt; gvAccession.DataBind(); dt = sd.GetData("web_descriptor_detail_download", ":traitid=" + traitID + ";:methodid=" + methodID, 0, 0).Tables["web_descriptor_detail_download"]; gvAccession2.DataSource = dt; gvAccession2.DataBind(); } } } }
public static string GetAccessionIds(string sql) { string s = ""; using (SecureData sd = GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { DataTable dtID = dm.Read(sql); List <string> IDs = new List <string>(); if (dtID != null) { foreach (DataRow dr in dtID.Rows) { IDs.Add(dr[0].ToString()); } if (IDs.Count > 0) { s = " @accession.accession_id in (" + String.Join(",", IDs.ToArray()) + ")"; } } } } return(s); }
private static void checkExpiredPassword(string webUserName, string loginToken, HttpContext ctx) { int days = Toolkit.GetSetting("PasswordExpireDays", 0); if (days > 0) { using (SecureData sd = new SecureData(true, loginToken, null)) { using (DataManager dm = sd.BeginProcessing(true, true)) { string lastModified = (dm.ReadValue(@"select modified_date from web_user where user_name = :username ", new DataParameters(":username", webUserName, DbType.String))).ToString(); if (lastModified == "") // level 1 user { lastModified = (dm.ReadValue(@"select created_date from web_user where user_name = :username ", new DataParameters(":username", webUserName, DbType.String))).ToString(); } if (lastModified != "") { DateTime date = Toolkit.ToDateTime(lastModified); DateTime currentDate = DateTime.UtcNow; if ((currentDate - date).Days > days) { ctx.Response.Clear(); ctx.Response.Redirect("~/userAcct.aspx?action=expirePwd"); ctx.Response.End(); } } } } } }
private void bindAccessionPIBook(int id) { try { using (var sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { // Only US NPGS would have the value and continue processing string acp = dm.ReadValue(@"select accession_number_part1 from accession where accession_id = :aid", new DataParameters(":aid", id, DbType.Int32)).ToString(); if (acp.Trim() == "PI") { //string cnt = dm.ReadValue(@"select count(sys_table_id) from sys_table where table_name = 'plant_inventory_index'").ToString(); //if (cnt != "0") //{ int pinumber = Int32.Parse(dm.ReadValue(@"select accession_number_part2 from accession where accession_id = :aid", new DataParameters(":aid", id, DbType.Int32)).ToString()); DataTable dt = sd.GetData("web_accessiondetail_pi", ":pinumber=" + pinumber, 0, 0).Tables["web_accessiondetail_pi"]; if (dt.Rows.Count > 0) { HasPIValue = true; DataRow dr = dt.Rows[0]; PIAssigned = dr["plant_inventory_year"].ToString(); IVVolume = dr["plant_inventory_volumn"].ToString(); } dt = sd.GetData("web_accessiondetail_piindex", ":pinumber=" + pinumber, 0, 0).Tables["web_accessiondetail_piindex"]; if (dt.Rows.Count > 0) { lblViewPDF.Visible = true; foreach (DataRow dr in dt.Rows) { string PIIndex = "in_vol=" + dr["plant_inventory_volumn"].ToString() + "&in_suffix=" + dr["volumn_suffix"].ToString() + "&in_page=" + dr["page"].ToString(); lblViewPDF.Text = lblViewPDF.Text.Replace("*", PIIndex); } } dt = sd.GetData("web_accessiondetail_pimindex", ":pinumber=" + pinumber, 0, 0).Tables["web_accessiondetail_pimindex"]; if (dt.Rows.Count > 0) { lblViewIMPDF.Visible = true; foreach (DataRow dr in dt.Rows) { string PIIndex = "in_vol=" + dr["plant_immigrant_volumn"].ToString() + "&in_page=" + dr["plant_immigrant_page"].ToString(); lblViewIMPDF.Text = lblViewIMPDF.Text.Replace("*", PIIndex); } } //} } } } } catch (Exception ex) { string msg = ex.Message; } }
public static bool IsDefaultAddress(int addrid) { string defaultStatus; using (SecureData sd = GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { defaultStatus = dm.ReadValue(@" select is_default from web_user_shipping_address where web_user_id = :webuserid and web_user_shipping_address_id = :addrid ", new DataParameters( ":webuserid", sd.WebUserID, DbType.Int32, ":addrid", addrid, DbType.Int32 )).ToString(); return((defaultStatus == "Y") ? true : false); } } }
private void bindData(bool exportAll) { string sqlAll = ""; string sqlSelect = ""; if (Session["sqlwhere"] != null) { sqlAll = Session["sqlwhere"].ToString(); sqlSelect = sqlAll + ") and " + sqlAll.Substring(1, sqlAll.IndexOf("))")); DataTable dt = null; using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { // only selected traits if (exportAll) { dt = sd.GetData("web_descriptorbrowse_trait_export", ":where=" + sqlAll, 0, 0).Tables["web_descriptorbrowse_trait_export"]; } else { dt = sd.GetData("web_descriptorbrowse_trait_export", ":where=" + sqlSelect, 0, 0).Tables["web_descriptorbrowse_trait_export"]; } dt.Columns.RemoveAt(0); List <string> colist = new List <string>() { "accession_surfix", "plant_name", "taxon", "origin", "original_value", "frequency", "low", "hign", "mean", "sdev", "ssize", "inventory_prefix", "inventory_number", "inventory_suffix", "accession_comment" }; for (int i = 0; i < cblOptions.Items.Count; i++) { if (!cblOptions.Items[i].Selected) { dt.Columns.Remove(colist[i]); } } gvResult.DataSource = dt; gvResult.DataBind(); } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Request.QueryString["id"] != null) { // Only display what login user's order string id = Request.QueryString["id"].ToString(); using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { DataTable dt = dm.Read(@" select web_order_request_id from web_order_request where web_cooperator_id = :wcoopID ", new DataParameters(":wcoopID", sd.WebCooperatorID)); bool isMine = false; foreach (DataRow dr in dt.Rows) { if (dr["web_order_request_id"].ToString() == id) { isMine = true; bindDisplayData((Int32.Parse(id))); break; } } if (!isMine) { Response.Redirect("orderhistory.aspx"); } } } } } }
protected void DisplayReference(object sender, EventArgs e) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { int cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(literature_id) from literature"), 0); litcnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(distinct cit.citation_id) from citation cit join literature l on cit.literature_id = l.literature_id where cit.taxonomy_species_id is not null and l.abbreviation not in ('PEAS','ISTA','AH 505','AOSA Hb 25','World Econ Pl')"), 0); tcitcnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(distinct cit.taxonomy_species_id) from taxonomy_species ts join citation cit on ts.taxonomy_species_id = cit.taxonomy_species_id join literature l on cit.literature_id = l.literature_id where cit.taxonomy_species_id is not null and ts.taxonomy_species_id = ts.current_taxonomy_species_id and l.abbreviation not in ('PEAS','ISTA','AH 505','AOSA Hb 25','World Econ Pl')"), 0); actcitcnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(distinct cit.taxonomy_species_id) from taxonomy_species ts join citation cit on ts.taxonomy_species_id = cit.taxonomy_species_id join literature l on cit.literature_id = l.literature_id where cit.taxonomy_species_id is not null and ts.taxonomy_species_id != ts.current_taxonomy_species_id and l.abbreviation not in ('PEAS','ISTA','AH 505','AOSA Hb 25','World Econ Pl')"), 0); syntcitcnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(citation_id) from citation where taxonomy_genus_id is not null"), 0); gcitcnt = string.Format("{0:n0}", cnt1); } } pnlIndex.Visible = false; pnlSumm.Visible = false; pnlIntro.Visible = false; pnlHist.Visible = false; pnlScope.Visible = false; pnlScient.Visible = false; pnlCommon.Visible = false; pnlEcon.Visible = false; pnlDistrib.Visible = false; pnlLiter.Visible = true; pnlSpec.Visible = false; pnlBasis.Visible = false; pnlConcl.Visible = false; pnlAcknowl.Visible = false; pnlRefer.Visible = false; pnlSymb.Visible = false; }
private void DisplayHelp(int id) { using (SecureData sd = UserManager.GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { DataTable dt = dm.Read(@" select web_help_tag, virtual_path, heading, title, help_text_html from web_help where web_help_id = :helpid and sys_lang_id = :syslangid ", new DataParameters( ":helpid", id, ":syslangid", sd.LanguageID )); if (dt.Rows.Count > 0) { string tag = dt.Rows[0].ItemArray[0].ToString(); string vPath = dt.Rows[0].ItemArray[1].ToString(); string heading = dt.Rows[0].ItemArray[2].ToString(); string title = dt.Rows[0].ItemArray[3].ToString(); string text = dt.Rows[0].ItemArray[4].ToString(); string root = Toolkit.GetSetting("WebHelpURL", "~/help/"); if (!string.IsNullOrEmpty(vPath)) { Response.Redirect(vPath); } else if (!string.IsNullOrEmpty(tag)) { Response.Redirect(root + tag); } else if (!string.IsNullOrEmpty(text)) { lblHeading.Text = heading; lblTitle.Text = title; lblHelp.Text = text; } else { lblTitle.Text = Site1.DisplayText("noHelp", "Help content is not available now."); } } else { lblTitle.Text = Site1.DisplayText("noHelp", "Help content is not available now."); } } } }
private bool save(string name, string password, string conpassword) { if (!checkPassword(password)) { return(false); } if (password != conpassword) { Master.ShowError(Page.GetDisplayMember("UserAcct", "mismatchedPasswords", "The two passwords you entered did not match each other. Please try again.")); return(false); } string hashedPassword = Crypto.HashText(txtPassword.Text); hashedPassword = Crypto.HashText(hashedPassword); DataTable dt = null; using (SecureData sd = new SecureData(false, UserManager.GetLoginToken())) { using (DataManager dm = sd.BeginProcessing(true)) { dm.Limit = 1; dt = dm.Read(@" select wu.web_user_id, wu.web_cooperator_id from web_user wu where wu.user_name = :username and wu.is_enabled = 'Y' ", new DataParameters(":username", name)); //Won't allow same user_name(e-mail) address if (dt.Rows.Count > 0) { Master.ShowMessage(Page.GetDisplayMember("UserAcct", "usernameInUse", "The user name is already used.")); return(false); } var userID = dm.Write(@" insert into web_user (user_name, password, is_enabled, sys_lang_id, created_date) values (:user_name, :password, :is_enabled, :seclangid, :createddate) ", true, "web_user_id", new DataParameters( ":user_name", name, DbType.String, ":password", hashedPassword, DbType.String, ":is_enabled", "Y", DbType.String, ":seclangid", 1, DbType.Int32, ":createddate", DateTime.UtcNow, DbType.DateTime2 )); } } return(true); }
private void bindCitation(int id) { using (SecureData sd = UserManager.GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { rptReference.DataSource = sd.GetData("web_taxonomycwr_reference", ":taxonomyid=" + id, 0, 0).Tables["web_taxonomycwr_reference"]; rptReference.DataBind(); } } }
public static int GetGeographyID(string countryCode) { using (SecureData sd = GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { return(Toolkit.ToInt32(dm.ReadValue(@"select geography_id from geography where country_code = :country_code order by geography_id ", new DataParameters(":country_code", countryCode, DbType.String)), -1)); } } }
protected void DisplaySummary(object sender, EventArgs e) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { int cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(a.accession_id) from accession a join cooperator c on a.owned_by = c.cooperator_id join site s on c.site_id = s.site_id where s.site_short_name not in ('INACTIVE','NSSB')"), 0); accnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_genus_id) from taxonomy_genus where genus_name not like 'Unident%' and (subgenus_name is null and section_name is null and series_name is null)"), 0); gncnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_genus_id) from taxonomy_genus where genus_name not like 'Unident%' and (subgenus_name is null and section_name is null and series_name is null) and (qualifying_code not like '%=%' or qualifying_code is null)"), 0); acgncnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_genus_id) from taxonomy_genus where genus_name not like 'Unident%' and (subgenus_name is not null or section_name is not null or series_name is not null)"), 0); igncnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_genus_id) from taxonomy_genus where genus_name not like 'Unident%' and (subgenus_name is not null or section_name is not null or series_name is not null) and (qualifying_code not like '%=%' or qualifying_code is null)"), 0); acigncnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_species_id) from taxonomy_species where species_name not in ('sp.','hybrid')"), 0); spcnt = string.Format("{0:n0}", cnt1); cnt1 = Toolkit.ToInt32(dm.ReadValue(@" select count(taxonomy_species_id) from taxonomy_species where taxonomy_species_id = current_taxonomy_species_id and species_name not in ('sp.','hybrid')"), 0); acspcnt = string.Format("{0:n0}", cnt1); } } pnlIndex.Visible = false; pnlSumm.Visible = true; pnlIntro.Visible = false; pnlHist.Visible = false; pnlScope.Visible = false; pnlScient.Visible = false; pnlCommon.Visible = false; pnlEcon.Visible = false; pnlDistrib.Visible = false; pnlLiter.Visible = false; pnlSpec.Visible = false; pnlBasis.Visible = false; pnlConcl.Visible = false; pnlAcknowl.Visible = false; pnlRefer.Visible = false; pnlSymb.Visible = false; }
private void sendMail(string fileName, string action) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true)) { string status = dm.ReadValue(@"select status_code from web_order_request where web_order_request_id = :wor", new DataParameters(":wor", _recordid, DbType.Int32)).ToString(); string emails = ""; if (status == "ACCEPTED") { DataTable dt = sd.GetData("web_order_request_owner", ":wor=" + _recordid, 0, 0).Tables["web_order_request_owner"]; foreach (DataRow dr in dt.Rows) { emails += dr["email"].ToString() + ";"; } } if (emails.Length > 1) { int pos = fileName.LastIndexOf("/"); fileName = fileName.Substring(pos + 1, fileName.Length - pos - 1); string eSubject = Page.DisplayText("ExtraOrderAttachEmailSubject", "GRIN-GLOBAL - Public Order Attachment"); eSubject += " (Web Order Number " + _recordid + ") (action: " + action + " file " + fileName + ")"; string adminEmailTo = Toolkit.GetSetting("EmailOrderTo", ""); if (!String.IsNullOrEmpty(adminEmailTo)) { emails = adminEmailTo; } string eBody = "File " + fileName + " is " + Char.ToLowerInvariant(action[0]) + action.Substring(1) + "."; try { Email.Send(emails, Toolkit.GetSetting("EmailFrom", ""), "", "", eSubject, eBody); } catch (Exception ex) { string s = ex.Message; // debug Logger.LogTextForcefully("Application error: Sending email failed for notifying web order attachment " + _recordid + ". ", ex); } } } } }
private void deleteAttachments(int docid) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken())) { using (DataManager dm = sd.BeginProcessing(true)) { dm.Write(@" delete from web_order_request_attach where web_order_request_attach_id = :id ", new DataParameters(":id", docid)); } } }
private void populateLanguage() { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken())) { //DataTable dt = sd.ListLanguages(0).Tables["list_languages"]; // can't directly use secure data funciton, blocked by checkUserHasAdminEnabled(); using (DataManager dm = sd.BeginProcessing(true, true)) { DataTable dt = dm.Read(@"select * from sys_lang"); foreach (DataRow dr in dt.Rows) { ddlLang.Items.Add(new ListItem(dr["title"].ToString(), dr["sys_lang_id"].ToString())); } } } }
private void setPageTitle(Page page, int id) { using (SecureData sd = new SecureData(false, UserManager.GetLoginToken(true))) { using (DataManager dm = sd.BeginProcessing(true, true)) { var dt = dm.Read(@"select accession_number_part1, accession_number_part2, accession_number_part3 from accession where accession_id = :aid", new DataParameters(":aid", id, DbType.Int32)); if (dt.Rows.Count >= 1) { //page.Title = " - Accession: " + dt.Rows[0][0].ToString() + " " + dt.Rows[0][1].ToString() + " " + dt.Rows[0][2].ToString(); page.Title = "Accession: " + dt.Rows[0][0].ToString() + " " + dt.Rows[0][1].ToString() + " " + dt.Rows[0][2].ToString(); } } } }
public static void DeleteAddress(int addrid) { using (SecureData sd = GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true)) { dm.Write(@" delete from web_user_shipping_address where web_user_shipping_address_id = :addrid ", new DataParameters( ":addrid", addrid, DbType.Int32)); } } }
private void bindGrid() { using (var sd = new SecureData(true, UserManager.GetLoginToken())) { int limit = 0; int.TryParse(txtLimit.Text.Replace(",", ""), out limit); using (DataManager dm = sd.BeginProcessing(true, true)) { string sqlInput = txtSql.Text.Trim(); string sql = sqlInput.ToLower(); // Laura: need more cleanning work here, considering special characters, java scripts.... all these regular possible cases if (sql.Contains("update ") || sql.Contains("delete ") || sql.Contains("insert") || sql.Contains("select into") || sql.Contains("create ") || sql.Contains("exec ") || sql.Contains("execute ")) { lblError.Visible = true; lblError.Text = "Only Select query is allowed."; lblRetrieved.Visible = true; GridView1.DataSource = null; } else { try { dm.Limit = limit; DataTable dt = dm.Read(sqlInput); lblError.Visible = false; GridView1.DataSource = dt; int cnt = dt.Rows.Count; lblRetrieved.Visible = true; lblRetrieved.Text = "Retrieved " + cnt + " rows."; } catch (Exception ex) { lblError.Visible = true; lblError.Text = ex.Message; lblRetrieved.Visible = true; GridView1.DataSource = null; } } GridView1.PageSize = Toolkit.ToInt32(ddlPageSize.SelectedValue, 0); GridView1.DataBind(); } } }
private static void updateLoginTime(string webUserName, string loginToken) // TODO: need to move these sql/functions/methods to secureData.cs later { using (SecureData sd = new SecureData(true, loginToken, null)) { using (DataManager dm = sd.BeginProcessing(true)) { dm.Write(@" update web_user set last_login_date = :lastlogindate where user_name = :wusername ", new DataParameters( ":lastlogindate", DateTime.UtcNow, DbType.DateTime2, ":wusername", webUserName, DbType.String)); } } }
public static DataTable GetShippingAddress(int addressid) { using (SecureData sd = GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { return(dm.Read(@" select distinct wusa.*, g.country_code, g.adm1 as state_name from web_user_shipping_address wusa join geography g on wusa.geography_id = g.geography_id where wusa.web_user_id = :wuserid and wusa.web_user_shipping_address_id = :addressid", new DataParameters( ":wuserid", sd.WebUserID, DbType.Int32, ":addressid", addressid, DbType.Int32 ))); } } }
protected string GetOrderStatus(object valid, object valstatus) { string ret = valstatus.ToString(); string retid = valid.ToString(); if (!String.IsNullOrEmpty(retid)) { int orderID = Toolkit.ToInt32(retid); using (var sd = new SecureData(false, UserManager.GetLoginToken())) { using (DataManager dm = sd.BeginProcessing(true, true)) { // DataTable dtItems = sd.GetData("web_order_history_detail", ":orderrequestid=" + orderID, 0, 0).Tables["web_order_history_detail"]; DataTable dtItems = dm.Read(@" select wor.status_code as order_status, coalesce(ori.status_code, wori.status_code) as status_code from web_order_request_item wori left join order_request_item ori on wori.web_order_request_item_id = ori.web_order_request_item_id left join web_order_request wor on wori.web_order_request_id = wor.web_order_request_id where wori.web_order_request_id = :orderID ", new DataParameters(":orderID", orderID)); if (dtItems.Rows.Count > 0) { ret = dtItems.Rows[0].ItemArray[0].ToString(); bool complete = true; for (int i = 0; i < dtItems.Rows.Count; i++) { if (dtItems.Rows[i]["status_code"].ToString() != "SHIPPED") { complete = false; break; } } if (complete) { ret = "SHIPPED"; // Any other order status calculation logic ??? } } } } } return(ret); }
/// <summary> /// Save logged in user preference. /// </summary> /// <param name="coopid"></param> /// <param name="prefKey"></param> /// <param name="prefValue"></param> /// <returns></returns> public static void SaveUserPref(string prefKey, string prefValue) { using (SecureData sd = GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true)) { int wuserid = sd.WebUserID; int affected = dm.Write(@" update web_user_preference set preference_value = :prefvalue, modified_date = :now, modified_by = :modifiedby where web_user_id = :webuserid and preference_name = :prefname ", new DataParameters( ":prefvalue", prefValue, ":webuserid", wuserid, DbType.Int32, ":now", DateTime.UtcNow, DbType.DateTime2, ":modifiedby", wuserid, DbType.Int32, ":prefname", prefKey, DbType.String )); if (affected == 0) { dm.Write(@" insert into web_user_preference (web_user_id, preference_name, preference_value, created_date, created_by, owned_date, owned_by) values (:webuserid, :prefname, :prefvalue, :now1, :webuserid2, :now2, :webuserid3) ", new DataParameters( ":webuserid", wuserid, DbType.Int32, ":prefname", prefKey, DbType.String, ":prefvalue", prefValue, DbType.String, ":now1", DateTime.UtcNow, DbType.DateTime2, ":webuserid2", wuserid, DbType.Int32, ":now2", DateTime.UtcNow, DbType.DateTime2, ":webuserid3", wuserid, DbType.Int32 )); } } } }
private void bindLiterature(int literatureID, string abbr) { pnlLiterature.Visible = true; pnlCitation.Visible = false; using (SecureData sd = UserManager.GetSecureData(true)) { using (DataManager dm = sd.BeginProcessing(true, true)) { if (literatureID <= 0) { // if they didn't give us a valid lit id, try looking it up based on abbr literatureID = Toolkit.ToInt32(dm.ReadValue(@"select literature_id from literature where abbreviation = :abbr", new DataParameters(":abbr", abbr)), -1); } rptLiterature.DataSource = sd.GetData("web_literature", ":literature_id=" + literatureID, 0, 0).Tables["web_literature"]; rptLiterature.DataBind(); } } }