Beispiel #1
0
 protected ProjectBuilder(Project project, ProgressEventHandler total_handler, ProgressEventHandler task_handler)
 {
     this.project = project;
     this.total_handler = total_handler;
     this.task_handler = task_handler;
     total = new ProgressEventArgs ();
 }
 public void OnProgressUpdate(object sender, ProgressEventArgs args)
 {
     this.filteredReplays = args.Filtered;
       this.totalReplays = args.Total - args.Filtered;
       this.progressBar1.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action<double>(this.UpdateProgressBar), args.Progress);
       this.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(this.Refresh));
 }
Beispiel #3
0
        public void ProgressHadler(object sender, ProgressEventArgs e)
        {
            if (!Visible)
                Show();

            if (e.Step == 0)
            {
                progressBar.Maximum = e.Steps;
                begin = DateTime.Now;
            }
            progressBar.Value = e.Step;

            stepLabel.Text = e.Step.ToString() + "/" + e.Steps.ToString();
            actionNameLabel.Text = e.Process + " (" + e.ProcessedItem + ")";
            Text = "Loading... (" + DateTime.Now.Subtract(begin).ToString() + ")";

            if (DateTime.Now.Subtract(lastRefresh).Milliseconds > 200)
            {
                lastRefresh = DateTime.Now;
                Refresh();
            }

            if (e.Step == (e.Steps - 1))
                Hide();
        }
 void processor_ProgressUpdate(object sender, ProgressEventArgs<CopyFileWorkItem> e)
 {
     if (CopyFileProgressUpdate != null)
     {
         CopyFileProgressUpdate(this, e);
     }
 }
Beispiel #5
0
	void OnProgress(object sender, ProgressEventArgs e) {
		if (e.before < this.progress && e.after >= this.progress) {
			Debug.LogFormat("{0} progress went from {1} to {2} which crosses threshold {3}, adding {4} to cash",
			                thing.name, e.before, e.after, this.progress, this.cash);
			MoniesController.Instance.cash += this.cash;
			thing.ProgressChanged -= OnProgress;
		}	
	}
        protected virtual void OnProgressEvent(ProgressEventArgs e)
        {
            Throw.If(e).IsNull();

            EventHandler<ProgressEventArgs> evt = ProgressEvent;
            if (evt != null)
            {
                evt(this, e);
            }
        }
 private void AssertEventArgsCorrect(ProgressEventArgs actual, EventType et, 
   LocalNamespace ns, LocalTopic topic, Status oldStatus, Status newStatus, 
   string message)
 {
   Assert.AreEqual(et, actual.EventType, 
     "Checking that event types are equivalent for " + message); 
   Assert.AreEqual(ns.Name, actual.Namespace.Name, 
     "Checking that namespaces are equivalent for " + message); 
   Assert.AreEqual(topic.Name, actual.Topic.Name, 
     "Checking that topics are equivalent for " + message); 
   Assert.AreEqual(oldStatus, actual.OldStatus, 
     "Checking that old statuses are equivalent for " + message); 
   Assert.AreEqual(newStatus, actual.NewStatus, 
     "Checking that new statuses are equivalent for " + message); 
 }
Beispiel #8
0
        public void ProgressHandler(object sender, ProgressEventArgs e)
        {
            progress.Invoke(new MethodInvoker(delegate()
                                                        {
                                                  	if (!activity.Text.Equals(e.Process))
                                                  		activityProgress.PerformStep();
                                                  	activity.Text = e.Process;
                                                  	activityCountLabel.Text = activityProgress.Value.ToString() + "/3";

                                                  	progressText.Text = e.ProcessedItem;
                                                  	progressCountLabel.Text = e.Step.ToString() + "/" + e.Steps;

                                                            if (e.Step == 0)
                                                                progress.Maximum = e.Steps;

                                                            progress.Value = e.Step;
                                              }));
        }
Beispiel #9
0
        private void ShowProgress(ProgressEventArgs e)
        {
            if ("nextStep".Equals(e.Message))
            {
                label9.Text = "Ready measuring with signal";
                button3.Enabled = true;
                progressBar.Value = 0;
                return;
            }

            if (objProcess.getIsStopped())
            {
                label9.Text = "Result of measurement can be found in c:\\temp\\measurement.txt";
                stopProcess();
                progressBar.Value = 0;
                return;
            }
            progressBar.Value = (progressBar.Value + 1) % 100;

            if ( e.Message.Length > 0 ) label9.Text = e.Message;
        }
 private bool AddFile(string filePath)
 {
     var success = false;
     try
     {
         var tagFile = new TagFile(filePath);
         Files.Add(tagFile);
         FileIndex++;
         success = true;
     }
     catch (TagLib.CorruptFileException)
     {
         FileCount--;
     }
     catch (TagLib.UnsupportedFormatException)
     {
         FileCount--;
     }
     var e = new ProgressEventArgs(index: FileIndex, count: FileCount, path: filePath, success: success);
     Progress.Report(e);
     return e.Continue;
 }
 /// <summary>
 /// The progress item completed handler.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The event arguments.</param>
 private void ProgressItemCompletedHandler(object sender, ProgressEventArgs e)
 {
     this.IsBusy = false;
     this.ReleaseProgressItem();
 }
Beispiel #12
0
 void explorer_OnProgress(object sender, ProgressEventArgs e)
 {
     SetMessageText(e.Message, true);
 }
Beispiel #13
0
 public void OnProgress(object sender, ProgressEventArgs e)
 {
     throw new NotImplementedException();
 }
Beispiel #14
0
 /// <summary>
 /// Shows DC migration progress
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 static void DCMigrationManager_Progress(object sender, ProgressEventArgs e)
 {
     Console.WriteLine("{0}: {1}", e.EventDateTime, e.Message);
 }
 private void ProgressChangePercent(object sender, ProgressEventArgs e)
 {
     Assert.AreEqual(actualPerc, e.Percent);
     actualPerc += actualAdd;
 }
Beispiel #16
0
 public void OnProgress(object sender, ProgressEventArgs e)
 {
     _listener.OnProgress(sender, e);
 }
