Example #1
0
        public DataSet GetSPCModelContextData(byte[] param)
        {
            DataSet       dsReturn      = new DataSet();
            StringBuilder sb            = new StringBuilder();
            LinkedList    llstParam     = new LinkedList();
            LinkedList    llstCondition = new LinkedList();

            try
            {
                llstParam.SetSerialData(param);

                if (llstParam.Contains(Definition.CONDITION_KEY_MODEL_CONFIG_RAWID))
                {
                    llstCondition.Add("MODEL_CONFIG_RAWID", _ComUtil.NVL(llstParam[Definition.CONDITION_KEY_MODEL_CONFIG_RAWID]));
                }

                sb.Append("SELECT * FROM MODEL_CONTEXT_MST_SPC ");
                sb.Append(" WHERE MODEL_CONFIG_RAWID = :MODEL_CONFIG_RAWID ");
                sb.Append(" AND CONTEXT_KEY = 'PRODUCT_ID' ");

                dsReturn = this.Query(sb.ToString(), llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
            }
            catch (Exception ex)
            {
                BISTel.PeakPerformance.Client.CommonLibrary.LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, new string[] { ex.Message, ex.Source, ex.StackTrace });
            }
            finally
            {
                llstParam.Clear(); llstParam         = null;
                llstCondition.Clear(); llstCondition = null;
                sb.Remove(0, sb.Length); sb          = null;
            }

            return(dsReturn);
        }
Example #2
0
        public bool InsertSpecialLotGroup(byte[] baData)
        {
            bool bSuccess = false;

            DataSet       dsResult      = new DataSet();
            DataTable     dt            = new DataTable();
            LinkedList    llstFieldData = new LinkedList();
            LinkedList    llstData      = new LinkedList();
            StringBuilder sb            = new StringBuilder();
            string        sUserID       = string.Empty;

            try
            {
                llstData.SetSerialData(baData);

                if (llstData[Definition.DynamicCondition_Condition_key.USER_ID] != null)
                {
                    sUserID = llstData[Definition.DynamicCondition_Condition_key.USER_ID].ToString();
                }

                if (llstData[Definition.CONDITION_KEY_DATA] != null)
                {
                    dt = (DataTable)llstData[Definition.CONDITION_KEY_DATA];
                }

                DataRow drDel = null;

                base.BeginTrans();

                foreach (DataRow dr in dt.Rows)
                {
                    llstFieldData.Clear();
                    sb = new StringBuilder();

                    if (dr.RowState == DataRowState.Deleted || dr["_DELETE"].ToString().ToUpper() == "TRUE")
                    {
                        drDel = dr;
                        drDel.RejectChanges();
                        sb.AppendFormat("Where LOT_GROUP_NAME ='{0}'", drDel[COLUMN.LOT_GROUP_NAME].ToString());
                        sb.AppendFormat(" And USER_ID ='{0}'", sUserID);
                        base.Delete(TABLE.SPECIAL_LOT_SPC, sb.ToString(), new LinkedList());
                        if (base.ErrorMessage.Length > 0)
                        {
                            DSUtil.SetResult(dsResult, 0, "", base.ErrorMessage);
                            base.RollBack();
                            bSuccess = false;
                            return(bSuccess);
                        }
                    }
                    else if (dr["_INSERT"].ToString().ToUpper() == "TRUE")
                    {
                        llstFieldData.Add(COLUMN.LOT_ID, dr[COLUMN.LOT_ID]);
                        llstFieldData.Add(COLUMN.LOT_GROUP_NAME, dr[COLUMN.LOT_GROUP_NAME]);
                        llstFieldData.Add(COLUMN.USER_ID, sUserID);
                        llstFieldData.Add(COLUMN.CREATE_BY, sUserID);
                        llstFieldData.Add(string.Format("{0}+SYSTIMESTAMP", COLUMN.CREATE_DTTS), "");
                        llstFieldData.Add(COLUMN.LAST_UPDATE_BY, sUserID);
                        llstFieldData.Add(string.Format("{0}+SYSTIMESTAMP", COLUMN.LAST_UPDATE_DTTS), "");

                        base.Insert(TABLE.SPECIAL_LOT_SPC, llstFieldData);
                        if (base.ErrorMessage.Length > 0)
                        {
                            DSUtil.SetResult(dsResult, 0, "", base.ErrorMessage);
                            base.RollBack();
                            bSuccess = false;
                            return(bSuccess);
                        }
                    }
                    else if (dr["_MODIFY"].ToString().ToUpper() == "TRUE")
                    {
                        llstFieldData.Add(COLUMN.LOT_ID, dr[COLUMN.LOT_ID]);
                        llstFieldData.Add(COLUMN.LOT_GROUP_NAME, dr[COLUMN.LOT_GROUP_NAME]);
                        llstFieldData.Add(COLUMN.USER_ID, sUserID);
                        llstFieldData.Add(COLUMN.LAST_UPDATE_BY, sUserID);
                        llstFieldData.Add(string.Format("{0}+SYSTIMESTAMP", COLUMN.LAST_UPDATE_DTTS), "");

                        sb.AppendFormat("Where LOT_GROUP_NAME ='{0}'", dr[COLUMN.LOT_GROUP_NAME].ToString());
                        sb.AppendFormat(" And USER_ID ='{0}'", sUserID);
                        base.Update(TABLE.SPECIAL_LOT_SPC, llstFieldData, sb.ToString(), new LinkedList());
                        if (base.ErrorMessage.Length > 0)
                        {
                            DSUtil.SetResult(dsResult, 0, "", base.ErrorMessage);
                            base.RollBack();
                            bSuccess = false;
                            return(bSuccess);
                        }
                    }
                    else
                    {
                    }
                }
                base.Commit();
                bSuccess = true;
            }
            catch (Exception ex)
            {
                bSuccess = false;
                base.RollBack();
                DSUtil.SetResult(dsResult, 0, "", ex.Message);

                BISTel.PeakPerformance.Client.CommonLibrary.LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, new string[] { ex.Message, ex.Source, ex.StackTrace });
            }
            finally
            {
                if (llstFieldData != null)
                {
                    llstFieldData = null;
                }
            }

            return(bSuccess);
        }
