private void bbtnStart_Click(object sender, EventArgs e) { BISTel.PeakPerformance.Client.CommonUtil.GZip gZip = new BISTel.PeakPerformance.Client.CommonUtil.GZip(); FarPoint.Win.Spread.CellType.TextCellType tc = new FarPoint.Win.Spread.CellType.TextCellType(); pgBarModel.Value = 0; pgBarData.Value = 0; pgBarDataTemp.Value = 0; pgBarOOC.Value = 0; pgBarModelContext.Value = 0; string _startDate = BISTel.eSPC.Page.Common.CommonPageUtil.StartDate(StartDate.Value.ToString()); string _endDate = BISTel.eSPC.Page.Common.CommonPageUtil.EndDate(EndDate.Value.ToString()); if (this.bsprData.ActiveSheet.RowCount > 0) { if (this.srtLstProductID.Count > 0) { pgBarModel.Maximum = this.bsprData.ActiveSheet.RowCount; for (int i = 0; i < this.bsprData.ActiveSheet.RowCount; i++) { pgBarData.Value = 0; pgBarDataTemp.Value = 0; pgBarOOC.Value = 0; pgBarModelContext.Value = 0; this.bsprBLOBData.ClearHead(); this.bsprBLOBData.AddHeadComplete(); this.bsprBLOBData.UseSpreadEdit = false; this.bsprBLOBData.AutoGenerateColumns = true; this.bsprBLOBData.UseAutoSort = false; this.bsprTempTrxData.ClearHead(); this.bsprTempTrxData.AddHeadComplete(); this.bsprTempTrxData.UseSpreadEdit = false; this.bsprTempTrxData.AutoGenerateColumns = true; this.bsprTempTrxData.UseAutoSort = false; this.bsprOOCTRXData.ClearHead(); this.bsprOOCTRXData.AddHeadComplete(); this.bsprOOCTRXData.UseSpreadEdit = false; this.bsprOOCTRXData.AutoGenerateColumns = true; this.bsprOOCTRXData.UseAutoSort = false; this.bsprContextMSTData.ClearHead(); this.bsprContextMSTData.AddHeadComplete(); this.bsprContextMSTData.UseSpreadEdit = false; this.bsprContextMSTData.AutoGenerateColumns = true; this.bsprContextMSTData.UseAutoSort = false; this.bsprData.ActiveSheet.Rows[i].BackColor = Color.Yellow; Thread.Sleep(50); Application.DoEvents(); string _sModelConfigRawid = this.bsprData.ActiveSheet.Cells[i, 0].Text.ToString(); LinkedList lnkListTemp = new LinkedList(); lnkListTemp.Add("MODEL_CONFIG_RAWID", _sModelConfigRawid); lnkListTemp.Add("START_DTTS", _startDate); lnkListTemp.Add("END_DTTS", _endDate); #region DATA_TRX_SPC BLOB안에 PRODUCT_ID 바꾸기 DataSet _dsTemp = this._wsSPC.GetSPCBLOBData(lnkListTemp.GetSerialData()); this.bsprBLOBData.DataSource = _dsTemp; if (_dsTemp.Tables[0].Rows.Count > 0) { pgBarData.Maximum = this.bsprBLOBData.ActiveSheet.RowCount; this.bsprBLOBData.ActiveSheet.Cells[0, 0, this.bsprBLOBData.ActiveSheet.RowCount - 1, this.bsprBLOBData.ActiveSheet.ColumnCount - 1].CellType = tc; for (int j = 0; j < this.bsprBLOBData.ActiveSheet.RowCount; j++) { string _sDataRawid = this.bsprBLOBData.ActiveSheet.Cells[j, 0].Text.ToString(); this.bsprBLOBData.ActiveSheet.Rows[j].BackColor = Color.Yellow; Thread.Sleep(50); Application.DoEvents(); //BLOB안에 DATA를 바꾸자. object File_Data = _dsTemp.Tables[0].Rows[j][COLUMN.FILE_DATA]; //StreamReader sr = gZip.DecompressForStream(File_Data); StreamReader sr = CommonUtility.ConvertBLOBToStreamReader(File_Data); string _sline = string.Empty; StringBuilder sbFileData = new StringBuilder(); while (sr.Peek() > -1) { _sline = sr.ReadLine(); if (_sline.IndexOf("PRODUCT_ID") == 0) { string[] strArrTemp = _sline.Split('\t'); for (int k = 0; k < this.srtLstProductID.Count; k++) { string sTempKey = this.srtLstProductID.GetKey(k).ToString(); string sTempValue = this.srtLstProductID.GetByIndex(k).ToString(); for (int idxTemp = 0; idxTemp < strArrTemp.Length; idxTemp++) { if (strArrTemp[idxTemp].Equals(sTempKey)) { strArrTemp[idxTemp] = sTempValue; } } } _sline = ""; for (int idxTemp_1 = 0; idxTemp_1 < strArrTemp.Length; idxTemp_1++) { _sline += "\t" + strArrTemp[idxTemp_1]; } _sline = _sline.Substring(1); } sbFileData.AppendLine(_sline); } string _sFileData = sbFileData.ToString(); byte[] btBlob = Encoding.Default.GetBytes(_sFileData); MemoryStream msDestination = new MemoryStream(btBlob.Length); GZipStream compressedzipStream = new GZipStream(msDestination, CompressionMode.Compress, true); compressedzipStream.Write(btBlob, 0, btBlob.Length); compressedzipStream.Close(); msDestination.Position = 0; btBlob = new byte[msDestination.Length]; msDestination.Read(btBlob, 0, (int)msDestination.Length); LinkedList fieldData = new LinkedList(); fieldData.Add("RAWID", _sDataRawid); fieldData.Add("FILE_DATA", btBlob); bool bResult = this._wsSPC.ModifySPCBLOBData(fieldData.GetSerialData()); if (!bResult) { MSGHandler.DisplayMessage(MSGType.Error, "SPC_INFO_ERROR_PARSING", null, null); return; } this.bsprBLOBData.ActiveSheet.Rows[j].BackColor = Color.LightGreen; pgBarData.Increment(1); Thread.Sleep(50); Application.DoEvents(); } } else { pgBarData.Maximum = 1; pgBarData.Value = 1; } #endregion #region DATA_TEMP_TRX_SPC안에 PRODUCT_ID 바꾸기 DataSet _dsTempTrx = this._wsSPC.GetSPCTempTrxData(lnkListTemp.GetSerialData()); if (_dsTempTrx != null && _dsTempTrx.Tables != null && _dsTempTrx.Tables[0].Rows.Count > 0) { this.bsprTempTrxData.DataSource = _dsTempTrx; pgBarDataTemp.Maximum = this.bsprTempTrxData.ActiveSheet.RowCount; this.bsprTempTrxData.ActiveSheet.Cells[0, 0, this.bsprTempTrxData.ActiveSheet.RowCount - 1, this.bsprTempTrxData.ActiveSheet.ColumnCount - 1].CellType = tc; for (int j = 0; j < this.bsprTempTrxData.ActiveSheet.RowCount; j++) { string _sDataRawid = this.bsprTempTrxData.ActiveSheet.Cells[j, 0].Text.ToString(); this.bsprTempTrxData.ActiveSheet.Rows[j].BackColor = Color.Yellow; Thread.Sleep(50); Application.DoEvents(); //CLOB안에 DATA를 바꾸자. string sContext_List = _dsTempTrx.Tables[0].Rows[j][COLUMN.CONTEXT_LIST].ToString(); if (sContext_List.IndexOf("PRODUCT_ID") > -1) { string[] strArrTemp = sContext_List.Split('\t'); for (int idxTemp = 0; idxTemp < strArrTemp.Length; idxTemp++) { if (strArrTemp[idxTemp].Split('=').Length > 1) { if (strArrTemp[idxTemp].Split('=')[0].Equals("PRODUCT_ID")) { if (this.srtLstProductID.Contains(strArrTemp[idxTemp].Split('=')[1])) { int _idxOfKey = this.srtLstProductID.IndexOfKey(strArrTemp[idxTemp].Split('=')[1]); string sTempKey = this.srtLstProductID.GetKey(_idxOfKey).ToString(); string sTempValue = this.srtLstProductID.GetByIndex(_idxOfKey).ToString(); strArrTemp[idxTemp] = strArrTemp[idxTemp].Replace(sTempKey, sTempValue); } } else if (strArrTemp[idxTemp].Split('=')[0].Equals("CONTEXT_KEY")) { string[] strContextKeyValueTemp = strArrTemp[idxTemp].Split('=')[1].Split(';'); if (strContextKeyValueTemp.Length > 0) { for (int _iTemp = 0; _iTemp < strContextKeyValueTemp.Length; _iTemp++) { if (this.srtLstProductID.Contains(strContextKeyValueTemp[_iTemp])) { strContextKeyValueTemp[_iTemp] = this.srtLstProductID[strContextKeyValueTemp[_iTemp]].ToString(); } } string _sTemp = ""; for (int _idx = 0; _idx < strContextKeyValueTemp.Length; _idx++) { _sTemp += ";" + strContextKeyValueTemp[_idx]; } _sTemp = _sTemp.Substring(1); strArrTemp[idxTemp] = "CONTEXT_KEY=" + _sTemp; } } } } sContext_List = ""; for (int idxTemp_1 = 0; idxTemp_1 < strArrTemp.Length; idxTemp_1++) { sContext_List += "\t" + strArrTemp[idxTemp_1]; } sContext_List = sContext_List.Substring(1); } LinkedList fieldData = new LinkedList(); fieldData.Add("RAWID", _sDataRawid); fieldData.Add("CONTEXT_LIST", sContext_List); bool bResult = this._wsSPC.ModifySPCTempTrxData(fieldData.GetSerialData()); if (!bResult) { MSGHandler.DisplayMessage(MSGType.Error, "SPC_INFO_ERROR_PARSING", null, null); return; } this.bsprTempTrxData.ActiveSheet.Rows[j].BackColor = Color.LightGreen; pgBarDataTemp.Increment(1); Thread.Sleep(50); Application.DoEvents(); } } else { pgBarDataTemp.Maximum = 1; pgBarDataTemp.Value = 1; } #endregion #region OOC_TRX_SPC 안에 PRODUCT_ID 바꾸기 DataSet _dsTempOOCTrx = this._wsSPC.GetSPCOOCData(lnkListTemp.GetSerialData()); if (_dsTempOOCTrx != null && _dsTempOOCTrx.Tables != null && _dsTempOOCTrx.Tables[0].Rows.Count > 0) { this.bsprOOCTRXData.DataSource = _dsTempOOCTrx; pgBarOOC.Maximum = this.bsprOOCTRXData.ActiveSheet.RowCount; this.bsprOOCTRXData.ActiveSheet.Cells[0, 0, this.bsprOOCTRXData.ActiveSheet.RowCount - 1, this.bsprOOCTRXData.ActiveSheet.ColumnCount - 1].CellType = tc; for (int j = 0; j < this.bsprOOCTRXData.ActiveSheet.RowCount; j++) { string _sDataRawid = this.bsprOOCTRXData.ActiveSheet.Cells[j, 0].Text.ToString(); this.bsprOOCTRXData.ActiveSheet.Rows[j].BackColor = Color.Yellow; Thread.Sleep(50); Application.DoEvents(); //CLOB안에 DATA를 바꾸자. string sContext_List = _dsTempOOCTrx.Tables[0].Rows[j][COLUMN.CONTEXT_LIST].ToString(); if (sContext_List.IndexOf("PRODUCT_ID") > -1) { string[] strArrTemp = sContext_List.Split('\t'); for (int idxTemp = 0; idxTemp < strArrTemp.Length; idxTemp++) { if (strArrTemp[idxTemp].Split('=').Length > 1) { if (strArrTemp[idxTemp].Split('=')[0].Equals("PRODUCT_ID")) { if (this.srtLstProductID.Contains(strArrTemp[idxTemp].Split('=')[1])) { int _idxOfKey = this.srtLstProductID.IndexOfKey(strArrTemp[idxTemp].Split('=')[1]); string sTempKey = this.srtLstProductID.GetKey(_idxOfKey).ToString(); string sTempValue = this.srtLstProductID.GetByIndex(_idxOfKey).ToString(); strArrTemp[idxTemp] = strArrTemp[idxTemp].Replace(sTempKey, sTempValue); } } else if (strArrTemp[idxTemp].Split('=')[0].Equals("CONTEXT_KEY")) { string[] strContextKeyValueTemp = strArrTemp[idxTemp].Split('=')[1].Split(';'); if (strContextKeyValueTemp.Length > 0) { for (int _iTemp = 0; _iTemp < strContextKeyValueTemp.Length; _iTemp++) { if (this.srtLstProductID.Contains(strContextKeyValueTemp[_iTemp])) { strContextKeyValueTemp[_iTemp] = this.srtLstProductID[strContextKeyValueTemp[_iTemp]].ToString(); } } string _sTemp = ""; for (int _idx = 0; _idx < strContextKeyValueTemp.Length; _idx++) { _sTemp += ";" + strContextKeyValueTemp[_idx]; } _sTemp = _sTemp.Substring(1); strArrTemp[idxTemp] = "CONTEXT_KEY=" + _sTemp; } } } } sContext_List = ""; for (int idxTemp_1 = 0; idxTemp_1 < strArrTemp.Length; idxTemp_1++) { sContext_List += "\t" + strArrTemp[idxTemp_1]; } sContext_List = sContext_List.Substring(1); } LinkedList fieldData = new LinkedList(); fieldData.Add("RAWID", _sDataRawid); fieldData.Add("CONTEXT_LIST", sContext_List); bool bResult = this._wsSPC.ModifySPCOOCData(fieldData.GetSerialData()); if (!bResult) { MSGHandler.DisplayMessage(MSGType.Error, "SPC_INFO_ERROR_PARSING", null, null); return; } this.bsprOOCTRXData.ActiveSheet.Rows[j].BackColor = Color.LightGreen; pgBarOOC.Increment(1); Thread.Sleep(50); Application.DoEvents(); } } else { pgBarOOC.Maximum = 1; pgBarOOC.Value = 1; } #endregion #region MODEL_CONTEXT_MST_SPC 안에 PRODUCT_ID 바꾸기 DataSet _dsTempModelContext = this._wsSPC.GetSPCModelContextData(lnkListTemp.GetSerialData()); if (_dsTempModelContext != null && _dsTempModelContext.Tables != null && _dsTempModelContext.Tables[0].Rows.Count > 0) { this.bsprContextMSTData.DataSource = _dsTempModelContext; pgBarModelContext.Maximum = this.bsprContextMSTData.ActiveSheet.RowCount; this.bsprContextMSTData.ActiveSheet.Cells[0, 0, this.bsprContextMSTData.ActiveSheet.RowCount - 1, this.bsprContextMSTData.ActiveSheet.ColumnCount - 1].CellType = tc; for (int j = 0; j < this.bsprContextMSTData.ActiveSheet.RowCount; j++) { string _sDataRawid = this.bsprContextMSTData.ActiveSheet.Cells[j, 0].Text.ToString(); this.bsprContextMSTData.ActiveSheet.Rows[j].BackColor = Color.Yellow; Thread.Sleep(50); Application.DoEvents(); //CONTEXT_VALUE안에 DATA를 바꾸자. string sContext_Value = _dsTempModelContext.Tables[0].Rows[j][COLUMN.CONTEXT_VALUE].ToString(); string[] strArrTemp = sContext_Value.Split(';'); for (int idxTemp = 0; idxTemp < strArrTemp.Length; idxTemp++) { if (this.srtLstProductID.Contains(strArrTemp[idxTemp])) { string sTempValue = this.srtLstProductID[strArrTemp[idxTemp]].ToString(); strArrTemp[idxTemp] = sTempValue; } } sContext_Value = ""; for (int idxTemp_1 = 0; idxTemp_1 < strArrTemp.Length; idxTemp_1++) { sContext_Value += ";" + strArrTemp[idxTemp_1]; } sContext_Value = sContext_Value.Substring(1); LinkedList fieldData = new LinkedList(); fieldData.Add("RAWID", _sDataRawid); fieldData.Add("CONTEXT_VALUE", sContext_Value); bool bResult = this._wsSPC.ModifySPCModelContextData(fieldData.GetSerialData()); if (!bResult) { MSGHandler.DisplayMessage(MSGType.Error, "SPC_INFO_ERROR_PARSING", null, null); return; } this.bsprContextMSTData.ActiveSheet.Rows[j].BackColor = Color.LightGreen; pgBarModelContext.Increment(1); Thread.Sleep(50); Application.DoEvents(); } } else { pgBarModelContext.Maximum = 1; pgBarModelContext.Value = 1; } #endregion this.bsprData.ActiveSheet.Rows[i].BackColor = Color.LightGreen; pgBarModel.Increment(1); Thread.Sleep(50); Application.DoEvents(); } } else { MSGHandler.DisplayMessage(MSGType.Information, "SPC_INFO_NO_INFO_PROD_MAPPING", null, null); return; } } else { MSGHandler.DisplayMessage(MSGType.Information, "Please search SPC Model first."); return; } }