Beispiel #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void m_ftpClient_ProgressChanged(object sender, ProgressEventArgs e)
        {
            if (e.ThreadId == THREAD_VERSION_CHECK)
            {
                if (e.Percentage == POSFtpClient.ProgressCompleted ||
                    e.Percentage == POSFtpClient.ProgressFailed)
                {
                    if (this.InvokeRequired)
                    {
                        this.BeginInvoke((MethodInvoker) delegate()
                        {
                            Step02_GetVersionResult();
                        });
                    }
                    else
                    {
                        Step02_GetVersionResult();
                    }
                }

                return;
            }


            // folder download
            if (e.Percentage != POSFtpClient.ProgressCompleted)
            {
                UpdateProgress(this, new UpdateProgressEventArgs()
                {
                    StatusMessage   = string.Format("{0} 버전을 다운로드 하는 중...", m_newVersion),
                    ProgressMessage = string.Format("{0}/0", Path.GetFileName(e.ServerFile)),
                    Percentage      = e.Percentage,
                    TotalPercentage = e.TotalPercentage
                });
            }
            else
            {
                UpdateProgress(this, new UpdateProgressEventArgs()
                {
                    StatusMessage   = string.Format("{0} 버전을 다운로드 하는 중...", m_newVersion),
                    ProgressMessage = string.Format("{0}/1", Path.GetFileName(e.ServerFile)),
                    Percentage      = e.Percentage,
                    TotalPercentage = e.TotalPercentage
                });

                if (m_ftpClient.RemainFileCount == 0)
                {
                    if (this.InvokeRequired)
                    {
                        this.BeginInvoke((MethodInvoker) delegate()
                        {
                            Step03_DownloadVersionFolderCompleted();
                        });
                    }
                    else
                    {
                        Step03_DownloadVersionFolderCompleted();
                    }
                }
            }
        }
Beispiel #18
0
 private void OnProgressEvent(ProgressEventArgs e)
 {
     ProgressEvent?.Invoke(this, e);
 }
Beispiel #19
0
 private void MergerProgressEvent(object sender, ProgressEventArgs e)
 {
     OnProgressEvent(e);
 }
 private void Compressor_Compressing(object sender, ProgressEventArgs e)
 {
     ToolStatus.Text       = "Building " + targetBuildName + "..";
     ToolProgress.MaxValue = 100;
     ToolProgress.Value    = e.PercentDone;
 }
 private void OnProgressAvailable(object sender, ProgressEventArgs e)
 {
     ProgressAvailable(this, e);
 }
Beispiel #22
0
 public void InvokeProgress(ProgressEventArgs e)
 {
     Progressed?.Invoke(this, e);
 }
Beispiel #23
0
 public void OnTestGenerated(object sender, ProgressEventArgs e)
 {
     InvokeProgress(e);
 }
		public void InvokeWrittingProgress(ProgressEventArgs e)
		{
			var handler = WrittingProgress;
			if (handler != null)
				handler(this, e);
		}
Beispiel #25
0
        /// <summary>
        /// fires the progress event if necessary
        /// </summary>
        /// <param name="pEArgs"></param>
        /// <returns>"true", if the process should be cancelled, otherwise "false"</returns>
        private Boolean sendProgressEvent(ProgressEventArgs pEArgs)
        {
            long   ProgressSendLevel;
            Boolean retValue            = false;

            try 
	        {	        
               
		        if((m_EventTimer.currentMeasuring() > m_TimeSlice_ms) || pEArgs.ForceRefresh || pEArgs.NewLine || pEArgs.AddSeparator)
                {
                    // time is reason
                    Progress.Raise(this, pEArgs);

                    if(pEArgs.TotalValue > 0)
                        ProgressSendLevel =  ((100 * pEArgs.CurrentValue/pEArgs.TotalValue) / 10) * 10;
                    else
                        ProgressSendLevel =  -1;

                    m_EventTimer.startMeasuring();
                    m_lastProgress = ProgressSendLevel;

                    Debug.Print("Progress (t):" + ProgressSendLevel.ToString());
                }
                else
                { 
                    // progress is reason
                    if(pEArgs.TotalValue > 0)
                        ProgressSendLevel =  ((100 * pEArgs.CurrentValue/pEArgs.TotalValue) / 10) * 10;
                    else
                        ProgressSendLevel =  -1;
                    
                    if(((pEArgs.TotalValue != 0) && (((100 * pEArgs.CurrentValue/pEArgs.TotalValue) % m_PercentSlice) == 0) && (ProgressSendLevel != m_lastProgress)) || 
                       (ProgressSendLevel != m_lastProgress))
                    { 
                        // time is reason
                        Progress.Raise(this, pEArgs);

                        m_EventTimer.startMeasuring();
                        m_lastProgress = ProgressSendLevel;
                        Debug.Print("Progress (l):" + ProgressSendLevel.ToString());
                    }
                }

                retValue = pEArgs.Cancelled ;

                return retValue;
	        }
	        catch (Exception ex)
	        {
		        throw new Exception("Error while checking for progress event needed", ex);
	        }
        }
Beispiel #26
0
 private void ProgressChange(ProgressEventArgs e)
 {
     Assert.AreEqual(actual, e.ProgressCurrent);
     actual += actualAdd;
 }
Beispiel #27
0
		void RunInternal()
		{
			for (int i = 0; i < files.Count; i++)
			{
				string f = files[i];
				multihasnext = false;
				multiindex = 0;
				do
				{
					LoadOne(f);
				} while (multihasnext);
				if (OnProgress != null)
				{
					var e = new ProgressEventArgs(i + 1, files.Count);
					OnProgress(this, e);
					if (e.ShouldCancel)
						return;
				}
			}
		}
Beispiel #28
0
 private void UploadService_Processed(object sender, ProgressEventArgs e)
 {
     this.setProgress(e.Progress);
 }
 public static void OnProgress(int progress)
 {
     try
     {
         var handler = OnProgressHandler;
         if (handler == null) return;
         var args = new ProgressEventArgs(progress);
         handler(null, args);
     }
     catch (Exception)
     {
         //ignored
     }
 }
 void manager_SessionProgressReported(object sender, ProgressEventArgs e)
 {
     Dispatcher.BeginInvoke(new Action(() => { txtSession.Text = e.Message; }));
 }
 public void updateProgress(object sender, ProgressEventArgs e)
 {
     ProgressValue = e.Progress;
 }
