Exemple #1
0
        public string LoadSQL(string sqlFullPath, string templateID, params object[] obValues)
        {
            string sql = string.Empty;

            // null 값일 경우 공백으로 처리
            string[] value = obValues.Select(s => (s == null ? "" : s.ToString())).ToArray();


            string file = sqlFullPath;// Path.Combine(Global.ConfigInfo.SqlXmlPath, string.Format(@"{0}"
            //, FileName));

            DBAgentMultiTemplate dbaMulti = null;

            XmlSerializer serializer = new XmlSerializer(typeof(DBAgentMultiTemplate));

            XmlReader xr = XmlReader.Create(file);

            dbaMulti = serializer.Deserialize(xr) as DBAgentMultiTemplate;
            xr.Close();

            // templateID 검색
            var query = from a in dbaMulti.DBAgentTemplate
                        where a.TemplateID == templateID
                        select a;

            if (query != null)
            {
                DBAgentTemplate dt = query.First() as DBAgentTemplate;
                sql = MakeSQL(dt, value);
            }
            if (!sql.ToUpper().Contains("NOCOUNT"))
            {
                sql = " SET NOCOUNT ON " + "\n" + sql + "\n" + " SET NOCOUNT OFF ";
            }
            if (!sql.ToUpper().Contains("ARITHABORT"))
            {
                sql = " SET ARITHABORT ON " + "\n" + sql + "\n" + " SET ARITHABORT OFF ";
            }

            return(sql);
        }
Exemple #2
0
        public string LoadCondSQL(string sqlFullPath, string templateID, params object[] obValues)
        {
            string sql = string.Empty;

            // null 값일 경우 공백으로 처리
            string[] value = obValues.Select(s => (s == null ? "" : s.ToString())).ToArray();


            string file = sqlFullPath; // Path.Combine(Global.ConfigInfo.SqlXmlPath, string.Format(@"{0}"
                                       //, FileName));

            DBAgentMultiTemplate dbaMulti = null;

            XmlSerializer serializer = new XmlSerializer(typeof(DBAgentMultiTemplate));

            XmlReader xr = XmlReader.Create(file);

            dbaMulti = serializer.Deserialize(xr) as DBAgentMultiTemplate;
            xr.Close();

            // templateID 검색
            var query = from a in dbaMulti.DBAgentTemplate
                        where a.TemplateID == templateID
                        select a;

            if (query != null)
            {
                DBAgentTemplate dt = query.First() as DBAgentTemplate;
                //for (int i = 0; i < value.Length; i++)
                //{
                //    if (!value[i].Contains("''"))
                //    {
                //        value[i] = value[i].Replace("'", "''");
                //    }
                //}
                sql = MakeSQL(dt, value);
            }
            return(sql);
        }
Exemple #3
0
        public string LoadSQLXml(string sqlFullPath, string templateID, params string[] value)
        {
            string sql = string.Empty;

            string file = sqlFullPath; //Path.Combine(Global.ConfigInfo.SqlXmlPath, string.Format(@"{0}"
            //, FileName));

            DBAgentMultiTemplate dbaMulti = null;

            XmlSerializer serializer = new XmlSerializer(typeof(DBAgentMultiTemplate));

            XmlReader xr = XmlReader.Create(file);

            dbaMulti = serializer.Deserialize(xr) as DBAgentMultiTemplate;
            xr.Close();

            // templateID 검색
            var query = from a in dbaMulti.DBAgentTemplate
                        where a.TemplateID == templateID
                        select a;

            if (query != null)
            {
                DBAgentTemplate dt = query.First() as DBAgentTemplate;
                for (int i = 0; i < value.Length; i++)
                {
                    if (!value[i].Contains("@@@@"))
                    {
                        value[i] = value[i].Replace("'", "''");
                    }

                    value[i] = value[i].Replace("@@@@", "");
                }
                sql = MakeSQL(dt, value);
            }

            return(sql);
        }