예제 #1
0
        public static OracleConnection OpenConnection(string DBName)
        {
            string stConnect = System.Configuration.ConfigurationManager.AppSettings[DBName].ToString();

            stConnect = EnCode.DeCodeToString(stConnect, _key);

            //string fcc_test = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.49.5)(PORT=1521))(CONNECT_DATA=(SID=fptcv)));User ID=VIENTH;Password=Vien123";
            //string fcc_live = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.42.12)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=fcscb)));User ID=VIENTH;Password=Vien123";
            //string CW_DW = "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.46.14)(PORT=3020))(CONNECT_DATA=(SID=DW)));User ID=ccps;Password=cwccpsdw";

            //string s = EnCode.EnCodeToString(a, _key);

            OracleConnection sqlConnect;

            try
            {
                sqlConnect = new OracleConnection(stConnect);
                sqlConnect.Open();
                return(sqlConnect);
            }
            catch
            {
                return(null);
            }
        }
예제 #2
0
        public int GhiT140XuongDB(MC_T140 data)
        {
            DateTime runDate       = DateTime.ParseExact(data.runDate, "dd'/'MM'/'yy", null);
            DateTime clearingDate  = DateTime.ParseExact(data.clearingDate, "dd'/'MM'/'yyyy", null);
            int      numofinserted = -1;

            string sqlConnStr = System.Configuration.ConfigurationManager.AppSettings["SQLServerMasterCard"];

            sqlConnStr = EnCode.DeCodeToString(sqlConnStr, _key);
            SqlConnection sqlConn = new SqlConnection(sqlConnStr);

            sqlConn.Open();
            SqlCommand sqlCmd = new SqlCommand("INSERT_T140_GCMS_REPORT", sqlConn);

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.Parameters.Add(new SqlParameter("@FILENAME", data.filename));
            sqlCmd.Parameters.Add(new SqlParameter("@NEWFILENAME", data.newfilename));
            sqlCmd.Parameters.Add(new SqlParameter("@RUNDATE", runDate));
            sqlCmd.Parameters.Add(new SqlParameter("@CLEARINGDATE", clearingDate));
            sqlCmd.Parameters.Add(new SqlParameter("@CYCLE", data.clearingCycle));
            //sqlCmd.Parameters.Add(new SqlParameter("@CURRENCYCODE", data.currencyCode));
            sqlCmd.Parameters.Add(new SqlParameter("@USDAMOUNT", data.USDAmount));
            sqlCmd.Parameters.Add(new SqlParameter("@VNDAMOUNT", data.VNDAmount));

            try{
                numofinserted = sqlCmd.ExecuteNonQuery();
            }
            catch {}

            sqlConn.Close();
            //dtIPC = ICMSDataWithOrderIdx(ipcData);
            //return dtIPC;
            return(numofinserted);
        }
예제 #3
0
        public DataTable LoadCurrencyRateFromDB(string Currencydate)
        {
            DataTable data = new DataTable();
            DateTime  date = DateTime.ParseExact(Currencydate, "dd'/'MM'/'yyyy", null);

            //DateTime toDate = DateTime.ParseExact(denngay, "dd'/'MM'/'yyyy", null);

            string sqlConnStr = System.Configuration.ConfigurationManager.AppSettings["SQLServerMasterCard"];

            sqlConnStr = EnCode.DeCodeToString(sqlConnStr, _key);
            SqlConnection sqlConn = new SqlConnection(sqlConnStr);

            sqlConn.Open();
            DataTable  ipcData = new DataTable();
            SqlCommand sqlCmd  = new SqlCommand("SEARCH_T057_CURRENCY_CONVERSION_RATE", sqlConn);

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.Parameters.Add(new SqlParameter("@RATEDATE", date));
            //sqlCmd.Parameters.Add(new SqlParameter("@TOCLEARINGDATE", toDate));
            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);

            sqlDa.Fill(data);
            sqlConn.Close();
            return(data);
        }
예제 #4
0
        public void ThucThiProc(string ProcName, string ServerName)
        {
            string strConn = System.Configuration.ConfigurationManager.AppSettings[ServerName].ToString();

            strConn = EnCode.DeCodeToString(strConn, _key);
            SqlConnection conn = new SqlConnection(strConn);

            conn.Open();
            SqlCommand cmd = new SqlCommand(ProcName, conn);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            conn.Close();
        }
예제 #5
0
파일: EnCodeTests.cs 프로젝트: cwd29/sim
        public void BlendAndEndWithSame_1()
        {
            var code = new EnCode();
            var src  = new byte[] { 111, 111, 120, 111, 111, 111 };

            byte[] dst;
            code.Coding(src, out dst);

            var exceptData = new byte[] { 3, 111, 111, 120, 128 + 3, 111 };

            Assert.AreEqual(exceptData.Length, dst.Length);
            for (var i = 0; i < exceptData.Length; i++)
            {
                Assert.AreEqual(exceptData[i], dst[i]);
            }
        }