Beispiel #32
0
 private void sql_OnTableProgress(object sender, ProgressEventArgs e)
 {
     Application.DoEvents();
     progressBar1.Value = (int)e.Progress;
 }
 private void UpdateStatus(object sender, ProgressEventArgs e)
 {
     SetStatus(e.Status);
 }
Beispiel #34
0
 private void OnProgressAvailable(object sender, ProgressEventArgs e)
 {
     _providerServices.ProgressWindow.ShowProgress(e.Operation, e.PercentComplete);
 }
Beispiel #35
0
 protected override void OnProgress(ProgressEventArgs args)
 {
     this.Log("OnProgress() - progress: {0}%, overall progress: {1}%", args.ProgressPercentage, args.OverallPercentage);
 }
        /// <summary>
        /// Raises the Progress Event
        /// </summary>
        /// <param name="e">The Event Args</param>
        protected void OnProgress(ProgressEventArgs e)
        {
            if (Progress == null)
                return;

            Progress(this, e);
        }
Beispiel #37
0
 private void Initializer_OnProgress(ProgressEventArgs obj)
 {
     Log($"{obj.TotalPercentage}% - {obj.Message} ({obj.ServiceName})");
 }
 /// <summary>
 /// The progress item changed handler.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="e">The event arguments.</param>
 private void ProgressItemChangedHandler(object sender, ProgressEventArgs e)
 {
     this.Percentage = this.progressItem.Percentage;
     this.Subtitle   = this.progressItem.Text;
     this.Title      = this.progressItem.Title;
 }
Beispiel #39
0
        /// <summary>
        /// Imports the prices from a list of csv-strings
        /// </summary>
        /// <param name="CSV_Strings">data to import</param>
        /// <param name="importBehaviour">filter, which prices to import</param>
        /// <param name="dataSource">if data has no information about the datasource, this setting will count</param>
        /// <returns>a list of converted station data (including correct station ids) </returns>
        public List<EDStation> ImportPricesFromCSVStrings(String[] CSV_Strings, enImportBehaviour importBehaviour, enDataSource dataSource)
        {
            Boolean MissingSystem   = false;
            Boolean MissingStation  = false;
            String currentLanguage;
            DataTable newData;
            List<EDStation> StationData;
            List<EDSystem> SystemData = null;
            List<CsvRow> csvRowList = new List<CsvRow>();
            ProgressEventArgs eva;

            Int32 counter = 0;
            Dictionary<String, String> foundNames = new Dictionary<string,string>();            // quick cache for finding commodity names

            try
            {
                // *****************************************************************
                // START :section for automatically add unknown commodities

                currentLanguage     = Program.DBCon.getIniValue(IBESettingsView.DB_GROUPNAME, "Language", Program.BASE_LANGUAGE, false);
                newData             = new DataTable();
                newData.TableName   = "Names";
                newData.Columns.Add(Program.BASE_LANGUAGE, typeof(String));
                if(currentLanguage != Program.BASE_LANGUAGE)
                    newData.Columns.Add(currentLanguage, typeof(String));

                eva = new ProgressEventArgs() { Info="analysing data...", AddSeparator = true};
                sendProgressEvent(eva);

                for (int i = 0; i < CSV_Strings.Length; i++)
                {
                    String currentName;
                    List<dsEliteDB.tbcommoditylocalizationRow> currentCommodity;
                    if (CSV_Strings[i].Trim().Length > 0)
                    {
                        currentName = new CsvRow(CSV_Strings[i]).CommodityName;
                        if (!String.IsNullOrEmpty(currentName))
                        {
                            // check if we need to remap this name
                            Datasets.dsEliteDB.tbdnmap_commodityRow mappedName = (Datasets.dsEliteDB.tbdnmap_commodityRow)BaseData.tbdnmap_commodity.Rows.Find(new object[] {currentName, ""});
                            if (mappedName != null)
                            {
                                CSV_Strings[i] = CSV_Strings[i].Replace(mappedName.CompanionName, mappedName.GameName);
                                currentName = mappedName.GameName;
                            }

                            if (!foundNames.ContainsKey(currentName))
                            {
                                currentCommodity = Program.Data.BaseData.tbcommoditylocalization.Where(x => x.locname.Equals(currentName, StringComparison.InvariantCultureIgnoreCase)).ToList();
                                if (currentCommodity.Count == 0)
                                {
                                    if (currentLanguage == Program.BASE_LANGUAGE)
                                        newData.Rows.Add(currentName);
                                    else
                                        newData.Rows.Add(currentName, currentName);
                                }
                                foundNames.Add(currentName, "");
                            }
                        }
                    }
                    counter++;

                    eva = new ProgressEventArgs() { Info="analysing data...", CurrentValue=counter, TotalValue=CSV_Strings.GetUpperBound(0) + 1 };
                    sendProgressEvent(eva);
                    if(eva.Cancelled)
                        break;
                }

                eva = new ProgressEventArgs() { Info="analysing data...", CurrentValue=counter, TotalValue=counter, ForceRefresh=true };
                sendProgressEvent(eva);

                if (!eva.Cancelled)
                    if(newData.Rows.Count > 0)
                    {
                        // add found unknown commodities
                        var ds = new DataSet();
                        ds.Tables.Add(newData);
                        ImportCommodityLocalizations(ds);

                        // refresh translation columns
                        Program.Data.updateTranslation();

                        // refresh working tables 
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.tbcommoditylocalization.TableName);
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.tbcommodity.TableName);
                    }
                    
                // END : section for automatically add unknown commodities
                // *****************************************************************

                // convert csv-strings to EDStation-objects
                StationData = fromCSV(CSV_Strings, ref SystemData, ref csvRowList);

                // check if we've unknown systems or stations
                if(!eva.Cancelled)
                    foreach (EDStation Station in StationData)
                    {
                        if (Station.SystemId == 0)
                            MissingSystem = true;
                        else if(Station.Id == 0)
                            MissingStation = true;
                    }


                if ((!eva.Cancelled) && MissingSystem)
                {
                    // add unknown systems
                    ImportSystems_Own(ref SystemData, true);
                }

                if (!eva.Cancelled && (MissingSystem || MissingStation))
                {
                    // add unknown stations
                    foreach (EDStation Station in StationData)
                    {
                        // first get all missing system ids
                        if (Station.SystemId == 0)
                        {
                            EDSystem thisSystem = SystemData.FirstOrDefault(x => x.Name == Station.SystemName);

                            if(thisSystem != null)
                            {
                                // got it - set the id
                                Station.SystemId = thisSystem.Id;
                            }
                        }

                    }

                    ImportStations_Own(StationData, new Dictionary<Int32, Int32>(), true);
                }

                // now import the prices
                ImportPrices(StationData, importBehaviour, dataSource);

                if (MissingSystem)
                {
                    // reloading of base tables
                    Program.Data.PrepareBaseTables(Program.Data.BaseData.tbsystems.TableName);
                }

                if (MissingSystem || MissingStation)
                {
                    // reloading of base tables
                    Program.Data.PrepareBaseTables(Program.Data.BaseData.tbstations.TableName);

                    Program.Data.PrepareBaseTables(Program.Data.BaseData.visystemsandstations.TableName);
                }

                return StationData;
            }
            catch (Exception ex)
            {
                throw new Exception("Error while importing self collected price data", ex);
            }
        }
