예제 #1
0
파일: Activity.cs 프로젝트: qpidthc/QPID
        public void clearLogActivity(string activity, out Error error)
        {
            error = null;
            string               strSQL = "";
            SqlParameter         sqlParam;
            IList <SqlParameter> paraList = new System.Collections.Generic.List <SqlParameter>();

            THC_Library.DataBase.DataBaseControl dbCtl = new THC_Library.DataBase.DataBaseControl();
            try
            {
                dbCtl.Open();
                dbCtl.BeginTransaction();

                strSQL         = "delete from event_user_records where EUR002=@EUR002";
                sqlParam       = new SqlParameter("@EUR002", SqlDbType.Int);
                sqlParam.Value = activity;
                paraList.Add(sqlParam);
                dbCtl.ExecuteCommad(strSQL, paraList);
                dbCtl.CommintTransaction();
            }
            catch (Exception ex)
            {
                dbCtl.RollBackTransaction();
                error              = new Error();
                error.Number       = 305;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbCtl.Close();
            }
        }
예제 #2
0
        public void doResetPassword(string acc, string access_code, string pwd, out Error error)
        {
            error = null;
            bool bCodeExist = false;

            SqlParameter         sqlParam;
            IList <SqlParameter> paraList = new System.Collections.Generic.List <SqlParameter>();
            string strSQL = "select PT001 from password_temp where PT001=@PT001 and PT002=@PT002";

            THC_Library.DataBase.DataBaseControl dbCtl = new THC_Library.DataBase.DataBaseControl();

            try
            {
                sqlParam       = new SqlParameter("@PT001", SqlDbType.VarChar);
                sqlParam.Value = acc;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@PT002", SqlDbType.Char);
                sqlParam.Value = access_code;
                paraList.Add(sqlParam);


                dbCtl.Open();
                IDataReader dataReader = dbCtl.GetReader(strSQL, paraList);
                if (dataReader.Read())
                {
                    bCodeExist = true;
                }
                dataReader.Close();

                if (bCodeExist)
                {
                    byte[] pwdBytes = System.Text.Encoding.Default.GetBytes(pwd);                     //將字串來源轉為Byte[]
                    System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create(); //使用MD5
                    pwdBytes = md5.ComputeHash(pwdBytes);                                             //進行加密
                    pwd      = Convert.ToBase64String(pwdBytes);                                      //將加密後的字串從byte[]轉回string

                    dbCtl.BeginTransaction();
                    strSQL = "update consumer_member set CM007=@CM007 where CM002=@CM002";
                    paraList.Clear();
                    sqlParam       = new SqlParameter("@CM007", SqlDbType.VarChar);
                    sqlParam.Value = pwd;
                    paraList.Add(sqlParam);
                    sqlParam       = new SqlParameter("@CM002", SqlDbType.VarChar);
                    sqlParam.Value = acc;
                    paraList.Add(sqlParam);
                    dbCtl.ExecuteCommad(strSQL, paraList);

                    strSQL = "delete password_temp where PT001=@PT001";
                    paraList.Clear();
                    sqlParam       = new SqlParameter("@PT001", SqlDbType.VarChar);
                    sqlParam.Value = acc;
                    paraList.Add(sqlParam);
                    dbCtl.ExecuteCommad(strSQL, paraList);

                    dbCtl.CommintTransaction();
                }
                else
                {
                    throw new THC_Library.THCException(330, "無效的授權");
                }
            }
            catch (THCException thcEx)
            {
                dbCtl.RollBackTransaction();
                error              = new Error();
                error.Number       = thcEx.Number;
                error.ErrorMessage = thcEx.Message;
            }
            catch (Exception ex)
            {
                dbCtl.RollBackTransaction();
                error              = new Error();
                error.Number       = 301;
                error.ErrorMessage = ex.ToString();
            }
        }
예제 #3
0
파일: Activity.cs 프로젝트: qpidthc/QPID
        public void asyncActivity(string activity, out Error error)
        {
            error = null;
            string               strSQL = "";
            SqlParameter         sqlParam;
            IList <SqlParameter> paraList = new System.Collections.Generic.List <SqlParameter>();

            THC_Library.DataBase.DataBaseControl dbCtl = new THC_Library.DataBase.DataBaseControl();
            try
            {
                dynamic arrayJson   = Newtonsoft.Json.JsonConvert.DeserializeObject(activity);
                dynamic activityObj = arrayJson[0];
                dbCtl.Open();
                dbCtl.BeginTransaction();

                paraList.Clear();
                strSQL         = "delete from activity_event where AE001=@AE001";
                sqlParam       = new SqlParameter("@AE001", SqlDbType.Int);
                sqlParam.Value = activityObj.AE001;
                paraList.Add(sqlParam);
                dbCtl.ExecuteCommad(strSQL, paraList);

                paraList.Clear();
                sqlParam       = new SqlParameter("@AE001", SqlDbType.Int);
                sqlParam.Value = activityObj.AE001;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE002", SqlDbType.NVarChar);
                sqlParam.Value = activityObj.AE002;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE003", SqlDbType.NVarChar);
                sqlParam.Value = activityObj.AE003;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE004", SqlDbType.NVarChar);
                sqlParam.Value = activityObj.AE004;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE005", SqlDbType.VarChar);
                sqlParam.Value = activityObj.AE005;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE006", SqlDbType.VarChar);
                sqlParam.Value = activityObj.AE006;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE007", SqlDbType.Int);
                sqlParam.Value = activityObj.AE007;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE008", SqlDbType.NVarChar);
                sqlParam.Value = activityObj.AE008;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE009", SqlDbType.VarChar);
                sqlParam.Value = activityObj.AE009;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE010", SqlDbType.Char);
                sqlParam.Value = activityObj.AE010;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE011", SqlDbType.NVarChar);
                sqlParam.Value = activityObj.AE011;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE012", SqlDbType.SmallInt);
                sqlParam.Value = activityObj.AE012;
                paraList.Add(sqlParam);
                sqlParam       = new SqlParameter("@AE013", SqlDbType.VarChar);
                sqlParam.Value = activityObj.AE013;
                paraList.Add(sqlParam);

                strSQL = "insert into activity_event values (@AE001,@AE002,@AE003,@AE004,@AE005,@AE006," +
                         "@AE007,@AE008,@AE009,@AE010,@AE011,@AE012,@AE013)";
                dbCtl.ExecuteCommad(strSQL, paraList);

                dbCtl.CommintTransaction();
            }
            catch (Exception ex)
            {
                dbCtl.RollBackTransaction();
                error              = new Error();
                error.Number       = 305;
                error.ErrorMessage = ex.ToString();
            }
            finally
            {
                dbCtl.Close();
            }
        }