日常更新
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using NPOI.XSSF.UserModel;
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
using NPOI.XSSF.UserModel;
|
||||
using Ramitta;
|
||||
using System;
|
||||
using System.Collections;
|
||||
@@ -12,22 +14,20 @@ using System.Threading.Tasks;
|
||||
|
||||
using static Ramitta.Excel;
|
||||
using static Ramitta.lib.Basic;
|
||||
using static Ramitta.lib.CryptoHelper;
|
||||
using static Ramitta.SQLite;
|
||||
using static Ramitta.winDataGrid;
|
||||
|
||||
|
||||
namespace template
|
||||
{
|
||||
public partial class MainWindow
|
||||
{
|
||||
Neo4jService neo4jService = new Neo4jService("bolt://localhost:7687", "neo4j", "AE1BC6D3");
|
||||
Ramitta.Neo4jtool neo4jService = new Ramitta.Neo4jtool("bolt://localhost:7687", "neo4j", "AE1BC6D3");
|
||||
|
||||
public async void 数据升天计划neo4j()
|
||||
{
|
||||
await neo4jService.DeleteAllNodesAndRelationshipsAsync();
|
||||
|
||||
var 文件夹名单 = GetFilesAndDirectories(inputPath(null,null), true,
|
||||
outputFormat: dir => System.IO.Path.GetFileNameWithoutExtension(dir));
|
||||
outputFormat: dir => Path.GetFileNameWithoutExtension(dir));
|
||||
|
||||
|
||||
foreach (var 文件夹 in 文件夹名单)
|
||||
@@ -35,12 +35,12 @@ namespace template
|
||||
var 文件名单 = GetFilesAndDirectories(inputPath(null, null) + 文件夹, false,
|
||||
outputFormat: dir => System.IO.Path.GetFileNameWithoutExtension(dir));
|
||||
|
||||
await neo4jService.CreateNodeAsync("文件夹", new Dictionary<string, object>() { { "name", 文件夹 } });
|
||||
await neo4jService.CreateNodeAsync("文件夹", new Dictionary<string, string>() { { "name", 文件夹 } },alway_create:true);
|
||||
|
||||
foreach (var 文件 in 文件名单)
|
||||
{
|
||||
var name = Guid.NewGuid().ToString();
|
||||
var pair = new Dictionary<string, object>() {
|
||||
var pair = new Dictionary<string, string>() {
|
||||
{ "name", name },{ "文件夹",文件夹} };
|
||||
|
||||
if (文件夹.Contains("边墙沉重管") ||
|
||||
@@ -74,11 +74,6 @@ namespace template
|
||||
pair.Add("跨度", Regex.Match(文件, @"跨度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (文件.Contains("高度"))
|
||||
{
|
||||
pair.Add("高度", Regex.Match(文件, @"高度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (文件.Contains("长度"))
|
||||
{
|
||||
pair.Add("长度", Regex.Match(文件, @"长度(\d+)").Groups[1].Value);
|
||||
@@ -89,10 +84,10 @@ namespace template
|
||||
pair.Add("宽度", Regex.Match(文件, @"宽度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
await neo4jService.CreateNodeAsync("文件", pair);
|
||||
await neo4jService.CreateNodeAsync("文件", pair, alway_create: true);
|
||||
await neo4jService.CreateRelationshipAsync("拥有",
|
||||
"文件夹","name", 文件夹, "文件", "name", name);
|
||||
|
||||
"文件夹", new Dictionary<string, string> { { "name", 文件夹 } },
|
||||
"文件", new Dictionary<string, string> { { "name", name } });
|
||||
|
||||
}
|
||||
}
|
||||
@@ -188,7 +183,7 @@ namespace template
|
||||
|
||||
|
||||
|
||||
public async void 表升天() {
|
||||
public async void 表原核生物化() {
|
||||
|
||||
var 文件夹名单 = GetFilesAndDirectories(inputPath(null, null), true,
|
||||
outputFormat: dir => Path.GetFileNameWithoutExtension(dir));
|
||||
@@ -235,11 +230,6 @@ namespace template
|
||||
pair.Add("跨度", Regex.Match(文件, @"跨度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (文件.Contains("高度"))
|
||||
{
|
||||
pair.Add("高度", Regex.Match(文件, @"高度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (文件.Contains("长度"))
|
||||
{
|
||||
pair.Add("长度", Regex.Match(文件, @"长度(\d+)").Groups[1].Value);
|
||||
@@ -273,15 +263,17 @@ namespace template
|
||||
}
|
||||
}
|
||||
|
||||
public async void 新建关系(Dictionary<string, object> pair, Dictionary<string, List<string>> dict,string tap,string rela="属于") {
|
||||
public async void 新建关系(Dictionary<string, string> pair, Dictionary<string, List<string>> dict,string tap,string rela="属于") {
|
||||
if (pair.ContainsKey(tap))
|
||||
{
|
||||
await neo4jService.MergeNodeAsync(tap, new Dictionary<string, object>() {
|
||||
{ "name", dict[tap][0]} });
|
||||
await neo4jService.CreateNodeAsync(tap, new Dictionary<string, string>() {
|
||||
{ "name", tap} });
|
||||
|
||||
await neo4jService.CreateRelationshipAsync(rela,
|
||||
tap, "name", dict[tap][0],
|
||||
"文件", "name", dict["name"][0]);
|
||||
tap, new Dictionary<string, string> { { "name", tap } },
|
||||
"文件", new Dictionary<string, string> { { "name", dict["name"][0] } },
|
||||
relationshipProperties:
|
||||
new Dictionary<string, string>{ { "value", dict[tap][0] } });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -291,13 +283,13 @@ namespace template
|
||||
|
||||
var 文件名单 = GetFilesAndDirectories(
|
||||
文件夹路径,false,
|
||||
outputFormat: dir => System.IO.Path.GetFileNameWithoutExtension(dir));
|
||||
outputFormat: dir => Path.GetFileNameWithoutExtension(dir));
|
||||
|
||||
foreach (var 文件 in 文件名单) {
|
||||
var dict = ReadExcelAsDictCol(文件夹路径+文件+".xlsx",sheetName:"info");
|
||||
|
||||
// 创建新的字典pair
|
||||
var pair = new Dictionary<string, object>();
|
||||
var pair = new Dictionary<string, string>();
|
||||
|
||||
// 遍历dict,将每个key对应的第一个value添加到新的pair字典中
|
||||
foreach (var entry in dict)
|
||||
@@ -308,22 +300,40 @@ namespace template
|
||||
}
|
||||
}
|
||||
|
||||
await neo4jService.MergeNodeAsync("文件夹", new Dictionary<string, object>() {
|
||||
await neo4jService.CreateNodeAsync("文件夹", new Dictionary<string, string>() {
|
||||
{ "name", dict["文件夹"][0] } });
|
||||
|
||||
await neo4jService.MergeNodeAsync("文件", pair);
|
||||
await neo4jService.CreateNodeAsync("文件", pair);
|
||||
|
||||
|
||||
|
||||
await neo4jService.CreateRelationshipAsync("拥有",
|
||||
"文件夹", "name", dict["文件夹"][0],
|
||||
"文件", "name", dict["name"][0]);
|
||||
"文件夹", new Dictionary<string, string> { { "name", dict["文件夹"][0] } },
|
||||
"文件", new Dictionary<string, string> { { "name", dict["name"][0] } });
|
||||
|
||||
|
||||
新建关系(pair, dict, "跨度", "跨度");
|
||||
新建关系(pair, dict, "高度","高度");
|
||||
新建关系(pair, dict, "宽度","宽度");
|
||||
新建关系(pair, dict, "长度","长度");
|
||||
新建关系(pair, dict, "型号","型号");
|
||||
新建关系(pair, dict, "边高", "边高");
|
||||
|
||||
var dictdata = ReadExcelAsDictRow(文件夹路径 + 文件 + ".xlsx", sheetName: "data",headerInit:
|
||||
new List<string>() { "料号","名称","数量","标志","备注"});
|
||||
|
||||
dictdata.RemoveAt(0); // 移除列表中的第一个字典
|
||||
|
||||
foreach (var row in dictdata) {
|
||||
await neo4jService.CreateNodeAsync("品物", new Dictionary<string, string>() {
|
||||
{ "name", row["料号"] },{"名称",row["名称"] } });
|
||||
|
||||
await neo4jService.CreateRelationshipAsync("数量",
|
||||
"文件", new Dictionary<string, string> { { "name", dict["name"][0] } },
|
||||
"品物", new Dictionary<string, string> { { "name", row["料号"] } },
|
||||
relationshipProperties:
|
||||
new Dictionary<string, string> { { "数量", row["数量"] } });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -335,12 +345,12 @@ namespace template
|
||||
var basic = @"C:\Users\Xeroly\Desktop\组件库\";
|
||||
|
||||
var list = GetFilesAndDirectories(basic, true, null,
|
||||
outputFormat: dir => System.IO.Path.GetFileNameWithoutExtension(dir));
|
||||
outputFormat: dir => Path.GetFileNameWithoutExtension(dir));
|
||||
|
||||
foreach (var file in list)
|
||||
{
|
||||
var listson = GetFilesAndDirectories(basic + file, false, null,
|
||||
outputFormat: dir => System.IO.Path.GetFileNameWithoutExtension(dir));
|
||||
outputFormat: dir => Path.GetFileNameWithoutExtension(dir));
|
||||
|
||||
db.CreateTable(file, new Dictionary<string, string> {
|
||||
{ "料号", "TEXT" },
|
||||
@@ -445,6 +455,80 @@ namespace template
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public async void 数据升天计划mongodb()
|
||||
{
|
||||
var 文件夹名单 = GetFilesAndDirectories(inputPath(null, null), true,
|
||||
outputFormat: dir => Path.GetFileNameWithoutExtension(dir));
|
||||
|
||||
foreach (var 文件夹 in 文件夹名单)
|
||||
{
|
||||
var 文件名单 = GetFilesAndDirectories(inputPath(null, null) + 文件夹, false,
|
||||
outputFormat: dir => System.IO.Path.GetFileNameWithoutExtension(dir));
|
||||
/*
|
||||
// 使用示例
|
||||
var mongoDB = new MongoDB_interface(
|
||||
"mongodb://localhost:27017",
|
||||
"XerolySkinner",
|
||||
文件夹);
|
||||
*/
|
||||
foreach (var 文件 in 文件名单)
|
||||
{
|
||||
var name = Guid.NewGuid().ToString();
|
||||
var pair = new Dictionary<string, string>() {
|
||||
{ "name", name },{ "文件夹",文件夹} };
|
||||
|
||||
if (文件夹.Contains("边墙沉重管") ||
|
||||
文件夹.Contains("边墙基座固定") ||
|
||||
文件夹.Contains("杂件"))
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
pair.Add("类型", Regex.Match(文件, @"([^-]+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (
|
||||
文件夹.Contains("边墙沉重管") ||
|
||||
文件夹.Contains("承重柱") ||
|
||||
文件夹.Contains("弧形拉伸杆") ||
|
||||
文件夹.Contains("山墙侧柱套件") ||
|
||||
文件夹.Contains("山墙沉重管") ||
|
||||
文件夹.Contains("屋脊连接角") ||
|
||||
文件夹.Contains("屋面方管") ||
|
||||
文件夹.Contains("屋檐方管") ||
|
||||
文件夹.Contains("斜梁") ||
|
||||
文件夹.Contains("右悬挂管") ||
|
||||
文件夹.Contains("左悬挂管"))
|
||||
{
|
||||
pair.Add("型号", Regex.Match(文件, @"^(?:[^-]+-){2}([^-\r\n]+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (文件.Contains("跨度"))
|
||||
{
|
||||
pair.Add("跨度", Regex.Match(文件, @"跨度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (文件.Contains("长度"))
|
||||
{
|
||||
pair.Add("长度", Regex.Match(文件, @"长度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
if (文件.Contains("宽度"))
|
||||
{
|
||||
pair.Add("宽度", Regex.Match(文件, @"宽度(\d+)").Groups[1].Value);
|
||||
}
|
||||
|
||||
/*
|
||||
await neo4jService.CreateNodeAsync("文件", pair, alway_create: true);
|
||||
await neo4jService.CreateRelationshipAsync("拥有",
|
||||
"文件夹", new Dictionary<string, string> { { "name", 文件夹 } },
|
||||
"文件", new Dictionary<string, string> { { "name", name } });
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user