public bool InsertExecutionLog(string rows, TimeSpan t, DateTime starttime, int userid, List <Param> param, string refid)
 {
     try
     {
         List <JsonParams> _ParamList = new List <JsonParams>();
         if (param != null)
         {
             foreach (Param item in param)
             {
                 JsonParams obj = new JsonParams {
                     Name = item.Name, Type = Enum.GetName(typeof(EbDbTypes), Convert.ToInt32(item.Type)), Value = item.Value
                 };
                 _ParamList.Add(obj);
             }
         }
         string        _param     = JsonConvert.SerializeObject(_ParamList);
         string        query      = EbConnectionFactory.ObjectsDB.EB_INSERT_EXECUTION_LOGS;
         DbParameter[] parameters =
         {
             EbConnectionFactory.ObjectsDB.GetNewParameter("rows",       EbDbTypes.String,   rows),
             EbConnectionFactory.ObjectsDB.GetNewParameter("exec_time",  EbDbTypes.Int32,    t.TotalMilliseconds),
             EbConnectionFactory.ObjectsDB.GetNewParameter("created_by", EbDbTypes.Int32,    userid),
             EbConnectionFactory.ObjectsDB.GetNewParameter("created_at", EbDbTypes.DateTime, starttime),
             EbConnectionFactory.ObjectsDB.GetNewParameter("params",     EbDbTypes.Json,     _param),
             EbConnectionFactory.ObjectsDB.GetNewParameter("refid",      EbDbTypes.String,   refid)
         };
         this.EbConnectionFactory.ObjectsDB.DoNonQuery(query, parameters);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
         return(false);
     }
     return(true);
 }
Beispiel #2
0
        public T[] GetParamArray <T>() where T : new()
        {
            var typeName = typeof(T).Name;
            var entity   = JsonParams.Find(typeName + "[]");

            if (entity == null)
            {
                return(new T[0]);
            }
            else
            {
                return(JsonConvert.DeserializeObject <T[]>(entity.JsonBody));
            }
        }
Beispiel #3
0
        public void SetParamArray <T>(T[] args) where T : new()
        {
            var typeName = typeof(T).Name + "[]";
            var entity   = JsonParams.Find(typeName);

            if (entity == null)
            {
                entity = new JsonParam
                {
                    Id = typeName
                };
                JsonParams.Add(entity);
            }
            entity.JsonBody = JsonConvert.SerializeObject(args);
        }
Beispiel #4
0
        protected virtual object[] GetArguments()
        {
            // TODO: consider extracting this functionality into an ExecutionResponse class that takes the request and resolves the
            // relevant bits using an IExecutionRequestTargetResolver stated in ResolveExecutionTargetInfo.
            //           AND/OR
            // TODO: consider breaking this class up into specific ExecutionRequest implementations that encapsulate the style of intput parameters/arguments
            //  JsonParamsExecutionRequest, OrderedHttpArgsExecutionRequest, FormEncodedPostExecutionRequest, QueryStringParametersExecutionRequest.
            //  The type of the request should be resolved by examining the ContentType

            // see ExecutionRequestResolver.ResolveExecutionRequest

            // This method is becoming a little bloated
            // due to accomodating too many input paths.
            // This will need to be refactored IF
            // changes continue to be necessary
            // 07/29/2018 - +1 added notes -BA
            // see commit 2526558ea460852c033d1151dc190308a9feaefd

            object[] result = new object[] { };;
            if (HttpArgs.Has("jsonParams", out string jsonParams))
            {
                string[] jsonStrings = jsonParams.FromJson <string[]>();
                result = GetJsonArguments(jsonStrings);
            }
            else if (!string.IsNullOrEmpty(JsonParams))
            {
                // POST: bam.invoke
                string[] jsonStrings = JsonParams.FromJson <string[]>();

                result = GetJsonArguments(jsonStrings);
            }
            else if (Request != null && InputString.Length > 0)
            {
                // POST: probably from a form
                Queue <string> inputValues = new Queue <string>(InputString.Split('&'));

                result = GetFormArguments(inputValues);
            }
            else if (Request != null)
            {
                // GET: parse the querystring
                ViewName = Request.QueryString["view"];
                if (string.IsNullOrEmpty(ViewName))
                {
                    ViewName = "Default";
                }

                jsonParams = Request.QueryString["jsonParams"];
                bool numbered = !string.IsNullOrEmpty(Request.QueryString["numbered"]) ? true : false;
                bool named    = !numbered;

                if (!string.IsNullOrEmpty(jsonParams))
                {
                    dynamic  o           = JsonConvert.DeserializeObject <dynamic>(jsonParams);
                    string[] jsonStrings = ((string)(o["jsonParams"])).FromJson <string[]>();
                    result = GetJsonArguments(jsonStrings);
                }
                else if (named)
                {
                    result = GetNamedQueryStringArguments();
                }
                else
                {
                    result = GetNumberedQueryStringArguments();
                }
            }

            return(result);
        }
