This commit is contained in:
251
source/bizobjects/AyaLib/GZTW.AyaNova.BLL/ReportDataSet.cs
Normal file
251
source/bizobjects/AyaLib/GZTW.AyaNova.BLL/ReportDataSet.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
using System;
|
||||
using System.Data;
|
||||
//Case 232
|
||||
//using DevExpress.XtraReports;
|
||||
using DevExpress.Data;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace GZTW.AyaNova.BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// Used internally as "go-between" data source for reporting in cases where reports are based off complex business objects
|
||||
/// that contain hiearchical linked data sources.
|
||||
///
|
||||
/// Also used to support localized column names and filter out irrelevant and duplicate fields.
|
||||
///
|
||||
/// API users: treat this as a traditional DataSet object which it's derived from.
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public class ReportDataSet : DataSet,IDataDictionary
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
|
||||
|
||||
|
||||
private LocalizedTextTable localtext=null;
|
||||
private string sourceDisplayName="";
|
||||
private string showOnlyStartingWith="";
|
||||
public ReportDataSet()
|
||||
{
|
||||
}
|
||||
public ReportDataSet(SerializationInfo info, StreamingContext context) : base(info,context) {}
|
||||
|
||||
|
||||
public LocalizedTextTable LocaleTextTable
|
||||
{
|
||||
set
|
||||
{
|
||||
localtext=value;
|
||||
}
|
||||
}
|
||||
|
||||
public string DisplayName
|
||||
{set{sourceDisplayName=value;}}
|
||||
|
||||
public string ShowOnlyStartingWith
|
||||
{set{showOnlyStartingWith=value;}}
|
||||
|
||||
#region IDataDictionary Members
|
||||
|
||||
public string GetDataSourceDisplayName()
|
||||
{
|
||||
|
||||
return sourceDisplayName;
|
||||
}
|
||||
|
||||
public string GetObjectDisplayName(string dataMember)
|
||||
{
|
||||
//sometimes it prompts when it's already empty
|
||||
if (string.IsNullOrEmpty(dataMember)) return "";
|
||||
|
||||
#region Filter out extraneous tables not in main workorder tree
|
||||
//Devexpress example from http://www.devexpress.com/Support/Center/p/CQ29447.aspx
|
||||
//this is intended to hide the duplicate table names
|
||||
//that display but are not descendants of the workorder header and so have only one record
|
||||
//and are not supposed to be used
|
||||
//as requested in our case 1214
|
||||
DataSet ds = ((DataSet)this);//.DataSource);
|
||||
if (ds.Tables.Count > 1)
|
||||
{
|
||||
bool istable = false;
|
||||
for (int i = 0; i < ds.Tables.Count; i++)
|
||||
if (ds.Tables[i].TableName == dataMember)
|
||||
istable = true;
|
||||
|
||||
if (istable)
|
||||
{
|
||||
bool isParentTable = false;
|
||||
for (int i = 0; i < ds.Relations.Count; i++)
|
||||
if (ds.Relations[i].ParentTable.TableName == dataMember)
|
||||
isParentTable = true;
|
||||
if (!isParentTable)
|
||||
return "";
|
||||
}
|
||||
|
||||
//Workaround for workorderitem which passes through above
|
||||
if (istable)
|
||||
if (dataMember == "WorkorderItem")
|
||||
return "";
|
||||
|
||||
|
||||
}
|
||||
#endregion filter out extraneous tables
|
||||
|
||||
#region Lite: hide fields that shouldn't be shown in report designer
|
||||
//brute force method to hide workorder related non lite stuff
|
||||
if (AyaBizUtils.Lite)//case 1216
|
||||
{
|
||||
if (dataMember.Contains("WorkorderItem_Label_Custom"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Task"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Project"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("WorkorderItemOutsideService"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Unit"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Travel"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("MiscExpense"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Loan"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("HeadOffice"))
|
||||
return "";
|
||||
|
||||
|
||||
//---------------------------------------
|
||||
if (dataMember.Contains("ClientGroup"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("CloseByDate"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Dispatch"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("HO_"))//Head office address lines
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("PMID"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("QuoteID"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Region"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Bank"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Discount"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("QuantityReserved"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("PartSerial"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Label_Used"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("PartWarehouse"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom1"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom2"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom3"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom4"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom5"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom6"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom7"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom8"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom9"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Custom0"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("TrackSerialNumber"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Contract"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Balance"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("MemberOfGroup"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("UserType"))
|
||||
return "";
|
||||
|
||||
if (dataMember.Contains("Notification"))
|
||||
return "";
|
||||
|
||||
|
||||
}
|
||||
#endregion lite stuff
|
||||
|
||||
//If so it won't have the LT bit at all...
|
||||
if(dataMember.IndexOf("LT_")==-1)
|
||||
{
|
||||
//Ok, it is, now let's shorten it as much as possible
|
||||
//the normal format for items down the tree is every item above them
|
||||
//followed by a dot then the next etc etc...too wide
|
||||
//so we'll return everything after the last period
|
||||
int ndex=dataMember.LastIndexOf(".");
|
||||
if(ndex==-1) return dataMember;
|
||||
ndex++;
|
||||
return dataMember.Substring(ndex);
|
||||
|
||||
}
|
||||
|
||||
//Case 196
|
||||
if (localtext == null) return dataMember;
|
||||
|
||||
//Case 432 duped localized column names means one doesnt' appear
|
||||
//WorkorderHeader.LT_Workorder_Label_FromQuoteID
|
||||
string skey = dataMember.Substring(dataMember.IndexOf("LT_"));
|
||||
return localtext.GetLocalizedText(skey) + " " + skey;
|
||||
}
|
||||
|
||||
#endregion
|
||||
#pragma warning restore 1591
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user