Beispiel #40
0
        /// <summary>
        /// creates a list of "EDStations" with price listings from csv-array
        /// </summary>
        /// <param name="CSV_Strings">String to be converted</param>
        /// <param name="foundSystems"></param>
        /// <param name="csvRowList">for optional processing outside: a list of the data converted to CsvRow-objects</param>
        /// <returns></returns>
        public List<EDStation> fromCSV(String[] CSV_Strings, ref List<EDSystem> foundSystems, ref List<CsvRow> csvRowList)
        {
            List<EDStation> foundValues                     = new List<EDStation>();
            Dictionary<String, Int32> foundIndex            = new Dictionary<String, Int32>();
            Dictionary<String, Int32> foundSystemIndex      = new Dictionary<String, Int32>();
            String LastID                                   = "";
            EDSystem LastSystem                             = null;
            String currentID                                = "";
            EDStation currentStation                        = null;
            Int32 Index                                     = 0;
            Dictionary<String, Int32> commodityIDCache      = new Dictionary<string,Int32>();            // quick cache for finding commodity names
            Int32 currentItem                               = 0;
            ProgressEventArgs eva;

            try
            {
                eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0)+1, AddSeparator = true };
                sendProgressEvent(eva);

                if(foundSystems != null)
                    foundSystems.Clear();
                else
                    foundSystems = new List<EDSystem>();


                foreach (String CSV_String in CSV_Strings)
	            {

                    if(!String.IsNullOrEmpty(CSV_String.Trim()))
                    {
		                CsvRow currentRow           = new CsvRow(CSV_String);

                        if(csvRowList != null)
                            csvRowList.Add(currentRow);

                        currentID = currentRow.StationID;

                        if(!LastID.Equals(currentID, StringComparison.InvariantCultureIgnoreCase))
                        {
                            if(currentStation != null)
                                currentStation.ListingExtendMode = false;

                            if(foundIndex.TryGetValue(currentID, out Index))
                                currentStation = foundValues[Index];
                            else
                            {
                                currentStation  = new EDStation(currentRow);

                                foundValues.Add(currentStation);
                                foundIndex.Add(currentID, foundValues.Count-1);
                            }
                            LastID = currentRow.StationID;

                            currentStation.ListingExtendMode = true;


                            if((LastSystem == null) || (!LastSystem.Name.Equals(currentRow.SystemName, StringComparison.InvariantCultureIgnoreCase)))
                            {
                                if(foundSystemIndex.TryGetValue(currentRow.SystemName, out Index))
                                    LastSystem = foundSystems[Index];
                                else
                                {
                                    LastSystem  = new EDSystem();
                                    LastSystem.Name = currentRow.SystemName;

                                    if(LastSystem.Id == 0)
                                        LastSystem.Id = currentStation.SystemId;


                                    foundSystems.Add(LastSystem);
                                    foundSystemIndex.Add(currentRow.SystemName, foundSystems.Count-1);
                                }
                            }
                        }

                        currentStation.addListing(currentRow, ref commodityIDCache);
                    }

                    eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0)+1};
                    sendProgressEvent(eva);

                    if(eva.Cancelled)
                        break;

                    currentItem++;

	            }

                if(currentStation != null)
                    currentStation.ListingExtendMode = false;

                eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0)+1, ForceRefresh=true};
                sendProgressEvent(eva);

                return foundValues;

            }
            catch (Exception ex)
            {
                throw new Exception("Error while getting station values from CSV-String", ex);
            }
        }
		/// <summary>
		/// This event is used to detect when map is ready for printing.
		/// </summary>
		private void Map_Progress(object sender, ProgressEventArgs e)
		{
			IsMapReady = e.Progress == 100;
		}
