Пример #1
0
        public void QueryTyped_WithAnonymousParamsAndOutParam_Executes()
        {
            using (var c = _dataAndSchema.GetConnection())
            {
                c.Open();

                var w = new SqlMapperWrapper(c);

                IParametersFactory fact = new ParametersFactory();

                var args = fact.CreateInstance(new { Val = _dataAndSchema.Value.ToString() });
                args.Add("@affected", null, DbType.Int32, ParameterDirection.InputOutput);

                var result = w.Query <EntityBar>(
                    SqlDataAndSchema.SprocNameDapperSingleInSingleOutParam,
                    args,
                    commandType: CommandType.StoredProcedure).ToList();

                var outparam = args.Get <int>("@affected");

                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count() == 1);
                Assert.IsTrue(outparam == 1);
            }
        }
Пример #2
0
 static XpandSystemModule()
 {
     ParametersFactory.RegisterParameter(new MonthAgoParameter());
     if (!InterfaceBuilder.RuntimeMode)
     {
         new XpandXpoTypeInfoSource((TypesInfo)XafTypesInfo.Instance).AssignAsPersistentEntityStore();
     }
 }
Пример #3
0
        protected override void OnLoggedOn(LogonEventArgs args)
        {
            base.OnLoggedOn(args);
            ObjectSpace objectSpace          = this.CreateObjectSpace();
            CurrentCompanyOidParameter param = new CurrentCompanyOidParameter();

            param.CurrentCompanyOid = (objectSpace.FindObject <Company>(CriteriaOperator.Parse("Employees[Oid = ?]", SecuritySystem.CurrentUserId))).Oid;
            ParametersFactory.RegisterParameter(param);
        }
Пример #4
0
        public void Setup()
        {
            ParametersForTesting = ParametersFactory.CreateParametersForTesting();

            PriceServerFactoryMockSetup();
            var priceServerFactoryMock = PriceServerFactoryMock.Object;

            Calculator = new Calculator(priceServerFactoryMock);
        }
Пример #5
0
        object GetObjectKey(ViewShortcut shortcut, Type type, IObjectSpace objectSpace)
        {
            var objectKey = GetObjectKey(objectSpace, type, shortcut);

            if (objectKey != null)
            {
                return(objectKey);
            }
            return(shortcut.ObjectKey.StartsWith("@")
                            ? ParametersFactory.CreateParameter(shortcut.ObjectKey.Substring(1)).CurrentValue
                            : CriteriaWrapper.ParseCriteriaWithReadOnlyParameters(shortcut.ObjectKey, type));
        }
Пример #6
0
        /// <summary>
        /// Initializes the <see cref="XafDeltaModule"/> class.
        /// </summary>
        static XafDeltaModule()
        {
            // register read only parameters
            ParametersFactory.RegisterParameter(new CurrentNodeIdParameter());
            ParametersFactory.RegisterParameter(new ApplicationNameParameter());
            ParametersFactory.RegisterParameter(new SnapshotNodeIdParameter());
            ParametersFactory.RegisterParameter(new SnapshotNodeParameter());

            CurrentNodeIdOperator.Register();
            ApplicationNameOperator.Register();
            SnapshotNodeIdOperator.Register();
            SnapshotNodeOperator.Register();
        }
Пример #7
0
        public static double RMSE(ParameterTimeSeries forecast, ParameterTimeSeries real)
        {
            EvaluateCorrectness(forecast, real, 1);

            string type              = forecast.Type;
            int    length            = Math.Min(forecast.Length, real.Length);
            double sumOfSquareErrors = 0;

            for (var i = 0; i < length; i++)
            {
                sumOfSquareErrors += Math.Pow((double)(ParametersFactory.GetValueDistance(type, real.Values[i], forecast.Values[i])), 2);
            }

            double result = Math.Sqrt(sumOfSquareErrors / length);

            return(result);
        }
Пример #8
0
        public static double MAE(ParameterTimeSeries a, ParameterTimeSeries b)
        {
            EvaluateCorrectness(a, b, 1);

            string type        = a.Type;
            int    length      = Math.Min(a.Length, b.Length);
            int    sumOfErrors = 0;

            for (var i = 0; i < length; i++)
            {
                sumOfErrors += ParametersFactory.GetValueDistance(type, a.Values[i], b.Values[i]);
            }

            double result = (double)sumOfErrors / length;

            return(result);
        }
