Ejemplo n.º 1
0
        private void backgroundWorkerSearchOnline_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // does nothing if the search been canceled
            if (e.Cancelled || mHasSearchBeenCancelled)
            {
                return;
            }

            // get the result object
            ResultParameter result = (e.Result) as ResultParameter;

            // filter all the package we have found, from the one already installed locally, and save it in the result list of the form
            mFilesToDownload = removeAlreadyInstalledPackagesFromList(result.allPackageListFound);

            // if the list is empty, display an error message, but stay on this form to let the user try again
            if (mFilesToDownload.Count == 0)
            {
                // display a warning message and reload the library
                MessageBox.Show(this, BlueBrick.Properties.Resources.ErrorMsgNoAvailablePartsPackageToDownload,
                                BlueBrick.Properties.Resources.ErrorMsgTitleWarning, MessageBoxButtons.OK,
                                MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                // reenable the search button for a second chance
                changeSearchButton(true);

                // and reset the default cursor for the form
                this.Cursor = Cursors.Default;
            }
            else
            {
                // if we have something to download, close the form, to let the main form open the next form to download the packages
                mIsFormClosingSuccessfully = true;
                this.Close();
            }
        }
Ejemplo n.º 2
0
 public IList <T_Result> QueryT_Result(ResultParameter resultParameter)
 {
     if (resultParameter.EndTime.HasValue)
     {
         resultParameter.RealEndTime = resultParameter.EndTime.Value.AddDays(1);
     }
     return(ResultDAO.QueryT_Result(resultParameter));
 }
Ejemplo n.º 3
0
        private void MediateTableMetrics(DateTime start, DateTime end)
        {
            var queryExecuter = new QueryExecuter(_userSession.AzureInfo.AccountName, _userSession.AzureInfo.AccountKey);

            InvokeStatusStorageMetricsChanged("Get metrics data from Azure");
            MetricsTransactionsEntity[] metricsTransactionsEntities = queryExecuter.GetMetricData(start, end);

            String statusFormat = "Captured records count: {0}\r\nPushed to monitis service:{1}";

            Int32 totalProcessedRecords = 0;

            InvokeStatusStorageMetricsChanged(String.Format(statusFormat, metricsTransactionsEntities.Length, totalProcessedRecords));
            var customMonitorAPI = new CustomMonitorAPI(_userSession.APIKey, _userSession.APIType);

            foreach (MetricsTransactionsEntity metricsTransactionsEntity in metricsTransactionsEntities)
            {
                CustomMonitorConfig availabilityConfig =
                    CustomMonitorList.Singleton.GetConfigByMetricName(MetricNames.Availability);
                ResultParameter convertToMonitorResult = DataConverter.ConvertToMonitorResult(metricsTransactionsEntity.Availability,
                                                                                              metricsTransactionsEntity.Timestamp,
                                                                                              availabilityConfig);

                customMonitorAPI.AddResults(_userSession.CurrentAuthToken, availabilityConfig.MonitorID,
                                            new List <ResultParameter> {
                    convertToMonitorResult
                });

                CustomMonitorConfig totalRequestsConfig =
                    CustomMonitorList.Singleton.GetConfigByMetricName(MetricNames.TotalRequests);
                convertToMonitorResult = DataConverter.ConvertToMonitorResult(metricsTransactionsEntity.TotalRequests,
                                                                              metricsTransactionsEntity.Timestamp,
                                                                              totalRequestsConfig);
                customMonitorAPI.AddResults(_userSession.CurrentAuthToken, totalRequestsConfig.MonitorID,
                                            new List <ResultParameter> {
                    convertToMonitorResult
                });

                CustomMonitorConfig totalBillableRequestsConfig =
                    CustomMonitorList.Singleton.GetConfigByMetricName(MetricNames.TotalBillableRequests);
                convertToMonitorResult = DataConverter.ConvertToMonitorResult(metricsTransactionsEntity.TotalBillableRequests,
                                                                              metricsTransactionsEntity.Timestamp,
                                                                              totalBillableRequestsConfig);
                customMonitorAPI.AddResults(_userSession.CurrentAuthToken, totalBillableRequestsConfig.MonitorID,
                                            new List <ResultParameter> {
                    convertToMonitorResult
                });

                totalProcessedRecords++;
                InvokeStatusStorageMetricsChanged(String.Format(statusFormat, metricsTransactionsEntities.Length, totalProcessedRecords));
            }
            InvokeStatusStorageMetricsChanged("Completed");
            InvokeStorageMetricsPublishCompleted(EventArgs.Empty);
        }
        /// <summary>
        /// Convert Windows Azure perfomance counter data to Monitis monitor <see cref="ResultParameter"/>
        /// </summary>
        /// <param name="data">Data to convert</param>
        /// <param name="convert">Custom convertion function</param>
        /// <returns></returns>
        public static List <ResultParameter> ConvertToMonitorResults(IEnumerable <PerformanceData> data,
                                                                     Func <Double, String> convert)
        {
            var monitorData = new List <ResultParameter>();

            foreach (PerformanceData performanceData in data)
            {
                String monitisParameterName = UserSession.GetMonitisParameterName(performanceData.CounterName);

                ResultParameter parameter = ConvertToMonitorResult(performanceData.CounterValue,
                                                                   performanceData.Timestamp, convert,
                                                                   monitisParameterName);
                monitorData.Add(parameter);
            }
            return(monitorData);
        }
