Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="message"></param>
        /// <param name="type"></param>
        string InsertNewMessage(string message)
        {
            string type = "01";

            message = ParseCorrectMessage(message, out type);

            string            cdMsg = string.Empty;
            OracleDacHelper   db    = null;
            OracleTransaction trans = null;

            try
            {
                db    = new OracleDacHelper();
                trans = db.BeginTransaction();

                var query = "SELECT NVL(MAX(CD_MSG),'00000') FROM SYT012T WHERE CD_MSG_DIV = 'A' AND CD_BIZ_DIV = 'PS'";
                var max   = db.ExecuteScalar(query, null, null, trans);
                int nm    = TypeHelper.ToInt32(max) + 1;
                cdMsg = nm.ToString("d5");

                query = string.Format(@"INSERT INTO SYT012T(CD_MSG_DIV,CD_BIZ_DIV,CD_MSG,CD_MSG_TYPE,NM_MSG_TITLE,NM_MSG,
                                        NM_DESC,FG_USE,DT_CRTN,NO_CRTN,DT_CHG,NO_CHG,TT_IUDT) 
                        VALUES('A','PS',:CD_MSG,:MSG_TYPE,'  ',:NM_MSG,
                                        '','1',sysdate,'9999999',sysdate,'9999999','{0:yyyyMMddHHmmss}')", DateTime.Now);
                db.ExecuteNonQuery(query,
                                   new string[] {
                    ":CD_MSG",
                    ":MSG_TYPE",
                    ":NM_MSG"
                }, new object[] {
                    cdMsg,
                    type,
                    message
                }, trans);

                trans.Commit();
            }
            catch (Exception ex)
            {
                new LogFileHandler().LogException(ex);
                trans.Rollback();
            }
            finally
            {
                db.Dispose();
                trans.Dispose();
            }


            return(cdMsg);
        }
Exemple #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            string query = "select * from bsm031t where cd_astore = :cd_astore and fg_use = '1'";
            //string connString = "Data Source=124.137.10.26:1521/wmalldev;User Id=wmalldev;Password=wmall#dev;Persist Security Info=True;";
            string connString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=124.137.10.26)(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=wmalldev)));User Id=wmalldev;Password=wmall#dev;";

            OracleDacHelper.DefaultConnectionString = connString;
            using (var dac = new OracleDacHelper())
            {
                var ds = dac.ExecuteQuery(query,
                                          new string[] {
                    ":cd_astore"
                }, new object[] {
                    "01"
                });
                dataGridView1.DataSource = ds.Tables[0];
            }
        }
Exemple #3
0
        string FindMessageCode(string message)
        {
            string type = string.Empty;
            string msg  = ParseCorrectMessage(message, out type);

            try
            {
                using (var dac = new OracleDacHelper())
                {
                    var query = "SELECT CD_MSG FROM SYT012T WHERE CD_MSG_DIV = 'A' AND CD_BIZ_DIV = 'PS' AND NM_MSG = :NM_MSG";
                    var code  = dac.ExecuteScalar(query,
                                                  new string[] {
                        ":NM_MSG"
                    }, new object[] {
                        msg
                    });

                    string codeMsg = string.Empty;
                    bool   found   = code != null && !string.IsNullOrEmpty(code.ToString());
                    if (!found)
                    {
                        codeMsg = InsertNewMessage(message);
                    }
                    else
                    {
                        codeMsg = code.ToString();
                    }

                    return(string.Format("WSWD.WmallPos.FX.Shared.ConfigData.Current.SysMessage.GetMessage(\"{0}\")", codeMsg));
                }
            }
            catch (Exception ex)
            {
                new LogFileHandler().LogException(ex);
            }
            finally
            {
            }

            return(string.Empty);
        }
