/// <summary> /// Returns the instance of BaseListViewSource. Based on Factory method. /// </summary> /// <param name="listType"></param> /// <param name="showCheckBoxColumn"></param> /// <param name="dbConnection"></param> /// <param name="dbQueries"></param> /// <returns></returns> public static BaseListViewSource CreateListViewSource(ListViewType listType, DIConnection dbConnection, DIQueries dbQueries) { BaseListViewSource RetVal = null; UserPreference DIUserPreferencce = new UserPreference(); RetVal = ListViewSourceFactory.CreateListViewSource(listType, dbConnection, dbQueries, DIUserPreferencce); return RetVal; }
/// <summary> /// Returns the instance of BaseListViewSource. Based on Factory method. /// </summary> /// <param name="listType"></param> /// <param name="dbConnection"></param> /// <param name="dbQueries"></param> /// <param name="userprefenece"></param> /// <returns></returns> public static BaseListViewSource CreateListViewSource(ListViewType listType, DIConnection dbConnection, DIQueries dbQueries, UserPreference userprefenece) { BaseListViewSource RetVal = null; switch (listType) { case ListViewType.Indicator: RetVal = new IndicatorListViewSource(); RetVal.RaiseInitializedIndicatorListViewEvent(); break; case ListViewType.Timeperiod: RetVal = new TimeperiodListViewSource(); RetVal.RaiseInitializedTimperiodListViewEvent(); break; case ListViewType.Area: RetVal = new AreaListViewSource(); RetVal.RaiseInitializedAreaListViewEvent(); break; case ListViewType.Source: RetVal = new DISourceListViewSource(); RetVal.RaiseInitializedDISourceListViewEvent(); break; case ListViewType.Unit: RetVal = new UnitListViewSource(); RetVal.RaiseInitializedUnitListViewEvent(); break; case ListViewType.SubgroupVal: RetVal = new SubgroupValListViewSource(); RetVal.RaiseInitializedUnitListViewEvent(); break; case ListViewType.IC: RetVal = new ICListViewSource(); break; default: break; } if (RetVal != null) { //set variables RetVal.DBConnection = dbConnection; RetVal.DBQueries = dbQueries; RetVal.DIUserPreference = userprefenece; //set columns RetVal.SetColumnInfo(); } return RetVal; }
/// <summary> /// Area Autoselection: From the TreeView by Selected Area, Target Area Level /// </summary> /// <param name="userPreference"></param> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <param name="parentNId"></param> /// <param name="currentLevel"></param> /// <param name="requiredLevel"></param> public AutoSelectArea(UserPreference.UserPreference userPreference, DI_LibDAL.Connection.DIConnection dIConnection, DI_LibDAL.Queries.DIQueries dIQueries, int parentNId, int currentLevel, int requiredLevel) { // -- Connection details preserved this.mdIConnection = dIConnection; this.mdIQueries = dIQueries; this.mUserPreference = userPreference; // Autoselect Parameters this.mparentNId = parentNId; this.mcurrentLevel = currentLevel; this.mrequiredLevel = requiredLevel; this.mAreaNIDs = string.Empty; }
/// <summary> /// Area Autoselection: From the Available list by a list of available Area NIDs /// </summary> /// <param name="userPreference"></param> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <param name="sAvlAreaNIDs"></param> public AutoSelectArea(UserPreference.UserPreference userPreference, DI_LibDAL.Connection.DIConnection dIConnection, DI_LibDAL.Queries.DIQueries dIQueries, string avlAreaNIDs) { // -- Connection details preserved this.mdIConnection = dIConnection; this.mdIQueries = dIQueries; this.mUserPreference = userPreference; // Autoselect Parameters this.mparentNId = -1; this.mcurrentLevel = 0; this.mrequiredLevel = 0; this.mAreaNIDs = avlAreaNIDs; }
private DataTable GetRecordsForAvailableAutoSelect(string availableItemsNid) { DataTable RetVal = new DataTable(); int Requiredlevel = 0; AutoSelectArea AreaAutoSelect; UserPreference UserPreferenceInstance; try { //get required area level if (this._AreaRequiredLevel > 0) { Requiredlevel = this._AreaRequiredLevel; } //check and set userpreferences for selection if (this.UserPrefences != null) { UserPreferenceInstance = this.UserPrefences; } else { UserPreferenceInstance = new DevInfo.Lib.DI_LibBAL.UI.UserPreference.UserPreference(); UserPreferenceInstance.UserSelection = new DevInfo.Lib.DI_LibDAL.UserSelection.UserSelection(); UserPreferenceInstance.UserSelection.TimePeriodNIds = this.UserPrefences.UserSelection.TimePeriodNIds; UserPreferenceInstance.UserSelection.IndicatorNIds = this.UserPrefences.UserSelection.IndicatorNIds; UserPreferenceInstance.UserSelection.ShowIUS = this.UserPrefences.UserSelection.ShowIUS; } //create AutoSelect class instance AreaAutoSelect = new AutoSelectArea(UserPreferenceInstance, this._DBConnection, this.SqlQueries, availableItemsNid); //get records RetVal = AreaAutoSelect.GetAutoSelectAreas(this.UseIndicator, this.UseTime).Table; } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return(RetVal); }
/// <summary> /// If there is any change regarding to the timeperiod related porperty, its event will get fired. /// </summary> /// <param name="tempUserPreference"></param> /// <returns></returns> private bool TimePeriodAffected(UserPreference tempUserPreference) { //-- Interface lang. if (this.Language.InterfaceLanguage != tempUserPreference.Language.InterfaceLanguage) { this.RaiseTimePeriodContentChangedEvent(); return true; } //-- Database lang. if (this.Database.DatabaseLanguage != tempUserPreference.Database.DatabaseLanguage) { this.RaiseTimePeriodContentChangedEvent(); return true; } return false; }
/// <summary> /// PreviewChangeEvent is fired, if there is any change in preview limit properties /// </summary> /// <param name="tempUserPreference"></param> /// <returns></returns> private bool PreviewAffected(UserPreference tempUserPreference) { bool IsGraphChanged = false; //-- Set the flag to true, so that table preview is redraw if there is any change in the property. //-- Show excel if (!IsGraphChanged && this._General.ShowExcel != tempUserPreference.General.ShowExcel) { this.RaisePreviewChangedEvent(Presentation.PresentationType.Graph); //-- Set the flag to true, so that table preview is redraw if there is any change in the property. IsGraphChanged = true; } if (!IsGraphChanged && this.DataView.GraphPreviewLimit != tempUserPreference.DataView.GraphPreviewLimit) { this.RaisePreviewChangedEvent(Presentation.PresentationType.Graph); IsGraphChanged = true; } if (!IsGraphChanged && this.DataView.DIWizardGraphPreviewLimit != tempUserPreference.DataView.DIWizardGraphPreviewLimit) { this.RaisePreviewChangedEvent(Presentation.PresentationType.Graph); IsGraphChanged = true; } //-- Preview limit change if (this.DataView.TablePreviewLimit != tempUserPreference.DataView.TablePreviewLimit) { this.RaisePreviewChangedEvent(Presentation.PresentationType.Table); return true; } if (this.DataView.DIWizardTablePreviewLimit != tempUserPreference.DataView.DIWizardTablePreviewLimit) { this.RaisePreviewChangedEvent(Presentation.PresentationType.Table); return true; } return false; }
/// <summary> /// If there is any change regarding to the Indicator related porperty, its event will get fired. /// </summary> /// <param name="tempUserPreference"></param> /// <returns></returns> private bool IndicatorAffected(UserPreference tempUserPreference) { //-- Page Size if (this.General.PageSize != tempUserPreference.General.PageSize) { this.RaiseIndicatorContentChangedEvent(); return true; } //-- global Color if (this.General.ShowGlobalColor != tempUserPreference.General.ShowGlobalColor) { this.RaiseIndicatorContentChangedEvent(); return true; } //-- global Color if (this.General.GlobalColor != tempUserPreference.General.GlobalColor) { this.RaiseIndicatorContentChangedEvent(); return true; } //-- Interface lang. if (this.Language.InterfaceLanguage != tempUserPreference.Language.InterfaceLanguage) { this.RaiseIndicatorContentChangedEvent(); return true; } //-- Database lang. if (this.Database.DatabaseLanguage != tempUserPreference.Database.DatabaseLanguage) { this.RaiseIndicatorContentChangedEvent(); return true; } //-- Selectcted IC type if (this.Indicator.SelectedICType != tempUserPreference.Indicator.SelectedICType) { this.RaiseIndicatorContentChangedEvent(); return true; } //-- Show IUS if (this.UserSelection.ShowIUS != tempUserPreference.UserSelection.ShowIUS) { this.RaiseIndicatorContentChangedEvent(); return true; } //-- Show IUS if (this.Indicator.ShowIndicatorWithData != tempUserPreference.Indicator.ShowIndicatorWithData) { this.RaiseIndicatorContentChangedEvent(); return true; } return false; }
/// <summary> /// Set IC Field Information for columns selected by user /// </summary> /// <param name="userPreference"></param> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <param name="dtIUSNIDs">Datatable containing distinct IUSNIds for full dataview</param> private void BuildIUSICInfoTable(UserPreference.UserPreference userPreference, DI_LibDAL.Connection.DIConnection dIConnection, DI_LibDAL.Queries.DIQueries dIQueries, DataTable dtIUSNIDs) { string sIUSICInfoTableName = this._IUSICInfo.TableName; //Preserve Table name string sIUSICNIdInfoTableName = this._IUSICNIdInfo.TableName; //Preserve Table name // Get Table with IUSNId column. Later add additional columns based on IC fields selected this._IUSICInfo = dtIUSNIDs.Copy(); this._IUSICNIdInfo = dtIUSNIDs.Copy(); this._IUSICInfo.TableName = sIUSICInfoTableName; //Restore Table Name this._IUSICNIdInfo.TableName = sIUSICNIdInfoTableName; //Restore Table Name string[] arrSelectedICFields = null; // This dictionary will store all distinct ICType(KEY) for which fields are selected and Maximum child level (Value) selected System.Collections.Generic.Dictionary<ICType, int> ICMaxLevelCol = new Dictionary<ICType, int>(); System.Collections.Generic.Dictionary<ICType, string> ICGIdsCol = new Dictionary<ICType, string>(); string sICType = string.Empty; int ICIndex = -1; ICType ICType = ICType.Sector; string sLevel = string.Empty; string sCaption = string.Empty; // Add selected IC columns to _IUSICInfo table // Set language based caption // Preserve information of distinct IC selected and max child level to traverse in ICMaxLevelCol if (userPreference.DataView.ICFields.Length > 0) { arrSelectedICFields = userPreference.DataView.ICFields.Split(",".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arrSelectedICFields.Length; i++) { sICType = arrSelectedICFields[i].Substring(4, 2); ICIndex = DIQueries.ICTypeText.Values.IndexOf("'" + sICType + "'"); if (ICIndex > -1) { ICType = DIQueries.ICTypeText.Keys[ICIndex]; } sLevel = arrSelectedICFields[i].Substring(7); this._IUSICInfo.Columns.Add(arrSelectedICFields[i], typeof(string)); this._IUSICNIdInfo.Columns.Add(arrSelectedICFields[i], typeof(int)); this._IUSICInfo.Columns[arrSelectedICFields[i]].DefaultValue = string.Empty; this._IUSICNIdInfo.Columns[arrSelectedICFields[i]].DefaultValue = -1; if (ICMaxLevelCol.ContainsKey(ICType)) { ICMaxLevelCol[ICType] = Math.Max(ICMaxLevelCol[ICType], int.Parse(sLevel)); } else { ICMaxLevelCol.Add(ICType, int.Parse(sLevel)); } if (ICGIdsCol.ContainsKey(ICType) == false) { string[] sICGIds = null; switch (ICType) { case ICType.Sector: sICGIds = userPreference.DataView.ICSectorGIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); break; case ICType.Goal: sICGIds = userPreference.DataView.ICGoalGIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); break; case ICType.CF: sICGIds = "-1".Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); break; case ICType.Theme: sICGIds = userPreference.DataView.ICThemeGIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); break; case ICType.Source: sICGIds = userPreference.DataView.ICSourceGIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); break; case ICType.Institution: sICGIds = userPreference.DataView.ICInstitutionalGIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); break; case ICType.Convention: sICGIds = userPreference.DataView.ICConventionGIds.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); break; } for (int j = 0; j < sICGIds.Length; j++) { sICGIds[j] = "'" + sICGIds[j] + "'"; } ICGIdsCol.Add(ICType, string.Join(",", sICGIds)); } } } string sCommaDelimitedICTypes = string.Empty; string _Query = string.Empty; // Get distinct comma delimited IC types for query foreach (ICType sKey in ICMaxLevelCol.Keys) { sCommaDelimitedICTypes += "," + DIQueries.ICTypeText[sKey]; } // Fetch records for IC based on IUSNIds and ICTypes if (sCommaDelimitedICTypes.Length > 0) { sCommaDelimitedICTypes = sCommaDelimitedICTypes.Substring(1); //Remove extra "," _Query = dIQueries.IndicatorClassification.GetICForIUSNId(FilterFieldType.Type, sCommaDelimitedICTypes, this._IUSNIds, FieldSelection.Light); } else { _Query = dIQueries.IndicatorClassification.GetICForIUSNId(FilterFieldType.None, "", this._IUSNIds, FieldSelection.Light); } DataView dvIC = this.ExecuteInvariantDataTable(_Query).DefaultView; int iMaxLevel; string sParentNIds = string.Empty; string sColumnName = string.Empty; //for each classification type (for which fields has been selected) foreach (ICType sKey in ICMaxLevelCol.Keys) { ICType = sKey; iMaxLevel = ICMaxLevelCol[sKey]; sParentNIds = "-1"; // for each level of current classification type for (int i = 1; i <= iMaxLevel; i++) { if (!string.IsNullOrEmpty(sParentNIds)) { // Build the column name based on field naming convention "CLS_SC_1", "CLS_GL_3" sColumnName = "CLS_" + DIQueries.ICTypeText[ICType].Replace("'", "") + "_" + i.ToString(); // Check whether this column is part of _IUSICInfo table if (this._IUSICInfo.Columns.Contains(sColumnName)) { // for each IUS set _ICInfo[sColumnName] if its associated to Current IC record for (int k = 0; k < this._IUSICInfo.Rows.Count; k++) { dvIC.RowFilter = IndicatorClassificationsIUS.IUSNId + " = " + this._IUSICInfo.Rows[k][IndicatorClassificationsIUS.IUSNId].ToString() + " AND " + IndicatorClassifications.ICParent_NId + " IN (" + sParentNIds + ") AND " + IndicatorClassifications.ICGId + " IN (" + ICGIdsCol[ICType] + ") AND " + IndicatorClassifications.ICType + " = " + DIQueries.ICTypeText[ICType]; if (dvIC.Count > 0) { this._IUSICInfo.Rows[k][sColumnName] = dvIC[0][IndicatorClassifications.ICName]; this._IUSICNIdInfo.Rows[k][sColumnName] = dvIC[0][IndicatorClassifications.ICNId]; } else { this._IUSICInfo.Rows[k][sColumnName] = string.Empty; } } } // Set ParentNIds for next level dvIC.RowFilter = IndicatorClassifications.ICParent_NId + " IN (" + sParentNIds + ") AND " + IndicatorClassifications.ICType + " = " + DIQueries.ICTypeText[ICType]; sParentNIds = string.Empty; for (int j = 0; j < dvIC.Count; j++) { sParentNIds += "," + dvIC[j][IndicatorClassifications.ICNId]; } // remove extra "," if (sParentNIds.Length > 0) { sParentNIds = sParentNIds.Substring(1); } } } } }
public DimensionsSelection(DIConnection dbConnection, DIQueries dbQueries, UserPreference userPreference) { this.DbConnection = dbConnection; this.DbQueries = dbQueries; this.UserPreference = userPreference; }
private DataTable GetRecordsForAvailableAutoSelect(string availableItemsNid) { DataTable RetVal = new DataTable(); int Requiredlevel = 0; AutoSelectArea AreaAutoSelect; UserPreference UserPreferenceInstance; try { //get required area level if (this._AreaRequiredLevel > 0) { Requiredlevel = this._AreaRequiredLevel; } //check and set userpreferences for selection if (this.UserPrefences != null) { UserPreferenceInstance = this.UserPrefences; } else { UserPreferenceInstance = new DevInfo.Lib.DI_LibBAL.UI.UserPreference.UserPreference(); UserPreferenceInstance.UserSelection = new DevInfo.Lib.DI_LibDAL.UserSelection.UserSelection(); UserPreferenceInstance.UserSelection.TimePeriodNIds = this.UserPrefences.UserSelection.TimePeriodNIds; UserPreferenceInstance.UserSelection.IndicatorNIds = this.UserPrefences.UserSelection.IndicatorNIds; UserPreferenceInstance.UserSelection.ShowIUS = this.UserPrefences.UserSelection.ShowIUS; } //create AutoSelect class instance AreaAutoSelect = new AutoSelectArea(UserPreferenceInstance, this._DBConnection, this.SqlQueries, availableItemsNid); //get records RetVal = AreaAutoSelect.GetAutoSelectAreas(this.UseIndicator, this.UseTime).Table; } catch (Exception ex) { throw new ApplicationException(ex.ToString()); } return RetVal; }
/// <summary> /// Constructor /// </summary> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <param name="userPreference"></param> public TreeFilter(DIConnection dIConnection, DIQueries dIQueries, ref UserPreference userPreference) { this.DbConnection = dIConnection; this.DbQueries = dIQueries; this.Preference = userPreference; }
/// <summary> /// Set metadata master tables for Indicator / Area / Source /// </summary> /// <param name="metadataElementType">Indicator / Area / Source</param> /// <param name="userPreference"></param> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <returns></returns> private bool SetMetedataTables(MetadataElementType metadataElementType, UserPreference.UserPreference userPreference, DI_LibDAL.Connection.DIConnection dIConnection, DI_LibDAL.Queries.DIQueries dIQueries) { bool RetVal = false; string MaskFilePath = string.Empty; XmlDocument MaskFileDocument = new XmlDocument(); XmlNodeList MaskNodeList; string MaskPathText = string.Empty; string MaskPositionText = string.Empty; string[] MaskPositionArray; XmlDocument MetadataDocument = new XmlDocument(); string MetadataXml = string.Empty; XmlNodeList MetadataFld_ValNodeList; string[] arrSelectedMetadataFields = null; string JoinColumnName = string.Empty; string MetadataColumnName = string.Empty; string _Query = string.Empty; DataTable DistinctElementTable; string[] DistinctNIds = null; DataView dvMetadataInfo = null; DataTable ElementMetadataTable = null; string CategoryType = string.Empty; // I / A / S string MetadataPrefix = string.Empty; //MD_IND_, MD_SRC_ switch (metadataElementType) { case MetadataElementType.Indicator: // Set Category Type CategoryType = DIQueries.MetadataElementTypeText[MetadataElementType.Indicator]; MetadataPrefix = UserPreference.UserPreference.DataviewPreference.MetadataIndicator; // Get Metadata fields from userPreference arrSelectedMetadataFields = userPreference.DataView.MetadataIndicatorField.Split(",".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); // Set Mask file path MaskFilePath = Path.Combine(this.msMaskFolder, MASK_FILE_INDICATOR); //Set Join column and Metadata Column name JoinColumnName = Indicator.IndicatorNId; MetadataColumnName = Indicator.IndicatorInfo; // Get distinct indicator nids DistinctElementTable = this._IUSIndicator.DefaultView.ToTable(true, JoinColumnName); DistinctNIds = new string[DistinctElementTable.Rows.Count]; for (int i = 0; i < DistinctElementTable.Rows.Count; i++) { DistinctNIds[i] = DistinctElementTable.Rows[i][JoinColumnName].ToString(); } // Get Metadata Info for all Indicators _Query = this.mdIQueries.Indicators.GetIndicator(FilterFieldType.NId, string.Join(",", DistinctNIds), FieldSelection.Heavy); dvMetadataInfo = this.ExecuteInvariantDataTable(_Query).DefaultView; ElementMetadataTable = this._MetadataIndicator; break; case MetadataElementType.Area: // Set Category Type CategoryType = DIQueries.MetadataElementTypeText[MetadataElementType.Area]; MetadataPrefix = UserPreference.UserPreference.DataviewPreference.MetadataArea; // Get Metadata fields from userPreference arrSelectedMetadataFields = userPreference.DataView.MetadataAreaField.Split(",".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); // Set Mask file path MaskFilePath = Path.Combine(this.msMaskFolder, MASK_FILE_AREA); //Get LayerNids for these areas _Query = this.mdIQueries.Area.GetAreaMapByAreaNIds(this._AreaNIds, false); DataTable dtAreaMap = this.ExecuteInvariantDataTable(_Query); //Get Distinct LayerNIds string[] ColumnArray = new string[1]; ColumnArray[0] = Area_Map.LayerNId; DistinctElementTable = dtAreaMap.DefaultView.ToTable(true, ColumnArray); DistinctNIds = new string[DistinctElementTable.Rows.Count]; for (int i = 0; i < DistinctElementTable.Rows.Count; i++) { DistinctNIds[i] = DistinctElementTable.Rows[i][ColumnArray[0]].ToString(); } //Get Metadata for LayerNIds along with associated AreaNIds DataTable dtMetadata = GetInvariantDataTable(); if (DistinctNIds.Length > 0) { //Join to Associate AreaNId and LayerNId DataSet dsParentChild = GetInvariantDataSet(); // Add AreaMap Table dtMetadata = dtAreaMap.Copy(); // Since it might be part if a relationship, therefore adding the COPY dtMetadata.TableName = "Parent"; dtMetadata.Columns.Add(Area_Map_Metadata.MetadataText, typeof(string)); dsParentChild.Tables.Add(dtMetadata); // Add AreaMapMetadata Table _Query = this.mdIQueries.Area.GetAreaMapMetadata(string.Join(",", DistinctNIds)); DataTable dtAreaMapMetadata = this.ExecuteInvariantDataTable(_Query); dtAreaMapMetadata.TableName = "Child"; // Set Primaty Key in the AreaMapMetadata DataColumn[] PK = new DataColumn[1]; PK[0] = dtAreaMapMetadata.Columns[Area_Map_Metadata.LayerNId]; dtAreaMapMetadata.PrimaryKey = PK; dsParentChild.Tables.Add(dtAreaMapMetadata); // Define relationship dsParentChild.Relations.Add("RelAreaMap", dsParentChild.Tables[1].Columns[Area_Map.LayerNId], dsParentChild.Tables[0].Columns[Area_Map_Metadata.LayerNId], false); dsParentChild.Tables[0].Columns[Area_Map_Metadata.MetadataText].Expression = "Parent(RelAreaMap)." + Area_Map_Metadata.MetadataText; dsParentChild.AcceptChanges(); } dvMetadataInfo = dtMetadata.DefaultView; //(AreaNId-LayerNId-MetadataText) //Set Join column and Metadata Column name JoinColumnName = Area.AreaNId; MetadataColumnName = Area_Map_Metadata.MetadataText; // Get distinct area nids DistinctNIds = this._AreaNIds.Split(",".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); // Set metadata table ElementMetadataTable = this._MetadataArea; break; case MetadataElementType.Source: // Set Category Type CategoryType = DIQueries.MetadataElementTypeText[MetadataElementType.Source]; MetadataPrefix = UserPreference.UserPreference.DataviewPreference.MetadataSource; // Get Metadata fields from userPreference arrSelectedMetadataFields = userPreference.DataView.MetadataSourceField.Split(",".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); // Set Mask file path MaskFilePath = Path.Combine(this.msMaskFolder, MASK_FILE_SOURCE); //Set Join column and Metadata Column name JoinColumnName = IndicatorClassifications.ICNId; MetadataColumnName = IndicatorClassifications.ICInfo; // Get distinct source nids DistinctNIds = new string[this._Sources.Rows.Count]; for (int i = 0; i < this._Sources.Rows.Count; i++) { DistinctNIds[i] = this._Sources.Rows[i][JoinColumnName].ToString(); } // Get Metadata Info for all sources _Query = this.mdIQueries.IndicatorClassification.GetIC(FilterFieldType.NId, string.Join(",", DistinctNIds), ICType.Source, FieldSelection.Heavy); dvMetadataInfo = this.ExecuteInvariantDataTable(_Query).DefaultView; // Set metadata table ElementMetadataTable = this._MetadataSource; break; } // Check for existence of indicator mask file if (File.Exists(MaskFilePath)) { // Try loading indicator mask file try { MaskFileDocument.Load(MaskFilePath); } catch (Exception) { //TODO do not proceed further } } // Add Join columns to Metadata table ElementMetadataTable.Columns.Clear(); ElementMetadataTable.Columns.Add(JoinColumnName, typeof(int)); if (this._CensusInfoFeature) { _Query = this.mdIQueries.Metadata_Category.GetMetadataCategories(FilterFieldType.Type, CategoryType); DataView dvMetadataCategory = this.ExecuteInvariantDataTable(_Query).DefaultView; for (int j = 0; j < arrSelectedMetadataFields.Length; j++) { // Add Metadata columns to Metadata table ElementMetadataTable.Columns.Add(arrSelectedMetadataFields[j], typeof(string)); ElementMetadataTable.Columns[arrSelectedMetadataFields[j]].DefaultValue = string.Empty; // For each distinct Element for (int i = 0; i < DistinctNIds.Length; i++) { DataRow drMetadata; if (j == 0) { // Create data row for each Element (Indicator / Area / Source) only once drMetadata = ElementMetadataTable.NewRow(); drMetadata[JoinColumnName] = DistinctNIds[i]; } else { // If data row alreday exists simply update the desired field drMetadata = ElementMetadataTable.Select(JoinColumnName + " = " + DistinctNIds[i])[0]; } if (dvMetadataInfo != null && dvMetadataInfo.Table.Columns.Contains(JoinColumnName)) { dvMetadataInfo.RowFilter = JoinColumnName + " = " + DistinctNIds[i]; // Check for valid xml content if (dvMetadataInfo.Count > 0) { MetadataXml = dvMetadataInfo[0][MetadataColumnName].ToString(); if (MetadataXml != null && MetadataXml.Trim().Length > 0) { try // Try loading metadata xml { //Get all FLD_VAL contents into a Nodelist XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(dvMetadataInfo[0][MetadataColumnName].ToString()); dvMetadataCategory.RowFilter = Metadata_Category.CategoryNId + " = " + arrSelectedMetadataFields[j].Replace(MetadataPrefix, ""); if (dvMetadataCategory != null && dvMetadataCategory.Count > 0) { XmlNode CategoryXmlNode = xmlDoc.SelectSingleNode("//Category[@name='" + dvMetadataCategory[0][Metadata_Category.CategoryName].ToString() + "']"); string ParaNodeText = string.Empty; if (!String.IsNullOrEmpty(CategoryXmlNode.InnerText)) { // Replace Para defining delimiter by new line character ParaNodeText = CategoryXmlNode.InnerText.Replace(DevInfo.Lib.DI_LibBAL.DA.DML.MetadataManagerConstants.ReplaceableSymbol, Environment.NewLine); } // get category value from xml (from <para> tags) //foreach (XmlNode ParaNode in CategoryXmlNode.ChildNodes) //{ // // get para node text // // add para node into concatenated category value // if (!string.IsNullOrEmpty(ParaNodeText)) // { // ParaNodeText += Microsoft.VisualBasic.ControlChars.NewLine ; // } // ParaNodeText += ParaNode.InnerText.Trim(); //} // Based on position information (index) get Metadata content drMetadata[arrSelectedMetadataFields[j]] = ParaNodeText; } } catch (Exception) { //If unable to load metadata text then fields shall remain empty } } } dvMetadataInfo.RowFilter = string.Empty; } // Add element row only while looping for first field if (j == 0) { ElementMetadataTable.Rows.Add(drMetadata); } } } } else { // For each selected field for indicator / area (map) / source metadata for (int j = 0; j < arrSelectedMetadataFields.Length; j++) { // Add Metadata columns to Metadata table ElementMetadataTable.Columns.Add(arrSelectedMetadataFields[j], typeof(string)); ElementMetadataTable.Columns[arrSelectedMetadataFields[j]].DefaultValue = string.Empty; // Get position information from mask file MaskNodeList = MaskFileDocument.SelectNodes("*/*[ID='" + arrSelectedMetadataFields[j] + "']"); //root/Input1/ID if (MaskNodeList.Count > 0) { if (MaskNodeList[0].SelectNodes("Position")[0] != null) //TODO Remove Hardcoding "Position" { MaskPositionText = MaskNodeList[0].SelectNodes("Position")[0].InnerText; //TODO Remove Hardcoding "Position" MaskPositionArray = MaskPositionText.Split("/".ToCharArray(), System.StringSplitOptions.RemoveEmptyEntries); if (MaskPositionArray.Length == 5) // 1/1/1/n/1 1/2/1/n/1 { // For each distinct Element for (int i = 0; i < DistinctNIds.Length; i++) { DataRow drMetadata; if (j == 0) { // Create data row for each Element (Indicator / Area / Source) only once drMetadata = ElementMetadataTable.NewRow(); drMetadata[JoinColumnName] = DistinctNIds[i]; } else { // If data row alreday exists simply update the desired field drMetadata = ElementMetadataTable.Select(JoinColumnName + " = " + DistinctNIds[i])[0]; } if (dvMetadataInfo != null && dvMetadataInfo.Table.Columns.Contains(JoinColumnName)) { dvMetadataInfo.RowFilter = JoinColumnName + " = " + DistinctNIds[i]; // Check for valid xml content if (dvMetadataInfo.Count > 0) { MetadataXml = dvMetadataInfo[0][MetadataColumnName].ToString(); if (MetadataXml.Trim().Length > 0) { try // Try loading metadata xml { MetadataDocument.LoadXml(MetadataXml); //Get all FLD_VAL contents into a Nodelist MetadataFld_ValNodeList = MetadataDocument.SelectNodes("Indicator_Info/Row1/FLD_VAL"); //TODO Remove Hardcoding // Based on position information (index) get Metadata content //drMetadata[arrSelectedMetadataFields[j]] = "abc"; if (MetadataFld_ValNodeList.Count >= int.Parse(MaskPositionArray[1])) { drMetadata[arrSelectedMetadataFields[j]] = MetadataFld_ValNodeList[(int.Parse(MaskPositionArray[1]) - 1)].InnerText.Trim(); } } catch (Exception) { //If unable to load metadata text then fields shall remain empty } } } } // Add element row only while looping for first field if (j == 0) { ElementMetadataTable.Rows.Add(drMetadata); } } } } } } } return RetVal; }
/// <summary> /// Build Metadata tables for Indicator, Area and Source /// </summary> /// <param name="userPreference"></param> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <returns></returns> private void BuildMetadataTables(UserPreference.UserPreference userPreference, DI_LibDAL.Connection.DIConnection dIConnection, DI_LibDAL.Queries.DIQueries dIQueries) { if (userPreference.DataView.MetadataIndicatorField.Length > 0) { SetMetedataTables(MetadataElementType.Indicator, userPreference, dIConnection, dIQueries); } if (userPreference.DataView.MetadataAreaField.Length > 0) { SetMetedataTables(MetadataElementType.Area, userPreference, dIConnection, dIQueries); } if (userPreference.DataView.MetadataSourceField.Length > 0) { SetMetedataTables(MetadataElementType.Source, userPreference, dIConnection, dIQueries); } }
/// <summary> /// Initializes the Map object and setting its properties with the parameters passed. DIConnection + DIQueries (for Database operations) /// </summary> /// <param name="presentationData">DataView containing Most recent Data</param> /// <param name="DIConnection"></param> /// <param name="DIQueries"></param> /// <param name="UserSelection">UserSelection</param> public Map(DIDataView DIDataView, DIConnection DIConnection, DIQueries DIQueries, UserPreference.UserPreference userPreference) { this._DIDataView = DIDataView; //Sets the private variable to connection object. this.DIConnection = DIConnection; //Sets the private variable to DiQueries object. this.DIQueries = DIQueries; //Set the userPreference & userSelection. this._UserPreference = userPreference; // Property is used when deserializing Map object and again re-creating DIDataView. //Set Presentation data this._PresentationData = DIDataView.GetPresentationData(); // sets MetaData columns in its properties. (this._MDindicators, this._MDArea, this._MDSource are used in GeneratePresentation() where columns are needed to be displayed in excel sheet) this.SetMetadataInfo(); }
/// <summary> /// It prepares PresentationData using DIDataView class for specified Userselections. /// </summary> /// <param name="dBConnection"></param> /// <param name="dBQueries"></param> /// <param name="userSelection"></param> /// <param name="xmlLanguageFileNameWPath"></param> /// <returns></returns> private static DataView GetPresentationData(DIConnection dBConnection, DIQueries dBQueries, UserSelection userSelection, string xmlLanguageFileNameWPath) { DataView RetVal = null; //Create UserPreference required for DIDataView object. UserPreference UserPreference = new UserPreference(xmlLanguageFileNameWPath); UserPreference.UserSelection = userSelection; // prepare Map's dataview DIDataView DIDataView = new DevInfo.Lib.DI_LibBAL.UI.DataViewPage.DIDataView(UserPreference, dBConnection, dBQueries, "", ""); RetVal = DIDataView.GetAllDataByUserSelection(); if (RetVal == null) { RetVal = dBConnection.ExecuteDataTable(dBQueries.Data.GetPresentationData(userSelection, dBConnection.ConnectionStringParameters.ServerType)).DefaultView; } return RetVal; }
/// <summary> /// Constructor /// </summary> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <param name="pref"></param> /// <param name="stockFolderPath"></param> public DIWizard(DIConnection dIConnection, DIQueries dIQueries, ref UserPreference pref,string stockFolderPath) { // -- Set DAL connection object this.DbConnection = dIConnection; // -- Set DAL query object this.DbQueries = dIQueries; // -- Set the user preference object this._UserPreference = pref; // -- Create the instance of panel collection this._DIWizardPanels = new DIWizardPanels(); // -- Intialize the panels. this.IntializePanel(); // -- Intialize the navigation history property. this._NavigationHistory = new List<string>(); // -- Intialize the selection order history. this.SelectionOrder = new List<string>(); this.StockFolderPath = stockFolderPath; //-- Create the selection list. this.BuildSelectionList(); //-- Create the selection count list. this.BuildSelectionCountList(); if (!Directory.Exists(Path.Combine(this.StockFolderPath, Constants.CACHE))) { // -- Create the directory, if not exists Directory.CreateDirectory(Path.Combine(this.StockFolderPath, Constants.CACHE)); } // -- Create the database cache folder. this.CreateDbFolder(); // -- check for the existence of Diwizard.xml if (!File.Exists(Path.Combine(this.DbNamePath, Constants.DB_CACHE_FILENAME))) { // -- If not found create the file this.SaveRecordCount(); } else { // -- If found, retrieve the record this.AvailableNIdCache = CacheInfo.Load(Path.Combine(this.DbNamePath, Constants.DB_CACHE_FILENAME)); if (this.AvailableNIdCache == null) { this.AvailableNIdCache = new CacheInfo(); // -- If the file is not properly saved. this.SaveRecordCount(); } } //if (File.Exists(Path.Combine(this.DbNamePath, Constants.DB_CACHE_FILENAME))) //{ // //-- get the avialabel NIds // this.GetAvailableRecords(Path.Combine(this.DbNamePath, Constants.DB_CACHE_FILENAME)); //} }
/// <summary> /// Check for changes in user pref properties, and fire the event accordingly. /// </summary> /// <param name="tempUserPreference"></param> /// <returns></returns> public void UserPreferenceAffected(UserPreference tempUserPreference) { bool Success = false; try { //-- If there is any change regarding to the Data related porperty, its event will get fired. Success = this.DataviewAffected(tempUserPreference); //-- If there is any change regarding to the Indicator related porperty, its event will get fired. Success = this.IndicatorAffected(tempUserPreference); //-- If there is any change regarding to the preview limit porperty, its event will get fired. Success = this.PreviewAffected(tempUserPreference); //-- If there is any change regarding to the Timeperiod related porperty, its event will get fired. Success = this.TimePeriodAffected(tempUserPreference); //-- If there is any change regarding to the Area related porperty, its event will get fired. Success = this.AreaAffected(tempUserPreference); } catch (Exception ex) { } }
/// <summary> /// If there is any change regarding to the Area related porperty, its event will get fired. /// </summary> /// <param name="tempUserPreference"></param> /// <returns></returns> private bool AreaAffected(UserPreference tempUserPreference) { //-- sort by AreaId if (this.General.SortAreaTreeByAreaId != tempUserPreference.General.SortAreaTreeByAreaId) { this.RaiseAreaContentChangedEvent(); return true; } //-- global Color if (this.General.ShowGlobalColor != tempUserPreference.General.ShowGlobalColor) { this.RaiseAreaContentChangedEvent(); return true; } //-- global Color if (this.General.GlobalColor != tempUserPreference.General.GlobalColor) { this.RaiseAreaContentChangedEvent(); return true; } //-- Interface lang. if (this.Language.InterfaceLanguage != tempUserPreference.Language.InterfaceLanguage) { this.RaiseAreaContentChangedEvent(); return true; } //-- Database lang. if (this.Database.DatabaseLanguage != tempUserPreference.Database.DatabaseLanguage) { this.RaiseAreaContentChangedEvent(); return true; } return false; }
/// <summary> /// Sets the DIAdaptations static property and sets the Adaptations folder path. /// </summary> /// <param name="appPath"></param> public static void GetAdaptationFolderPath(string appPath) { try { DIAdaptations DIAdaptationObj; if (!_IsDILiteSetup) { //-- Get the DIAdapatation.xml file path. AdaptationFileNameWPath = Path.Combine(appPath, DIAdaptations.DI_ADAPTATIONS_FILENAME); } if (File.Exists(AdaptationFileNameWPath)) { DIAdaptationObj = DIAdaptations.Load(AdaptationFileNameWPath); if (!String.IsNullOrEmpty(DIAdaptationObj.LastUsedAdaptation.AdaptationFolder)) { AdaptationFolderPath = DIAdaptationObj.LastUsedAdaptation.AdaptationFolder; //-- check for the existence of adaptation folder path. if (Directory.Exists(AdaptationFolderPath)) { //-- Create the instance of Adaptation.xml if (File.Exists(Path.Combine(AdaptationFolderPath, Adaptation.ADAPTATION_FILE_NAME))) { AdaptationObj = Adaptation.Load(Path.Combine(AdaptationFolderPath, Adaptation.ADAPTATION_FILE_NAME)); } else { AdaptationObj = new Adaptation(); } } } } else if (_IsDILiteSetup) { if (!string.IsNullOrEmpty(_AdaptationFolderPath)) { if (File.Exists(Path.Combine(_AdaptationFolderPath, Adaptation.ADAPTATION_FILE_NAME))) { AdaptationObj = Adaptation.Load(Path.Combine(AdaptationFolderPath, Adaptation.ADAPTATION_FILE_NAME)); } else { AdaptationObj = new Adaptation(); } } } if (AdaptationObj != null && Directory.Exists(Path.Combine(Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Stock), AdaptationObj.DirectoryLocation.SystemFolder))) { if (!File.Exists(Path.Combine(Path.Combine(Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Stock), AdaptationObj.DirectoryLocation.SystemFolder), UserPreference.USER_PREF_FILE_NAME))) { UserPreferenceObj = new UserPreference(Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Language)); if (Directory.Exists(Path.Combine(Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Stock), AdaptationObj.DirectoryLocation.SystemFolder))) { //-- If the system file directory exists. PrefFilePath = Path.Combine(Path.Combine(Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Stock), AdaptationObj.DirectoryLocation.SystemFolder), UserPreference.USER_PREF_FILE_NAME); } else { PrefFilePath = string.Empty; } } else { UserPreferenceObj = UserPreference.Load(Path.Combine(Path.Combine(Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Stock), AdaptationObj.DirectoryLocation.SystemFolder), UserPreference.USER_PREF_FILE_NAME), Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Language)); PrefFilePath = Path.Combine(Path.Combine(Path.Combine(AdaptationFolderPath, AdaptationObj.DirectoryLocation.Stock), AdaptationObj.DirectoryLocation.SystemFolder), UserPreference.USER_PREF_FILE_NAME); } } } catch (Exception) { } }
/// <summary> /// If there is any change regarding to the Data related porperty, its event will get fired. /// </summary> /// <param name="tempUserPreference"></param> /// <returns></returns> private bool DataviewAffected(UserPreference tempUserPreference) { int Index = 0; #region " -- ContentAffected -- " //-- Paging if (this.General.PageSize != tempUserPreference.General.PageSize) { this._UserPreferenceChanged = AffectedDataview.ContentAffected; this.RaiseDataContentChangedEvent(); return true; } //////// Table Preview Limit //////if (this.DataView.TablePreviewLimit != tempUserPreference.DataView.TablePreviewLimit) //////{ ////// this._UserPreferenceChanged = AffectedDataview.ContentAffected; ////// this.RaiseDataContentChangedEvent(); ////// return true; //////} //////// Graph Preview Limit //////if (this.DataView.GraphPreviewLimit != tempUserPreference.DataView.GraphPreviewLimit) //////{ ////// this._UserPreferenceChanged = AffectedDataview.ContentAffected; ////// this.RaiseDataContentChangedEvent(); ////// return true; //////} //-- DB language if (this.Database.DatabaseLanguage != tempUserPreference.Database.DatabaseLanguage) { this._UserPreferenceChanged = AffectedDataview.ContentAffected; this.RaiseDataContentChangedEvent(); return true; } //-- Data if (this.DataView.Fields.Rows.Count != tempUserPreference.DataView.Fields.Rows.Count) { this._UserPreferenceChanged = AffectedDataview.ContentAffected; this.RaiseDataContentChangedEvent(); return true; } if (this.General.ShowRecommendedSourceColor != tempUserPreference.General.ShowRecommendedSourceColor) { this._UserPreferenceChanged = AffectedDataview.ContentAffected; this.RaiseDataContentChangedEvent(); return true; } //-- Existence of field. foreach (Field DvField in this.DataView.Fields.Rows) { if (tempUserPreference.DataView.Fields.Rows[DvField.FieldID] == null) { this._UserPreferenceChanged = AffectedDataview.ContentAffected; this.RaiseDataContentChangedEvent(); return true; } } //-- Metadata fields if (this.DataView.MetadataIndicatorField != tempUserPreference.DataView.MetadataIndicatorField || this.DataView.MetadataAreaField != tempUserPreference.DataView.MetadataAreaField || this.DataView.MetadataSourceField != tempUserPreference.DataView.MetadataSourceField) { this._UserPreferenceChanged = AffectedDataview.ContentAffected; this.RaiseDataContentChangedEvent(); return true; } //-- Ic fields if (this.DataView.ICSectorGIds != tempUserPreference.DataView.ICSectorGIds || this.DataView.ICSourceGIds != tempUserPreference.DataView.ICSourceGIds || this.DataView.ICInstitutionalGIds != tempUserPreference.DataView.ICInstitutionalGIds || this.DataView.ICThemeGIds != tempUserPreference.DataView.ICThemeGIds || this.DataView.ICConventionGIds != tempUserPreference.DataView.ICConventionGIds || this.DataView.ICGoalGIds != tempUserPreference.DataView.ICGoalGIds) { this._UserPreferenceChanged = AffectedDataview.ContentAffected; this.RaiseDataContentChangedEvent(); return true; } #endregion #region " -- LayoutAffected -- " //-- global Color if (this.General.ShowGlobalColor != tempUserPreference.General.ShowGlobalColor) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } if (this.General.GlobalColor != tempUserPreference.General.GlobalColor) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } //-- Source if (this.General.ShowRecommendedSourceColor != tempUserPreference.General.ShowRecommendedSourceColor) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } if (this.General.RecommendedSourceColor != tempUserPreference.General.RecommendedSourceColor) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } //-- Comments if (this.General.ShowComments != tempUserPreference.General.ShowComments) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } //-- Interface Language if (this.Language.InterfaceLanguage != tempUserPreference.Language.InterfaceLanguage) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } //-- Field Order. for (Index = 0; Index < this.DataView.Fields.Rows.Count; Index++) { if (this.DataView.Fields.Rows[Index].FieldID != tempUserPreference.DataView.Fields.Rows[Index].FieldID) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.DataLayoutChangedEvent(); return true; } } //-- Alternate dataview color if (this.DataView.ShowDataviewAlternateColor != tempUserPreference.DataView.ShowDataviewAlternateColor) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } if (this.DataView.DataviewAlternateColor != tempUserPreference.DataView.DataviewAlternateColor) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } if (this.DataView.AllowRowFiltering != tempUserPreference.DataView.AllowRowFiltering) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } if (this.DataView.DataValueAlignment != tempUserPreference.DataView.DataValueAlignment) { this._UserPreferenceChanged = AffectedDataview.LayoutAffected; this.RaiseDataLayoutChangedEvent(); return true; } #endregion this._UserPreferenceChanged = AffectedDataview.None; return false; }
private bool ExportData() { bool RetVal = false; try { UserPreference TempUserPref = new UserPreference(); TempUserPref.UserSelection = this.UserSelection; //- Insert SourceDatabase UT_Data table into Temp table in Target Database this.InsertDataTableIntoTemp(); DIExport.RaiseExportProgressBarIncrement(45); //- Delete from UT_data by DataView Filters if present in UserSelection this.DeleteFromDataByDataFilters(); DIExport.RaiseExportProgressBarIncrement(50); //- Update New NIds of Indicator, Unit, Subgroup in temp Data Table this.UpdateNewI_U_S_NIds(); DIExport.RaiseExportProgressBarIncrement(55); //- Update NewNId of IUS in temp Data Table this.UpdateNewIUSNIds(); DIExport.RaiseExportProgressBarIncrement(60); //- Update NewTimePeriodNId in temp Data Table this.UpdateNewTimePeriodNId(); DIExport.RaiseExportProgressBarIncrement(65); //- Update NewSourceNId in temp Data Table this.UpdateNewSourceNIds(); DIExport.RaiseExportProgressBarIncrement(70); //- Insert Records from Temp Data into Main UT_Data this.InsertDataFromTempIntoMain(); DIExport.RaiseExportProgressBarIncrement(75); this.InsertSourceNId_IUSNIdRelationship(); DIExport.RaiseExportProgressBarIncrement(80); } catch { throw; } return RetVal; }
/// <summary> /// Constructor for DIDataView builds up the primary information for getting paged data /// </summary> /// <param name="userPreference"></param> /// <param name="dIConnection"></param> /// <param name="dIQueries"></param> /// <param name="maskFolder">Path of Mask Folder where mask files for Indicator, Area and Source metadata resides. Constants for mask file name are available within this class</param> /// <param name="languageFilePath">Path of language file, used to set language based column captions</param> public DIDataView(UserPreference.UserPreference userPreference, DI_LibDAL.Connection.DIConnection dIConnection, DI_LibDAL.Queries.DIQueries dIQueries, string maskFolder, string commentsDataNIds) { string _Query = string.Empty; string[] DistinctColumns = new string[1]; // -- Connection details preserved for getting IUSSource (recommended source) later on demand this.mdIConnection = dIConnection; this.mdIQueries = dIQueries; this.mUserPreference = userPreference; this.mUserPreference.UserSelection.UserSelectionChangeEvent += UserSelectionChanged; // Mask folder for Metadata this.msMaskFolder = maskFolder; this._PagingCompleted = false; #region STEP 1: Get DataNIDs for the selected Indicator, Time and Area and Build the Master Tables // -- STEP 1: Get DataNIDs for the selected Indicator, Time and Area // -- STEP 1.1 - Build Query for the Data View - This query will return only the DataNIds on the basis of the selected I, A and T // Query for Data NIDs //We have to get data for records which are marked as deleted and still to be displayed at Data page if (string.IsNullOrEmpty(commentsDataNIds)) { _Query = dIQueries.Data.GetDataNIDByIUSTimePeriodAreaSource(userPreference.UserSelection, dIConnection.ConnectionStringParameters.ServerType, ""); } else { _Query = dIQueries.Data.GetDataNIDByIUSTimePeriodAreaSource(userPreference.UserSelection, dIConnection.ConnectionStringParameters.ServerType, commentsDataNIds); } // -- STEP 1.2: Execute the Query // -- This Data Table will have all the DataNIDs and wil be used in other operations to fetch data DataTable dtData = this.ExecuteInvariantDataTable(_Query); // -- STEP 1.3: Inititalize Data Tables InitializeVariables(); // -- STEP 1.4: Creating the Data Tables for // DataNID, IUSNId and IUS_SourceNId (These Datatables will be used in the DataView Page to fill the Data, Source, Unit and Subgroup Lists) // Indicator (master table based on IUSNId) // Unit (master table based on IUSNId) // Subgroup (master table based on IUSNId) // Source (master table based on IUS_SourceNId) if (dtData != null && dtData.Rows.Count > 0) { // Distinct DataNId DistinctColumns[0] = DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Data.DataNId; this._AllDataNIDs = dtData.DefaultView.ToTable(false, DistinctColumns); this._FilteredDataNIds = this._AllDataNIDs.Copy(); StringBuilder sbDataNIDs = new StringBuilder(); for (int i = 0; i < this._AllDataNIDs.Rows.Count; i++) { sbDataNIDs.Append("," + this._AllDataNIDs.Rows[i][Data.DataNId]); } if (sbDataNIDs.Length > 0) { msAllDataNIDs = sbDataNIDs.ToString().Substring(1); } // Distinct IUSNID DistinctColumns[0] = DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Data.IUSNId; DataTable dtIUSNIDs = GetInvariantDataTable(); dtIUSNIDs = dtData.DefaultView.ToTable(true, DistinctColumns); StringBuilder sbIUSNIDs = new StringBuilder(); this._IUSNIds = string.Empty; for (int i = 0; i < dtIUSNIDs.Rows.Count; i++) { sbIUSNIDs.Append("," + dtIUSNIDs.Rows[i][Data.IUSNId]); } if (sbIUSNIDs.Length > 0) { this._IUSNIds = sbIUSNIDs.ToString().Substring(1); } // Distinct AreaNIds DistinctColumns[0] = Data.AreaNId; DataTable dtAreaNIds = GetInvariantDataTable(); dtAreaNIds = dtData.DefaultView.ToTable(true, DistinctColumns); StringBuilder sbAreaNIds = new StringBuilder(); this._AreaNIds = string.Empty; for (int i = 0; i < dtAreaNIds.Rows.Count; i++) { sbAreaNIds.Append("," + dtAreaNIds.Rows[i][Data.AreaNId]); } if (sbAreaNIds.Length > 0) { this._AreaNIds = sbAreaNIds.ToString().Substring(1); } // Distinct TimePeriodNIds DistinctColumns[0] = Data.TimePeriodNId; DataTable dtTimePeriodNIds = GetInvariantDataTable(); dtTimePeriodNIds = dtData.DefaultView.ToTable(true, DistinctColumns); StringBuilder sbTimePeriodNIds = new StringBuilder(); this._TimePeriodNIds = string.Empty; for (int i = 0; i < dtTimePeriodNIds.Rows.Count; i++) { sbTimePeriodNIds.Append("," + dtTimePeriodNIds.Rows[i][Data.TimePeriodNId]); } if (sbTimePeriodNIds.Length > 0) { this._TimePeriodNIds = sbTimePeriodNIds.ToString().Substring(1); } // Distinct SourceNIDs string[] SourceDistinctColumns = new string[2]; SourceDistinctColumns[0] = DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Data.IUSNId; SourceDistinctColumns[1] = DevInfo.Lib.DI_LibDAL.Queries.DIColumns.Data.SourceNId; this.mdtIUSSourceNIDs = dtData.DefaultView.ToTable(true, SourceDistinctColumns); // Build IUSIndicator table this.BuildIUSIndicator(dIConnection, dIQueries); // Build IUSUnit table this.BuildIUSUnit(dIConnection, dIQueries); // Build IUSSubgroup this.BuildIUSSubgroup(dIConnection, dIQueries); // Build Source this.BuildSource(dIConnection, dIQueries); //Build IUSSource this.GetIUSSource(dIConnection, dIQueries); // BuildMetadataTables this.BuildMetadataTables(userPreference, dIConnection, dIQueries); // BuildIUSICInfoTables this.BuildIUSICInfoTable(userPreference, dIConnection, dIQueries, dtIUSNIDs); // Set Paging Info SetPagingInfo(this._AllDataNIDs.Rows.Count); } #endregion }