예제 #1
0
        internal object FormatVisitDataDouble(IAnalyticsField field, AnalyticsDataRow row1, AnalyticsDataRow row2)
        {
            string key = field.Name.Substring(3);

            double valueOld = (row1 == null ? 0 : row1.GetDouble(field));
            double valueNew = (row2 == null ? 0 : row2.GetDouble(field));

            double change = valueNew - valueOld;

            double percent = change / valueOld * 100;

            return(new OmgDataRow {
                Alias = key,
                Label = Context.Translate(field),
                Value = new { raw = valueNew, text = Context.Format(valueNew) },
                OldValue = new { raw = valueOld, text = Context.Format(valueOld) },
                Change = new {
                    raw = change,
                    text = FormatChange(change),
                    percent = new {
                        raw = Double.IsInfinity(percent) ? null : (object)percent,
                        text = Double.IsInfinity(percent) ? null : FormatChange(percent)
                    }
                },
            });
        }
예제 #2
0
        internal object FormatDouble(IAnalyticsField field, AnalyticsDataRow row)
        {
            string key = field.Name.Substring(3);

            double value = (row == null ? 0 : row.GetDouble(field));

            return(new OmgDataRow {
                Alias = key,
                Label = Context.Translate(field),
                Value = new { raw = value, text = Context.Format(value) }
            });
        }
예제 #3
0
        internal object FormatVisitDataDouble(IAnalyticsField field, DataRow row1, DataRow row2)
        {
            string key = field.Name.Substring(3);

            double valueOld = (row1 == null ? 0 : row1.GetDouble(key));
            double valueNew = (row2 == null ? 0 : row2.GetDouble(key));

            double change = valueNew - valueOld;

            return(new OmgDataRow {
                Alias = key,
                Label = Context.Translate(field),
                Value = new { raw = valueNew, text = Context.Format(valueNew) },
                Change = new { raw = change, text = FormatChange(change) },
            });
        }
예제 #4
0
 public int GetInt32(IAnalyticsField field)
 {
     return(GetValue <int>(field));
 }
예제 #5
0
 public string GetString(IAnalyticsField field)
 {
     return(GetValue <string>(field));
 }
예제 #6
0
 /// <summary>
 /// Gets the value of the cell with the specified <code>field</code> and converts it to
 /// <code>T</code> if found, otherwise the default value for <code>T</code> will be
 /// returned.
 /// </summary>
 /// <param name="field">The field (key) of the cell.</param>
 public T GetValue <T>(IAnalyticsField field)
 {
     return(GetValue <T>(field.Name));
 }
예제 #7
0
 public double GetDouble(IAnalyticsField field)
 {
     return(GetValue <double>(field));
 }
예제 #8
0
 /// <summary>
 /// Translates the phrase matching the name of the specified <code>field</code>.
 /// </summary>
 /// <param name="field">The field.</param>
 public string Translate(IAnalyticsField field)
 {
     return(DashboardHelpers.Translate(Culture, field));
 }
 /// <summary>
 /// Translates the phrase matching the name of the specified <code>field</code>.
 /// </summary>
 /// <param name="field">The field.</param>
 public static string Translate(IAnalyticsField field) {
     return DashboardTranslations.Instance.Translate(DashboardContext.Current.Culture, field.Name);
 }
 public int GetInt32(IAnalyticsField field) {
     return GetInt32(field.Name.Substring(3));
 }
예제 #11
0
 /// <summary>
 /// Translates the phrase matching the name of the specified <code>field</code>.
 /// </summary>
 /// <param name="culture">The culture to be used for the translation.</param>
 /// <param name="field">The field.</param>
 public static string Translate(CultureInfo culture, IAnalyticsField field)
 {
     return(DashboardTranslations.Instance.Translate(culture, field.Name));
 }
        internal object FormatDouble(IAnalyticsField field, AnalyticsDataRow row) {

            string key = field.Name.Substring(3);

            double value = (row == null ? 0 : row.GetDouble(field));

            return new OmgDataRow {
                Alias = key,
                Label = Context.Translate(field),
                Value = new { raw = value, text = Context.Format(value) }
            };

        }
예제 #13
0
 /// <summary>
 /// Translates the phrase matching the name of the specified <code>field</code>.
 /// </summary>
 /// <param name="field">The field.</param>
 public static string Translate(IAnalyticsField field)
 {
     return(DashboardTranslations.Instance.Translate(DashboardContext.Current.Culture, field.Name));
 }