예제 #6
0
파일: EnCodeTests.cs 프로젝트: cwd29/sim
        public void ThreeSameData()
        {
            var code = new EnCode();
            var src  = new byte[] { 111, 111, 111 };

            byte[] dst;
            code.Coding(src, out dst);

            Assert.AreEqual(2, dst.Length);
            var exceptData = new Byte[] { 128 + 3, 111 };

            for (var i = 0; i < exceptData.Length; i++)
            {
                Assert.AreEqual(exceptData[i], dst[i]);
            }
        }
예제 #7
0
파일: EnCodeTests.cs 프로젝트: cwd29/sim
        public void TwoDifferentDataTest()
        {
            var code = new EnCode();
            var src  = new byte[] { 110, 111 };

            byte[] dst;
            code.Coding(src, out dst);

            Assert.AreEqual(3, dst.Length);
            var exceptData = new byte[] { 2, 110, 111 };

            for (var i = 0; i < exceptData.Length; i++)
            {
                Assert.AreEqual(exceptData[i], dst[i]);
            }
        }
예제 #8
0
파일: EnCodeTests.cs 프로젝트: cwd29/sim
        public void SeriesDifferentData()
        {
            var code = new EnCode();
            var src  = new byte[] { 111, 111, 123, 122, 111, 122 };

            byte[] dst;
            code.Coding(src, out dst);


            var exceptData = new byte[] { 6, 111, 111, 123, 122, 111, 122 };

            Assert.AreEqual(exceptData.Length, dst.Length);
            for (var i = 0; i < exceptData.Length; i++)
            {
                Assert.AreEqual(exceptData[i], dst[i]);
            }
        }
예제 #9
0
        public static string From(byte[] b, EnCode t)
        {
            switch (t)
            {
            case EnCode.Ascii:
                return(new ASCIIEncoding().GetString(b));

            case EnCode.Unicode:
                return(new UnicodeEncoding().GetString(b));

            case EnCode.Utf7:
                return(new UTF7Encoding().GetString(b));

            case EnCode.Utf8:
                return(new UTF8Encoding().GetString(b));
            }
            return(string.Empty);
        }
예제 #10
0
        /// <summary>
        /// 读取文件内容
        /// </summary>
        /// <param name="Path">相对路径</param>
        /// <param name="FileEncoding">文件的编码格式如: Encode.GB2312</param>
        /// <returns></returns>
        public static string Read(string Path, EnCode FileEncoding)
        {
            StreamReader reader;
            string       str = string.Empty;

            if (!Exists(Path))
            {
                return("{WsErr}未找到该文件:" + Path + "!");
            }
            switch (FileEncoding)
            {
            case EnCode.GB2312:
                reader = new StreamReader(Path, Encoding.GetEncoding("GB2312"));
                break;

            case EnCode.Big5:
                reader = new StreamReader(Path, Encoding.GetEncoding("Big5"));
                break;

            case EnCode.UTF8:
                reader = new StreamReader(Path, Encoding.UTF8);
                break;

            case EnCode.ASCII:
                reader = new StreamReader(Path, Encoding.ASCII);
                break;

            case EnCode.Unicode:
                reader = new StreamReader(Path, Encoding.Unicode);
                break;

            default:
                reader = new StreamReader(Path, Encoding.Default);
                break;
            }
            str = reader.ReadToEnd();
            reader.Close();
            return(str);
        }
예제 #11
0
        static void Main(string[] args)
        {
            Encoding unicode = Encoding.Unicode;

            Console.OutputEncoding = unicode;

            Console.Write("Enter key ");
            string key = Console.ReadLine();

            Console.WriteLine("Word to encode ");
            string word = Console.ReadLine();

            EnCode incode     = new EnCode();
            string incodeword = incode.GetWord(key, word);

            DeCode decode     = new DeCode();
            string decodeword = decode.GetWord(key, incodeword);

            Console.WriteLine("Encoding word " + word);
            Console.WriteLine("Result: " + incodeword);

            Console.WriteLine(decodeword);
        }