Ejemplo n.º 5
0
        public JsonResult GetAll(int page, int limit)
        {
            JsonResult json = new JsonResult
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet
            };

            List <User> users = new List <User>();

            for (int i = 0; i < 100; i++)
            {
                User user = new User()
                {
                    UserID     = 101 + i,
                    Username   = "******" + i.ToString(),
                    Sex        = "男",
                    City       = "城市-" + i.ToString(),
                    Sign       = "签名-" + i.ToString(),
                    Experience = 646,
                    Logins     = 107,
                    Wealth     = 974506 + i,
                    Classify   = "酱油",
                    Score      = 77 + i
                };

                users.Add(user);
            }

            IQueryable <User> res = (IQueryable <User>)null;

            page = page == 0 ? 1 : page;
            {
                res = users.OrderBy(x => x.UserID).Skip((page - 1) * limit).Take(limit).AsQueryable();
            }

            ResultParameter <User> resultParameter = new ResultParameter <User>()
            {
                code  = 0,
                msg   = "",
                count = users.Count(),
                data  = res
            };

            json.Data = resultParameter;
            return(json);
        }
Ejemplo n.º 6
0
        private void downloadBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            // does nothing if the search been canceled
            if (e.Cancelled || mHasDownloadBeenCancelled)
            {
                return;
            }

            // get the result object
            ResultParameter result = (e.Result) as ResultParameter;

            // update the overall percentage for this file
            updatePercentageOfTotalBar(result.fileIndex, 100);

            // check if there was an error to change the color
            if (result.hasErrorOccurs)
            {
                // get the item
                ListViewItem item = this.DownloadListView.Items[result.fileIndex];
                // change the color for this item to red
                item.ForeColor = Color.Red;
                // change the text
                item.SubItems[SUBITEM_PERCENTAGE_INDEX].Text = Properties.Resources.ErrorMsgTitleError;
            }
            else
            {
                // update the full percentage of for the file to 100% (but not if there was errors)
                updatePercentageOfOneFile(result.fileIndex, 100);

                // save the file in the list of successfull download
                mSuccessfullyDownloadedFiles.Add(mFilesToDownload[result.fileIndex]);
            }

            // then download the next file
            downloadOneFile(result.fileIndex + 1);
        }
Ejemplo n.º 7
0
 public IList <T_Result> QueryT_Result(ResultParameter resultParameter)
 {
     return(Mapper.QueryForList <T_Result>("QueryT_Result", resultParameter));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Adds an additional parameter to this TestStep run.
 /// </summary>
 /// <param name="param">Parameter to add.</param>
 public void AddParameter(ResultParameter param)
 {
     stepRun.Parameters.Add(param);
 }
Ejemplo n.º 9
0
        private void backgroundWorkerSearchOnline_DoWork(object sender, DoWorkEventArgs e)
        {
            const string partsFolder = @"/parts/";

            // Get the BackgroundWorker that raised this event.
            BackgroundWorker worker = sender as BackgroundWorker;
            // and get the parameters
            SearchParameter parameters = e.Argument as SearchParameter;
            ResultParameter result     = new ResultParameter();

            // declare a variable to report the progress on the search
            int currentUrlIndex = 0;

            // iterate on all the url in the search parameters
            foreach (string url in parameters.searchURLs)
            {
                // increase the current url and init the serach step
                currentUrlIndex++;
                int searchStep = 0;

                try
                {
                    // report the begining of the search
                    worker.ReportProgress(searchStep, new ProgressParameter(currentUrlIndex, parameters.searchURLs.Count));

                    // create a web request to browse the url
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
                    {
                        // report that we got an answer
                        worker.ReportProgress(++searchStep, new ProgressParameter(currentUrlIndex, parameters.searchURLs.Count));

                        using (StreamReader reader = new StreamReader(response.GetResponseStream()))
                        {
                            string html = reader.ReadToEnd();
                            // use a regexp to parse all the listed files from the html page
                            Regex           regex   = new Regex("<a href=\".+\\.zip\">(?<name>.+\\.zip)</a>");
                            MatchCollection matches = regex.Matches(html);
                            foreach (Match match in matches)
                            {
                                if (match.Success)
                                {
                                    // create an array to store the destination file name, and url source file name
                                    DownloadCenterForm.DownloadableFileInfo downloadInfo = new DownloadCenterForm.DownloadableFileInfo();
                                    // get the file name found
                                    string fileName = match.Groups["name"].Value;
                                    string fileNameWithoutExtension = fileName.Remove(fileName.Length - 4);
                                    // check if the file name contains a version number
                                    int dotIndex = fileNameWithoutExtension.IndexOf('.');
                                    if (dotIndex > 0)
                                    {
                                        downloadInfo.FileName = fileNameWithoutExtension.Remove(dotIndex) + ".zip";
                                        downloadInfo.Version  = fileNameWithoutExtension.Substring(dotIndex + 1);
                                    }
                                    else
                                    {
                                        downloadInfo.FileName = fileName;
                                        downloadInfo.Version  = string.Empty;
                                    }
                                    downloadInfo.SourceURL         = url + fileName;
                                    downloadInfo.DestinationFolder = partsFolder + fileName;
                                    // add the array in the result list
                                    result.allPackageListFound.Add(downloadInfo);
                                }
                            }

                            // report that we have finished to parse the html
                            worker.ReportProgress(++searchStep, new ProgressParameter(currentUrlIndex, parameters.searchURLs.Count));
                        }
                    }
                }
                catch
                {
                    // report that the error
                    worker.ReportProgress(3, new ProgressParameter(currentUrlIndex, parameters.searchURLs.Count));
                }
            }

            // set the result in the event of the background worker
            e.Result = result;
        }