コード例 #1
0
        private void btnSure_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtOriginalPassword.Text.Trim() == string.Empty)
                {
                    MessageBoxs.Show(Trans.COM, this.ToString(), "原密码不可为空", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (!LoginInfoDAX.UserPassword.Equals(CryptoHelp.EncodeToMD5(txtOriginalPassword.Text.Trim())))
                {
                    MessageBoxs.Show(Trans.COM, this.ToString(), "原密码错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (txtNewPassword.Text.Trim() == string.Empty)
                {
                    MessageBoxs.Show(Trans.COM, this.ToString(), "新密码不可为空", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                if (txtNewPassword.Text.Trim() != txtSurePassword.Text.Trim())
                {
                    MessageBoxs.Show(Trans.COM, this.ToString(), "新密码和确认密码不一致", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                DialogResult dr = MessageBoxs.Show(Trans.COM, this.ToString(), "您将要修改密码!\r\n单击【确定】继续,【取消】返回。", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
                if (dr != DialogResult.OK)
                {
                    return;
                }
                MDLSM_User userQuery = new MDLSM_User();
                userQuery.WHERE_User_ID = LoginInfoDAX.UserID;
                MDLSM_User userResult = new MDLSM_User();
                _bll.QueryForObject <MDLSM_User, MDLSM_User>(userQuery, userResult);
                userResult.WHERE_User_ID        = LoginInfoDAX.UserID;
                userResult.WHERE_User_VersionNo = userResult.User_VersionNo;
                userResult.User_Password        = CryptoHelp.EncodeToMD5(txtNewPassword.Text.Trim());
                userResult.User_VersionNo      += 1;
                bool boolTmp = _bll.Save <MDLSM_User>(userResult);
                if (!boolTmp)
                {
                    MessageBoxs.Show(Trans.COM, this.ToString(), "保存失败!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                else
                {
                    MessageBoxs.Show(Trans.COM, this.ToString(), "保存成功!", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    this.Close();
                    _supplierMain.DialogResult = DialogResult.Yes;
                    _supplierMain.Close();
                    _flg.Show();
                }
            }
            catch (Exception ex)
            {
                MessageBoxs.Show(Trans.COM, this.ToString(), ex.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error);
                LogHelper.WriteErrorLog(Trans.COM, System.Reflection.MethodBase.GetCurrentMethod().ToString() + SysConst.ENTER + ex.StackTrace, ex.Message, null, ex);
            }
        }
コード例 #2
0
        /// <summary>
        /// 将【详情】Tab内控件的值赋值给基类的DetailDS
        /// </summary>
        private void SetCardCtrlsToDetailDS()
        {
            DetailDS = new UserManagerUIModel
            {
                //用户ID
                User_ID = txtUser_ID.Text.Trim(),
                //姓名
                User_Name = txtUser_Name.Text.Trim(),
                //工号
                User_EMPNO = txtUser_EMPNO.Text.Trim(),
                //身份证号
                User_IDNo = txtUser_IDNo.Text.Trim(),
                //性别
                User_Sex = cbUser_Sex.Text.Trim(),
                //地址
                User_Address = txtUser_Address.Text.Trim(),
                //电话号码
                User_PhoneNo = txtUser_PhoneNo.Text.Trim(),
                //是否允许微信认证
                User_IsAllowWechatCertificate = ckUser_IsAllowWechatCertificate.Checked,
                //是否已微信认证
                User_IsWechatCertified = ckUser_IsWechatCertified.Checked,
                //打印标题前缀
                User_PrintTitlePrefix = txtUser_PrintTitlePrefix.Text.Trim(),
                //有效
                User_IsValid = ckUser_IsValid.Checked,
                //创建人
                User_CreatedBy = txtUser_CreatedBy.Text,
                //创建时间
                User_CreatedTime = (DateTime?)dtUser_CreatedTime.Value ?? BLLCom.GetCurStdDatetime(),
                //修改人
                User_UpdatedBy = txtUser_UpdatedBy.Text,
                //修改时间
                User_UpdatedTime = (DateTime?)dtUser_UpdatedTime.Value ?? BLLCom.GetCurStdDatetime(),
                //版本号
                User_VersionNo = Convert.ToInt64(txtUser_VersionNo.Text.Trim() == "" ? "1" : txtUser_VersionNo.Text.Trim()),
            };

            //密码
            string encodePassword = null;

            if (!string.IsNullOrEmpty(txtUser_Password.Text.Trim()))
            {
                if (txtUser_Password.Text.Trim() != _oldPassword)
                {
                    encodePassword = CryptoHelp.EncodeToMD5(txtUser_Password.Text.Trim());
                }
                else
                {
                    encodePassword = txtUser_Password.Text.Trim();
                }
            }
            else
            {
                encodePassword = CryptoHelp.EncodeToMD5(SysConst.USER_INITIAL_PASSWORD);
            }
            DetailDS.User_Password = encodePassword;
        }
コード例 #3
0
        /// <summary>
        /// 前端检查-提现
        /// </summary>
        /// <returns></returns>
        private bool ClientCheckForWithdrawal()
        {
            //验证密码
            if (string.IsNullOrEmpty(txtWal_TradingPassword.Text.Trim()))
            {
                MessageBoxs.Show(Trans.RIA, ToString(), MsgHelp.GetMsg(MsgCode.E_0001, new object[] { MsgParam.PASSWORD }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (_withdrawalInfo.Wal_TradingPassword != CryptoHelp.EncodeToMD5(txtWal_TradingPassword.Text.Trim()))
            {
                //密码错误
                MessageBoxs.Show(Trans.RIA, ToString(), MsgHelp.GetMsg(MsgCode.E_0011, new object[] { MsgParam.PASSWORD }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            //验证钱包
            if (string.IsNullOrEmpty(txtWal_No.Text))
            {
                //没有获取到钱包,提现失败
                MessageBoxs.Show(Trans.RIA, ToString(), MsgHelp.GetMsg(MsgCode.W_0024, new object[] { MsgParam.WALLET, SystemActionEnum.Name.WITHDRAWCASH }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            WalletInfoUIModel curWallet = BLLCom.GetWalletByWalletNo(txtWal_No.Text);

            if (string.IsNullOrEmpty(curWallet.Wal_ID) ||
                string.IsNullOrEmpty(curWallet.Wal_No))
            {
                //没有获取到钱包,提现失败
                MessageBoxs.Show(Trans.RIA, ToString(), MsgHelp.GetMsg(MsgCode.W_0024, new object[] { MsgParam.WALLET, SystemActionEnum.Name.WITHDRAWCASH }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            //验证本次提现金额
            if (numThisWithdrawalAmount.Value == null ||
                Convert.ToDecimal(numThisWithdrawalAmount.Value) == 0)
            {
                //本次提现金额不能为零!
                MessageBoxs.Show(Trans.RIA, ToString(), MsgHelp.GetMsg(MsgCode.E_0000, new object[] { MsgParam.WITHDRAWALAMOUNT_CANNOTZERO }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }
            if (curWallet.Wal_AvailableBalance < Convert.ToDecimal(numThisWithdrawalAmount.Value))
            {
                //提现金额大于钱包可用余额,不能提现!
                MessageBoxs.Show(Trans.RIA, ToString(), MsgHelp.GetMsg(MsgCode.E_0017, new object[] { "提现金额大于钱包可用余额", SystemActionEnum.Name.WITHDRAWCASH }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            //确定要提现吗?
            DialogResult dialogResult = MessageBoxs.Show(Trans.RIA, ToString(), MsgHelp.GetMsg(MsgCode.I_0003, new object[] { SystemActionEnum.Name.WITHDRAWCASH }), MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (dialogResult != DialogResult.OK)
            {
                return(false);
            }

            return(true);
        }
コード例 #4
0
        /// <summary>
        /// 更新AppConfig
        /// </summary>
        /// <param name="paramJObject"></param>
        private static void ChangeAppConfiguration(JObject paramJObject, string paramActiveCode)
        {
            //读取程序集的配置文件
            Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            //商户编码
            string mctCode = paramJObject["MCT_Code"] == null ? "" : paramJObject["MCT_Code"].ToString();
            //商户名称
            string mctName = paramJObject["MCT_Name"] == null ? "" : paramJObject["MCT_Name"].ToString();
            //数据连接字符串
            string systemConnString = paramJObject["MerchantServerConnectString"] == null
                ? ""
                : paramJObject["MerchantServerConnectString"].ToString();

            if (!string.IsNullOrEmpty(systemConnString))
            {
                string[] connstring = systemConnString.Split(';');
                if (!string.IsNullOrEmpty(connstring[0]) && !string.IsNullOrEmpty(connstring[1]) && !string.IsNullOrEmpty(connstring[2]) && !string.IsNullOrEmpty(connstring[3]))
                {
                    systemConnString = connstring[0].Substring(connstring[0].IndexOf("=", StringComparison.Ordinal) + 1) + ";"
                                       + connstring[1].Substring(connstring[1].IndexOf("=", StringComparison.Ordinal) + 1) + ";"
                                       + connstring[2].Substring(connstring[2].IndexOf("=", StringComparison.Ordinal) + 1) + ";"
                                       + connstring[3].Substring(connstring[3].IndexOf("=", StringComparison.Ordinal) + 1);
                }
            }
            //获取appSettings节点
            AppSettingsSection appSettings = (AppSettingsSection)config.GetSection("appSettings");

            //设置商户编码
            appSettings.Settings["MCT_Code"].Value = mctCode;
            //设置商户名称
            appSettings.Settings["MCT_Name"].Value = mctName;
            //设置商户激活码
            appSettings.Settings["MCT_ActivationCode"].Value = paramActiveCode;
            //设置数据连接字符串
            appSettings.Settings["SystemConnString"].Value = CryptoHelp.Encode(systemConnString);

            //保存配置文件
            config.Save();
        }
コード例 #5
0
        private long ChunkSize = 102400;//100K 每次读取文件,只读取100K,这样可以缓解服务器的压力

        /// <summary>
        /// 下载文件
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {
            SMT.Foundation.Log.Tracer.Debug("开始下载文件");
            try
            {
                //\SMT\OA\考勤管理\2010121702324784503941.JPG
                //string fileName = "123.jpg";//客户端保存的文件名
                if (context.Request.QueryString["filename"] == null)
                {
                    return;
                }
                String fileurl = HttpUtility.UrlDecode(context.Request.QueryString["filename"]);
                SMT.Foundation.Log.Tracer.Debug("下载文件地址:" + fileurl);
                // string filePath = string.Format(SavePath, fileName.Split('|')[0], fileName.Split('|')[1],  fileName.Split('|')[2]+"\\"+fileName.Split('|')[3]); //context.Server.MapPath("Bubble.jpg");
                string             filePath            = string.Format(FileConfig.GetCompanyItem(fileurl.Split('\\')[1]).SavePath, fileurl.Split('\\')[1], fileurl.Split('\\')[2], fileurl.Split('\\')[3] + "\\" + fileurl.Split('\\')[4]);
                string             NewfilePath         = string.Format(FileConfig.GetCompanyItem(fileurl.Split('\\')[1]).SavePath, fileurl.Split('\\')[1], fileurl.Split('\\')[2], fileurl.Split('\\')[3] + "\\" + fileurl.Split('\\')[5]);
                string             saveFileName        = fileurl.Split('\\')[5];                 //保存文件名
                string             StrServicesFileName = fileurl.Split('\\')[4].Substring(0, 8); //取前面的作为解密字符串
                System.IO.FileInfo fileInfo            = new System.IO.FileInfo(filePath);
                if (fileInfo.Exists == true)
                {
                    //byte[] buffer = new byte[ChunkSize];
                    //context.Response.Clear();
                    //string Key = this.key;
                    string Key = StrServicesFileName;

                    //DESCryptoServiceProvider des = new DESCryptoServiceProvider();
                    //des.Key = ASCIIEncoding.Default.GetBytes(Key);
                    //des.IV = ASCIIEncoding.Default.GetBytes(Key);

                    ////Create a file stream to read the encrypted file back.
                    //FileStream fsread = new FileStream(filePath, FileMode.Open,FileAccess.Read);
                    ////Create a DES decryptor from the DES instance.
                    //ICryptoTransform desdecrypt = des.CreateDecryptor();


                    //byte[] FileStreamArray = new byte[fsread.Length];
                    //fsread.Read(FileStreamArray, 0, FileStreamArray.Length);

                    //MemoryStream ms = new MemoryStream();
                    //CryptoStream FileCryptoStream = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Read);
                    //FileCryptoStream.Write(FileStreamArray, 0, FileStreamArray.Length);
                    //FileCryptoStream.FlushFinalBlock();
                    //FileStream filOutStream = new FileStream(NewfilePath, FileMode.OpenOrCreate, FileAccess.Write);
                    ////InputFileStream = File.OpenWrite(FileName);
                    //foreach (byte b in ms.ToArray())
                    //{
                    //    filOutStream.WriteByte(b);
                    //}
                    //fsread.Close();
                    //ms.Close();
                    //filOutStream.Close();
                    //filOutStream.Dispose();
                    CryptoHelp.DecryptFile(filePath, NewfilePath, StrServicesFileName);
                    //System.IO.FileStream iStream = System.IO.File.OpenRead(NewfilePath);
                    long   dataToRead;
                    int    length;
                    byte[] buffer = new Byte[300000];
                    System.IO.FileStream iStream = new System.IO.FileStream(NewfilePath, System.IO.FileMode.Open,
                                                                            System.IO.FileAccess.Read, System.IO.FileShare.Read);

                    //   Total   bytes   to   read:
                    dataToRead = iStream.Length;

                    context.Response.ContentType = "application/octet-stream";
                    context.Response.Charset     = "UTF-8";
                    context.Response.AddHeader("Content-Disposition", "attachment;   filename=" + System.Web.HttpUtility.UrlEncode(saveFileName, System.Text.Encoding.UTF8));

                    //   Read   the   bytes.
                    while (dataToRead > 0)
                    {
                        //   Verify   that   the   client   is   connected.
                        if (context.Response.IsClientConnected)
                        {
                            //   Read   the   data   in   buffer.
                            length = iStream.Read(buffer, 0, 300000);

                            //   Write   the   data   to   the   current   output   stream.
                            context.Response.OutputStream.Write(buffer, 0, length);

                            //   Flush   the   data   to   the   HTML   output.
                            context.Response.Flush();

                            buffer     = new Byte[300000];
                            dataToRead = dataToRead - length;
                        }
                        else
                        {
                            //prevent   infinite   loop   if   user   disconnects
                            dataToRead = -1;
                        }
                    }
                    if (iStream != null)
                    {
                        //Close   the   file.
                        iStream.Close();
                    }
                    context.Response.Clear();

                    context.Response.End();
                    //long dataLengthToRead = iStream.Length;//获得下载文件的总大小

                    //context.Response.ContentType = "application/octet-stream";
                    ////通知浏览器下载文件而不是打开
                    //context.Response.AddHeader("Content-Disposition", "attachment;  filename=" + HttpUtility.UrlEncode(saveFileName, System.Text.Encoding.UTF8));
                    //while (dataLengthToRead > 0 && context.Response.IsClientConnected)
                    //{
                    //    int lengthRead = iStream.Read(buffer, 0, Convert.ToInt32(ChunkSize));//读取的大小
                    //    context.Response.OutputStream.Write(buffer, 0, lengthRead);
                    //    //context.Response.Flush();
                    //    dataLengthToRead = dataLengthToRead - lengthRead;
                    //}
                    //context.Response.Flush();
                    //iStream.Dispose();
                    //iStream.Close();
                    ////context.Response.Close();
                    //context.Response.Clear();
                    ////File.Delete(NewfilePath);
                    //context.Response.End();
                }
                else
                {
                    System.Web.HttpContext.Current.Response.Write("<script>alert('该文件不存在!');</script>");
                }
                //context.Response.ContentType = "text/plain";
                //context.Response.Write("Hello World");
            }
            catch (Exception ex)
            {
                SMT.Foundation.Log.Tracer.Debug("下载文件出错" + ex.ToString());
            }
        }
コード例 #6
0
ファイル: MvcDownload.aspx.cs プロジェクト: jjg0519/OA
        protected void Page_Load(object sender, EventArgs e)
        {
            SMT.Foundation.Log.Tracer.Debug("开始下载文件");
            try
            {
                //\SMT\OA\考勤管理\2010121702324784503941.JPG
                //string fileName = "123.jpg";//客户端保存的文件名
                bool IsThum = false;//是否下载缩略图、不经过解密处理开关
                if (Request["filename"] == null)
                {
                    return;
                }
                if (Request["flag"] != null)
                {
                    IsThum = true;
                }
                String fileurl = HttpUtility.UrlDecode(Request["filename"]);
                SMT.Foundation.Log.Tracer.Debug("下载文件地址:" + fileurl);
                string[] arrFilePath = fileurl.Split('\\');
                // string filePath = string.Format(SavePath, fileName.Split('|')[0], fileName.Split('|')[1],  fileName.Split('|')[2]+"\\"+fileName.Split('|')[3]); //context.Server.MapPath("Bubble.jpg");
                string filePath = "";
                if (arrFilePath.Length == 6)
                {
                    filePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[4]);
                }
                else
                {
                    filePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[4]) + "\\" + arrFilePath[arrFilePath.Length - 2];
                }
                string NewfilePath = "";
                if (!IsThum)
                {
                    NewfilePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[5]);
                }
                else
                {
                    //缩略图没有进行加密操作所以还是显示原图
                    NewfilePath = string.Format(FileConfig.GetCompanyItem(arrFilePath[1]).SavePath, arrFilePath[1], arrFilePath[2], arrFilePath[3] + "\\" + arrFilePath[4]) + "\\" + arrFilePath[arrFilePath.Length - 2];
                }
                SMT.Foundation.Log.Tracer.Debug("下载真实文件地址NewfilePath:" + NewfilePath);
                string             saveFileName        = arrFilePath[arrFilePath.Length - 1];                 //获取文件名
                string             StrServicesFileName = arrFilePath[arrFilePath.Length - 2].Substring(0, 8); //取前面的作为解密字符串
                System.IO.FileInfo fileInfo            = new System.IO.FileInfo(filePath);
                if (fileInfo.Exists == true)
                {
                    string Key = StrServicesFileName;
                    if (!IsThum)
                    {
                        CryptoHelp.DecryptFile(filePath, NewfilePath, StrServicesFileName);
                    }

                    Response.Charset         = "utf-8";
                    Response.ContentEncoding = System.Text.Encoding.UTF8;
                    //ctx.Response.ContentEncoding

                    Response.AppendHeader("Content-Type", "text/html;charset=utf-8");
                    Response.AppendHeader("Content-Disposition", string.Format("attachment; filename={0}", HttpUtility.UrlEncode(saveFileName, System.Text.Encoding.UTF8)));
                    using (FileStream fs = new FileStream(NewfilePath, FileMode.Open, FileAccess.Read))
                    {
                        SMT.Foundation.Log.Tracer.Debug("下载文件路径NewfilePath:" + NewfilePath);
                        SMT.Foundation.Log.Tracer.Debug("下载文件大小:" + fs.Length);
                        byte[] fileData       = new byte[fs.Length];
                        int    numBytesToRead = (int)fs.Length;
                        int    numBytesRead   = 0;
                        while (numBytesToRead > 0)
                        {
                            // Read may return anything from 0 to numBytesToRead.
                            int n = fs.Read(fileData, numBytesRead, numBytesToRead);
                            // Break when the end of the file is reached.
                            if (n == 0)
                            {
                                break;
                            }
                            numBytesRead   += n;
                            numBytesToRead -= n;
                        }
                        fs.Close();
                        SMT.Foundation.Log.Tracer.Debug("下载文件地址fileData:" + fileData.Length);
                        Response.BinaryWrite(fileData);
                    }
                    ////System.IO.FileStream iStream = System.IO.File.OpenRead(NewfilePath);
                    //long dataToRead;
                    //int length;
                    //byte[] buffer = new Byte[300000];
                    //System.IO.FileStream iStream = new System.IO.FileStream(NewfilePath, System.IO.FileMode.Open,
                    //System.IO.FileAccess.Read, System.IO.FileShare.Read);

                    ////   Total   bytes   to   read:
                    //dataToRead = iStream.Length;

                    //Response.ContentType = "application/octet-stream";

                    //Response.Charset = "UTF-8";
                    //Response.AddHeader("Content-Disposition", "attachment;   filename=" + System.Web.HttpUtility.UrlEncode(saveFileName, System.Text.Encoding.UTF8));
                    //Response.AddHeader("Content-Length", dataToRead.ToString());
                    ////   Read   the   bytes.
                    //while (dataToRead > 0)
                    //{
                    //    //   Verify   that   the   client   is   connected.
                    //    if (Response.IsClientConnected)
                    //    {
                    //        //   Read   the   data   in   buffer.
                    //        length = iStream.Read(buffer, 0, 300000);

                    //        //   Write   the   data   to   the   current   output   stream.
                    //        Response.OutputStream.Write(buffer, 0, length);

                    //        //   Flush   the   data   to   the   HTML   output.
                    //        Response.Flush();

                    //        buffer = new Byte[300000];
                    //        dataToRead = dataToRead - length;
                    //    }
                    //    else
                    //    {
                    //        //prevent   infinite   loop   if   user   disconnects
                    //        dataToRead = -1;
                    //    }

                    //}
                    //if (iStream != null)
                    //{
                    //    //Close   the   file.
                    //    iStream.Close();
                    //    iStream.Dispose();

                    //}
                    //删除文件
                    if (!IsThum)
                    {
                        File.Delete(NewfilePath);
                    }
                }
                else
                {
                    System.Web.HttpContext.Current.Response.Write("<script>alert('该文件不存在!');</script>");
                }
                //context.Response.ContentType = "text/plain";
                //context.Response.Write("Hello World");
            }
            catch (Exception ex)
            {
                //   Trap   the   error,   if   any.
                Response.Write("下载出现异常Error   :   " + ex.Message);
                Response.Clear();
                Response.End();
            }
            finally
            {
                Response.End();
            }
        }
コード例 #7
0
ファイル: DBManager.cs プロジェクト: menglou/winformyunche
        /// <summary>
        /// DB初始化(多数据库配置初始化)
        /// </summary>
        public static void DBInit(string paramDBConfig)
        {
            //如果数据库配置对象已经存在,则不再进行初始化
            if (dicSqlMap.ContainsKey(paramDBConfig))
            {
                return;
            }

            #region 加载sqlmap.config配置文件

            XmlDocument xmlDoc  = new XmlDocument();
            string      xmlPath = System.AppDomain.CurrentDomain.BaseDirectory +
                                  ConfigurationManager.AppSettings[AppSettingKey.SQLMAP_PATH];
            if (!File.Exists(xmlPath))
            {
                throw new Exception("Can not find the session config  xml file " + xmlPath);
            }
            xmlDoc.Load(xmlPath);

            if (null == xmlDoc)
            {
                throw new Exception("sqlmap.config load faild");
            }

            #endregion

            var builder = new DomSqlMapBuilder();
            try
            {
                //数据库配置SkyCar.Coeus
                if (DBCONFIG.Coeus.Equals(paramDBConfig))
                {
                    #region 解析AppSetting内配置的数据库连接字符串

                    var connectString = ConfigurationManager.AppSettings[AppSettingKey.CONNECTION_STRING];
                    try
                    {
                        var plainString = CryptoHelp.Decode(connectString);
                        if (!string.IsNullOrEmpty(plainString))
                        {
                            connectString = plainString;
                        }
                    }
                    catch
                    {
                    }
                    var dbInfos = connectString.Split(';');
                    if (dbInfos.Length != 4)
                    {
                        throw new Exception("数据库连接字符串配置错误");
                    }
                    #endregion

                    var newDBConfig = string.Format("{0}.Coeus.config,{0}", AssemblyName);
                    xmlDoc.ChildNodes[1].ChildNodes[1].Attributes[0].Value = newDBConfig;
                    var sqlMap = builder.Configure(xmlDoc);
                    sqlMap.DataSource.ConnectionString = string.Format(DALConst.ConnectionStr, dbInfos);
                    dicSqlMap[paramDBConfig]           = sqlMap;
                }
                //数据库配置(其他数据库配置)
                else
                {
                    var newDBConfig = string.Format("{0}.Coeus.config,{0}", AssemblyName);
                    xmlDoc.ChildNodes[1].ChildNodes[1].Attributes[0].Value = newDBConfig;
                    var sqlMap = builder.Configure(xmlDoc);
                    sqlMap.DataSource.ConnectionString = DBCONFIG.Configs[paramDBConfig];
                    dicSqlMap[paramDBConfig]           = sqlMap;
                }
            }
            catch (Exception e)
            {
                throw new DataMapperException("Error init DBConfig.  Cause: " + e.Message, e);
            }
        }
コード例 #8
0
ファイル: Upload.aspx.cs プロジェクト: jjg0519/OA
        protected void Page_Load(object sender, EventArgs e)
        {
            //UploadService bb = new UploadService();
            //bb.CreateCompanyDirectory("703dfb3c-d3dc-4b1d-9bf0-3507ba01b716", "集团本部", "SMT");
            SMT.Foundation.Log.Tracer.Debug("开始上传文件时间:" + System.DateTime.Now.ToString());
            try
            {
                string         NewPath  = "";
                HttpPostedFile fileData = Request.Files["Filedata"];
                SMT.Foundation.Log.Tracer.Debug("开始上传文件的大小:" + fileData.ContentLength.ToString());
                SMT.Foundation.Log.Tracer.Debug("开始上传文件:" + fileData.FileName);
                string filePath    = "";
                string companyCode = ""; //公司代码
                string systemCode  = ""; //系统代码
                string modelCode   = ""; //模块代码
                string encryptName = ""; //加密字符串
                string strFileName = "";
                strFileName = fileData.FileName;
                UserFile model = null;

                string DownloadUrl = string.Concat(ConfigurationManager.AppSettings["DownLoadUrl"]);
                //获取用户身份,由用户名,密码组成
                string StrAuthUser = string.Concat(ConfigurationManager.AppSettings["FileUploadUser"]);
                //if (Request["path"] != null)
                //{
                //    filePath = Request["path"].ToString();
                //    SMT.Foundation.Log.Tracer.Debug("上传文件完成,路径:" + filePath);
                //}
                if (Request["companyCode"] != null)//公司代码
                {
                    companyCode = Request["companyCode"].ToString();
                    model       = FileConfig.GetCompanyItem(companyCode);
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件companyCode:" + companyCode);
                }
                if (Request["systemCode"] != null)//系统代码
                {
                    systemCode = Request["systemCode"].ToString();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件systemcode:" + systemCode);
                }
                if (Request["modelCode"] != null)//模块代码
                {
                    modelCode = Request["modelCode"].ToString();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件modlecode:" + modelCode);
                }
                if (Request["encryptName"] != null)//加密文件名
                {
                    encryptName = Request["encryptName"].ToString();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件encryptName:" + encryptName);
                }
                if (fileData != null)
                {
                    //string path = ctx.Server.MapPath(ctx.Request["file"].ToString());
                    string strPath = string.Format(model.SavePath, companyCode, systemCode, modelCode);
                    if (!System.IO.Directory.Exists(strPath))
                    {
                        if (strPath.IndexOf("\\\\") == 0)
                        {
                            string FirstName    = "";
                            string UserName     = "";
                            string StrPwd       = "";
                            string ComputerName = "";
                            if (StrAuthUser.IndexOf(",") > 0)
                            {
                                FirstName    = StrAuthUser.Split(',')[0];
                                ComputerName = FirstName.Split('/')[0];
                                UserName     = FirstName.Split('/')[1];
                                StrPwd       = StrAuthUser.Split(',')[1];
                            }
                            LogonImpersonate imper   = new LogonImpersonate(UserName, StrPwd);
                            string           path    = @"Z:\" + companyCode + @"\" + systemCode + @"\" + modelCode;
                            string           OldPath = model.SavePath.Split('{')[0].TrimEnd('\\');
                            if (CreateDirectory(path, UserName, StrPwd, OldPath))
                            {
                                SMT.Foundation.Log.Tracer.Debug("aspx页面创建了驱动器映射");
                            }
                            else
                            {
                                SMT.Foundation.Log.Tracer.Debug("aspx页面有创建映射问题");
                            }
                        }
                        else
                        {
                            System.IO.Directory.CreateDirectory(strPath);
                        }
                    }
                    NewPath = Path.Combine(strPath, encryptName);            //还未上传完成的路径
                    string OldFilePath = Path.Combine(strPath, strFileName); //原来上传的文件
                    string PassWordKey = "";                                 //加密字符串
                    if (encryptName.Length > 8)
                    {
                        PassWordKey = encryptName.Substring(0, 8);
                    }
                    else
                    {
                        PassWordKey = "12345678";
                    }
                    int    fileLength = fileData.ContentLength;
                    byte[] data       = new Byte[fileLength];
                    Stream fileStream = fileData.InputStream;
                    fileStream.Read(data, 0, fileLength);

                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件开始,路径NewPath:" + NewPath);
                    using (FileStream fs = File.Create(NewPath))
                    {
                        fs.Write(data, 0, data.Length);
                        fs.Close();
                        fs.Dispose();
                    }
                    //创建上传过来的文件
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件开始,路径OldFilePath:" + OldFilePath);
                    using (FileStream fsOld = File.Create(OldFilePath))
                    {
                        fsOld.Write(data, 0, data.Length);
                        fsOld.Close();
                        fsOld.Dispose();
                    }

                    string strTempName = Path.Combine(strPath, encryptName);//已经上传完成的路径
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件开始,路径strTempName:" + strTempName);
                    File.Move(NewPath, strTempName);
                    NewPath = strTempName;//最近返回已完成的路径
                    string imageType = ".JPEG,.JPG,.GIF,.BMP";
                    //判断上传的模块的类型,如果是新闻则生成缩略图
                    #region 生成缩略图

                    string FileType = "";
                    if (imageType.IndexOf(FileType) > 0 || imageType.ToLower().IndexOf(FileType) > 0)
                    {
                        string thumbPath = string.Format(model.SavePath, companyCode, systemCode, modelCode) + "\\thumb\\";
                        SMT.Foundation.Log.Tracer.Debug("aspx页面上传图片文件,路径thumbPath:" + thumbPath);
                        if (!System.IO.Directory.Exists(thumbPath))
                        {
                            SMT.Foundation.Log.Tracer.Debug("aspx页面上传图片文件,不存在路径thumbPath:" + thumbPath);
                            if (strPath.IndexOf("\\\\") == 0)
                            {
                                string FirstName    = "";
                                string UserName     = "";
                                string StrPwd       = "";
                                string ComputerName = "";
                                if (StrAuthUser.IndexOf(",") > 0)
                                {
                                    FirstName    = StrAuthUser.Split(',')[0];
                                    ComputerName = FirstName.Split('/')[0];
                                    UserName     = FirstName.Split('/')[1];
                                    StrPwd       = StrAuthUser.Split(',')[1];
                                }
                                LogonImpersonate imper   = new LogonImpersonate(UserName, StrPwd);
                                string           path    = @"Z:\" + companyCode + @"\" + systemCode + @"\" + modelCode;
                                string           OldPath = model.SavePath.Split('{')[0].TrimEnd('\\');
                                if (CreateDirectory(path, UserName, StrPwd, OldPath))
                                {
                                    SMT.Foundation.Log.Tracer.Debug("创建了驱动器映射");
                                }
                                else
                                {
                                    SMT.Foundation.Log.Tracer.Debug("aspx页面图片上传有问题");
                                }
                            }
                            else
                            {
                                SMT.Foundation.Log.Tracer.Debug("aspx页面上传图片文件,开始创建路径thumbPath:" + thumbPath);
                                System.IO.Directory.CreateDirectory(thumbPath);
                            }
                        }
                        string thumbFile = thumbPath + encryptName;
                        string strType   = "JPG";
                        strType = FileType;
                        MakeImageThumb.MakeThumbnail(OldFilePath, thumbFile, 250, 200, "DB", strType);
                        //保存到数据库的路径
                        string strSaveThumb = string.Format("\\{0}\\{1}\\{2}", companyCode, systemCode, modelCode + "\\thumb\\" + encryptName);
                        //entity.THUMBNAILURL = string.Format("\\{0}\\{1}\\{2}", model.CompanyCode, model.SystemCode, model.ModelCode + "\\" + strMd5Name);
                        //entity.THUMBNAILURL = strSaveThumb;
                    }
                    #endregion
                    CryptoHelp.EncryptFileForMVC(OldFilePath, NewPath, PassWordKey);
                    //fileStream.Close();
                    //fileStream.Dispose();
                    SMT.Foundation.Log.Tracer.Debug("aspx页面上传文件完成,路径:" + NewPath + " tempName:" + strTempName);
                }
            }
            catch (Exception ex)
            {
                SMT.Foundation.Log.Tracer.Debug("上传文件upload.aspx页面出现错误:" + ex.ToString());
            }
        }
コード例 #9
0
        /// <summary>
        /// 前端检查-保存
        /// </summary>
        /// <returns></returns>
        private bool ClientCheckForSave()
        {
            //验证所有人类别
            if (string.IsNullOrEmpty(mcbWal_OwnerTypeName.SelectedText))
            {
                MessageBoxs.Show(Trans.RIA, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0013, new object[] { MsgParam.OWNER_TYPE }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            //所有人类别为{平台内汽修商}的场合,验证汽修商户和汽修商组织
            if (mcbWal_OwnerTypeName.SelectedText == CustomerTypeEnum.Name.PTNQXSH)
            {
                if (string.IsNullOrEmpty(mcbAutoFactoryName.SelectedValue) ||
                    string.IsNullOrEmpty(mcbAutoFactoryName.SelectedText))
                {
                    MessageBoxs.Show(Trans.RIA, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0013, new object[] { MsgParam.AUTOFACTORY }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
                if (string.IsNullOrEmpty(txtWal_AutoFactoryOrgCode.Text))
                {
                    MessageBoxs.Show(Trans.RIA, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0013, new object[] { MsgParam.AUTOFACTORY_ORG }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
            }

            //验证开户人
            if (string.IsNullOrEmpty(mcbClientName.SelectedText))
            {
                MessageBoxs.Show(Trans.RIA, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0013, new object[] { MsgParam.ACCOUNT_BY }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                return(false);
            }

            //验证交易密码
            if (string.IsNullOrEmpty(txtWal_TradingPassword.Text) && string.IsNullOrEmpty(txtConfirmTradingPassword.Text))
            {
                //获取系统配置中的电子钱包初始密码
                var resultParameters = CacheDAX.Get(CacheDAX.CacheKey.S1006) as List <MDLSM_Parameter>;
                if (resultParameters != null && resultParameters.Count > 0)
                {
                    txtConfirmTradingPassword.Text = txtWal_TradingPassword.Text = CryptoHelp.EncodeToMD5(resultParameters[0].Para_Value1);
                }
                else
                {
                    MessageBoxs.Show(Trans.RIA, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0000, new object[] { "1006(钱包初始密码)未在SM_Parameter表中配置" }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }
            }
            else
            {
                //交易密码和确认密码不一致
                if (txtWal_TradingPassword.Text != txtConfirmTradingPassword.Text)
                {
                    MessageBoxs.Show(Trans.RIA, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0000, new object[] { "交易密码和确认密码不一致" }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return(false);
                }

                if (txtWal_TradingPassword.Text != null)
                {
                    //加密
                    txtWal_TradingPassword.Text    = CryptoHelp.EncodeToMD5(txtWal_TradingPassword.Text);
                    txtConfirmTradingPassword.Text = txtWal_TradingPassword.Text;
                }
                else
                {
                    //获取系统配置中的电子钱包初始密码
                    var resultParameters = CacheDAX.Get(CacheDAX.CacheKey.S1006) as List <MDLSM_Parameter>;
                    if (resultParameters != null && resultParameters.Count > 0)
                    {
                        txtWal_TradingPassword.Text    = CryptoHelp.EncodeToMD5(resultParameters[0].Para_Value1);
                        txtConfirmTradingPassword.Text = txtWal_TradingPassword.Text;
                    }
                    else
                    {
                        MessageBoxs.Show(Trans.RIA, this.ToString(), MsgHelp.GetMsg(MsgCode.E_0000, new object[] { "1006(钱包初始密码)未在SM_Parameter表中配置" }), MessageBoxButtons.OK, MessageBoxIcon.Information);
                        return(false);
                    }
                }
            }

            return(true);
        }