초기 커밋.

This commit is contained in:
2025-02-03 11:02:48 +09:00
parent a7d46f415f
commit fe9aa0799f
2334 changed files with 674826 additions and 0 deletions

View File

@@ -0,0 +1,184 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows.Forms;
using JWH.DATA;
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
using MongoDB.Driver;
namespace JWH.MONGODB
{
public class FDCMongoDB
{
public static string ConnectionString { get; set; } = "mongodb://192.168.8.181:27001";
public static string DatabaseName { get; set; } = "fdc";
public static List<BsonDocument> GetListCollection()
{
MongoClient client = new MongoClient(ConnectionString);
IMongoDatabase database = client.GetDatabase(DatabaseName);
List<BsonDocument> item = database.ListCollectionsAsync().Result.ToListAsync<BsonDocument>().Result;
return item;
}
public static List<TraceCollection> GetCollectionData(string collectionName, DateTime dtStart, DateTime dtEnd, TraceCollection condition = null)
{
MongoClient client = new MongoClient(ConnectionString);
IMongoDatabase database = client.GetDatabase(DatabaseName);
IMongoCollection<TraceCollection> collection = database.GetCollection<TraceCollection>(collectionName);
// # ALL Data
//var lst = collection.Find(_ => true).ToList();
// # Use BsonDocument
//var filter = new BsonDocument("LotID", "13089570006B");
// # Use Builders.Filter
//var filterBuilder = Builders<TraceCollection>.Filter;
//var filter = filterBuilder.Eq(x => x.LotID, "13109360026B");
FilterDefinitionBuilder<TraceCollection> filterBuilder = Builders<TraceCollection>.Filter;
FilterDefinition<TraceCollection> filter = filterBuilder.Gte(x => x.EVENTTIME, dtStart) & filterBuilder.Lt(x => x.EVENTTIME, dtEnd);
if (condition != null)
{
string[] SkipPropertys = new string[] { "_id", "EVENTTIME" };
foreach (PropertyInfo property in condition.GetType().GetProperties())
{
object value = property.GetValue(condition);
if (value != null)
{
if (property.Name.Equals("LotID")) filter &= filterBuilder.Eq(x => x.LotID, value);
continue;
}
}
}
List<TraceCollection> document = collection.Find(filter).ToList();
return document;
}
public static bool GetCollectionSize_Flag = false;
public static async void GetCollectionSize(string filename, Action<string> complete, params object[] controls)
{
GetCollectionSize_Flag = true;
StreamWriter writer = null;
BsonDocument document = null;
try
{
ProgressBar progressBar = null;
Control textBox = null;
foreach(object ctrl in controls)
{
if (ctrl.GetType() == typeof(ProgressBar)) progressBar = (ProgressBar)ctrl;
if (ctrl.GetType() == typeof(Label)) textBox = (Label)ctrl;
if (ctrl.GetType() == typeof(TextBox)) textBox = (TextBox)ctrl;
}
MongoClient client = new MongoClient(ConnectionString);
IMongoDatabase database = client.GetDatabase(DatabaseName);
List<BsonDocument> collections = database.ListCollectionsAsync().Result.ToListAsync<BsonDocument>().Result;
if (progressBar != null)
{
progressBar.Maximum = collections.Count;
progressBar.Minimum = 0;
progressBar.Value = 0;
}
string[] elementNames = new string[] { "size", "count", "avgObjSize", "storageSize", "freeStorageSize", "totalIndexSize", "totalSize" };
StringBuilder sb = new StringBuilder();
sb.Append($"EQ, SVID, name, ");
foreach (string elementName in elementNames) sb.Append($"{elementName}, ");
writer = new StreamWriter(filename);
writer.WriteLine(sb.ToString());
for (int i = 0; i < collections.Count; i++)
{
BsonDocument collection = collections[i];
string collectionName = collection.GetElement("name").Value.ToString();
var command = new JsonCommand<BsonDocument>("{collstats:\"" + collectionName + "\"}");
document = await database.RunCommandAsync(command);
string[] elementValues = new string[] { "", "", "", "", "", "", "" };
BsonElement[] elements = document.ToArray();
foreach(BsonElement element in elements)
{
for (int j = 0; j < elementNames.Length; j++)
{
if (element.Name == elementNames[j])
{
elementValues[j] = element.Value.ToString();
break;
}
}
}
sb.Clear();
string[] splitName = collectionName.Split('.');
if (splitName.Length == 2) sb.Append($"{splitName[0]}, {splitName[1]}, {collectionName}, ");
else sb.Append($", , {collectionName},");
foreach (string value in elementValues) sb.Append($"{value}, ");
writer.WriteLine(sb.ToString());
if (progressBar != null) progressBar.Value = i;
if (textBox != null) textBox.Text = $"{i.ToString("#,##0")} / {collections.Count.ToString("#,##0")}"; ;
if (!GetCollectionSize_Flag) break;
}
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
filename = string.Empty;
}
finally
{
FDCMongoDB.GetCollectionSize_Flag = false;
if (writer != null) writer.Close();
complete(filename);
}
}
public class TraceCollection : DataTableBase
{
public ObjectId _id { get; set; }
public List<object> LotList { get; set; }
[BsonDateTimeOptions(Kind = DateTimeKind.Local)]
public DateTime EVENTTIME { get; set; }
public string VIDName { get; set; }
public object Value { get; set; }
public string LotID { get; set; }
public string MaterialID { get; set; }
public string ProductID { get; set; }
public object UnitNO { get; set; }
public string Recipe { get; set; }
public string ProcessID { get; set; }
public string VORNR { get; set; }
public string UnitState { get; set; }
public string Sign { get; set; }
}
}
}

