개정판 f37c5383
Fix: 심볼 검색 속도 개선(Component를 데이타베이스에 저장한 프로젝트는 심볼 사용 여부를 데이타베이스에서 조회)
Change-Id: I06c51ee6fd38d4c5b61ac70df308f1153fae5914
ID2.Manager/ID2.Manager.Controller/Controllers/DocumentController.cs | ||
---|---|---|
200 | 200 |
} |
201 | 201 |
} |
202 | 202 |
|
203 |
public IEnumerable<ID2Symbol> FindID2Symbols(string Name) |
|
203 |
public IEnumerable<ID2Symbol> FindID2Symbols(string Name, bool XmlOnly)
|
|
204 | 204 |
{ |
205 | 205 |
IEnumerable<ID2Symbol> results = null; |
206 | 206 |
|
... | ... | |
208 | 208 |
{ |
209 | 209 |
using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR)) |
210 | 210 |
{ |
211 |
return rep.FindID2Symbols(Name); |
|
211 |
return rep.FindID2Symbols(Name, XmlOnly); |
|
212 |
} |
|
213 |
} |
|
214 |
catch (Exception ex) |
|
215 |
{ |
|
216 |
throw ex; |
|
217 |
} |
|
218 |
|
|
219 |
return results; |
|
220 |
} |
|
221 |
|
|
222 |
public IEnumerable<ID2Configuration> GetID2Configurations() |
|
223 |
{ |
|
224 |
IEnumerable<ID2Configuration> results = null; |
|
225 |
|
|
226 |
try |
|
227 |
{ |
|
228 |
using (DocumentRepository rep = new DocumentRepository(this._ID2CONNSTR)) |
|
229 |
{ |
|
230 |
return rep.GetID2Configurations(); |
|
212 | 231 |
} |
213 | 232 |
} |
214 | 233 |
catch (Exception ex) |
ID2.Manager/ID2.Manager.Dapper/Repository/DocumentRepository.cs | ||
---|---|---|
819 | 819 |
/// </summary> |
820 | 820 |
/// <param name="id2Info"></param> |
821 | 821 |
/// <param name="Name"></param> |
822 |
/// <param name="XmlOnly">Component가 Xml에만 저장되어 있는지 여부</param>" |
|
822 | 823 |
/// <returns></returns> |
823 |
public IEnumerable<ID2Symbol> FindID2Symbols(string Name) |
|
824 |
public IEnumerable<ID2Symbol> FindID2Symbols(string Name, bool XmlOnly)
|
|
824 | 825 |
{ |
825 |
string query = $@"select Name, T.[Type], OriginalPoint, ConnectionPoint, Width, Height |
|
826 |
from Symbol A join SymbolType T on A.SymbolType_UID=T.UID where A.Name like @Name"; |
|
826 |
string query; |
|
827 |
if (!XmlOnly) |
|
828 |
{ |
|
829 |
query = $@"select A.Name, T.[Type], A.OriginalPoint, A.ConnectionPoint, A.Width, A.Height |
|
830 |
from Symbol A |
|
831 |
join SymbolType T on A.SymbolType_UID=T.UID |
|
832 |
where A.Name like @Name and EXISTS(select * from Components where Symbol_UID = A.UID)"; |
|
833 |
} |
|
834 |
else |
|
835 |
{ |
|
836 |
query = $@"select Name, T.[Type], OriginalPoint, ConnectionPoint, Width, Height |
|
837 |
from Symbol A |
|
838 |
join Components C on A.Symbol_UID=C.UID |
|
839 |
join SymbolType T on A.SymbolType_UID=T.UID where A.Name like @Name"; |
|
840 |
} |
|
841 |
|
|
827 | 842 |
return Query<ID2Symbol>(query, new { Name = $"%{Name}%" }); |
828 | 843 |
} |
829 | 844 |
|
845 |
/// <summary> |
|
846 |
/// ID2 Configuration을 조회한다. |
|
847 |
/// </summary> |
|
848 |
/// <returns></returns> |
|
849 |
public IEnumerable<ID2Configuration> GetID2Configurations() |
|
850 |
{ |
|
851 |
string query = $@"select [Section], [Key], [Value] from Configuration"; |
|
852 |
return Query<ID2Configuration>(query); |
|
853 |
} |
|
830 | 854 |
|
831 | 855 |
//Transactions |
832 | 856 |
public int GetTranKey(string userId, string projectIDs) |
ID2.Manager/ID2.Manager.Data/Models/Documents.cs | ||
---|---|---|
514 | 514 |
public int Height{ get; set; } |
515 | 515 |
} |
516 | 516 |
|
517 |
[DataContract] |
|
518 |
public class ID2Configuration |
|
519 |
{ |
|
520 |
public string Section{ get; set; } |
|
521 |
public string Key{ get; set; } |
|
522 |
public string Value{ get; set; } |
|
523 |
} |
|
524 |
|
|
517 | 525 |
public class DocumentsResult |
518 | 526 |
{ |
519 | 527 |
public List<Documents> Dwgs { get; set; } |
ID2.Manager/ID2.Manager.Data/Models/ProjectInfo.cs | ||
---|---|---|
5 | 5 |
using System.Threading.Tasks; |
6 | 6 |
|
7 | 7 |
using System.Runtime.Serialization; |
8 |
using System.ComponentModel; |
|
8 | 9 |
|
9 | 10 |
namespace ID2.Manager.Data.Models |
10 | 11 |
{ |
... | ... | |
69 | 70 |
public string Team { get; set; } |
70 | 71 |
[DataMember] |
71 | 72 |
public int? Port { get; set; } = 2549; |
73 |
|
|
74 |
[Description("Component를 Xml에만 저장하는지 여부")] |
|
75 |
public bool XmlOnly { get; set; } = true; |
|
72 | 76 |
} |
73 | 77 |
} |
ID2.Manager/ID2.Manager/Classes/ID2SymbolWorker.cs | ||
---|---|---|
78 | 78 |
if (!registered.Any()) continue; |
79 | 79 |
#endregion |
80 | 80 |
|
81 |
string Folder = System.IO.Path.Combine(prj.Path, "Temp"); |
|
82 |
var files = System.IO.Directory.GetFiles(Folder, "*.xml"); |
|
83 |
foreach(var file in files) |
|
81 |
if (prj.XmlOnly) |
|
84 | 82 |
{ |
85 |
XmlDocument doc = new XmlDocument(); |
|
83 |
string Folder = System.IO.Path.Combine(prj.Path, "Temp"); |
|
84 |
var files = System.IO.Directory.GetFiles(Folder, "*.xml"); |
|
85 |
foreach (var file in files) |
|
86 | 86 |
{ |
87 |
doc.Load(file); |
|
88 |
var nodes = doc.GetElementsByTagName("SYMBOLS"); |
|
89 |
if (nodes.Count != 1 || !nodes[0].HasChildNodes) continue; |
|
90 |
|
|
91 |
foreach (XmlNode symbol in nodes[0].ChildNodes) |
|
87 |
XmlDocument doc = new XmlDocument(); |
|
92 | 88 |
{ |
93 |
var name = symbol["NAME"].InnerText; |
|
94 |
int idx = registered.FindIndex(x => x.Name.Equals(name)); |
|
95 |
if (-1 != idx) |
|
89 |
doc.Load(file); |
|
90 |
var nodes = doc.GetElementsByTagName("SYMBOLS"); |
|
91 |
if (nodes.Count != 1 || !nodes[0].HasChildNodes) continue; |
|
92 |
|
|
93 |
foreach (XmlNode symbol in nodes[0].ChildNodes) |
|
96 | 94 |
{ |
97 |
string DxfFilePath = Path.Combine(prj.Path, "image", registered[idx].Type, $"{registered[idx].Name}.dxf"); |
|
98 |
if (!File.Exists(DxfFilePath)) |
|
95 |
var name = symbol["NAME"].InnerText; |
|
96 |
int idx = registered.FindIndex(x => x.Name.Equals(name)); |
|
97 |
if (-1 != idx) |
|
99 | 98 |
{ |
100 |
#region 이미지에서 dxf를 추출한다. |
|
101 |
string PngFilePath = Path.Combine(prj.Path, "image", registered[idx].Type, $"{registered[idx].Name}.png"); |
|
102 |
using (Bitmap bmp = new Bitmap(PngFilePath)) |
|
99 |
string DxfFilePath = Path.Combine(prj.Path, "image", registered[idx].Type, $"{registered[idx].Name}.dxf"); |
|
100 |
if (!File.Exists(DxfFilePath)) |
|
103 | 101 |
{ |
104 |
string BmpFilePath = Path.Combine(Path.GetDirectoryName(PngFilePath), Path.GetFileNameWithoutExtension(PngFilePath) + ".bmp"); |
|
105 |
bmp.Save(BmpFilePath, ImageFormat.Bmp); |
|
106 |
Potrace(BmpFilePath); |
|
102 |
#region 이미지에서 dxf를 추출한다. |
|
103 |
string PngFilePath = Path.Combine(prj.Path, "image", registered[idx].Type, $"{registered[idx].Name}.png"); |
|
104 |
using (Bitmap bmp = new Bitmap(PngFilePath)) |
|
105 |
{ |
|
106 |
string BmpFilePath = Path.Combine(Path.GetDirectoryName(PngFilePath), Path.GetFileNameWithoutExtension(PngFilePath) + ".bmp"); |
|
107 |
bmp.Save(BmpFilePath, ImageFormat.Bmp); |
|
108 |
Potrace(BmpFilePath); |
|
109 |
} |
|
110 |
#endregion |
|
107 | 111 |
} |
108 |
#endregion |
|
109 |
} |
|
110 | 112 |
|
111 |
Used.Add(registered[idx]); |
|
112 |
registered.RemoveAt(idx); |
|
113 |
Used.Add(registered[idx]); |
|
114 |
registered.RemoveAt(idx); |
|
115 |
} |
|
113 | 116 |
} |
114 | 117 |
} |
118 |
|
|
119 |
///찾을 심볼이 없으면 루프를 중단한다. |
|
120 |
if (!registered.Any()) break; |
|
115 | 121 |
} |
122 |
} |
|
123 |
else |
|
124 |
{ |
|
125 |
foreach (var symbol in registered) |
|
126 |
{ |
|
127 |
string DxfFilePath = Path.Combine(prj.Path, "image", symbol.Type, $"{symbol.Name}.dxf"); |
|
128 |
if (!File.Exists(DxfFilePath)) |
|
129 |
{ |
|
130 |
#region 이미지에서 dxf를 추출한다. |
|
131 |
string PngFilePath = Path.Combine(prj.Path, "image", symbol.Type, $"{symbol.Name}.png"); |
|
132 |
using (Bitmap bmp = new Bitmap(PngFilePath)) |
|
133 |
{ |
|
134 |
string BmpFilePath = Path.Combine(Path.GetDirectoryName(PngFilePath), Path.GetFileNameWithoutExtension(PngFilePath) + ".bmp"); |
|
135 |
bmp.Save(BmpFilePath, ImageFormat.Bmp); |
|
136 |
Potrace(BmpFilePath); |
|
137 |
} |
|
138 |
#endregion |
|
139 |
} |
|
116 | 140 |
|
117 |
///찾을 심볼이 없으면 루프를 중단한다.
|
|
118 |
if (!registered.Any()) break;
|
|
141 |
Used.Add(symbol);
|
|
142 |
}
|
|
119 | 143 |
} |
120 | 144 |
} |
121 | 145 |
} |
ID2.Manager/ID2.Manager/Main.cs | ||
---|---|---|
159 | 159 |
//this.radGridViewDocuments.MasterView.TableSearchRow.InitialSearchResultsTreshold = ; |
160 | 160 |
this.radGridViewDocuments.MasterView.TableSearchRow.IsVisible = false; |
161 | 161 |
this.radGridViewDocuments.GroupSummaryEvaluate += RadGridViewDocuments_GroupSummaryEvaluate; |
162 |
this.radGridViewID2Symbols.GroupSummaryEvaluate += RadGridViewDocuments_GroupSummaryEvaluate; |
|
162 | 163 |
|
163 | 164 |
var openProjectView = new OpenProjectView() |
164 | 165 |
{ |
... | ... | |
751 | 752 |
{ |
752 | 753 |
try |
753 | 754 |
{ |
754 |
var symbols = new DocumentController(id2prj).FindID2Symbols(SymbolName); |
|
755 |
var controller = new DocumentController(id2prj); |
|
756 |
var configs = controller.GetID2Configurations(); |
|
757 |
var config = configs.FirstOrDefault(x => x.Section.Equals("Data Save") && x.Key.Equals("Drawing Xml Only")); |
|
758 |
id2prj.XmlOnly = config != null && config.Value.Equals("1"); |
|
759 |
var symbols = controller.FindID2Symbols(SymbolName, id2prj.XmlOnly); |
|
755 | 760 |
symbols.ForAll(x => |
756 | 761 |
{ |
757 | 762 |
x.PrjName = id2prj.Name; |
758 | 763 |
x.PrjPath = id2prj.Path; |
759 | 764 |
}); |
760 | 765 |
AllSymbols.AddRange(symbols); |
766 |
|
|
761 | 767 |
} |
762 | 768 |
catch (Exception ex) |
763 | 769 |
{ |
내보내기 Unified diff