Beispiel #1
0
 protected void OnBeginEventOccurs(string tag)
 {
     if (EventOccurs != null)
     {
         EventOccurs.BeginInvoke(this, EventArg.New(tag), null, null);
     }
 }
Beispiel #2
0
 public event EventHandler EventName; //define the event if no custom data
 public void Raiser(EventArg e)
 {
     if (EventHandler != null)
     {
         EventHandler(this, e); //raise the event
     }
 }
        protected override void OnInnerProcessorCompleted(EventArg<System.Data.DataTable> e)
        {
            try
            {
                querySetCount = 0;

                RaiseProcessingUpdate(new EventArg<string>("Getting Yahoo Finance data..."));
                var col = e.Data.Columns.Add(FieldConstant.ExDividendDate, typeof(string));
                col = e.Data.Columns.Add(FieldConstant.DividendPayDate, typeof(string));
                col = e.Data.Columns.Add(FieldConstant.DividendYield, typeof(string));
                col = e.Data.Columns.Add(FieldConstant.TargetPrice1y, typeof(float));

                //get the filtered data
                //contruct the data
                //get back the table

                var result = ConstructURL(e.Data);

                foreach (string url in result)
                {
                    CsvDataAdapter adapter = new CsvDataAdapter(false);
                    adapter.DataRetrieveCompleted += adapter_DataRetrieveCompleted;
                    adapter.DataRetrieveError += adapter_DataRetrieveError;
                    adapter.CurrentURL = url;
                    adapter.RetrieveData();
                    Interlocked.Increment(ref querySetCount);
                }
            }
            catch (Exception err)
            {

                RaiseProcessingError(new EventArg<Exception>(err));
            }
        }
 public void BeforeLeavingContact(object sender, EventArg<vCard> e)
 {
     if (_view.SelectedContactIndex > -1)
     {
         if (_repository.dirty)
             _repository.SaveDirtyVCard(_view.SelectedContactIndex, e.Data);
     }
 }
		private void OnToggleChanged (object sender, EventArg<bool> args)
		{
			//Debug.Log ("OnToggleChanged");
			if (args.CurrentValue == true) {
				iconImage.texture = OnTexture;
			} else {
				iconImage.texture = OffTexture;
			}
		}
        protected override void OnInnerProcessorCompleted(EventArg<System.Data.DataTable> e)
        {
            RaiseProcessingUpdate(new EventArg<string>("Begin valuation calculation..."));

                //construct more PE derived columns
                var col = e.Data.Columns.Add(HistoricalDataAdapter.Low5Year_PE, typeof(float));
                col = e.Data.Columns.Add(HistoricalDataAdapter.High5Year_PE, typeof(float));
                col = e.Data.Columns.Add(HistoricalDataAdapter.Low10Year_PE, typeof(float));
                col = e.Data.Columns.Add(HistoricalDataAdapter.High10Year_PE, typeof(float));

                List<string> columnLabels = new List<string>();
                columnLabels.Add(HistoricalDataAdapter.CurrentPE + "_{0}");
                columnLabels.Add(HistoricalDataAdapter.Low5Year_PE + "_{0}");
                columnLabels.Add(HistoricalDataAdapter.High5Year_PE + "_{0}");
                columnLabels.Add(HistoricalDataAdapter.Low10Year_PE + "_{0}");
                columnLabels.Add(HistoricalDataAdapter.High10Year_PE + "_{0}");

                //construct 5 years growth potential columns

                foreach (string label in columnLabels)
                {
                    int year = DateTime.Now.Year-1;
                    for (int i = 0; i < YearCount; i++)
                    {
                        e.Data.Columns.Add(string.Format(label, year), typeof(float));
                        year = year+1;
                    }
                }

                foreach (DataRow row in e.Data.Rows)
                {
                    //get the ticker name
                    var value = (string)row[FieldConstant.Ticker];

                    //get the exchange
                    var exchange = (string)row[FieldConstant.Exchange];

                    HistoricalDataAdapter adapter = new HistoricalDataAdapter();
                    adapter.DataRetrieveCompleted += adapter_DataRetrieveCompleted;
                    adapter.DataRetrieveError += adapter_DataRetrieveError;
                    adapters.TryAdd(value, adapter);
                    string[] values = exchange.Split('=');
                    if (values.Length == 2)
                    {
                        Exchange ex = Exchange.NYSE;

                        Enum.TryParse(values[0], true, out ex);
                        RaiseProcessingUpdate(new EventArg<string>("Retrieving PE for ..." + value));
                        adapter.RetrieveData(value, ex);
                    }

                }
        }