Example #3
0
        public bool InsertAnalysisChartConfiguration(byte[] baData)
        {
            bool bSuccess = false;

            DataSet       dsResult      = new DataSet();
            DataTable     dt            = new DataTable();
            LinkedList    llstFieldData = new LinkedList();
            LinkedList    llstData      = new LinkedList();
            StringBuilder sb            = new StringBuilder();
            decimal       dRawID        = 0;
            string        sUserID       = string.Empty;

            try
            {
                llstData.SetSerialData(baData);

                if (llstData[Definition.DynamicCondition_Condition_key.USER_ID] != null)
                {
                    sUserID = llstData[Definition.DynamicCondition_Condition_key.USER_ID].ToString();
                }

                if (llstData[Definition.CONDITION_KEY_DATA] != null)
                {
                    dt = (DataTable)llstData[Definition.CONDITION_KEY_DATA];
                }

                DataRow drDel = null;

                base.BeginTrans();

                foreach (DataRow dr in dt.Rows)
                {
                    llstFieldData.Clear();
                    sb = new StringBuilder();
                    if (dr.RowState == DataRowState.Deleted)
                    {
                        drDel = dr;
                        drDel.RejectChanges();
                        sb.AppendFormat("Where RAWID ={0}", drDel[COLUMN.RAWID].ToString());
                        base.Delete(TABLE.ANALYSISCHAT_CONFIG_SPC, sb.ToString(), new LinkedList());
                        if (base.ErrorMessage.Length > 0)
                        {
                            DSUtil.SetResult(dsResult, 0, "", base.ErrorMessage);
                            base.RollBack();
                            bSuccess = false;
                            return(bSuccess);
                        }
                    }
                    else if (dr.RowState == DataRowState.Added)
                    {
                        dRawID = base.GetSequence(SEQUENCE.SEQ_ANALYSISCHAT_CONFIG_SPC);
                        llstFieldData.Add(COLUMN.RAWID, dRawID);
                        llstFieldData.Add(COLUMN.LOCATION_RAWID, dr[COLUMN.LOCATION_RAWID]);
                        llstFieldData.Add(COLUMN.USER_ID, dr[COLUMN.USER_ID]);
                        llstFieldData.Add(COLUMN.CHART_CODE, dr[COLUMN.CHART_CODE]);
                        llstFieldData.Add(COLUMN.CHART_NAME, dr[COLUMN.CHART_NAME]);
                        llstFieldData.Add(COLUMN.CHART_ALIAS, dr[COLUMN.CHART_ALIAS]);
                        llstFieldData.Add(COLUMN.CHART_LIST, dr[COLUMN.CHART_LIST]);
                        llstFieldData.Add(COLUMN.FROM_NOW, dr[COLUMN.FROM_NOW]);
                        llstFieldData.Add(COLUMN.PUBLIC_YN, dr[COLUMN.PUBLIC_YN]);
                        llstFieldData.Add(COLUMN.USE_YN, dr[COLUMN.USE_YN]);
                        llstFieldData.Add(COLUMN.SEARCH_YN, dr[COLUMN.SEARCH_YN]);
                        llstFieldData.Add(string.Format("{0}+SYSTIMESTAMP", COLUMN.CREATE_DTTS), "");

                        base.Insert(TABLE.ANALYSISCHAT_CONFIG_SPC, llstFieldData);
                        if (base.ErrorMessage.Length > 0)
                        {
                            DSUtil.SetResult(dsResult, 0, "", base.ErrorMessage);
                            base.RollBack();
                            bSuccess = false;
                            return(bSuccess);
                        }
                        dr[COLUMN.RAWID] = dRawID;
                    }
                    else if (dr.RowState == DataRowState.Modified || dr["_MODIFY"].ToString().ToUpper() == "TRUE")
                    {
                        dRawID = decimal.Parse(dr[COLUMN.RAWID].ToString());
                        llstFieldData.Add(COLUMN.LOCATION_RAWID, dr[COLUMN.LOCATION_RAWID]);
                        llstFieldData.Add(COLUMN.CHART_CODE, dr[COLUMN.CHART_CODE]);
                        llstFieldData.Add(COLUMN.CHART_NAME, dr[COLUMN.CHART_NAME]);
                        llstFieldData.Add(COLUMN.CHART_ALIAS, dr[COLUMN.CHART_ALIAS]);
                        llstFieldData.Add(COLUMN.CHART_LIST, dr[COLUMN.CHART_LIST]);
                        llstFieldData.Add(COLUMN.FROM_NOW, dr[COLUMN.FROM_NOW]);
                        llstFieldData.Add(COLUMN.PUBLIC_YN, dr[COLUMN.PUBLIC_YN]);
                        llstFieldData.Add(COLUMN.USE_YN, dr[COLUMN.USE_YN]);
                        llstFieldData.Add(COLUMN.SEARCH_YN, dr[COLUMN.SEARCH_YN]);
                        llstFieldData.Add(COLUMN.LAST_UPDATE_BY, sUserID);
                        llstFieldData.Add(string.Format("{0}+SYSTIMESTAMP", COLUMN.LAST_UPDATE_DTTS), "");

                        sb.AppendFormat("Where RAWID ={0}", dRawID);
                        base.Update(TABLE.ANALYSISCHAT_CONFIG_SPC, llstFieldData, sb.ToString(), new LinkedList());
                        if (base.ErrorMessage.Length > 0)
                        {
                            DSUtil.SetResult(dsResult, 0, "", base.ErrorMessage);
                            base.RollBack();
                            bSuccess = false;
                            return(bSuccess);
                        }
                    }
                }
                base.Commit();
                bSuccess = true;
            }
            catch (Exception ex)
            {
                bSuccess = false;
                base.RollBack();
                DSUtil.SetResult(dsResult, 0, "", ex.Message);

                BISTel.PeakPerformance.Client.CommonLibrary.LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, new string[] { ex.Message, ex.Source, ex.StackTrace });
            }
            finally
            {
                if (llstFieldData != null)
                {
                    llstFieldData = null;
                }
            }

            return(bSuccess);
        }
        public DataSet GetSPCModelVersionData(string modelConfigRawid, string version, bool isATT)
        {
            DataSet dsReturn = new DataSet();

            DataSet       dsTemp        = null;
            StringBuilder sb            = new StringBuilder();
            LinkedList    llstCondition = new LinkedList();

            string modelMstTblName          = string.Empty;
            string modelConfigMstTblName    = string.Empty;
            string modelConfigMsthTblName   = string.Empty;
            string modelConfigOptMstTblname = string.Empty;
            string modelContextMstTblname   = string.Empty;
            string modelRuleMstTblName      = string.Empty;
            string modelRuleMsthTblName     = string.Empty;
            string modelRuleOptMstTblName   = string.Empty;
            string modelRuleOptMsthTblName  = string.Empty;
            string modelAutoCalcMstTblname  = string.Empty;
            string modelAutoCalcMsthTblName = string.Empty;
            string ruleMstTblName           = string.Empty;
            string ruleOptMstTblName        = string.Empty;

            if (isATT)
            {
                modelMstTblName          = TABLE.MODEL_ATT_MST_SPC;
                modelConfigMstTblName    = TABLE.MODEL_CONFIG_ATT_MST_SPC;
                modelConfigMsthTblName   = TABLE.MODEL_CONFIG_ATT_MSTH_SPC;
                modelConfigOptMstTblname = TABLE.MODEL_CONFIG_OPT_ATT_MST_SPC;
                modelContextMstTblname   = TABLE.MODEL_CONTEXT_ATT_MST_SPC;
                modelRuleMstTblName      = TABLE.MODEL_RULE_ATT_MST_SPC;
                modelRuleMsthTblName     = TABLE.MODEL_RULE_ATT_MSTH_SPC;
                modelRuleOptMstTblName   = TABLE.MODEL_RULE_OPT_ATT_MST_SPC;
                modelRuleOptMsthTblName  = TABLE.MODEL_RULE_OPT_ATT_MSTH_SPC;
                modelAutoCalcMstTblname  = TABLE.MODEL_AUTOCALC_ATT_MST_SPC;
                modelAutoCalcMsthTblName = TABLE.MODEL_AUTOCALC_ATT_MSTH_SPC;
                ruleMstTblName           = TABLE.RULE_ATT_MST_SPC;
                ruleOptMstTblName        = TABLE.RULE_OPT_ATT_MST_SPC;
            }
            else
            {
                modelMstTblName          = TABLE.MODEL_MST_SPC;
                modelConfigMstTblName    = TABLE.MODEL_CONFIG_MST_SPC;
                modelConfigMsthTblName   = TABLE.MODEL_CONFIG_MSTH_SPC;
                modelConfigOptMstTblname = TABLE.MODEL_CONFIG_OPT_MST_SPC;
                modelContextMstTblname   = TABLE.MODEL_CONTEXT_MST_SPC;
                modelRuleMstTblName      = TABLE.MODEL_RULE_MST_SPC;
                modelRuleMsthTblName     = TABLE.MODEL_RULE_MSTH_SPC;
                modelRuleOptMstTblName   = TABLE.MODEL_RULE_OPT_MST_SPC;
                modelRuleOptMsthTblName  = TABLE.MODEL_RULE_OPT_MSTH_SPC;
                modelAutoCalcMstTblname  = TABLE.MODEL_AUTOCALC_MST_SPC;
                modelAutoCalcMsthTblName = TABLE.MODEL_AUTOCALC_MSTH_SPC;
                ruleMstTblName           = TABLE.RULE_MST_SPC;
                ruleOptMstTblName        = TABLE.RULE_OPT_MST_SPC;
            }

            try
            {
                llstCondition.Add("MODEL_CONFIG_RAWID", modelConfigRawid);
                llstCondition.Add("VERSION", version);

                //#00. MODEL_MST_SPC
                string query =
                    "SELECT * " +
                    " FROM " + modelMstTblName +
                    " WHERE RAWID IN (SELECT MODEL_RAWID " +
                    "                 FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                    "                       FROM " + modelConfigMsthTblName + " a " +
                    "                       WHERE Rawid = :MODEL_CONFIG_RAWID " +
                    "                       AND version = :VERSION) " +
                    "                 WHERE RNK = 1) ";

                dsTemp = this.Query(query, llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtConfig = dsTemp.Tables[0].Copy();
                    dtConfig.TableName = modelMstTblName;

                    dsReturn.Tables.Add(dtConfig);
                }


                //#01. MODEL_CONFIG_MST_SPC

                //2009-12-07 bskwon 수정
                if (isATT)
                {
                    query =
                        "SELECT mcms.* " +
                        " FROM (SELECT * FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                        "       FROM MODEL_CONFIG_ATT_MSTH_SPC a " +
                        "       WHERE Rawid = :MODEL_CONFIG_RAWID " +
                        "       AND version = :VERSION) " +
                        " WHERE RNK = 1) mcms " +
                        " ORDER BY mcms.RAWID";
                }
                else
                {
                    query =
                        "SELECT mcms.*, B.NAME AS PARAM_TYPE, cc.name as MANAGE_TYPE_NAME " +
                        " FROM (SELECT * " +
                        "       FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                        "             FROM MODEL_CONFIG_MSTH_SPC a " +
                        "             WHERE Rawid = :MODEL_CONFIG_RAWID " +
                        "             AND version = :VERSION) " +
                        "       WHERE RNK = 1) mcms " +
                        "       LEFT OUTER JOIN (SELECT CODE, NAME " +
                        "                        FROM CODE_MST_PP WHERE CATEGORY = 'SPC_PARAM_TYPE') B " +
                        "                   ON mcms.PARAM_TYPE_CD = B.CODE " +
                        "       LEFT OUTER JOIN (SELECT CODE, NAME " +
                        "                        FROM CODE_MST_PP WHERE CATEGORY='SPC_MANAGE_TYPE') cc " +
                        "                   ON mcms.manage_type_cd = cc.code " +
                        " ORDER BY mcms.RAWID";
                }

                dsTemp = this.Query(query, llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtConfig = dsTemp.Tables[0].Copy();
                    dtConfig.TableName = modelConfigMstTblName;

                    dsReturn.Tables.Add(dtConfig);
                }


                //#02. MODEL_CONFIG_OPT_MST_SPC
                if (isATT)
                {
                    query =
                        "SELECT A.* " +
                        " FROM (SELECT * " +
                        "       FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                        "             FROM MODEL_CONFIG_OPT_ATT_MSTH_SPC a " +
                        "             WHERE model_config_rawid = :MODEL_CONFIG_RAWID " +
                        "             AND version = :VERSION) " +
                        "       WHERE RNK = 1) A ";
                }
                else
                {
                    query =
                        "SELECT A.*, B.NAME AS SPC_PARAM_CATEGORY, C.NAME AS SPC_PRIORITY " +
                        " FROM (SELECT * " +
                        "       FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                        "             FROM MODEL_CONFIG_OPT_MSTH_SPC a " +
                        "             WHERE model_config_rawid = :MODEL_CONFIG_RAWID " +
                        "             AND version = :VERSION) " +
                        "       WHERE RNK = 1) A " +
                        "       LEFT OUTER JOIN (SELECT CODE, NAME " +
                        "                        FROM CODE_MST_PP WHERE CATEGORY = 'SPC_PARAM_CATEGORY') B " +
                        "                   ON (A.SPC_PARAM_CATEGORY_CD = B.CODE) " +
                        "       LEFT OUTER JOIN (SELECT CODE, NAME " +
                        "                        FROM CODE_MST_PP WHERE CATEGORY = 'SPC_PRIOTIRY') C " +
                        "                   ON (A.SPC_PRIORITY_CD = C.CODE) ";
                }

                dsTemp = this.Query(query, llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtConfigOPT = dsTemp.Tables[0].Copy();
                    dtConfigOPT.TableName = modelConfigOptMstTblname;

                    dsReturn.Tables.Add(dtConfigOPT);
                }


                //#03. MODEL_CONTEXT_MST_SPC
                if (isATT)
                {
                    query =
                        "SELECT mcms.* " +
                        " FROM (SELECT * " +
                        "       FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                        "             FROM MODEL_CONTEXT_ATT_MSTH_SPC a " +
                        "             WHERE model_config_rawid = :MODEL_CONFIG_RAWID " +
                        "             AND version = :VERSION) " +
                        "       WHERE RNK = 1 ) mcms " +
                        " ORDER BY mcms.KEY_ORDER ASC ";
                }
                else
                {
                    query =
                        "SELECT mcms.*, aa.name as context_key_name " +
                        " FROM (SELECT * " +
                        "       FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                        "             FROM MODEL_CONTEXT_MSTH_SPC a " +
                        "             WHERE model_config_rawid = :MODEL_CONFIG_RAWID " +
                        "             AND version = :VERSION) " +
                        "       WHERE RNK = 1 ) mcms, " +
                        "      (SELECT CODE,NAME " +
                        "       FROM code_mst_pp " +
                        "       WHERE category='CONTEXT_TYPE' " +
                        "             UNION SELECT CODE,NAME " +
                        "             FROM code_mst_pp " +
                        "             WHERE category='SPC_CONTEXT_TYPE') AA " +
                        " WHERE mcms.context_key = aa.code " +
                        " ORDER BY mcms.KEY_ORDER ASC ";
                }

                dsTemp = this.Query(query, llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtContext = dsTemp.Tables[0].Copy();
                    dtContext.TableName = modelContextMstTblname;

                    dsReturn.Tables.Add(dtContext);
                }

                //#04. MODEL_RULE_MST_SPC
                query =
                    "SELECT A.*, B.DESCRIPTION, " +
                    "       DECODE(A.USE_MAIN_SPEC_YN,'Y','True','N','False','True') AS USE_MAIN_SPEC, " +
                    "       '' AS RULE_OPTION, '' AS RULE_OPTION_DATA " +
                    " FROM (SELECT * " +
                    "       FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                    "             FROM " + modelRuleMsthTblName + " a " +
                    "             WHERE model_config_rawid = :MODEL_CONFIG_RAWID " +
                    "             AND version = :VERSION ) " +
                    "       WHERE RNK = 1) A " +
                    "       LEFT OUTER JOIN " + ruleMstTblName + " B " +
                    "                   ON A.SPC_RULE_NO = B.SPC_RULE_NO ";

                dsTemp = this.Query(query, llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtRule = dsTemp.Tables[0].Copy();
                    dtRule.TableName = modelRuleMstTblName;

                    dsReturn.Tables.Add(dtRule);
                }

                //#05. MODEL_RULE_OPT_MST_SPC
                query =
                    "SELECT b.*, c.option_name, c.description, a.spc_rule_no " +
                    " FROM (SELECT * " +
                    "       FROM (SELECT RANK () OVER (PARTITION BY VERSION ORDER BY input_dtts) rnk, aa.* " +
                    "             FROM " + modelRuleMsthTblName + " aa " +
                    "             WHERE model_config_rawid = :MODEL_CONFIG_RAWID " +
                    "             AND VERSION = :VERSION) " +
                    "       WHERE rnk = 1) a " +
                    "       LEFT OUTER JOIN (SELECT * " +
                    "                        FROM (SELECT RANK () OVER (PARTITION BY VERSION ORDER BY input_dtts) rnk, aaa.* " +
                    "                              FROM " + modelRuleOptMsthTblName + " aaa " +
                    "                              WHERE model_rule_rawid IN (SELECT DISTINCT rawid " +
                    "                                                         FROM " + modelRuleMsthTblName +
                    "                                                         WHERE model_config_rawid = :MODEL_CONFIG_RAWID " +
                    "                                                         AND VERSION = :VERSION) " +
                    "                              AND VERSION = :VERSION) " +
                    "                        WHERE rnk = 1) b " +
                    "                  ON (a.rawid = b.model_rule_rawid AND b.VERSION = :VERSION) " +
                    "       LEFT OUTER JOIN (SELECT a.rawid AS rule_rawid, a.spc_rule_no, " +
                    "                               b.rule_option_no, b.option_name, b.description " +
                    "                        FROM " + ruleMstTblName + " a " +
                    "                             LEFT OUTER JOIN " + ruleOptMstTblName + " b " +
                    "                                        ON (a.rawid = b.rule_rawid) ) c " +
                    "                  ON (a.spc_rule_no = c.spc_rule_no " +
                    "                      AND b.rule_option_no = c.rule_option_no) " +
                    " ORDER BY b.rawid ASC ";

                dsTemp = this.Query(query, llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtRuleOPT = dsTemp.Tables[0].Copy();
                    dtRuleOPT.TableName = modelRuleOptMstTblName;

                    dsReturn.Tables.Add(dtRuleOPT);
                }

                //#06. MODEL_AUTOCALC_MST_SPC
                query =
                    "SELECT * " +
                    " FROM (SELECT * " +
                    "       FROM (SELECT rank () over(partition by version order by input_dtts) RNK, a.* " +
                    "             FROM " + modelAutoCalcMsthTblName + " a " +
                    "             WHERE model_config_rawid = :model_config_rawid " +
                    "             AND version = :version) " +
                    "       WHERE RNK = 1) ";

                dsTemp = this.Query(query, llstCondition);

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtAutoCalc = dsTemp.Tables[0].Copy();
                    dtAutoCalc.TableName = modelAutoCalcMstTblname;

                    dsReturn.Tables.Add(dtAutoCalc);
                }
            }
            catch (Exception ex)
            {
                BISTel.PeakPerformance.Client.CommonLibrary.LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, new string[] { ex.Message, ex.Source, ex.StackTrace });
            }
            finally
            {
                //resource 해제
                if (dsTemp != null)
                {
                    dsTemp.Dispose();
                    dsTemp = null;
                }

                llstCondition.Clear();
                llstCondition = null;
            }

            return(dsReturn);
        }
