private void button13_Click(object sender, EventArgs e) { listBox1.Items.Clear(); //获取唯一值 // 属性过滤器 IQueryFilter pQueryFilter = new QueryFilter(); pQueryFilter.AddField(this.cboField.SelectedItem.ToString()); // 要素游标 IFeatureCursor pFeatureCursor = mFeatureLayer.Search(pQueryFilter, true); ICursor pCursor = pFeatureCursor as ICursor; // 设置统计信息 IDataStatistics pDataStatistics = new DataStatistics(); pDataStatistics.Field = this.cboField.SelectedItem.ToString(); pDataStatistics.Cursor = pCursor; // 获取唯一值 IEnumerator uniqueValues = pDataStatistics.UniqueValues; uniqueValues.Reset(); // 遍历唯一值 while (uniqueValues.MoveNext()) { listBox1.Items.Add(uniqueValues.Current.ToString()); } }
//通过实时监测的数据获取各个应急处置空间位置的信息 private void checkBox2_CheckedChanged(object sender, EventArgs e) { try { if (checkBox2.Checked == true) { groupBox3.Enabled = true; button9.Enabled = true; //将应急处置点序号添加进去 string currentFieldName = "FID"; IFeatureLayer pFeatureLayerEmergencypoint = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text); IFeatureClass pFeatureClassEmergencypoint = pFeatureLayerEmergencypoint.FeatureClass; IFeatureCursor pFeatureCursorEmergencypoint = pFeatureClassEmergencypoint.Search(null, false); IDataStatistics pDataStatisticsEmergencypoint = new DataStatistics(); pDataStatisticsEmergencypoint.Field = currentFieldName; pDataStatisticsEmergencypoint.Cursor = pFeatureCursorEmergencypoint as ICursor; System.Collections.IEnumerator pEnumerator = pDataStatisticsEmergencypoint.UniqueValues; while (pEnumerator.MoveNext()) { comboBox7.Items.Add(Convert.ToInt32(pEnumerator.Current.ToString()) + 1); } comboBox7.SelectedIndex = 0; } else { groupBox3.Enabled = false; button9.Enabled = false; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常"); } }
// Tar fram statistik om utvalda features. public void showStatistics(IFeatureSelection fSelect, string fieldName) { if (fSelect.SelectionSet.Count != 0) { string roadCount = "Antal vägar: " + fSelect.SelectionSet.Count.ToString() + "\r"; IFeatureLayer fLayer = (IFeatureLayer)fSelect; IDataStatistics dataStat = new DataStatistics(); dataStat.Field = fieldName; dataStat.Cursor = (ICursor)fLayer.Search(null, false); IEnumerator enumVar = dataStat.UniqueValues; if (enumVar == null) { MessageBox.Show("Kolumn tom."); } else { enumVar.Reset(); string tempString = fieldName + ": \r"; while (enumVar.MoveNext() != false) { object value = enumVar.Current; tempString += value.ToString() + "\r"; } MessageBox.Show(roadCount + tempString, "Närmaste vägar"); } } else { MessageBox.Show("Inga objekt är utvalda."); } }
public void StoreDataStatistic(DataStatistics data) { using (var repo = Repo <DataStatisticsRepository>()) { repo.AddOrUpdateDoCommit(data); } }
private DataStatistics() //如果在测完数据不手动设置instance == null,则会出现数据堆积。因为这是个单例模式 { instance = this; if (MainEditor.labelTitle.Equals(MainEditor.ANDRIOD_PLATFORM)) { standardPlatformData = new AndriodStandardData(); } else if (MainEditor.labelTitle.Equals(MainEditor.PC_PLATFORM)) { standardPlatformData = new PCStandardData(); } profilerProperty = new ProfilerProperty(); monoProperty = new Property("MonoMemory"); textureProperty = new Property("TextureMemory"); animationProperty = new Property("AnimationMemory"); audioProperty = new Property("AudioMemory"); meshProperty = new Property("MeshMemory"); gameobjectProperty = new Property("GameObjects"); drawCallProperty = new Property("DrawCalls"); trisProperty = new Property("Tris"); fpsProperty = new RateProperty("FPS", standardPlatformData.FPS); renderingTimeProperty = new Property("CpuRenderingTime"); animationTimeProperty = new Property("CpuAnimationTime"); uiTimeProperty = new Property("CpuUiTime"); scriptsTimeProperty = new Property("CpuScriptsTime"); }
//统计最低温 private cityTeme getMinTemp() { cityTeme CT2 = new cityTeme("低温城市", 0.0); IFeatureLayer featLayer = (IFeatureLayer)Utilities.GetLayerByName("省市", axMapControl1.Map); IFeatureClass featClass = featLayer.FeatureClass; IDataStatistics maxTemp = new DataStatistics(); IDataStatistics minTemp = new DataStatistics(); IFeatureCursor featCursor; IQueryFilter queryfilter = new QueryFilterClass(); featCursor = featClass.Search(null, false); ICursor cursor = (ICursor)featCursor; minTemp.Cursor = cursor; minTemp.Field = "LowTemperature"; IStatisticsResults MINtemp; MINtemp = minTemp.Statistics; CT2.Teme = MINtemp.Minimum; String minWhereClause = "[LowTemperature] = " + CT2.Teme; queryfilter.WhereClause = minWhereClause; featCursor = featClass.Search(queryfilter, false); IFeature MINpFeature = featCursor.NextFeature(); if (MINpFeature != null) { int index2 = featClass.FindField("NAME"); CT2.City = MINpFeature.get_Value(index2).ToString(); } return(CT2); }
//获取应急处置空间位置的FID private void button5_Click(object sender, EventArgs e) { try { if (comboBox1.Text == "") { MessageBox.Show("请输入应急处置空间备选数据", "输入应急处置空间备选数据", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } else { label2.Enabled = true; comboBox2.Enabled = true; string currentFieldName = "FID"; pFeatureLayerEmergency = CDataImport.ImportFeatureLayerFromControltext(comboBox1.Text); IFeatureClass pFeatureClassEmergency = pFeatureLayerEmergency.FeatureClass; IFeatureCursor pFeatureCursorEmergency = pFeatureClassEmergency.Search(null, false); IDataStatistics pDataStatistics = new DataStatistics(); pDataStatistics.Field = currentFieldName; pDataStatistics.Cursor = pFeatureCursorEmergency as ICursor; System.Collections.IEnumerator pEnumerator = pDataStatistics.UniqueValues; while (pEnumerator.MoveNext()) { comboBox2.Items.Add(Convert.ToInt32(pEnumerator.Current.ToString()) + 1); } comboBox2.SelectedIndex = 0; } } catch (Exception ex) { MessageBox.Show(ex.Message + "\n" + ex.ToString(), "异常"); } }
private void cbFieldNameList_SelectedIndexChanged(object sender, EventArgs e) { IFeatureClass featureClass = m_FeatureLayer.FeatureClass; IDataStatistics dataStatistics = new DataStatistics(); //get cursor ICursor cursor; if (m_WithSelectionSet) { m_SelectionSet.Search(null, true, out cursor); } else { IFeatureCursor featureCursor = featureClass.Search(null, false); cursor = (ICursor)featureCursor; } dataStatistics.Cursor = cursor; //input field int index = featureClass.Fields.FindField(cbFieldNameList.SelectedItem.ToString()); dataStatistics.Field = featureClass.Fields.get_Field(index).Name; //get results IStatisticsResults statisticsResults; statisticsResults = dataStatistics.Statistics; lbMax.Text = statisticsResults.Maximum.ToString(); lbMin.Text = statisticsResults.Minimum.ToString(); lbAvg.Text = statisticsResults.Mean.ToString(); }
public string Statistic(string layerName, string fieldName, IMap iMap) { DataOperator dataOperator = new DataOperator(iMap); IFeatureLayer featLayer = (IFeatureLayer)dataOperator.GetLayerByName(layerName); IFeatureClass featClass = featLayer.FeatureClass; IDataStatistics dataStatistics = new DataStatistics(); IFeatureCursor featCursor; featCursor = featClass.Search(null, false); ICursor cursor = (ICursor)featCursor; dataStatistics.Cursor = cursor; dataStatistics.Field = fieldName; IStatisticsResults statResult; statResult = dataStatistics.Statistics; // double dMax; // double dMin; // double dMean; string sResult = "最大面积为:" + statResult.Maximum.ToString() + "\n最小面积为:" + statResult.Minimum.ToString() + "\n平均面积为:" + statResult.Mean.ToString(); return(sResult); }
public void Run() { Console.WriteLine("Downloading news for database..."); List <News> news = DataStore.Instance.GetAllNews(300); Console.WriteLine("News downloaded " + news.Count); news = Words.ComputeWords(news); /* * CosinusMetricComparator cos = new CosinusMetricComparator(); * EuclidesMetricComparator eu = new EuclidesMetricComparator(); * JaccardMetricCompartator ja = new JaccardMetricCompartator(); */ var stats = new WordsStats(news); stats.Compute(); DataStatistics ds = new DataStatistics(); Console.WriteLine("Jaccard metric information: "); Console.WriteLine(ds.getData(news, stats, 5000, new JaccardMetricCompartator())); Console.WriteLine("Cosinus metric information: "); Console.WriteLine(ds.getData(news, stats, 5000, new CosinusMetricComparator())); Console.WriteLine("Euclides metric information: "); Console.WriteLine(ds.getData(news, stats, 5000, new EuclidesMetricComparator())); }
/// <summary> /// 从shape文件中获取唯一值 /// </summary> /// <param name="Table"></param> /// <param name="FieldNames"></param> public static IList <string> GimmeUniqueValuesFromShape(ITable Table, IList <string> FieldNames) { IQueryFilter pQueryFilter = new QueryFilter(); IDataStatistics pData = new DataStatistics(); IList <string> alUniqueVal = new List <string>(); try { for (int i = 0; i <= FieldNames.Count - 1; i++) { pData.Field = FieldNames[i].ToString(); pQueryFilter.SubFields = FieldNames[i].ToString(); ICursor pCursor = Table.Search(pQueryFilter, false); pData.Cursor = pCursor; IEnumerator objEnum = pData.UniqueValues; objEnum.MoveNext(); while (!(objEnum.Current == null)) { alUniqueVal.Add(objEnum.Current.ToString()); objEnum.MoveNext(); } } return(alUniqueVal); } catch (Exception ex) { MessageBox.Show(ex.Message + " " + ex.Source + " " + ex.StackTrace); return(alUniqueVal); } }
public string Statistic(string layerName, string fieldName, IMap imap) { DataOperator pDo = new DataOperator(imap, null); IFeatureLayer pFl = (IFeatureLayer)pDo.GetLayerbyName(layerName); IFeatureClass pFcl = pFl.FeatureClass; IDataStatistics pDst = new DataStatistics(); IFeatureCursor pFc; pFc = pFcl.Search(null, false); ICursor pCs = (ICursor)pFc; pDst.Cursor = pCs; pDst.Field = fieldName; IStatisticsResults StartReasult; StartReasult = pDst.Statistics; double dMax, dMin, dMean; dMax = StartReasult.Maximum; dMin = StartReasult.Minimum; dMean = StartReasult.Mean; string sReasult; sReasult = "最大面积为" + dMax.ToString() + ";最小面积为" + dMin.ToString() + ";平均面积为" + dMean.ToString(); return(sReasult); }
public bool GetUniqueValues(ITable pTable, string sFieldName, IList Items) { bool flag; try { ICursor cursor = pTable.Search(null, false); IDataStatistics dataStatisticsClass = new DataStatistics() { Field = sFieldName, Cursor = cursor }; IEnumerator uniqueValues = dataStatisticsClass.UniqueValues; uniqueValues.Reset(); while (uniqueValues.MoveNext()) { Items.Add(uniqueValues.Current); } Marshal.ReleaseComObject(dataStatisticsClass); dataStatisticsClass = null; Marshal.ReleaseComObject(cursor); cursor = null; flag = true; return(flag); } catch (Exception exception) { } flag = false; return(flag); }
public PerformanceStatistics(PerformanceMonitorConfiguration configuration) { _configuration = configuration; ControllerActionStatistics = new ActionStatistics(); RequestStatistics = new DataStatistics(); ResponseStatisticsPreAction = new DataStatistics(); ResponseStatisticsPostAction = new DataStatistics(); ConversionStatistics = new DataStatistics(); DatabaseFlushStatistics = new DataStatistics(); }
private int GetUniqueValuesCount(IFeatureClass featureClass, string strField) { ICursor cursor = featureClass.Search(null, false) as ICursor; IDataStatistics dataStatistics = new DataStatistics(); dataStatistics.Field = strField; dataStatistics.Cursor = cursor; System.Collections.IEnumerator enumerator = dataStatistics.UniqueValues; return(dataStatistics.UniqueValueCount); }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { string fieldName = comboBox1.SelectedItem.ToString(); string selectLayerName = comboBox2.SelectedItem.ToString(); IEnumLayer pEnumlayer = PMap.Layers; //获取地图中的图层集合 pEnumlayer.Reset(); // ILayer pLayer = pEnumlayer.Next(); //获得第一个图层 while (pLayer != null) // { string name = pLayer.Name; //获得图层名称 if (selectLayerName == name) //在图层集合中找到相应名称的图层 { IFeatureLayer featureLayer = pLayer as IFeatureLayer; if (fieldName != null) { IFields pFields = featureLayer.FeatureClass.Fields; //获得特征类的字段集合 for (int i = 0; i < pFields.FieldCount; i++) // 循环 { IField pField = pFields.get_Field(i); //获得第i个字段 if (pField.Name == fieldName) { IQueryFilter queryFilter = new QueryFilterClass(); // 创建查询过滤条件对象 queryFilter.SubFields = fieldName; // 设置返回的字段名称 IFeatureCursor pFeatureCursor = featureLayer.FeatureClass.Search(queryFilter, true); //得到IFeatureCursor游标 ICursor pCursor = pFeatureCursor as ICursor; //接口查询返回ICursor游标 IDataStatistics pDataStatistics = new DataStatistics(); //创建DataStatistics对象,该对象用于进行字段值的统计 pDataStatistics.Cursor = pCursor; //给DataStatistics对象的游标属性赋值 pDataStatistics.Field = fieldName; //给DataStatistics对象的字段属性赋值 IStatisticsResults pStatisticsResult = pDataStatistics.Statistics; //获得统计结果 label2.Text = pStatisticsResult.Maximum.ToString(); //最大值 label3.Text = pStatisticsResult.Minimum.ToString(); //最小值 label4.Text = pStatisticsResult.Mean.ToString(); //平均值 label5.Text = pStatisticsResult.StandardDeviation.ToString(); //标准差 label6.Text = pStatisticsResult.Count.ToString(); //个数 label7.Text = pStatisticsResult.Sum.ToString(); //总和 return; } } } return; } pLayer = pEnumlayer.Next(); //获得下一个图层 } }
private System.Collections.IEnumerator GetUniqueValues( IFeatureClass featureClass, string strField) { ICursor cursor = (ICursor)featureClass.Search(null, false); IDataStatistics dataStatistics = new DataStatistics(); dataStatistics.Field = strField; dataStatistics.Cursor = cursor; System.Collections.IEnumerator enumerator = dataStatistics.UniqueValues; return(enumerator); }
private void InitializeMisc(BatchingNeoStores neoStores, DataStatistics distribution) { PrintStageHeader("(4/4) Post processing", ESTIMATED_REQUIRED_MEMORY_USAGE, bytes(BaselineMemoryRequirement(neoStores))); long actualNodeCount = distribution.NodeCount; // The reason the highId of the relationship store is used, as opposed to actual number of imported relationships // is that the stages underneath operate on id ranges, not knowing which records are actually in use. long relationshipRecordIdCount = neoStores.RelationshipStore.HighId; long groupCount = neoStores.TemporaryRelationshipGroupStore.HighId; InitializeProgress(groupCount + groupCount + groupCount + actualNodeCount + relationshipRecordIdCount, ImportStage.PostProcessing); }
private void Push(string address, int value) { Task.Run(() => { DataStatistics dataStatistics = new DataStatistics(windowSize); packetStatisticses.TryAdd(address, dataStatistics); packetStatisticses[address].Push(value); }); }
public int GetLinkCount(IPoint point, IFeatureClass featureClass) { ISpatialFilter spatialFilter = new SpatialFilterClass(); spatialFilter.Geometry = point; spatialFilter.GeometryField = featureClass.ShapeFieldName; spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; IFeatureCursor featureCursor = featureClass.Search(spatialFilter, false); IDataStatistics dataStatistics = new DataStatistics() { Field = featureClass.OIDFieldName, Cursor = featureCursor as ICursor }; int count = dataStatistics.Statistics.Count; Marshal.ReleaseComObject(featureCursor); return(count); }
private void comboBox2_SelectedIndexChanged(object sender, EventArgs e) { IDataStatistics pDs = new DataStatistics(); pDs.Field = comboBox2.SelectedItem.ToString(); IFeatureSelection featureSelection = currentFeatureLayer as IFeatureSelection; ICursor pCursor = null; featureSelection.SelectionSet.Search(null, false, out pCursor); pDs.Cursor = pCursor; IStatisticsResults pSR = pDs.Statistics; count.Text = pSR.Count.ToString(); min.Text = pSR.Minimum.ToString(); max.Text = pSR.Maximum.ToString(); mean.Text = pSR.Mean.ToString(); std.Text = pSR.StandardDeviation.ToString(); sum.Text = pSR.Sum.ToString(); }
/// <summary> /// 获取ITable记录的某一字段唯一值 /// </summary> /// <param name="table"></param> /// <param name="fieldName"></param> /// <param name="whereClause"></param> /// <returns></returns> public static List <string> getUniqeValues(ITable table, string fieldName, string whereClause) { IQueryFilter qf = new QueryFilter(); qf.WhereClause = whereClause; ICursor cur = table.Search(qf, false); DataStatistics dataStatistics = new DataStatistics(); dataStatistics.Field = fieldName; dataStatistics.Cursor = cur; IEnumerator uniqueValues = dataStatistics.UniqueValues; List <string> list = new List <string>(); while (uniqueValues.MoveNext()) { list.Add((string)uniqueValues.Current); } Marshal.ReleaseComObject(cur); return(list); }
private void BuildDataStatisticsContentXmlFile(string fileName, DataStatistics dataStatistifs, int index) { BuildContentTypeRoot(fileName, "DataStatistics", index, out string identifier); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "DataStatistics.PublishDate", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/DataStatistics.PublishDate", index), "Value", dataStatistifs.DeclareDate); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "DataStatistics.YearAndMonthLabel", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/DataStatistics.YearAndMonthLabel", index), "Value", dataStatistifs.YearAndMonthLabel); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "EnumerationField.Classification", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/EnumerationField.Classification", index), "Value", dataStatistifs.Classification); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "EnumerationField.ChineseEconomyStatisticsCategory", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/EnumerationField.ChineseEconomyStatisticsCategory", index), "Value", dataStatistifs.ChineseEconomyStatisticsCategory); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "EnumerationField.ForeignInvestmentStatisticsCategory", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/EnumerationField.ForeignInvestmentStatisticsCategory", index), "Value", dataStatistifs.ForeignInvestmentStatisticsCategory); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "EnumerationField.OverseasInvestmentStatisticsCategory", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/EnumerationField.OverseasInvestmentStatisticsCategory", index), "Value", dataStatistifs.OverseasInvestmentStatisticsCategory); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "TextField.Source", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/TextField.Source", index), "Text", dataStatistifs.Source); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "TextField.SubTitle", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/TextField.SubTitle", index), "Text", dataStatistifs.SubTitle); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "BodyPart", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/BodyPart", index), "Text", dataStatistifs.Body); BuildCommonPart(fileName, index, dataStatistifs.PublishDate, identifier, "DataStatistics"); BuildPositionAndCulture(fileName, index); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "TagsPart", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/TagsPart", index), "Tags", dataStatistifs.Tag); XMLHelper.CreateOrUpdateXmlNodeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]", index), "TitlePart", ""); XMLHelper.CreateOrUpdateXmlAttributeByXPath(fileName, string.Format("/Orchard/Content/DataStatistics[{0}]/TitlePart", index), "Title", dataStatistifs.Title); }
private WsdProject( WsdProjectInfo projectInfo, WordDictionary dictionary, TextData[] trainData, TextData[] testData, EmbeddingDictionary wordEmbeddings, EmbeddingDictionary meaningEmbeddings, WordAnalysisDictionary dataAnalysis, DictionaryStatistics dictionaryStatistics, DataStatistics dataStatistics, EmbeddingStatistics wordEmbeddingStatistics, EmbeddingStatistics meaningEmbeddingStatistics) { ProjectInfo = projectInfo; Dictionary = dictionary; TrainData = trainData; TestData = testData; WordEmbeddings = wordEmbeddings; MeaningEmbeddings = meaningEmbeddings; DataAnalysis = dataAnalysis; DictionaryStatistics = dictionaryStatistics; DataStatistics = dataStatistics; WordEmbeddingStatistics = wordEmbeddingStatistics; MeaningEmbeddingStatistics = meaningEmbeddingStatistics; PosList = new WsdPosList(trainData); PluginData = new PluginData(); }
public void ClearNotInteresting() { if (ControllerActionStatistics?.IsInteresting(_configuration.ControllerAction) != true) { ControllerActionStatistics = null; } if (RequestStatistics?.IsInteresting(_configuration.DataConfiguration.ClientData) != true) { RequestStatistics = null; } if (ResponseStatisticsPreAction?.IsInteresting(_configuration.DataConfiguration.Model2DTO) != true) { ResponseStatisticsPreAction = null; } if (ResponseStatisticsPostAction?.IsInteresting(_configuration.DataConfiguration.Model2DTO) != true) { ResponseStatisticsPostAction = null; } if (ConversionStatistics?.IsInteresting(_configuration.DataConfiguration.DTO2ViewModel) != true) { ConversionStatistics = null; } if (DatabaseFlushStatistics?.IsInteresting(_configuration.DBFlush) != true) { DatabaseFlushStatistics = null; } if (ControllerActionStatistics == null && RequestStatistics == null && ResponseStatisticsPreAction == null && ResponseStatisticsPostAction == null && ConversionStatistics == null && DatabaseFlushStatistics == null) { Controller = null; Action = null; } }
private void button1_Click(object sender, EventArgs e) { if (_pSelectedField != null) { listUniqueValue.Enabled = true; listUniqueValue.Items.Clear(); IQueryFilter queryFilter = new QueryFilterClass(); // 创建查询过滤条件对象 queryFilter.SubFields = _pSelectedField.Name; // 设置返回的字段名称 IFeatureCursor pFeatureCursor = _pSelectedFeatureClass.Search(queryFilter, true); //得到IFeatureCursor游标 ICursor pCursor = pFeatureCursor as ICursor; //接口查询返回ICursor游标 IDataStatistics pDataStatistics = new DataStatistics(); //创建DataStatistics对象,该对象用于进行字段值的统计以及获取字段的唯一值 pDataStatistics.Cursor = pCursor; //给DataStatistics对象的游标属性赋值 pDataStatistics.Field = _pSelectedField.Name; //给DataStatistics对象的字段属性赋值 IEnumerator pEnumerator = pDataStatistics.UniqueValues; //获得唯一值数据集 pEnumerator.Reset(); // while (pEnumerator.MoveNext()) //未到最后一条记录 { if (pEnumerator.Current != null) { string lsname = pEnumerator.Current.ToString(); //把当前值转成字符串 switch (ParseFieldType(_pSelectedField.Type)) //判断字段类型 { case "System.String": //若为字符串, listUniqueValue.Items.Add("'" + lsname + "'"); //在文本字符串两端加上单引号,然后添加进唯一值列表控件中 break; default: listUniqueValue.Items.Add(lsname); //若为其他类型的字段,则直接添加进唯一值列表控件中 break; } } } } }
private void _worker_DoWork(object sender, DoWorkEventArgs e) { var logger = LogManager.GetLogger(typeof(Program)); FileInfo fileInfo = new FileInfo(openFileDialog1.FileName); using (ExcelPackage package = new ExcelPackage(fileInfo)) { if (package.Workbook.Worksheets.Count > 0) { ExcelWorksheet ws = package.Workbook.Worksheets[1]; int minColumnNum = ws.Dimension.Start.Column; //工作区开始列 int maxColumnNum = ws.Dimension.End.Column; //工作区结束列 int minRowNum = ws.Dimension.Start.Row + 1; //工作区开始行号 int maxRowNum = ws.Dimension.End.Row; //工作区结束行号 _maxGenerationDataCount = maxRowNum - 1; logger.Info(string.Format("总行数:{0}", _maxGenerationDataCount)); var fileCategory = string.Empty; var fileNames = new List <string>(); if (openFileDialog1.FileName.ToLower().Contains("news")) { fileCategory = DataCategory.News.ToString(); fileNames.Add("fdi-news-recipe-1.0.recipe"); } else if (openFileDialog1.FileName.ToLower().Contains("laws")) { fileCategory = DataCategory.Legal.ToString(); fileNames.Add("fdi-inward-legal-recipe-1.0.recipe"); fileNames.Add("fdi-outward-legal-recipe-1.0.recipe"); } else if (openFileDialog1.FileName.ToLower().Contains("data-statistics")) { fileCategory = DataCategory.DataStatistics.ToString(); fileNames.Add("fdi-data-statistics-recipe-1.0.recipe"); } #region 循环 foreach (var fileName in fileNames) { CreateFileAndBuildRecipeContent(fileName); var index = 0; var inwardLegalIndex = 0; var outwardLegalIndex = 0; for (int n = minRowNum; n <= maxRowNum; n++) { var id = ws.Cells[string.Format("A{0}", n)].Value; if (id == null) { continue; } Regex reg = new Regex("\\d{7}"); if (!reg.IsMatch(id.ToString()) || !int.TryParse(id.ToString(), out int result)) { continue; } if (fileCategory == DataCategory.News.ToString()) { var news = new News() { Id = int.Parse(id.ToString()) }; #region Set Data var publishDate = ws.Cells[string.Format("J{0}", n)]; if (publishDate.Value != null) { news.PublishDate = publishDate.Value.ToString(); } var title = ws.Cells[string.Format("Y{0}", n)]; if (title.Value != null) { news.Title = title.Value.ToString(); } var body = ws.Cells[string.Format("Z{0}", n)]; if (body.Value != null) { news.Body = body.Value.ToString(); } var classification = ws.Cells[string.Format("AC{0}", n)]; if (classification.Value != null) { news.Classification = "Business Economy";//classification.Value.ToString(); } var tag = ws.Cells[string.Format("AD{0}", n)]; if (tag.Value != null) { news.Tag = tag.Value.ToString(); } var source = ws.Cells[string.Format("AE{0}", n)]; if (source.Value != null) { news.Source = source.Value.ToString(); } var author = ws.Cells[string.Format("AF{0}", n)]; if (author.Value != null) { news.Author = author.Value.ToString(); } var vocation = ws.Cells[string.Format("AG{0}", n)]; if (vocation.Value != null) { news.IndustrialEconomyVocation = vocation.Value.ToString(); } var areaRegion = ws.Cells[string.Format("AH{0}", n)]; if (areaRegion.Value != null) { news.AreaEconomyRegion = areaRegion.Value.ToString(); } var areaChina = ws.Cells[string.Format("AI{0}", n)]; if (areaChina.Value != null) { news.AreaEconomyChina = areaChina.Value.ToString(); } var areaOversea = ws.Cells[string.Format("AJ{0}", n)]; if (areaOversea.Value != null) { news.AreaEconomyOversea = areaOversea.Value.ToString(); } var subtitle = ws.Cells[string.Format("AK{0}", n)]; if (subtitle.Value != null) { news.SubTitle = subtitle.Value.ToString(); } #endregion index++; BuildNewsContentXmlFile(fileName, news, index); } else if (fileCategory == DataCategory.Legal.ToString()) { var legal = new Legal() { Id = int.Parse(id.ToString()) }; #region Set Data var publishDate = ws.Cells[string.Format("J{0}", n)]; if (publishDate.Value != null) { legal.PublishDate = publishDate.Value.ToString(); } var title = ws.Cells[string.Format("Y{0}", n)]; if (title.Value != null) { legal.Title = title.Value.ToString(); } var body = ws.Cells[string.Format("Z{0}", n)]; if (body.Value != null) { legal.Body = body.Value.ToString(); } var classification = ws.Cells[string.Format("AC{0}", n)]; if (classification.Value != null) { var classStr = classification.Value.ToString().Trim(); if (classStr == "“Going global” Laws and Regulations") { legal.Type = LegalType.Outward; legal.Classification = GetOutwardLegalClassification(ws.Cells[string.Format("AL{0}", n)].Value); outwardLegalIndex++; } else { legal.Type = LegalType.Inward; if (classStr == "“Bringing in” Laws and Regulations") { legal.Classification = GetInwardLegalClassification(ws.Cells[string.Format("AK{0}", n)].Value); } else if (classStr == "Comprehensive Laws and Regulations") { legal.Classification = GetInwardLegalClassification(ws.Cells[string.Format("AJ{0}", n)].Value); } else if (classStr == "Other") { legal.Classification = @"/alias=inward-laws-classfication\/other"; } inwardLegalIndex++; } } var promulgationDate = ws.Cells[string.Format("AD{0}", n)]; if (promulgationDate.Value != null) { legal.PromulgationDate = promulgationDate.Value.ToString(); } var promulgationNumber = ws.Cells[string.Format("AE{0}", n)]; if (promulgationNumber.Value != null) { legal.PromulgationNumber = promulgationNumber.Value.ToString(); } var promulgationDepartment = ws.Cells[string.Format("AF{0}", n)]; if (promulgationDepartment.Value != null) { legal.PromulgationDepartment = promulgationDepartment.Value.ToString(); } var subtitle = ws.Cells[string.Format("AH{0}", n)]; if (subtitle.Value != null) { legal.SubTitle = subtitle.Value.ToString(); } var tag = ws.Cells[string.Format("AI{0}", n)]; if (tag.Value != null) { legal.SubTitle = tag.Value.ToString(); } #endregion if (fileName.Contains(legal.Type.ToString().ToLower())) { if (legal.Type == LegalType.Inward) { BuildLegalContentXmlFile(fileName, legal, inwardLegalIndex); } else { BuildLegalContentXmlFile(fileName, legal, outwardLegalIndex); } } } else if (fileCategory == DataCategory.DataStatistics.ToString()) { var dataStatistics = new DataStatistics() { Id = int.Parse(id.ToString()) }; #region Set Data var publishDate = ws.Cells[string.Format("J{0}", n)]; if (publishDate.Value != null) { dataStatistics.PublishDate = publishDate.Value.ToString(); } var title = ws.Cells[string.Format("Y{0}", n)]; if (title.Value != null) { dataStatistics.Title = title.Value.ToString(); } var body = ws.Cells[string.Format("Z{0}", n)]; if (body.Value != null) { dataStatistics.Body = body.Value.ToString(); } var classification = ws.Cells[string.Format("AC{0}", n)]; if (classification.Value != null) { dataStatistics.Classification = classification.Value.ToString(); } var foreignCategory = ws.Cells[string.Format("AD{0}", n)]; if (foreignCategory.Value != null) { dataStatistics.ForeignInvestmentStatisticsCategory = foreignCategory.Value.ToString(); } var chineseCategory = ws.Cells[string.Format("AE{0}", n)]; if (chineseCategory.Value != null) { dataStatistics.ChineseEconomyStatisticsCategory = chineseCategory.Value.ToString(); } var tag = ws.Cells[string.Format("AG{0}", n)]; if (tag.Value != null) { dataStatistics.SubTitle = tag.Value.ToString(); } var declareDate = ws.Cells[string.Format("AH{0}", n)]; if (declareDate.Value != null) { dataStatistics.DeclareDate = declareDate.Value.ToString(); } var overseaCategory = ws.Cells[string.Format("AI{0}", n)]; if (overseaCategory.Value != null) { dataStatistics.OverseasInvestmentStatisticsCategory = overseaCategory.Value.ToString(); } var subtitle = ws.Cells[string.Format("AJ{0}", n)]; if (subtitle.Value != null) { dataStatistics.SubTitle = subtitle.Value.ToString(); } var yearMonthLabel = ws.Cells[string.Format("AL{0}", n)]; if (yearMonthLabel.Value != null) { dataStatistics.YearAndMonthLabel = yearMonthLabel.Value.ToString(); } var source = ws.Cells[string.Format("AM{0}", n)]; if (source.Value != null) { dataStatistics.Source = source.Value.ToString(); } #endregion index++; BuildDataStatisticsContentXmlFile(fileName, dataStatistics, index); } if (_worker.CancellationPending) { e.Cancel = true; return; } } } #endregion } } }
//统计最低温 private cityTeme getMinTemp() { cityTeme CT2 = new cityTeme("低温城市", 0.0); IFeatureLayer featLayer = (IFeatureLayer)Utilities.GetLayerByName("省市", axMapControl1.Map); IFeatureClass featClass = featLayer.FeatureClass; IDataStatistics maxTemp = new DataStatistics(); IDataStatistics minTemp = new DataStatistics(); IFeatureCursor featCursor; IQueryFilter queryfilter = new QueryFilterClass(); featCursor = featClass.Search(null, false); ICursor cursor = (ICursor)featCursor; minTemp.Cursor = cursor; minTemp.Field = "LowTemperature"; IStatisticsResults MINtemp; MINtemp = minTemp.Statistics; CT2.Teme = MINtemp.Minimum; String minWhereClause = "[LowTemperature] = " + CT2.Teme; queryfilter.WhereClause = minWhereClause; featCursor = featClass.Search(queryfilter, false); IFeature MINpFeature = featCursor.NextFeature(); if (MINpFeature != null) { int index2 = featClass.FindField("NAME"); CT2.City = MINpFeature.get_Value(index2).ToString(); } return CT2; }
/// <summary> /// 获取统计数据 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnGet_Click(object sender, EventArgs e) { object[] result = null; ErrorMessage errorMessage = new ErrorMessage(ErrorMessage.ExceptionCode, "未知的统计类型。"); string userName = lbPublicAccount.SelectedValue; string type = lbType.SelectedValue; string typeName = lbType.SelectedItem.Text; DateTime beginDate = DateTime.Parse(txtBeginDate.Text); DateTime endDate = DateTime.Parse(txtEndDate.Text); if (type == "UserSummary") { result = DataStatistics.GetUserSummary(userName, beginDate, endDate, out errorMessage); } else if (type == "UserCumulate") { result = DataStatistics.GetUserCumulate(userName, beginDate, endDate, out errorMessage); } else if (type == "ArticleSummary") { result = DataStatistics.GetArticleSummary(userName, beginDate, endDate, out errorMessage); } else if (type == "ArticleTotal") { result = DataStatistics.GetArticleTotal(userName, beginDate, endDate, out errorMessage); } else if (type == "UserRead") { result = DataStatistics.GetUserRead(userName, beginDate, endDate, out errorMessage); } else if (type == "UserReadHour") { result = DataStatistics.GetUserReadHour(userName, beginDate, endDate, out errorMessage); } else if (type == "UserShare") { result = DataStatistics.GetUserShare(userName, beginDate, endDate, out errorMessage); } else if (type == "UserShareHour") { result = DataStatistics.GetUserShareHour(userName, beginDate, endDate, out errorMessage); } else if (type == "UpstreamMsg") { result = DataStatistics.GetUpstreamMsg(userName, beginDate, endDate, out errorMessage); } else if (type == "UpstreamMsgHour") { result = DataStatistics.GetUpstreamMsgHour(userName, beginDate, endDate, out errorMessage); } else if (type == "UpstreamMsgWeek") { result = DataStatistics.GetUpstreamMsgWeek(userName, beginDate, endDate, out errorMessage); } else if (type == "UpstreamMsgMonth") { result = DataStatistics.GetUpstreamMsgMonth(userName, beginDate, endDate, out errorMessage); } else if (type == "UpstreamMsgDist") { result = DataStatistics.GetUpstreamMsgDist(userName, beginDate, endDate, out errorMessage); } else if (type == "UpstreamMsgDistWeek") { result = DataStatistics.GetUpstreamMsgDistWeek(userName, beginDate, endDate, out errorMessage); } else if (type == "UpstreamMsgDistMonth") { result = DataStatistics.GetUpstreamMsgDistMonth(userName, beginDate, endDate, out errorMessage); } else if (type == "InterfaceSummary") { result = DataStatistics.GetInterfaceSummary(userName, beginDate, endDate, out errorMessage); } else if (type == "InterfaceSummaryHour") { result = DataStatistics.GetInterfaceSummaryHour(userName, beginDate, endDate, out errorMessage); } if (errorMessage.IsSuccess) { StringBuilder sb = new StringBuilder(); if (result != null && result.Length > 0) { foreach (object item in result) { sb.AppendLine(item.ToString()); sb.AppendLine("----------------------"); } } txtData.Text = sb.ToString(); ltrMessage.Text = string.Format("获取{0}成功。", typeName); } else { txtData.Text = ""; ltrMessage.Text = string.Format("获取{0}失败。{1}", typeName, errorMessage); } }
public void ExportTxtResult() { FinalCaculate(); MakeTxt(); instance = null;//舍弃掉此实例,因为里面的数据不会自动清理。相当于清空数据 }
public static WsdProject CreateAndSave( WsdProjectCreateInfo info, string destinationPath, IProgressHandle progress) { if (info == null) { throw new ArgumentNullException(nameof(info)); } if (string.IsNullOrEmpty(destinationPath)) { throw new ArgumentNullException(nameof(destinationPath)); } if (PathEx.Identify(destinationPath) != PathIdentity.Directory || Directory.GetFiles(destinationPath, "*", SearchOption.AllDirectories).Length > 0) { throw new ArgumentException(ExceptionMessage.DestinationPathMustBeEmptyAndExisting); } if (progress == null) { throw new ArgumentNullException(nameof(progress)); } info.AssertIsValid(); progress.SetMessageFormat(MessageFormat.LoadingDictionary_Bytes); var dictionary = InputDictionaryReader.ReadAll(info.DictionaryPath, progress); progress.SetMessageFormat(MessageFormat.ComputingDictionaryStatistics); var dictionaryStatistics = new DictionaryStatistics().Compute(dictionary, progress); TextData[] trainData; TextData[] testData; if (info.DataType == InputDataType.PlainText) { progress.SetMessageFormat(MessageFormat.LoadingTrainData_Files); trainData = InputPlainTextDataReader.ReadAllFiles(info.TrainDataPath, progress); progress.SetMessageFormat(MessageFormat.LoadingTestData_Files); testData = InputPlainTextDataReader.ReadAllFiles(info.TestDataPath, progress); } else { progress.SetMessageFormat(MessageFormat.LoadingSynsetMappings_Bytes); var synsetMappings = InputSynsetMappingReader.ReadAll(info.SynsetMappingsPath, progress); progress.SetMessageFormat(MessageFormat.LoadingTrainData_Files); trainData = InputXmlDataReader.Read( info.TrainDataPath, info.TrainGoldKeyPath, synsetMappings, dictionary, out var trainXmlParseErrors, progress); if (trainXmlParseErrors != null && trainXmlParseErrors.Any()) { XmlParseErrorWriter.WriteAll( Path.Combine(destinationPath, FileName.TrainXmlParseErrors + FileExtension.Text), trainXmlParseErrors); } progress.SetMessageFormat(MessageFormat.LoadingTestData_Files); testData = InputXmlDataReader.Read( info.TestDataPath, info.TestGoldKeyPath, synsetMappings, dictionary, out var testXmlParseErrors, progress); if (testXmlParseErrors != null && testXmlParseErrors.Any()) { XmlParseErrorWriter.WriteAll( Path.Combine(destinationPath, FileName.TestXmlParseErrors + FileExtension.Text), testXmlParseErrors); } } progress.SetMessageFormat(MessageFormat.AnalyzingData_Files); var dataAnalysis = new WordAnalysisDictionary() .Analyze(dictionary, trainData, testData, progress); progress.SetMessageFormat(MessageFormat.ComputingDataStatistics); var dataStatistics = new DataStatistics() .Compute(dictionary, dataAnalysis, progress); progress.SetMessageFormat(MessageFormat.LoadingWordEmbeddings_Bytes); var wordEmbeddings = InputEmbeddingReader.ReadAll( info.WordEmbeddingsPath, dataAnalysis.GetAllWordOccurrences(), progress); var wordEmbeddingStatistics = new EmbeddingStatistics().Compute(wordEmbeddings); EmbeddingDictionary meaningEmbeddings = null; var meaningEmbeddingStatistics = new EmbeddingStatistics(); if (!string.IsNullOrWhiteSpace(info.MeaningEmbeddingsPath)) { progress.SetMessageFormat(MessageFormat.LoadingMeaningEmbeddings_Bytes); meaningEmbeddings = InputEmbeddingReader.ReadAll( info.MeaningEmbeddingsPath, dataAnalysis.GetAllMeaningOccurrences(), progress); meaningEmbeddingStatistics.Compute(meaningEmbeddings); } var projectInfo = new WsdProjectInfo { ProjectName = Path.GetFileName(destinationPath), ProjectVersion = CurrentProjectVersion, ApplicationVersion = typeof(WsdProject).Assembly.GetName().Version.ToString(), Dictionary = FileName.Dictionary + FileExtension.WsdData, TrainData = trainData.Select(x => new WsdProjectTextDataInfo { Name = x.TextName, Path = Path.Combine(FolderName.Train, x.TextName + FileExtension.WsdData) }).ToArray(), TestData = testData.Select(x => new WsdProjectTextDataInfo { Name = x.TextName, Path = Path.Combine(FolderName.Test, x.TextName + FileExtension.WsdData) }).ToArray(), WordEmbeddings = FileName.WordEmbeddings + FileExtension.WsdData, MeaningEmbeddings = meaningEmbeddings != null ? FileName.MeaningEmbeddings + FileExtension.WsdData : string.Empty, DataAnalysis = FileName.DataAnalysis + FileExtension.WsdData, DictionaryStatistics = FileName.DictionaryStatistics + FileExtension.WsdData, DataStatistics = FileName.DataStatistics + FileExtension.WsdData, WordEmbeddingsStatistics = FileName.WordEmbeddingsStatistics + FileExtension.WsdData, MeaningEmbeddingsStatistics = FileName.MeaningEmbeddingsStatistics + FileExtension.WsdData }; progress.SetMessageFormat(MessageFormat.SavingDictionary_Words); SystemDictionaryWriter.WriteAll( Path.Combine(destinationPath, projectInfo.Dictionary), dictionary, progress); progress.SetMessageFormat(MessageFormat.SavingTrainData_Files); SystemDataWriter.WriteAllFiles( destinationPath, projectInfo.TrainData .Select(x => (x.Path, trainData.Single(y => y.TextName == x.Name).Data)) .ToArray(), progress); progress.SetMessageFormat(MessageFormat.SavingTestData_Files); SystemDataWriter.WriteAllFiles( destinationPath, projectInfo.TestData .Select(x => (x.Path, testData.Single(y => y.TextName == x.Name).Data)) .ToArray(), progress); progress.SetMessageFormat(MessageFormat.SavingWordEmbeddings_Embeddings); SystemEmbeddingWriter.WriteAll( Path.Combine(destinationPath, projectInfo.WordEmbeddings), wordEmbeddings, progress); if (meaningEmbeddings != null) { progress.SetMessageFormat(MessageFormat.SavingMeaningEmbeddings_Embeddings); SystemEmbeddingWriter.WriteAll( Path.Combine(destinationPath, projectInfo.MeaningEmbeddings), meaningEmbeddings, progress); } progress.SetMessageFormat(MessageFormat.SavingDataAnalysis_Words); SystemDataAnalysisWriter.WriteAll( Path.Combine(destinationPath, projectInfo.DataAnalysis), dataAnalysis, progress); SystemJsonWriter.Write( Path.Combine(destinationPath, projectInfo.DictionaryStatistics), dictionaryStatistics); SystemJsonWriter.Write( Path.Combine(destinationPath, projectInfo.DataStatistics), dataStatistics); SystemJsonWriter.Write( Path.Combine(destinationPath, projectInfo.WordEmbeddingsStatistics), wordEmbeddingStatistics); SystemJsonWriter.Write( Path.Combine(destinationPath, projectInfo.MeaningEmbeddingsStatistics), meaningEmbeddingStatistics); SystemJsonWriter.Write( Path.Combine(destinationPath, projectInfo.ProjectName + FileExtension.WsdProj), projectInfo); return(new WsdProject( projectInfo, dictionary, trainData, testData, wordEmbeddings, meaningEmbeddings, dataAnalysis, dictionaryStatistics, dataStatistics, wordEmbeddingStatistics, meaningEmbeddingStatistics)); }