-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patha.linq
139 lines (133 loc) · 4.32 KB
/
a.linq
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
<Query Kind="Program">
<Connection>
<ID>71cffb82-448c-4d1c-8ebc-666c3c2050be</ID>
<Persist>true</Persist>
<Driver>EntityFrameworkDbContext</Driver>
<CustomAssemblyPath>C:\Users\ufuko\Source\Repos\tigem\Tigem.Business\bin\Debug\Tigem.Business.dll</CustomAssemblyPath>
<CustomTypeName>Tigem.Business.Data.Model.TigemDBEntities</CustomTypeName>
<AppConfigPath>C:\Users\ufuko\Source\Repos\tigem\Tigem.Business\bin\Debug\Tigem.Business.dll.config</AppConfigPath>
</Connection>
<Reference><RuntimeDirectory>\WPF\PresentationFramework.dll</Reference>
<Reference><RuntimeDirectory>\System.Xaml.dll</Reference>
<Reference><RuntimeDirectory>\WPF\WindowsBase.dll</Reference>
<Reference><RuntimeDirectory>\WPF\PresentationCore.dll</Reference>
<Reference><RuntimeDirectory>\System.Configuration.dll</Reference>
<Reference><RuntimeDirectory>\WPF\UIAutomationProvider.dll</Reference>
<Reference><RuntimeDirectory>\WPF\UIAutomationTypes.dll</Reference>
<Reference><RuntimeDirectory>\WPF\ReachFramework.dll</Reference>
<Reference><RuntimeDirectory>\WPF\PresentationUI.dll</Reference>
<Reference><RuntimeDirectory>\WPF\System.Printing.dll</Reference>
<Reference><RuntimeDirectory>\Accessibility.dll</Reference>
<Reference><RuntimeDirectory>\System.Deployment.dll</Reference>
<NuGetReference>Newtonsoft.Json</NuGetReference>
<Namespace>Newtonsoft.Json</Namespace>
<Namespace>Newtonsoft.Json.Bson</Namespace>
<Namespace>Newtonsoft.Json.Converters</Namespace>
<Namespace>Newtonsoft.Json.Linq</Namespace>
<Namespace>Newtonsoft.Json.Schema</Namespace>
<Namespace>Newtonsoft.Json.Serialization</Namespace>
<Namespace>Tigem.Tools</Namespace>
<Namespace>System.Windows</Namespace>
</Query>
public class Tem {
public string Name { get; set; }
public string PropertyName{ get; set; }
}
void Main()
{
var list=typeof(Tigem.Business.Data.Model.TigemDBEntities).GetProperties();
//.Dump();
var ty = list.Select(o => o.PropertyType.GenericTypeArguments.FirstOrDefault()).Where(o => o != null);
//.Dump();
var dictionary=new Dictionary<string,List<Tem>>();
foreach (var e in ty)
{
dictionary[e.Name]= e.GetProperties().Where(t=> t.PropertyType.IsPrimitive|| t.PropertyType == typeof(Decimal) || t.PropertyType == typeof(String) ||t.PropertyType==typeof(DateTime) ).Select(o => new Tem {Name=o.Name, PropertyName=o.PropertyType.Name}).ToList();
}
dictionary.Keys.OrderBy(o=>o).Dump();
var str = GenerateOutoCode(dictionary);
}
public string GenerateOutoCode(Dictionary<string, List<Tem>> dic)
{
var map = new Dictionary<string, string> {
{"Int32", "Integer"},
{"Decimal", "Real"},
{"String", "String"},
{"DateTime", "DateTime"},
{"Boolean", "Enum"},
{"Byte", "Integer"},
{"Double", "Real"},
};
var tpl = @"
TableName='_{0}';
treeNode.AOTadd(TableName);
fieldlist = TreeNode::findNode('\\Data Dictionary\\Tables\\' + TableName + '\\Fields');
{1}";
var tpl2 = @"fieldList.add{0}('{1}');"+Environment.NewLine;
var str = new StringBuilder();
var str2 = new StringBuilder();
var t = GetList();
foreach (var e in dic.Keys.Where(o => !t.Contains(o)).OrderBy(o=>o))
{
str2.Clear();
foreach (var d in dic[e])
{
str2.AppendFormat(tpl2, map[d.PropertyName], d.Name);
}
str.AppendFormat(tpl, e, str2).Dump();
}
return str.ToString();
}
public static List<string> GetList()
{
var t = @"BudgetPrice
EquipmentExpenseGroup
InputOutputDocument
InputOutputDocumentSignature
InputOutputEquipment
LiveAsset
NoteOfExpense
SetOfUnit
StockKind
StockPeriod
EquipmentStore
EquipmentStoreShelf
EquipmentType
EquipmentTypeAlternative
EquipmentTypeCountingError
EquipmentTypeCountingErrorDetail
EquipmentTypeGroup
EquipmentTypeRequest
EquipmentTypeSpecialCode
EquipmentTypeUnit
Unit
UnitSetOfUnit
FA_AbandonManagement
FA_AccountPlan
FA_BankIntegration
FA_CheckBill
FA_DeptReceivable
FA_DeptReceivablePayment
FA_Embezzlement
FA_EmbezzlementEquipment
FA_Expiration
FA_ExpirationPayment
FA_IncomeExpense
FA_InstutionBankAccount
FA_Invoice
FA_PaymentDocument
FA_PaymentInstruction
FA_Receipt
FA_ReversalRecord
HR_SalaryCalculationFactor
HR_ShiftSchedule
HR_SocialAid
HR_SocialAidDetail
HR_Worker
Business
BusinessDepartment
Shelf
Store
";
return t.Split(new[] { "\n"},StringSplitOptions.RemoveEmptyEntries).Select(o=>o.Trim()).ToList();
}