Ejemplo n.º 1
0
        /// <summary>
        /// Helper method to get the single rule view model.
        /// </summary>
        /// <param name="id">Quality check id.</param>
        /// <returns>Quality check rule view model.</returns>
        private QCRuleViewModel GetQCRuleViewModel(int id)
        {
            QCRuleViewModel ruleModel = new QCRuleViewModel();
            // create the object of HttpWeb Request Manager
            webRequestManager = new HttpWebRequestManager();
            // set the request details to get repostiry list
            webRequestManager.SetRequestDetails(new RequestParams()
            {
                RequestURL = string.Concat(BaseController.BaseWebApiFilePath, "?type=QCCOLUMNTYPES"),
            });
            string columnTypeJson = webRequestManager.RetrieveWebResponse();

            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
            jsSerializer.MaxJsonLength = int.MaxValue;
            var lstQCColumnTypes = jsSerializer.Deserialize<IEnumerable<QualityCheckColumnType>>(columnTypeJson);

            if (id > 0)
            {
                // set the request details to get file list
                webRequestManager.SetRequestDetails(new RequestParams()
                {
                    RequestURL = string.Concat(BaseController.BaseWebApiQCPath + id),
                });

                string qcRuleList = webRequestManager.RetrieveWebResponse();
                var qualityCheckData = jsSerializer.Deserialize<QualityCheckModel>(qcRuleList);
                ruleModel.SetValuesFrom(qualityCheckData, lstQCColumnTypes);
            }
            else
            {
                QCHeaderViewModel headerModel = new QCHeaderViewModel();
                headerModel.QCColumnTypes = new SelectList(lstQCColumnTypes, "QualityCheckColumnTypeId", "Name");
                headerModel.Order = 1;
                ruleModel.LstHeaderNames.Add(headerModel);
            }

            return ruleModel;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Method to get the quality check view model.
        /// </summary>
        /// <returns></returns>
        private QualityCheckViewModel GetQualityCheckViewModel()
        {
            QualityCheckViewModel viewModel = new QualityCheckViewModel();

            // create the object of HttpWeb Request Manager
            webRequestManager = new HttpWebRequestManager();

            // set the request details to get file list
            webRequestManager.SetRequestDetails(new RequestParams()
            {
                RequestURL = string.Concat(BaseController.BaseWebApiQCPath),
            });

            string qcRulesList = webRequestManager.RetrieveWebResponse();

            // set the request details to get repostiry list
            webRequestManager.SetRequestDetails(new RequestParams()
            {
                RequestURL = string.Concat(BaseController.BaseWebApiFilePath, "?type=QCCOLUMNTYPES"),
            });

            string columnTypeJson = webRequestManager.RetrieveWebResponse();


            JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
            jsSerializer.MaxJsonLength = int.MaxValue;

            var lstQCRules = jsSerializer.Deserialize<IList<QualityCheckModel>>(qcRulesList);
            lstQCRules = lstQCRules.OrderByDescending(rul => rul.QualityCheckData.CreatedOn).ToList();
            var lstQCColumnTypes = jsSerializer.Deserialize<IEnumerable<QualityCheckColumnType>>(columnTypeJson);

            foreach (var qcObj in lstQCRules)
            {
                QCRuleViewModel rule = new QCRuleViewModel();
                rule.SetValuesFrom(qcObj, lstQCColumnTypes);
                viewModel.QualityCheckRules.Add(rule);
            }

            return viewModel;
        }