private Classifier.IOutputData Processing(Classifier.IInputData data) { var factory = new Classifier.Factory(data); factory.Execute(); return(factory.outputData); }
private void uselessshit() { MapInfoAppControls map = new MapInfoAppControls(new MapinfoCurrentApp()); map.TablesShow(); var table = map.GetTable(); var cadNums = new ConcurrentDictionary <(string, double), Classifier.IFactory>(); Console.WriteLine("Start collecting cad_nums"); Stopwatch sw = new Stopwatch(); sw.Start(); foreach (var row in table.Rows) { if (row.RowID % 10000 == 0) { Console.WriteLine("{0} Elapsed time => {1}", row.RowID, sw.Elapsed.Seconds); sw.Restart(); } string cadNum = row["CAD_NUM"]; double area = row["Площадь"] * 10000; if (cadNum.Length > 10) { cadNums.TryAdd((cadNum, area), null); } } Console.WriteLine("Start processing cad_nums"); sw.Restart(); var bag = new ConcurrentBag <Plot>(); using (var context = new Context()) { var plots = context.Plots.ToList(); foreach (var _plot in plots) { _plot.Buildings.ToList(); bag.Add(_plot); } } Parallel.ForEach(cadNums, (item) => { var plot = bag.FirstOrDefault(p => p.CadNum.Equals(item.Key.Item1, StringComparison.InvariantCulture)); if (plot != null) { var data = new Classifier.InputDataDB(plot, (int)item.Key.Item2); var factory = new Classifier.Factory(data); factory.Execute(); cadNums[item.Key] = factory; } }); Console.WriteLine("Start writing data"); foreach (var row in table.Rows) { if (row.RowID % 10000 == 0) { Console.WriteLine("{0} Elapsed time => {1}", row.RowID, sw.Elapsed.Seconds); sw.Restart(); } string cadNum = row["CAD_NUM"]; if (cadNum.Length > 10) { var data = cadNums.FirstOrDefault(p => p.Key.Item1.Equals(cadNum, StringComparison.InvariantCulture)).Value; if (data != null) { row["VRI"] = data.outputData.VRI_List; row["Type"] = data.outputData.Type; row["Kind"] = data.outputData.Kind; } } } }
static void Main() { var mf = new Classifier.Nodes.NodesCollection(); var app = new MapInfoAppControls(new MapinfoCurrentApp()); app.TablesShow(); Context context = null; try { context = new Context(); } catch (Exception e) { Console.WriteLine(e); } finally { context.Dispose(); } var table = app.GetTable(); Console.WriteLine("Number of rows is: {0}", table.Lenght); var sw = new Stopwatch(); sw.Start(); foreach (var val in table.Rows) { Console.WriteLine("{0} rows was comleted", val.RowID); try { string vri_egrn = string.IsNullOrEmpty(val["Наименование_ОКС"]) ? val["Назначение"] : val["Наименование_ОКС"]; string vri_dgi = val["ДГИ_назначение"]; if (!string.IsNullOrEmpty(vri_egrn)) { Classifier.InputData data = new Classifier.InputData(vri_egrn, 600); Classifier.Factory factory = new Classifier.Factory(data); factory.Execute(); var vri = factory.outputData.VRI_List; val["VRI_EGRN"] = vri; } if (!string.IsNullOrEmpty(vri_dgi)) { Classifier.InputData data = new Classifier.InputData(vri_dgi, 600); Classifier.Factory factory = new Classifier.Factory(data); factory.Execute(); var vri = factory.outputData.VRI_List; val["VRI_DGI"] = vri; } } catch (Exception e) { Console.WriteLine(e.Message); continue; } } sw.Stop(); }