Beispiel #42
0
        /// <summary>
        /// exports the market data to a file
        /// </summary>
        /// <param name="fileName"></param>
        public void ExportMarketDataToCSV(string fileName, Boolean inCurrentLanguage, Boolean extendedFormat)
        {
            String sqlString;
            DataTable data;
            Int32 Counter;
            StringBuilder sBuilder = new StringBuilder();
            Char filterCharacter=(char)(48);
            Int32 totalDataCount = 0;
            ProgressEventArgs eva;

            try
            {

                if(System.IO.File.Exists(fileName))
                    System.IO.File.Delete(fileName);

                var writer = new StreamWriter(File.OpenWrite(fileName));

                if(extendedFormat)
                    writer.WriteLine("System;Station;Commodity;Sell;Buy;Demand;;Supply;;Date;SourceFileName;Source");
                else
                    writer.WriteLine("System;Station;Commodity;Sell;Buy;Demand;;Supply;;Date;");

                data        = new DataTable();
                Counter     = 0;
                    
                totalDataCount = Program.DBCon.Execute<Int32>("select count(*) from tbCommodityData;");

                for (int i = 0; i < 36; i++)
                {
                    if(i < 10)
                        filterCharacter = (char)(48 + i);
                    else
                        filterCharacter = (char)(65 + i - 10);

                    if (inCurrentLanguage)
                    {
                        // export names in user language
                        sqlString = String.Format("select Sy.systemname, St.stationname, C.loccommodity as commodity, D.sell, D.buy, D.demand, D.demandlevel, D.supply, D.supplylevel, D.timestamp, S.source" +
                                                  " from tbSystems Sy, tbStations St, tbCommodityData D, tbCommodity C, tbSource S" +
                                                  " where Sy.id           = St.system_id" + 
                                                  " and   St.id           = D.station_id" +
                                                  " and   D.commodity_id  = C.id" +
                                                  " and   D.sources_id    = S.id" +
                                                  " and   Sy.systemname like '{0}%'" +
                                                  " order by Sy.systemname, St.stationname, C.loccommodity",
                                                  filterCharacter); 
                    }
                    else
                    {
                        // export names in default language (english)
                        sqlString = String.Format("select Sy.systemname, St.stationname, C.commodity, D.sell, D.buy, D.demand, D.demandlevel, D.supply, D.supplylevel, D.timestamp, S.source" +
                                                  " from tbSystems Sy, tbStations St, tbCommodityData D, tbCommodity C, tbSource S" +
                                                  " where Sy.id           = St.system_id" + 
                                                  " and   St.id           = D.station_id" +
                                                  " and   D.commodity_id  = C.id" +
                                                  " and   D.sources_id    = S.id" +
                                                  " and   Sy.systemname like '{0}%'" +
                                                  " order by Sy.systemname, St.stationname, C.commodity",
                                                  filterCharacter); 
                    }

                    eva = new ProgressEventArgs() { Info=String.Format("collecting data '{0}'...", filterCharacter), CurrentValue=Counter, TotalValue=totalDataCount, NewLine=true};
                    sendProgressEvent(eva);

                    Program.DBCon.Execute(sqlString, data);

                    foreach (DataRow row in data.Rows)
                    {
                        String Demand = "";
                        String Supply = "";

                        if (inCurrentLanguage)
                        {
                            Demand =  ((String)BaseTableIDToName("economylevel", SQL.DBConvert.To<int?>(row["demandlevel"]), "loclevel")).NToString("");
                            Supply =  ((String)BaseTableIDToName("economylevel", SQL.DBConvert.To<int?>(row["supplylevel"]), "loclevel")).NToString("");
                        }
                        else
                        {
                            Demand =  ((String)BaseTableIDToName("economylevel", SQL.DBConvert.To<int?>(row["demandlevel"]), "level")).NToString("");
                            Supply =  ((String)BaseTableIDToName("economylevel", SQL.DBConvert.To<int?>(row["supplylevel"]), "level")).NToString("");
                        }

                        sBuilder.Append(row["systemname"] + ";" + 
                                        row["stationname"] + ";" + 
                                        row["commodity"] + ";" + 
                                        row["sell"] + ";" + 
                                        row["buy"] + ";" + 
                                        row["demand"] + ";" + 
                                        Demand + ";" + 
                                        row["supply"] + ";" + 
                                        Supply + ";" + 
                                        row["timestamp"]);

                        if(extendedFormat)
                        {

                            sBuilder.Append(";;" +              //sourceFileName, no more in use but for compatibility
                                           row["source"]);      //source
                        }

                        writer.WriteLine(sBuilder.ToString());

                        sBuilder.Clear();

                        Counter++;

                        eva = new ProgressEventArgs() { Info=String.Format("export prices '{0}'...", filterCharacter), CurrentValue=Counter, TotalValue=totalDataCount};
                        sendProgressEvent(eva);
                        if(eva.Cancelled)
                            break;
                    }

                    eva = new ProgressEventArgs() { Info=String.Format("export prices '{0}'...", filterCharacter), CurrentValue=Counter, TotalValue=totalDataCount, ForceRefresh=true};
                    sendProgressEvent(eva);
                    if(eva.Cancelled)
                        break;

                    if(eva.Cancelled)
                        break;

                }

                eva = new ProgressEventArgs() { Info=String.Format("export prices '{0}'...", filterCharacter), CurrentValue=Counter, TotalValue=totalDataCount, ForceRefresh=true};
                sendProgressEvent(eva);

                writer.Close();
                writer.Dispose();
            }
            catch (Exception ex)
            {
                throw new Exception("Error while exporting to csv file", ex);
            }
        }
Beispiel #43
0
 protected virtual void OnProgress(ProgressEventArgs e)
 {
     EventHandler<ProgressEventArgs> myEvent = Progress;
     if (myEvent != null)
     {
         myEvent(this, e);
     }
 }
Beispiel #44
0
        private void ProgressionCallBack(object sender, ProgressEventArgs e)
        {
            this.textProgressInformation.Text += "\nPreparing page " + e.ProgressInfo.CurrentPageNumber.ToString();

            this.progressScrollViewer.ScrollToBottom();
        }