Example #5
0
        public DataSet GetSPCModelsData(string[] modelRawids, bool useComma, bool isATT)
        {
            DataSet dsReturn = new DataSet();

            string modelMstTblName        = string.Empty;
            string modelConfigMstTblName  = string.Empty;
            string modelContextMstTblName = string.Empty;
            string modelRuleMstTblName    = string.Empty;
            string ruleMstTblName         = string.Empty;

            if (isATT)
            {
                modelMstTblName        = TABLE.MODEL_ATT_MST_SPC;
                modelConfigMstTblName  = TABLE.MODEL_CONFIG_ATT_MST_SPC;
                modelContextMstTblName = TABLE.MODEL_CONTEXT_ATT_MST_SPC;
                modelRuleMstTblName    = TABLE.MODEL_RULE_ATT_MST_SPC;
                ruleMstTblName         = TABLE.RULE_ATT_MST_SPC;
            }
            else
            {
                modelMstTblName        = TABLE.MODEL_MST_SPC;
                modelConfigMstTblName  = TABLE.MODEL_CONFIG_MST_SPC;
                modelContextMstTblName = TABLE.MODEL_CONTEXT_MST_SPC;
                modelRuleMstTblName    = TABLE.MODEL_RULE_MST_SPC;
                ruleMstTblName         = TABLE.RULE_MST_SPC;
            }

            try
            {
                DataSet       temp = new DataSet();
                StringBuilder sb   = new StringBuilder();

                //#00. MODEL_MST_SPC
                sb.Append("SELECT rawid, spc_model_name FROM ");
                sb.Append(modelMstTblName);
                sb.Append(" WHERE 1 = 1 ");

                for (int i = 0; i < modelRawids.Length; i++)
                {
                    if (i == 0)
                    {
                        sb.Append(" and ((");
                    }
                    else
                    {
                        sb.Append(" or (");
                    }
                    sb.Append("RAWID = '" + modelRawids[i] + "')");
                }
                sb.Append(") order by rawid");

                temp = this.Query(sb.ToString());

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtConfig = temp.Tables[0].Copy();
                    dtConfig.TableName = modelMstTblName;

                    dsReturn.Tables.Add(dtConfig);
                }

                //#01. MODEL_CONFIG_MST_SPC
                sb.Remove(0, sb.Length);

                if (isATT)
                {
                    sb.Append(@"SELECT rawid, model_rawid, MAIN_YN, CHART_MODE_CD,  VERSION
                                FROM model_config_att_mst_spc WHERE 1 = 1 ");
                }
                else
                {
                    sb.Append(@"SELECT rawid, model_rawid, MAIN_YN, CHART_MODE_CD, PARAM_TYPE_CD, VERSION
                                FROM model_config_mst_spc WHERE 1 = 1 ");
                }

                for (int i = 0; i < modelRawids.Length; i++)
                {
                    if (i == 0)
                    {
                        sb.Append(" and ((");
                    }
                    else
                    {
                        sb.Append(" or (");
                    }
                    sb.Append("MODEL_RAWID = '" + modelRawids[i] + "')");
                }
                sb.Append(")");
                sb.Append(" ORDER BY model_rawid, RAWID");

                temp = this.Query(sb.ToString());

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtConfig = temp.Tables[0].Copy();
                    dtConfig.TableName = modelConfigMstTblName;

                    dsReturn.Tables.Add(dtConfig);
                }

                //#02. MODEL_CONTEXT_MST_SPC
                sb.Remove(0, sb.Length);
                sb.Append("SELECT mcms.rawid, mcms.model_config_rawid, mcms.context_key,  ");

                if (useComma)
                {
                    sb.Append("   replace(mcms.context_value, ';', ',') as context_value, ");
                }
                else
                {
                    sb.Append("   mcms.context_value, ");
                }

                sb.Append("       mcms.exclude_list, mcms.key_order, mcms.create_dtts, mcms.create_by, mcms.last_update_dtts, ");
                sb.Append("       mcms.last_update_by, mcms.group_yn, mcms.version, aa.name AS context_key_name ");
                sb.Append(" FROM " + modelContextMstTblName + " mcms, ");
                sb.Append("   (SELECT code, NAME ");
                sb.Append("     FROM code_mst_pp ");
                sb.Append("     WHERE CATEGORY = 'CONTEXT_TYPE'   ");
                sb.Append("     UNION                                      ");
                sb.Append("    SELECT code, NAME ");
                sb.Append("     FROM code_mst_pp               ");
                sb.Append("     WHERE CATEGORY = 'SPC_CONTEXT_TYPE') aa   ");
                sb.Append(" WHERE mcms.context_key = aa.code                  ");
                sb.Append(" AND mcms.model_config_rawid IN (SELECT rawid    ");
                sb.Append("                                 FROM " + modelConfigMstTblName + " ");
                sb.Append("                                 WHERE 1=1 ");

                for (int i = 0; i < modelRawids.Length; i++)
                {
                    if (i == 0)
                    {
                        sb.Append(" AND ((");
                    }
                    else
                    {
                        sb.Append(" OR (");
                    }
                    sb.Append("MODEL_RAWID = '" + modelRawids[i] + "')");
                }
                sb.Append(")");
                sb.Append(") ORDER BY mcms.key_order ASC");

                temp = this.Query(sb.ToString());

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtConfig = temp.Tables[0].Copy();
                    dtConfig.TableName = modelContextMstTblName;

                    dsReturn.Tables.Add(dtConfig);
                }

                //#03. MODEL_RULE_MST_SPC
                sb.Remove(0, sb.Length);
                sb.Append(@"SELECT a.*, b.description,
                                   DECODE (a.use_main_spec_yn,
                                           'Y', 'True',
                                           'N', 'False',
                                           'True'
                                          ) AS use_main_spec,
                                   '' AS rule_option, '' AS rule_option_data
                              FROM " + modelRuleMstTblName + " a LEFT OUTER JOIN " + ruleMstTblName + @" b
                                   ON a.spc_rule_no = b.spc_rule_no
                             WHERE 1 = 1 AND a.model_config_rawid IN (SELECT rawid
                                                                        FROM " + modelConfigMstTblName +
                          " WHERE 1=1 ");

                for (int i = 0; i < modelRawids.Length; i++)
                {
                    if (i == 0)
                    {
                        sb.Append(" and ((");
                    }
                    else
                    {
                        sb.Append(" or (");
                    }
                    sb.Append("MODEL_RAWID = '" + modelRawids[i] + "')");
                }
                sb.Append(") )");

                temp = this.Query(sb.ToString());

                if (base.ErrorMessage.Length > 0)
                {
                    DSUtil.SetResult(dsReturn, 0, "", base.ErrorMessage);
                    return(dsReturn);
                }
                else
                {
                    DataTable dtConfig = temp.Tables[0].Copy();
                    dtConfig.TableName = modelRuleMstTblName;

                    dsReturn.Tables.Add(dtConfig);
                }
            }
            catch (Exception ex)
            {
                BISTel.PeakPerformance.Client.CommonLibrary.LogHandler.ExceptionLogWrite(Definition.APPLICATION_NAME, new string[] { ex.Message, ex.Source, ex.StackTrace });
            }

            return(dsReturn);
        }