private void OnDataBinding(object sender, EventArgs e) { Literal lbl = (Literal)sender; DataGridItem objContainer = (DataGridItem)lbl.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; if (row != null) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } if (row[sDATA_FIELD] != DBNull.Value) { lbl.Text = L10n.Term(Sql.ToString(row[sDATA_FIELD])); } } else { lbl.Text = sDATA_FIELD; } }
public static string ValidateIDs(string[] arrID, bool bQuoted) { if (arrID.Length == 0) { return(String.Empty); } if (arrID.Length > 200) { L10N L10n = HttpContext.Current.Items["L10n"] as L10N; throw(new Exception(L10n.Term(".LBL_TOO_MANY_RECORDS"))); } foreach (string sID in arrID) { Guid gID = Sql.ToGuid(sID); if (Sql.IsEmptyGuid(gID)) { // 05/02/2006 Paul. Provide a more descriptive error message by including the ID. throw(new Exception("Invalid ID: " + sID)); } } string sIDs = String.Empty; if (bQuoted) { sIDs = "'" + String.Join("','", arrID) + "'"; } else { sIDs = String.Join(",", arrID); } return(sIDs); }
private void lst_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem)lst.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; if (row != null) { string sMODULE_NAME = Sql.ToString(row["MODULE_NAME"]); // 04/25/2006 Paul. We could use GUIDS like SugarCRM, but since there is only one ACL grid, // there is no need for that kind of uniqueness. // 04/25/2006 Paul. toggleDisplay() will automatically reverse toggle of a linked control. divList.ID = sMODULE_NAME + "_" + sACCESS_TYPE; lst.ID = "lst" + sMODULE_NAME + "_" + sACCESS_TYPE; // 04/25/2006 Paul. OnChange, update the the innerHTML and the hidden field. lst.Attributes.Add("onchange", "document.getElementById('" + divLabel.ClientID + "').innerHTML=this.options[this.selectedIndex].text; document.getElementById('" + hid.ClientID + "').value=document.getElementById('" + divLabel.ClientID + "').innerHTML; toggleDisplay('" + divList.ClientID + "');"); // 04/25/2006 Paul. The first parent is the DIV, the second is the TableCell. TableCell td = divList.Parent as TableCell; if (td != null) { td.Attributes.Add("ondblclick", "toggleDisplay('" + divList.ClientID + "')"); } if (row[sDATA_FIELD] != DBNull.Value) { int nACCESS = Sql.ToInteger(row[sDATA_FIELD]); lst.Attributes.Add("class", AccessClassName(sACCESS_TYPE, nACCESS)); try { // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. if (!objContainer.Page.IsPostBack) { lst.SelectedValue = NormalizeAccessValue(sACCESS_TYPE, nACCESS).ToString(); } } catch { } } // 04/25/2006 Paul. We always need to translate the items, even during postback. // This is because we always build the DropDownList. // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } // 04/25/2006 Paul. Make sure to translate the text. // It cannot be translated in InstantiateIn() because the Page is not defined. foreach (ListItem itm in lst.Items) { itm.Text = L10n.Term(itm.Text); } } }
private void lit_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem)lbl.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; // 04/25/2006 Paul. We don't have access to the ACLGrid in InstantiateIn(), so do so here. ACLGrid grd = objContainer.Parent.Parent as ACLGrid; if (!grd.EnableACLEditing) { divList.Controls.Clear(); // 04/25/2006 Paul. I'd like to remove the dvList, but I can't do it here. //divList.Parent.Controls.Remove(divList); //divList = null; } if (row != null) { string sMODULE_NAME = Sql.ToString(row["MODULE_NAME"]); // 04/25/2006 Paul. We could use GUIDS like SugarCRM, but since there is only one ACL grid, // there is no need for that kind of uniqueness. divLabel.ID = sMODULE_NAME + "_" + sACCESS_TYPE + "link"; hid.ID = "hid" + sMODULE_NAME + "_" + sACCESS_TYPE; if (row[sDATA_FIELD] != DBNull.Value) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } int nACCESS = Sql.ToInteger(row[sDATA_FIELD]); divLabel.Attributes.Add("class", AccessClassName(sACCESS_TYPE, nACCESS)); // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. // 04/26/2006 Paul. Make sure to set the division color, even on postback. // 05/03/2006 Paul. If we are not editing, then always bind to the query. // This is so that the AccessView control can be placed in an unrelated control that have postbacks. // This was first noticed in the UserRolesView.ascx. if (!objContainer.Page.IsPostBack || !grd.EnableACLEditing) { lbl.Text = L10n.Term(AccessLabel(sACCESS_TYPE, nACCESS)); hid.Value = lbl.Text; } else { // 04/25/2006 Paul. The label will not retain its value, so restore from the hidden field. // We use the hidden field because the value my have been changed by the user. // 04/25/2006 Paul. We are too early in the ASP.NET lifecycle to access hid.Value, // so go directly to the Request to get the submitted value. lbl.Text = hid.Page.Request[hid.UniqueID]; } } } }
public static void AppendDetailViewFields(string sDETAIL_NAME, HtmlTable tbl, IDataReader rdr, L10N L10n, TimeZone T10n, CommandEventHandler Page_Command) { if ( tbl == null ) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), "HtmlTable is not defined for " + sDETAIL_NAME); return; } DataTable dtFields = SplendidCache.DetailViewFields(sDETAIL_NAME); AppendDetailViewFields(dtFields.DefaultView, tbl, rdr, L10n, T10n, Page_Command, false); }
public static Stack FilterByACL_Stack(string sMODULE_NAME, string sACCESS_TYPE, string[] arrID, string sTABLE_NAME) { Stack stk = new Stack(); StringBuilder sb = new StringBuilder(); int nACLACCESS = Security.GetUserAccess(sMODULE_NAME, sACCESS_TYPE); if (nACLACCESS >= 0 && arrID.Length > 0) { if (nACLACCESS == ACL_ACCESS.OWNER) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { // 09/26/2006 Paul. The connection needed to be opened. con.Open(); string sSQL; sSQL = "select ID " + ControlChars.CrLf + " from vw" + sTABLE_NAME + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AppendGuids(cmd, arrID, "ID"); Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false); using (IDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { stk.Push(Sql.ToString(rdr["ID"])); } } } } if (stk.Count == 0) { L10N L10n = HttpContext.Current.Items["L10n"] as L10N; throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } } else { foreach (string sID in arrID) { if (sID.Length > 0) { stk.Push(sID); } } } } return(stk); }
public static string Culture() { string sCulture = Sql.ToString(HttpContext.Current.Application["CONFIG.default_language"]); DataView vwLanguages = new DataView(SplendidCache.Languages()); vwLanguages.RowFilter = "NAME = '" + sCulture + "'"; if (vwLanguages.Count > 0) { sCulture = Sql.ToString(vwLanguages[0]["NAME"]); } if (Sql.IsEmptyString(sCulture)) { sCulture = "en-US"; } return(L10N.NormalizeCulture(sCulture)); }
public static string FilterByACL(string sMODULE_NAME, string sACCESS_TYPE, string[] arrID, string sTABLE_NAME) { StringBuilder sb = new StringBuilder(); int nACLACCESS = Security.GetUserAccess(sMODULE_NAME, sACCESS_TYPE); if (nACLACCESS >= 0 && arrID.Length > 0) { if (nACLACCESS == ACL_ACCESS.OWNER) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { string sSQL; sSQL = "select ID " + ControlChars.CrLf + " from vw" + sTABLE_NAME + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; Sql.AppendGuids(cmd, arrID, "ID"); Sql.AppendParameter(cmd, Security.USER_ID, "ASSIGNED_USER_ID", false); using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.SingleRow)) { while (rdr.Read()) { if (sb.Length > 0) { sb.Append(","); } sb.Append(Sql.ToString(rdr["ID"])); } } } } if (sb.Length == 0) { L10N L10n = HttpContext.Current.Items["L10n"] as L10N; throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } } else { return(String.Join(",", arrID)); } } return(sb.ToString()); }
public L10N GetL10n() { // 08/30/2005 Paul. Move the L10N creation to this get function so that the first control // that gets created will cause the creation of L10N. The UserControls get the OnInit event before the Page onInit event. if (L10n == null) { m_sCULTURE = Sql.ToString(Session["USER_SETTINGS/CULTURE"]); m_sDATEFORMAT = Sql.ToString(Session["USER_SETTINGS/DATEFORMAT"]); m_sTIMEFORMAT = Sql.ToString(Session["USER_SETTINGS/TIMEFORMAT"]); // 05/09/2006 Paul. Initialize the numeric separators. string sGROUP_SEPARATOR = Sql.ToString(Session["USER_SETTINGS/GROUP_SEPARATOR"]); string sDECIMAL_SEPARATOR = Sql.ToString(Session["USER_SETTINGS/DECIMAL_SEPARATOR"]); L10n = new L10N(m_sCULTURE); // 08/05/2006 Paul. We cannot set the CurrencyDecimalSeparator directly on Mono as it is read-only. // Hold off setting the CurrentCulture until we have updated all the settings. CultureInfo culture = CultureInfo.CreateSpecificCulture(L10n.NAME); culture.DateTimeFormat.ShortDatePattern = m_sDATEFORMAT; culture.DateTimeFormat.ShortTimePattern = m_sTIMEFORMAT; // 06/03/2006 Paul. Setting the separators is causing some users a problem. It may be because the strings were empty. if (!Sql.IsEmptyString(sGROUP_SEPARATOR)) { culture.NumberFormat.CurrencyGroupSeparator = sGROUP_SEPARATOR; } if (!Sql.IsEmptyString(sDECIMAL_SEPARATOR)) { culture.NumberFormat.CurrencyDecimalSeparator = sDECIMAL_SEPARATOR; } if (!Sql.IsEmptyString(sGROUP_SEPARATOR)) { culture.NumberFormat.NumberGroupSeparator = sGROUP_SEPARATOR; } if (!Sql.IsEmptyString(sDECIMAL_SEPARATOR)) { culture.NumberFormat.NumberDecimalSeparator = sDECIMAL_SEPARATOR; } // 08/30/2005 Paul. We don't need the long time pattern because we simply do not use it. //Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongTimePattern = m_sTIMEFORMAT; //Thread.CurrentThread.CurrentUICulture = Thread.CurrentThread.CurrentCulture; //08/05/2006 Paul. Apply the modified cultures. Thread.CurrentThread.CurrentCulture = culture; Thread.CurrentThread.CurrentUICulture = culture; } return(L10n); }
public L10N GetL10n() { // 08/30/2005 Paul. Attempt to get the L10n & T10n objects from the parent page. // If that fails, then just create them because they are required. if (L10n == null) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. // A port to DNN prompted this approach. L10n = Context.Items["L10n"] as L10N; if (L10n == null) { string sCULTURE = Sql.ToString(Session["USER_SETTINGS/CULTURE"]); L10n = new L10N(sCULTURE); } } return(L10n); }
public static string TableColumnName(L10N L10n, string sModule, string sDISPLAY_NAME) { // 07/04/2006 Paul. Some columns have global terms. // 06/05/2007 Paul. Add Team global term. if (sDISPLAY_NAME == "DATE_ENTERED" || sDISPLAY_NAME == "DATE_MODIFIED" || sDISPLAY_NAME == "ASSIGNED_TO" || sDISPLAY_NAME == "CREATED_BY" || sDISPLAY_NAME == "MODIFIED_BY" || sDISPLAY_NAME == "TEAM_NAME") { sDISPLAY_NAME = L10n.Term(".LBL_" + sDISPLAY_NAME).Replace(":", ""); } else { // 07/04/2006 Paul. Column names are aliased so that we don't have to redefine terms. sDISPLAY_NAME = L10n.AliasedTerm(sModule + ".LBL_" + sDISPLAY_NAME).Replace(":", ""); } return(sDISPLAY_NAME); }
// 12/22/2007 Paul. Inside the timer event, there is no current context, so we need to pass the application. public static string Culture(HttpApplicationState Application) { string sCulture = Sql.ToString(Application["CONFIG.default_language"]); // 12/22/2007 Paul. The cache is not available when we are inside the timer event. if (HttpContext.Current != null && HttpContext.Current.Cache != null) { DataView vwLanguages = new DataView(SplendidCache.Languages()); vwLanguages.RowFilter = "NAME = '" + sCulture + "'"; if (vwLanguages.Count > 0) { sCulture = Sql.ToString(vwLanguages[0]["NAME"]); } } if (Sql.IsEmptyString(sCulture)) { sCulture = "en-US"; } return(L10N.NormalizeCulture(sCulture)); }
// 11/12/2005 Paul. Not sure why, but Unified Search/Project List is not translating. public void L10nTranslate() { if (!bTranslated) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } PagerStyle.PrevPageText = L10n.Term(PagerStyle.PrevPageText); PagerStyle.NextPageText = L10n.Term(PagerStyle.NextPageText); foreach (DataGridColumn col in Columns) { col.HeaderText = L10n.Term(col.HeaderText); } bTranslated = true; } }
/// <summary> /// CronDescription /// </summary> public static string CronDescription(L10N L10n, string sCRON) { StringBuilder sb = new StringBuilder(); sCRON = sCRON.Replace(" ", ""); if (sCRON == "*::*::*::*::*") { return(L10n.Term("Schedulers.LBL_OFTEN")); } CultureInfo culture = CultureInfo.CreateSpecificCulture(L10n.NAME); string sCRON_MONTH = "*"; string sCRON_DAYOFMONTH = "*"; string sCRON_DAYOFWEEK = "*"; string sCRON_HOUR = "*"; string sCRON_MINUTE = "*"; string[] arrCRON = sCRON.Replace("::", "|").Split('|'); string[] arrCRON_TEMP = new string[] {}; string[] arrCRON_VALUE = new string[] {}; string[] arrDaySuffixes = new string[32]; int nCRON_VALUE = 0; int nCRON_VALUE_START = 0; int nCRON_VALUE_END = 0; int nON_THE_MINUTE = -1; for (int n = 0; n < arrDaySuffixes.Length; n++) { arrDaySuffixes[n] = "th"; } arrDaySuffixes[0] = ""; arrDaySuffixes[1] = "st"; arrDaySuffixes[2] = "nd"; arrDaySuffixes[3] = "rd"; // minute hour dayOfMonth month dayOfWeek if (arrCRON.Length > 0) { sCRON_MINUTE = arrCRON[0]; } if (arrCRON.Length > 1) { sCRON_HOUR = arrCRON[1]; } if (arrCRON.Length > 2) { sCRON_DAYOFMONTH = arrCRON[2]; } if (arrCRON.Length > 3) { sCRON_MONTH = arrCRON[3]; } if (arrCRON.Length > 4) { sCRON_DAYOFWEEK = arrCRON[4]; } if (sCRON_MINUTE != "*") { arrCRON_TEMP = sCRON_MINUTE.Split(','); // 12/31/2007 Paul. Check for either comma or dash. if (sCRON_MINUTE.Split(",-".ToCharArray()).Length == 1) { nON_THE_MINUTE = Sql.ToInteger(sCRON_MINUTE); sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); if (nON_THE_MINUTE == 0) { sb.Append(L10n.Term("Schedulers.LBL_HOUR_SING")); } else { sb.Append(nON_THE_MINUTE.ToString("00")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); } } else { for (int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++) { if (arrCRON_TEMP[i].IndexOf('-') >= 0) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if (arrCRON_VALUE.Length >= 2) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if (nCRON_VALUE_START >= 0 && nCRON_VALUE_START <= 23 && nCRON_VALUE_END >= 0 && nCRON_VALUE_END <= 23) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); if (nCRON_VALUE_START == 0) { sb.Append(L10n.Term("Schedulers.LBL_HOUR_SING")); } else { sb.Append(nCRON_VALUE_START.ToString("0")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); } sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); sb.Append(nCRON_VALUE_END.ToString("0")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if (nCRON_VALUE >= 0 && nCRON_VALUE <= 23) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); if (nCRON_VALUE == 0) { sb.Append(L10n.Term("Schedulers.LBL_HOUR_SING")); } else { sb.Append(nCRON_VALUE.ToString("0")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); } nCronEntries++; } } } } } if (sCRON_HOUR != "*") { if (sb.Length > 0) { sb.Append("; "); } arrCRON_TEMP = sCRON_HOUR.Split(','); for (int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++) { if (arrCRON_TEMP[i].IndexOf('-') >= 0) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if (arrCRON_VALUE.Length >= 2) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if (nCRON_VALUE_START >= 1 && nCRON_VALUE_START <= 31 && nCRON_VALUE_END >= 1 && nCRON_VALUE_END <= 31) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(arrCRON_VALUE[0]); if (nON_THE_MINUTE >= 0) { sb.Append(":" + nON_THE_MINUTE.ToString("00")); } sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(arrCRON_VALUE[1]); if (nON_THE_MINUTE >= 0) { sb.Append(":" + nON_THE_MINUTE.ToString("00")); } nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if (nCRON_VALUE >= 1 && nCRON_VALUE <= 31) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(arrCRON_TEMP[i]); if (nON_THE_MINUTE >= 0) { sb.Append(":" + nON_THE_MINUTE.ToString("00")); } nCronEntries++; } } } } if (sCRON_DAYOFMONTH != "*") { if (sb.Length > 0) { sb.Append("; "); } arrCRON_TEMP = sCRON_DAYOFMONTH.Split(','); for (int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++) { if (arrCRON_TEMP[i].IndexOf('-') >= 0) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if (arrCRON_VALUE.Length >= 2) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if (nCRON_VALUE_START >= 1 && nCRON_VALUE_START <= 31 && nCRON_VALUE_END >= 1 && nCRON_VALUE_END <= 31) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(nCRON_VALUE_START.ToString() + arrDaySuffixes[nCRON_VALUE_START]); sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(nCRON_VALUE_END.ToString() + arrDaySuffixes[nCRON_VALUE_END]); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if (nCRON_VALUE >= 1 && nCRON_VALUE <= 31) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(nCRON_VALUE.ToString() + arrDaySuffixes[nCRON_VALUE]); nCronEntries++; } } } } if (sCRON_MONTH != "*") { if (sb.Length > 0) { sb.Append("; "); } arrCRON_TEMP = sCRON_MONTH.Split(','); for (int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++) { if (arrCRON_TEMP[i].IndexOf('-') >= 0) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if (arrCRON_VALUE.Length >= 2) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if (nCRON_VALUE_START >= 1 && nCRON_VALUE_START <= 12 && nCRON_VALUE_END >= 1 && nCRON_VALUE_END <= 12) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(culture.DateTimeFormat.MonthNames[nCRON_VALUE_START]); sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(culture.DateTimeFormat.MonthNames[nCRON_VALUE_END]); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if (nCRON_VALUE >= 1 && nCRON_VALUE <= 12) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(culture.DateTimeFormat.MonthNames[nCRON_VALUE]); nCronEntries++; } } } } if (sCRON_DAYOFWEEK != "*") { if (sb.Length > 0) { sb.Append("; "); } arrCRON_TEMP = sCRON_DAYOFWEEK.Split(','); for (int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++) { if (arrCRON_TEMP[i].IndexOf('-') >= 0) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if (arrCRON_VALUE.Length >= 2) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if (nCRON_VALUE_START >= 0 && nCRON_VALUE_START <= 6 && nCRON_VALUE_END >= 0 && nCRON_VALUE_END <= 6) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(culture.DateTimeFormat.DayNames[nCRON_VALUE_START]); sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(culture.DateTimeFormat.DayNames[nCRON_VALUE_END]); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if (nCRON_VALUE >= 0 && nCRON_VALUE <= 6) { if (nCronEntries > 0) { sb.Append(L10n.Term("Schedulers.LBL_AND")); } sb.Append(culture.DateTimeFormat.DayNames[nCRON_VALUE]); nCronEntries++; } } } } return(sb.ToString()); }
public string create_opportunity(string user_name, string password, string name, string amount) { // 03/12/2007 Paul. If using NTLM, then user_name will be updated with value from Identity object. Guid gUSER_ID = LoginUser(ref user_name, password); int nACLACCESS = Security.GetUserAccess("Opportunities", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } Guid gID = Guid.Empty; SqlProcs.spOPPORTUNITIES_New(ref gID, Guid.Empty, name, Sql.ToDecimal(amount), Guid.Empty, DateTime.MinValue, String.Empty); return "1"; }
public user_detail[] user_list(string user_name, string password) { // 03/12/2007 Paul. If using NTLM, then user_name will be updated with value from Identity object. Guid gUSER_ID = LoginUser(ref user_name, password); if ( !IsAdmin(gUSER_ID) ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } user_detail[] results = new user_detail[0]; DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwSOAP_User_List" + ControlChars.CrLf + " where 1 = 1 " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; try { using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); if ( dt.Rows.Count > 0 ) { // 02/20/2006 Paul. First initialize the array. results = new user_detail[dt.Rows.Count]; for ( int i=0; i < dt.Rows.Count ; i++ ) { // 02/20/2006 Paul. Then initialize each element in the array. results[i] = new user_detail(); results[i].email_address = Sql.ToString(dt.Rows[i]["EMAIL_ADDRESS"]); results[i].user_name = Sql.ToString(dt.Rows[i]["USER_NAME" ]); results[i].first_name = Sql.ToString(dt.Rows[i]["FIRST_NAME" ]); results[i].last_name = Sql.ToString(dt.Rows[i]["LAST_NAME" ]); results[i].department = Sql.ToString(dt.Rows[i]["DEPARTMENT" ]); results[i].id = Sql.ToString(dt.Rows[i]["ID" ]); results[i].title = Sql.ToString(dt.Rows[i]["TITLE" ]); } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw(new Exception("SOAP: Failed user_list", ex)); } } } return results; }
public set_relationship_list_result set_relationships(string session, set_relationship_value[] set_relationship_list) { Guid gUSER_ID = GetSessionUserID(session); set_relationship_list_result results = new set_relationship_list_result(); results.created = 0; results.failed = 0; for ( int i=0; i < set_relationship_list.Length; i ++ ) { int nACLACCESS = Security.GetUserAccess(set_relationship_list[i].module1, "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } SetRelationship(set_relationship_list[i].module1, set_relationship_list[i].module1_id, set_relationship_list[i].module2, set_relationship_list[i].module2_id); results.created++ ; } return results; }
public set_entry_result set_note_attachment(string session, note_attachment note) { Guid gUSER_ID = GetSessionUserID(session); Guid gNOTE_ID = Sql.ToGuid(note.id); string sFILENAME = Path.GetFileName (note.filename); string sFILE_EXT = Path.GetExtension(sFILENAME); string sFILE_MIME_TYPE = "application/octet-stream"; int nACLACCESS = Security.GetUserAccess("Notes", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } set_entry_result result = new set_entry_result(); byte[] byData = Convert.FromBase64String(note.file); // 02/20/2006 Paul. Try and reduce the memory requirements by releasing the original data as soon as possible. note.file = null; using ( MemoryStream stm = new System.IO.MemoryStream(byData) ) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); Guid gASSIGNED_USER_ID = Guid.Empty; /* // 09/01/2006 Paul. Notes do not have an ASSIGNED_USER_ID. string sSQL = String.Empty; sSQL = "select * " + ControlChars.CrLf + " from vwNOTES_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gNOTE_ID); using ( IDataReader rdr = cmd.ExecuteReader() ) { if ( rdr.Read() ) { gASSIGNED_USER_ID = Sql.ToGuid(rdr["ASSIGNED_USER_ID"]); } } } */ if ( nACLACCESS != ACL_ACCESS.OWNER || (nACLACCESS == ACL_ACCESS.OWNER && gASSIGNED_USER_ID == gUSER_ID) ) { using ( IDbTransaction trn = con.BeginTransaction() ) { try { Guid gAttachmentID = Guid.Empty; SqlProcs.spNOTE_ATTACHMENTS_Insert(ref gAttachmentID, gNOTE_ID, note.filename, sFILENAME, sFILE_EXT, sFILE_MIME_TYPE, trn); SplendidCRM.Notes.EditView.LoadFile(gAttachmentID, stm, trn); trn.Commit(); } catch(Exception ex) { trn.Rollback(); SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw ( new Exception(ex.Message) ); } } } } } byData = null; return result; }
public string create_account(string user_name, string password, string name, string phone, string website) { // 03/12/2007 Paul. If using NTLM, then user_name will be updated with value from Identity object. Guid gUSER_ID = LoginUser(ref user_name, password); int nACLACCESS = Security.GetUserAccess("Accounts", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } Guid gID = Guid.Empty; SqlProcs.spACCOUNTS_New(ref gID, name, phone, website); return "1"; }
public string create_case(string user_name, string password, string name) { Guid gUSER_ID = LoginUser(user_name, password); int nACLACCESS = Security.GetUserAccess("Cases", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } Guid gID = Guid.Empty; SqlProcs.spCASES_New(ref gID, name, String.Empty, Guid.Empty); return "1"; }
private void OnDataBinding(object sender, EventArgs e) { Literal lbl = (Literal)sender; DataGridItem objContainer = (DataGridItem)lbl.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; if (row != null) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } if (L10n != null) { if (row[sDATA_FIELD] != DBNull.Value) { string sList = sLIST_NAME; // 01/18/2007 Paul. If AssignedUser list, then use the cached value to find the value. if (sLIST_NAME == "AssignedUser") { lbl.Text = SplendidCache.AssignedUser(Sql.ToGuid(row[sDATA_FIELD])); } // 12/05/2005 Paul. The activity status needs to be dynamically converted to the correct list. else if (sLIST_NAME == "activity_status") { string sACTIVITY_TYPE = String.Empty; try { sACTIVITY_TYPE = Sql.ToString(row["ACTIVITY_TYPE"]); switch (sACTIVITY_TYPE) { case "Tasks": sList = "task_status_dom"; break; case "Meetings": sList = "meeting_status_dom"; break; case "Calls": // 07/15/2006 Paul. Call status is translated externally. lbl.Text = Sql.ToString(row[sDATA_FIELD]); return; //sList = "call_status_dom" ; break; case "Notes": // 07/15/2006 Paul. Note Status is not normally as it does not have a status. lbl.Text = L10n.Term(".activity_dom.Note"); return; // 06/15/2006 Paul. This list name for email_status does not follow the standard. case "Emails": sList = "dom_email_status"; break; // 04/21/2006 Paul. If the activity does not have a status (such as a Note), then use activity_dom. default: sList = "activity_dom"; break; } } catch (Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex); } lbl.Text = Sql.ToString(L10n.Term("." + sList + ".", row[sDATA_FIELD])); } else { lbl.Text = Sql.ToString(L10n.Term("." + sList + ".", row[sDATA_FIELD])); } } } else { lbl.Text = Sql.ToString(row[sDATA_FIELD]); } } else { lbl.Text = sDATA_FIELD; } }
public static void InitTerminology() { try { HttpApplicationState Application = HttpContext.Current.Application; DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; sSQL = "select NAME " + ControlChars.CrLf + " , LANG " + ControlChars.CrLf + " , MODULE_NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " from vwTERMINOLOGY " + ControlChars.CrLf + " where LIST_NAME is null" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { // 01/20/2006 Paul. Enable all languages when debugging. //#if DEBUG // sSQL += " and LANG = 'en-us'" + ControlChars.CrLf; //#endif cmd.CommandText = sSQL; using (IDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { //Application[Sql.ToString(rdr["LANG"]) + "." + Sql.ToString(rdr["MODULE_NAME"]) + "." + Sql.ToString(rdr["NAME"])] = Sql.ToString(rdr["DISPLAY_NAME"]); string sLANG = Sql.ToString(rdr["LANG"]); string sMODULE_NAME = Sql.ToString(rdr["MODULE_NAME"]); string sNAME = Sql.ToString(rdr["NAME"]); string sDISPLAY_NAME = Sql.ToString(rdr["DISPLAY_NAME"]); L10N.SetTerm(sLANG, sMODULE_NAME, sNAME, sDISPLAY_NAME); } } } sSQL = "select NAME " + ControlChars.CrLf + " , LANG " + ControlChars.CrLf + " , MODULE_NAME " + ControlChars.CrLf + " , LIST_NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " from vwTERMINOLOGY " + ControlChars.CrLf + " where LIST_NAME is not null" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { // 01/20/2006 Paul. Enable all languages when debugging. //#if DEBUG // sSQL += " and LANG = 'en-us'" + ControlChars.CrLf; //#endif cmd.CommandText = sSQL; using (IDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { // 01/13/2006 Paul. Don't include MODULE_NAME when used with a list. // DropDownLists are populated without the module name in the list name. // 01/13/2006 Paul. We can remove the module, but not the dot. // Otherwise it breaks all other code that references a list term. //Application[Sql.ToString(rdr["LANG"]) + "." + sMODULE_NAME + "." + Sql.ToString(rdr["LIST_NAME"]) + "." + Sql.ToString(rdr["NAME"])] = Sql.ToString(rdr["DISPLAY_NAME"]); string sLANG = Sql.ToString(rdr["LANG"]); string sMODULE_NAME = Sql.ToString(rdr["MODULE_NAME"]); string sNAME = Sql.ToString(rdr["NAME"]); string sLIST_NAME = Sql.ToString(rdr["LIST_NAME"]); string sDISPLAY_NAME = Sql.ToString(rdr["DISPLAY_NAME"]); L10N.SetTerm(sLANG, sMODULE_NAME, sLIST_NAME, sNAME, sDISPLAY_NAME); } } } sSQL = "select ALIAS_NAME " + ControlChars.CrLf + " , ALIAS_MODULE_NAME " + ControlChars.CrLf + " , ALIAS_LIST_NAME " + ControlChars.CrLf + " , NAME " + ControlChars.CrLf + " , MODULE_NAME " + ControlChars.CrLf + " , LIST_NAME " + ControlChars.CrLf + " from vwTERMINOLOGY_ALIASES" + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; using (IDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { string sALIAS_NAME = Sql.ToString(rdr["ALIAS_NAME"]); string sALIAS_MODULE_NAME = Sql.ToString(rdr["ALIAS_MODULE_NAME"]); string sALIAS_LIST_NAME = Sql.ToString(rdr["ALIAS_LIST_NAME"]); string sNAME = Sql.ToString(rdr["NAME"]); string sMODULE_NAME = Sql.ToString(rdr["MODULE_NAME"]); string sLIST_NAME = Sql.ToString(rdr["LIST_NAME"]); L10N.SetAlias(sALIAS_MODULE_NAME, sALIAS_LIST_NAME, sALIAS_NAME, sMODULE_NAME, sLIST_NAME, sNAME); } } } // 07/13/2006 Paul. The reporting module needs a quick way to translate a module name to a table name. sSQL = "select MODULE_NAME" + ControlChars.CrLf + " , TABLE_NAME " + ControlChars.CrLf + " from vwMODULES " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; using (IDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { string sMODULE_NAME = Sql.ToString(rdr["MODULE_NAME"]); string sTABLE_NAME = Sql.ToString(rdr["TABLE_NAME"]); Application["Modules." + sMODULE_NAME + ".TableName"] = sTABLE_NAME; } } } } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); //HttpContext.Current.Response.Write(ex.Message); } }
private void lst_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem) lst.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; ReportFilterGrid grd = objContainer.Parent.Parent as ReportFilterGrid; if ( row != null ) { // 04/25/2006 Paul. We always need to translate the items, even during postback. // This is because we always build the DropDownList. // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if ( L10n == null ) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } if ( row[sDATA_FIELD] != DBNull.Value ) { string sID = Sql.ToString(row["ID" ]); string sMODULE = Sql.ToString(row["MODULE_NAME"]); lst.ID = sDATA_FIELD + "_" + sID; try { if ( sDATA_FIELD == "MODULE_NAME" ) { XmlDocument xml = grd.Rdl; /* // 06/20/2006 Paul. New RdlDocument handles custom properties. string sRelationships = RdlUtil.GetCustomProperty(xml.DocumentElement, "Relationships"); if ( !Sql.IsEmptyString(sRelationships) ) { XmlDocument xmlRelationship = new XmlDocument(); xmlRelationship.LoadXml(sRelationships); dt = XmlUtil.CreateDataTable(xmlRelationship.DocumentElement, "Relationship", new string[] {"MODULE_NAME", "DISPLAY_NAME"}); lst.AutoPostBack = true; foreach ( DataRow rowRelationship in dt.Rows ) { lst.Items.Add(new ListItem(Sql.ToString(rowRelationship["DISPLAY_NAME"]), Sql.ToString(rowRelationship["MODULE_NAME"]))); } } */ } else if ( sDATA_FIELD == "DATA_FIELD" ) { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select ColumnName as NAME " + ControlChars.CrLf + " , ColumnName as DISPLAY_NAME " + ControlChars.CrLf + " from vwSqlColumns " + ControlChars.CrLf + " where ObjectName = @ObjectName " + ControlChars.CrLf + " and ColumnName not in ('ID', 'ID_C')" + ControlChars.CrLf + " and ColumnName not like '%_ID' " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; DropDownList lstMODULE_NAME = null; // 05/28/2006 Paul. Not sure why, but grd.FindFilterControl() does not work. foreach(DataGridItem itm in objContainer.Parent.Controls) { lstMODULE_NAME = itm.FindControl("MODULE_NAME" + "_" + sID) as DropDownList; if ( lstMODULE_NAME != null ) break; } string sMODULE_NAME = lstMODULE_NAME.SelectedValue; string[] arrModule = sMODULE_NAME.Split(' '); string sModule = arrModule[0]; string sTableAlias = arrModule[0]; if ( arrModule.Length > 1 ) sTableAlias = arrModule[1].ToUpper(); Sql.AddParameter(cmd, "@ObjectName", "vw" + sModule); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ( (IDbDataAdapter) da ).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); foreach ( DataRow rowColumn in dt.Rows ) { rowColumn["NAME" ] = sMODULE + "." + Sql.ToString(rowColumn["NAME"]); rowColumn["DISPLAY_NAME"] = L10n.Term(sModule + ".LBL_" + Sql.ToString(rowColumn["DISPLAY_NAME"])).Replace(":", ""); } DataView vwColumns = new DataView(dt); vwColumns.Sort = "DISPLAY_NAME"; foreach ( DataRowView rowColumn in vwColumns ) { lst.Items.Add(new ListItem(Sql.ToString(rowColumn["DISPLAY_NAME"]), Sql.ToString(rowColumn["NAME"]))); } } } } } } catch { } try { // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. if ( !objContainer.Page.IsPostBack ) { lst.SelectedValue = Sql.ToString(row[sDATA_FIELD]); } } catch { } } /* // 04/25/2006 Paul. Make sure to translate the text. // It cannot be translated in InstantiateIn() because the Page is not defined. foreach(ListItem itm in lst.Items ) { itm.Text = L10n.Term(itm.Text); } */ } }
// 11/12/2005 Paul. Not sure why, but Unified Search/Project List is not translating. public void L10nTranslate() { if ( !bTranslated ) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if ( L10n == null ) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } PagerStyle.PrevPageText = L10n.Term(PagerStyle.PrevPageText); PagerStyle.NextPageText = L10n.Term(PagerStyle.NextPageText); foreach(DataGridColumn col in Columns) { col.HeaderText = L10n.Term(col.HeaderText); } bTranslated = true; } }
private void OnDataBinding(object sender, EventArgs e) { Literal lbl = (Literal)sender; DataGridItem objContainer = (DataGridItem) lbl.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; if ( row != null ) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if ( L10n == null ) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } if ( L10n != null ) { if ( row[sDATA_FIELD] != DBNull.Value ) { string sList = sLIST_NAME; // 12/05/2005 Paul. The activity status needs to be dynamically converted to the correct list. if ( sLIST_NAME == "activity_status" ) { string sACTIVITY_TYPE = String.Empty; try { sACTIVITY_TYPE = Sql.ToString(row["ACTIVITY_TYPE"]); switch ( sACTIVITY_TYPE ) { case "Tasks" : sList = "task_status_dom" ; break; case "Meetings": sList = "meeting_status_dom"; break; case "Calls" : // 07/15/2006 Paul. Call status is translated externally. lbl.Text = Sql.ToString(row[sDATA_FIELD]); return; //sList = "call_status_dom" ; break; case "Notes" : // 07/15/2006 Paul. Note Status is not normally as it does not have a status. lbl.Text = L10n.Term(".activity_dom.Note"); return; // 06/15/2006 Paul. This list name for email_status does not follow the standard. case "Emails" : sList = "dom_email_status" ; break; // 04/21/2006 Paul. If the activity does not have a status (such as a Note), then use activity_dom. default : sList = "activity_dom" ; break; } } catch(Exception ex) { SplendidError.SystemWarning(new StackTrace(true).GetFrame(0), ex.Message); } } lbl.Text = Sql.ToString(L10n.Term("." + sList + ".", row[sDATA_FIELD])); } } else { lbl.Text = Sql.ToString(row[sDATA_FIELD]); } } else { lbl.Text = sDATA_FIELD; } }
private void lit_OnDataBinding(object sender, EventArgs e) { Literal lbl = (Literal)sender; DataGridItem objContainer = (DataGridItem) lbl.NamingContainer; // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if ( L10n == null ) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } lbl.Text = L10n.Term(sLABEL); }
protected void OnItemCreated(object sender, DataGridItemEventArgs e) { // 08/21/2006 Lawrence Zamorano. Add the record count to the pager control. // 08/21/2006 Paul. Enhance to include page range. if (e.Item.ItemType == ListItemType.Pager) { TableCell pgr = e.Item.Controls[0] as TableCell; DataView vw = this.DataSource as DataView; if (vw != null && vw.Count > 0) { // 08/21/2006 Paul. Grab references to the Prev and Next controls while we know their indexes. // 08/21/2006 Paul. The previous and next controls will either be a LinkButton if active, or a Label if inactive. LinkButton lnkPrev = pgr.Controls[0] as LinkButton; LinkButton lnkNext = pgr.Controls[2] as LinkButton; Label lblPrev = pgr.Controls[0] as Label; Label lblNext = pgr.Controls[2] as Label; L10N L10n = HttpContext.Current.Items["L10n"] as L10N; string sOf = L10n.Term(".LBL_LIST_OF"); int nPageStart = this.CurrentPageIndex * this.PageSize + 1; int nPageEnd = Math.Min((this.CurrentPageIndex + 1) * this.PageSize, vw.Count); LiteralControl litPageRange = new LiteralControl(); litPageRange.Text = String.Format(" <span class=\"pageNumbers\">({0} - {1} {2} {3})</span> ", nPageStart, nPageEnd, sOf, vw.Count); pgr.Controls.AddAt(1, litPageRange); string sThemeURL = Sql.ToString(HttpContext.Current.Session["themeURL"]); if (lblPrev != null) { lblPrev.Text = "<img src=\"" + sThemeURL + "images/previous_off.gif" + "\" border=\"0\" height=\"10\" width=\"6\" /> " + lblPrev.Text; } if (lnkPrev != null) { lnkPrev.Text = "<img src=\"" + sThemeURL + "images/previous.gif" + "\" border=\"0\" height=\"10\" width=\"6\" /> " + lnkPrev.Text; //LinkButton lnkStart = new LinkButton(); //lnkStart.CommandArgument = "1"; //lnkStart.CommandName = "Page"; //lnkStart.Text = "<img src=\"" + sThemeURL + "images/start.gif" + "\" border=\"0\" height=\"10\" width=\"11\" /> " + L10n.Term(".LNK_LIST_START") + " "; //pgr.Controls.AddAt(0, lnkStart); } if (lblNext != null) { lblNext.Text = lblNext.Text + " <img src=\"" + sThemeURL + "images/next_off.gif" + "\" border=\"0\" height=\"10\" width=\"6\" />"; } if (lnkNext != null) { lnkNext.Text = lnkNext.Text + " <img src=\"" + sThemeURL + "images/next.gif" + "\" border=\"0\" height=\"10\" width=\"6\" />"; //LinkButton lnkEnd = new LinkButton(); //lnkEnd.CommandArgument = this.PageCount.ToString(); //lnkEnd.CommandName = "Page"; //lnkEnd.Text = " " + L10n.Term(".LNK_LIST_END") + " <img src=\"" + sThemeURL + "images/end.gif" + "\" border=\"0\" height=\"10\" width=\"11\" />"; //pgr.Controls.Add(lnkEnd); } } } else if (e.Item.ItemType == ListItemType.Header) { // 06/09/2006 Paul. Move the translation to overridden DataBind. //L10nTranslate(); // 11/21/2005 Paul. The header cells should never wrap, the background image was not designed to wrap. foreach (TableCell cell in e.Item.Cells) { cell.Wrap = false; } HttpSessionState Session = HttpContext.Current.Session; string sLastSortColumn = (string)ViewState["LastSortColumn"]; string sLastSortOrder = (string)ViewState["LastSortOrder"]; // 08/28/2006 Paul. We need to watch for overflow. This has occurred when a grid was created with no columns. for (int i = 0; i < e.Item.Controls.Count && i < this.Columns.Count; i++) { // 11/13/2005 Paul. If sorting is not enabled, this code will cause the header text to disappear. if (this.AllowSorting && !Sql.IsEmptyString(Columns[i].SortExpression)) { Image img = new Image(); img.Width = 8; img.Height = 10; if (Columns[i].SortExpression == sLastSortColumn) { if (sLastSortOrder == "asc") { img.ImageUrl = Session["themeURL"] + "images/arrow_down.gif"; } else { img.ImageUrl = Session["themeURL"] + "images/arrow_up.gif"; } } else { img.ImageUrl = Session["themeURL"] + "images/arrow.gif"; } Literal lit = new Literal(); lit.Text = " "; e.Item.Cells[i].Controls.Add(lit); e.Item.Cells[i].Controls.Add(img); } } } else if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // 09/05/2005 Paul. Reducing viewstate data in a table can be done at the row level. // This will provide a major performance benefit while not loosing the ability to sort a grid. // http://authors.aspalliance.com/jimross/Articles/DatagridDietPartTwo.aspx // 10/13/2005 Paul. Can't disable the content otherwise the data is not retained during certain postback operations. //e.Item.EnableViewState = false; } }
private void lst_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem) lst.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; if ( row != null ) { string sMODULE_NAME = Sql.ToString(row["MODULE_NAME"]); // 04/25/2006 Paul. We could use GUIDS like SugarCRM, but since there is only one ACL grid, // there is no need for that kind of uniqueness. // 04/25/2006 Paul. toggleDisplay() will automatically reverse toggle of a linked control. divList.ID = sMODULE_NAME + "_" + sACCESS_TYPE; lst.ID = "lst" + sMODULE_NAME + "_" + sACCESS_TYPE; // 04/25/2006 Paul. OnChange, update the the innerHTML and the hidden field. lst.Attributes.Add("onchange", "document.getElementById('" + divLabel.ClientID + "').innerHTML=this.options[this.selectedIndex].text; document.getElementById('" + hid.ClientID + "').value=document.getElementById('" + divLabel.ClientID + "').innerHTML; toggleDisplay('" + divList.ClientID + "');"); // 04/25/2006 Paul. The first parent is the DIV, the second is the TableCell. TableCell td = divList.Parent as TableCell; if ( td != null ) td.Attributes.Add("ondblclick", "toggleDisplay('" + divList.ClientID + "')"); if ( row[sDATA_FIELD] != DBNull.Value ) { int nACCESS = Sql.ToInteger(row[sDATA_FIELD]); lst.Attributes.Add("class", AccessClassName(sACCESS_TYPE, nACCESS)); try { // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. if ( !objContainer.Page.IsPostBack ) { lst.SelectedValue = NormalizeAccessValue(sACCESS_TYPE, nACCESS).ToString(); } } catch { } } // 04/25/2006 Paul. We always need to translate the items, even during postback. // This is because we always build the DropDownList. // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if ( L10n == null ) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } // 04/25/2006 Paul. Make sure to translate the text. // It cannot be translated in InstantiateIn() because the Page is not defined. foreach(ListItem itm in lst.Items ) { itm.Text = L10n.Term(itm.Text); } } }
private void lst_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem)lst.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; ReportFilterGrid grd = objContainer.Parent.Parent as ReportFilterGrid; if (row != null) { // 04/25/2006 Paul. We always need to translate the items, even during postback. // This is because we always build the DropDownList. // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if (L10n == null) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } if (row[sDATA_FIELD] != DBNull.Value) { string sID = Sql.ToString(row["ID"]); string sMODULE = Sql.ToString(row["MODULE_NAME"]); lst.ID = sDATA_FIELD + "_" + sID; try { if (sDATA_FIELD == "MODULE_NAME") { XmlDocument xml = grd.Rdl; /* * // 06/20/2006 Paul. New RdlDocument handles custom properties. * string sRelationships = RdlUtil.GetCustomProperty(xml.DocumentElement, "Relationships"); * if ( !Sql.IsEmptyString(sRelationships) ) * { * XmlDocument xmlRelationship = new XmlDocument(); * xmlRelationship.LoadXml(sRelationships); * dt = XmlUtil.CreateDataTable(xmlRelationship.DocumentElement, "Relationship", new string[] {"MODULE_NAME", "DISPLAY_NAME"}); * lst.AutoPostBack = true; * foreach ( DataRow rowRelationship in dt.Rows ) * { * lst.Items.Add(new ListItem(Sql.ToString(rowRelationship["DISPLAY_NAME"]), Sql.ToString(rowRelationship["MODULE_NAME"]))); * } * } */ } else if (sDATA_FIELD == "DATA_FIELD") { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using (IDbConnection con = dbf.CreateConnection()) { con.Open(); string sSQL; sSQL = "select ColumnName as NAME " + ControlChars.CrLf + " , ColumnName as DISPLAY_NAME " + ControlChars.CrLf + " from vwSqlColumns " + ControlChars.CrLf + " where ObjectName = @ObjectName " + ControlChars.CrLf + " and ColumnName not in ('ID', 'ID_C')" + ControlChars.CrLf + " and ColumnName not like '%_ID' " + ControlChars.CrLf; using (IDbCommand cmd = con.CreateCommand()) { cmd.CommandText = sSQL; DropDownList lstMODULE_NAME = null; // 05/28/2006 Paul. Not sure why, but grd.FindFilterControl() does not work. foreach (DataGridItem itm in objContainer.Parent.Controls) { lstMODULE_NAME = itm.FindControl("MODULE_NAME" + "_" + sID) as DropDownList; if (lstMODULE_NAME != null) { break; } } string sMODULE_NAME = lstMODULE_NAME.SelectedValue; string[] arrModule = sMODULE_NAME.Split(' '); string sModule = arrModule[0]; string sTableAlias = arrModule[0]; if (arrModule.Length > 1) { sTableAlias = arrModule[1].ToUpper(); } Sql.AddParameter(cmd, "@ObjectName", "vw" + sModule); using (DbDataAdapter da = dbf.CreateDataAdapter()) { ((IDbDataAdapter)da).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); foreach (DataRow rowColumn in dt.Rows) { rowColumn["NAME"] = sMODULE + "." + Sql.ToString(rowColumn["NAME"]); rowColumn["DISPLAY_NAME"] = L10n.Term(sModule + ".LBL_" + Sql.ToString(rowColumn["DISPLAY_NAME"])).Replace(":", ""); } DataView vwColumns = new DataView(dt); vwColumns.Sort = "DISPLAY_NAME"; foreach (DataRowView rowColumn in vwColumns) { lst.Items.Add(new ListItem(Sql.ToString(rowColumn["DISPLAY_NAME"]), Sql.ToString(rowColumn["NAME"]))); } } } } } } catch { } try { // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. if (!objContainer.Page.IsPostBack) { lst.SelectedValue = Sql.ToString(row[sDATA_FIELD]); } } catch { } } /* * // 04/25/2006 Paul. Make sure to translate the text. * // It cannot be translated in InstantiateIn() because the Page is not defined. * foreach(ListItem itm in lst.Items ) * { * itm.Text = L10n.Term(itm.Text); * } */ } }
public error_value relate_note_to_module(string session, string note_id, string module_name, string module_id) { Guid gUSER_ID = GetSessionUserID(session); Guid gNOTE_ID = Sql.ToGuid(note_id); string sPARENT_TYPE = module_name; Guid gPARENT_ID = Guid.Empty; Guid gCONTACT_ID = Guid.Empty; if ( String.Compare(sPARENT_TYPE, "Contacts", true) == 0 ) gCONTACT_ID = Sql.ToGuid(module_id); else gPARENT_ID = Sql.ToGuid(module_id); int nACLACCESS = Security.GetUserAccess("Notes", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } error_value results = new error_value(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwNOTES_Edit" + ControlChars.CrLf + " where ID = @ID " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", gNOTE_ID); using ( IDataReader rdr = cmd.ExecuteReader() ) { if ( rdr.Read() ) { string sNAME = Sql.ToString(rdr["NAME" ]); string sDESCRIPTION = Sql.ToString(rdr["DESCRIPTION" ]); // 09/01/2006 Paul. Notes do not have an ASSIGNED_USER_ID. Guid gASSIGNED_USER_ID = Guid.Empty; // Sql.ToGuid (rdr["ASSIGNED_USER_ID"]); if ( nACLACCESS != ACL_ACCESS.OWNER || (nACLACCESS == ACL_ACCESS.OWNER && gASSIGNED_USER_ID == gUSER_ID) ) { SqlProcs.spNOTES_Update ( ref gNOTE_ID , sNAME , sPARENT_TYPE , gPARENT_ID , gCONTACT_ID , sDESCRIPTION , Sql.ToGuid(rdr["TEAM_ID"]) ); } } } } } return results; }
public string create_lead(string user_name, string password, string first_name, string last_name, string email_address) { Guid gUSER_ID = LoginUser(user_name, password); int nACLACCESS = Security.GetUserAccess("Leads", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } Guid gID = Guid.Empty; SqlProcs.spLEADS_New(ref gID, first_name, last_name, String.Empty, email_address); return "1"; }
public set_entry_result set_entry(string session, string module_name, name_value[] name_value_list) { Guid gUSER_ID = GetSessionUserID(session); Guid gTIMEZONE = Sql.ToGuid(HttpContext.Current.Cache.Get("soap.user.timezone." + gUSER_ID.ToString())); TimeZone T10n = TimeZone.CreateTimeZone(gTIMEZONE); string sTABLE_NAME = VerifyModuleName(module_name); int nACLACCESS = Security.GetUserAccess(module_name, "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } set_entry_result results = new set_entry_result(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); // 02/21/2006 Paul. Delete operations come in as set_entry with deleted = 1. if ( DeleteEntry(name_value_list) ) { IDbCommand cmdDelete = SqlProcs.Factory(con, "sp" + sTABLE_NAME + "_Delete"); // 10/10/2006 Paul. Use IDbDataParameter to be consistent. foreach(IDbDataParameter par in cmdDelete.Parameters) { par.Value = DBNull.Value; } Sql.SetParameter(cmdDelete, "@MODIFIED_USER_ID", gUSER_ID.ToString()); Guid gID = FindID(name_value_list); if ( gID != Guid.Empty ) { Sql.SetParameter(cmdDelete, "@ID", gID.ToString()); cmdDelete.ExecuteNonQuery(); } } else { IDbCommand cmdUpdate = SqlProcs.Factory(con, "sp" + sTABLE_NAME + "_Update"); IDbDataParameter parID = Sql.FindParameter(cmdUpdate, "@ID"); // 10/10/2006 Paul. Use IDbDataParameter to be consistent. foreach(IDbDataParameter par in cmdUpdate.Parameters) { par.Value = DBNull.Value; } // 08/31/2006 Paul. We need to initialize the values of any fields not provided. // The stored procedure always updates all fields, so we need to make sure not to clear fields that are not provided. // This problem was first noticed when the Outlook Plug-in kept clearing the ASSIGNED_USER_ID field. Guid gID = FindID(name_value_list); if ( gID != Guid.Empty ) { // 08/31/2006 Paul. If the ID is not found, then this must be a new InitializeParameters(con, sTABLE_NAME, gID, cmdUpdate); } Sql.SetParameter(cmdUpdate, "@MODIFIED_USER_ID", gUSER_ID.ToString()); for ( int j = 0; j < name_value_list.Length; j++ ) { // 04/04/2006 Paul. DATE_START & TIME_START need to be combined into DATE_TIME. if ( name_value_list[j].name.ToUpper() == "TIME_START" ) { // 04/04/2006 Paul. Modules that have a TIME_START field are MEETINGS, CALLS, TASKS, EMAILS, EMAIL_MARKETING, PROJECT_TASK string sDateTime = EntryDateTime(name_value_list, "DATE_START", "TIME_START"); if ( sTABLE_NAME == "TASKS" || sTABLE_NAME == "PROJECT_TASK" ) { Sql.SetParameter(cmdUpdate, "@DATE_TIME_START", T10n.ToServerTimeFromUniversalTime(sDateTime)); } else { Sql.SetParameter(cmdUpdate, "@DATE_TIME", T10n.ToServerTimeFromUniversalTime(sDateTime)); } } // 04/04/2006 Paul. DATE_DUE & TIME_DUE need to be combined into DATE_TIME_DUE. else if ( name_value_list[j].name.ToUpper() == "TIME_DUE" ) { // 04/04/2006 Paul. Modules that have a TIME_DUE field are TASKS, PROJECT_TASK string sDateTime = EntryDateTime(name_value_list, "DATE_DUE", "TIME_DUE"); Sql.SetParameter(cmdUpdate, "@DATE_TIME_DUE", T10n.ToServerTimeFromUniversalTime(sDateTime)); } else { Sql.SetParameter(cmdUpdate, "@" + name_value_list[j].name, name_value_list[j].value); } } cmdUpdate.ExecuteNonQuery(); if ( parID != null ) { results.id = Sql.ToString(parID.Value); } } } return results; }
public static XmlDocument InitUserPreferences(string sUSER_PREFERENCES) { XmlDocument xml = null; try { xml = new XmlDocument(); if (!sUSER_PREFERENCES.StartsWith("<?xml ")) { sUSER_PREFERENCES = XmlUtil.ConvertFromPHP(sUSER_PREFERENCES); } xml.LoadXml(sUSER_PREFERENCES); HttpApplicationState Application = HttpContext.Current.Application; string sCulture = L10N.NormalizeCulture(XmlUtil.SelectSingleNode(xml, "culture")); string sTheme = XmlUtil.SelectSingleNode(xml, "theme"); string sDateFormat = XmlUtil.SelectSingleNode(xml, "dateformat"); string sTimeFormat = XmlUtil.SelectSingleNode(xml, "timeformat"); string sTimeZone = XmlUtil.SelectSingleNode(xml, "timezone"); string sCurrencyID = XmlUtil.SelectSingleNode(xml, "currency_id"); if (Sql.IsEmptyString(sCulture)) { XmlUtil.SetSingleNode(xml, "culture", SplendidDefaults.Culture()); } if (Sql.IsEmptyString(sTheme)) { XmlUtil.SetSingleNode(xml, "theme", SplendidDefaults.Theme()); } if (Sql.IsEmptyString(sDateFormat)) { XmlUtil.SetSingleNode(xml, "dateformat", SplendidDefaults.DateFormat()); } // 11/12/2005 Paul. "m" is not valid for .NET month formatting. Must use MM. // 11/12/2005 Paul. Require 4 digit year. Otherwise default date in Pipeline of 12/31/2100 would get converted to 12/31/00. if (SplendidDefaults.IsValidDateFormat(sDateFormat)) { XmlUtil.SetSingleNode(xml, "dateformat", SplendidDefaults.DateFormat(sDateFormat)); } if (Sql.IsEmptyString(sTimeFormat)) { XmlUtil.SetSingleNode(xml, "timeformat", SplendidDefaults.TimeFormat()); } if (Sql.IsEmptyString(sCurrencyID)) { XmlUtil.SetSingleNode(xml, "currency_id", SplendidDefaults.CurrencyID()); } // 09/01/2006 Paul. Only use timez if provided. Otherwise we will default to GMT. if (Sql.IsEmptyString(sTimeZone) && !Sql.IsEmptyString(XmlUtil.SelectSingleNode(xml, "timez"))) { int nTimez = Sql.ToInteger(XmlUtil.SelectSingleNode(xml, "timez")); sTimeZone = SplendidDefaults.TimeZone(nTimez); XmlUtil.SetSingleNode(xml, "timezone", sTimeZone); } // 09/01/2006 Paul. Default TimeZone was not getting set properly. if (Sql.IsEmptyString(sTimeZone)) { sTimeZone = SplendidDefaults.TimeZone(); XmlUtil.SetSingleNode(xml, "timezone", sTimeZone); } } catch (Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); } return(xml); }
public error_value set_relationship(string session, set_relationship_value set_relationship_value) { Guid gUSER_ID = GetSessionUserID(session); // 02/16/2006 Paul. Don't need to verify the modules as it will be done inside SetRelationship(); //VerifyModuleName(set_relationship_value.module1); //VerifyModuleName(set_relationship_value.module2); int nACLACCESS = Security.GetUserAccess(set_relationship_value.module1, "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } error_value results = new error_value(); SetRelationship(set_relationship_value.module1, set_relationship_value.module1_id, set_relationship_value.module2, set_relationship_value.module2_id); return results; }
public static void Export(DataView vw, string sModuleName, string sExportFormat, string sExportRange, int nCurrentPage, int nPageSize, string[] arrID) { int nStartRecord = 0; int nEndRecord = vw.Count; switch (sExportRange) { case "Page": nStartRecord = nCurrentPage * nPageSize; nEndRecord = Math.Min(nStartRecord + nPageSize, vw.Count); break; case "Selected": { // 10/17/2006 Paul. There must be one selected record to continue. if (arrID == null) { L10N L10n = HttpContext.Current.Items["L10n"] as L10N; throw(new Exception(L10n.Term(".LBL_LISTVIEW_NO_SELECTED"))); } StringBuilder sbIDs = new StringBuilder(); int nCount = 0; foreach (string item in arrID) { if (nCount > 0) { sbIDs.Append(" or "); } sbIDs.Append("ID = \'" + item.Replace("\'", "\'\'") + "\'" + ControlChars.CrLf); nCount++; } //vw.RowFilter = "ID in (" + sbIDs.ToString() + ")"; // 11/03/2006 Paul. A filter might already exist, so make sure to maintain the existing filter. if (vw.RowFilter.Length > 0) { vw.RowFilter = " and (" + sbIDs.ToString() + ")"; } else { vw.RowFilter = sbIDs.ToString(); } nEndRecord = vw.Count; break; } } HttpResponse Response = HttpContext.Current.Response; StringBuilder sb = new StringBuilder(); switch (sExportFormat) { case "csv": Response.ContentType = "text/csv"; Response.AddHeader("Content-Disposition", "attachment;filename=" + sModuleName + ".csv"); ExportDelimited(Response.OutputStream, vw, sModuleName.ToLower(), nStartRecord, nEndRecord, ','); Response.End(); break; case "tab": Response.ContentType = "text/txt"; Response.AddHeader("Content-Disposition", "attachment;filename=" + sModuleName + ".txt"); ExportDelimited(Response.OutputStream, vw, sModuleName.ToLower(), nStartRecord, nEndRecord, '\t'); Response.End(); break; case "xml": Response.ContentType = "text/xml"; Response.AddHeader("Content-Disposition", "attachment;filename=" + sModuleName + ".xml"); ExportXml(Response.OutputStream, vw, sModuleName.ToLower(), nStartRecord, nEndRecord); Response.End(); break; //case "Excel": default: Response.ContentType = "application/vnd.ms-excel"; Response.AddHeader("Content-Disposition", "attachment;filename=" + sModuleName + ".xlb"); ExportExcel(Response.OutputStream, vw, sModuleName.ToLower(), nStartRecord, nEndRecord); Response.End(); break; } //vw.RowFilter = null; }
public get_entry_list_result_encoded sync_get_modified_relationships(string session, string module_name, string related_module, string from_date, string to_date, int offset, int max_results, int deleted, string module_id, string[] select_fields, string[] ids, string relationship_name, string deletion_date, int php_serialize) { Guid gUSER_ID = GetSessionUserID(session); Guid gTIMEZONE = Sql.ToGuid(HttpContext.Current.Cache.Get("soap.user.timezone." + gUSER_ID.ToString())); TimeZone T10n = TimeZone.CreateTimeZone(gTIMEZONE); string sTABLE_NAME = VerifyModuleName(module_name ); int nACLACCESS = Security.GetUserAccess(module_name, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } sTABLE_NAME = VerifyModuleName(related_module); nACLACCESS = Security.GetUserAccess(related_module, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } get_entry_list_result_encoded results = new get_entry_list_result_encoded(); results.error.name = "not supported"; results.error.number = "-1"; results.error.description = "sync_get_modified_relationships is not supported at this time"; return results; }
public get_entry_result get_entry(string session, string module_name, string id, string[] select_fields) { Guid gUSER_ID = GetSessionUserID(session); string sTABLE_NAME = VerifyModuleName(module_name); int nACLACCESS = Security.GetUserAccess(module_name, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } get_entry_result results = new get_entry_result(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select *" + ControlChars.CrLf + " from " + sTABLE_NAME + ControlChars.CrLf + " where ID = @ID" + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@ID", id); if ( nACLACCESS == ACL_ACCESS.OWNER ) { // 09/01/2006 Paul. Notes do not have an ASSIGNED_USER_ID. if ( sTABLE_NAME != "NOTES" ) Sql.AppendParameter(cmd, gUSER_ID, "ASSIGNED_USER_ID"); } try { using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); if ( dt.Rows.Count > 0 ) { // 02/20/2006 Paul. First initialize the array. results.field_list = new field [select_fields.Length]; results.entry_list = new entry_value[select_fields.Length]; DataRow row = dt.Rows[0]; for ( int i=0; i < select_fields.Length; i++ ) { string sColumnName = select_fields[i]; DataColumn col = dt.Columns[sColumnName]; // 02/20/2006 Paul. Then initialize each element in the array. // varchar, bool, datetime, int, text, blob results.field_list[i] = new field(sColumnName.ToLower(), col.DataType.ToString(), sColumnName, 0); // 02/20/2006 Paul. Then initialize each element in the array. results.entry_list[i] = new entry_value(id, module_name, sColumnName, Sql.ToString(row[sColumnName])); } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw(new Exception("SOAP: Failed contact_by_email", ex)); } } } return results; }
public string create_lead(string user_name, string password, string first_name, string last_name, string email_address) { // 03/12/2007 Paul. If using NTLM, then user_name will be updated with value from Identity object. Guid gUSER_ID = LoginUser(ref user_name, password); int nACLACCESS = Security.GetUserAccess("Leads", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } Guid gID = Guid.Empty; SqlProcs.spLEADS_New(ref gID, first_name, last_name, String.Empty, email_address); return "1"; }
public contact_detail[] contact_by_email(string user_name, string password, string email_address) { // 03/12/2007 Paul. If using NTLM, then user_name will be updated with value from Identity object. Guid gUSER_ID = LoginUser(ref user_name, password); int nACLACCESS = Security.GetUserAccess("Contacts", "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } contact_detail[] results = new contact_detail[0]; DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select * " + ControlChars.CrLf + " from vwSOAP_Contact_By_Email" + ControlChars.CrLf + " where 1 = 0 " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; // 12/29/2005 Paul. Allow multiple email addresses, separated by a semicolon. email_address = email_address.Replace(" ", ""); string[] aAddresses = email_address.Split(';'); // 02/20/2006 Paul. Need to use the IN clause. Sql.AppendParameter(cmd, aAddresses, "EMAIL1", true); Sql.AppendParameter(cmd, aAddresses, "EMAIL2", true); if ( nACLACCESS == ACL_ACCESS.OWNER ) { Sql.AppendParameter(cmd, gUSER_ID, "ASSIGNED_USER_ID"); } try { using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); if ( dt.Rows.Count > 0 ) { // 02/20/2006 Paul. First initialize the array. results = new contact_detail[dt.Rows.Count]; for ( int i=0; i < dt.Rows.Count ; i++ ) { // 02/20/2006 Paul. Then initialize each element in the array. results[i] = new contact_detail(); results[i].email_address = Sql.ToString(dt.Rows[i]["EMAIL_ADDRESS"]); results[i].name1 = Sql.ToString(dt.Rows[i]["NAME1" ]); results[i].name2 = Sql.ToString(dt.Rows[i]["NAME2" ]); results[i].association = Sql.ToString(dt.Rows[i]["ASSOCIATION" ]); results[i].id = Sql.ToString(dt.Rows[i]["ID" ]); results[i].type = Sql.ToString(dt.Rows[i]["TYPE" ]); results[i].msi_id = (i+1).ToString(); } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw(new Exception("SOAP: Failed contact_by_email", ex)); } } } return results; }
public get_entry_result get_entries(string session, string module_name, string[] ids, string[] select_fields) { Guid gUSER_ID = GetSessionUserID(session); Guid gTIMEZONE = Sql.ToGuid(HttpContext.Current.Cache.Get("soap.user.timezone." + gUSER_ID.ToString())); TimeZone T10n = TimeZone.CreateTimeZone(gTIMEZONE); string sTABLE_NAME = VerifyModuleName(module_name); int nACLACCESS = Security.GetUserAccess(module_name, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } get_entry_result results = new get_entry_result(); // 02/19/2006 Paul. Exit early if nothing to get. We need to prevent fetching all recods. if ( ids.Length == 0 ) return results; DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; // 02/16/2006 Paul. Convert the table name to a VIEW. We can do this because we don't want deleted records. // 02/18/2006 Paul. Use the Edit view as it will include description, content, etc. sSQL = "select *" + ControlChars.CrLf + " from vw" + sTABLE_NAME + "_Edit" + ControlChars.CrLf + " where 1 = 1" + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; // 02/19/2006 Paul. Need to filter by the IDs povided. Sql.AppendParameter(cmd, ids, "ID"); if ( nACLACCESS == ACL_ACCESS.OWNER ) { // 09/01/2006 Paul. Notes do not have an ASSIGNED_USER_ID. if ( sTABLE_NAME != "NOTES" ) Sql.AppendParameter(cmd, gUSER_ID, "ASSIGNED_USER_ID"); } try { CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); if ( dt.Rows.Count > 0 ) { // 02/20/2006 Paul. First initialize the array. results.field_list = new field [select_fields.Length]; results.entry_list = new entry_value[dt.Rows.Count]; for ( int i=0; i < select_fields.Length; i++ ) { string sColumnName = select_fields[i]; DataColumn col = dt.Columns[sColumnName]; // 02/21/2006 Paul. Column may not exist. For example, we don't return a MEETINGS.TIME_START. if ( col != null ) { // 02/20/2006 Paul. Then initialize each element in the array. // 02/16/2006 Paul. We don't have a mapping for the labels, so just return the column name. // varchar, bool, datetime, int, text, blob results.field_list[i] = new field(sColumnName.ToLower(), col.DataType.ToString(), sColumnName, 0); } } // 02/16/2006 Paul. SugarCRM 3.5.1 returns all fields even though only a few were requested. We will do the same. int nItem = 0; foreach ( DataRow row in dt.Rows ) { // 02/20/2006 Paul. Then initialize each element in the array. results.entry_list[nItem] = new entry_value(); results.entry_list[nItem].id = Sql.ToGuid(row["ID"]).ToString(); results.entry_list[nItem].module_name = module_name; // 02/20/2006 Paul. First initialize the array. results.entry_list[nItem].name_value_list = new name_value[dt.Columns.Count]; int nColumn = 0; foreach ( DataColumn col in dt.Columns ) { // 02/20/2006 Paul. Then initialize each element in the array. // 08/17/2006 Paul. We need to convert all dates to UniversalTime. if ( Information.IsDate(row[col.ColumnName]) ) { // 08/17/2006 Paul. The time on the server and the time in the database are both considered ServerTime. DateTime dtServerTime = Sql.ToDateTime(row[col.ColumnName]); // 08/17/2006 Paul. We need a special function to convert to UniversalTime because it might already be in UniversalTime, based on m_bGMTStorage flag. DateTime dtUniversalTime = T10n.ToUniversalTimeFromServerTime(dtServerTime); results.entry_list[nItem].name_value_list[nColumn] = new name_value(col.ColumnName.ToLower(), dtUniversalTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat)); } else { results.entry_list[nItem].name_value_list[nColumn] = new name_value(col.ColumnName.ToLower(), Sql.ToString(row[col.ColumnName])); } nColumn++; } nItem++; } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw(new Exception("SOAP: Failed get_entries", ex)); } } } return results; }
public L10N GetL10n() { // 08/30/2005 Paul. Attempt to get the L10n & T10n objects from the parent page. // If that fails, then just create them because they are required. if ( L10n == null ) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. // A port to DNN prompted this approach. L10n = Context.Items["L10n"] as L10N; if ( L10n == null ) { string sCULTURE = Sql.ToString(Session["USER_SETTINGS/CULTURE" ]); L10n = new L10N(sCULTURE); } } return L10n; }
public get_entry_list_result get_entry_list(string session, string module_name, string query, string order_by, int offset, string[] select_fields, int max_results, int deleted) { Guid gUSER_ID = GetSessionUserID(session); Guid gTIMEZONE = Sql.ToGuid(HttpContext.Current.Cache.Get("soap.user.timezone." + gUSER_ID.ToString())); TimeZone T10n = TimeZone.CreateTimeZone(gTIMEZONE); if ( offset < 0 ) throw(new Exception("offset must be a non-negative number")); if ( max_results <= 0 ) throw(new Exception("max_results must be a postive number")); string sTABLE_NAME = VerifyModuleName(module_name); query = query.ToUpper(); order_by = order_by.ToUpper(); query = query .Replace(sTABLE_NAME + ".", String.Empty); order_by = order_by.Replace(sTABLE_NAME + ".", String.Empty); int nACLACCESS = Security.GetUserAccess(module_name, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } get_entry_list_result results = new get_entry_list_result(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select *" + ControlChars.CrLf + " from " + sTABLE_NAME + ControlChars.CrLf + " where DELETED = @DELETED" + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { if ( !Sql.IsEmptyString(query) ) { // 02/16/2006 Paul. As much as I dislike the idea of allowing a query string, // I don't have the time to parse this. // 03/08/2006 Paul. Prepend the AND clause. sSQL += " and " + query + ControlChars.CrLf; } cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@DELETED", Math.Min(deleted, 1)); if ( nACLACCESS == ACL_ACCESS.OWNER ) { // 09/01/2006 Paul. Notes do not have an ASSIGNED_USER_ID. if ( sTABLE_NAME != "NOTES" ) Sql.AppendParameter(cmd, gUSER_ID, "ASSIGNED_USER_ID"); } try { CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); if ( dt.Rows.Count > 0 ) { // 02/16/2006 Paul. Don't sort in the database as it provides a hacker another attempt at SQL-Injection. // Bad sort values will just throw an exception here. DataView dv = new DataView(dt); dv.Sort = order_by; results.result_count = Math.Min(dt.Rows.Count - offset, max_results); results.next_offset = offset + results.result_count; // 02/20/2006 Paul. First initialize the array. results.field_list = new field [select_fields.Length]; results.entry_list = new entry_value[results.result_count]; for ( int i=0; i < select_fields.Length; i++ ) { string sColumnName = select_fields[i]; DataColumn col = dt.Columns[sColumnName]; // 02/20/2006 Paul. Then initialize each element in the array. // 02/16/2006 Paul. We don't have a mapping for the labels, so just return the column name. // varchar, bool, datetime, int, text, blob results.field_list[i] = new field(sColumnName.ToLower(), col.DataType.ToString(), sColumnName, 0); } // 02/16/2006 Paul. SugarCRM 3.5.1 returns all fields even though only a few were requested. We will do the same. int j = 0; foreach ( DataRowView row in dv ) { if ( j >= offset && j < offset + results.result_count ) { int nItem = j - offset; // 02/20/2006 Paul. Then initialize each element in the array. results.entry_list[nItem] = new entry_value(); results.entry_list[nItem].id = Sql.ToGuid(row["ID"]).ToString(); results.entry_list[nItem].module_name = module_name; // 02/20/2006 Paul. First initialize the array. results.entry_list[nItem].name_value_list = new name_value[dt.Columns.Count]; int nColumn = 0; foreach ( DataColumn col in dt.Columns ) { // 02/20/2006 Paul. Then initialize each element in the array. // 08/17/2006 Paul. We need to convert all dates to UniversalTime. if ( Information.IsDate(row[col.ColumnName]) ) { // 08/17/2006 Paul. The time on the server and the time in the database are both considered ServerTime. DateTime dtServerTime = Sql.ToDateTime(row[col.ColumnName]); // 08/17/2006 Paul. We need a special function to convert to UniversalTime because it might already be in UniversalTime, based on m_bGMTStorage flag. DateTime dtUniversalTime = T10n.ToUniversalTimeFromServerTime(dtServerTime); results.entry_list[nItem].name_value_list[nColumn] = new name_value(col.ColumnName.ToLower(), dtUniversalTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat)); } else { results.entry_list[nItem].name_value_list[nColumn] = new name_value(col.ColumnName.ToLower(), Sql.ToString(row[col.ColumnName])); } nColumn++; } } j++; } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw(new Exception("SOAP: Failed get_entry_list", ex)); } } } return results; }
public static DataTable List(string sListName) { System.Web.Caching.Cache Cache = HttpContext.Current.Cache; L10N L10n = new L10N(HttpContext.Current.Session["USER_SETTINGS/CULTURE"] as string); DataTable dt = Cache.Get(L10n.NAME + "." + sListName) as DataTable; if ( dt == null ) { try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; // 10/13/2005 Paul. Use distinct because the same list appears to be duplicated in various modules. // appointment_filter_dom is in an Activities and a History module. // ORDER BY items must appear in the select list if SELECT DISTINCT is specified. sSQL = "select distinct " + ControlChars.CrLf + " NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " , LIST_ORDER " + ControlChars.CrLf + " from vwTERMINOLOGY " + ControlChars.CrLf + " where lower(LIST_NAME) = @LIST_NAME" + ControlChars.CrLf // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. + " and lower(LANG ) = @LANG " + ControlChars.CrLf // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. + " order by LIST_ORDER " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. Sql.AddParameter(cmd, "@LIST_NAME", sListName.ToLower()); Sql.AddParameter(cmd, "@LANG" , L10n.NAME.ToLower()); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); Cache.Insert(L10n.NAME + "." + sListName, dt, null, DefaultCacheExpiration(), Cache.NoSlidingExpiration); } } // 12/03/2005 Paul. Most lists require data, so if the language-specific list does not exist, just use English. if ( dt.Rows.Count == 0 ) { if ( String.Compare(L10n.NAME, "en-US", true) != 0 ) { using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. Sql.AddParameter(cmd, "@LIST_NAME", sListName.ToLower()); Sql.AddParameter(cmd, "@LANG" , "en-US" .ToLower()); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); Cache.Insert(L10n.NAME + "." + sListName, dt, null, DefaultCacheExpiration(), Cache.NoSlidingExpiration); } } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); // 10/16/2005 Paul. Ignore list errors. // 03/30/2006 Paul. IBM DB2 is returning an error, which is causing a data-binding error. // SQL1585N A system temporary table space with sufficient page size does not exist. // 03/30/2006 Paul. In case of error, we should return NULL. return null; } } return dt; }
public get_relationships_result get_relationships(string session, string module_name, string module_id, string related_module, string related_module_query, int deleted) { Guid gUSER_ID = GetSessionUserID(session); Guid gTIMEZONE = Sql.ToGuid(HttpContext.Current.Cache.Get("soap.user.timezone." + gUSER_ID.ToString())); TimeZone T10n = TimeZone.CreateTimeZone(gTIMEZONE); string sTABLE_NAME = VerifyModuleName(module_name ); int nACLACCESS = Security.GetUserAccess(module_name, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } sTABLE_NAME = VerifyModuleName(related_module); nACLACCESS = Security.GetUserAccess(related_module, "list"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } get_relationships_result results = new get_relationships_result(); DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; // 02/16/2006 Paul. Providing a way to directly access tables is a hacker's dream. // We will not do that here. We will require that all relationships be defined in a SQL view. using ( IDbCommand cmd = con.CreateCommand() ) { switch ( module_name ) { case "Contacts": { switch ( related_module ) { case "Calls": { sSQL = "select * " + ControlChars.CrLf + " from vwCONTACTS_CALLS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } case "Meetings": { sSQL = "select * " + ControlChars.CrLf + " from vwCONTACTS_MEETINGS_Soap" + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } case "Users": { sSQL = "select * " + ControlChars.CrLf + " from vwCONTACTS_USERS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { throw(new Exception(String.Format("A related_module_query is not allowed at this time.", module_name, related_module))); } break; } default: { throw(new Exception(String.Format("Relationship between {0} and {1} is not defined", module_name, related_module))); } } break; } case "Users": { switch ( related_module ) { case "Calls": { sSQL = "select * " + ControlChars.CrLf + " from vwUSERS_CALLS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } case "Meetings": { sSQL = "select * " + ControlChars.CrLf + " from vwUSERS_MEETINGS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } case "Contacts": { sSQL = "select * " + ControlChars.CrLf + " from vwUSERS_CONTACTS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { throw(new Exception(String.Format("A related_module_query is not allowed at this time.", module_name, related_module))); } break; } default: { throw(new Exception(String.Format("Relationship between {0} and {1} is not defined", module_name, related_module))); } } break; } case "Meetings": { switch ( related_module ) { case "Contacts": { sSQL = "select * " + ControlChars.CrLf + " from vwMEETINGS_CONTACTS_Soap" + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } case "Users": { sSQL = "select * " + ControlChars.CrLf + " from vwMEETINGS_USERS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } default: { throw(new Exception(String.Format("Relationship between {0} and {1} is not defined", module_name, related_module))); } } break; } case "Calls": { switch ( related_module ) { case "Contacts": { sSQL = "select * " + ControlChars.CrLf + " from vwCALLS_CONTACTS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } case "Users": { sSQL = "select * " + ControlChars.CrLf + " from vwCALLS_USERS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { DateTime dtBeginDate = DateTime.MinValue; DateTime dtEndDate = DateTime.MinValue; ParseDateRange(related_module_query, "DATE_START", T10n, ref dtBeginDate, ref dtEndDate); if ( dtBeginDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START > @BEGIN_DATE" + ControlChars.CrLf; Sql.AddParameter(cmd, "@BEGIN_DATE", dtBeginDate); } if ( dtEndDate != DateTime.MinValue ) { cmd.CommandText += " and DATE_START < @END_DATE " + ControlChars.CrLf; Sql.AddParameter(cmd, "@END_DATE" , dtEndDate ); } } break; } default: { throw(new Exception(String.Format("Relationship between {0} and {1} is not defined", module_name, related_module))); } } break; } case "Accounts": { switch ( related_module ) { case "Contacts": { sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_CONTACTS_Soap" + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { throw(new Exception(String.Format("A related_module_query is not allowed at this time.", module_name, related_module))); } break; } case "Users": { sSQL = "select * " + ControlChars.CrLf + " from vwACCOUNTS_USERS_Soap " + ControlChars.CrLf + " where PRIMARY_ID = @PRIMARY_ID" + ControlChars.CrLf + " and DELETED = @DELETED " + ControlChars.CrLf; cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@PRIMARY_ID", module_id ); Sql.AddParameter(cmd, "@DELETED" , Math.Min(deleted, 1)); if ( !Sql.IsEmptyString(related_module_query) ) { throw(new Exception(String.Format("A related_module_query is not allowed at this time.", module_name, related_module))); } break; } default: { throw(new Exception(String.Format("Relationship between {0} and {1} is not defined", module_name, related_module))); } } break; } default: { throw(new Exception(String.Format("Relationship between {0} and {1} is not defined", module_name, related_module))); } } try { CultureInfo ciEnglish = CultureInfo.CreateSpecificCulture("en-US"); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; using ( DataTable dt = new DataTable() ) { da.Fill(dt); if ( dt.Rows.Count > 0 ) { results.ids = new id_mod[dt.Rows.Count]; int i = 0; foreach ( DataRow row in dt.Rows ) { results.ids[i] = new id_mod(); results.ids[i].id = Sql.ToString (row["RELATED_ID" ]); results.ids[i].deleted = Sql.ToInteger (row["DELETED" ]); // 06/13/2006 Paul. Italian has a problem with the time separator. Use the value from the culture from CalendarControl.SqlDateTimeFormat. // 06/14/2006 Paul. The Italian problem was that it was using the culture separator, but DataView only supports the en-US format. // 08/17/2006 Paul. The time on the server and the time in the database are both considered ServerTime. DateTime dtDATE_MODIFIED_ServerTime = Sql.ToDateTime(row["DATE_MODIFIED"]); // 08/17/2006 Paul. We need a special function to convert to UniversalTime because it might already be in UniversalTime, based on m_bGMTStorage flag. DateTime dtDATE_MODIFIED_UniversalTime = T10n.ToUniversalTimeFromServerTime(dtDATE_MODIFIED_ServerTime); results.ids[i].date_modified = dtDATE_MODIFIED_UniversalTime.ToString(CalendarControl.SqlDateTimeFormat, ciEnglish.DateTimeFormat); i++; } } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex); throw(new Exception("SOAP: Failed get_relationships", ex)); } } } return results; }
public static DataTable List(string sModuleName, string sListName) { System.Web.Caching.Cache Cache = HttpContext.Current.Cache; L10N L10n = new L10N(HttpContext.Current.Session["USER_SETTINGS/CULTURE"] as string); DataTable dt = Cache.Get(L10n.NAME + "." + sListName) as DataTable; if ( dt == null ) { try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " from vwTERMINOLOGY " + ControlChars.CrLf + " where lower(MODULE_NAME) = @MODULE_NAME" + ControlChars.CrLf + " and lower(LIST_NAME ) = @LIST_NAME " + ControlChars.CrLf + " and lower(LANG ) = @LANG " + ControlChars.CrLf + " order by LIST_ORDER " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; // 03/06/2006 Paul. Oracle is case sensitive, and we modify the case of L10n.NAME to be lower. Sql.AddParameter(cmd, "@MODULE_NAME", sModuleName.ToLower()); Sql.AddParameter(cmd, "@LIST_NAME" , sListName .ToLower()); Sql.AddParameter(cmd, "@LANG" , L10n.NAME .ToLower()); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); Cache.Insert(L10n.NAME + "." + sListName, dt, null, DefaultCacheExpiration(), Cache.NoSlidingExpiration); } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); // 10/16/2005 Paul. Ignore list errors. } } return dt; }
private void lit_OnDataBinding(object sender, EventArgs e) { DataGridItem objContainer = (DataGridItem) lbl.NamingContainer; DataRowView row = objContainer.DataItem as DataRowView; // 04/25/2006 Paul. We don't have access to the ACLGrid in InstantiateIn(), so do so here. ACLGrid grd = objContainer.Parent.Parent as ACLGrid; if ( !grd.EnableACLEditing ) { divList.Controls.Clear(); // 04/25/2006 Paul. I'd like to remove the dvList, but I can't do it here. //divList.Parent.Controls.Remove(divList); //divList = null; } if ( row != null ) { string sMODULE_NAME = Sql.ToString(row["MODULE_NAME"]); // 04/25/2006 Paul. We could use GUIDS like SugarCRM, but since there is only one ACL grid, // there is no need for that kind of uniqueness. divLabel.ID = sMODULE_NAME + "_" + sACCESS_TYPE + "link"; hid.ID = "hid" + sMODULE_NAME + "_" + sACCESS_TYPE; if ( row[sDATA_FIELD] != DBNull.Value ) { // 04/30/2006 Paul. Use the Context to store pointers to the localization objects. // This is so that we don't need to require that the page inherits from SplendidPage. L10N L10n = HttpContext.Current.Items["L10n"] as L10N; if ( L10n == null ) { // 04/26/2006 Paul. We want to have the AccessView on the SystemCheck page. L10n = new L10N(Sql.ToString(HttpContext.Current.Session["USER_SETTINGS/CULTURE"])); } int nACCESS = Sql.ToInteger(row[sDATA_FIELD]); divLabel.Attributes.Add("class", AccessClassName(sACCESS_TYPE, nACCESS)); // 04/25/2006 Paul. Don't update values on postback, otherwise it will over-write modified values. // 04/26/2006 Paul. Make sure to set the division color, even on postback. // 05/03/2006 Paul. If we are not editing, then always bind to the query. // This is so that the AccessView control can be placed in an unrelated control that have postbacks. // This was first noticed in the UserRolesView.ascx. if ( !objContainer.Page.IsPostBack || !grd.EnableACLEditing ) { lbl.Text = L10n.Term(AccessLabel(sACCESS_TYPE, nACCESS)); hid.Value = lbl.Text; } else { // 04/25/2006 Paul. The label will not retain its value, so restore from the hidden field. // We use the hidden field because the value my have been changed by the user. // 04/25/2006 Paul. We are too early in the ASP.NET lifecycle to access hid.Value, // so go directly to the Request to get the submitted value. lbl.Text = hid.Page.Request[hid.UniqueID]; } } } }
public static DataTable ReportingModules() { System.Web.Caching.Cache Cache = HttpContext.Current.Cache; DataTable dt = Cache.Get("vwMODULES_Reporting_" + Security.USER_ID.ToString()) as DataTable; if ( dt == null ) { L10N L10n = new L10N(HttpContext.Current.Session["USER_SETTINGS/CULTURE"] as string); try { DbProviderFactory dbf = DbProviderFactories.GetFactory(); using ( IDbConnection con = dbf.CreateConnection() ) { con.Open(); string sSQL; sSQL = "select MODULE_NAME " + ControlChars.CrLf + " , DISPLAY_NAME " + ControlChars.CrLf + " from vwMODULES_Reporting " + ControlChars.CrLf + " where USER_ID = @USER_ID " + ControlChars.CrLf + " or USER_ID is null " + ControlChars.CrLf; using ( IDbCommand cmd = con.CreateCommand() ) { cmd.CommandText = sSQL; Sql.AddParameter(cmd, "@USER_ID", Security.USER_ID); using ( DbDataAdapter da = dbf.CreateDataAdapter() ) { ((IDbDataAdapter)da).SelectCommand = cmd; dt = new DataTable(); da.Fill(dt); foreach(DataRow row in dt.Rows) { row["DISPLAY_NAME"] = L10n.Term(Sql.ToString(row["DISPLAY_NAME"])); } Cache.Insert("vwMODULES_Reporting_" + Security.USER_ID.ToString(), dt, null, DefaultCacheExpiration(), Cache.NoSlidingExpiration); } } } } catch(Exception ex) { SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex.Message); // 10/16/2005 Paul. Ignore list errors. } } return dt; }
/// <summary> /// CronDescription /// </summary> public static string CronDescription(L10N L10n, string sCRON) { StringBuilder sb = new StringBuilder(); sCRON = sCRON.Replace(" ", ""); if ( sCRON == "*::*::*::*::*" ) return L10n.Term("Schedulers.LBL_OFTEN"); CultureInfo culture = CultureInfo.CreateSpecificCulture(L10n.NAME); string sCRON_MONTH = "*"; string sCRON_DAYOFMONTH = "*"; string sCRON_DAYOFWEEK = "*"; string sCRON_HOUR = "*"; string sCRON_MINUTE = "*"; string[] arrCRON = sCRON.Replace("::", "|").Split('|'); string[] arrCRON_TEMP = new string[] {}; string[] arrCRON_VALUE = new string[] {}; string[] arrDaySuffixes = new string[32]; int nCRON_VALUE = 0; int nCRON_VALUE_START = 0; int nCRON_VALUE_END = 0; int nON_THE_MINUTE = -1; for ( int n = 0; n < arrDaySuffixes.Length; n++ ) arrDaySuffixes[n] = "th"; arrDaySuffixes[0] = ""; arrDaySuffixes[1] = "st"; arrDaySuffixes[2] = "nd"; arrDaySuffixes[3] = "rd"; // minute hour dayOfMonth month dayOfWeek if ( arrCRON.Length > 0 ) sCRON_MINUTE = arrCRON[0]; if ( arrCRON.Length > 1 ) sCRON_HOUR = arrCRON[1]; if ( arrCRON.Length > 2 ) sCRON_DAYOFMONTH = arrCRON[2]; if ( arrCRON.Length > 3 ) sCRON_MONTH = arrCRON[3]; if ( arrCRON.Length > 4 ) sCRON_DAYOFWEEK = arrCRON[4]; if ( sCRON_MINUTE != "*" ) { arrCRON_TEMP = sCRON_MINUTE.Split(','); // 12/31/2007 Paul. Check for either comma or dash. if ( sCRON_MINUTE.Split(",-".ToCharArray()).Length == 1 ) { nON_THE_MINUTE = Sql.ToInteger(sCRON_MINUTE); sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); if ( nON_THE_MINUTE == 0 ) { sb.Append(L10n.Term("Schedulers.LBL_HOUR_SING")); } else { sb.Append(nON_THE_MINUTE.ToString("00")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); } } else { for ( int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++ ) { if ( arrCRON_TEMP[i].IndexOf('-') >= 0 ) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if ( arrCRON_VALUE.Length >= 2 ) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if ( nCRON_VALUE_START >= 0 && nCRON_VALUE_START <= 23 && nCRON_VALUE_END >= 0 && nCRON_VALUE_END <= 23 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); if ( nCRON_VALUE_START == 0 ) { sb.Append(L10n.Term("Schedulers.LBL_HOUR_SING")); } else { sb.Append(nCRON_VALUE_START.ToString("0")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); } sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); sb.Append(nCRON_VALUE_END.ToString("0")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if ( nCRON_VALUE >= 0 && nCRON_VALUE <= 23 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(L10n.Term("Schedulers.LBL_ON_THE")); if ( nCRON_VALUE == 0 ) { sb.Append(L10n.Term("Schedulers.LBL_HOUR_SING")); } else { sb.Append(nCRON_VALUE.ToString("0")); sb.Append(L10n.Term("Schedulers.LBL_MIN_MARK")); } nCronEntries++; } } } } } if ( sCRON_HOUR != "*" ) { if ( sb.Length > 0 ) sb.Append("; "); arrCRON_TEMP = sCRON_HOUR.Split(','); for ( int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++ ) { if ( arrCRON_TEMP[i].IndexOf('-') >= 0 ) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if ( arrCRON_VALUE.Length >= 2 ) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if ( nCRON_VALUE_START >= 1 && nCRON_VALUE_START <= 31 && nCRON_VALUE_END >= 1 && nCRON_VALUE_END <= 31 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(arrCRON_VALUE[0]); if ( nON_THE_MINUTE >= 0 ) sb.Append(":" + nON_THE_MINUTE.ToString("00")); sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(arrCRON_VALUE[1]); if ( nON_THE_MINUTE >= 0 ) sb.Append(":" + nON_THE_MINUTE.ToString("00")); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if ( nCRON_VALUE >= 1 && nCRON_VALUE <= 31 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(arrCRON_TEMP[i]); if ( nON_THE_MINUTE >= 0 ) sb.Append(":" + nON_THE_MINUTE.ToString("00")); nCronEntries++; } } } } if ( sCRON_DAYOFMONTH != "*" ) { if ( sb.Length > 0 ) sb.Append("; "); arrCRON_TEMP = sCRON_DAYOFMONTH.Split(','); for ( int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++ ) { if ( arrCRON_TEMP[i].IndexOf('-') >= 0 ) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if ( arrCRON_VALUE.Length >= 2 ) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if ( nCRON_VALUE_START >= 1 && nCRON_VALUE_START <= 31 && nCRON_VALUE_END >= 1 && nCRON_VALUE_END <= 31 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(nCRON_VALUE_START.ToString() + arrDaySuffixes[nCRON_VALUE_START]); sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(nCRON_VALUE_END.ToString() + arrDaySuffixes[nCRON_VALUE_END]); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if ( nCRON_VALUE >= 1 && nCRON_VALUE <= 31 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(nCRON_VALUE.ToString() + arrDaySuffixes[nCRON_VALUE]); nCronEntries++; } } } } if ( sCRON_MONTH != "*" ) { if ( sb.Length > 0 ) sb.Append("; "); arrCRON_TEMP = sCRON_MONTH.Split(','); for ( int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++ ) { if ( arrCRON_TEMP[i].IndexOf('-') >= 0 ) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if ( arrCRON_VALUE.Length >= 2 ) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if ( nCRON_VALUE_START >= 1 && nCRON_VALUE_START <= 12 && nCRON_VALUE_END >= 1 && nCRON_VALUE_END <= 12 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(culture.DateTimeFormat.MonthNames[nCRON_VALUE_START]); sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(culture.DateTimeFormat.MonthNames[nCRON_VALUE_END]); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if ( nCRON_VALUE >= 1 && nCRON_VALUE <= 12 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(culture.DateTimeFormat.MonthNames[nCRON_VALUE]); nCronEntries++; } } } } if ( sCRON_DAYOFWEEK != "*" ) { if ( sb.Length > 0 ) sb.Append("; "); arrCRON_TEMP = sCRON_DAYOFWEEK.Split(','); for ( int i = 0, nCronEntries = 0; i < arrCRON_TEMP.Length; i++ ) { if ( arrCRON_TEMP[i].IndexOf('-') >= 0 ) { arrCRON_VALUE = arrCRON_TEMP[i].Split('-'); if ( arrCRON_VALUE.Length >= 2 ) { nCRON_VALUE_START = Sql.ToInteger(arrCRON_VALUE[0]); nCRON_VALUE_END = Sql.ToInteger(arrCRON_VALUE[1]); if ( nCRON_VALUE_START >= 0 && nCRON_VALUE_START <= 6 && nCRON_VALUE_END >= 0 && nCRON_VALUE_END <= 6 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(L10n.Term("Schedulers.LBL_FROM")); sb.Append(culture.DateTimeFormat.DayNames[nCRON_VALUE_START]); sb.Append(L10n.Term("Schedulers.LBL_RANGE")); sb.Append(culture.DateTimeFormat.DayNames[nCRON_VALUE_END]); nCronEntries++; } } } else { nCRON_VALUE = Sql.ToInteger(arrCRON_TEMP[i]); if ( nCRON_VALUE >= 0 && nCRON_VALUE <= 6 ) { if ( nCronEntries > 0 ) sb.Append(L10n.Term("Schedulers.LBL_AND")); sb.Append(culture.DateTimeFormat.DayNames[nCRON_VALUE]); nCronEntries++; } } } } return sb.ToString(); }
public string create_account(string user_name, string password, string name, string phone, string website) { Guid gUSER_ID = LoginUser(user_name, password); int nACLACCESS = Security.GetUserAccess("Accounts", "edit"); if ( nACLACCESS < 0 ) { L10N L10n = new L10N("en-US"); throw(new Exception(L10n.Term("ACL.LBL_INSUFFICIENT_ACCESS"))); } Guid gID = Guid.Empty; SqlProcs.spACCOUNTS_New(ref gID, name, phone, website); return "1"; }