Beispiel #45
0
        /// <summary>
        /// Imports the prices from the list of stations. It's clever
        /// firstly to import the stations from the same file.
        /// </summary>
        /// <param name="Stations"></param>
        private void ImportPrices(List<EDStation> Stations, enImportBehaviour importBehaviour, enDataSource dataSource)
        {
            DBConnector lDBCon = new DBConnector(Program.DBCon.ConfigData, true);
            ProgressEventArgs eva;

            try
            { 
                StringBuilder sqlStringB = new StringBuilder();
                String timeFilter = "";
                Int32 Counter;
                Dictionary<Int32, Int32> commodityIDs = new Dictionary<Int32, Int32>();
                List<Listing> missedListings = new List<Listing>();
                Listing[] currentListing;
                Boolean currentListingDone;
                Int32 priceCountTotal = 0;
                Int32 priceCount = 0;
                Int32 SourceID;
                enDataSource initialDataSource = dataSource;
                

                if ((dataSource == enDataSource.fromRN) || (dataSource == enDataSource.fromIBE_OCR))
                    dataSource = enDataSource.fromIBE;

                if(dataSource == enDataSource.fromEDDN_T)
                    dataSource = enDataSource.fromEDDN;

                // for the prices is no transaction necessary, because we're changing
                // only a single table

                // count the prices for messages
                foreach (EDStation Station in Stations)
                    priceCountTotal += Station.Listings.Count();

                Counter = 0;
                sendProgressEvent(new ProgressEventArgs() { Info="updating prices...", AddSeparator=true });

                Boolean AddComma = false;
                int?  DemandLevel = null;
                int?  SupplyLevel = null;

                Dictionary<String, int?> Levels = new Dictionary<String, int?>();

                // gettin' some freaky performance
                lDBCon.Execute("set global innodb_flush_log_at_trx_commit=2");

                // now add the commodities and prices
                foreach (EDStation Station in Stations)
                {
                    currentListingDone = false;
                    missedListings.Clear();
                    currentListing = Station.Listings;

                    do
                    {
                        commodityIDs.Clear();
                        currentListingDone = true;

                        if ((Station.Id != 0) && (currentListing.Count() > 0))
                        {
                            sqlStringB.Clear();
                            sqlStringB.Append("insert into tbCommodityData(id, station_id, commodity_id, Sell, Buy," +
                                              "Demand, DemandLevel, Supply, SupplyLevel, Sources_id, timestamp) ");

                            foreach (Listing StationListing in currentListing)
                            {
                                // is this commodity already added in this round ? .... 
                                if (!commodityIDs.ContainsKey(StationListing.CommodityId))
                                {
                                    // ... no

                                    if (!String.IsNullOrEmpty(StationListing.DataSource))
                                        SourceID = (Int32)BaseTableNameToID("source", StationListing.DataSource);
                                    else
                                        SourceID = (Int32)dataSource;

                                    if (dataSource <= 0)
                                        throw new Exception("Illegal SourceID for import : " + SourceID);

                                    if (AddComma)
                                        sqlStringB.Append(" union all ");

                                    // cache level-ids
                                    getLevels(ref DemandLevel, ref SupplyLevel, Levels, StationListing);
                            
                                    switch (importBehaviour)
	                                {
                                        case enImportBehaviour.OnlyNewer:
                                            timeFilter = String.Format("SC1.timestamp < {0}) or (SC1.timestamp is null)", DBConnector.SQLDateTime(DateTimeOffset.FromUnixTimeSeconds(StationListing.CollectedAt).DateTime));
                                            break;

                                        case enImportBehaviour.NewerOrEqual:
                                            timeFilter = String.Format("SC1.timestamp <= {0}) or (SC1.timestamp is null)", DBConnector.SQLDateTime(DateTimeOffset.FromUnixTimeSeconds(StationListing.CollectedAt).DateTime));
                                            break;                                                          

                                        case enImportBehaviour.All:
                                            timeFilter = String.Format("SC1.timestamp = SC1.timestamp", DBConnector.SQLDateTime(DateTimeOffset.FromUnixTimeSeconds(StationListing.CollectedAt).DateTime));
                                            break;
	                                }

                                    sqlStringB.Append(String.Format("(select if(SC1.cnt = 0, 0, SC1.id),{0},{1},{2},{3},{4},{5},{6},{7},{8},{9}" +
                                                                    "         from (select ID, station_id, commodity_id, Count(*) As cnt, timestamp from tbCommodityData" +
                                                                    "              where station_id   = {0}" +
                                                                    "              and   commodity_id = {1}) SC1" +
                                                                    "  where ({10})",
                                                                    Station.Id,
                                                                    StationListing.CommodityId,
                                                                    StationListing.SellPrice,
                                                                    StationListing.BuyPrice,
                                                                    StationListing.Demand,
                                                                    DemandLevel.ToNString("null"),
                                                                    StationListing.Supply,
                                                                    SupplyLevel.ToNString("null"),
                                                                    SourceID,
                                                                    DBConnector.SQLDateTime(DateTimeOffset.FromUnixTimeSeconds(StationListing.CollectedAt).DateTime), 
                                                                    timeFilter));

                                    AddComma = true;
                                    commodityIDs.Add(StationListing.CommodityId, 0);
                                }
                                else
                                {
                                    // If we add the same commodity multiple times in one command the database will not recognize
                                    // the doubled price and add both. So we add multiple prices step by step- only the newest 
                                    // price will remain by this way.
                                    currentListingDone = false;
                                    missedListings.Add(StationListing);
                                }

                                priceCount++;
                            }

                            sqlStringB.Append(" on duplicate key update " +
                                              "  Sell        = Values(Sell)" +
                                              ", Buy         = Values(Buy)" +
                                              ", Demand      = Values(Demand)" +
                                              ", DemandLevel = Values(DemandLevel)" +
                                              ", Supply      = Values(Supply)" +
                                              ", SupplyLevel = Values(SupplyLevel)" +
                                              ", Sources_id  = Values(Sources_id)" +
                                              ", timestamp   = Values(timestamp)");

                            lDBCon.Execute(sqlStringB.ToString());
                        }

                        AddComma = false;
                        Counter++;

                        eva = new ProgressEventArgs() { Info="updating prices...", CurrentValue=priceCount, TotalValue=priceCountTotal };
                        if(sendProgressEvent(eva))
                            break;

                        currentListing = missedListings.ToArray();

                        
                    } while (!currentListingDone);

                    if(((initialDataSource == enDataSource.fromIBE) || (initialDataSource == enDataSource.fromEDDN_T)) && 
                        Program.DBCon.getIniValue<Boolean>(frmDataIO.DB_GROUPNAME, "AutoPurgeNotMoreExistingDataDays", true.ToString(), false))
                    {
                        // remove old prices if we got the data from ourself or from trusted eddn senders
                        Program.Data.DeleteNoLongerExistingMarketData(Program.DBCon.getIniValue<Int32>(frmDataIO.DB_GROUPNAME, "PurgeNotMoreExistingDataDays", "30", false), Station.Id);
                    }

                    if(eva.Cancelled)
                        break;
                }

                eva = new ProgressEventArgs() { Info="updating prices...", CurrentValue=priceCount, TotalValue=priceCountTotal, ForceRefresh=true };

                // gettin' some freaky performance
                lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");

                lDBCon.Dispose();

            }
            catch (Exception ex)
            {
                try{
                    // gettin' some freaky performance
                    lDBCon.Execute("set global innodb_flush_log_at_trx_commit=1");
                    lDBCon.Dispose();
                }catch (Exception) { }

                throw new Exception("Error while importing prices", ex);
            }
        }
 private void Extr_Extracting(object sender, ProgressEventArgs e)
 {
     InfoLabel.Content  = "Extracting patch file " + _downloadVersion + ": " + e.PercentDone + "%";
     progressBar1.Value = e.PercentDone;
 }
