Example #1
0
        /// <summary>
        /// 上传文件
        /// </summary>
        /// <param name="inputStream">流对象</param>
        /// <param name="fileName">保存文件名,可包含文件夹(test/test.txt)</param>
        /// <returns>bool[true:成功,false:失败]</returns>
        public bool UploadFile(Stream inputStream, string fileName)
        {
            if (inputStream == null || string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            WebClient client = new WebClient();

            client.Credentials = this.myCredentialCache;
            int length = (int)inputStream.Length;

            byte[] buffer = new byte[length];
            inputStream.Read(buffer, 0, length);

            try
            {
                string urlFile = GetUrlFile(this.URL, fileName);
                using (Stream stream = client.OpenWrite(urlFile, "PUT"))
                {
                    stream.Write(buffer, 0, length);
                }
            }
            catch (WebException ex)
            {
                LogTextHelper.Debug(ex);
                return(false);
            }
            return(true);
        }
Example #2
0
        /// <summary>
        /// 记录用户操作日志
        /// </summary>
        /// <param name="info">用户信息</param>
        /// <param name="systemType">系统类型ID</param>
        /// <param name="ip">IP地址</param>
        /// <param name="macAddr">Mac地址</param>
        /// <param name="note">备注说明</param>
        public void AddLoginLog(UserInfo info, string systemType, string ip, string macAddr, string note)
        {
            if (info == null)
            {
                return;
            }

            #region 记录用户登录操作
            try
            {
                LoginLogInfo logInfo = new LoginLogInfo();
                logInfo.IPAddress     = ip;
                logInfo.MacAddress    = macAddr;
                logInfo.LastUpdated   = DateTime.Now;
                logInfo.Note          = note;
                logInfo.SystemType_ID = systemType;

                logInfo.User_ID     = info.ID.ToString();
                logInfo.FullName    = info.FullName;
                logInfo.LoginName   = info.Name;
                logInfo.Company_ID  = info.Company_ID;
                logInfo.CompanyName = info.CompanyName;

                BLLFactory <LoginLog> .Instance.Insert2(logInfo);
            }
            catch (Exception ex)
            {
                LogTextHelper.Debug(ex);
            }
            #endregion
        }
Example #3
0
        /// <summary>
        /// 设置主线程的UI Culture
        /// </summary>
        /// <param name="cultureName"></param>
        public static void SetMainThreadUICulture(string cultureName)
        {
            try
            {
                LogTextHelper.Info(string.Format("UICulture = {0}", cultureName));

                var culture = new CultureInfo(cultureName);
                mainCulture = culture;
                Thread.CurrentThread.CurrentUICulture = culture;
            }
            catch (Exception ex)
            {
                LogTextHelper.Debug(string.Format("Error setting UICulture: {0}", cultureName), ex);
            }
        }
Example #4
0
        /// <summary>
        /// 根据查询条件获取简单用户对象列表
        /// </summary>
        /// <param name="condition">查询条件</param>
        /// <returns></returns>
        public List <SimpleUserInfo> FindSimpleUsers(string condition)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Debug(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }

            //串连条件语句为一个完整的Sql语句
            string sql = string.Format("Select ID,Name,Password,FullName,HandNo,MobilePhone,Email From {0} Where Deleted = 0 ", tableName);

            if (!string.IsNullOrEmpty(condition))
            {
                sql += string.Format(" AND {0} ", condition);
            }
            sql += string.Format(" Order by {0} {1}", GetSafeFileName(sortField), isDescending ? "DESC" : "ASC");

            return(FillSimpleUsers(sql));
        }
Example #5
0
        /// <summary>
        /// 根据条件查询数据库,并返回DataTable集合(用于分页数据显示)
        /// </summary>
        /// <param name="condition">查询的条件</param>
        /// <param name="info">分页实体</param>
        /// <param name="fieldToSort">排序字段</param>
        /// <param name="desc">是否降序</param>
        /// <param name="trans">事务对象</param>
        /// <returns>指定DataTable的集合</returns>
        public override DataTable FindToDataTable(string condition, PagerInfo info, string fieldToSort, bool desc, DbTransaction trans = null)
        {
            if (HasInjectionData(condition))
            {
                LogTextHelper.Debug(string.Format("检测出SQL注入的恶意数据, {0}", condition));
                throw new Exception("检测出SQL注入的恶意数据");
            }

            PagerHelper helper = new PagerHelper(tableName, this.selectedFields, fieldToSort,
                                                 info.PageSize, info.CurrenetPageIndex, desc, condition);

            string countSql = helper.GetPagingSql(DatabaseType.Access, true);
            string strCount = SqlValueList(countSql, trans);

            info.RecordCount = Convert.ToInt32(strCount);

            string dataSql = helper.GetPagingSql(DatabaseType.Access, false);

            return(GetDataTableBySql(dataSql, trans));
        }
Example #6
0
        public List <CListItem> InitRAS()
        {
            List <CListItem> list = new List <CListItem>();

            try
            {
                ReadOnlyCollection <RasConnection> ret = RasConnection.GetActiveConnections();
                foreach (RasConnection connection in ret)
                {
                    list.Add(new CListItem(connection.EntryName, connection.EntryId.ToString()));
                }
            }
            catch (Exception ex)
            {
                LogTextHelper.Debug(ex);
                throw;
            }

            return(list);
        }