Beispiel #5
0
        protected object[] GetParameters()
        {
            // TODO: consider breaking this class up into specific ExecutionRequest implementations that encapsulate the style of parameters
            //  JsonParamsExecutionRequest, OrderedHttpArgsExecutionRequest, FormEncodedPostExecutionRequest, QueryStringParametersExecutionRequest

            // This method is becoming a little bloated
            // due to accomodating too many input paths.
            // This will need to be refactored IF
            // changes continue to be necessary

            object[] result = new object[] { };;
            string   jsonParams;

            if (HttpArgs.Has("jsonParams", out jsonParams))
            {
                string[] jsonStrings = jsonParams.FromJson <string[]>();
                result = GetJsonParameters(jsonStrings);
            }
            else if (HttpArgs.Ordered.Length > 0)
            {
                result = new object[HttpArgs.Ordered.Length];
                HttpArgs.Ordered.Each((val, i) =>
                {
                    result[i] = val;
                });
            }
            else if (!string.IsNullOrEmpty(JsonParams))
            {
                // POST: bam.invoke
                string[] jsonStrings = JsonParams.FromJson <string[]>();

                result = GetJsonParameters(jsonStrings);
            }
            else if (Request != null && InputString.Length > 0)
            {
                // POST: probably from a form
                Queue <string> inputValues = new Queue <string>(InputString.Split('&'));

                result = GetFormParameters(inputValues);
            }
            else if (Request != null)
            {
                // GET: parse the querystring
                ViewName = Request.QueryString["view"];
                if (string.IsNullOrEmpty(ViewName))
                {
                    ViewName = "Default";
                }

                jsonParams = Request.QueryString["jsonParams"];
                bool numbered = !string.IsNullOrEmpty(Request.QueryString["numbered"]) ? true : false;
                bool named    = !numbered;

                if (!string.IsNullOrEmpty(jsonParams))
                {
                    dynamic  o           = JsonConvert.DeserializeObject <dynamic>(jsonParams);
                    string[] jsonStrings = ((string)(o["jsonParams"])).FromJson <string[]>();
                    result = GetJsonParameters(jsonStrings);
                }
                else if (named)
                {
                    result = GetNamedQueryStringParameters();
                }
                else
                {
                    result = GetNumberedParameters();
                }
            }

            return(result);
        }
Beispiel #6
0
        private async void ApiConnect(string LastDevices, string date, int destin)
        {
            try
            {
                if (destin == 0)
                {
                    string            json4Date = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=2&ugo=" + date);
                    AverageJsonParams JParamss  = Newtonsoft.Json.JsonConvert.DeserializeObject <AverageJsonParams>(json4Date);
                    AvDateSp.Text   = JParamss.AverageSpeed.ToString();
                    AvDateDist.Text = JParamss.TotalDistance.ToString();
                    AvDateCal.Text  = JParamss.TotalCalories.ToString();
                }
            }
            catch
            {
                await DisplayAlert("Error", "No data found for this date", "Ok");
            }
            while (StopRM.IsVisible == true)
            {
                try
                {
                    if (destin != 0)
                    {
                        string     json    = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=0&ugo=ugo");
                        JsonParams JParams = Newtonsoft.Json.JsonConvert.DeserializeObject <JsonParams>(json);
                        LSpeed.Text    = JParams.Speed.ToString();
                        LDistance.Text = JParams.Distance.ToString();
                        LCalories.Text = JParams.Сalories.ToString();

                        string json4Average = GETApi("api/params/paraparams?id=" + LastDevices + "&simbol=1&ugo=ugo");

                        AverageJsonParams JParamss = Newtonsoft.Json.JsonConvert.DeserializeObject <AverageJsonParams>(json4Average);
                        AvSpeed.Text = JParamss.AverageSpeed.ToString();
                        AvCal.Text   = JParamss.TotalDistance.ToString();
                        AvDis.Text   = JParamss.TotalCalories.ToString();
                    }


                    int i = rnd.Next(1, 3);
                    if (i == 1)
                    {
                        await StopRM.RotateTo(720, 4000, Easing.CubicInOut);

                        await StopRM.RotateTo(0, 0);
                    }
                    if (i == 2)
                    {
                        await StopRM.RotateTo(1080, 6000, Easing.CubicInOut);

                        await StopRM.RotateTo(0, 0);
                    }
                }
                catch
                {
                    StopRM.IsVisible  = false;
                    StartRM.IsVisible = true;
                    await DisplayAlert("Server is not available", "Check your Internet connection", "Ok");

                    break;
                }
            }
        }