Esempio n. 1
0
        private static Dictionary <int, string> SplitSqlBySemicolon(string Sql)
        {
            List <int> aIndex = new List <int>();
            Dictionary <int, string> dicIdxSql = new Dictionary <int, string>();

            bool IsStartQuot = false;

            for (int i = 0; i < Sql.Length; i++)
            {
                char c = Sql[i];
                if (c == '\'')
                {
                    IsStartQuot = !IsStartQuot;
                }
                else if (c == ';')
                {
                    if (!IsStartQuot)
                    {
                        aIndex.Add(i);
                    }
                }
            }

            int IndexStart = 0;
            int IndexEnd   = -2;

            for (int i = 0; i < aIndex.Count; i++)
            {
                IndexStart = IndexEnd + 2;
                IndexEnd   = aIndex[i] - 1;
                string SqlCur = Sql.Substring(IndexStart, (IndexEnd - IndexStart + 1));

                if (!string.IsNullOrEmpty(CFindRep.TrimWhiteSpace(SqlCur)))
                {
                    dicIdxSql.Add(IndexStart, SqlCur);
                }
            }

            {
                IndexStart = IndexEnd + 2;
                IndexEnd   = Sql.Length - 1;
                string SqlCur = Sql.Substring(IndexStart, (IndexEnd - IndexStart + 1));

                if (!string.IsNullOrEmpty(CFindRep.TrimWhiteSpace(SqlCur)))
                {
                    dicIdxSql.Add(IndexStart, SqlCur);
                }
            }

            return(dicIdxSql);
        }
Esempio n. 2
0
        public static string GetOracleApplicationErrorMessage(int OraErrorNumber, string ExceptionMessage)
        {
            /*
             * ORA-20000: 1지문2문항의 1번째 문제유형:L, 문항영역:2, 문항번호:17에 대한 권한이 없거나 허용 개수를 초과했습니다.
             * ORA-06512: ""DB_CONTEST.PKG_EXAM_INFO"", 줄 330에서
             * ORA-06512: 줄 1에서
             */

            string Pattern = "ORA" + OraErrorNumber.ToString() + ":\\s(?<Message>.+?)ORA-";
            Regex  r       = new Regex(Pattern, RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.IgnorePatternWhitespace);
            Match  m       = r.Match(ExceptionMessage);

            //If not found, return original message.
            if (!m.Success)
            {
                return(ExceptionMessage);
            }

            return(CFindRep.TrimWhiteSpace(m.Groups["Message"].Value));
        }
Esempio n. 3
0
        public static CSyncReturn Syncronize(Type T)
        {
            CScriptConstSyncAttribute[] attributes = (CScriptConstSyncAttribute[])T.GetCustomAttributes(typeof(CScriptConstSyncAttribute), false);

            string FullPath = attributes[0].FullPathOfJavaScript;

            if (FullPath.StartsWith("/"))
            {
                FullPath = HttpContext.Current.Server.MapPath(FullPath);
            }

            if (!File.Exists(FullPath))
            {
                throw new Exception(string.Format("{0} is not exists.", FullPath));
            }

            string JsGenerated = ConvertToJavaScript(T, 0);

            string FileContent    = CFile.GetTextInFile(FullPath);
            string LogDateTime    = DateTime.Now.ToString(CConst.Format_yyyyMMddHHmmss);
            string FullPathBackup = GetFullPathBackup(FullPath, LogDateTime);

            string Declare = "var " + T.Name + " ";

            SyncResults SyncResult = SyncResults.NoChange;

            string JsAlready = GetJavaScriptByDeclare(FileContent, Declare);

            if (!string.IsNullOrEmpty(JsAlready))
            {
                if (CFindRep.TrimWhiteSpace(JsGenerated) != CFindRep.TrimWhiteSpace(JsAlready))
                {
                    SyncResult = SyncResults.Update;
                }
            }
            else
            {
                SyncResult = SyncResults.Append;
            }

            if (SyncResult != SyncResults.NoChange)
            {
                string Line = string.Format("//{0} {1} by CScriptConstSyncAttribute", LogDateTime, SyncResult);

                string FileContentNew = "";
                if (SyncResult == SyncResults.Update)
                {
                    FileContentNew = FileContent.Replace(JsAlready, Line + "\r\n" + JsGenerated);
                }
                else if (SyncResult == SyncResults.Append)
                {
                    FileContentNew = FileContent + "\r\n" + Line + "\r\n" + JsGenerated;
                }

                CFile.WriteTextToFile(FullPath, FileContentNew);
                CFile.WriteTextToFile(FullPathBackup, FileContent);
            }

            return(new CSyncReturn()
            {
                SyncResult = SyncResult,
                FullPathOfJavaScript = FullPath,
                FullPathOfJavaScriptBackup = FullPathBackup
            });
        }
