示例#1
0
        //计算相关性
        private void btn_Calculate_Click(object sender, EventArgs e)
        {
            string imgPath       = this.txb_inputImg.Text;
            string shapefileName = this.cmb_QualityList.SelectedValue.ToString();

            List <string> waterFieldList = new List <string>();

            if (this.checkBox_COD.Checked)
            {
                waterFieldList.Add("CODmn");
            }
            if (checkBox_NH4N.Checked)
            {
                waterFieldList.Add("NH4_N");
            }
            if (checkBox_TN.Checked)
            {
                waterFieldList.Add("TN");
            }
            if (checkBox_TP.Checked)
            {
                waterFieldList.Add("TP");
            }
            //获取栅格数据集
            IRasterDataset pRasterDataset = GetDataClass.GetRasterDataset(imgPath);
            //获取矢量要素
            IFeatureClass pFeatureClass = GetDataClass.GetFeatureClassByName(shapefileName);
            //计算相关系数
            InversionClass pInversionClass = new InversionClass(this.richtxb_result);

            pInversionClass.CalculateRelativityInit(pFeatureClass, pRasterDataset, waterFieldList);
        }
    public static string LOAD_PURCHASE(string UserID, string BranchID, string VID)
    {
        List <GetDataClass> RegionList = new List <GetDataClass>();
        string         acc             = "";
        string         query           = "select * from VW_GET_PURCHASE_SALE_DATA where SPID='" + VID + "' and  BranchID='" + BranchID + "' and  BranchID1='" + BranchID + "' and  BranchID2='" + BranchID + "' and  BranchID3='" + BranchID + "' and  BranchID4='" + BranchID + "' and  BranchID5='" + BranchID + "' order by SrNo";
        SqlConnection  Con             = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
        SqlDataAdapter da = new SqlDataAdapter(query, Con);
        DataTable      dt = new DataTable();

        da.Fill(dt);
        RegionList.Clear();
        if (dt.Rows.Count > 0)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                GetDataClass dbdc = new GetDataClass();
                dbdc.SPDate            = dt.Rows[i]["SPDate"].ToString();
                dbdc.SPID              = dt.Rows[i]["SPID"].ToString();
                dbdc.AccountsID        = dt.Rows[i]["AccountsID"].ToString();
                dbdc.LocalBillNo       = dt.Rows[i]["LocalBillNo"].ToString();
                dbdc.CustomerAddress   = dt.Rows[i]["CustomerAddress"].ToString();
                dbdc.SrNo              = dt.Rows[i]["SrNo"].ToString();
                dbdc.ITEMName          = dt.Rows[i]["ITEMID"].ToString() + " ^ " + dt.Rows[i]["ITEMName"].ToString() + " ^ " + dt.Rows[i]["CatTitle"].ToString() + " ^ " + dt.Rows[i]["BrandTitle"].ToString();
                dbdc.QtyIn             = dt.Rows[i]["QtyIn"].ToString();
                dbdc.QtyOut            = dt.Rows[i]["QtyOut"].ToString();
                dbdc.QtyAvailed        = dt.Rows[i]["QtyAvailed"].ToString();
                dbdc.UnitPrice         = dt.Rows[i]["UnitPrice"].ToString();
                dbdc.RMBUnitPrice      = dt.Rows[i]["RMBUnitPrice"].ToString();
                dbdc.TotalPrice        = dt.Rows[i]["TotalPrice"].ToString();
                dbdc.RMBTotalPrice     = dt.Rows[i]["RMBTotalPrice"].ToString();
                dbdc.SalesDiscountPKR  = dt.Rows[i]["SalesDiscountPKR"].ToString();
                dbdc.SalesDiscountRMB  = dt.Rows[i]["SalesDiscountRMB"].ToString();
                dbdc.SupplierAmountPKR = dt.Rows[i]["SupplierAmountPKR"].ToString();
                dbdc.SupplierAmountRMB = dt.Rows[i]["SupplierAmountRMB"].ToString();
                dbdc.CusAmountPKR      = dt.Rows[i]["CusAmountPKR"].ToString();
                dbdc.CusAmountRMB      = dt.Rows[i]["CusAmountRMB"].ToString();
                dbdc.TotalAmount       = dt.Rows[i]["TotalAmount"].ToString();
                dbdc.RMBAmount         = dt.Rows[i]["RMBAmount"].ToString();
                dbdc.RMBValue          = dt.Rows[i]["RMBValue"].ToString();
                dbdc.BatchID           = dt.Rows[i]["BatchID"].ToString();
                dbdc.ID = dt.Rows[i]["ID"].ToString();
                RegionList.Insert(i, dbdc);
            }
        }

        JavaScriptSerializer jser = new JavaScriptSerializer();


        return(jser.Serialize(RegionList));
    }
        public void GivenAKeyWordWithLotsOfSpecialCharacters_WhenfetchSearchResultsandProcessIsRan_ThenItShouldStillReturnTheCorrectCountAndNoExceptionThrown()
        {
            //Arrange
            var testSearchWord   = "https://www.gov.uk";
            var testKeyWords     = "@+!£$%^     &* () ' '";
            var testSearchEngine = "www.google.com";

            var mockWebClientHelper = new Mock <IWebClientHelper>();

            mockWebClientHelper.Setup(m => m.returnWebClientResource(testSearchEngine + "/search?num=100&q=@+!£$%^+&*+()+'+'")).Returns(System.IO.File.ReadAllText("Test Data/TestData - 1 match.txt"));

            var testGetDataClass = new GetDataClass(mockWebClientHelper.Object);

            //Act
            var testCount = testGetDataClass.fetchSearchResultsandProcess(testSearchEngine, testKeyWords, testSearchWord);

            //Assert
            testCount.Should().Be("3");
        }
        public void GivenAValidUrl_WhenfetchSearchResultsandProcessIsRan_ThenItShouldReturnTheCorrectCount()
        {
            //Arrange
            var testSearchWord   = "https://www.gov.uk";
            var testSearchEngine = "www.gooogle.com";
            var testKeyWords     = "TestSearchWord";

            var mockWebClientHelper = new Mock <IWebClientHelper>();

            mockWebClientHelper.Setup(m => m.returnWebClientResource(It.IsAny <string>())).Returns(System.IO.File.ReadAllText("Test Data/TestData - 1 match.txt"));

            var testGetDataClass = new GetDataClass(mockWebClientHelper.Object);

            //Act
            var testCount = testGetDataClass.fetchSearchResultsandProcess(testSearchEngine, testKeyWords, testSearchWord);

            //Assert
            testCount.Should().Be("3");
        }