Beispiel #47
0
        /// <summary>
        /// Imports the prices from a list of csv-strings in EDDB format
        /// </summary>
        /// <param name="CSV_Strings">data to import</param>
        /// <param name="importBehaviour">filter, which prices to import</param>
        /// <param name="dataSource">if data has no information about the datasource, this setting will count</param>
        public void ImportPricesFromEDDBStrings(String[] CSV_Strings, enImportBehaviour importBehaviour, enDataSource dataSource, PriceImportParameters importParams)
        {
            List<EDStation> StationData;
            Boolean updateTables = false;
            ProgressEventArgs eva=new ProgressEventArgs();
            Int32 initialSize=0;

            try
            {
                StationData = fromCSV_EDDB(CSV_Strings);

                if(importParams != null)
                {
                    DataTable data = Program.Data.GetNeighbourSystems(importParams.SystemID, importParams.Radius);

                    String info = "filter data to the bubble (radius " + importParams.Radius+ " ly) : " + data.Rows.Count +" systems...";
                    eva = new ProgressEventArgs() { Info=info, NewLine=true};      

                    if(!sendProgressEvent(eva))
                    {
                       if(data.Rows.Count > 0)
                       {
                           updateTables = true;

                            initialSize = StationData.Count();

                            for (int i = StationData.Count()-1 ; i >= 0 ; i--)
                           {
                               if(data.Rows.Find(StationData[i].SystemId) == null)    
                               {
                                   // system is not in the bubble
                                   StationData.Remove(StationData[i]);
                               }
                               else
                               { 
                                      // system is in the bubble - set as visited
                                   Program.Data.checkPotentiallyNewSystemOrStation(StationData[i].SystemName, StationData[i].Name, null, true);
                               }

                               eva = new ProgressEventArgs() { Info=info, CurrentValue=initialSize-i, TotalValue=initialSize };
                               sendProgressEvent(eva);
                               if(eva.Cancelled)
                                   break;

                           }

                       }
                       else
                           StationData.Clear();
                    }

                    eva = new ProgressEventArgs() { Info=info, CurrentValue=initialSize, TotalValue=initialSize, ForceRefresh=true };
                    sendProgressEvent(eva);
                }

                if((!eva.Cancelled) && (updateTables))
                { 
                    eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", NewLine=true };
                    sendProgressEvent(eva);

                    if(!eva.Cancelled)
                    {
                        Program.Data.updateVisitedFlagsFromBase();
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=25, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                    if(!eva.Cancelled)
                    {
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.tbsystems.TableName);
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=50, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                    if(!eva.Cancelled)
                    {
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.tbstations.TableName);
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=75, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                    if(!eva.Cancelled)
                    {
                        Program.Data.PrepareBaseTables(Program.Data.BaseData.visystemsandstations.TableName);
                        eva = new ProgressEventArgs() { Info = "refreshing basetables in memory...", CurrentValue=100, TotalValue=100, ForceRefresh=true };
                        sendProgressEvent(eva);
                    }
                }

                // now import the prices
                if(!eva.Cancelled)
                { 
                   ImportPrices(StationData, importBehaviour, dataSource);
                }



            }
            catch (Exception ex)
            {
                throw new Exception("Error while importing self collected price data", ex);
            }
        }
        private void SetCurrentProgress(ProgressEventArgs args)
        {
            ProgressType type = args.Type;
            string resource = args.ResourceId;
            int total = args.MaxValue;
            double pg = args.Value;
            if (this.InvokeRequired)
            {
                Action<ProgressEventArgs> action = SetCurrentProgress;
                this.Invoke(action, new object[] { args });
            }
            else
            {
                int span = this.CurrentProgress.Maximum - this.CurrentProgress.Minimum;
                double v = (((double)pg / total) * span) + this.CurrentProgress.Minimum;
                this.CurrentProgress.Value = (int)Math.Max(Math.Min(v, this.CurrentProgress.Maximum), this.CurrentProgress.Minimum);
                OperationLabel.Text = resource;

                int largePg = (int)Array.IndexOf(BUILD_STAGES, type);
                if (largePg >= 0)
                {
                    this.TotalProgress.Maximum = 100;
                    this.TotalProgress.Minimum = 0;

                    double tick = 100 / BUILD_STAGES.Length;
                    double lv = (tick * largePg) + (tick * (pg / total));

                    this.TotalProgress.Value = (int)Math.Max(Math.Min((int)lv, this.TotalProgress.Maximum), this.TotalProgress.Minimum);
                }

                switch (type)
                {
                    case ProgressType.Uploading:
                        {
                            HideTotal();
                            if (Math.Abs(pg - total) < double.Epsilon)
                            {
                                OperationLabel.Text = Strings.ProgressWaitingForServer;
                                CurrentProgress.Style = ProgressBarStyle.Marquee;
                            }
                            else
                            {
                                OperationLabel.Text = string.Format(Strings.ProgressUploading, ((double)pg / 1024), ((double)total / 1024));
                                this.Refresh();
                            }
                        }
                        break;
                    case ProgressType.ListingFiles:
                        {
                            HideTotal();
                            OperationLabel.Text = Strings.ProgressReadingPackage;
                            CurrentProgress.Style = ProgressBarStyle.Marquee;
                        }
                        break;
                    case ProgressType.Compressing:
                        {
                            OperationLabel.Text = Strings.ProgressCompressing;
                        }
                        break;
                    case ProgressType.MovingResources:
                        {
                            OperationLabel.Text = Strings.ProgressUpdatingReferences;
                        }
                        break;
                    case ProgressType.PreparingFolder:
                        {
                            OperationLabel.Text = resource;
                        }
                        break;
                    case ProgressType.SetResource:
                        {
                            CurrentProgress.Style = ProgressBarStyle.Continuous;
                            CurrentProgress.Maximum = 100;
                            CurrentProgress.Value = Convert.ToInt32(Math.Min(100.0, pg));
                            OperationLabel.Text = string.Format(Strings.ProgressSetResource, resource, pg);
                        }
                        break;
                    case ProgressType.SetResourceData:
                        {
                            CurrentProgress.Style = ProgressBarStyle.Continuous;
                            CurrentProgress.Maximum = 100;
                            CurrentProgress.Value = Convert.ToInt32(Math.Min(100.0, pg));
                            OperationLabel.Text = string.Format(Strings.ProgressSetResourceData, resource, pg);
                        }
                        break;
                }
            }
        }
Beispiel #49
0
        /// <summary>
        /// creates a list of "EDStations" with price listings from csv-array in EDDB format
        /// </summary>
        /// <param name="CSV_Strings">String to be converted</param>
        /// <param name="foundSystems"></param>
        /// <param name="csvRowList">for optional processing outside: a list of the data converted to CsvRow-objects</param>
        /// <returns></returns>
        public List<EDStation> fromCSV_EDDB(String[] CSV_Strings)
        {
            List<EDStation> foundValues                     = new List<EDStation>();
            Dictionary<Int32, Int32> foundIndex             = new Dictionary<Int32, Int32>();
            Dictionary<String, Int32> foundSystemIndex      = new Dictionary<String, Int32>();
            Int32 LastID                                    = 0;
            EDSystem LastSystem                             = null;
            Int32 currentID                                 = 0;
            EDStation currentStation                        = null;
            Int32 Index                                     = 0;
            Dictionary<String, Int32> commodityIDCache      = new Dictionary<string,Int32>();            // quick cache for finding commodity names
            Int32 currentItem                               = 0;
            ProgressEventArgs eva;

            try
            {
                eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0), NewLine= true};
                sendProgressEvent(eva);

                foreach (String CSV_String in CSV_Strings)
	            {

                    if(!String.IsNullOrEmpty(CSV_String.Trim()))
                    {
		                Listing currentRow           = new Listing(CSV_String);

                        currentID = currentRow.StationId;

                        if(LastID != currentID)
                        {
                            if(currentStation != null)
                                currentStation.ListingExtendMode = false;

                            if(foundIndex.TryGetValue(currentID, out Index))
                                currentStation = foundValues[Index];
                            else
                            {
                                currentStation  = new EDStation(currentRow);

                                foundValues.Add(currentStation);
                                foundIndex.Add(currentID, foundValues.Count-1);
                            }
                            LastID = currentRow.StationId;

                            currentStation.ListingExtendMode = true;

                        }

                        currentStation.addListing(currentRow);
                    }
                
                    eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0)};
                    sendProgressEvent(eva);

                    if(eva.Cancelled)
                        break;

                    currentItem++;
	            }

                if(currentStation != null)
                    currentStation.ListingExtendMode = false;

                eva = new ProgressEventArgs() { Info="converting data...", CurrentValue=currentItem, TotalValue=CSV_Strings.GetUpperBound(0), ForceRefresh=true};
                sendProgressEvent(eva);

                return foundValues;

            }
            catch (Exception ex)
            {
                throw new Exception("Error while getting station values from CSV-String", ex);
            }
        }
