/// <summary> /// Populates the marketlog views. /// </summary> /// <param name="mlSelected">The selected marketlog</param> /// <param name="bValidItem">If the marketlog is a valid Marketlog object</param> private bool MarketItemSelected(MarketLog mlSelected, bool bValidItem) { if (EnableBargainCombos(bValidItem)) { MarketLog mlChosenItem = mlSelected; string sItem = DataHandler.ReplaceEscapeChars(mlChosenItem.Item); // Save Item hash for reselection if list changes _iItemSelectedHash = mlChosenItem.ItemHash; lblItemsChanged.Visible = false; // Reset notification DataRow[] drFoundRows = Values.dtMarketLogsListTable.Select("item = \'" + sItem + "\'", "region DESC, created DESC"); Hashtable htRegions = new Hashtable(); MarketLog ml; foreach (DataRow dr in drFoundRows) { ml = DataHandler.DataRowToMarketLog(dr); // If optional date filter is set in options, then filter logs /*if (Values.IsLogsDateFilterSet && ml.Created <= Values.LogsDateFilter) * { * MessageBox.Show( "MARKETLOG FILTERED BY ITS DATE" ); * continue; * }*/ // make list for item selection combobox if (!htRegions.Contains(ml.RegionHash)) // if key exists { htRegions.Add(ml.RegionHash, ml); } else { // compare dates of marketlog and replace if newer MarketLog oldItem = (MarketLog)htRegions[ml.RegionHash]; if (oldItem.Created < ml.Created) { htRegions.Remove(ml.RegionHash); htRegions.Add(ml.RegionHash, ml); } } } // Convert regions for current item to arraylist for comboboxes ArrayList alRegionsForCurrentItem = new ArrayList(); MarketLog mlFirstInlistMessage = new MarketLog(); mlFirstInlistMessage.Region = "!!!"; alRegionsForCurrentItem.Insert(0, mlFirstInlistMessage); // Convert to arraylist for sorting foreach (MarketLog mlr in htRegions.Values) { // If optional date filter is set in options, then filter logs if (Values.IsLogsDateFilterSet && mlr.Created <= Values.LogsDateFilter) { continue; } alRegionsForCurrentItem.Add(mlr); } MarketLogComparer compareOn = new MarketLogComparer(MarketLogCompareField.Region); alRegionsForCurrentItem.Sort(compareOn); mlFirstInlistMessage.Region = Values.MSG_SELECT_REGION; ArrayList alRegionsForCurrentItemClone = (ArrayList)alRegionsForCurrentItem.Clone(); _abDoneFirstRegionLoad[0] = false; cbRegionsL.DataSource = alRegionsForCurrentItem; _abDoneFirstRegionLoad[1] = false; cbRegionsR.DataSource = alRegionsForCurrentItemClone; // Do a refresh after new item selected RefreshRegions(); } return(bValidItem); }
/// <summary> /// /// </summary> /// <returns></returns> private DataTable ToDataTable() { DataTable dtLog = null; if (File.Exists(this.FilePath)) //Check if file still exists { DataHandler dh = new DataHandler(); switch (Path.GetExtension(this.FilePath)) { case ".txt": FileStream fs = new FileStream(this.FilePath, FileMode.Open); dtLog = dh.ProcessMarketLog(fs, FileDataTypes.Csv, Values.dtMarketLogsListTable.TableName, ref Values.slStationNames); fs.Close(); break; case ".cache": dtLog = dh.ProcessCachedMarketLog(this.FilePath, Values.dtMarketLogsListTable.TableName, ref Values.slStationNames); break; } } return dtLog; }
/// <summary> /// The initial load of Market logs from cache files. /// ... /// TODO: write the rest... /// ... /// Fills the item ComboBox. /// </summary> private void LoadMarketLogsFromCache() { try { MarketLog ml; Parser p = new Parser(); //reset market logs Values.dtMarketLogsListTable = DataHandler.CreateMarketLogsListTable(); EveCacheParser.Parser.SetCachedFilesFolders("CachedMethodCalls"); EveCacheParser.Parser.SetIncludeMethodsFilter("GetOrders"); FileInfo[] cachedFiles = EveCacheParser.Parser.GetMachoNetCachedFiles(); DirectoryInfo di = new DirectoryInfo(Values.MarketLogPath + "\\Cache"); if (!di.Exists) { di.Create(); } Hashtable htItems = _htAvailLogItems; //EVEMon's integrated unified uploader deletes cache files so we have to protect them foreach (FileInfo fi in cachedFiles) { fi.CopyTo(Values.MarketLogPath + "\\Cache\\" + fi.Name, true); } foreach (FileInfo fi in di.GetFiles()) { ml = p.parseCachedMarketLog(fi, ref Values.dRegionNames); if (ml != null) { Values.dtMarketLogsListTable.Rows.Add(DataHandler.MarketLogToDataRow(ml, Values.dtMarketLogsListTable)); // make list for item selection combobox, filter by date created from options if (!htItems.Contains(ml.ItemHash)) { // If Date filtering is set and logs created date is less than set date, then skip it. if (Values.IsLogsDateFilterSet && ml.Created < Values.LogsDateFilter) { /* skip */ } else { htItems.Add(ml.ItemHash, ml); } } } // Step the progress bar toolStripProgressBar1.PerformStep(); //pbGeneralProgressbar.PerformStep(); } // Put the unique item in an arraylist to sort and use as datasource for combobox ArrayList alItems = new ArrayList(); MarketLog mlFirstInlistMessage = new MarketLog { Item = "!!!" }; alItems.Insert(0, mlFirstInlistMessage); alItems.InsertRange(1, htItems.Values); MarketLogComparer compareOn = new MarketLogComparer(MarketLogCompareField.Item); alItems.Sort(compareOn); // Check for any items at all _isMarketlogsLoaded = alItems.Count > 1; mlFirstInlistMessage.Item = _isMarketlogsLoaded ? Values.MSG_SELECT_ITEM : Values.MSG_NO_LOGS; cbItems.DataSource = alItems; cbItems.MaxDropDownItems = 25; } catch (Exception ex) { MessageBox.Show(ex.Message, Values.MSG_ERROR); } // Clear the progressbar toolStripProgressBar1.Value = 0; // Load the market tree view if (!splitContainerMain.Panel1Collapsed && _isMarketlogsLoaded) { ItemTreeView.LoadTreeView(ref _htAvailLogItems); } LightErrorHandler(); }