示例#5
0
    public void MethodB()
    {
        GetDataClass objData = new GetDataClass();

        objData.BindDataTotalSummary();
    }
示例#6
0
        //计算回归模型
        private void btn_Calculate_Click(object sender, EventArgs e)
        {
            //输入影像
            IRasterDataset pRasterDataset = GetDataClass.GetRasterDataset(this.txb_inputImg.Text);

            if (pRasterDataset == null)
            {
                MessageBox.Show("输入影像数据不能为空!");
                return;
            }
            //水质期数
            IFeatureClass pFeatureClass = GetDataClass.GetFeatureClassByName(this.cmb_QualityList.SelectedValue.ToString());

            if (pFeatureClass == null)
            {
                MessageBox.Show("选择矢量数据不能为空!");
                return;
            }
            //反演字段
            string        selectWaterField = _waterFieldsDictionary[GetSelectRadText(gb_waterFields)];
            List <string> fieldsList       = new List <string>()
            {
                selectWaterField
            };
            //获取水质数据和全部影像波段数据
            InversionClass inversionClass = new InversionClass(this.richtxb_info);

            double[][] imgDataArray = inversionClass.GetImgCellValue(pFeatureClass, pRasterDataset);
            Dictionary <string, double[]> waterDataDictionary = inversionClass.GetQualityByFields(pFeatureClass, fieldsList);

            //获取需要反演的水质参数
            double[] selectWaterData = waterDataDictionary[selectWaterField];
            //获取选择的波段组合数据
            double[][] selectBandsCombData = GetSelectBandData(imgDataArray);
            //获取选择的反演方法
            string regressionMethod = GetSelectRadText(gb_regressionMethod);


            if (regressionMethod == "一元线性")
            {
                AddInfoToRichTextBox("============开始反演============");
                AddInfoToRichTextBox("反演波段为:" + selectWaterField);
                AddInfoToRichTextBox("反演方法为一元线性,回归模型为Y=b+a*X");
                int bandCombCount = selectBandsCombData.Length;
                for (int i = 0; i < bandCombCount; i++)
                {
                    double[] resultDoubles = RegressionClass.SimpleLinearRegression(selectBandsCombData[i],
                                                                                    selectWaterData);
                    AddInfoToRichTextBox(string.Format("{0}:自变量为{1}", i + 1, _bandCombList[i]));
                    AddInfoToRichTextBox(string.Format("{0,7}{1,7}{2,7}{3,7}{4,7}{5,7}{6,7}{7,7}", "回归系数b", "回归系数a",
                                                       "偏差平方和", "平均标准偏差", "回归平方和", "最大偏差", "最小偏差", "偏差平均值"));
                    AddInfoToRichTextBox(string.Format("{0,10}{1,10}{2,11}{3,11}{4,12}{5,13}{6,12}{7,12}",
                                                       resultDoubles[0].ToString("0.###"), resultDoubles[1].ToString("0.###"),
                                                       resultDoubles[2].ToString("0.###"), resultDoubles[3].ToString("0.###"),
                                                       resultDoubles[4].ToString("0.###"), resultDoubles[5].ToString("0.###"),
                                                       resultDoubles[6].ToString("0.###"), resultDoubles[7].ToString("0.###")));
                }
                AddInfoToRichTextBox("============反演结束============\n");
            }
            else if (regressionMethod == "多元线性")
            {
                AddInfoToRichTextBox("============开始反演============");
                //获取反演结果
                List <double[]> resultList = RegressionClass.MultiLinearRegression(selectBandsCombData, selectWaterData);
                //输出
                AddInfoToRichTextBox("反演波段为:" + selectWaterField);
                AddInfoToRichTextBox("反演方法为多元线性,回归模型为:");
                StringBuilder strBuilder1 = new StringBuilder();
                strBuilder1.Append("Y=");
                int bandComCount = _bandCombList.Count;
                for (int i = 0; i < bandComCount; i++)
                {
                    strBuilder1.AppendFormat("a{0}*{1}+", i, _bandCombList[i]);
                }
                strBuilder1.AppendFormat("a{0}", bandComCount);
                AddInfoToRichTextBox(strBuilder1.ToString());
                //模型参数
                double[] a = resultList[0];
                AddInfoToRichTextBox(string.Format("模型参数a0到a{0}分别为:", bandComCount));
                StringBuilder strbBuilder = new StringBuilder();
                int           alength     = a.Length;
                for (int i = 0; i < alength; i++)
                {
                    strbBuilder.Append(a[i].ToString("0.###") + "   ");
                }
                AddInfoToRichTextBox(strbBuilder.ToString());
                //模型偏差
                AddInfoToRichTextBox("\n模型偏差:");
                double[] dt = resultList[1];
                AddInfoToRichTextBox(string.Format("{0,7}{1,7}{2,7}{3,7}", "偏差平方和", "平均标准偏差", "相关系数", "回归平方和"));
                AddInfoToRichTextBox(string.Format("{0,10}{1,10}{2,14}{3,12}", dt[0].ToString("0.###"),
                                                   dt[1].ToString("0.###"), dt[2].ToString("0.###"), dt[3].ToString("0.###")));
                AddInfoToRichTextBox("============反演结束============");
            }
        }
