Ejemplo n.º 1
0
		/*
		public static string GetFieldsAsString(XmlDocument xml)
		{
			StringBuilder sb = new StringBuilder();
			if ( xml.DocumentElement != null )
			{
				XmlNodeList nlDataFields = xml.DocumentElement.SelectNodes("DataSets/DataSet/Fields/Field/DataField");
				foreach ( XmlNode xDataField in nlDataFields )
				{
					if ( sb.Length > 0 )
						sb.Append(", ");
					sb.Append("'");
					sb.Append(xDataField.InnerText);
					sb.Append("'");
				}
			}
			return sb.ToString();
		}
		*/

		// 07/15/2010   Use new function to format Rdl. 
		public static string RdlEncode(RdlDocument rdl)
		{
			StringBuilder sb = new StringBuilder();
			XmlUtil.Dump(ref sb, "", rdl.DocumentElement);
			string sDump = HttpUtility.HtmlEncode(sb.ToString());
			sDump = sDump.Replace("\n", "<br />\n");
			sDump = sDump.Replace("\t", "&nbsp;&nbsp;&nbsp;");
			sDump = "<div style=\"width: 100%; border: 1px solid black; font-family: courier new;\">" + sDump + "</div>";
			return sDump;
		}
Ejemplo n.º 2
0
		// 05/03/2011   We need to include the USER_ID because we cache the Assigned User ID and the Team ID. 
		public static DataTable ChartParameters(Guid gID, Guid gUSER_ID)
		{
			System.Web.Caching.Cache Cache = HttpRuntime.Cache;
			DataTable dt = Cache.Get("vwCHARTS.Parameters." + gID.ToString() + "." + gUSER_ID.ToString()) as DataTable;
			if ( dt == null )
			{
				dt = new DataTable();
				dt.Columns.Add("NAME"         , typeof(String));
				dt.Columns.Add("MODULE_NAME"  , typeof(String));
				dt.Columns.Add("DATA_TYPE"    , typeof(String));  // String, Boolean, DateTime, Integer, Float
				dt.Columns.Add("NULLABLE"     , typeof(bool  ));
				dt.Columns.Add("ALLOW_BLANK"  , typeof(bool  ));
				dt.Columns.Add("MULTI_VALUE"  , typeof(bool  ));
				// 02/03/2012   Add support for the Hidden flag. 
				dt.Columns.Add("HIDDEN"       , typeof(bool  ));
				dt.Columns.Add("PROMPT"       , typeof(String));
				dt.Columns.Add("DEFAULT_VALUE", typeof(String));
				// 02/16/2012   We need a separate list for report parameter lists. 
				dt.Columns.Add("DATA_SET_NAME"   , typeof(String));
				
				try
				{
					DataTable dtChart = SplendidCache.Chart(gID);
					if ( dtChart.Rows.Count > 0 )
					{
						DataRow rdr = dtChart.Rows[0];
						string sRDL         = Sql.ToString(rdr["RDL"        ]);
						string sMODULE_NAME = Sql.ToString(rdr["MODULE_NAME"]);
						
						RdlDocument rdl = new RdlDocument();
						rdl.LoadRdl(sRDL);
						rdl.NamespaceManager.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
						
						// 02/16/2012   We need a separate list for report parameter lists. 
						string sReportID = rdl.SelectNodeValue("rd:ReportID");
						XmlNodeList nlReportParameters = rdl.SelectNodesNS("ReportParameters/ReportParameter");
						foreach ( XmlNode xReportParameter in nlReportParameters )
						{
							DataRow row = dt.NewRow();
							dt.Rows.Add(row);
							// 11/15/2011   Must use rdl.SelectNodeValue to get the properties. 
							string sName         = XmlUtil.GetNamedItem    (xReportParameter, "Name"    );
							string sDataType     = rdl.SelectNodeValue(xReportParameter, "DataType");
							bool   bNullable     = Sql.ToBoolean(rdl.SelectNodeValue(xReportParameter, "Nullable"  ));
							bool   bAllowBlank   = Sql.ToBoolean(rdl.SelectNodeValue(xReportParameter, "AllowBlank"));
							bool   bMultiValue   = Sql.ToBoolean(rdl.SelectNodeValue(xReportParameter, "MultiValue"));
							// 02/03/2012   Add support for the Hidden flag. 
							bool   bHidden       = Sql.ToBoolean(rdl.SelectNodeValue(xReportParameter, "Hidden"    ));
							string sPrompt       = rdl.SelectNodeValue(xReportParameter, "Prompt"  );
							// 02/16/2012   We need a separate list for report parameter lists. 
							string sDataSetName    = rdl.SelectNodeValue(xReportParameter, "ValidValues/DataSetReference/DataSetName");
							string sDefaultValue   = rdl.SelectNodeValue(xReportParameter, "DefaultValue/Values/Value");
							// 02/16/2012   Add support for specific parameter values. 
							XmlNodeList nlValidValues = rdl.SelectNodesNS(xReportParameter, "ValidValues/ParameterValues/ParameterValue");
							if ( nlValidValues.Count > 0 )
							{
								DataTable dtValidValues = new DataTable();
								dtValidValues.Columns.Add("VALUE", typeof(String));
								dtValidValues.Columns.Add("NAME" , typeof(String));
								foreach ( XmlNode xValidValue in nlValidValues )
								{
									DataRow rowValid = dtValidValues.NewRow();
									rowValid["VALUE"] = rdl.SelectNodeValue(xValidValue, "Value");
									rowValid["NAME" ] = rdl.SelectNodeValue(xValidValue, "Label");
									dtValidValues.Rows.Add(rowValid);
								}
								SplendidCache.AddReportSource(sReportID + "." + sName + ".SpecificValues", "VALUE", "NAME", dtValidValues);
								row["DATA_SET_NAME"] = sReportID + "." + sName + ".SpecificValues";
							}
							XmlNodeList nlDefaultValues = rdl.SelectNodesNS(xReportParameter, "DefaultValue/Values");
							if ( nlDefaultValues.Count > 0 )
							{
								if ( bMultiValue )
								{
									XmlDocument xml = new XmlDocument();
									xml.AppendChild(xml.CreateXmlDeclaration("1.0", "UTF-8", null));
									xml.AppendChild(xml.CreateElement("Values"));
									foreach ( XmlNode xDefaultValue in nlDefaultValues )
									{
										XmlNode xValue = xml.CreateElement("Value");
										xml.DocumentElement.AppendChild(xValue);
										// 10/05/2012   Check default value for null, not new value. 
										bool bNull = Sql.ToBoolean(XmlUtil.GetNamedItem(xDefaultValue, "xsi:nil"));
										if ( !bNull )
											xValue.InnerText = xDefaultValue.InnerText;
									}
									row["DEFAULT_VALUE"] = xml.OuterXml;
								}
								else
								{
									// <Value xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
									XmlNode xDefaultValue = nlDefaultValues[0];
									bool bNull = Sql.ToBoolean(XmlUtil.GetNamedItem(xDefaultValue, "xsi:nil"));
									if ( !bNull )
										row["DEFAULT_VALUE"] = Sql.ToString(xDefaultValue.InnerText);
								}
							}
							
							row["NAME"       ] = sName       ;
							row["MODULE_NAME"] = sMODULE_NAME;
							row["DATA_TYPE"  ] = sDataType   ;
							row["NULLABLE"   ] = bNullable   ;
							row["ALLOW_BLANK"] = bAllowBlank ;
							row["MULTI_VALUE"] = bMultiValue ;
							// 02/03/2012   Add support for the Hidden flag. 
							row["HIDDEN"     ] = bHidden     ;
							row["PROMPT"     ] = sPrompt     ;
							// 02/16/2012   We need a separate list for report parameter lists. 
							if ( !Sql.IsEmptyString(sDataSetName) )
								row["DATA_SET_NAME"] = sReportID + "." + sDataSetName;
							if ( String.Compare(sName, "ASSIGNED_USER_ID", true) == 0 )
							{
								row["DEFAULT_VALUE"] = Security.USER_ID.ToString();
							}
							else if ( String.Compare(sName, "TEAM_ID", true) == 0 )
							{
								row["DEFAULT_VALUE"] = Security.TEAM_ID.ToString();
							}
						}
					}
					Cache.Insert("vwCHARTS.Parameters." + gID.ToString() + "." + gUSER_ID.ToString(), dt, null, DefaultCacheExpiration(), Cache.NoSlidingExpiration);
				}
				catch(Exception ex)
				{
					SplendidError.SystemError(new StackTrace(true).GetFrame(0), ex);
				}
			}
			return dt;
		}