Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="value"></param>
 /// <param name="mode"></param>
 public static void MemoryEntry(String value, StatisticMode mode = StatisticMode.Information)
 {
     memoryEntry.Add(mode.ToString(), value);
 }
Пример #2
0
 public double Statistic(string datasourceName, string datasetName, string fieldName, StatisticMode statisticMode)
 {
     if (string.IsNullOrEmpty(datasourceName)) throw new ArgumentNullException("datasourceName", Resources.ArgumentIsNotNull);
     if (string.IsNullOrEmpty(datasetName)) throw new ArgumentNullException("datasetName", Resources.ArgumentIsNotNull);
     if (string.IsNullOrEmpty(fieldName)) throw new ArgumentNullException("fieldName", Resources.ArgumentIsNotNull);
     string uri = string.Format("{0}/data/datasources/{1}/datasets/{2}/fields/{3}/{4}.json?", this._serviceUrl,
         HttpUtility.UrlEncode(datasourceName), HttpUtility.UrlEncode(datasetName), HttpUtility.UrlEncode(fieldName), statisticMode.ToString());
     string result = SynchHttpRequest.GetRequestString(uri);
     Dictionary<string, object> hasResult = JsonConvert.DeserializeObject<Dictionary<string, object>>(result);
     double statisticResult = -9999;
     if (hasResult != null && hasResult.ContainsKey("result") && hasResult["result"] != null)
     {
         double.TryParse(hasResult["result"].ToString(), out statisticResult);
     }
     return statisticResult;
 }
Пример #3
0
        /// <summary>
        /// Save on database Log
        /// </summary>
        /// <param name="value"></param>
        /// <param name="mode"></param>
        /// <param name="source"></param>
        public static Boolean DataBaseEntry(String value, StatisticMode mode = StatisticMode.Information, String source = "")
        {
            var model = new MtnLog {
                CreatedType = DateTime.Now, LogId = Guid.NewGuid().ToString(), ModeType = mode.ToString(), Source = source.Replace("'", "\""), Value = value.Replace("'", "\"")
            };
            var strQuery =
                Configuration.Config.GetConnectionString("Mtn.Library.Statistics.InsertQuery");

            strQuery = strQuery.IsNullOrWhiteSpaceMtn() ? m_query : strQuery;
            strQuery = strQuery.FormatByPropertyMtn(model);
            var useDbContext =
                Configuration.Config.GetNullableBoolean("Mtn.Library.Statistics.UseDbContext").HasValue;

            var assemblyLoad =
                Configuration.Config.GetString("Mtn.Library.Statistics.EntityAssembly");
            var cnnsStr = Mtn.Library.Configuration.Config.GetConnectionString("Mtn.Library.Statistics.ConnectionString");
            //System.Data.Entity.DbContext            DbConte
            //var db = new ObjectContext();

            //return db.ExecuteStoreCommand(strQuery) > 0;

            var objDb = Assembly.Load(assemblyLoad);

            if (objDb != null)
            {
                var     objList = new object[] { cnnsStr };
                dynamic db;
                if (useDbContext)
                {
                    db = objDb.CreateInstance("System.Data.Entity.DbContext", false, BindingFlags.CreateInstance, null, objList, null, null);
                    if (db != null)
                    {
                        int ret = db.Database.ExecuteSqlCommand(strQuery);
                        return(ret > 0);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    db = objDb.CreateInstance("System.Data.Objects.ObjectContext", false, BindingFlags.CreateInstance, null, objList, null, null);
                    if (db != null)
                    {
                        int ret = db.ExecuteStoreCommand(strQuery);
                        return(ret > 0);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            else
            {
                throw new ArgumentNullException("Cannot instance the object : " + assemblyLoad);
            }
        }