示例#7
0
    public static string LOAD_PURCHASE(string UserID, string BranchID, string VID)
    {
        List <GetDataClass> RegionList = new List <GetDataClass>();
        string         acc             = "";
        string         query           = "select * from VW_GET_PURCHASE_SALE_DATA where SPID='" + VID + "' and  BranchID='" + BranchID + "' and  BranchID1='" + BranchID + "' and  BranchID2='" + BranchID + "' and  BranchID3='" + BranchID + "' and  BranchID4='" + BranchID + "' and  BranchID5='" + BranchID + "' order by SrNo";
        SqlConnection  Con             = new SqlConnection(ConfigurationManager.ConnectionStrings["Con"].ConnectionString);
        SqlDataAdapter da = new SqlDataAdapter(query, Con);
        DataTable      dt = new DataTable();

        da.Fill(dt);
        RegionList.Clear();
        if (dt.Rows.Count > 0)
        {
            string ITEMDetail = "";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                GetDataClass dbdc = new GetDataClass();
                dbdc.SPDate          = dt.Rows[i]["SPDate"].ToString();
                dbdc.SPID            = dt.Rows[i]["SPID"].ToString();
                dbdc.AccountsID      = dt.Rows[i]["AccountsID"].ToString();
                dbdc.LocalBillNo     = dt.Rows[i]["LocalBillNo"].ToString();
                dbdc.CustomerAddress = dt.Rows[i]["CustomerAddress"].ToString();
                dbdc.SrNo            = dt.Rows[i]["SrNo"].ToString();
                ITEMDetail           = dt.Rows[i]["ITEMName"].ToString() + " " + dt.Rows[i]["CatTitle"].ToString() + " " + dt.Rows[i]["BrandTitle"].ToString();
                SqlDataAdapter dda = new SqlDataAdapter("select * from SP_DETAIL where ID='" + dt.Rows[i]["BatchID"].ToString() + "'", Con);
                DataTable      dtt = new DataTable();
                dda.Fill(dtt);
                if (dtt.Rows.Count > 0)
                {
                    decimal bl = Convert.ToDecimal(dtt.Rows[0]["QtyIn"].ToString()) - Convert.ToDecimal(dtt.Rows[0]["QtyAvailed"].ToString());
                    ITEMDetail      = ITEMDetail + " ^ Price : " + dtt.Rows[0]["UnitPrice"].ToString() + " ^ QTY : " + bl + " ^ " + dtt.Rows[0]["ITEMID"].ToString() + " ^ Purchase # : " + dtt.Rows[0]["SPID"].ToString() + " ^ ID : " + dtt.Rows[0]["ID"].ToString();
                    dbdc.QtyAvailed = dtt.Rows[0]["QtyAvailed"].ToString();
                    dbdc.QtyIn      = dtt.Rows[0]["QtyIn"].ToString();
                }
                dbdc.ITEMName = ITEMDetail;
                //dbdc.QtyIn = dt.Rows[i]["QtyIn"].ToString();
                dbdc.QtyOut = dt.Rows[i]["QtyOut"].ToString();
                // dbdc.QtyAvailed = dt.Rows[i]["QtyAvailed"].ToString();
                dbdc.UnitPrice         = dt.Rows[i]["UnitPrice"].ToString();
                dbdc.RMBUnitPrice      = dt.Rows[i]["RMBUnitPrice"].ToString();
                dbdc.TotalPrice        = dt.Rows[i]["TotalPrice"].ToString();
                dbdc.RMBTotalPrice     = dt.Rows[i]["RMBTotalPrice"].ToString();
                dbdc.SalesDiscountPKR  = dt.Rows[i]["SalesDiscountPKR"].ToString();
                dbdc.SalesDiscountRMB  = dt.Rows[i]["SalesDiscountRMB"].ToString();
                dbdc.SupplierAmountPKR = dt.Rows[i]["SupplierAmountPKR"].ToString();
                dbdc.SupplierAmountRMB = dt.Rows[i]["SupplierAmountRMB"].ToString();
                dbdc.CusAmountPKR      = dt.Rows[i]["CusAmountPKR"].ToString();
                dbdc.CusAmountRMB      = dt.Rows[i]["CusAmountRMB"].ToString();
                dbdc.TotalAmount       = dt.Rows[i]["TotalAmount"].ToString();
                dbdc.RMBAmount         = dt.Rows[i]["RMBAmount"].ToString();
                dbdc.RMBValue          = dt.Rows[i]["RMBValue"].ToString();
                dbdc.BatchID           = dt.Rows[i]["BatchID"].ToString();
                dbdc.ID                = dt.Rows[i]["ID"].ToString();
                dbdc.CustomerName      = dt.Rows[i]["CustomerName"].ToString();
                dbdc.CustomerContactNo = dt.Rows[i]["CustomerContactNo"].ToString();

                dbdc.TaxAmount   = dt.Rows[i]["TaxAmount"].ToString();
                dbdc.TaxRate     = dt.Rows[i]["TaxRate"].ToString();
                dbdc.GrandTotal  = dt.Rows[i]["GrandTotal"].ToString();
                dbdc.CashBack    = dt.Rows[i]["CashBack"].ToString();
                dbdc.CashRcvd    = dt.Rows[i]["CashRcvd"].ToString();
                dbdc.Description = dt.Rows[i]["Description"].ToString();
                SqlDataAdapter daPayment = new SqlDataAdapter("select Top(1) * from Transaction_Detail where TaskID='C-" + VID + "'", Con);
                DataTable      dtPayment = new DataTable();
                daPayment.Fill(dtPayment);
                if (dtPayment.Rows.Count > 0)
                {
                    dbdc.DebitPKR  = dtPayment.Rows[0]["DebitPKR"].ToString();
                    dbdc.AccountID = dtPayment.Rows[0]["AccountID"].ToString();
                }

                RegionList.Insert(i, dbdc);
            }
        }

        JavaScriptSerializer jser = new JavaScriptSerializer();


        return(jser.Serialize(RegionList));
    }
