public static void MakeSureInit() { if (null == AlphaFactory.Get()) { AlphaFactory.Init(new OmegaFactory()); } }
void RunShear() { BackgroundWorker worker = new BackgroundWorker(); try { worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { MessageBox.Show("Done with Alpha"); }; worker.DoWork += delegate(object s, DoWorkEventArgs args) { try { IsProcessing = true; int upperCompidx = ColumnCollection.UpperWSComp(DataSetStartDate); int lowerCompidx = ColumnCollection.LowerWSComp(DataSetStartDate); ISessionColumn upperws = ColumnCollection[upperCompidx]; ISessionColumn lowerws = ColumnCollection[lowerCompidx]; AxisFactory factory = new AxisFactory(); IAxis Yaxis = factory.CreateAxis(AxisType.Hour); Yaxis.SessionColIndex = ColumnCollection.DateIndex; IAxis Xaxis = factory.CreateAxis(AxisType.Month); Xaxis.SessionColIndex = ColumnCollection.DateIndex; AlphaFactory afactory = new AlphaFactory(); ColumnCollection.AlphaCollection.Add(afactory.CreateAlpha(DownloadedData [0], upperws, lowerws, Xaxis, Yaxis)); ColumnCollection.AlphaCollection.ToList().ForEach(c => c.CalculateAlpha()); ObservableCollection <ShearGridViewModel> thisShearCollection = new ObservableCollection <ShearGridViewModel>(); foreach (Alpha a in ColumnCollection.AlphaCollection) { int i = 1; thisShearCollection.Add(new ShearGridViewModel(a, Xaxis.AxisType + " by " + Yaxis.AxisType)); i++; } //add sheargridviewmodels to allsheargridviewmodel ShearGridCollection = new AllShearViewModel(thisShearCollection); IsProcessing = false; } finally { IsProcessing = false; } }; worker.RunWorkerAsync(); } catch (Exception e) { throw; } }
public override void PerformFetch(UIApplication application, Action <UIBackgroundFetchResult> completionHandler) { OmegaFactory.MakeSureInit(); AlphaFactory.MakeSureDomain().BackgroundUpdateLastPublicActivityAsync().ContinueWith ( t => completionHandler(UIBackgroundFetchResult.NoData) // UIBackgroundFetchResult.NewData を返すと呼ばれなくなるフシがあるので必ず UIBackgroundFetchResult.NoData // を返しておくようにしてみる。 ); }
public AlphaApp MakeSureApp() { if (null == App) { global::Xamarin.Forms.Forms.Init(); ImageCircleRenderer.Init(); OmegaFactory.MakeSureInit(); App = AlphaFactory.MakeSureApp(); } return(App); }
public AlphaApp MakeSureApp() { if (null == App) { global::Xamarin.Forms.Forms.Init(); global::OxyPlot.Xamarin.Forms.Platform.iOS.PlotViewRenderer.Init(); ImageCircleRenderer.Init(); OmegaFactory.MakeSureInit(); App = AlphaFactory.MakeSureApp(); } return(App); }
public void Run(IBackgroundTaskInstance taskInstance) { var Deferral = taskInstance.GetDeferral(); OmegaFactory.MakeSureInit(); AlphaFactory.MakeSureDomain() .BackgroundUpdateLastPublicActivityAsync() .ContinueWith ( t => { Deferral.Complete(); } ); }
void UpdateLastPublicActivity(Intent intent) { OmegaFactory.MakeSureInit(); var Domain = AlphaFactory.MakeSureDomain() as OmegaDomain; try { Domain.ThreadContext.Value = this; Domain.BackgroundUpdateLastPublicActivityAsync().Wait(); } finally { Domain.ThreadContext.Value = null; } }
public void UpdateLastPublicActivity(Context context, Intent intent) { OmegaFactory.MakeSureInit(); var Domain = AlphaFactory.MakeSureDomain() as OmegaDomain; try { Domain.ThreadContext.Value = context; Domain.AutoUpdateLastPublicActivityAsync().Wait(); } finally { Domain.ThreadContext.Value = null; } }
void RunShear() { BackgroundWorker worker = new BackgroundWorker(); try { worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { }; worker.DoWork += delegate(object s, DoWorkEventArgs args) { try { IsProcessing = true; int upperCompidx = ColumnCollection.UpperWSComp(DataSetStartDate); int lowerCompidx = ColumnCollection.LowerWSComp(DataSetStartDate); ISessionColumn upperws = ColumnCollection[upperCompidx]; ISessionColumn lowerws = ColumnCollection[lowerCompidx]; IAxis Xaxis = GetAxis(_xShearAxis, _xBinWidth); IAxis Yaxis = GetAxis(_yShearAxis, _yBinWidth); AlphaFactory afactory = new AlphaFactory(); Alpha alpha = (Alpha)afactory.CreateAlpha(DownloadedData[0], _alphaFilter, upperws, lowerws, Xaxis, Yaxis); alpha.AlphaUpdated += new Alpha.AlphaUpdatedEventHandler(UpdatedAlphaCollection); alpha.SourceDataSet = this.DisplayName; ColumnCollection.AlphaCollection.Add(alpha); alpha.CalculateAlpha(); string xBin = string.Empty; string yBin = string.Empty; if (Xaxis.AxisType == AxisType.WD) { var wdaxis = (WindDirectionAxis)Xaxis; xBin = " " + wdaxis.BinWidth.ToString() + " deg"; } if (Xaxis.AxisType == AxisType.WS) { var wsaxis = (WindSpeedAxis)Xaxis; xBin = " " + wsaxis.BinWidth.ToString() + " m/s"; } if (Yaxis.AxisType == AxisType.WD) { var wdaxis = (WindDirectionAxis)Yaxis; yBin = " " + wdaxis.BinWidth.ToString() + " deg"; } if (Yaxis.AxisType == AxisType.WS) { var wsaxis = (WindSpeedAxis)Yaxis; yBin = " " + wsaxis.BinWidth.ToString() + " m/s"; } AllShearViewModel asvm = new AllShearViewModel(); string filter; if (_alphaFilter == AlphaFilterMethod.Coincident) { filter = "CDNT"; } else { filter = "NCDNT"; } string gridname = alpha.SourceDataSet + "_" + filter + "_" + Xaxis.AxisType + xBin + " by " + Yaxis.AxisType + yBin; ShearGridViewModel sgvm = new ShearGridViewModel(alpha, gridname); if (ShearGridCollection == null) { ShearGridCollection = new AllShearViewModel(); } if (ShearGridCollection.ShearCollection.Count == 0) { asvm.ShearCollection.Add(sgvm); } UpdatedAlphaCollection(alpha); alpha.AlphaUpdated -= UpdatedAlphaCollection; this.Dispatcher.Invoke(DispatcherPriority.Render, new Action ( delegate() { if (ShearGridCollection.ShearCollection.Count == 0) { ShearGridCollection = asvm; } else { ShearGridCollection.ShearCollection.Add(sgvm); } })); //add sheargridviewmodels to allsheargridviewmodel IsProcessing = false; } catch (ApplicationException e) { MessageBox.Show(e.Message); } finally { IsProcessing = false; } }; worker.RunWorkerAsync(); } catch (Exception e) { throw; } }
void OutPutSummary() { BackgroundWorker worker = new BackgroundWorker(); string filename = string.Empty; SaveFileDialog sf = new SaveFileDialog(); sf.Title = "save data"; sf.Filter = "Excel|*.xlsx"; sf.DefaultExt = ".xlsx"; sf.FileName = "Unified" + "_StnSummary_" + DateTime.Now.ToShortDateString().Replace(@"/", ""); DialogResult result = sf.ShowDialog(); if (result == DialogResult.Cancel) { return; } if (sf.FileName != "") { filename = sf.FileName; } else { return; } worker.RunWorkerCompleted += delegate(object sender, RunWorkerCompletedEventArgs e) { SummaryIsProcessing = false; }; worker.DoWork += delegate(object s, DoWorkEventArgs args) { XbyYShearStationSummary summary = null; try { SummaryIsProcessing = true; //create the DataTable if (_unifiedData != null) { _unifiedData.Clear(); } BuildDataTable(); //create column collection ColumnCollection = new SessionColumnCollection(_unifiedData); //add column def and add configs ISessionColumn hubws = ColumnCollection[HubHeight.ToString() + "m"]; hubws.ColumnType = SessionColumnType.WSAvgShear; hubws.IsCalculated = true; hubws.IsComposite = true; SensorConfig config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate, Height = HubHeight }; hubws.Configs.Add(config); ISessionColumn upperws = ColumnCollection[UpperHeight.ToString().Replace(".", "_") + "m"]; upperws.ColumnType = SessionColumnType.WSAvg; upperws.IsComposite = true; config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate, Height = UpperHeight }; upperws.Configs.Add(config); ISessionColumn lowerws = ColumnCollection[LowerHeight.ToString().Replace(".", "_") + "m"]; lowerws.ColumnType = SessionColumnType.WSAvg; lowerws.IsComposite = true; config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate, Height = LowerHeight }; lowerws.Configs.Add(config); ISessionColumn wd = ColumnCollection["WD"]; wd.ColumnType = SessionColumnType.WDAvg; wd.IsComposite = true; config = new SensorConfig() { StartDate = _startDate, EndDate = _endDate }; wd.Configs.Add(config); //get axis selections from UI IAxis Xaxis = GetAxis(_xShearAxis, _xBinWidth); IAxis Yaxis = GetAxis(_yShearAxis, _yBinWidth); //calculate alpha AlphaFactory afactory = new AlphaFactory(); Alpha alpha = (Alpha)afactory.CreateAlpha(_unifiedData, AlphaFilterMethod.Coincident, upperws, lowerws, Xaxis, Yaxis); alpha.SourceDataSet = this.DisplayName; alpha.CalculateAlpha(); string xBin = string.Empty; string yBin = string.Empty; if (Xaxis.AxisType == AxisType.WD) { var wdaxis = (WindDirectionAxis)Xaxis; xBin = " " + wdaxis.BinWidth.ToString() + " deg"; } if (Xaxis.AxisType == AxisType.WS) { var wsaxis = (WindSpeedAxis)Xaxis; xBin = " " + wsaxis.BinWidth.ToString() + " m/s"; } if (Yaxis.AxisType == AxisType.WD) { var wdaxis = (WindDirectionAxis)Yaxis; yBin = " " + wdaxis.BinWidth.ToString() + " deg"; } if (Yaxis.AxisType == AxisType.WS) { var wsaxis = (WindSpeedAxis)Yaxis; yBin = " " + wsaxis.BinWidth.ToString() + " m/s"; } //Set up column metadata for the summary run summary = new XbyYShearStationSummary(ColumnCollection, _unifiedData.AsDataView(), 30, 10, 2, alpha); summary.CreateReport(filename); SummaryIsProcessing = false; } catch (ApplicationException e) { MessageBox.Show("Error calculating station summary: " + e.Message + " " + e.Source); StreamWriter fs = new StreamWriter(Path.GetDirectoryName(filename) + @"\LOG_" + Path.GetFileNameWithoutExtension(filename) + ".txt", false); summary.log.ForEach(c => fs.WriteLine(c)); fs.Close(); } finally { SummaryIsProcessing = false; } }; worker.RunWorkerAsync(); }