Esempio n. 1
0
        internal CounterInfo GetCounters(Guid tenantId, string entityId)
        {
            //  List<CounterInfo> counters = null;
            CounterInfo counters = null;

            try
            {
                SqlProcedureCommand cmd = CreateProcedureCommand("dbo.Counter_GetAll");
                cmd.AppendGuid("@guidTenantId", tenantId);
                cmd.AppendMediumText("@guidEntityId", entityId);
                using (SqlDataReader reader = ExecuteCommandAndReturnReader(cmd))
                {
                    while (reader.Read())
                    {
                        counters = ReadInfo(reader);
                    }
                }
            }
            catch (SqlException e)
            {
                throw ReportAndTranslateException(e, "DataCounter::Counter_GetById");
            }

            return(counters);
        }
Esempio n. 2
0
        bool IManagerCounter.Update(Guid tenantId, CounterInfo info)
        {
            IMetadataManager _iMetadataManager = new VPC.Framework.Business.MetadataManager.Contracts.MetadataManager();
            string           entityId          = _iMetadataManager.GetEntityContextByEntityName(info.EntityName);

            return(_adminCounter.Update(tenantId, info, entityId));
        }
        public static CounterInfo FromPerfmonCounter(CounterItem item)
        {
            CounterInfo info = new CounterInfo();

            SaveCounterItemInfo(item, info);
            return(info);
        }
        public IList<CounterInfo> GetCounters()
        {
            var data = new List<CounterInfo>();
            foreach (var counter in Counters)
            {
                var hostGroup = HostGroups[counter.HostGroup];
                if (hostGroup == null)
                    throw new ConfigurationErrorsException(string.Format("HostGroup '{0}' not defined.", counter.HostGroup));

                var condition = GetCondition(counter.Condition);
                var transform = GetTransform(counter.Transform);

                foreach (var host in hostGroup.Hosts)
                {
                    foreach (var instance in GetInstances(counter, host))
                    {
                        foreach (var counterName in GetCounters(counter, host, instance))
                        {
                            using (var perfCounter = PerformanceCounterHelper.Get(counter.Category, counterName, instance, host.Name))
                            {
                                var counterInfo = new CounterInfo(host.Name, perfCounter.CategoryName, perfCounter.CounterName,
                                                                            perfCounter.InstanceName, perfCounter.CounterType,
                                                                            counter.SamplingInterval, condition, transform);

                                data.Add(counterInfo);
                            }
                        }
                    }
                }
            }
            return data;
        }
Esempio n. 5
0
        private static void MergeSampleData(CounterInfo original, CounterInfo newSample)
        {
            foreach (var dim in newSample.Dimensions)
            {
                if (!original.Dimensions.Any(d => d.Equals(dim, StringComparison.OrdinalIgnoreCase)))
                {
                    original.Dimensions.Add(dim);
                }

                if (original.StartTime > newSample.StartTime)
                {
                    original.StartTime = newSample.StartTime;
                }
                if (original.EndTime < newSample.EndTime)
                {
                    original.EndTime = newSample.EndTime;
                }
            }

            if (newSample.DimensionValues != null)
            {
                // Necessary because of some fun quackery in Bond.
                original.FixDimensionValuesCaseSensitivity();
                foreach (var kvp in newSample.DimensionValues)
                {
                    var dim       = kvp.Key;
                    var newValues = kvp.Value;
                    original.AddDimensionValues(dim, newValues);
                }
            }
        }