示例#8
0
        //插值
        private void btn_interpolation_Click(object sender, EventArgs e)
        {
            this.label_fun.Text = "";
            //获取加密点矢量
            IWorkspaceFactory pWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
            IWorkspace        pWorkspace        = pWorkspaceFactory.OpenFromFile(@"D:\RasterMaSysTemp\hhData", 0);
            IFeatureWorkspace pFeatureWorkspace = pWorkspace as IFeatureWorkspace;
            IFeatureClass     pFeatureClass     = pFeatureWorkspace.OpenFeatureClass("加密点.shp");
            //获取栅格波段
            IRasterDataset pRasterDataset = GetDataClass.GetRasterDataset(this.txb_inputImg.Text);
            InversionClass inversionClass = new InversionClass(new RichTextBox());

            double[][] imgAllBands = inversionClass.GetImgCellValue(pFeatureClass, pRasterDataset);

            //所有波段组合的值
            Dictionary <string, double[]> imgBandscomb = calculateBandscomb(imgAllBands);

            string selectMethod     = this.GetSelectRadText(gb_regressionMethod);
            string selectFieldRad   = this.GetSelectRadText(gb_waterFields);
            string selectWaterField = _waterFieldsDictionary[selectFieldRad];

            _labelFun = string.Format("回归拟合方程为:{0}=", selectWaterField);
            //获取结果值
            if (selectMethod == "二次模型" || selectMethod == "指数模型")
            {
                MessageBox.Show("请选择其他拟合算法");
                return;
            }
            List <double> resultList = this.GetResultValue(imgBandscomb, selectMethod, imgAllBands[0].Length);

            //显示拟合函数
            this.label_fun.Text += _labelFun;

            //更新加密点属性
            if (resultList.Count == 0)
            {
                MessageBox.Show("获取数据失败");
                return;
            }
            this.UpdatePointValue(pFeatureClass, selectWaterField, resultList);

            //插值
            if (this.txb_output.Text.Trim() != "")
            {
                GpToolsClass gpTools = new GpToolsClass();
                gpTools.CalKriging(selectWaterField, this.txb_output.Text);
            }
            //如果生成插值图成功,则添加显示
            if (File.Exists(this.txb_output.Text))
            {
                if (File.Exists(@"D:\RasterMaSysTemp\hhData\水质插值专题图.mxd"))
                {
                    MapDocument mapDoc = new MapDocumentClass();
                    mapDoc.Open(@"D:\RasterMaSysTemp\hhData\水质插值专题图.mxd", "");
                    axPageLayoutControl1.PageLayout = mapDoc.PageLayout;

                    IMap         pMap         = mapDoc.get_Map(0);
                    IRasterLayer pRasterLayer = pMap.Layer[0] as IRasterLayer;
                    pRasterLayer.CreateFromFilePath(this.txb_output.Text);
                    axPageLayoutControl1.PageLayout.ZoomToWhole();
                    IPage page = axPageLayoutControl1.Page;
                    axPageLayoutControl1.Refresh();
                }
                else
                {
                    IMap         pMap         = this.axPageLayoutControl1.ActiveView.FocusMap;
                    IRasterLayer pRasterLayer = new RasterLayerClass();
                    pRasterLayer.CreateFromFilePath(this.txb_output.Text);
                    pMap.AddLayer(pRasterLayer);
                }
            }
            else
            {
                MessageBox.Show("处理失败!");
            }
        }