Пример #9
0
        public static double MASE(ParameterTimeSeries forecast, ParameterTimeSeries real)
        {
            EvaluateCorrectness(forecast, real, 2);

            string type   = forecast.Type;
            int    length = Math.Min(forecast.Length, real.Length);

            int sumOfNaiveErrors = 0;
            int sumOfErrors      = ParametersFactory.GetValueDistance(type, real.Values[0], forecast.Values[0]);

            for (var i = 1; i < length; i++)
            {
                sumOfErrors      += ParametersFactory.GetValueDistance(type, real.Values[i], forecast.Values[i]);
                sumOfNaiveErrors += ParametersFactory.GetValueDistance(type, real.Values[i], real.Values[i - 1]);
            }

            double result = (double)sumOfErrors * (length - 1) / (length * sumOfNaiveErrors);

            return(result);
        }
Пример #10
0
        private void SetUpPlot(string valType)
        {
            PlotModel = new OxyPlot.PlotModel
            {
                Title                   = ParametersFactory.GetName(valType),
                TitlePadding            = 0,
                Padding                 = new OxyThickness(1, 10, 1, 0),
                PlotAreaBorderThickness = 1,
                PlotAreaBorderColor     = OxyColor.FromAColor(64, OxyColors.Black),
                LegendOrientation       = LegendOrientation.Vertical,
                LegendBackground        = OxyColor.FromAColor(128, OxyColors.White),
                LegendItemSpacing       = 0,
                LegendColumnSpacing     = 0,
                LegendPlacement         = LegendPlacement.Outside,
            };

            var valueAxis = new LinearAxis(AxisPosition.Left)
            {
                AbsoluteMaximum    = ParametersFactory.GetMaxValue(valType),
                AbsoluteMinimum    = ParametersFactory.GetMinValue(valType),
                MinimumPadding     = 0.05,
                MaximumPadding     = 0.05,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot,
                Title = ParametersFactory.GetName(valType),
            };

            string unit = ParametersFactory.GetUnit(valType);

            if (unit.Length > 0)
            {
                valueAxis.Unit = unit;
                valueAxis.TitleFormatString = "{0}, {1}";
            }

            PlotModel.Annotations.Add(timePickerAnnotation);
            PlotModel.Axes.Add(dateAxis);
            PlotModel.Axes.Add(valueAxis);
        }
Пример #11
0
        public AccuracyPlotViewModel(AccuracyResult data)
        {
            SetUpPlot(data.ParameterType, data.RealSource);

            var categories = new List <StatisticMethods>();

            categories = (from source in data.Values.Keys
                          from result in data.Values[source]
                          select result.Key).Distinct().ToList();

            foreach (var source in data.Values.Keys)
            {
                var columnSerie = new ColumnSeries()
                {
                    FillColor           = source.OxyColor(),
                    TrackerFormatString = source.Name + "\r\n" + ParametersFactory.GetName(data.ParameterType) + "\r\n{1}: {2:0.000}",
                };

                foreach (var results in data.Values[source])
                {
                    columnSerie.Items.Add(new ColumnItem(results.Value, categories.IndexOf(results.Key)));
                }
                PlotModel.Series.Add(columnSerie);
            }

            var categoryAxis = new CategoryAxis()
            {
                IsZoomEnabled = false,
                IsPanEnabled  = false,
                GapWidth      = 0.5
            };

            foreach (var item in categories)
            {
                categoryAxis.Labels.Add(item.ToString());
            }
            PlotModel.Axes.Add(categoryAxis);
        }
Пример #12
0
        public static double MAPE(ParameterTimeSeries forecast, ParameterTimeSeries real)
        {
            EvaluateCorrectness(forecast, real, 1);

            string type = forecast.Type;

            if (ParametersFactory.IsZeroable(type))
            {
                throw new ArgumentException("MAPE of zeroable values not allowed.");
            }

            int    length = Math.Min(forecast.Length, real.Length);
            double sumOfPercantageErrors = 0;

            for (var i = 0; i < length; i++)
            {
                sumOfPercantageErrors += Math.Abs((double)ParametersFactory.GetValueDistance(type, real.Values[i], forecast.Values[i]) / real.Values[i]);
            }

            double result = sumOfPercantageErrors / length;

            return(result);
        }