401
DDUtilityApp/MONGO/FrmFDCMongo.Designer.cs generated Normal file
View File

@@ -0,0 +1,401 @@
namespace DDUtilityApp.MONGO
{
partial class FrmFDCMongo
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Telerik.WinControls.UI.TableViewDefinition tableViewDefinition4 = new Telerik.WinControls.UI.TableViewDefinition();
this.panel1 = new System.Windows.Forms.Panel();
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.splitContainer3 = new System.Windows.Forms.SplitContainer();
this.btnGetCollectionSizeStart = new Telerik.WinControls.UI.RadButton();
this.tboxEquipmentID = new Telerik.WinControls.UI.RadTextBox();
this.btnEquipmentFind = new Telerik.WinControls.UI.RadButton();
this.tree = new Telerik.WinControls.UI.RadTreeView();
this.splitContainer2 = new System.Windows.Forms.SplitContainer();
this.panel2 = new System.Windows.Forms.Panel();
this.radLabel2 = new Telerik.WinControls.UI.RadLabel();
this.radLabel1 = new Telerik.WinControls.UI.RadLabel();
this.btnRefresh = new Telerik.WinControls.UI.RadButton();
this.dpEnd = new Telerik.WinControls.UI.RadDateTimePicker();
this.dpStart = new Telerik.WinControls.UI.RadDateTimePicker();
this.statusStrip = new Telerik.WinControls.UI.RadStatusStrip();
this.ssName = new Telerik.WinControls.UI.RadLabelElement();
this.ssStatus01 = new Telerik.WinControls.UI.RadLabelElement();
this.ssStatus02 = new Telerik.WinControls.UI.RadLabelElement();
this.ssMessage = new Telerik.WinControls.UI.RadLabelElement();
this.pbarCollectionSize = new System.Windows.Forms.ProgressBar();
this.lblProgressValue = new System.Windows.Forms.Label();
this.grid = new JWH.CONTROL.GridViewEx();
this.panel1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).BeginInit();
this.splitContainer3.Panel1.SuspendLayout();
this.splitContainer3.Panel2.SuspendLayout();
this.splitContainer3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.btnGetCollectionSizeStart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tboxEquipmentID)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.btnEquipmentFind)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.tree)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
this.splitContainer2.Panel1.SuspendLayout();
this.splitContainer2.Panel2.SuspendLayout();
this.splitContainer2.SuspendLayout();
this.panel2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.radLabel2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.radLabel1)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.btnRefresh)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dpEnd)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dpStart)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.statusStrip)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.grid)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.grid.MasterTemplate)).BeginInit();
this.SuspendLayout();
//
// panel1
//
this.panel1.Controls.Add(this.splitContainer1);
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Padding = new System.Windows.Forms.Padding(3);
this.panel1.Size = new System.Drawing.Size(800, 424);
this.panel1.TabIndex = 0;
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer1.Location = new System.Drawing.Point(3, 3);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.splitContainer3);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.splitContainer2);
this.splitContainer1.Size = new System.Drawing.Size(794, 418);
this.splitContainer1.SplitterDistance = 375;
this.splitContainer1.TabIndex = 0;
//
// splitContainer3
//
this.splitContainer3.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer3.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer3.IsSplitterFixed = true;
this.splitContainer3.Location = new System.Drawing.Point(0, 0);
this.splitContainer3.Name = "splitContainer3";
this.splitContainer3.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer3.Panel1
//
this.splitContainer3.Panel1.Controls.Add(this.lblProgressValue);
this.splitContainer3.Panel1.Controls.Add(this.pbarCollectionSize);
this.splitContainer3.Panel1.Controls.Add(this.btnGetCollectionSizeStart);
this.splitContainer3.Panel1.Controls.Add(this.tboxEquipmentID);
this.splitContainer3.Panel1.Controls.Add(this.btnEquipmentFind);
//
// splitContainer3.Panel2
//
this.splitContainer3.Panel2.Controls.Add(this.tree);
this.splitContainer3.Size = new System.Drawing.Size(375, 418);
this.splitContainer3.SplitterDistance = 75;
this.splitContainer3.TabIndex = 1;
//
// btnGetCollectionSizeStart
//
this.btnGetCollectionSizeStart.Location = new System.Drawing.Point(298, 34);
this.btnGetCollectionSizeStart.Name = "btnGetCollectionSizeStart";
this.btnGetCollectionSizeStart.Size = new System.Drawing.Size(73, 21);
this.btnGetCollectionSizeStart.TabIndex = 2;
this.btnGetCollectionSizeStart.Text = "Start";
//
// tboxEquipmentID
//
this.tboxEquipmentID.Location = new System.Drawing.Point(10, 9);
this.tboxEquipmentID.Name = "tboxEquipmentID";
this.tboxEquipmentID.Size = new System.Drawing.Size(282, 20);
this.tboxEquipmentID.TabIndex = 1;
//
// btnEquipmentFind
//
this.btnEquipmentFind.Location = new System.Drawing.Point(298, 8);
this.btnEquipmentFind.Name = "btnEquipmentFind";
this.btnEquipmentFind.Size = new System.Drawing.Size(73, 21);
this.btnEquipmentFind.TabIndex = 0;
this.btnEquipmentFind.Text = "Find";
//
// tree
//
this.tree.Dock = System.Windows.Forms.DockStyle.Fill;
this.tree.Location = new System.Drawing.Point(0, 0);
this.tree.Name = "tree";
this.tree.Size = new System.Drawing.Size(375, 339);
this.tree.SpacingBetweenNodes = -1;
this.tree.TabIndex = 0;
//
// splitContainer2
//
this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
this.splitContainer2.IsSplitterFixed = true;
this.splitContainer2.Location = new System.Drawing.Point(0, 0);
this.splitContainer2.Name = "splitContainer2";
this.splitContainer2.Orientation = System.Windows.Forms.Orientation.Horizontal;
//
// splitContainer2.Panel1
//
this.splitContainer2.Panel1.Controls.Add(this.panel2);
//
// splitContainer2.Panel2
//
this.splitContainer2.Panel2.Controls.Add(this.grid);
this.splitContainer2.Size = new System.Drawing.Size(415, 418);
this.splitContainer2.SplitterDistance = 75;
this.splitContainer2.TabIndex = 2;
//
// panel2
//
this.panel2.Controls.Add(this.radLabel2);
this.panel2.Controls.Add(this.radLabel1);
this.panel2.Controls.Add(this.btnRefresh);
this.panel2.Controls.Add(this.dpEnd);
this.panel2.Controls.Add(this.dpStart);
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(415, 75);
this.panel2.TabIndex = 0;
//
// radLabel2
//
this.radLabel2.AutoSize = false;
this.radLabel2.Location = new System.Drawing.Point(3, 37);
this.radLabel2.Name = "radLabel2";
this.radLabel2.Size = new System.Drawing.Size(100, 18);
this.radLabel2.TabIndex = 8;
this.radLabel2.Text = "End Date : ";
this.radLabel2.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
//
// radLabel1
//
this.radLabel1.AutoSize = false;
this.radLabel1.Location = new System.Drawing.Point(3, 11);
this.radLabel1.Name = "radLabel1";
this.radLabel1.Size = new System.Drawing.Size(100, 18);
this.radLabel1.TabIndex = 7;
this.radLabel1.Text = "Start Date : ";
this.radLabel1.TextAlignment = System.Drawing.ContentAlignment.MiddleRight;
//
// btnRefresh
//
this.btnRefresh.Location = new System.Drawing.Point(294, 10);
this.btnRefresh.Name = "btnRefresh";
this.btnRefresh.Size = new System.Drawing.Size(110, 20);
this.btnRefresh.TabIndex = 4;
this.btnRefresh.Text = "Refresh";
//
// dpEnd
//
this.dpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Short;
this.dpEnd.Location = new System.Drawing.Point(109, 36);
this.dpEnd.Name = "dpEnd";
this.dpEnd.Size = new System.Drawing.Size(179, 20);
this.dpEnd.TabIndex = 2;
this.dpEnd.TabStop = false;
this.dpEnd.Text = "2024-03-28";
this.dpEnd.Value = new System.DateTime(2024, 3, 28, 11, 24, 49, 907);
//
// dpStart
//
this.dpStart.Location = new System.Drawing.Point(109, 10);
this.dpStart.Name = "dpStart";
this.dpStart.Size = new System.Drawing.Size(179, 20);
this.dpStart.TabIndex = 0;
this.dpStart.TabStop = false;
this.dpStart.Text = "2024년 3월 28일 목요일";
this.dpStart.Value = new System.DateTime(2024, 3, 28, 11, 24, 49, 907);
//
// statusStrip
//
this.statusStrip.Items.AddRange(new Telerik.WinControls.RadItem[] {
this.ssName,
this.ssStatus01,
this.ssStatus02,
this.ssMessage});
this.statusStrip.Location = new System.Drawing.Point(0, 424);
this.statusStrip.Name = "statusStrip";
this.statusStrip.Size = new System.Drawing.Size(800, 26);
this.statusStrip.TabIndex = 1;
//
// ssName
//
this.ssName.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
this.ssName.Name = "ssName";
this.statusStrip.SetSpring(this.ssName, false);
this.ssName.Text = "Collection";
this.ssName.TextWrap = true;
//
// ssStatus01
//
this.ssStatus01.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
this.ssStatus01.BorderHighlightThickness = 2;
this.ssStatus01.BorderVisible = false;
this.ssStatus01.Name = "ssStatus01";
this.ssStatus01.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.statusStrip.SetSpring(this.ssStatus01, false);
this.ssStatus01.Text = "수집시간";
this.ssStatus01.TextWrap = true;
//
// ssStatus02
//
this.ssStatus02.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
this.ssStatus02.BorderVisible = false;
this.ssStatus02.FlipText = false;
this.ssStatus02.Name = "ssStatus02";
this.statusStrip.SetSpring(this.ssStatus02, false);
this.ssStatus02.Text = "출력시간";
this.ssStatus02.TextWrap = true;
//
// ssMessage
//
this.ssMessage.Alignment = System.Drawing.ContentAlignment.MiddleLeft;
this.ssMessage.Name = "ssMessage";
this.statusStrip.SetSpring(this.ssMessage, false);
this.ssMessage.Text = "";
this.ssMessage.TextWrap = true;
//
// pbarCollectionSize
//
this.pbarCollectionSize.Location = new System.Drawing.Point(10, 34);
this.pbarCollectionSize.Name = "pbarCollectionSize";
this.pbarCollectionSize.Size = new System.Drawing.Size(282, 21);
this.pbarCollectionSize.TabIndex = 3;
//
// lblProgressValue
//
this.lblProgressValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.lblProgressValue.BackColor = System.Drawing.Color.Transparent;
this.lblProgressValue.Location = new System.Drawing.Point(99, 57);
this.lblProgressValue.Name = "lblProgressValue";
this.lblProgressValue.Size = new System.Drawing.Size(194, 18);
this.lblProgressValue.TabIndex = 4;
this.lblProgressValue.Text = "label1";
this.lblProgressValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// grid
//
this.grid.BackColor = System.Drawing.SystemColors.ControlLightLight;
this.grid.ColumnResizeKey = System.Windows.Forms.Keys.F6;
this.grid.Dock = System.Windows.Forms.DockStyle.Fill;
this.grid.Location = new System.Drawing.Point(0, 0);
this.grid.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
//
//
//
this.grid.MasterTemplate.ViewDefinition = tableViewDefinition4;
this.grid.Name = "grid";
//
//
//
this.grid.RootElement.ControlBounds = new System.Drawing.Rectangle(0, 0, 240, 150);
this.grid.Size = new System.Drawing.Size(415, 339);
this.grid.TabIndex = 1;
//
// FrmFDCMongo
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.panel1);
this.Controls.Add(this.statusStrip);
this.Name = "FrmFDCMongo";
this.Text = "FrmFDC";
this.panel1.ResumeLayout(false);
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
this.splitContainer1.ResumeLayout(false);
this.splitContainer3.Panel1.ResumeLayout(false);
this.splitContainer3.Panel1.PerformLayout();
this.splitContainer3.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer3)).EndInit();
this.splitContainer3.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.btnGetCollectionSizeStart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tboxEquipmentID)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.btnEquipmentFind)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.tree)).EndInit();
this.splitContainer2.Panel1.ResumeLayout(false);
this.splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
this.splitContainer2.ResumeLayout(false);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.radLabel2)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.radLabel1)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.btnRefresh)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dpEnd)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dpStart)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.statusStrip)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.grid.MasterTemplate)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.grid)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.SplitContainer splitContainer1;
private Telerik.WinControls.UI.RadTreeView tree;
private System.Windows.Forms.SplitContainer splitContainer2;
private JWH.CONTROL.GridViewEx grid;
private System.Windows.Forms.SplitContainer splitContainer3;
private System.Windows.Forms.Panel panel2;
private Telerik.WinControls.UI.RadDateTimePicker dpEnd;
private Telerik.WinControls.UI.RadDateTimePicker dpStart;
private Telerik.WinControls.UI.RadButton btnRefresh;
private Telerik.WinControls.UI.RadStatusStrip statusStrip;
private Telerik.WinControls.UI.RadLabelElement ssName;
private Telerik.WinControls.UI.RadLabelElement ssStatus01;
private Telerik.WinControls.UI.RadLabelElement ssStatus02;
private Telerik.WinControls.UI.RadLabelElement ssMessage;
private Telerik.WinControls.UI.RadTextBox tboxEquipmentID;
private Telerik.WinControls.UI.RadButton btnEquipmentFind;
private Telerik.WinControls.UI.RadLabel radLabel2;
private Telerik.WinControls.UI.RadLabel radLabel1;
private Telerik.WinControls.UI.RadButton btnGetCollectionSizeStart;
private System.Windows.Forms.ProgressBar pbarCollectionSize;
private System.Windows.Forms.Label lblProgressValue;
}
}