Esempio n. 4
0
        public string ConvertToSsml(string TextToSpeak)
        {
            //숫자 읽는 방식은 say-as로 변경 가능함. (telephone으로 설정해도 전화번호 형식이 아니면 안됨)
            //<say-as interpret-as="telephone">1-800-282-0114</say-as>
            //http://msdn.microsoft.com/en-us/library/dd450828(v=office.13).aspx

            //속도는 <prosody rate="+100%">two time fast.</prosody>

            //원래는 xmlns="http://www.w3.org/2001/10/synthesis" 이나 xmlns 속성이 자동으로 생겨 :w를 추가함.
            string XmlTemplate =
                @"<?xml version=""1.0""?>
<speak version=""1.0""
	xmlns:w=""http://www.w3.org/2001/10/synthesis""
	xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance""
	xsi:schemaLocation=""http://www.w3.org/2001/10/synthesis
	http://www.w3.org/TR/speech-synthesis/synthesis.xsd""
	xml:lang=""en-US"">
</speak>";
            XmlDocument XDoc = new XmlDocument();

            XDoc.LoadXml(XmlTemplate);
            XmlElement Doc = XDoc.DocumentElement;


            //string Pattern = "(^" + VarMan + ")|(^" + VarWoman + ")|(^" + VarBreak + "(?<Seconds>\\d+[\\.\\d]*))";
            string Pattern = string.Format("(?<Man>{0})|(?<Woman>{1})|(?<Break>{2})|(?<Ignore>{3})", _Variable.Man, _Variable.Woman, _Variable.Break, _Variable.Ignore);
            Regex  r       = new Regex(Pattern, CRegex.Options.Compiled_Multiline_IgnoreCase_IgnorePatternWhitespace);

            List <XmlAttribute> aAttr      = new List <XmlAttribute>();
            List <XmlElement>   aElemBreak = new List <XmlElement>();

            XmlElement VoiceCur = XDoc.CreateElement("voice");

            foreach (CMatchInfo mi in CRegex.GetMatchResult(r, TextToSpeak))
            {
                Match m = mi.Match;

                string Value = CFindRep.TrimWhiteSpace(mi.ValueBeforeMatch);
                if (!string.IsNullOrEmpty(Value))
                {
                    //int PosColon = Value.IndexOf(":");
                    //if (PosColon != -1)
                    //{
                    //    CParagraph p = new CParagraph();
                    //    List<string> aWord = p.GetWords(Value.Substring(0, PosColon + 1), false);
                    //    throw new Exception(aWord[aWord.Count - 1] + ":은 잘못된 변수명입니다. ':' 문자열을 지우거나 허용된 변수명을 입력하세요.");
                    //}

                    AddElementVoice(XDoc, Value, VoiceCur);
                    VoiceCur = XDoc.CreateElement("voice");
                }

                if (m == null)
                {
                    break;
                }

                if (!string.IsNullOrEmpty(m.Groups["Man"].Value))
                {
                    foreach (XmlAttribute AttrCur in GetAttrNameGender(XDoc, false))
                    {
                        VoiceCur.Attributes.Append(AttrCur);
                    }
                }
                else if (!string.IsNullOrEmpty(m.Groups["Woman"].Value))
                {
                    foreach (XmlAttribute AttrCur in GetAttrNameGender(XDoc, true))
                    {
                        VoiceCur.Attributes.Append(AttrCur);
                    }
                }
                else if (!string.IsNullOrEmpty(m.Groups["Break"].Value))
                {
                    VoiceCur.AppendChild(GetElementBreak(XDoc, m.Groups["Seconds"].Value));
                }
                else if (!string.IsNullOrEmpty(m.Groups["Ignore"].Value))
                {
                    //
                }
            }

            string Indented = CXml.GetIndentedContent(XDoc);

            return(Indented);
            //return XDoc.OuterXml;
        }