Пример #13
0
        private void SetUpPlot(string valType, RealDataSource realSource)
        {
            PlotModel = new OxyPlot.PlotModel
            {
                Title                   = ParametersFactory.GetName(valType),
                Subtitle                = "данные от " + realSource.Name,
                TitlePadding            = 0,
                Padding                 = new OxyThickness(1, 10, 1, 0),
                PlotAreaBorderThickness = 1,
                PlotAreaBorderColor     = OxyColor.FromAColor(64, OxyColors.Black),
            };

            var valueAxis = new LinearAxis(AxisPosition.Left)
            {
                AbsoluteMinimum    = 0,
                MinimumPadding     = 0,
                MaximumPadding     = 0.05,
                MajorGridlineStyle = LineStyle.Solid,
                MinorGridlineStyle = LineStyle.Dot
            };

            PlotModel.Axes.Add(valueAxis);
        }
 public SourcesParametersPickerViewModel()
 {
     Sources    = new ObservableCollection <IAbstractDataSource>(SourcesDirector.Instance.AllDataSources);
     Parameters = new ObservableCollection <AbstractParameter>(
         ParametersFactory.KnownParameterTypesNames.Select(type => ParametersFactory.CreateParameter(type, 1)));
     CheckedSources.CollectionChanged += (s, e) =>
     {
         if (!_sourceListManualAdding)
         {
             if (CheckedSources.Count == Sources.Count)
             {
                 IsAllSourcesChecked = true; // consider CheckedSources may contain only elements of Sources
             }
             else
             {
                 IsAllSourcesChecked = false;
             }
         }
     };
     CheckedParameters.CollectionChanged += (s, e) =>
     {
         if (!_sourceListManualAdding)
         {
             if (CheckedParameters.Count == Parameters.Count)
             {
                 IsAllParametersChecked = true; // consider CheckedParameters may contain only elements of Parameters
             }
             else
             {
                 IsAllParametersChecked = false;
             }
         }
     };
     IsAllSourcesChecked    = false;
     IsAllParametersChecked = false;
 }
Пример #15
0
 public FeatureCenterWindowsFormsModule()
 {
     InitializeComponent();
     ParametersFactory.RegisterParameter(new ExternalApplicationKeyParameter());
     RequiredModuleTypes.Add(typeof(Xpand.XAF.Modules.CloneModelView.CloneModelViewModule));
 }
Пример #16
0
 static XpandSystemModule()
 {
     ParametersFactory.RegisterParameter(new MonthAgoParameter());
     TranslatorProvider.RegisterProvider(new GoogleTranslatorProvider());
 }
Пример #17
0
        private void AddDataSeries(ParameterTimeSeries data, IAbstractDataSource source, OxyColor color)
        {
            string timeRelation = GetRelationPreposition(data.GroupingTimeKind, true);
            var    lineSerie    = new LineSeries
            {
                StrokeThickness             = 2,
                Color                       = color,
                MarkerType                  = MarkerType.Circle,
                MarkerSize                  = 4,
                MarkerFill                  = color,
                CanTrackerInterpolatePoints = false,
                TrackerFormatString         = source.Name + "\r\n{0}\r\n{1} {2:" + targetDateTimeFormat + "}\r\n{3}: {4} " + ParametersFactory.GetUnit(data.Type),
                Title                       = string.Format("{0} {1} {2:" + (source is ForecastDataSource ? groupingDateTimeFormat : groupingDateFormat) + "}", data.Length, timeRelation, data.GroupingTime),
                Smooth                      = false,
            };

            for (int i = 0; i < data.Length; i++)
            {
                lineSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(data.TargetTimes[i]), data.RealValues[i]));
            }
            PlotModel.Series.Add(lineSerie);
        }
Пример #18
0
 public MethodCaller(AjaxHandler executionContext, IMkJson json)
 {
     this._executionContext = executionContext;
     this._resultsFactory = new ResultsFactory(json);
     this._parametersFactory = new ParametersFactory(json);
 }
Пример #19
0
 public FeatureCenterWindowsFormsModule()
 {
     InitializeComponent();
     ParametersFactory.RegisterParameter(new ExternalApplicationKeyParameter());
 }
        public void QueryTyped_WithAnonymousParamsAndOutParam_Executes()
        {
            using (var c = _dataAndSchema.GetConnection())
            {
                c.Open();

                var w = new SqlMapperWrapper(c);

                IParametersFactory fact = new ParametersFactory();

                var args = fact.CreateInstance(new {Val = _dataAndSchema.Value.ToString()});
                args.Add("@affected", null, DbType.Int32, ParameterDirection.InputOutput);

                var result = w.Query<EntityBar>(
                    SqlDataAndSchema.SprocNameDapperSingleInSingleOutParam,
                    args,
                    commandType: CommandType.StoredProcedure).ToList();

                var outparam = args.Get<int>("@affected");

                Assert.IsNotNull(result);
                Assert.IsTrue(result.Count() == 1);
                Assert.IsTrue(outparam == 1);
            }
        }