/// <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> /// Get the auto select record count and its Nids /// </summary> /// <param name="filename"></param> private void GetAutoSelectRecords(string filename) { this.AutoSelectNIdCache = CacheInfo.Load(Path.Combine(this.DbNamePath, filename)); if (this.AutoSelectNIdCache != null) { //-- Database if (this.AutoSelectRecordCount.ContainsKey(DIWizardPanel.PanelType.Database)) { this.AutoSelectRecordCount[DIWizardPanel.PanelType.Database]= this.AutoSelectNIdCache.DataCount; } else { this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Database, this.AutoSelectNIdCache.DataCount); } //-- Indicator if (this.AutoSelectRecordCount.ContainsKey(DIWizardPanel.PanelType.Indicator)) { this.AutoSelectRecordCount[DIWizardPanel.PanelType.Indicator]= this.AutoSelectNIdCache.IndicatorCount; } else { this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Indicator, this.AutoSelectNIdCache.IndicatorCount); } // -- Area if (this.AutoSelectRecordCount.ContainsKey(DIWizardPanel.PanelType.Area)) { this.AutoSelectRecordCount[DIWizardPanel.PanelType.Area]= this.AutoSelectNIdCache.AreaCount; } else { this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Area, this.AutoSelectNIdCache.AreaCount); } //-- Timr period if (this.AutoSelectRecordCount.ContainsKey(DIWizardPanel.PanelType.TimePeriod)) { this.AutoSelectRecordCount[DIWizardPanel.PanelType.TimePeriod]= this.AutoSelectNIdCache.TimeperiodCount; } else { this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.TimePeriod, this.AutoSelectNIdCache.TimeperiodCount); } //-- source if (this.AutoSelectRecordCount.ContainsKey(DIWizardPanel.PanelType.Source)) { this.AutoSelectRecordCount[DIWizardPanel.PanelType.Source]= this.AutoSelectNIdCache.SourceCount; } else { this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Source, this.AutoSelectNIdCache.SourceCount); } // -- Indicator NIds if (this._AutoSelectRecords.ContainsKey(DIWizardPanel.PanelType.Indicator)) { this._AutoSelectRecords[DIWizardPanel.PanelType.Indicator]=this.AutoSelectNIdCache.IndicatorNIds; } else { this._AutoSelectRecords.Add(DIWizardPanel.PanelType.Indicator, this.AutoSelectNIdCache.IndicatorNIds); } //-- Area Nids if (this._AutoSelectRecords.ContainsKey(DIWizardPanel.PanelType.Area)) { this._AutoSelectRecords[DIWizardPanel.PanelType.Area]=this.AutoSelectNIdCache.AreaNIds; } else { this._AutoSelectRecords.Add(DIWizardPanel.PanelType.Area, this.AutoSelectNIdCache.AreaNIds); } // -- Time period NIds if (this._AutoSelectRecords.ContainsKey(DIWizardPanel.PanelType.TimePeriod)) { this._AutoSelectRecords[DIWizardPanel.PanelType.TimePeriod]= this.AutoSelectNIdCache.TimeperiodNIds; } else { this._AutoSelectRecords.Add(DIWizardPanel.PanelType.TimePeriod, this.AutoSelectNIdCache.TimeperiodNIds); } // -- Source if (this._AutoSelectRecords.ContainsKey(DIWizardPanel.PanelType.Source)) { this._AutoSelectRecords[DIWizardPanel.PanelType.Source]= this.AutoSelectNIdCache.SourceNIds; } else { this._AutoSelectRecords.Add(DIWizardPanel.PanelType.Source, this.AutoSelectNIdCache.SourceNIds); } } else { this.AutoSelectNIdCache = new CacheInfo(); this.SaveAutoSelectNidsCount(filename); } //this.AutoSelectRecordCount = new Dictionary<DIWizardPanel.PanelType, int>(); //this._AutoSelectRecords = new Dictionary<DIWizardPanel.PanelType, string>(); //XmlDocument XmlDocument = new XmlDocument(); //XmlDocument.Load(Path.Combine(this.DbNamePath, filename)); //XmlNodeList XmlNodeLst = XmlDocument.SelectNodes("Selection"); //for (int Count = 0; Count < XmlNodeLst[0].ChildNodes.Count; Count++) //{ // // -- loop to store the auto select record count and its NIds // for (int ChildCount = 0; ChildCount < XmlNodeLst[0].ChildNodes[Count].ChildNodes.Count; ChildCount++) // { // switch (XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].Name.ToLower()) // { // case "dv": // if (XmlNodeLst[0].ChildNodes[Count].Name.ToLower() == "count") // { // this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Database, Convert.ToInt32(XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText)); // } // break; // case "i": // if (XmlNodeLst[0].ChildNodes[Count].Name.ToLower() == "count") // { // this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Indicator, Convert.ToInt32(XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText)); // } // else // { // this._AutoSelectRecords.Add(DIWizardPanel.PanelType.Indicator, XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText); // } // break; // case "a": // if (XmlNodeLst[0].ChildNodes[Count].Name.ToLower() == "count") // { // this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Area, Convert.ToInt32(XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText)); // } // else // { // this._AutoSelectRecords.Add(DIWizardPanel.PanelType.Area, XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText); // } // break; // case "t": // if (XmlNodeLst[0].ChildNodes[Count].Name.ToLower() == "count") // { // this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.TimePeriod, Convert.ToInt32(XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText)); // } // else // { // this._AutoSelectRecords.Add(DIWizardPanel.PanelType.TimePeriod, XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText); // } // break; // case "s": // if (XmlNodeLst[0].ChildNodes[Count].Name.ToLower() == "count") // { // this.AutoSelectRecordCount.Add(DIWizardPanel.PanelType.Source, Convert.ToInt32(XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText)); // } // else // { // this._AutoSelectRecords.Add(DIWizardPanel.PanelType.Source, XmlNodeLst[0].ChildNodes[Count].ChildNodes[ChildCount].InnerText); // } // break; // default: // break; // } // } //} }