Beispiel #7
0
        static void valuationProcessor_DataProcessingCompleted(object sender, EventArg<DataTable> e)
        {
            Console.WriteLine("Success\n\r" + e.Data);

            string fileName = "result_" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".csv";
            string folder = Path.Combine(System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "BeyondInsights");

            if (!Directory.Exists(folder))
                Directory .CreateDirectory(folder);

            string path = Path.Combine(folder,fileName);

            PutDataTableToCsv(path, e.Data, true);
            exitFlag.Set();
        }
        public void NewFileOpened(object sender, EventArg<string> e)
        {
            string path = e.Data;
            if (!string.IsNullOrEmpty(path))
            {
                FixedList MRUList = ConfigRepository.Instance.Paths;

                if (!MRUList.Contains(path))
                {
                    MRUList.Enqueue(path);
                    // ConfigRepository.Instance.Paths.Clear();
                    _view.UpdateMRUMenu(MRUList);
                }

                _repository.LoadContacts(path);
                _view.DisplayContacts(_repository.Contacts);
            }
        }
    private void handleButtonPressed(object sender,   EventArg<bool> arg)
    {
        int buttonId = (sender as VideoToggleDataBinder).gameObject.GetInstanceID();
        string movieName = m_buttonsToMovieNames[buttonId];
        // If we've recieved a button turning off.
        if ( arg.CurrentValue == false ) {
          pauseCurrentMovie();
          return;
        }

        clearOtherButtons(buttonId);

        if ( m_currentMovieName == null ) { // If we don't have a current video
          loadAndPlayMovie(movieName);
        }
        else if (movieName == m_currentMovieName) { // If we have the same video
          playCurrentMovie();
        }
        else if (movieName != m_currentMovieName) { // If we have two different videos
          dumpCurrentMovie();
          loadAndPlayMovie(movieName);
        }
    }
 protected override void OnInnerProcessorError(EventArg<Exception> e)
 {
 }
        void adapter_DataRetrieveCompleted(object sender, EventArg<DataTable> e)
        {
            RaiseProcessingUpdate(new EventArg<string>("Retrieving FinViz data...done"));

            lock (lockObj)
            {
                //combine data together based on exchanges
                CsvDataAdapter adapter = sender as CsvDataAdapter;

                if (adapter == null)
                {
                    return;
                }

                string selectedExchange = string.Empty;
                foreach (var s in exhcanges)
                {
                    string[] values = s.Split('=');
                    if (adapter.CurrentURL.Contains(values[1]))
                    {
                        selectedExchange = s;
                        break;
                    }
                }

                e.Data.Columns.Add(FieldConstant.Exchange , typeof(string));

                foreach (DataRow r in e.Data.Rows)
                {
                    r[FieldConstant.Exchange] = selectedExchange;
                }

                this.result.Merge(e.Data, true, MissingSchemaAction.Add);

                DataColumn col = this.result.Columns[FieldConstant.Ticker];

                if (col != null)
                {
                    this.result.PrimaryKey = new DataColumn[]{col};
                }
                exhcanges.Remove(selectedExchange);

                if (exhcanges.Count == 0)
                    RaiseProcessingCompleted(new EventArg<DataTable>(this.result));
            }
        }
Beispiel #12
0
 private void MainOnProgress(object sender, EventArg<ProgressData> e)
 {
     SetProgress(e.Data);
 }
 protected override void OnInnerProcessorCompleted(EventArg<DataTable> e)
 {
 }
Beispiel #14
0
 private void MainOnDebug(object sender, EventArg<string> e)
 {
     try {
         _dbg.AddDebug(e.Data);
     }
     catch(Exception) {
     }
 }