예제 #12
0
        public DataTable TimT140GCSMTheoNgayClearing(string tungay, string denngay)
        {
            DataTable data     = new DataTable();
            DateTime  fromDate = DateTime.ParseExact(tungay, "dd'/'MM'/'yyyy", null);
            DateTime  toDate   = DateTime.ParseExact(denngay, "dd'/'MM'/'yyyy", null);

            string sqlConnStr = System.Configuration.ConfigurationManager.AppSettings["SQLServerMasterCard"];

            sqlConnStr = EnCode.DeCodeToString(sqlConnStr, _key);
            SqlConnection sqlConn = new SqlConnection(sqlConnStr);

            sqlConn.Open();
            DataTable  ipcData = new DataTable();
            SqlCommand sqlCmd  = new SqlCommand("SEARCH_T140_GCMS_REPORT_BY_CLEARINGDATE", sqlConn);

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.Parameters.Add(new SqlParameter("@FROMCLEARINGDATE", fromDate));
            sqlCmd.Parameters.Add(new SqlParameter("@TOCLEARINGDATE", toDate));
            SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);

            sqlDa.Fill(data);
            sqlConn.Close();
            return(data);
        }
예제 #13
0
        public int GhiT057XuongDB(MC_T057 data, int i)
        {
            //string date = data.date.Substring(0, 2) + "/" + data.date.Substring(2, 2) + "/" + data.date.Substring(4, 4);
            DateTime currencyDate = DateTime.ParseExact(data.date, "dd'/'MM'/'yyyy", null);
            //DateTime clearingDate = DateTime.ParseExact(data.clearingDate, "dd'/'MM'/'yy", null);
            int numofinserted = -1;

            string sqlConnStr = System.Configuration.ConfigurationManager.AppSettings["SQLServerMasterCard"];

            sqlConnStr = EnCode.DeCodeToString(sqlConnStr, _key);
            SqlConnection sqlConn = new SqlConnection(sqlConnStr);

            sqlConn.Open();
            SqlCommand sqlCmd = new SqlCommand("INSERT_T057_CURRENCY_CONVERSION_RATE", sqlConn);

            sqlCmd.CommandType = CommandType.StoredProcedure;
            sqlCmd.Parameters.Add(new SqlParameter("@FILENAME", data.filename));
            sqlCmd.Parameters.Add(new SqlParameter("@NEWFILENAME", data.newfilename));
            sqlCmd.Parameters.Add(new SqlParameter("@RATEDATE", currencyDate));
            sqlCmd.Parameters.Add(new SqlParameter("@SOURCECODE", data.detail[i].sourceCurrencyCode));
            sqlCmd.Parameters.Add(new SqlParameter("@REFERENCECODE", data.detail[i].referenceCurrencyCode));
            sqlCmd.Parameters.Add(new SqlParameter("@CURRENCYEXPONENT", data.detail[i].sourceCurrencyExponent));
            sqlCmd.Parameters.Add(new SqlParameter("@RATECLASS", data.detail[i].rateClass));
            sqlCmd.Parameters.Add(new SqlParameter("@BUYRATE", data.detail[i].buyCurrencyConversionRate));
            sqlCmd.Parameters.Add(new SqlParameter("@MIDRATE", data.detail[i].midCurrencyConversionRate));
            sqlCmd.Parameters.Add(new SqlParameter("@SELLRATE", data.detail[i].sellCurrencyConversionRate));

            try
            {
                numofinserted = sqlCmd.ExecuteNonQuery();
            }
            catch { }

            sqlConn.Close();
            return(numofinserted);
        }
예제 #14
0
파일: File.cs 프로젝트: svn2github/Voodoo
        /// <summary>
        /// 读取文件内容
        /// </summary>
        /// <param name="Path">相对路径</param>
        /// <param name="FileEncoding">文件的编码格式如: Encode.GB2312</param>
        /// <returns></returns>
        public static string Read(string Path, EnCode FileEncoding)
        {
            StreamReader reader;
            string str = string.Empty;
            if (!Exists(Path))
            {
                return ("{WsErr}未找到该文件:" + Path + "!");
            }
            switch (FileEncoding)
            {
                case EnCode.GB2312:
                    reader = new StreamReader(Path, Encoding.GetEncoding("GB2312"));
                    break;

                case EnCode.Big5:
                    reader = new StreamReader(Path, Encoding.GetEncoding("Big5"));
                    break;

                case EnCode.UTF8:
                    reader = new StreamReader(Path, Encoding.UTF8);
                    break;

                case EnCode.ASCII:
                    reader = new StreamReader(Path, Encoding.ASCII);
                    break;

                case EnCode.Unicode:
                    reader = new StreamReader(Path, Encoding.Unicode);
                    break;

                default:
                    reader = new StreamReader(Path, Encoding.Default);
                    break;
            }
            str = reader.ReadToEnd();
            reader.Close();
            return str;
        }
예제 #15
0
        private void btnDecode_Click(object sender, EventArgs e)
        {
            string key = txtKey.Text;

            txtString2.Text = EnCode.DeCodeToString(txtString1.Text, key);
        }