/// <summary> /// 통신에서 전송시 깨지지 않도록 61진수 형태로 변환된 Unicode 문자열을 원래의 문자열로 변환함. /// </summary> /// <param name="Text"></param> /// <param name="Delim"></param> /// <returns></returns> public static string DecryptUnicode(string Text) { const char Delim = '|'; string All = ""; string s = ""; for (int i = 0, i2 = Text.Length; i < i2; i++) { char c = Text[i]; if (c == Delim) { if (Text.Substring(i + 1, 1) != Delim.ToString()) { string Num61 = Text.Substring(i + 1, 3); int AscCode = (int)CMath.Get10FromN(Num61, 61); s = ((char)AscCode).ToString(); i += 3; } else { s = c.ToString(); i++; } } else { s = c.ToString(); } All += s; } return(All); }
/// <summary> /// Unicode 문자열을 통신에서 전송시 깨지지 않도록 61진수 형태로 변환함. /// </summary> /// <param name="Text"></param> /// <param name="Delim"></param> /// <returns></returns> public static string EncryptUnicode(string Text, bool EncodeUrlParam) { const char Delim = '|'; string All = ""; string s = ""; for (int i = 0, i2 = Text.Length; i < i2; i++) { char c = Text[i]; if (CTwoByte.Is2ByteChar(c)) { int AscCode = (int)c; string Num61 = CMath.GetNFrom10(AscCode, 61); s = Delim + Num61.PadRight(3); } else if (c == Delim) { s = Delim.ToString() + Delim.ToString(); } else { s = EncodeUrlParam ? HttpUtility.UrlEncode(c.ToString()) : c.ToString(); } All += s; } return(All); }
private Instruction NextInstruction(Tokenizer tokenizer, object source) { // check if there is an end-command semicolon delimiter. if so, run this function again starting from that position in the text Delim semicolonDelim = CodeRules._instruction_finished_delimiter_ignore_rest[0]; int semicolonIndex = tokenizer.IndexOf(semicolonDelim); if (semicolonIndex >= 0) { int startIndex = tokenizer.tokens[semicolonIndex].index + semicolonDelim.text.Length; //Show.Log("found next instruction at " + startIndex); string nextText = tokenizer.str.Substring(startIndex); //Show.Log(nextText); return(new Instruction(nextText, source)); } return(null); }
public string Join <T>(T[] list) { string[] strList; if (list is string[]) { strList = list as string[]; } else { strList = new string[list.Length]; for (int i = 0; i < list.Length; i++) { strList[i] = list[i].ToString(); } } return(string.Join(Delim.ToString(), strList)); }
/// <summary>Given a file path, sniffs the target to be either tabbed or CSV deliminated</summary> /// <param name="path">Path to a physical file to test</param> /// <returns>The format type as an enum</returns> /// <remarks>The logic sucks - its just a basic test</remarks> public static Delim Sniffer(string path) { Delim results = Delim.Unknown; if (String.IsNullOrWhiteSpace(path)) { return(results); } // check the file exists FileInfo fi = new FileInfo(path); if (!fi.Exists) { return(results); } // read the file using (StreamReader reader = new StreamReader(path, Encoding.UTF8)) { // read the first line string next = reader.ReadLine(); // if there is a first line if (!String.IsNullOrWhiteSpace(next)) { // now split string[] tabs = next.Split(new char[] { '\t' }, StringSplitOptions.None); string[] commas = next.Split(new char[] { ',' }, StringSplitOptions.None); results = (tabs.Length > commas.Length) ? Delim.Tab : Delim.Comma; } } return(results); }
void tmr_Elapsed(object sender, ElapsedEventArgs e) { const char Delim = '─'; if (this.mRunning) { return; } else { this.mRunning = true; } string LogFullPath = GetLogFullPath(); string LogFolderForSync = Path.GetDirectoryName(LogFullPath); try { CXmlConfig xc = GetXmlConfig(); string[] aRootPathSrc = xc.GetSetting("RootPathSrc", "").Split(Delim); string[] aFtpHost = xc.GetSetting("FtpHost", "").Split(Delim); string[] aFtpId = xc.GetSetting("FtpId", "").Split(Delim); string[] aFtpPassword = xc.GetSetting("FtpPassword", "").Split(Delim); for (int i = 0; i < aFtpPassword.Length; i++) { aFtpPassword[i] = CEncrypt.DecryptPassword(aFtpPassword[i]); } string[] aFtpFolder = xc.GetSetting("FtpFolder", "").Split(Delim); string[] aSyncType = xc.GetSetting("SyncType", "").Split(Delim); string[] aMinifyJs = xc.GetSetting("MinifyJs", "").Split(Delim); string[] aFileNameToAppendParam = xc.GetSetting("FileNameToAppendParam", "").Split(Delim); string[] asDateTimeAfter = xc.GetSetting("DateTimeAfter", "").Split(Delim); DateTime[] aDateTimeAfter = new DateTime[asDateTimeAfter.Length]; for (int i = 0; i < asDateTimeAfter.Length; i++) { aDateTimeAfter[i] = CFindRep.IfNotDateTimeThen19000101(asDateTimeAfter[i]); } for (int i = 0; i < aRootPathSrc.Length; i++) { CFtpInfoSync[] aFtpInfo = new CFtpInfoSync[] { new CFtpInfoSync() { Host = aFtpHost[i], UserId = aFtpId[i], Password = aFtpPassword[i], Folder = aFtpFolder[i] } }; CSyncFile sf = new CSyncFile(aRootPathSrc[i], aFtpInfo, CEnum.GetValueByName <SyncTypes>(aSyncType[i]), (aMinifyJs[i] == "1"), aFileNameToAppendParam, aDateTimeAfter[i], LogFolderForSync); sf.DisallowedFolder = new string[] { LogFolderForSync }; sf.CopyAll(); aDateTimeAfter[i] = DateTime.Now; } for (int i = 0; i < aDateTimeAfter.Length; i++) { asDateTimeAfter[i] = aDateTimeAfter[i].ToString(CConst.Format_yyyy_MM_dd_HH_mm_ss); } xc.SaveSetting("DateTimeAfter", string.Join(Delim.ToString(), asDateTimeAfter)); } catch (Exception ex) { CFile.AppendTextToFile(LogFullPath, "Error " + DateTime.Now.ToString() + "\r\n" + ex.Message + "\r\n" + ex.StackTrace + "\r\n" + ex.Source); } this.mRunning = false; }