Beispiel #15
0
 private void MainOnError(object sender, EventArg<string> e)
 {
     if(e.Data == null)
         return;
     SetText(e.Data);
 }
        protected override void OnInnerProcessorCompleted(EventArg<System.Data.DataTable> e)
        {
            RaiseProcessingUpdate(new EventArg<string>("Begin summary valuation..."));

            DataColumn currentTTMPE = null;
            List<DataColumn> columns = new List<DataColumn>();
            foreach(DataColumn col in e.Data.Columns)
            {
                int year = DateTime.Now.Year-1;
                if (col.ColumnName.Contains(HistoricalDataAdapter.CurrentPE))
                {
                    columns.Add(col);
                    if (col.ColumnName.Equals(string.Format(HistoricalDataAdapter.CurrentPE + "_{0}",DateTime.Now.Year)))
                    {
                        currentTTMPE = col;
                    }
                }
            }
            foreach (DataRow row in e.Data.Rows)
            {
                float ratio = (float)row[currentTTMPE];

                if (ratio > 1)
                {
                    //get ticker

                    string ticker = (string)row[FieldConstant.Ticker];

                    string company = (string)row[FieldConstant.Company];

                    string industry = (string)row[FieldConstant.Industry];

                    float price = float.Parse(row[FieldConstant.Price].ToString());

                    float peg = float.Parse(row[FieldConstant.PEG].ToString());

                    string roa = (string)row[FieldConstant.ROA];
                    string roe = (string)row[FieldConstant.ROE];
                    string instOWn = (string)row[FieldConstant.InstOwn];

                    string insiderTran = (String)row[FieldConstant.InsiderTran];

                    string earningDate = (string)row[FieldConstant.EarningDates];
                    string analystRec = (string)row[FieldConstant.AnalystRecom];
                    string _20Day = (string)row[FieldConstant._20Day];
                    string _50Day = (string)row[FieldConstant._50Day];
                    string _200Day = (string)row[FieldConstant._200Day];

                    _20Day = _20Day.TrimEnd('%');
                    _50Day = _50Day.TrimEnd('%');
                    _200Day = _200Day.TrimEnd('%');

                    string dividendPayDate = (string)row[FieldConstant.DividendPayDate];
                    string exDividendDate = (string)row[FieldConstant.ExDividendDate];
                    string exDividendYield = (string)row[FieldConstant.DividendYield];
                    float targetPrice = (float)row[FieldConstant.TargetPrice1y];

                    float targetPriceGap = targetPrice - price;

                    var newRow = table.Rows.Add();
                    newRow[FieldConstant.Ticker] = ticker;
                    newRow[FieldConstant.Industry] = industry;
                    newRow[FieldConstant.Company] = company;
                    newRow[FieldConstant.Price] = price;
                    newRow[FieldConstant.PEG] = peg;
                    newRow[FieldConstant.InsiderTran] = insiderTran;
                    newRow[FieldConstant.InstOwn] = instOWn;
                    newRow[FieldConstant.EarningDates] = earningDate;
                    newRow[FieldConstant._20Day] = float.Parse(_20Day);
                    newRow[FieldConstant._50Day] = float.Parse(_50Day);
                    newRow[FieldConstant._200Day] = float.Parse(_200Day);
                    newRow[FieldConstant.AnalystRecom] = analystRec;
                    newRow[FieldConstant.ROA] = roa;
                    newRow[FieldConstant.ROE] = roe;
                    newRow[HistoricalDataAdapter.CurrentPE] = ratio;
                    newRow[FieldConstant.DividendPayDate] = dividendPayDate;
                    newRow[FieldConstant.ExDividendDate] = exDividendDate;
                    newRow[FieldConstant.DividendYield] = exDividendYield;
                    newRow[FieldConstant.TargetPrice1y] = targetPrice;
                    newRow[FieldConstant.CurrentTargetPriceDiff] = targetPriceGap;
                    newRow[FieldConstant.StockChartUrl] = string.Format(charturlBase, ticker);
                }

            }
            RaiseProcessingUpdate(new EventArg<string>("Summary valuation...done"));
            this.RaiseProcessingCompleted(new EventArg<DataTable>(table));
        }
 protected void RaiseProcessingError(EventArg<Exception> e)
 {
     if (DataRetrieveError != null)
         DataRetrieveError(this, e);
 }
 void _DataStream_DataReceived(object sender, EventArg<Reading> e)
 {
     Log.Add(e.Data);
 }
 protected override void OnInnerProcessorError(EventArg<Exception> e)
 {
     throw new NotImplementedException();
 }
 private void innerProcessor_DataRetrieveError(object sender, EventArg<Exception> e)
 {
     OnInnerProcessorError(e);
 }
 private void innerProcessor_DataProcessingCompleted(object sender, EventArg<System.Data.DataTable> e)
 {
     OnInnerProcessorCompleted(e);
 }
 protected void RaiseProcessingUpdate(EventArg<string> e)
 {
     if (UpdateStatus != null)
         UpdateStatus(this, e);
 }
 void adapter_DataRetrieveError(object sender, EventArg<Exception> e)
 {
     RaiseProcessingError(e);
 }
 protected abstract void OnInnerProcessorError(EventArg<Exception> e);
 protected override void OnInnerProcessorError(EventArg<Exception> e)
 {
     RaiseProcessingError(e);
 }
 protected void RaiseProcessingCompleted(EventArg<System.Data.DataTable> e)
 {
     if (DataProcessingCompleted != null)
         DataProcessingCompleted(this, e);
 }
 void innerProcessor_UpdateStatus(object sender, EventArg<string> e)
 {
     RaiseProcessingUpdate(e);
 }
 protected override void OnInnerProcessorCompleted(EventArg<System.Data.DataTable> e)
 {
     RaiseProcessingCompleted(e);
 }
 protected override void OnInnerProcessorCompleted(EventArg<System.Data.DataTable> e)
 {
     throw new NotImplementedException();
 }
 void dataStream_DataReceived(object sender, EventArg<int> e)
 {
     _DataReceivedValue = e.Data;
 }
		void HandleRedrawNeeded(object sender, EventArg<VisualElement> e)
		{
			foreach (string propertyName in _batchedProperties)
				HandlePropertyChanged(this, new PropertyChangedEventArgs(propertyName));
			_batchedProperties.Clear();

			if (_layoutNeeded)
				MaybeRequestLayout();
			_layoutNeeded = false;
		}
 void dataStream_ErrorOccurred(object sender, EventArg<Exception> e)
 {
     _ExceptionReceived = e.Data;
 }