View File

@@ -0,0 +1,387 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;
using System.Windows.Forms;
using JWH;
using JWH.MONGODB;
using MongoDB.Bson;
using Telerik.WinControls.Data;
using Telerik.WinControls.UI;
using static JWH.MONGODB.FDCMongoDB;
namespace DDUtilityApp.MONGO
{
public partial class FrmFDCMongo : Form
{
public string EquipmentID { get; set; } = string.Empty;
public string VID { get; set; } = string.Empty;
public DateTime DateTimeStart { get; set; } = DateTime.Now.Date;
public DateTime DateTimeEnd { get; set; } = DateTime.Now.AddDays(1).Date;
public FrmFDCMongo()
{
InitializeComponent();
this.SetLayout();
this.SetEventHandler();
}
private void SetLayout()
{
this.Text = $"FDC MongoDB";
this.dpStart.CustomFormat = "yyyy-MM-dd HH:mm";
this.dpStart.Format = DateTimePickerFormat.Custom;
this.dpStart.Value = this.DateTimeStart;
this.dpEnd.CustomFormat = "yyyy-MM-dd HH:mm";
this.dpEnd.Format = DateTimePickerFormat.Custom;
this.dpEnd.Value = this.DateTimeEnd;
this.pbarCollectionSize.Visible = false;
this.lblProgressValue.Visible = false;
this.tree.ShowLines = true;
this.tree.ShowRootLines = true;
this.GridSetting();
}
private void SetEventHandler()
{
this.Shown += this.FrmFDC_Shown;
this.tboxEquipmentID.KeyDown += this.TboxEquipmentID_KeyDown;
this.btnEquipmentFind.Click += this.BtnEquipmentFind_Click;
this.dpStart.ValueChanged += this.DpStart_ValueChanged;
this.dpEnd.ValueChanged += this.DpEnd_ValueChanged;
this.btnRefresh.Click += this.BtnRefresh_Click;
this.btnGetCollectionSizeStart.Click += this.BtnGetCollectionSizeStart_Click;
this.tree.SelectedNodeChanged += this.Tree_SelectedNodeChanged;
}
#region [ Event ] =====================================================
private void FrmFDC_Shown(object sender, EventArgs e)
{
this.SetTree();
if (string.IsNullOrEmpty(this.EquipmentID)) return;
this.tboxEquipmentID.Text = this.EquipmentID;
this.dpStart.Value = this.DateTimeStart;
this.dpEnd.Value = this.DateTimeEnd;
this.BtnEquipmentFind_Click(null, null);
}
private void DpStart_ValueChanged(object sender, EventArgs e)
{
this.DateTimeStart = this.dpStart.Value;
}
private void DpEnd_ValueChanged(object sender, EventArgs e)
{
this.DateTimeEnd = this.dpEnd.Value;
}
private void BtnRefresh_Click(object sender, EventArgs e)
{
DateTime timeStart = DateTime.Now;
List<TraceCollection> data = null;
try
{
this.Cursor = Cursors.WaitCursor;
this.ssName.Text = "GRID";
DateTime dtStart = this.DateTimeStart;
DateTime dtEnd = this.DateTimeEnd;
data = FDCMongoDB.GetCollectionData($"{this.EquipmentID}.{this.VID}", dtStart, dtEnd);
timeStart = this.StatusLabelDisplay(this.ssStatus01, "수집", timeStart, DateTime.Now);
this.grid.AutoBinding(data.ToArray());
}
catch (Exception ex)
{
throw ex;
}
finally
{
this.StatusLabelDisplay(this.ssStatus02, "출력", timeStart, DateTime.Now);
this.ssMessage.Text = $"RowCount is {data?.Count.ToString("#,##0")}";
this.Cursor = Cursors.Default;
}
}
private void TboxEquipmentID_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Enter)
this.BtnEquipmentFind_Click(null, null);
}
private void BtnEquipmentFind_Click(object sender, EventArgs e)
{
RadTreeNode node = this.tree.Find(x => x.Name.StartsWith(this.tboxEquipmentID.Text));
if (node != null)
{
this.tree.ClearSelection();
node.Selected = true;
node.ExpandAll();
}
}
private void BtnGetCollectionSizeStart_Click(object sender, EventArgs e)
{
if (FDCMongoDB.GetCollectionSize_Flag)
{
this.GetCollectionSize_Complete();
return;
}
SaveFileDialog dlg = new SaveFileDialog();
dlg.Title = "FDC Collection Infomation";
dlg.Filter = "CSV|*.csv";
dlg.FilterIndex = 0;
dlg.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
dlg.FileName = $"FDC_Collection-{DateTime.Now.ToString("yyyyMMddHHmm")}.csv";
if (dlg.ShowDialog() != DialogResult.OK) return;
this.lblProgressValue.Text = "";
this.lblProgressValue.Visible = true;
this.pbarCollectionSize.Visible = true;
this.btnGetCollectionSizeStart.Text = "Stop";
FDCMongoDB.GetCollectionSize(dlg.FileName, this.GetCollectionSize_Complete, this.pbarCollectionSize, this.lblProgressValue);
}
private void GetCollectionSize_Complete(string filename = "")
{
FDCMongoDB.GetCollectionSize_Flag = false;
this.btnGetCollectionSizeStart.Text = "Start";
this.pbarCollectionSize.Visible = false;
this.lblProgressValue.Visible = false;
if (string.IsNullOrEmpty(filename)) return;
Process.Start(filename);
}
#endregion
#region [ Method ] ====================================================
private DateTime StatusLabelDisplay(RadLabelElement control, string name, DateTime start, DateTime end)
{
TimeSpan span = end.Subtract(start);
StringBuilder sb = new StringBuilder();
if (!string.IsNullOrEmpty(name)) sb.Append($"{name} ");
sb.Append($"[{span.Seconds}.{span.Milliseconds.ToString("D3")}sec] ");
sb.Append($"{start.ToString("HH:mm:ss.fff")}~{end.ToString("HH:mm:ss.fff")}");
control.Text = sb.ToString();
return end;
}
#endregion
#region [ Tree: Equipment & VID List ] ================================
private void SetTree()
{
DateTime timeStart = DateTime.Now;
SortedDictionary<string, List<string>> dicEquipment = new SortedDictionary<string, List<string>>();
try
{
this.Cursor = Cursors.WaitCursor;
this.ssName.Text = "TREE";
timeStart = DateTime.Now;
List<BsonDocument> lst = FDCMongoDB.GetListCollection();
timeStart = this.StatusLabelDisplay(this.ssStatus01, "수집", timeStart, DateTime.Now);
foreach (BsonDocument doc in lst)
{
string[] values = doc.GetElement("name").Value.ToString().Split(new char[] { '=', '.' });
if (values.Length != 2)
{
XLogger.Instance.Error($"Split Fail: {doc.GetElement(0)}");
continue;
}
string name = values[0];
string vid = values[1];
if (!dicEquipment.ContainsKey(name))
dicEquipment[name] = new List<string>();
dicEquipment[name].Add(vid);
}
DataTable dt = this.GetMesEquipment();
this.tree.Nodes.Clear();
foreach (string equipmentID in dicEquipment.Keys)
{
string text = equipmentID;
RadTreeNode nodeParent = null;
DataRow[] drEquipmnet = dt.Select($"EQUIPMENTID='{equipmentID}'");
if (drEquipmnet?.Length > 0)
{
string facilityName = drEquipmnet[0]["FACILITYNAME"].ToString();
string equipmentName = drEquipmnet[0]["DESCRIPTION"].ToString();
string segmentID = drEquipmnet[0]["PROCESSSEGMENTID"].ToString();
string segmentName = drEquipmnet[0]["PROCESSSEGMENTNAME"].ToString();
if (!this.tree.Nodes.Contains(facilityName))
this.tree.Nodes.Add(facilityName).Name = facilityName;
nodeParent = this.tree.Nodes[facilityName];
//if (!nodeParent.Nodes.Contains(segmentID))
// nodeParent.Nodes.Add($"[{segmentID}] {segmentName}").Name = segmentID;
//nodeParent = nodeParent.Nodes[segmentID];
text = $"[{equipmentID}] {equipmentName}({dicEquipment[equipmentID].Count})";
}
RadTreeNode node = new RadTreeNode(text);
node.Name = equipmentID;
if (nodeParent != null) nodeParent.Nodes.Add(node);
else this.tree.Nodes.Add(node);
foreach (string vid in dicEquipment[equipmentID])
{
RadTreeNode nodeVID = node.Nodes.Add(vid);
nodeVID.Name = $"{equipmentID}.{vid}";
nodeVID.Tag = $"{equipmentID}.{vid}";
}
}
this.tree.SortOrder = System.Windows.Forms.SortOrder.Ascending;
}
catch (Exception ex)
{
throw ex;
}
finally
{
this.StatusLabelDisplay(this.ssStatus02, "출력", timeStart, DateTime.Now);
this.ssMessage.Text = $"Equipment is {dicEquipment.Count.ToString("#,##0")}";
this.Cursor = Cursors.Default;
}
}
private DataTable GetMesEquipment()
{
SqlConnection sqlConnection = null;
DataSet ds = null;
DataTable dt = null;
try
{
string connectionString = string.Empty;
StringBuilder query = new StringBuilder();
query.AppendLine($" SELECT A.SITEID, ");
query.AppendLine($" A.FACILITYID, ");
query.AppendLine($" D.FACILITYNAME, ");
query.AppendLine($" B.PROCESSSEGMENTID, ");
query.AppendLine($" B.PROCESSSEGMENTNAME, ");
query.AppendLine($" A.SUBCATEGORY, ");
query.AppendLine($" C.EQUIPMENTID AS MAINEQUIPMENTID, ");
query.AppendLine($" C.EQUIPMENTNAME AS MAINEQUIPMENTNAME, ");
query.AppendLine($" A.EQUIPMENTID, ");
query.AppendLine($" A.EQUIPMENTNAME, ");
query.AppendLine($" A.DESCRIPTION, ");
query.AppendLine($" A.OPERATIONMODE, ");
query.AppendLine($" A.CONTROLMODE, ");
query.AppendLine($" A.LASTTRACKINLOTID, ");
query.AppendLine($" A.LASTTRACKOUTLOTID, ");
query.AppendLine($" A.MAKER, ");
query.AppendLine($" A.EQPSTATE, ");
query.AppendLine($" A.LOCATION ");
query.AppendLine($" FROM CIM_EQUIPMENT A (nolock) ");
query.AppendLine($" INNER JOIN CIM_PROCESSSEGMENT B (nolock) ON A.PROCESSSEGMENTID = B.PROCESSSEGMENTID AND A.SITEID = B.SITEID ");
query.AppendLine($" INNER JOIN CIM_EQUIPMENT C (nolock) ON A.PARENTID = C.EQUIPMENTID AND A.SITEID = C.SITEID ");
query.AppendLine($" INNER JOIN CIM_FACILITY D (nolock) ON A.PHYSICALLOCATION = D.FACILITYID AND a.SITEID = d.SITEID ");
query.AppendLine($" WHERE A.SITEID='1130' ");
connectionString = $@"server=192.168.8.232;database=ddmes;uid=DDB2MESAdmin;pwd=Yhqe4csJXJ4W5$%;";
sqlConnection = new SqlConnection();
sqlConnection.ConnectionString = connectionString;
sqlConnection.Open();
SqlCommand sqlCommand = new SqlCommand();
sqlCommand.Connection = sqlConnection;
sqlCommand.CommandType = CommandType.Text;
sqlCommand.CommandText = query.ToString();
ds = new DataSet();
SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlCommand);
sqlAdapter.Fill(ds);
sqlConnection.Close();
if (ds != null && ds.Tables.Count > 0) dt = ds.Tables[0];
return dt;
}
catch (Exception ex)
{
XLogger.Instance.Fatal(ex);
return null;
}
finally
{
if (sqlConnection != null && sqlConnection.State != ConnectionState.Closed)
{
sqlConnection.Close();
sqlConnection.Dispose();
}
}
}
private void Tree_SelectedNodeChanged(object sender, RadTreeViewEventArgs e)
{
if (e.Node == null || e.Node.Tag == null) return;
string[] values = e.Node.Tag.ToString().Split('.');
if (values.Length != 2) return;
this.EquipmentID = values[0];
this.VID = values[1];
this.BtnRefresh_Click(null, null);
}
#endregion
#region [ Grid: TraceCollection ] =====================================
private void GridSetting()
{
this.grid.MultiSelect = true;
this.grid.Columns.Clear();
this.grid.TableElement.RowHeight = 20;
this.grid.HeaderTextToTitleCase = false;
this.grid.AddColumn("EVENTTIME", "EventTime");
this.grid.AddColumn("VIDName");
this.grid.AddColumn("Value");
this.grid.AddColumn("LotID");
this.grid.AddColumn("MaterialID");
this.grid.AddColumn("ProductID");
this.grid.AddColumn("Recipe");
this.grid.AddColumn("UnitNO");
this.grid.AddColumn("ProcessID");
this.grid.AddColumn("VORNR");
this.grid.AddColumn("UnitState");
this.grid.AddColumn("Sign");
}
#endregion
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>