예제 #14
0
 public double GetDouble(IAnalyticsField field)
 {
     return(GetDouble(field.Name.Substring(3)));
 }
예제 #15
0
 public int GetInt32(IAnalyticsField field)
 {
     return(GetInt32(field.Name.Substring(3)));
 }
예제 #16
0
 public string GetString(IAnalyticsField field)
 {
     return(GetString(field.Name.Substring(3)));
 }
 public double GetDouble(IAnalyticsField field) {
     return GetDouble(field.Name.Substring(3));
 }
        internal object FormatVisitDataDouble(IAnalyticsField field, DataRow row1, DataRow row2) {

            string key = field.Name.Substring(3);

            double valueOld = (row1 == null ? 0 : row1.GetDouble(key));
            double valueNew = (row2 == null ? 0 : row2.GetDouble(key));

            double change = valueNew - valueOld;

            return new OmgDataRow {
                Alias = key,
                Label = Context.Translate(field),
                Value = new { raw = valueNew, text = Context.Format(valueNew) },
                Change = new { raw = change, text = Context.Format(change) },
            };

        }
예제 #19
0
        internal object FormatVisitDataTime(IAnalyticsField field, AnalyticsDataRow row1, AnalyticsDataRow row2)
        {
            string key = field.Name.Substring(3);

            double valueOld = (row1 == null ? 0 : row1.GetDouble(field));
            double valueNew = (row2 == null ? 0 : row2.GetDouble(field));

            double change = valueNew - valueOld;

            double percent = change / valueOld * 100;

            TimeSpan ts1 = TimeSpan.FromSeconds(valueOld);
            TimeSpan ts2 = TimeSpan.FromSeconds(valueNew);
            TimeSpan ts3 = TimeSpan.FromSeconds(change);

            List <string> text1 = new List <string>();
            List <string> text2 = new List <string>();
            List <string> text3 = new List <string>();


            if (ts1.TotalSeconds < 10)
            {
                text1.Add(ts1.TotalSeconds.ToString("0.00") + "s");
            }
            else
            {
                if (ts1.Hours > 0)
                {
                    text1.Add(ts1.Hours + "t");
                }
                if (ts1.Minutes > 0)
                {
                    text1.Add(ts1.Minutes + "m");
                }
                if (ts1.Seconds > 0)
                {
                    text1.Add(ts1.Seconds + "s");
                }
            }

            if (ts2.TotalSeconds < 10)
            {
                text2.Add(ts2.TotalSeconds.ToString("0.00") + "s");
            }
            else
            {
                if (ts2.Hours > 0)
                {
                    text2.Add(ts2.Hours + "t");
                }
                if (ts2.Minutes > 0)
                {
                    text2.Add(ts2.Minutes + "m");
                }
                if (ts2.Seconds > 0)
                {
                    text2.Add(ts2.Seconds + "s");
                }
            }

            if (Math.Abs(ts3.TotalSeconds) < 10)
            {
                text3.Add(ts3.TotalSeconds.ToString("0.00") + "s");
            }
            else
            {
                if (Math.Abs(ts3.Hours) > 0)
                {
                    text3.Add(ts3.Hours + "t");
                }
                if (Math.Abs(ts3.Minutes) > 0)
                {
                    text3.Add(ts3.Minutes + "m");
                }
                if (Math.Abs(ts3.Seconds) > 0)
                {
                    text3.Add(ts3.Seconds + "s");
                }
            }

            return(new OmgDataRow {
                Alias = key,
                Label = Context.Translate(field),
                OldValue = new { raw = valueOld, text = String.Join(" og ", text1) },
                Value = new { raw = valueNew, text = String.Join(" og ", text2) },
                Change = new {
                    raw = change,
                    text = (ts3.Ticks > 0 ? "+" : "") + String.Join(" og ", text3),
                    percent = new {
                        raw = Double.IsInfinity(percent) ? null : (object)percent,
                        text = Double.IsInfinity(percent) ? null : FormatChange(percent)
                    }
                },
            });
        }
 /// <summary>
 /// Translates the phrase matching the name of the specified <code>field</code>.
 /// </summary>
 /// <param name="culture">The culture to be used for the translation.</param>
 /// <param name="field">The field.</param>
 public static string Translate(CultureInfo culture, IAnalyticsField field) {
     return DashboardTranslations.Instance.Translate(culture, field.Name);
 }
 public string GetString(IAnalyticsField field) {
     return GetString(field.Name.Substring(3));
 }