개정판 54796052
issue #0000
FIle 추가
Change-Id: I3d318be28439185d8e4100fc63d48f75008677a6
ID2.Manager/ID2.Manager.Controller/Controllers/FileController.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
using ID2.Manager.Data.Models; |
|
8 |
using ID2.Manager.Dapper.Repository; |
|
9 |
|
|
10 |
namespace ID2.Manager.Controller.Controllers |
|
11 |
{ |
|
12 |
public class FileController : BaseController |
|
13 |
{ |
|
14 |
public IEnumerable<FileInfo> GetFileList(string documentID) |
|
15 |
{ |
|
16 |
using (FileRepository rep = new FileRepository(this._DbConnectionStr)) |
|
17 |
{ |
|
18 |
return rep.GetFileList(documentID); |
|
19 |
} |
|
20 |
} |
|
21 |
|
|
22 |
public bool SetUserInfo(List<FileInfo> fileList) |
|
23 |
{ |
|
24 |
using (FileRepository rep = new FileRepository(this._DbConnectionStr)) |
|
25 |
{ |
|
26 |
return rep.SetFileInfo(fileList); |
|
27 |
} |
|
28 |
} |
|
29 |
} |
|
30 |
} |
ID2.Manager/ID2.Manager.Controller/ID2.Manager.Controller.csproj | ||
---|---|---|
62 | 62 |
<ItemGroup> |
63 | 63 |
<Compile Include="Controllers\BaseController.cs" /> |
64 | 64 |
<Compile Include="Controllers\DocumentController.cs" /> |
65 |
<Compile Include="Controllers\FileController.cs" /> |
|
65 | 66 |
<Compile Include="Controllers\MarkusInfoController.cs" /> |
66 | 67 |
<Compile Include="Controllers\ProjectController.cs" /> |
67 | 68 |
<Compile Include="Controllers\UserController.cs" /> |
ID2.Manager/ID2.Manager.Dapper/ID2.Manager.Dapper.csproj | ||
---|---|---|
67 | 67 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
68 | 68 |
<Compile Include="Repository\BaseRepository.cs" /> |
69 | 69 |
<Compile Include="Repository\DocumentRepository.cs" /> |
70 |
<Compile Include="Repository\FileRepository.cs" /> |
|
70 | 71 |
<Compile Include="Repository\MarkusRepository.cs" /> |
71 | 72 |
<Compile Include="Repository\ProjectRepository.cs" /> |
72 | 73 |
<Compile Include="Repository\UserRepository.cs" /> |
ID2.Manager/ID2.Manager.Dapper/Repository/FileRepository.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
using ID2.Manager.Data.Models; |
|
8 |
|
|
9 |
namespace ID2.Manager.Dapper.Repository |
|
10 |
{ |
|
11 |
public class FileRepository : BaseRepository |
|
12 |
{ |
|
13 |
public FileRepository(string connectionStr) : base(connectionStr) { } |
|
14 |
|
|
15 |
public IEnumerable<FileInfo> GetFileList(string documentID) |
|
16 |
{ |
|
17 |
string query = $@" |
|
18 |
select * from dbo.Files where RefDocID=@documentID order by CreatedDate"; |
|
19 |
|
|
20 |
return Query<FileInfo>(query, new { documentID }); |
|
21 |
} |
|
22 |
|
|
23 |
public bool SetFileInfo(List<FileInfo> fileList) |
|
24 |
{ |
|
25 |
bool isSuccess = false; |
|
26 |
|
|
27 |
try |
|
28 |
{ |
|
29 |
using (var transaction = base.BeginTransaction()) |
|
30 |
{ |
|
31 |
foreach (FileInfo file in fileList) |
|
32 |
{ |
|
33 |
string query = $@" |
|
34 |
insert into dbo.Files (FileID, RefDocID, FileType, FileName, FilePath, FileData) |
|
35 |
values |
|
36 |
( |
|
37 |
lower(newid()) |
|
38 |
,@RefDocID |
|
39 |
,@FileType |
|
40 |
,@FileName |
|
41 |
,@FilePath |
|
42 |
,@FileData |
|
43 |
)"; |
|
44 |
base.Execute(query, file, transaction); |
|
45 |
} |
|
46 |
|
|
47 |
transaction.Commit(); |
|
48 |
isSuccess = true; |
|
49 |
} |
|
50 |
} |
|
51 |
catch (Exception ex) |
|
52 |
{ |
|
53 |
throw ex; |
|
54 |
} |
|
55 |
|
|
56 |
return isSuccess; |
|
57 |
} |
|
58 |
} |
|
59 |
} |
ID2.Manager/ID2.Manager.Data/ID2.Manager.Data.csproj | ||
---|---|---|
62 | 62 |
</ItemGroup> |
63 | 63 |
<ItemGroup> |
64 | 64 |
<Compile Include="Models\Documents.cs" /> |
65 |
<Compile Include="Models\FileInfo.cs" /> |
|
65 | 66 |
<Compile Include="Models\ProjectInfo.cs" /> |
66 | 67 |
<Compile Include="Models\UserInfo.cs" /> |
67 | 68 |
<Compile Include="Properties\AssemblyInfo.cs" /> |
ID2.Manager/ID2.Manager.Data/Models/FileInfo.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
using System.Runtime.Serialization; |
|
8 |
|
|
9 |
namespace ID2.Manager.Data.Models |
|
10 |
{ |
|
11 |
[DataContract] |
|
12 |
public class FileInfo |
|
13 |
{ |
|
14 |
[DataMember] |
|
15 |
public string FileID { get; set; } |
|
16 |
[DataMember] |
|
17 |
public string RefDocID { get; set; } |
|
18 |
[DataMember] |
|
19 |
public string FileType { get; set; } |
|
20 |
[DataMember] |
|
21 |
public string FileName { get; set; } |
|
22 |
[DataMember] |
|
23 |
public string FilePath { get; set; } |
|
24 |
[DataMember] |
|
25 |
public byte[] FileData { get; set; } |
|
26 |
[DataMember] |
|
27 |
public DateTime CreatedDate { get; set; } |
|
28 |
} |
|
29 |
} |
ID2.Manager/ID2.Manager/Forms/ImageView.Designer.cs | ||
---|---|---|
33 | 33 |
this.pictureBox1 = new System.Windows.Forms.PictureBox(); |
34 | 34 |
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); |
35 | 35 |
this.tableLayoutPanel2 = new System.Windows.Forms.TableLayoutPanel(); |
36 |
this.radBrowseEditorFile = new Telerik.WinControls.UI.RadBrowseEditor(); |
|
37 |
this.radButtonSave = new Telerik.WinControls.UI.RadButton(); |
|
36 | 38 |
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); |
37 | 39 |
this.tableLayoutPanel1.SuspendLayout(); |
40 |
this.tableLayoutPanel2.SuspendLayout(); |
|
41 |
((System.ComponentModel.ISupportInitialize)(this.radBrowseEditorFile)).BeginInit(); |
|
42 |
((System.ComponentModel.ISupportInitialize)(this.radButtonSave)).BeginInit(); |
|
38 | 43 |
this.SuspendLayout(); |
39 | 44 |
// |
40 | 45 |
// flowLayoutPanel1 |
... | ... | |
79 | 84 |
// |
80 | 85 |
// tableLayoutPanel2 |
81 | 86 |
// |
82 |
this.tableLayoutPanel2.ColumnCount = 1;
|
|
87 |
this.tableLayoutPanel2.ColumnCount = 2;
|
|
83 | 88 |
this.tableLayoutPanel1.SetColumnSpan(this.tableLayoutPanel2, 2); |
84 | 89 |
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); |
85 |
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); |
|
90 |
this.tableLayoutPanel2.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 80F)); |
|
91 |
this.tableLayoutPanel2.Controls.Add(this.radBrowseEditorFile, 0, 0); |
|
92 |
this.tableLayoutPanel2.Controls.Add(this.radButtonSave, 1, 0); |
|
86 | 93 |
this.tableLayoutPanel2.Dock = System.Windows.Forms.DockStyle.Fill; |
87 | 94 |
this.tableLayoutPanel2.Location = new System.Drawing.Point(23, 587); |
88 | 95 |
this.tableLayoutPanel2.Name = "tableLayoutPanel2"; |
89 | 96 |
this.tableLayoutPanel2.RowCount = 1; |
90 | 97 |
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); |
91 |
this.tableLayoutPanel2.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F)); |
|
92 | 98 |
this.tableLayoutPanel2.Size = new System.Drawing.Size(934, 44); |
93 | 99 |
this.tableLayoutPanel2.TabIndex = 2; |
94 | 100 |
// |
101 |
// radBrowseEditorFile |
|
102 |
// |
|
103 |
this.radBrowseEditorFile.Anchor = System.Windows.Forms.AnchorStyles.Right; |
|
104 |
this.radBrowseEditorFile.Location = new System.Drawing.Point(451, 12); |
|
105 |
this.radBrowseEditorFile.Name = "radBrowseEditorFile"; |
|
106 |
this.radBrowseEditorFile.Size = new System.Drawing.Size(400, 20); |
|
107 |
this.radBrowseEditorFile.TabIndex = 0; |
|
108 |
// |
|
109 |
// radButtonSave |
|
110 |
// |
|
111 |
this.radButtonSave.Anchor = System.Windows.Forms.AnchorStyles.Left; |
|
112 |
this.radButtonSave.Location = new System.Drawing.Point(857, 10); |
|
113 |
this.radButtonSave.Name = "radButtonSave"; |
|
114 |
this.radButtonSave.Size = new System.Drawing.Size(74, 24); |
|
115 |
this.radButtonSave.TabIndex = 1; |
|
116 |
this.radButtonSave.Text = "Save"; |
|
117 |
// |
|
95 | 118 |
// ImageView |
96 | 119 |
// |
97 | 120 |
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); |
... | ... | |
102 | 125 |
this.Text = "ImageView"; |
103 | 126 |
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); |
104 | 127 |
this.tableLayoutPanel1.ResumeLayout(false); |
128 |
this.tableLayoutPanel2.ResumeLayout(false); |
|
129 |
this.tableLayoutPanel2.PerformLayout(); |
|
130 |
((System.ComponentModel.ISupportInitialize)(this.radBrowseEditorFile)).EndInit(); |
|
131 |
((System.ComponentModel.ISupportInitialize)(this.radButtonSave)).EndInit(); |
|
105 | 132 |
this.ResumeLayout(false); |
106 | 133 |
|
107 | 134 |
} |
... | ... | |
112 | 139 |
private System.Windows.Forms.PictureBox pictureBox1; |
113 | 140 |
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1; |
114 | 141 |
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel2; |
142 |
private Telerik.WinControls.UI.RadBrowseEditor radBrowseEditorFile; |
|
143 |
private Telerik.WinControls.UI.RadButton radButtonSave; |
|
115 | 144 |
} |
116 | 145 |
} |
ID2.Manager/ID2.Manager/Forms/ImageView.cs | ||
---|---|---|
10 | 10 |
|
11 | 11 |
using System.IO; |
12 | 12 |
|
13 |
using ID2.Manager.Common; |
|
14 |
using ID2.Manager.Data.Models; |
|
15 |
using ID2.Manager.Controller.Controllers; |
|
16 |
|
|
17 |
using Telerik.WinControls; |
|
18 |
|
|
13 | 19 |
namespace ID2.Manager.Forms |
14 | 20 |
{ |
15 | 21 |
public partial class ImageView : BaseForm |
16 | 22 |
{ |
17 |
public ImageView() |
|
23 |
string DocumentID = string.Empty; |
|
24 |
public OpenFileDialog ofd; |
|
25 |
|
|
26 |
public ImageView(string docID) |
|
18 | 27 |
{ |
19 | 28 |
InitializeComponent(); |
20 | 29 |
|
30 |
this.DocumentID = docID; |
|
31 |
|
|
32 |
this.Initialize(); |
|
33 |
|
|
21 | 34 |
this.Load += ImageView_Load; |
35 |
this.radButtonSave.Click += RadButtonSave_Click; |
|
36 |
} |
|
37 |
|
|
38 |
private void Initialize() |
|
39 |
{ |
|
40 |
ofd = this.radBrowseEditorFile.BrowseDialog as OpenFileDialog; |
|
41 |
ofd.Filter = "Image files (*.png)|*.png"; |
|
42 |
ofd.Title = "Open an Image File"; |
|
22 | 43 |
} |
23 | 44 |
|
24 | 45 |
private void ImageView_Load(object sender, EventArgs e) |
25 | 46 |
{ |
26 | 47 |
//string[] files = Directory.GetFiles(@"C:\Users\yoush97\Desktop\PAP자료\SG6609 HMB\ID2\Image\img\", "*.png"); |
27 | 48 |
|
28 |
string[] files = new string[] { }; |
|
49 |
//string[] files = new string[] { };
|
|
29 | 50 |
|
30 |
foreach (string file in files) |
|
51 |
//foreach (string file in files) |
|
52 |
//{ |
|
53 |
// PictureBox pic = new PictureBox(); |
|
54 |
// pic.Image = Image.FromFile(file); |
|
55 |
// pic.SizeMode = PictureBoxSizeMode.Zoom; |
|
56 |
// pic.Width = 150; |
|
57 |
// pic.Height = 150; |
|
58 |
// pic.Margin = new Padding(5); |
|
59 |
|
|
60 |
// flowLayoutPanel1.Controls.Add(pic); |
|
61 |
|
|
62 |
// pic.Click += Pic_Click; |
|
63 |
//} |
|
64 |
|
|
65 |
this.GetFileList(); |
|
66 |
} |
|
67 |
|
|
68 |
public void GetFileList() |
|
69 |
{ |
|
70 |
var files = new FileController().GetFileList(this.DocumentID).ToList(); |
|
71 |
|
|
72 |
foreach (Data.Models.FileInfo file in files) |
|
31 | 73 |
{ |
32 |
PictureBox pic = new PictureBox(); |
|
33 |
pic.Image = Image.FromFile(file); |
|
34 |
pic.SizeMode = PictureBoxSizeMode.Zoom; |
|
35 |
pic.Width = 150; |
|
36 |
pic.Height = 150; |
|
37 |
pic.Margin = new Padding(5); |
|
74 |
var arrayBinary = file.FileData.ToArray(); |
|
75 |
|
|
76 |
using (MemoryStream ms = new MemoryStream(arrayBinary)) |
|
77 |
{ |
|
78 |
PictureBox pic = new PictureBox(); |
|
79 |
pic.Image = Image.FromStream(ms); |
|
80 |
pic.SizeMode = PictureBoxSizeMode.Zoom; |
|
81 |
pic.Width = 150; |
|
82 |
pic.Height = 150; |
|
83 |
pic.Margin = new Padding(5); |
|
38 | 84 |
|
39 |
flowLayoutPanel1.Controls.Add(pic); |
|
85 |
flowLayoutPanel1.Controls.Add(pic);
|
|
40 | 86 |
|
41 |
pic.Click += Pic_Click; |
|
87 |
pic.Click += Pic_Click; |
|
88 |
} |
|
42 | 89 |
} |
43 | 90 |
} |
44 | 91 |
|
... | ... | |
47 | 94 |
PictureBox pic = sender as PictureBox; |
48 | 95 |
pictureBox1.Image = pic.Image; |
49 | 96 |
} |
97 |
|
|
98 |
private void RadButtonSave_Click(object sender, EventArgs e) |
|
99 |
{ |
|
100 |
if (string.IsNullOrEmpty(ofd.FileName) && !File.Exists(ofd.FileName)) |
|
101 |
{ |
|
102 |
RadMessageBox.Show($"There is no Image File selected.", "Information", MessageBoxButtons.OK, RadMessageIcon.Info); |
|
103 |
return; |
|
104 |
} |
|
105 |
|
|
106 |
var file = new Data.Models.FileInfo(); |
|
107 |
file.RefDocID = this.DocumentID; |
|
108 |
file.FileName = ofd.FileName; |
|
109 |
file.FilePath = ofd.FileName; |
|
110 |
file.FileType = ofd.FileName; |
|
111 |
using (var stream = new FileStream(ofd.FileName, FileMode.Open, FileAccess.Read)) |
|
112 |
{ |
|
113 |
using (var reader = new BinaryReader(stream)) |
|
114 |
{ |
|
115 |
file.FileData = reader.ReadBytes((int)stream.Length); |
|
116 |
} |
|
117 |
} |
|
118 |
|
|
119 |
var files = new List<Data.Models.FileInfo>() { file }; |
|
120 |
|
|
121 |
bool result = new FileController().SetUserInfo(files); |
|
122 |
|
|
123 |
if (result) |
|
124 |
{ |
|
125 |
RadMessageBox.Show("Save is complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
|
126 |
} |
|
127 |
else |
|
128 |
{ |
|
129 |
RadMessageBox.Show("Save is not complete", Globals.Name, MessageBoxButtons.OK, RadMessageIcon.Error); |
|
130 |
} |
|
131 |
} |
|
50 | 132 |
} |
51 | 133 |
} |
ID2.Manager/ID2.Manager/Main.cs | ||
---|---|---|
353 | 353 |
break; |
354 | 354 |
case "ToCapturePath": |
355 | 355 |
case "FrCapturePath": |
356 |
using (var frm = new ImageView()) |
|
356 |
|
|
357 |
if (e.Row.DataBoundItem is Documents dd) |
|
357 | 358 |
{ |
358 |
frm.ShowDialog(this); |
|
359 |
using (var frm = new ImageView(dd.DocID)) |
|
360 |
{ |
|
361 |
frm.ShowDialog(this); |
|
362 |
} |
|
359 | 363 |
} |
360 | 364 |
break; |
361 | 365 |
case "ID2Connection": |
내보내기 Unified diff