Beispiel #50
0
 void dataFilter_CurrentLineChanged(object sender, ProgressEventArgs e)
 {
     ucProgress.SetCount(e);
 }
 private void OnProgressAvailable(object sender, ProgressEventArgs e)
 {
     ProgressAvailable(this, e);
 }
Beispiel #52
0
 private void Extractor_Extracting(object sender, ProgressEventArgs e)
 {
     ItemMessage = "Extracting Archive..." + e.PercentDone + "%";
     StepItemProgress();
 }
Beispiel #53
0
 protected void OnProgress(object sender, ProgressEventArgs args)
 {
     if (Progress != null)
     {
         Progress(sender, args);
     }
 }
 private void OnProgressAvailable(object sender, ProgressEventArgs e)
 {
     WriteProgress(ProgressActivityIds.DownloadPackageId, e.Operation, e.PercentComplete);
 }
 private void ProgressChange(object sender, ProgressEventArgs e)
 {
     Assert.AreEqual(actual, e.CurrentRecord);
     actual += actualAdd;
 }
Beispiel #56
0
 public void dataService_ProgressAvailable(object sender, ProgressEventArgs e)
 {
     App.ProgressHandler.Progress(null, e.PercentComplete, "Downloading");
 }
Beispiel #57
0
 private void OnProgressAvailable(object sender, ProgressEventArgs e)
 {
     _progressWindowOpener.ShowProgress(e.Operation, e.PercentComplete);
 }
Beispiel #58
0
 void OnProcess(object sender, ProgressEventArgs e)
 {
     mCurFileProcessByteCount = e.Processed;
     mCurFileTotalByteCount   = e.Target > 0 ? e.Target : e.Processed;
 }
 private void OnCompressing(ProgressEventArgs e)
 {
     if (Compressing != null)
     {
         Compressing(this, e);
     }
 }
Beispiel #60
0
 static void downloader_ProgressDownload(object sender, ProgressEventArgs e)
 {
     Console.WriteLine("[progress {0}]", e.Percentage);
 }