Пример #1
0
        /// <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);
        }
Пример #2
0
        /// <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);
        }
        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));
        }
Пример #4
0
        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;
        }