Esempio n. 6
0
 public void CounterAdd(CounterInfo counterinfo)
 {
     try
     {
         if (base.sqlcon.State == ConnectionState.Closed)
         {
             base.sqlcon.Open();
         }
         SqlCommand sccmd = new SqlCommand("CounterAdd", base.sqlcon);
         sccmd.CommandType = CommandType.StoredProcedure;
         SqlParameter sprmparam5 = new SqlParameter();
         sprmparam5       = sccmd.Parameters.Add("@counterName", SqlDbType.VarChar);
         sprmparam5.Value = counterinfo.CounterName;
         sprmparam5       = sccmd.Parameters.Add("@narration", SqlDbType.VarChar);
         sprmparam5.Value = counterinfo.Narration;
         sprmparam5       = sccmd.Parameters.Add("@extra1", SqlDbType.VarChar);
         sprmparam5.Value = counterinfo.Extra1;
         sprmparam5       = sccmd.Parameters.Add("@extra2", SqlDbType.VarChar);
         sprmparam5.Value = counterinfo.Extra2;
         sccmd.ExecuteNonQuery();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
     finally
     {
         base.sqlcon.Close();
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterSP   spCounter   = new CounterSP();
         infoCounter.CounterName = txtCounterName.Text.Trim();
         infoCounter.Narration   = txtNarration.Text.Trim();
         infoCounter.Extra1      = string.Empty;
         infoCounter.Extra2      = string.Empty;
         if (spCounter.CounterCheckIfExist(txtCounterName.Text.Trim(), 0) == false)
         {
             decLedgerId = spCounter.CounterAddWithIdentity(infoCounter);
             Messages.SavedMessage();
             Clear();
             decIdForOtherForms = decLedgerId;
         }
         else
         {
             Messages.InformationMessage("Counter name already exist");
             txtCounterName.Focus();
         }
         if (frmPOSObj != null)
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 8
0
        /// <summary>
        /// Counter view with narration
        /// </summary>
        /// <param name="decCounterId"></param>
        /// <returns></returns>
        public CounterInfo CounterWithNarrationView(decimal decCounterId)
        {
            CounterInfo   counterinfo = new CounterInfo();
            SqlDataReader sdrreader   = null;

            try
            {
                if (sqlcon.State == ConnectionState.Closed)
                {
                    sqlcon.Open();
                }
                SqlCommand sccmd = new SqlCommand("CounterWithNarrationView", sqlcon);
                sccmd.CommandType = CommandType.StoredProcedure;
                SqlParameter sprmparam = new SqlParameter();
                sprmparam       = sccmd.Parameters.Add("@counterId", SqlDbType.Decimal);
                sprmparam.Value = decCounterId;
                sdrreader       = sccmd.ExecuteReader();
                while (sdrreader.Read())
                {
                    counterinfo.CounterId   = Convert.ToDecimal(sdrreader[0].ToString());
                    counterinfo.CounterName = sdrreader[1].ToString();
                    counterinfo.Narration   = sdrreader[2].ToString();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                sdrreader.Close();
                sqlcon.Close();
            }
            return(counterinfo);
        }
Esempio n. 9
0
        internal bool Update(Guid tenantId, CounterInfo info, string entityId)
        {
            try
            {
                var cmd = CreateProcedureCommand("dbo.Counter_Update");
                cmd.AppendGuid("@guidTenantId", tenantId);
                cmd.AppendGuid("@guidCounterId", info.CounterId);
                cmd.AppendMediumText("@strText", info.Text);
                cmd.AppendMediumText("@strDescription", info.Description);
                cmd.AppendInt("@intCounterN", info.CounterN.Value);
                cmd.AppendInt("@intCounterO", info.CounterO.Value);
                cmd.AppendInt("@intCounterP", info.CounterP.Value);
                cmd.AppendInt("@intResetCounterN", info.ResetCounterN.Value);
                cmd.AppendInt("@intResetCounterO", info.ResetCounterO.Value);
                cmd.AppendInt("@intResetCounterP", info.ResetCounterP.Value);
                cmd.AppendDateTime("@dateUpdatedOn", DateTime.UtcNow);
                cmd.AppendGuid("@guidUpdatedBy", info.UpdatedBy);
                cmd.AppendMediumText("@strEntityId", entityId);
                ExecuteCommand(cmd);
                return(true);
            }
            catch (SqlException e)
            {
                throw ReportAndTranslateException(e, "DataBatchType::Counter_Update");
            }

            // return true;
        }
        string GetCounterShortName(CounterInfo counterInfo)
        {
            string instanceString = "";
            if (!string.IsNullOrWhiteSpace(counterInfo.Instance))
                instanceString = string.Format("/{0}", counterInfo.Instance);

            return string.Format("{0}{1}", counterInfo.Name, instanceString);
        }
Esempio n. 11
0
 private void SaveCounterVisualProperties(CounterInfo counterInfo, CounterItem item)
 {
     if (counterInfo.OriginalPath != item.Path)
     {
         return;
     }
     CounterInfoHelper.SaveCounterItemInfo(item, counterInfo);
 }
Esempio n. 12
0
        private TreeNode AddCounterToTree(TreeNode parent, CounterInfo counterinfo)
        {
            TreeNode node = parent.Nodes.Add(counterinfo.FinalPath);

            node.Tag                = counterinfo;
            node.ImageIndex         = 2;
            node.SelectedImageIndex = 2;
            return(node);
        }
Esempio n. 13
0
        /// <inheritdoc />
        public CounterInfo AddCounter(string key)
        {
            var counter = new CounterInfo {
                Name = key
            };

            _counterInfo.Add(key, counter);

            return(counter);
        }
Esempio n. 14
0
        private void AddNewSysCounterFromUI(CounterItem currentUICounter, CounterFolder folder)
        {
            CounterInfo newCOunterInfo = CounterInfoHelper.FromPerfmonCounter(currentUICounter);

            if (folder.ContainsCounter(newCOunterInfo))
            {
                return;
            }
            folder.Counterinfos.Add(newCOunterInfo);
            AddCounterToTree(TreeSelectedFolderNode, newCOunterInfo);
        }
        public async Task <string> StartUp(int threadCount, string text)
        {
            counterInfo             = new CounterInfo();
            counterInfo.Sentences   = new List <string>();
            counterInfo.Words       = new List <string>();
            counterInfo.ThreadCount = new List <ThreadInfo>();
            counterInfo.WordCount   = new List <WordInfo>();

            await FindSentences(text);

            CalucateAvarageOfWordCount(counterInfo.Sentences);

            var takeCount = counterInfo.SentenceCount / threadCount;

            if (takeCount == 0)
            {
                takeCount = 1;
            }

            List <IEnumerable <string> > listOfPartition = new List <IEnumerable <string> >();
            int totalTakeCount = 0;

            for (int i = 0; i < threadCount; i++)
            {
                if (totalTakeCount == counterInfo.Sentences.Count)
                {
                    takeCount = 0;
                }

                if (i == threadCount - 1 && counterInfo.Sentences.Count > threadCount)
                {
                    takeCount = counterInfo.Sentences.Count - totalTakeCount;
                }

                listOfPartition.Add(counterInfo.Sentences.Skip(i).Take(takeCount));
                totalTakeCount += takeCount;
            }

            tasks = new List <Task>();
            foreach (var item in listOfPartition)
            {
                tasks.Add(Task.Run(async() =>
                {
                    await WordParserProcess(item);
                    await Task.Delay(2000);
                }));
            }

            Task.WaitAll(tasks.ToArray());

            string result = WriteProcessResults();

            return(result);
        }
Esempio n. 16
0
 public bool ContainsCounter(CounterInfo info)
 {
     foreach (CounterInfo local in counterinfos)
     {
         if (local.ShortName == info.ShortName && local.OriginalPath != string.Empty)
         {
             return(true);
         }
     }
     return(false);
 }
Esempio n. 17
0
        public static void AddCounterItem(CounterInfo info, SysMonitorControlEx monitor)
        {
            CounterItem item =
                monitor.Counters.Add(info.FinalPath);

            item.Color     = (uint)info.Colornum;
            item.LineStyle = info.LineStyle;
//			item.ScaleFactor= info.Scale;
            item.Width = info.Width;
            info.Tag   = item;
        }
Esempio n. 18
0
        public async Task <CounterInfo> AddCounter(string userId)
        {
            var counterInfo = new CounterInfo
            {
                Counter = 0,
                UserId  = userId
            };

            await _counterRepository.AddCounter(counterInfo);

            return(await _counterRepository.GetCounter(userId));
        }
Esempio n. 19
0
        private static CounterInfo BuildCounterInfo(Counter counter, DimensionSpecification queryParameters)
        {
            var counterInfo = new CounterInfo
            {
                Name            = counter.Name,
                Type            = counter.Type,
                StartTime       = counter.StartTime.ToMillisecondTimestamp(),
                EndTime         = counter.EndTime.ToMillisecondTimestamp(),
                Dimensions      = counter.Dimensions.ToList(),
                DimensionValues = null,                   // null this out by default to avoid response bloat.
            };

            // Queries for dimension values will come with a 'dimension=pattern' query parameter.
            // Dimension values can be further filtered with '<dimensionName>=pattern'
            string dimensionPattern;

            if (queryParameters.TryGetValue(ReservedDimensions.DimensionDimension, out dimensionPattern))
            {
                counterInfo.DimensionValues = new Dictionary <string, ISet <string> >();

                // We want to be able to filter dimension values by time (and only time)
                var    dimensionQuery = new DimensionSpecification();
                string timeValue;
                if (!queryParameters.TryGetValue(ReservedDimensions.StartTimeDimension, out timeValue))
                {
                    timeValue = MinimumStartTime;
                }
                dimensionQuery[ReservedDimensions.StartTimeDimension] = timeValue;
                if (!queryParameters.TryGetValue(ReservedDimensions.EndTimeDimension, out timeValue))
                {
                    timeValue = MaximumEndTime;
                }
                dimensionQuery[ReservedDimensions.EndTimeDimension] = timeValue;

                foreach (var dim in counter.Dimensions.Where(d => d.MatchGlob(dimensionPattern)))
                {
                    string filterPattern;
                    if (queryParameters.TryGetValue(dimensionPattern, out filterPattern))
                    {
                        counterInfo.AddDimensionValues(dim,
                                                       counter.GetDimensionValues(dim, dimensionQuery)
                                                       .Where(dimensionValue =>
                                                              dimensionValue.MatchGlob(filterPattern)));
                    }
                    else
                    {
                        counterInfo.AddDimensionValues(dim, counter.GetDimensionValues(dim, dimensionQuery));
                    }
                }
            }

            return(counterInfo);
        }
Esempio n. 20
0
        public override void Write(ByteArray by)
        {
            base.Write(by);
            ushort count = (ushort)list.Count;

            by.WriteUShort(count);
            for (int i = 0; i < count; ++i)
            {
                CounterInfo obj = list[i];
                obj.Write(by);
            }
        }
Esempio n. 21
0
        private void AddSampleData(CounterInfo newSample)
        {
            CounterInfo knownCounter;

            if (this.knownCounters.TryGetValue(newSample, out knownCounter))
            {
                MergeSampleData(knownCounter, newSample);
            }
            else
            {
                this.knownCounters.Add(newSample, newSample);
            }
        }
Esempio n. 22
0
        public override void Read(ByteArray by)
        {
            base.Read(by);
            list.Clear();
            ushort count = by.ReadUShort();

            for (int i = 0; i < count; ++i)
            {
                CounterInfo obj = new CounterInfo();
                obj.Read(by);
                list.Add(obj);
            }
        }
Esempio n. 23
0
        public CounterInfo CounterWithNarrationView(decimal decCounterId)
        {
            CounterInfo counterinfo = new CounterInfo();

            try
            {
                counterinfo = spCounter.CounterWithNarrationView(decCounterId);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CBLL:5" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(counterinfo);
        }
Esempio n. 24
0
        public decimal CounterAddWithIdentity(CounterInfo CounterInfo)
        {
            decimal decLedgerId = 0;

            try
            {
                decLedgerId = spCounter.CounterAddWithIdentity(CounterInfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CBLL:3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(decLedgerId);
        }
Esempio n. 25
0
        public bool CounterEditParticularField(CounterInfo counterinfo)
        {
            bool isEdit = false;

            try
            {
                isEdit = spCounter.CounterEditParticularField(counterinfo);
            }
            catch (Exception ex)
            {
                MessageBox.Show("CBLL:4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            return(isEdit);
        }
Esempio n. 26
0
 /// <summary>
 /// Function to edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterSP   spCounter   = new CounterSP();
         infoCounter.CounterName = txtCounterName.Text.Trim();
         infoCounter.Narration   = txtNarration.Text.Trim();
         infoCounter.Extra1      = string.Empty;
         infoCounter.Extra2      = string.Empty;
         infoCounter.CounterId   = Convert.ToDecimal(dgvCounter.CurrentRow.Cells["dgvtxtcounterId"].Value.ToString());
         if (txtCounterName.Text.ToString() != strCounterName)
         {
             if (spCounter.CounterCheckIfExist(txtCounterName.Text.Trim(), decCounterId) == false)
             {
                 if (spCounter.CounterEditParticularField(infoCounter))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
                 else if (infoCounter.CounterId == 1)
                 {
                     Messages.InformationMessage("Cannot update");
                     Clear();
                     txtCounterName.Focus();
                 }
             }
             else
             {
                 Messages.InformationMessage("Counter name already exist");
                 txtCounterName.Focus();
             }
         }
         else
         {
             spCounter.CounterEditParticularField(infoCounter);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 27
0
        private void SetActivateTabTitle(object tag)
        {
            if (tag == null || tabs.TabPages.Count == 0)
            {
                return;
            }
            if (tag is CounterFolder)
            {
                CounterFolder folder = tag as CounterFolder;
                tabs.SelectedTab.Text = folder.Name;
            }

            if (tag is CounterInfo)
            {
                CounterInfo info = tag as CounterInfo;
                tabs.SelectedTab.Text = info.ShortName;
            }
        }
        public IActionResult Put([FromBody] CounterInfo info)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called CounterController Put {0}=", JsonConvert.SerializeObject(info));
                info.UpdatedBy = UserId;

                var retVal = _managerCounter.Update(TenantCode, info);
                stopwatch.StopAndLog("End CounterController put");
                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Esempio n. 29
0
        public void ActivateCountersFromObject(object tag)
        {
            ClearCounters();
            if (tag == null)
            {
                return;
            }
            if (tag is CounterFolder)
            {
                CounterFolder folder = tag as CounterFolder;
                AddFolderCountersToMonitor(folder);
            }

            if (tag is CounterInfo)
            {
                CounterInfo info = tag as CounterInfo;
                AddCounterToMonitor(info);
            }
        }
Esempio n. 30
0
 /// <summary>
 /// Function to fill controls to update
 /// </summary>
 public void FillControls()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterSP   spCounter   = new CounterSP();
         infoCounter         = spCounter.CounterWithNarrationView(Convert.ToDecimal(dgvCounter.CurrentRow.Cells[1].Value.ToString()));
         txtCounterName.Text = infoCounter.CounterName;
         txtNarration.Text   = infoCounter.Narration;
         btnSave.Text        = "Update";
         btnDelete.Enabled   = true;
         decCounterId        = infoCounter.CounterId;
         strCounterName      = infoCounter.CounterName;
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
Esempio n. 31
0
 private void SaveVisualProperties(AxSystemMonitor.AxSystemMonitor ActiveMonitor, CounterItem SelectedCounter)
 {
     if (TreeSelectedCounter == null)
     {
         int           sysCountersCount = ActiveMonitor.Counters.Count;
         CounterFolder folder           = TreeSelectedFolder;
         for (int i = 1; i <= sysCountersCount; i++)
         {
             CounterInfo info = (CounterInfo)folder.Counterinfos[i - 1];
             CounterItem item = ActiveMonitor.Counters[i];
             SaveCounterVisualProperties(info, item);
         }
     }
     else
     {
         SaveCounterVisualProperties(TreeSelectedCounter, SelectedCounter);
     }
     MessageBox.Show("Saved!");
 }
Esempio n. 32
0
        public static void SaveCounterItemInfo(CounterItem item, CounterInfo info)
        {
            //find bug of short name
//			info.Colornum=(int) item.Color;
//			info.LineStyle= item.LineStyle;
//			info.OriginalPath= item.Path;
//			info.Scale=item.ScaleFactor;
//			info.Width=item.Width;
//			info.Tag= item;
//
            info.Colornum  = int.Parse(item.Color.ToString());
            info.LineStyle = int.Parse(item.LineStyle.ToString());
            string newpath = string.Copy(item.Path);

            info.OriginalPath = newpath;

            info.Scale = int.Parse(item.ScaleFactor.ToString());
            info.Width = int.Parse(item.Width.ToString());
            info.Tag   = item;
        }
 private void UpdateCounterStats(CounterInfo counter, Stats stats, double? last)
 {
     string counterName = GetCounterShortName(counter);
     UpdateConsoleDataRow(stats.ConsoleRow, counterName,
                         NumberToString(last), NumberToString(stats.Avarage()),
                         NumberToString(stats.Percentile(0.9)), NumberToString(stats.Max()));
 }
 /// <summary>
 /// Function to fill controls to update
 /// </summary>
 public void FillControls()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterBll bllCounter = new CounterBll();
         infoCounter = bllCounter.CounterWithNarrationView(Convert.ToDecimal(dgvCounter.CurrentRow.Cells[1].Value.ToString()));
         txtCounterName.Text = infoCounter.CounterName;
         txtNarration.Text = infoCounter.Narration;
         btnSave.Text = "Update";
         btnDelete.Enabled = true;
         decCounterId = infoCounter.CounterId;
         strCounterName = infoCounter.CounterName;
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT8" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
 /// <summary>
 /// Function to save
 /// </summary>
 public void SaveFunction()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterBll bllCounter = new CounterBll();
         infoCounter.CounterName = txtCounterName.Text.Trim();
         infoCounter.Narration = txtNarration.Text.Trim();
         infoCounter.Extra1 = string.Empty;
         infoCounter.Extra2 = string.Empty;
         if (bllCounter.CounterCheckIfExist(txtCounterName.Text.Trim(), 0) == false)
         {
             decLedgerId = bllCounter.CounterAddWithIdentity(infoCounter);
             Messages.SavedMessage();
             Clear();
             decIdForOtherForms = decLedgerId;
         }
         else
         {
             Messages.InformationMessage("Counter name already exist");
             txtCounterName.Focus();
         }
         if (frmPOSObj != null)
         {
             this.Close();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT3" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }
        private static void MergeSampleData(CounterInfo original, CounterInfo newSample)
        {
            foreach (var dim in newSample.Dimensions)
            {
                if (!original.Dimensions.Any(d => d.Equals(dim, StringComparison.OrdinalIgnoreCase)))
                {
                    original.Dimensions.Add(dim);
                }

                if (original.StartTime > newSample.StartTime)
                {
                    original.StartTime = newSample.StartTime;
                }
                if (original.EndTime < newSample.EndTime)
                {
                    original.EndTime = newSample.EndTime;
                }
            }

            if (newSample.DimensionValues != null)
            {
                // Necessary because of some fun quackery in Bond.
                original.FixDimensionValuesCaseSensitivity();
                foreach (var kvp in newSample.DimensionValues)
                {
                    var dim = kvp.Key;
                    var newValues = kvp.Value;
                    original.AddDimensionValues(dim, newValues);
                }
            }
        }
 private void AddSampleData(CounterInfo newSample)
 {
     CounterInfo knownCounter;
     if (this.knownCounters.TryGetValue(newSample, out knownCounter))
     {
         MergeSampleData(knownCounter, newSample);
     }
     else
     {
         this.knownCounters.Add(newSample, newSample);
     }
 }
Esempio n. 38
0
        private static CounterInfo BuildCounterInfo(Counter counter, DimensionSpecification queryParameters)
        {
            var counterInfo = new CounterInfo
                              {
                                  Name = counter.Name,
                                  Type = counter.Type,
                                  StartTime = counter.StartTime.ToMillisecondTimestamp(),
                                  EndTime = counter.EndTime.ToMillisecondTimestamp(),
                                  Dimensions = counter.Dimensions.ToList(),
                                  DimensionValues = null, // null this out by default to avoid response bloat.
                              };

            // Queries for dimension values will come with a 'dimension=pattern' query parameter.
            // Dimension values can be further filtered with '<dimensionName>=pattern'
            string dimensionPattern;
            if (queryParameters.TryGetValue(ReservedDimensions.DimensionDimension, out dimensionPattern))
            {
                counterInfo.DimensionValues = new Dictionary<string, ISet<string>>();

                // We want to be able to filter dimension values by time (and only time)
                var dimensionQuery = new DimensionSpecification();
                string timeValue;
                if (!queryParameters.TryGetValue(ReservedDimensions.StartTimeDimension, out timeValue))
                {
                    timeValue = MinimumStartTime;
                }
                dimensionQuery[ReservedDimensions.StartTimeDimension] = timeValue;
                if (!queryParameters.TryGetValue(ReservedDimensions.EndTimeDimension, out timeValue))
                {
                    timeValue = MaximumEndTime;
                }
                dimensionQuery[ReservedDimensions.EndTimeDimension] = timeValue;

                foreach (var dim in counter.Dimensions.Where(d => d.MatchGlob(dimensionPattern)))
                {
                    string filterPattern;
                    if (queryParameters.TryGetValue(dimensionPattern, out filterPattern))
                    {
                        
                        counterInfo.AddDimensionValues(dim,
                                                       counter.GetDimensionValues(dim, dimensionQuery)
                                                              .Where(dimensionValue =>
                                                                     dimensionValue.MatchGlob(filterPattern)));
                    }
                    else
                    {
                        counterInfo.AddDimensionValues(dim, counter.GetDimensionValues(dim, dimensionQuery));
                    }
                }
            }

            return counterInfo;
        }
 public Stats(CounterInfo counter, int consoleRow)
 {
     Counter = counter;
     ConsoleRow = consoleRow;
 }
 /// <summary>
 /// Function to edit
 /// </summary>
 public void EditFunction()
 {
     try
     {
         CounterInfo infoCounter = new CounterInfo();
         CounterBll bllCounter = new CounterBll();
         infoCounter.CounterName = txtCounterName.Text.Trim();
         infoCounter.Narration = txtNarration.Text.Trim();
         infoCounter.Extra1 = string.Empty;
         infoCounter.Extra2 = string.Empty;
         infoCounter.CounterId = Convert.ToDecimal(dgvCounter.CurrentRow.Cells["dgvtxtcounterId"].Value.ToString());
         if (txtCounterName.Text.ToString() != strCounterName)
         {
             if (bllCounter.CounterCheckIfExist(txtCounterName.Text.Trim(), decCounterId) == false)
             {
                 if (bllCounter.CounterEditParticularField(infoCounter))
                 {
                     Messages.UpdatedMessage();
                     Clear();
                 }
                 else if (infoCounter.CounterId == 1)
                 {
                     Messages.InformationMessage("Cannot update");
                     Clear();
                     txtCounterName.Focus();
                 }
             }
             else
             {
                 Messages.InformationMessage("Counter name already exist");
                 txtCounterName.Focus();
             }
         }
         else
         {
             bllCounter.CounterEditParticularField(infoCounter);
             Messages.UpdatedMessage();
             Clear();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("CT4" + ex.Message, "OpenMiracle", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
 }