Exemple #4
0
        /// <summary>
        /// 메시지 중복 처리
        /// 1) 중복 메시지 코드 찾기
        /// 2) 한 코드만 사용, 나머지 삭제
        /// 3) 삭제 하기 전에 소스 바꾸고 저장 & 메시지 삭제
        /// </summary>
        private void ProcessDupMsgFiles()
        {
            #region Find dup msg and and get list of code

            lblProgress.Text = "중복 메시지 검색 중...";
            Application.DoEvents();

            /*
             * SELECT * FROM SYT012T mto
             *      INNER JOIN
             *      (SELECT NM_MSG FROM SYT012T mtp
             *              WHERE mtp.CD_BIZ_DIV = 'PS' AND mtp.CD_MSG_DIV = 'P'
             *              GROUP BY mtp.NM_MSG
             *              HAVING COUNT(*) > 1
             *              ) mtp ON mto.NM_MSG = mtp.NM_MSG
             * WHERE mto.CD_BIZ_DIV = 'PS' AND mto.CD_MSG_DIV = 'P'
             * ORDER BY mto.NM_MSG DESC;
             *
             */

            Dictionary <string, List <string> > dupCodes = new Dictionary <string, List <string> >();
            using (var dac = new OracleDacHelper())
            {
                var query = "SELECT * FROM SYT012T mto INNER JOIN (SELECT NM_MSG FROM SYT012T mtp WHERE mtp.CD_BIZ_DIV = 'PS' AND mtp.CD_MSG_DIV = 'A' GROUP BY mtp.NM_MSG HAVING COUNT(*) > 1) mtp ON mto.NM_MSG = mtp.NM_MSG WHERE mto.CD_BIZ_DIV = 'PS' AND mto.CD_MSG_DIV = 'A' ORDER BY mto.NM_MSG DESC, mto.CD_MSG ASC";

                var dupDataset = dac.ExecuteQuery(query, null, null);

                string lastNmMsg = string.Empty;
                string lastCdMsg = string.Empty;
                foreach (DataRow dr in dupDataset.Tables[0].Rows)
                {
                    List <string> lst = null;

                    string cdMsg = dr["CD_MSG"].ToString();
                    string nmMsg = dr["NM_MSG"].ToString();

                    if (!lastNmMsg.Equals(nmMsg))
                    {
                        lst = new List <string>();
                        dupCodes.Add(cdMsg, lst);

                        lastCdMsg = cdMsg;
                        lastNmMsg = nmMsg;
                    }
                    else
                    {
                        lst = dupCodes[lastCdMsg];
                    }

                    lst.Add(cdMsg);
                }
            }

            #endregion

            #region Search and get related cs file

            lblProgress.Text = "처리 할 소스 파일 리스트 만드는 중...";
            Application.DoEvents();

            // get list of files exception designer.cs
            List <string> processingFiles = new List <string>();
            var           files           = Directory.GetFiles(txtDupSrcPath.Text, "*.cs", SearchOption.AllDirectories);
            foreach (var file in files)
            {
                try
                {
                    string fileContent = File.ReadAllText(file, Encoding.UTF8);
                    if (fileContent.Contains("ConfigData.Current.SysMessage.GetMessage"))
                    {
                        processingFiles.Add(file);

                        lblProgress.Text = "처리 할 소스 파일 리스트 만드는 중..." + Path.GetFileName(file);
                        Application.DoEvents();
                    }
                }
                catch
                {
                }
            }

            #endregion

            #region Search in POS source, replace all code with first code if above

            lblProgress.Text = "중복 메시지를 처리 중...";
            Application.DoEvents();

            // dupCodes
            // Search in each key of dupCodes, find all msg code, replace with keyCode
            foreach (var file in processingFiles)
            {
                try
                {
                    string fileContent = File.ReadAllText(file, Encoding.UTF8);
                    lblProgress.Text = "중복 메시지를 처리 중..." + Path.GetFileName(file);
                    Application.DoEvents();

                    bool changed = false;

                    foreach (var key in dupCodes.Keys)
                    {
                        List <string> lst = dupCodes[key];
                        lst.Remove(key);

                        foreach (var code in lst)
                        {
                            string rt = string.Format("Current.SysMessage.GetMessage(\"{0}\")", code);
                            if (!fileContent.Contains(rt))
                            {
                                continue;
                            }

                            fileContent = fileContent.Replace(rt, string.Format("Current.SysMessage.GetMessage(\"{0}\")", key));
                            changed     = true;
                        }
                    }

                    if (changed)
                    {
                        File.WriteAllText(file, fileContent, Encoding.UTF8);
                    }
                }
                catch
                {
                }
            }

            lblProgress.Text = "중복 메시지를 처리 완료..." + processingFiles.Count.ToString();
            Application.DoEvents();

            #endregion

            #region 메시지를 디비에서 삭제

            // 메시지를 디비에서 삭제
            lblProgress.Text = "중복 메시지를 처리 중...";
            Application.DoEvents();

            using (var dac = new OracleDacHelper())
            {
                foreach (var key in dupCodes.Keys)
                {
                    List <string> lst = dupCodes[key];
                    lst.Remove(key);
                    foreach (var code in lst)
                    {
                        // Delete from DB
                        var query = string.Format("DELETE FROM SYT012T mtp WHERE mtp.CD_BIZ_DIV = 'PS' AND mtp.CD_MSG_DIV = 'A' AND mtp.CD_MSG = '{0}'", code);
                        dac.ExecuteNonQuery(query, null, null);
                    }
                }
            }

            #endregion

            lblProgress.Text = "작업 완료.";
            Application.DoEvents();
        }