code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231 values | license stringclasses 13 values | size int64 1 2.01M |
|---|---|---|---|---|---|
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnBrand
{
public EnBrand()
{}
#region Model
private int _id;
private int? _companyid = 0;
private string _title;
private string _letter;
private int? _groupid = 0;
private string _attribute;
private string _productcategory;
private string _homepage;
private int? _productcount;
private string _spread;
private string _material;
private string _style;
private string _color;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _keywords;
private string _template;
private int? _hits = 0;
private int? _sort = 0;
private int? _createmid = 0;
private int? _lasteditid;
private DateTime _lastedittime = DateTime.Now;
private int _auditstatus = 0;
private int _linestatus = 0;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public int? companyid
{
set { _companyid = value; }
get { return _companyid; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public int? groupid
{
set { _groupid = value; }
get { return _groupid; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string productcategory
{
set { _productcategory = value; }
get { return _productcategory; }
}
/// <summary>
/// 主页地址
/// </summary>
public string homepage
{
set { _homepage = value; }
get { return _homepage; }
}
/// <summary>
///
/// </summary>
public int? productcount
{
set { _productcount = value; }
get { return _productcount; }
}
/// <summary>
///
/// </summary>
public string spread
{
set { _spread = value; }
get { return _spread; }
}
/// <summary>
///
/// </summary>
public string material
{
set { _material = value; }
get { return _material; }
}
/// <summary>
///
/// </summary>
public string style
{
set { _style = value; }
get { return _style; }
}
/// <summary>
///
/// </summary>
public string color
{
set { _color = value; }
get { return _color; }
}
/// <summary>
///
/// </summary>
public string surface
{
set { _surface = value; }
get { return _surface; }
}
/// <summary>
///
/// </summary>
public string logo
{
set { _logo = value; }
get { return _logo; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string desimage
{
set { _desimage = value; }
get { return _desimage; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string keywords
{
set { _keywords = value; }
get { return _keywords; }
}
/// <summary>
/// 模版ID
/// </summary>
public string template
{
set { _template = value; }
get { return _template; }
}
/// <summary>
/// 点击量
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
/// 排序
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? createmid
{
set { _createmid = value; }
get { return _createmid; }
}
/// <summary>
///
/// </summary>
public int? lasteditid
{
set { _lasteditid = value; }
get { return _lasteditid; }
}
/// <summary>
/// 最后个改
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
/// 审核状态
/// </summary>
public int auditstatus
{
set { _auditstatus = value; }
get { return _auditstatus; }
}
/// <summary>
/// 在线状态
/// </summary>
public int linestatus
{
set { _linestatus = value; }
get { return _linestatus; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnBrand.cs | C# | oos | 6,731 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumConfigByEnterprise
{
人员规模=2,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumConfigByEnterprise.cs | C# | oos | 204 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumPromotionStageType
{
打折=11,
直减=12,
赠送=13,
}
public enum EnumPromotionStageModule
{
活动总额=101,
}
public enum EnumPromotionModule
{
订单活动产品额=1001,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumPromotionStage.cs | C# | oos | 415 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumProductConType
{
风格特点=101,
产品细节=102,
材质工艺=103,
保养说明=104,
配送周期 = 105,
温馨提示=106,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumProductConType.cs | C# | oos | 338 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumPromotionType
{
资讯=101,
团购=102
}
public enum EnumPromotionDefType
{
企业=1000,
店铺=1001,
产品=1002,
卖场=1003,
品牌=1004
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumPromotionType.cs | C# | oos | 389 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumActionType
{
读取=101,
新增=102,
修改=103,
删除=104,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumActionType.cs | C# | oos | 254 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumTemplate
{
默认风格=0,
级别1=1,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumTemplate.cs | C# | oos | 213 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumGroupOrderStatus
{
取消订单=100,
待付报名费=101,
己付报名费=102
}
public enum EnumGroupOrderPayStatus
{
未付=0,
己付=1,
}
public enum EnumGroupOrderPayType
{
报名费=101,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumGroupOrder.cs | C# | oos | 436 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumAttribute
{
置顶=101,
推荐=102,
热门=103,
精华=104,
幻灯=105,
高亮=106,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumAttribute.cs | C# | oos | 295 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumAuditStatus
{
待审核=0,
正在审核=-1,
通过=1,
未通过=-99,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumAuditStatus.cs | C# | oos | 262 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumConfigByProduct
{
产品颜色=12,
产品类型=11,
产品价位=5,
产品选材=4,
产品风格=3,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumConfigByProduct.cs | C# | oos | 290 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumMemberType
{
个人成员=100,
工厂企业=101,
经销商=102,
卖场=103,
店铺管理员=104,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumMemberType.cs | C# | oos | 301 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumLineStatus
{
未上线=0,
己上线=1,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumLineStatus.cs | C# | oos | 214 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumAppBrandModule
{
经销商申请=1001,
店铺申请 = 1002
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumAppBrandModule.cs | C# | oos | 234 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumAppBrandType
{
申请新建品牌=1001,
申请代理品牌= 1002
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumAppBrandType.cs | C# | oos | 240 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumAdvertisementinType
{
文字广告=101,
图片广告=102,
Flash广告=103,
JS代码广告 = 104,
视频广告=105,
动画广告=106,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumAdvertisementinType.cs | C# | oos | 344 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumConfigModule
{
系统配置=101,
企业配置=102,
工厂配置=1021,
经销商配置=1202,
店铺配置=1203,
卖场配置=1204,
产品配置=103
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumConfigModule.cs | C# | oos | 369 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public enum EnumModuleType
{
系统=1001,
后台 = 1002,
供应商 = 1003,
供应商厂家 = 100301,
供应商经销商 = 100302,
供应商卖场 = 100303,
供应商店铺 = 100304,
前台 = 1004,
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Enum/EnumModuleType.cs | C# | oos | 410 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public class TableName
{
#region 权限
public static string TBSystemModule = "t_sys_module";
public static string TBSystemModuleLink = "t_sys_module_link";
public static string TBSystemAction = "t_sys_action";
public static string TBSystemRole = "t_sys_role";
public static string TBRoleActionDef = "t_sys_roleactiondef";
#endregion
#region 管理员
public static string TBAdmin = "t_admin";
#endregion
//广告及广告分类
public static string TBAdvertisement = "t_advertising";
public static string TBAdvertisementCategory = "t_advertisingcategory";
#region 成员
public static string TBMember = "t_member"; //登陆账号
public static string TBCompany = "t_company"; //企业表
public static string TBDealer = "t_dealer"; //经销商表
public static string TBShop = "t_shop"; //店铺表
public static string TBShopBrand = "t_shopbrand";
public static string TBMarket = "t_market"; //卖场表
public static string TBMarketStorey = "t_marketstorey"; //卖场表
public static string TBMarketStoreyShop = "t_marketstoreyshop"; //卖场表
public static string TBMemberGroup = "t_membergroup"; //登陆账号
public static string TBCompanyGroup = "t_companygroup"; //企业表
public static string TBDealerGroup = "t_dealergroup"; //经销商表
public static string TBShopGroup = "t_shopgroup"; //店铺表
public static string TBMarketGroup = "t_marketgroup"; //卖场表
#endregion
public static string TBArticle = "t_article";
public static string TVArticle = "v_article";
public static string TBArticleCategory = "t_articlecategory";
public static string TPArticleCategoryUp = "MoveArticleNodeUp";
public static string TBBrand = "t_brand";
public static string TBBrands = "t_brands";
public static string TBAppBrand = "t_appbrand";
public static string TBArea = "t_area";
public static string TBConfig = "t_config";
public static string TBConfigType = "t_configtype";
public static string TBMenu = "t_menu";
public static string TBLog = "t_log";
public static string TBAggregation = "t_aggregation";
public static string TBAggregationType = "t_aggregationtype";
public static string TBPromotion = "t_promotion";
public static string TBPromotionDef = "t_promotiondef";
public static string TBPromotionStage = "t_promotionstage";
public static string TBProduct = "t_product";
public static string TBProductCategory = "t_productcategory";
public static string TBProductAttribute = "t_productattribute";
public static string TBProductCon = "t_productcon";
public static string TBPCategoryPTyp = "t_pcategoryptypedef";
public static string TBGroupOrder = "t_grouporder";
public static string TBGroupOrderPay = "t_grouporderpay";
public static string TBGroupOrderProduct = "t_grouporderproduct";
public static string TBPromotionAppBrand = "t_promotionappbrand";
public static string TBAppBrandCustomer = "t_appbrandcustomer";
public static string TBAppBrandProduct = "t_promotionappproduct";
#region 视图
public static string TVBrand = "v_brand";
public static string TVCompanyList = "v_compalylistByC";
public static string TVCompanyBrandList = "v_companylistByB";
public static string TVShopList = "v_shoplistByS";
public static string TVShopBrandList = "v_shoplistByB";
public static string TVProduct = "v_product";
public static string TVMarket = "v_marketlist";
public static string TVMarketStoreyShop = "v_marketstoreyshoplist";
public static string TVCompanySearchItem = "v_companysearchitem";
public static string TVShopSearchItem = "v_shopsearchitem";
public static string TVProductSearchItem = "v_productsearchitem";
public static string TVMarketSearchItem = "v_marketsearchitem";
public static string TVAggregation = "v_aggregation";
public static string TVPromotion = "v_promotion";
public static string TVAllBrand = "v_allbrand";
public static string TVPromotionInfoList = "v_promotioninfolist";
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/TableName.cs | C# | oos | 4,721 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace TREC.Entity
{
[Serializable]
public class EnWebMarketStoreyShop
{
#region Model
private int _id;
private int _marketid;
private string _markettitle;
private int _storeyid;
private string _storeytitle;
private int _shopid;
private string _shoptitle;
private string _brandidlist;
private string _brandtitlelist;
private int? _istop;
private int? _isrecommend;
private int? _lev;
private int? _sort;
private int? _lastedid;
private DateTime _lastedittime;
private string _shopthumb;
private string _shopmap;
private string _shoplinkman;
private string _shopphone;
private string _shopareacode;
private string _shopaddress;
private string _brandxml;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public int marketid
{
set { _marketid = value; }
get { return _marketid; }
}
/// <summary>
///
/// </summary>
public string markettitle
{
set { _markettitle = value; }
get { return _markettitle; }
}
/// <summary>
///
/// </summary>
public int storeyid
{
set { _storeyid = value; }
get { return _storeyid; }
}
/// <summary>
///
/// </summary>
public string storeytitle
{
set { _storeytitle = value; }
get { return _storeytitle; }
}
/// <summary>
///
/// </summary>
public int shopid
{
set { _shopid = value; }
get { return _shopid; }
}
/// <summary>
///
/// </summary>
public string shoptitle
{
set { _shoptitle = value; }
get { return _shoptitle; }
}
/// <summary>
///
/// </summary>
public string brandidlist
{
set { _brandidlist = value; }
get { return _brandidlist; }
}
/// <summary>
///
/// </summary>
public string brandtitlelist
{
set { _brandtitlelist = value; }
get { return _brandtitlelist; }
}
/// <summary>
///
/// </summary>
public int? istop
{
set { _istop = value; }
get { return _istop; }
}
/// <summary>
///
/// </summary>
public int? isrecommend
{
set { _isrecommend = value; }
get { return _isrecommend; }
}
/// <summary>
///
/// </summary>
public int? lev
{
set { _lev = value; }
get { return _lev; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public string shopthumb
{
set { _shopthumb = value; }
get { return _shopthumb; }
}
/// <summary>
///
/// </summary>
public string shopmap
{
set { _shopmap = value; }
get { return _shopmap; }
}
/// <summary>
///
/// </summary>
public string shoplinkman
{
set { _shoplinkman = value; }
get { return _shoplinkman; }
}
/// <summary>
///
/// </summary>
public string shopphone
{
set { _shopphone = value; }
get { if(string.IsNullOrEmpty(_shopphone))
return "4006066818";
else
{
return _shopphone;
}
}
}
/// <summary>
///
/// </summary>
public string shopareacode
{
set { _shopareacode = value; }
get { return _shopareacode; }
}
/// <summary>
///
/// </summary>
public string shopaddress
{
set { _shopaddress = value; }
get { return _shopaddress; }
}
/// <summary>
///
/// </summary>
public string brandxml
{
set { _brandxml = value; }
get { return _brandxml; }
}
#endregion Model
public string BrandName
{
get
{
if (MarketStoreyShopBrandList.Count > 0)
{
string t = "";
foreach (MarketStoreyShopBrand m in MarketStoreyShopBrandList)
{
t += m.title + ",";
}
return t;
}
return "";
}
}
public string StyleName
{
get
{
if (MarketStoreyShopBrandList.Count > 0)
{
string t = "";
foreach (MarketStoreyShopBrand m in MarketStoreyShopBrandList)
{
if (!t.Contains(m.style + ","))
{
t += m.style + ",";
}
}
return t;
}
return "";
}
}
public List<MarketStoreyShopBrand> MarketStoreyShopBrandList
{
get
{
if (!string.IsNullOrEmpty(brandxml))
{
List<MarketStoreyShopBrand> list = new List<MarketStoreyShopBrand>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(brandxml, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
MarketStoreyShopBrand m = new MarketStoreyShopBrand();
GroupCollection gc = match.Groups;
list.Add((MarketStoreyShopBrand)TRECommon.SerializationHelper.DeSerialize(typeof(MarketStoreyShopBrand), "<MarketStoreyShopBrand>" + gc["g"].Value + "</MarketStoreyShopBrand>"));
}
}
return list;
}
return new List<MarketStoreyShopBrand>();
}
}
[Serializable]
public class MarketStoreyShopBrand
{
public string id { get; set; }
public string title { get; set; }
public string logo { get; set; }
public string thumb { get; set; }
public string style { get; set; }
public string companyid { get; set; }
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebMarketStoreyShop.cs | C# | oos | 8,179 |
using System;
namespace TREC.Entity
{
/// <summary>
/// sys_action:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnArea
{
public EnArea()
{}
#region Model
private string _areacode;
private string _parentcode;
private string _areaname;
private string _areazipcode;
private string _grouparea;
/// <summary>
///
/// </summary>
public string areacode
{
set { _areacode = value; }
get { return _areacode; }
}
/// <summary>
///
/// </summary>
public string parentcode
{
set { _parentcode = value; }
get { return _parentcode; }
}
/// <summary>
///
/// </summary>
public string areaname
{
set { _areaname = value; }
get { return _areaname; }
}
/// <summary>
///
/// </summary>
public string areazipcode
{
set { _areazipcode = value; }
get { return _areazipcode; }
}
/// <summary>
///
/// </summary>
public string grouparea
{
set { _grouparea = value; }
get { return _grouparea; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnArea.cs | C# | oos | 1,474 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("TREC.Entity")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("FORDIO")]
[assembly: AssemblyProduct("TREC.Entity")]
[assembly: AssemblyCopyright("Copyright © FORDIO 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("8a3cc1d8-9e09-487e-958e-547302628be0")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/Properties/AssemblyInfo.cs | C# | oos | 1,366 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnShopBrand
{
public EnShopBrand()
{}
#region Model
private int _shopid;
private int _brandid;
/// <summary>
///
/// </summary>
public int shopid
{
set { _shopid = value; }
get { return _shopid; }
}
/// <summary>
///
/// </summary>
public int brandid
{
set { _brandid = value; }
get { return _brandid; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnShopBrand.cs | C# | oos | 741 |
using System;
namespace TREC.Entity
{
[Serializable]
public class EnWebBrand
{
/// <summary>
/// id
/// </summary>
private int _id;
public int id
{
get { return _id; }
set { _id = value; }
}
/// <summary>
/// companyid
/// </summary>
private int _companyid;
public int companyid
{
get { return _companyid; }
set { _companyid = value; }
}
/// <summary>
/// title
/// </summary>
private string _title;
public string title
{
get { return _title; }
set { _title = value; }
}
/// <summary>
/// letter
/// </summary>
private string _letter;
public string letter
{
get { return _letter; }
set { _letter = value; }
}
/// <summary>
/// groupid
/// </summary>
private int _groupid;
public int groupid
{
get { return _groupid; }
set { _groupid = value; }
}
/// <summary>
/// attribute
/// </summary>
private string _attribute;
public string attribute
{
get { return _attribute; }
set { _attribute = value; }
}
/// <summary>
/// productcategory
/// </summary>
private string _productcategory;
public string productcategory
{
get { return _productcategory; }
set { _productcategory = value; }
}
/// <summary>
/// homepage
/// </summary>
private string _homepage;
public string homepage
{
get { return _homepage; }
set { _homepage = value; }
}
/// <summary>
/// productcount
/// </summary>
private int _productcount;
public int productcount
{
get { return _productcount; }
set { _productcount = value; }
}
/// <summary>
/// spread
/// </summary>
private string _spread;
public string spread
{
get { return _spread; }
set { _spread = value; }
}
/// <summary>
/// material
/// </summary>
private string _material;
public string material
{
get { return _material; }
set { _material = value; }
}
/// <summary>
/// style
/// </summary>
private string _style;
public string style
{
get { return _style; }
set { _style = value; }
}
/// <summary>
/// companyname
/// </summary>
private string _companyname;
public string companyname
{
get { return _companyname; }
set { _companyname = value; }
}
/// <summary>
/// spreadname
/// </summary>
private string _spreadname;
public string spreadname
{
get { return _spreadname; }
set { _spreadname = value; }
}
/// <summary>
/// stylename
/// </summary>
private string _stylename;
public string stylename
{
get { return _stylename; }
set { _stylename = value; }
}
/// <summary>
/// materialname
/// </summary>
private string _materialname;
public string materialname
{
get { return _materialname; }
set { _materialname = value; }
}
/// <summary>
/// surface
/// </summary>
private string _surface;
public string surface
{
get { return _surface; }
set { _surface = value; }
}
/// <summary>
/// logo
/// </summary>
private string _logo;
public string logo
{
get { _logo = _logo.StartsWith(",") ? _logo.Substring(1, _logo.Length - 1) : _logo;
_logo = _logo.EndsWith(",") ? _logo.Substring(0, _logo.Length - 1) : _logo;
return _logo;
}
set { _logo = value; }
}
/// <summary>
/// thumb
/// </summary>
private string _thumb;
public string thumb
{
get { return _thumb; }
set { _thumb = value; }
}
/// <summary>
/// bannel
/// </summary>
private string _bannel;
public string bannel
{
get { return _bannel; }
set { _bannel = value; }
}
/// <summary>
/// desimage
/// </summary>
private string _desimage;
public string desimage
{
get { return _desimage; }
set { _desimage = value; }
}
/// <summary>
/// descript
/// </summary>
private string _descript;
public string descript
{
get { return _descript; }
set { _descript = value; }
}
/// <summary>
/// keywords
/// </summary>
private string _keywords;
public string keywords
{
get { return _keywords; }
set { _keywords = value; }
}
/// <summary>
/// template
/// </summary>
private string _template;
public string template
{
get { return _template; }
set { _template = value; }
}
/// <summary>
/// hits
/// </summary>
private int _hits;
public int hits
{
get { return _hits; }
set { _hits = value; }
}
/// <summary>
/// sort
/// </summary>
private int _sort;
public int sort
{
get { return _sort; }
set { _sort = value; }
}
/// <summary>
/// createmid
/// </summary>
private int _createmid;
public int createmid
{
get { return _createmid; }
set { _createmid = value; }
}
/// <summary>
/// lasteditid
/// </summary>
private int _lasteditid;
public int lasteditid
{
get { return _lasteditid; }
set { _lasteditid = value; }
}
/// <summary>
/// lastedittime
/// </summary>
private DateTime _lastedittime;
public DateTime lastedittime
{
get { return _lastedittime; }
set { _lastedittime = value; }
}
/// <summary>
/// auditstatus
/// </summary>
private int _auditstatus;
public int auditstatus
{
get { return _auditstatus; }
set { _auditstatus = value; }
}
/// <summary>
/// linestatus
/// </summary>
private int _linestatus;
public int linestatus
{
get { return _linestatus; }
set { _linestatus = value; }
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebBrand.cs | C# | oos | 7,676 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace TREC.Entity
{
[Serializable]
public class EnWebProduct
{
#region Model
private string _shopxml;
private string _attributexml;
private string _shopprice;
private string _spreadname;
private int _id;
private string _attribute;
private string _title;
private string _shottitle;
private string _tcolor;
private string _sku;
private string _no;
private string _letter;
private int _categoryid;
private string _categorytitle;
private string _subcategoryidlist;
private string _subcategorytitlelist;
private int _brandid;
private string _brandtitle;
private string _brandlogo;
private int? _brandsid;
private string _brandstitle;
private string _stylevalue;
private string _stylename;
private string _colorname;
private string _colorvalue;
private string _materialvalue;
private string _materialname;
private string _unit;
private string _localitycode;
private string _shipcode;
private int? _customize;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _tob2c;
private int? _companyid;
private string _companyname;
private int _createmid;
private int? _hits;
private int? _sort;
private int? _lastedid;
private DateTime _lastedittime;
private int _auditstatus;
private int _linestatus;
/// <summary>
///
/// </summary>
public string shopxml
{
set { _shopxml = value; }
get { return _shopxml; }
}
/// <summary>
///
/// </summary>
public string attributexml
{
set { _attributexml = value; }
get { return _attributexml; }
}
/// <summary>
///
/// </summary>
public string shopprice
{
set { _shopprice = value; }
get { return _shopprice; }
}
public string spreadname
{
set { _spreadname = value; }
get { return _spreadname; }
}
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string shottitle
{
set { _shottitle = value; }
get { return _shottitle; }
}
/// <summary>
///
/// </summary>
public string tcolor
{
set { _tcolor = value; }
get { return _tcolor; }
}
/// <summary>
///
/// </summary>
public string sku
{
set { _sku = value; }
get { return _sku; }
}
/// <summary>
///
/// </summary>
public string no
{
set { _no = value; }
get { return _no; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public int categoryid
{
set { _categoryid = value; }
get { return _categoryid; }
}
/// <summary>
///
/// </summary>
public string categorytitle
{
set { _categorytitle = value; }
get { return _categorytitle; }
}
/// <summary>
///
/// </summary>
public string subcategoryidlist
{
set { _subcategoryidlist = value; }
get { return _subcategoryidlist; }
}
/// <summary>
///
/// </summary>
public string subcategorytitlelist
{
set { _subcategorytitlelist = value; }
get { return _subcategorytitlelist; }
}
/// <summary>
///
/// </summary>
public int brandid
{
set { _brandid = value; }
get { return _brandid; }
}
/// <summary>
///
/// </summary>
public string brandtitle
{
set { _brandtitle = value; }
get { return _brandtitle; }
}
public string brandlogo
{
set { _brandlogo = value; }
get { return _brandlogo; }
}
/// <summary>
///
/// </summary>
public int? brandsid
{
set { _brandsid = value; }
get { return _brandsid; }
}
/// <summary>
///
/// </summary>
public string brandstitle
{
set { _brandstitle = value; }
get { return _brandstitle; }
}
/// <summary>
///
/// </summary>
public string stylevalue
{
set { _stylevalue = value; }
get { return _stylevalue; }
}
/// <summary>
///
/// </summary>
public string stylename
{
set { _stylename = value; }
get { return _stylename; }
}
/// <summary>
///
/// </summary>
public string colorname
{
set { _colorname = value; }
get { return _colorname; }
}
/// <summary>
///
/// </summary>
public string colorvalue
{
set { _colorvalue = value; }
get { return _colorvalue; }
}
/// <summary>
///
/// </summary>
public string materialvalue
{
set { _materialvalue = value; }
get { return _materialvalue; }
}
/// <summary>
///
/// </summary>
public string materialname
{
set { _materialname = value; }
get { return _materialname; }
}
/// <summary>
///
/// </summary>
public string unit
{
set { _unit = value; }
get { return _unit; }
}
/// <summary>
///
/// </summary>
public string localitycode
{
set { _localitycode = value; }
get { return _localitycode; }
}
/// <summary>
///
/// </summary>
public string shipcode
{
set { _shipcode = value; }
get { return _shipcode; }
}
/// <summary>
///
/// </summary>
public int? customize
{
set { _customize = value; }
get { return _customize; }
}
/// <summary>
///
/// </summary>
public string surface
{
set { _surface = value; }
get { return _surface; }
}
/// <summary>
///
/// </summary>
public string logo
{
set { _logo = value; }
get { return _logo; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string desimage
{
set { _desimage = value; }
get { return _desimage; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string tob2c
{
set { _tob2c = value; }
get { return _tob2c; }
}
/// <summary>
///
/// </summary>
public int? companyid
{
set { _companyid = value; }
get { return _companyid; }
}
/// <summary>
///
/// </summary>
public string companyname
{
set { _companyname = value; }
get { return _companyname; }
}
/// <summary>
///
/// </summary>
public int createmid
{
set { _createmid = value; }
get { return _createmid; }
}
/// <summary>
///
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int auditstatus
{
set { _auditstatus = value; }
get { return _auditstatus; }
}
/// <summary>
///
/// </summary>
public int linestatus
{
set { _linestatus = value; }
get { return _linestatus; }
}
#endregion Model
public string shopMapapi = "";
public string HtmlProductName
{
get
{
return brandtitle + " " +categorytitle+ " " + sku + " " + materialname;
}
}
public ProductShop ProductShopInfo
{
get
{
if (ProductShopList.Count > 0)
{
return ProductShopList[0];
}
return new ProductShop();
}
}
public List<ProductShop> ProductShopList
{
get
{
if (!string.IsNullOrEmpty(shopxml))
{
List<ProductShop> list = new List<ProductShop>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(shopxml, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
ProductShop m = new ProductShop();
GroupCollection gc = match.Groups;
list.Add((ProductShop)TRECommon.SerializationHelper.DeSerialize(typeof(ProductShop), "<ProductShop>" + gc["g"].Value + "</ProductShop>"));
if (!string.IsNullOrEmpty(m.map)) { shopMapapi += m.map + "|"; }
}
}
return list;
}
return new List<ProductShop>();
}
}
public ProductAttribute ProductAttributeInfo
{
get
{
if (ProductAttributeList.Count > 0)
{
return ProductAttributeList[0];
}
return new ProductAttribute();
}
}
public List<ProductAttribute> ProductAttributeList
{
get
{
if (!string.IsNullOrEmpty(attributexml))
{
List<ProductAttribute> list = new List<ProductAttribute>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(attributexml, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
ProductAttribute m = new ProductAttribute();
GroupCollection gc = match.Groups;
list.Add((ProductAttribute)TRECommon.SerializationHelper.DeSerialize(typeof(ProductAttribute), "<ProductAttribute>" + gc["g"].Value + "</ProductAttribute>"));
}
}
return list;
}
return new List<ProductAttribute>();
}
}
public ProducShopPrice ProducShopPriceInfo
{
get
{
if (ProducShopPriceList.Count > 0)
{
return ProducShopPriceList[0];
}
return new ProducShopPrice();
}
}
public List<ProducShopPrice> ProducShopPriceList
{
get
{
if (!string.IsNullOrEmpty(shopprice))
{
List<ProducShopPrice> list = new List<ProducShopPrice>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(shopprice, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
ProducShopPrice m = new ProducShopPrice();
GroupCollection gc = match.Groups;
list.Add((ProducShopPrice)TRECommon.SerializationHelper.DeSerialize(typeof(ProducShopPrice), "<ProducShopPrice>" + gc["g"].Value + "</ProducShopPrice>"));
}
}
return list;
}
return new List<ProducShopPrice>();
}
}
public Hashtable HtMaterial
{
get
{
Hashtable ht = new Hashtable();
if (ProductAttributeList != null)
{
foreach (ProductAttribute a in ProductAttributeList)
{
if (!ht.ContainsKey(a.productmaterial))
{
ht.Add(a.productmaterial, a.productmaterial);
}
}
}
return ht;
}
}
public Hashtable HtSize
{
get
{
Hashtable ht = new Hashtable();
if (ProductAttributeList != null)
{
foreach (ProductAttribute a in ProductAttributeList)
{
if (!ht.ContainsKey(a.productwidth+"*"+a.productlength+"*"+a.productheight))
{
ht.Add(a.productwidth + "*" + a.productlength + "*" + a.productheight, a.productwidth + "*" + a.productlength + "*" + a.productheight);
}
}
}
return ht;
}
}
}
[Serializable]
public class ProductShop
{
public string id { get; set; }
public string title { get; set; }
public string thumb { get; set; }
public string map { get; set; }
public string linkman { get; set; }
public string phone { get; set; }
public string areacode { get; set; }
public string address { get; set; }
}
[Serializable]
public class ProductAttribute
{
public string id { get; set; }
public string typevalue { get; set; }
public string typename { get; set; }
public string productstyle { get; set; }
public string productmaterial { get; set; }
public string productwidth { get; set; }
public string productlength { get; set; }
public string productheight { get; set; }
public string productcbm { get; set; }
public string productcolorimg { get; set; }
public string productcolortitle { get; set; }
public string productcolorvalue { get; set; }
public string buyprice { get; set; }
public string markprice { get; set; }
public string saleprice { get; set; }
public string isdefault { get; set; }
public string sort { get; set; }
}
[Serializable]
public class ProducShopPrice
{
public string shopid { get; set; }
public string productid { get; set; }
public string attributeid { get; set; }
public string markprice { get; set; }
public string saleprice { get; set; }
public string buyprice { get; set; }
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebProduct.cs | C# | oos | 18,612 |
using System;
namespace TREC.Entity
{
/// <summary>
/// sys_action:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnAction
{
public EnAction()
{}
#region Model
private int _id;
private string _title;
private string _mark;
private int _mid;
private int _actype=0;
private string _descript;
private int _sort;
/// <summary>
///
/// </summary>
public int id
{
set{ _id=value;}
get{return _id;}
}
/// <summary>
///
/// </summary>
public string title
{
set{ _title=value;}
get{return _title;}
}
/// <summary>
///
/// </summary>
public string mark
{
set{ _mark=value;}
get{return _mark;}
}
/// <summary>
///
/// </summary>
public int mid
{
set{ _mid=value;}
get{return _mid;}
}
/// <summary>
///
/// </summary>
public int actype
{
set{ _actype=value;}
get{return _actype;}
}
/// <summary>
///
/// </summary>
public string descript
{
set{ _descript=value;}
get{return _descript;}
}
/// <summary>
///
/// </summary>
public int sort
{
set{ _sort=value;}
get{return _sort;}
}
/// <summary>
/// 是否有该动作权限
/// </summary>
public int isActionHas
{
get;
set;
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnAction.cs | C# | oos | 1,484 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnShopGroup
{
public EnShopGroup()
{}
#region Model
private int _id;
private string _title;
private string _color;
private string _avatar;
private decimal? _integral;
private decimal? _money;
private int? _adcount;
private int? _marketpcount;
private int? _brandcount;
private int? _promotioncount;
private int? _productcount;
private int? _adrecommend;
private int? _marketrecommend;
private int? _brandrecommend;
private int? _promotionrecommend;
private int? _productrecommend;
private string _permissions;
private int? _lev;
private string _descript;
private int? _sort;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string color
{
set { _color = value; }
get { return _color; }
}
/// <summary>
///
/// </summary>
public string avatar
{
set { _avatar = value; }
get { return _avatar; }
}
/// <summary>
///
/// </summary>
public decimal? integral
{
set { _integral = value; }
get { return _integral; }
}
/// <summary>
///
/// </summary>
public decimal? money
{
set { _money = value; }
get { return _money; }
}
/// <summary>
///
/// </summary>
public int? adcount
{
set { _adcount = value; }
get { return _adcount; }
}
/// <summary>
///
/// </summary>
public int? marketpcount
{
set { _marketpcount = value; }
get { return _marketpcount; }
}
/// <summary>
///
/// </summary>
public int? brandcount
{
set { _brandcount = value; }
get { return _brandcount; }
}
/// <summary>
///
/// </summary>
public int? promotioncount
{
set { _promotioncount = value; }
get { return _promotioncount; }
}
/// <summary>
///
/// </summary>
public int? productcount
{
set { _productcount = value; }
get { return _productcount; }
}
/// <summary>
///
/// </summary>
public int? adrecommend
{
set { _adrecommend = value; }
get { return _adrecommend; }
}
/// <summary>
///
/// </summary>
public int? marketrecommend
{
set { _marketrecommend = value; }
get { return _marketrecommend; }
}
/// <summary>
///
/// </summary>
public int? brandrecommend
{
set { _brandrecommend = value; }
get { return _brandrecommend; }
}
/// <summary>
///
/// </summary>
public int? promotionrecommend
{
set { _promotionrecommend = value; }
get { return _promotionrecommend; }
}
/// <summary>
///
/// </summary>
public int? productrecommend
{
set { _productrecommend = value; }
get { return _productrecommend; }
}
/// <summary>
///
/// </summary>
public string permissions
{
set { _permissions = value; }
get { return _permissions; }
}
/// <summary>
///
/// </summary>
public int? lev
{
set { _lev = value; }
get { return _lev; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnShopGroup.cs | C# | oos | 4,948 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnCompanyGroup
{
public EnCompanyGroup()
{}
#region Model
private int _id;
private string _title;
private string _color;
private string _avatar;
private decimal? _integral;
private decimal? _money;
private int? _adcount;
private int? _shopcount;
private int? _brandcount;
private int? _promotioncount;
private int? _adrecommend;
private int? _shoprecommend;
private int? _brandrecommend;
private int? _promotionrecommend;
private string _permissions;
private int? _lev;
private string _descript;
private int? _sort;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string color
{
set { _color = value; }
get { return _color; }
}
/// <summary>
///
/// </summary>
public string avatar
{
set { _avatar = value; }
get { return _avatar; }
}
/// <summary>
///
/// </summary>
public decimal? integral
{
set { _integral = value; }
get { return _integral; }
}
/// <summary>
///
/// </summary>
public decimal? money
{
set { _money = value; }
get { return _money; }
}
/// <summary>
///
/// </summary>
public int? adcount
{
set { _adcount = value; }
get { return _adcount; }
}
/// <summary>
///
/// </summary>
public int? shopcount
{
set { _shopcount = value; }
get { return _shopcount; }
}
/// <summary>
///
/// </summary>
public int? brandcount
{
set { _brandcount = value; }
get { return _brandcount; }
}
/// <summary>
///
/// </summary>
public int? promotioncount
{
set { _promotioncount = value; }
get { return _promotioncount; }
}
/// <summary>
///
/// </summary>
public int? adrecommend
{
set { _adrecommend = value; }
get { return _adrecommend; }
}
/// <summary>
///
/// </summary>
public int? shoprecommend
{
set { _shoprecommend = value; }
get { return _shoprecommend; }
}
/// <summary>
///
/// </summary>
public int? brandrecommend
{
set { _brandrecommend = value; }
get { return _brandrecommend; }
}
/// <summary>
///
/// </summary>
public int? promotionrecommend
{
set { _promotionrecommend = value; }
get { return _promotionrecommend; }
}
/// <summary>
///
/// </summary>
public string permissions
{
set { _permissions = value; }
get { return _permissions; }
}
/// <summary>
///
/// </summary>
public int? lev
{
set { _lev = value; }
get { return _lev; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnCompanyGroup.cs | C# | oos | 4,436 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace TREC.Entity
{
public class EnWebShop
{
#region Model
private string _brandxml;
private int _productcount;
private int _id;
private int _mid;
private string _title;
private string _letter;
private int _groupid;
private string _attribute;
private string _industry;
private string _productcategory;
private int? _vip;
private string _areacode;
private string _address;
private string _mapapi;
private int? _staffsize;
private string _regyear;
private string _regcity;
private string _buy;
private string _sell;
private string _linkman;
private string _phone;
private string _mphone;
private string _fax;
private string _email;
private string _postcode;
private string _homepage;
private string _domain;
private string _domainip;
private string _icp;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _keywords;
private string _template;
private int? _hits;
private int? _sort;
private int? _marketid;
private string _marketname;
private int? _cid;
private int? _ctype;
private int? _createmid;
private int? _lastedid;
private DateTime _lastedittime;
private int _auditstatus;
private int _linestatus;
/// <summary>
///
/// </summary>
public string brandxml
{
set { _brandxml = value; }
get { return _brandxml; }
}
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
public int productcount
{
set { _productcount = value; }
get { return _productcount; }
}
/// <summary>
///
/// </summary>
public int mid
{
set { _mid = value; }
get { return _mid; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public int groupid
{
set { _groupid = value; }
get { return _groupid; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string industry
{
set { _industry = value; }
get { return _industry; }
}
/// <summary>
///
/// </summary>
public string productcategory
{
set { _productcategory = value; }
get { return _productcategory; }
}
/// <summary>
///
/// </summary>
public int? vip
{
set { _vip = value; }
get { return _vip; }
}
/// <summary>
///
/// </summary>
public string areacode
{
set { _areacode = value; }
get { return _areacode; }
}
/// <summary>
///
/// </summary>
public string address
{
set { _address = value; }
get { return _address; }
}
/// <summary>
///
/// </summary>
public string mapapi
{
set { _mapapi = value; }
get { return _mapapi; }
}
/// <summary>
///
/// </summary>
public int? staffsize
{
set { _staffsize = value; }
get { return _staffsize; }
}
/// <summary>
///
/// </summary>
public string regyear
{
set { _regyear = value; }
get { return _regyear; }
}
/// <summary>
///
/// </summary>
public string regcity
{
set { _regcity = value; }
get { return _regcity; }
}
/// <summary>
///
/// </summary>
public string buy
{
set { _buy = value; }
get { return _buy; }
}
/// <summary>
///
/// </summary>
public string sell
{
set { _sell = value; }
get { return _sell; }
}
/// <summary>
///
/// </summary>
public string linkman
{
set { _linkman = value; }
get { return _linkman; }
}
/// <summary>
///
/// </summary>
public string phone
{
set { _phone = value; }
get { return _phone; }
}
/// <summary>
///
/// </summary>
public string mphone
{
set { _mphone = value; }
get { return _mphone; }
}
/// <summary>
///
/// </summary>
public string fax
{
set { _fax = value; }
get { return _fax; }
}
/// <summary>
///
/// </summary>
public string email
{
set { _email = value; }
get { return _email; }
}
/// <summary>
///
/// </summary>
public string postcode
{
set { _postcode = value; }
get { return _postcode; }
}
/// <summary>
///
/// </summary>
public string homepage
{
set { _homepage = value; }
get { return _homepage; }
}
/// <summary>
///
/// </summary>
public string domain
{
set { _domain = value; }
get { return _domain; }
}
/// <summary>
///
/// </summary>
public string domainip
{
set { _domainip = value; }
get { return _domainip; }
}
/// <summary>
///
/// </summary>
public string icp
{
set { _icp = value; }
get { return _icp; }
}
/// <summary>
///
/// </summary>
public string surface
{
set { _surface = value; }
get { return _surface; }
}
/// <summary>
///
/// </summary>
public string logo
{
set { _logo = value; }
get { return _logo; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string desimage
{
set { _desimage = value; }
get { return _desimage; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string keywords
{
set { _keywords = value; }
get { return _keywords; }
}
/// <summary>
///
/// </summary>
public string template
{
set { _template = value; }
get { return _template; }
}
/// <summary>
///
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? marketid
{
set { _marketid = value; }
get { return _marketid; }
}
public string marketname
{
set { _marketname = value; }
get { return _marketname; }
}
/// <summary>
///
/// </summary>
public int? cid
{
set { _cid = value; }
get { return _cid; }
}
/// <summary>
///
/// </summary>
public int? ctype
{
set { _ctype = value; }
get { return _ctype; }
}
/// <summary>
///
/// </summary>
public int? createmid
{
set { _createmid = value; }
get { return _createmid; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int auditstatus
{
set { _auditstatus = value; }
get { return _auditstatus; }
}
/// <summary>
///
/// </summary>
public int linestatus
{
set { _linestatus = value; }
get { return _linestatus; }
}
#endregion Model
public string BrandName
{
get
{
if (ShopBrandList.Count > 0)
{
string t = "";
foreach (ShopBrand m in ShopBrandList)
{
t += m.title + ",";
}
return t;
}
return "";
}
}
public string StyleName
{
get
{
if (ShopBrandList.Count > 0)
{
string t = "";
foreach (ShopBrand m in ShopBrandList)
{
if (!t.Contains(m.stylevalue + ","))
{
t += m.stylevalue + ",";
}
}
return t;
}
return "";
}
}
public string SpreadName
{
get
{
if (ShopBrandList.Count > 0)
{
string t = "";
foreach (ShopBrand m in ShopBrandList)
{
if (!t.Contains(m.spreadvalue + ","))
{
t += m.spreadvalue + ",";
}
}
return t;
}
return "";
}
}
public string BrandIdList
{
get
{
if (ShopBrandList.Count > 0)
{
string t = "";
foreach (ShopBrand m in ShopBrandList)
{
if (!t.Contains(m.id + ","))
{
t += m.id + ",";
}
}
t = t.EndsWith(",") ? t.Substring(0, t.Length - 1) : t;
t = t.StartsWith(",") ? t.Substring(1, t.Length - 1) : t;
return t;
}
return "0";
}
}
public ShopBrand ShopBrandInfo
{
get
{
if (ShopBrandList.Count > 0)
{
return ShopBrandList[0];
}
return new ShopBrand();
}
}
public List<ShopBrand> ShopBrandList
{
get
{
if (!string.IsNullOrEmpty(brandxml))
{
List<ShopBrand> list = new List<ShopBrand>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(brandxml, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
ShopBrand m = new ShopBrand();
GroupCollection gc = match.Groups;
list.Add((ShopBrand)TRECommon.SerializationHelper.DeSerialize(typeof(ShopBrand), "<ShopBrand>" + gc["g"].Value + "</ShopBrand>"));
}
}
return list;
}
return new List<ShopBrand>();
}
}
}
[Serializable]
public class ShopBrand
{
public string id { get; set; }
public string title { get; set; }
public string thumb { get; set; }
public string map { get; set; }
public string spreadvalue { get; set; }
public string materialvalue { get; set; }
public string stylevalue { get; set; }
public string companyid { get; set; }
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebShop.cs | C# | oos | 14,886 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin_rol:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnRole
{
public EnRole()
{}
#region Model
private int _id;
private int _parentid;
private string _title;
private string _mark;
private string _descript;
private int _sort;
/// <summary>
///
/// </summary>
public int id
{
set{ _id=value;}
get{return _id;}
}
/// <summary>
///
/// </summary>
public int parentid
{
set{ _parentid=value;}
get{return _parentid;}
}
/// <summary>
///
/// </summary>
public string title
{
set{ _title=value;}
get{return _title;}
}
/// <summary>
///
/// </summary>
public string mark
{
set{ _mark=value;}
get{return _mark;}
}
/// <summary>
///
/// </summary>
public string descript
{
set{ _descript=value;}
get{return _descript;}
}
/// <summary>
///
/// </summary>
public int sort
{
set{ _sort=value;}
get{return _sort;}
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnRole.cs | C# | oos | 1,175 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TREC.Config;
namespace TREC.Entity
{
public class EnFilePath
{
protected static string resource = WebConfigs.GetConfig().WebUrl + "/";
protected static string _company = "";
protected static string _dealer = "";
protected static string _shop = "";
protected static string _market = "";
protected static string _brand = "";
protected static string _article = "";
protected static string _articlecategory = "";
protected static string _promotion = "";
protected static string _groupon = "";
protected static string _product = "";
protected static string _productcategory = "";
protected static string _productattribute = "";
protected static string _ad = "";
protected static string _apppromotionbrand = "";
public static string Thumb = "thumb";
public static string Surface = "surface";
public static string Logo = "logo";
public static string Banner ="banner";
public static string DesImage = "desimage";
public static string ConImage = "conimage";
public static string ProductAttributeColorImg = "productcolor";
public static string fileRootPath = "/upload";
public static string tmpRootPath = "/upload/temp/";
public static string Company
{
get {
if (_company == "")
return fileRootPath + "/company/{1}/{0}/";
return _company;
}
set { _company = value; }
}
public static string Dealer
{
get
{
if (_dealer == "")
return fileRootPath + "/dealer/{1}/{0}/";
return _dealer;
}
set { _dealer = value; }
}
public static string Shop
{
get
{
if (_shop == "")
return fileRootPath + "/shop/{1}/{0}/";
return _shop;
}
set { _shop = value; }
}
public static string Market
{
get
{
if (_market == "")
return fileRootPath + "/market/{1}/{0}/";
return _market;
}
set { _market = value; }
}
public static string MarketStorey
{
get
{
if (_market == "")
return fileRootPath + "/marketstorey/{1}/{0}/";
return _market;
}
set { _market = value; }
}
public static string Brand
{
get
{
if (_brand == "")
return fileRootPath + "/brand/{1}/{0}/";
return _brand;
}
set { _brand = value; }
}
public static string Brands
{
get
{
if (_brand == "")
return fileRootPath + "/brands//{1}{0}/";
return _brand;
}
set { _brand = value; }
}
public static string Article
{
get
{
if (_article == "")
return fileRootPath + "/article/{1}/{0}/";
return _article;
}
set { _article = value; }
}
public static string ArticleCategory
{
get
{
if (_articlecategory == "")
return fileRootPath + "/articlecategory/{1}/{0}/";
return _articlecategory;
}
set { _articlecategory = value; }
}
public static string Promotion
{
get
{
if (_promotion == "")
return fileRootPath + "/promotion/{1}/{0}/";
return _promotion;
}
set { _promotion = value; }
}
public static string PromotionDef
{
get
{
if (_promotion == "")
return fileRootPath + "/promotiondef/{1}/{0}/";
return _promotion;
}
set { _promotion = value; }
}
public static string Aggregation
{
get
{
if (_promotion == "")
return fileRootPath + "/aggregation/{1}/{0}/";
return _promotion;
}
set { _promotion = value; }
}
public static string Groupon
{
get
{
if (_groupon == "")
return fileRootPath + "/groupon/{1}/{0}/";
return _groupon;
}
set { _groupon = value; }
}
public static string Product
{
get
{
if (_product == "")
return fileRootPath + "/product/{1}/{0}/";
return _product;
}
set { _product = value; }
}
public static string ProductCategory
{
get
{
if (_productcategory == "")
return fileRootPath + "/productcategory/{1}/{0}/";
return _productcategory;
}
set { _productcategory = value; }
}
public static string ProductAttribute
{
get
{
if (_productattribute == "")
return fileRootPath + "/productcategory/{1}/{0}/";
return _productattribute;
}
set { _productattribute = value; }
}
public static string Ad
{
get
{
if (_ad == "")
return fileRootPath + "/show/{1}/{0}/";
return _ad;
}
set { _ad = value; }
}
public static string AppPromotionBrand
{
get
{
if (_apppromotionbrand == "")
return fileRootPath + "/apppromotionbrand/{1}/{0}/";
return _apppromotionbrand;
}
set { _apppromotionbrand = value; }
}
public static string GetFile(string file)
{
return file.Replace(",", "");
}
public static string GetCompanyThumbPath(string id,string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Company, id, Thumb) + "/" + file : resource + "resource/web/images/noshop.jpg";
}
public static string GetCompanyBannerPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Company, id, Banner) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetShopThumbPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Shop, id, Thumb) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetAggregationThumbPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Aggregation, id, Thumb) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetShopBannerPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Shop, id, Banner) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetBrandThumbPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Brand, id, Thumb) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetFordioBrandLogoPath(string file)
{
return !string.IsNullOrEmpty(file) ? "http://www.fujiawang.com/images/brand/105_38/" + file + "_1" : resource + "resource/web/images/noshop.jpg";
}
public static string GetProductThumbPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Product, id, Thumb) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetProductBannerPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Product, id, Banner) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetBrandLogoPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Brand, id, Logo) + "/" + GetFile(file) : resource+"resource/web/images/noproductlistshop.gif";
}
public static string GetMarketSurfacePath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Market, id, Surface) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetMarketLogoPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Market, id, Logo) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetMarketBannerPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Market, id, Banner) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetMarketStoreyThumbPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(MarketStorey, id, Thumb) + "/" + GetFile(file) : resource + "/resource/web/images/nomarkets.gif";
}
public static string GetMarketThumbPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Market, id, Thumb) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
public static string GetMarketDescriptPath(string id, string file)
{
return !string.IsNullOrEmpty(file) ? resource + string.Format(Market, id, DesImage) + "/" + GetFile(file) : resource + "resource/web/images/noshop.jpg";
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnFilePath.cs | C# | oos | 11,070 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace TREC.Entity
{
public class EnWebAggregation
{
#region Model
private int _id;
private string _typethumb;
private string _typeurl;
private string _typetitle;
private int? _parent;
private int? _type;
private string _title;
private string _title1;
private string _title2;
private string _title3;
private string _thumb;
private int? _thumbw;
private int? _thumbh;
private string _bannel;
private string _url;
private string _descript;
private int? _sort;
private int? _hits;
private DateTime _lastedittime;
private int? _createmid;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string typethumb
{
set { _typethumb = value; }
get { return _typethumb; }
}
/// <summary>
///
/// </summary>
public string typeurl
{
set { _typeurl = value; }
get { return _typeurl; }
}
/// <summary>
///
/// </summary>
public string typetitle
{
set { _typetitle = value; }
get { return _typetitle; }
}
/// <summary>
///
/// </summary>
public int? parent
{
set { _parent = value; }
get { return _parent; }
}
/// <summary>
///
/// </summary>
public int? type
{
set { _type = value; }
get { return _type; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string title1
{
set { _title1 = value; }
get { return _title1; }
}
/// <summary>
///
/// </summary>
public string title2
{
set { _title2 = value; }
get { return _title2; }
}
/// <summary>
///
/// </summary>
public string title3
{
set { _title3 = value; }
get { return _title3; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public int? thumbw
{
set { _thumbw = value; }
get { return _thumbw; }
}
/// <summary>
///
/// </summary>
public int? thumbh
{
set { _thumbh = value; }
get { return _thumbh; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string url
{
set { _url = value; }
get { return _url; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int? createmid
{
set { _createmid = value; }
get { return _createmid; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebAggregation.cs | C# | oos | 4,690 |
using System;
namespace TREC.Entity
{
/// <summary>
/// sys_module_link:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnModuleLink
{
public EnModuleLink()
{}
#region Model
private int _moduleid;
private string _title;
private string _icourl;
private string _linkurl;
/// <summary>
///
/// </summary>
public int ModuleId
{
set { _moduleid = value; }
get { return _moduleid; }
}
/// <summary>
///
/// </summary>
public string title
{
set{ _title=value;}
get{return _title;}
}
/// <summary>
///
/// </summary>
public string icourl
{
set{ _icourl=value;}
get{return _icourl;}
}
/// <summary>
///
/// </summary>
public string linkurl
{
set{ _linkurl=value;}
get{return _linkurl;}
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnModuleLink.cs | C# | oos | 956 |
using System;
namespace TREC.Entity
{
/// <summary>
/// sys_action:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnMarketStoreyShop
{
public EnMarketStoreyShop()
{}
#region Model
private int _id;
private int _marketid;
private string _markettitle;
private int _storeyid;
private string _storeytitle;
private int _shopid;
private string _shoptitle;
private string _brandidlist;
private string _brandtitlelist;
private int? _istop;
private int? _isrecommend;
private int? _lev;
private int? _sort;
private int? _lastedid = 0;
private DateTime _lastedittime;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public int marketid
{
set { _marketid = value; }
get { return _marketid; }
}
/// <summary>
///
/// </summary>
public string markettitle
{
set { _markettitle = value; }
get { return _markettitle; }
}
/// <summary>
///
/// </summary>
public int storeyid
{
set { _storeyid = value; }
get { return _storeyid; }
}
/// <summary>
///
/// </summary>
public string storeytitle
{
set { _storeytitle = value; }
get { return _storeytitle; }
}
/// <summary>
///
/// </summary>
public int shopid
{
set { _shopid = value; }
get { return _shopid; }
}
/// <summary>
///
/// </summary>
public string shoptitle
{
set { _shoptitle = value; }
get { return _shoptitle; }
}
/// <summary>
///
/// </summary>
public string brandidlist
{
set { _brandidlist = value; }
get { return _brandidlist; }
}
/// <summary>
///
/// </summary>
public string brandtitlelist
{
set { _brandtitlelist = value; }
get { return _brandtitlelist; }
}
/// <summary>
///
/// </summary>
public int? istop
{
set { _istop = value; }
get { return _istop; }
}
/// <summary>
///
/// </summary>
public int? isrecommend
{
set { _isrecommend = value; }
get { return _isrecommend; }
}
/// <summary>
///
/// </summary>
public int? lev
{
set { _lev = value; }
get { return _lev; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnMarketStoreyShop.cs | C# | oos | 3,740 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnAdmin
{
public EnAdmin()
{}
#region Model
private int _id;
private string _name;
private string _password;
private string _displayname;
private string _question;
private string _answer;
private string _email;
private string _phone;
private string _areacode;
private string _address;
private int _logincount=0;
private int _islock=0;
private string _lastmodule;
private DateTime _createdate;
private DateTime _lastactivitydate;
/// <summary>
///
/// </summary>
public int id
{
set{ _id=value;}
get{return _id;}
}
/// <summary>
///
/// </summary>
public string name
{
set{ _name=value;}
get{return _name;}
}
/// <summary>
///
/// </summary>
public string password
{
set{ _password=value;}
get{return _password;}
}
/// <summary>
///
/// </summary>
public string displayname
{
set{ _displayname=value;}
get{return _displayname;}
}
/// <summary>
///
/// </summary>
public string question
{
set{ _question=value;}
get{return _question;}
}
/// <summary>
///
/// </summary>
public string answer
{
set{ _answer=value;}
get{return _answer;}
}
/// <summary>
///
/// </summary>
public string email
{
set{ _email=value;}
get{return _email;}
}
/// <summary>
///
/// </summary>
public string phone
{
set{ _phone=value;}
get{return _phone;}
}
/// <summary>
///
/// </summary>
public string areacode
{
set{ _areacode=value;}
get{return _areacode;}
}
/// <summary>
///
/// </summary>
public string address
{
set{ _address=value;}
get{return _address;}
}
/// <summary>
///
/// </summary>
public int logincount
{
set{ _logincount=value;}
get{return _logincount;}
}
/// <summary>
///
/// </summary>
public int islock
{
set{ _islock=value;}
get{return _islock;}
}
/// <summary>
///
/// </summary>
public string lastmodule
{
set{ _lastmodule=value;}
get{return _lastmodule;}
}
/// <summary>
///
/// </summary>
public DateTime createdate
{
set{ _createdate=value;}
get{return _createdate;}
}
/// <summary>
///
/// </summary>
public DateTime lastactivitydate
{
set{ _lastactivitydate=value;}
get{return _lastactivitydate;}
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnAdmin.cs | C# | oos | 2,695 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
namespace TREC.Entity
{
[Serializable]
public class EnWebMarket
{
#region Model
private int? _shopcount;
private string _shopxml;
private string _brandxml;
private string _marketstoreyxml;
private int _id;
private int _mid;
private string _title;
private string _letter;
private int _groupid;
private string _attribute;
private string _industry;
private string _productcategory;
private int? _vip;
private string _areacode;
private string _address;
private string _mapapi;
private int? _staffsize;
private string _regyear;
private string _regcity;
private string _buy;
private string _sell;
private decimal? _cbm;
private string _lphone;
private string _zphone;
private string _busroute;
private string _hours;
private string _linkman;
private string _phone;
private string _mphone;
private string _fax;
private string _email;
private string _postcode;
private string _homepage;
private string _domain;
private string _domainip;
private string _icp;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _keywords;
private string _template;
private int? _hits;
private int? _sort;
private int? _createmid;
private int? _lastedid;
private DateTime _lastedittime;
private int _auditstatus;
private int _linestatus;
/// <summary>
///
/// </summary>
public int? shopcount
{
set { _shopcount = value; }
get { return _shopcount; }
}
/// <summary>
///
/// </summary>
public string shopxml
{
set { _shopxml = value; }
get { return _shopxml; }
}
/// <summary>
///
/// </summary>
public string brandxml
{
set { _brandxml = value; }
get { return _brandxml; }
}
public string marketstoreyxml
{
set { _marketstoreyxml = value; }
get { return _marketstoreyxml; }
}
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public int mid
{
set { _mid = value; }
get { return _mid; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public int groupid
{
set { _groupid = value; }
get { return _groupid; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string industry
{
set { _industry = value; }
get { return _industry; }
}
/// <summary>
///
/// </summary>
public string productcategory
{
set { _productcategory = value; }
get { return _productcategory; }
}
/// <summary>
///
/// </summary>
public int? vip
{
set { _vip = value; }
get { return _vip; }
}
/// <summary>
///
/// </summary>
public string areacode
{
set { _areacode = value; }
get { return _areacode; }
}
/// <summary>
///
/// </summary>
public string address
{
set { _address = value; }
get { return _address; }
}
/// <summary>
///
/// </summary>
public string mapapi
{
set { _mapapi = value; }
get { return _mapapi; }
}
/// <summary>
///
/// </summary>
public int? staffsize
{
set { _staffsize = value; }
get { return _staffsize; }
}
/// <summary>
///
/// </summary>
public string regyear
{
set { _regyear = value; }
get { return _regyear; }
}
/// <summary>
///
/// </summary>
public string regcity
{
set { _regcity = value; }
get { return _regcity; }
}
/// <summary>
///
/// </summary>
public string buy
{
set { _buy = value; }
get { return _buy; }
}
/// <summary>
///
/// </summary>
public string sell
{
set { _sell = value; }
get { return _sell; }
}
/// <summary>
///
/// </summary>
public decimal? cbm
{
set { _cbm = value; }
get { return _cbm; }
}
/// <summary>
///
/// </summary>
public string lphone
{
set { _lphone = value; }
get { return _lphone; }
}
/// <summary>
///
/// </summary>
public string zphone
{
set { _zphone = value; }
get { return _zphone; }
}
/// <summary>
///
/// </summary>
public string busroute
{
set { _busroute = value; }
get { return _busroute; }
}
/// <summary>
///
/// </summary>
public string hours
{
set { _hours = value; }
get { return _hours; }
}
/// <summary>
///
/// </summary>
public string linkman
{
set { _linkman = value; }
get { return _linkman; }
}
/// <summary>
///
/// </summary>
public string phone
{
set { _phone = value; }
get { return _phone; }
}
/// <summary>
///
/// </summary>
public string mphone
{
set { _mphone = value; }
get { return _mphone; }
}
/// <summary>
///
/// </summary>
public string fax
{
set { _fax = value; }
get { return _fax; }
}
/// <summary>
///
/// </summary>
public string email
{
set { _email = value; }
get { return _email; }
}
/// <summary>
///
/// </summary>
public string postcode
{
set { _postcode = value; }
get { return _postcode; }
}
/// <summary>
///
/// </summary>
public string homepage
{
set { _homepage = value; }
get { return _homepage; }
}
/// <summary>
///
/// </summary>
public string domain
{
set { _domain = value; }
get { return _domain; }
}
/// <summary>
///
/// </summary>
public string domainip
{
set { _domainip = value; }
get { return _domainip; }
}
/// <summary>
///
/// </summary>
public string icp
{
set { _icp = value; }
get { return _icp; }
}
/// <summary>
///
/// </summary>
public string surface
{
set { _surface = value; }
get { return _surface; }
}
/// <summary>
///
/// </summary>
public string logo
{
set { _logo = value; }
get { return _logo; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string desimage
{
set { _desimage = value; }
get { return _desimage; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string keywords
{
set { _keywords = value; }
get { return _keywords; }
}
/// <summary>
///
/// </summary>
public string template
{
set { _template = value; }
get { return _template; }
}
/// <summary>
///
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? createmid
{
set { _createmid = value; }
get { return _createmid; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int auditstatus
{
set { _auditstatus = value; }
get { return _auditstatus; }
}
/// <summary>
///
/// </summary>
public int linestatus
{
set { _linestatus = value; }
get { return _linestatus; }
}
#endregion Model
public MarketShop MarketShopInfo
{
get
{
if (MarketShopList.Count > 0)
{
return MarketShopList[0];
}
return new MarketShop();
}
}
public List<MarketShop> MarketShopList
{
get
{
if (!string.IsNullOrEmpty(shopxml))
{
List<MarketShop> list = new List<MarketShop>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(shopxml, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
MarketShop m = new MarketShop();
GroupCollection gc = match.Groups;
list.Add((MarketShop)TRECommon.SerializationHelper.DeSerialize(typeof(MarketShop), "<MarketShop>" + gc["g"].Value + "</MarketShop>"));
}
}
return list;
}
return new List<MarketShop>();
}
}
public MarketBrand MarketBrandInfo
{
get
{
if (MarketBrandList.Count > 0)
{
return MarketBrandList[0];
}
return new MarketBrand();
}
}
public List<MarketBrand> MarketBrandList
{
get
{
if (!string.IsNullOrEmpty(brandxml))
{
List<MarketBrand> list = new List<MarketBrand>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(brandxml, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
MarketBrand m = new MarketBrand();
GroupCollection gc = match.Groups;
list.Add((MarketBrand)TRECommon.SerializationHelper.DeSerialize(typeof(MarketBrand), "<MarketBrand>" + gc["g"].Value + "</MarketBrand>"));
}
}
return list;
}
return new List<MarketBrand>();
}
}
public List<MarketStorey> MarketStoreyList
{
get
{
if (!string.IsNullOrEmpty(marketstoreyxml))
{
List<MarketStorey> list = new List<MarketStorey>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(marketstoreyxml, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
MarketStorey m = new MarketStorey();
GroupCollection gc = match.Groups;
list.Add((MarketStorey)TRECommon.SerializationHelper.DeSerialize(typeof(MarketStorey), "<MarketStorey>" + gc["g"].Value + "</MarketStorey>"));
}
}
return list;
}
return new List<MarketStorey>();
}
}
[Serializable]
public class MarketBrand
{
public string id { get; set; }
public string title { get; set; }
public string logo { get; set; }
public string storeytitle { get; set; }
public string companyid { get; set; }
}
[Serializable]
public class MarketShop
{
public string id { get; set; }
public string title { get; set; }
public string thumb { get; set; }
public string map { get; set; }
public string linkman { get; set; }
public string phone { get; set; }
public string areacode { get; set; }
public string address { get; set; }
public string brandid{ get; set; }
public string brandletter{ get; set; }
public string brandlogo{ get; set; }
public string brandtitle { get; set; }
public string brandstylename { get; set; }
public string marketstorey { get; set; }
}
[Serializable]
public class MarketStorey
{
public string id { get; set; }
public string title { get; set; }
public string thumb { get; set; }
public string number { get; set; }
public string surface { get; set; }
public string logo { get; set; }
public string bannel { get; set; }
public string desimage { get; set; }
public string descript { get; set; }
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebMarket.cs | C# | oos | 17,146 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public class EnWebCompanyBrand
{
#region Model
private int _id;
private int _mid;
private string _title;
private string _letter;
private int _groupid;
private string _attribute;
private string _industry;
private string _productcategory;
private int? _vip;
private string _areacode;
private string _address;
private string _mapapi;
private int? _staffsize;
private string _regyear;
private string _regcity;
private string _buy;
private string _sell;
private string _linkman;
private string _phone;
private string _mphone;
private string _fax;
private string _email;
private string _postcode;
private string _homepage;
private string _domain;
private string _domainip;
private string _icp;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _keywords;
private string _template;
private int? _hits;
private int? _sort;
private int? _createmid;
private int? _lastedid;
private DateTime _lastedittime;
private int _auditstatus;
private int _linestatus;
private int? _brandid;
private string _brandtitle;
private string _brandthumb;
private string _stylevalue;
private string _materialvalue;
private string _spreadvalue;
private int? _brandlinestatus;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public int mid
{
set { _mid = value; }
get { return _mid; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public int groupid
{
set { _groupid = value; }
get { return _groupid; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string industry
{
set { _industry = value; }
get { return _industry; }
}
/// <summary>
///
/// </summary>
public string productcategory
{
set { _productcategory = value; }
get { return _productcategory; }
}
/// <summary>
///
/// </summary>
public int? vip
{
set { _vip = value; }
get { return _vip; }
}
/// <summary>
///
/// </summary>
public string areacode
{
set { _areacode = value; }
get { return _areacode; }
}
/// <summary>
///
/// </summary>
public string address
{
set { _address = value; }
get { return _address; }
}
/// <summary>
///
/// </summary>
public string mapapi
{
set { _mapapi = value; }
get { return _mapapi; }
}
/// <summary>
///
/// </summary>
public int? staffsize
{
set { _staffsize = value; }
get { return _staffsize; }
}
/// <summary>
///
/// </summary>
public string regyear
{
set { _regyear = value; }
get { return _regyear; }
}
/// <summary>
///
/// </summary>
public string regcity
{
set { _regcity = value; }
get { return _regcity; }
}
/// <summary>
///
/// </summary>
public string buy
{
set { _buy = value; }
get { return _buy; }
}
/// <summary>
///
/// </summary>
public string sell
{
set { _sell = value; }
get { return _sell; }
}
/// <summary>
///
/// </summary>
public string linkman
{
set { _linkman = value; }
get { return _linkman; }
}
/// <summary>
///
/// </summary>
public string phone
{
set { _phone = value; }
get { return _phone; }
}
/// <summary>
///
/// </summary>
public string mphone
{
set { _mphone = value; }
get { return _mphone; }
}
/// <summary>
///
/// </summary>
public string fax
{
set { _fax = value; }
get { return _fax; }
}
/// <summary>
///
/// </summary>
public string email
{
set { _email = value; }
get { return _email; }
}
/// <summary>
///
/// </summary>
public string postcode
{
set { _postcode = value; }
get { return _postcode; }
}
/// <summary>
///
/// </summary>
public string homepage
{
set { _homepage = value; }
get { return _homepage; }
}
/// <summary>
///
/// </summary>
public string domain
{
set { _domain = value; }
get { return _domain; }
}
/// <summary>
///
/// </summary>
public string domainip
{
set { _domainip = value; }
get { return _domainip; }
}
/// <summary>
///
/// </summary>
public string icp
{
set { _icp = value; }
get { return _icp; }
}
/// <summary>
///
/// </summary>
public string surface
{
set { _surface = value; }
get { return _surface; }
}
/// <summary>
///
/// </summary>
public string logo
{
set { _logo = value; }
get { return _logo; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string desimage
{
set { _desimage = value; }
get { return _desimage; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string keywords
{
set { _keywords = value; }
get { return _keywords; }
}
/// <summary>
///
/// </summary>
public string template
{
set { _template = value; }
get { return _template; }
}
/// <summary>
///
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? createmid
{
set { _createmid = value; }
get { return _createmid; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int auditstatus
{
set { _auditstatus = value; }
get { return _auditstatus; }
}
/// <summary>
///
/// </summary>
public int linestatus
{
set { _linestatus = value; }
get { return _linestatus; }
}
/// <summary>
///
/// </summary>
public int? brandid
{
set { _brandid = value; }
get { return _brandid; }
}
/// <summary>
///
/// </summary>
public string brandtitle
{
set { _brandtitle = value; }
get { return _brandtitle; }
}
/// <summary>
///
/// </summary>
public string brandthumb
{
set { _brandthumb = value; }
get { return _brandthumb; }
}
/// <summary>
///
/// </summary>
public string stylevalue
{
set { _stylevalue = value; }
get { return _stylevalue; }
}
/// <summary>
///
/// </summary>
public string materialvalue
{
set { _materialvalue = value; }
get { return _materialvalue; }
}
/// <summary>
///
/// </summary>
public string spreadvalue
{
set { _spreadvalue = value; }
get { return _spreadvalue; }
}
/// <summary>
///
/// </summary>
public int? brandlinestatus
{
set { _brandlinestatus = value; }
get { return _brandlinestatus; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebCompanyBrand.cs | C# | oos | 11,242 |
using System;
namespace TREC.Entity
{
/// <summary>
/// t_articlecategory:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnArticleCategory
{
public EnArticleCategory()
{}
#region Model
private int _id;
private string _attribute;
private string _title;
private string _subtitle;
private string _letter;
private string _ico;
private string _thumb;
private string _banner;
private string _keyword;
private string _descript;
private string _context;
private string _othercon;
private int _linktype;
private string _linkurl;
private int _parentid;
private int _lft;
private int _rgt;
private string _depth;
private int _lev;
private string _indextemplate;
private string _listtemplate;
private string _contemplate;
private int _sort = 0;
private DateTime _createtime;
private int _createid = 0;
private DateTime _edittime = DateTime.Now;
private int _editid = 0;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string subtitle
{
set { _subtitle = value; }
get { return _subtitle; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public string ico
{
set { _ico = value; }
get { return _ico; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string banner
{
set { _banner = value; }
get { return _banner; }
}
/// <summary>
///
/// </summary>
public string keyword
{
set { _keyword = value; }
get { return _keyword; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string context
{
set { _context = value; }
get { return _context; }
}
/// <summary>
///
/// </summary>
public string othercon
{
set { _othercon = value; }
get { return _othercon; }
}
/// <summary>
///
/// </summary>
public int linktype
{
set { _linktype = value; }
get { return _linktype; }
}
/// <summary>
///
/// </summary>
public string linkurl
{
set { _linkurl = value; }
get { return _linkurl; }
}
/// <summary>
///
/// </summary>
public int parentid
{
set { _parentid = value; }
get { return _parentid; }
}
/// <summary>
///
/// </summary>
public int lft
{
set { _lft = value; }
get { return _lft; }
}
/// <summary>
///
/// </summary>
public int rgt
{
set { _rgt = value; }
get { return _rgt; }
}
/// <summary>
///
/// </summary>
public string depth
{
set { _depth = value; }
get { return _depth; }
}
/// <summary>
///
/// </summary>
public int lev
{
set { _lev = value; }
get { return _lev; }
}
/// <summary>
///
/// </summary>
public string indextemplate
{
set { _indextemplate = value; }
get { return _indextemplate; }
}
/// <summary>
///
/// </summary>
public string listtemplate
{
set { _listtemplate = value; }
get { return _listtemplate; }
}
/// <summary>
///
/// </summary>
public string contemplate
{
set { _contemplate = value; }
get { return _contemplate; }
}
/// <summary>
///
/// </summary>
public int sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public DateTime createtime
{
set { _createtime = value; }
get { return _createtime; }
}
/// <summary>
///
/// </summary>
public int createid
{
set { _createid = value; }
get { return _createid; }
}
/// <summary>
///
/// </summary>
public DateTime edittime
{
set { _edittime = value; }
get { return _edittime; }
}
/// <summary>
///
/// </summary>
public int editid
{
set { _editid = value; }
get { return _editid; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnArticleCategory.cs | C# | oos | 6,363 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnAdvertisement
{
public EnAdvertisement()
{}
#region Model
private int _id;
private int _categoryid;
private string _title;
private string _linkurl;
private string _flashurl;
private string _imgurl;
private string _videourl;
private string _adtext;
private string _adcode;
private int? _isopen;
private string _adlinkman;
private string _adlinkphone;
private string _adlinkemail;
private DateTime _lastedittime;
private int _lasteditaid;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public int categoryid
{
set { _categoryid = value; }
get { return _categoryid; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string linkurl
{
set { _linkurl = value; }
get { return _linkurl; }
}
/// <summary>
///
/// </summary>
public string flashurl
{
set { _flashurl = value; }
get { return _flashurl; }
}
/// <summary>
///
/// </summary>
public string imgurl
{
set { _imgurl = value; }
get { return _imgurl; }
}
/// <summary>
///
/// </summary>
public string videourl
{
set { _videourl = value; }
get { return _videourl; }
}
/// <summary>
///
/// </summary>
public string adtext
{
set { _adtext = value; }
get { return _adtext; }
}
/// <summary>
///
/// </summary>
public string adcode
{
set { _adcode = value; }
get { return _adcode; }
}
/// <summary>
///
/// </summary>
public int? isopen
{
set { _isopen = value; }
get { return _isopen; }
}
/// <summary>
///
/// </summary>
public string adlinkman
{
set { _adlinkman = value; }
get { return _adlinkman; }
}
/// <summary>
///
/// </summary>
public string adlinkphone
{
set { _adlinkphone = value; }
get { return _adlinkphone; }
}
/// <summary>
///
/// </summary>
public string adlinkemail
{
set { _adlinkemail = value; }
get { return _adlinkemail; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int lasteditaid
{
set { _lasteditaid = value; }
get { return _lasteditaid; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnAdvertisement.cs | C# | oos | 3,724 |
using System;
using System.Collections;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public class EnWebPromotionInfoList
{
#region Model
private string _brandlogo;
private string _ptitle;
private string _htmltitle;
private DateTime? _startdatetime;
private DateTime? _enddatetime;
private string _areacode;
private string _address;
private int? _ptype;
private int _id;
private string _title;
private int _pid;
private string _attribute;
private string _type;
private string _value;
private string _valueletter;
private string _valuetitle;
private string _thumb;
private string _banner;
private string _descript;
private string _curcountmoney;
private string _curcountpeople;
private string _curstage;
private string _fordio;
private int? _sort;
private string _stagelist;
private int? _stagecount;
//public
/// <summary>
///
/// </summary>
public string brandlogo
{
set { _brandlogo = value; }
get { return _brandlogo; }
}
/// <summary>
///
/// </summary>
public string ptitle
{
set { _ptitle = value; }
get { return _ptitle; }
}
/// <summary>
///
/// </summary>
public string htmltitle
{
set { _htmltitle = value; }
get { return _htmltitle; }
}
/// <summary>
///
/// </summary>
public DateTime? startdatetime
{
set { _startdatetime = value; }
get { return _startdatetime; }
}
/// <summary>
///
/// </summary>
public DateTime? enddatetime
{
set { _enddatetime = value; }
get { return _enddatetime; }
}
/// <summary>
///
/// </summary>
public string areacode
{
set { _areacode = value; }
get { return _areacode; }
}
/// <summary>
///
/// </summary>
public string address
{
set { _address = value; }
get { return _address; }
}
/// <summary>
///
/// </summary>
public int? ptype
{
set { _ptype = value; }
get { return _ptype; }
}
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public int pid
{
set { _pid = value; }
get { return _pid; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string type
{
set { _type = value; }
get { return _type; }
}
/// <summary>
///
/// </summary>
public string value
{
set { _value = value; }
get { return _value; }
}
/// <summary>
///
/// </summary>
public string valueletter
{
set { _valueletter = value; }
get { return _valueletter; }
}
/// <summary>
///
/// </summary>
public string valuetitle
{
set { _valuetitle = value; }
get { return _valuetitle; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string banner
{
set { _banner = value; }
get { return _banner; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string curcountmoney
{
set { _curcountmoney = value; }
get { return _curcountmoney; }
}
/// <summary>
///
/// </summary>
public string curcountpeople
{
set { _curcountpeople = value; }
get { return _curcountpeople; }
}
/// <summary>
///
/// </summary>
public string curstage
{
set { _curstage = value; }
get { return _curstage; }
}
/// <summary>
///
/// </summary>
public string fordio
{
set { _fordio = value; }
get { return _fordio; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public string stagelist
{
set { _stagelist = value; }
get { return _stagelist; }
}
/// <summary>
///
/// </summary>
public int? stagecount
{
set { _stagecount = value; }
get { if (_stagecount == 0)return 1; return _stagecount; }
}
#endregion Model
private List<EnPromotionStage> _Stagelist = new List<EnPromotionStage>();
public List<EnPromotionStage> StageList
{
get
{
if (!string.IsNullOrEmpty(stagelist))
{
List<EnPromotionStage> list = new List<EnPromotionStage>();
string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", "<type>", "</type>");//匹配URL的模式,并分组
MatchCollection mc = Regex.Matches(stagelist, pattern);//满足pattern的匹配集合
if (mc.Count != 0)
{
foreach (Match match in mc)
{
GroupCollection gc = match.Groups;
EnPromotionStage m = (EnPromotionStage)TRECommon.SerializationHelper.DeSerialize(typeof(EnPromotionStage), "<EnPromotionStage>" + gc["g"].Value + "</EnPromotionStage>");
list.Add(m);
}
}
return list;
}
return new List<EnPromotionStage>();
}
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnWebPromotionInfoList.cs | C# | oos | 7,504 |
using System;
namespace TREC.Entity
{
/// <summary>
/// product:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnProduct
{
public EnProduct()
{}
#region Model
private int _id;
private string _attribute;
private string _title;
private string _shottitle;
private string _tcolor;
private string _sku;
private string _no;
private string _letter;
private int _categoryid;
private string _categorytitle;
private string _subcategoryidlist;
private string _subcategorytitlelist;
private int _brandid;
private string _brandtitle;
private int? _brandsid;
private string _brandstitle;
private string _stylevalue;
private string _stylename;
private string _colorname;
private string _colorvalue;
private string _materialvalue;
private string _materialname;
private string _unit;
private string _localitycode;
private string _shipcode;
private int? _customize = 0;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _tob2c;
private int? _companyid;
private string _companyname;
private int _createmid = 0;
private int? _hits;
private int? _sort;
private int? _lastedid = 0;
private DateTime _lastedittime;
private int _auditstatus;
private int _linestatus;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string shottitle
{
set { _shottitle = value; }
get { return _shottitle; }
}
/// <summary>
///
/// </summary>
public string tcolor
{
set { _tcolor = value; }
get { return _tcolor; }
}
/// <summary>
///
/// </summary>
public string sku
{
set { _sku = value; }
get { return _sku; }
}
/// <summary>
///
/// </summary>
public string no
{
set { _no = value; }
get { return _no; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public int categoryid
{
set { _categoryid = value; }
get { return _categoryid; }
}
/// <summary>
///
/// </summary>
public string categorytitle
{
set { _categorytitle = value; }
get { return _categorytitle; }
}
/// <summary>
///
/// </summary>
public string subcategoryidlist
{
set { _subcategoryidlist = value; }
get { return _subcategoryidlist; }
}
/// <summary>
///
/// </summary>
public string subcategorytitlelist
{
set { _subcategorytitlelist = value; }
get { return _subcategorytitlelist; }
}
/// <summary>
///
/// </summary>
public int brandid
{
set { _brandid = value; }
get { return _brandid; }
}
/// <summary>
///
/// </summary>
public string brandtitle
{
set { _brandtitle = value; }
get { return _brandtitle; }
}
/// <summary>
///
/// </summary>
public int? brandsid
{
set { _brandsid = value; }
get { return _brandsid; }
}
/// <summary>
///
/// </summary>
public string brandstitle
{
set { _brandstitle = value; }
get { return _brandstitle; }
}
/// <summary>
///
/// </summary>
public string stylevalue
{
set { _stylevalue = value; }
get { return _stylevalue; }
}
/// <summary>
///
/// </summary>
public string stylename
{
set { _stylename = value; }
get { return _stylename; }
}
/// <summary>
///
/// </summary>
public string colorname
{
set { _colorname = value; }
get { return _colorname; }
}
/// <summary>
///
/// </summary>
public string colorvalue
{
set { _colorvalue = value; }
get { return _colorvalue; }
}
/// <summary>
///
/// </summary>
public string materialvalue
{
set { _materialvalue = value; }
get { return _materialvalue; }
}
/// <summary>
///
/// </summary>
public string materialname
{
set { _materialname = value; }
get { return _materialname; }
}
/// <summary>
///
/// </summary>
public string unit
{
set { _unit = value; }
get { return _unit; }
}
/// <summary>
///
/// </summary>
public string localitycode
{
set { _localitycode = value; }
get { return _localitycode; }
}
/// <summary>
///
/// </summary>
public string shipcode
{
set { _shipcode = value; }
get { return _shipcode; }
}
/// <summary>
///
/// </summary>
public int? customize
{
set { _customize = value; }
get { return _customize; }
}
/// <summary>
///
/// </summary>
public string surface
{
set { _surface = value; }
get { return _surface; }
}
/// <summary>
///
/// </summary>
public string logo
{
set { _logo = value; }
get { return _logo; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string desimage
{
set { _desimage = value; }
get { return _desimage; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string tob2c
{
set { _tob2c = value; }
get { return _tob2c; }
}
/// <summary>
///
/// </summary>
public int? companyid
{
set { _companyid = value; }
get { return _companyid; }
}
/// <summary>
///
/// </summary>
public string companyname
{
set { _companyname = value; }
get { return _companyname; }
}
/// <summary>
///
/// </summary>
public int createmid
{
set { _createmid = value; }
get { return _createmid; }
}
/// <summary>
///
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int auditstatus
{
set { _auditstatus = value; }
get { return _auditstatus; }
}
/// <summary>
///
/// </summary>
public int linestatus
{
set { _linestatus = value; }
get { return _linestatus; }
}
#endregion Model
public string HtmlProductName
{
get
{
return brandstitle + " " + sku + " " + materialname;
}
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnProduct.cs | C# | oos | 10,135 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnMember
{
public EnMember()
{}
#region Model
private int _id;
private string _username;
private string _password;
private string _paypassword;
private string _passport;
private int _type;
private int _groupid = 0;
private string _sound;
private string _tname;
private string _email;
private int? _gender;
private string _mobile;
private string _phone;
private string _msn;
private string _qq;
private string _skype;
private string _ali;
private DateTime _birthdate;
private string _areacode;
private string _address;
private string _department;
private string _career;
private decimal? _sms = 0M;
private decimal? _integral = 0M;
private decimal? _money = 0M;
private string _bank;
private string _account;
private string _alipay;
private string _regip;
private DateTime? _regtime = DateTime.Now;
private string _loginip;
private DateTime? _logintime = DateTime.Now;
private int? _logincount;
private string _auth;
private string _authvalue;
private DateTime _authtime;
private int? _vemail;
private int? _vmobile;
private int? _vname;
private int? _vbank;
private int? _vcompany;
private int? _valipay;
private string _support;
private string _inviter;
private DateTime? _lastedittime = DateTime.Now;
private int? _chat;
private int? _message;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
/// 登陆账号
/// </summary>
public string username
{
set { _username = value; }
get { return _username; }
}
/// <summary>
/// 密码
/// </summary>
public string password
{
set { _password = value; }
get { return _password; }
}
/// <summary>
/// 支付密码
/// </summary>
public string paypassword
{
set { _paypassword = value; }
get { return _paypassword; }
}
/// <summary>
/// 通行证
/// </summary>
public string passport
{
set { _passport = value; }
get { return _passport; }
}
/// <summary>
/// 账号类型
/// </summary>
public int type
{
set { _type = value; }
get { return _type; }
}
/// <summary>
/// 会员组ID
/// </summary>
public int groupid
{
set { _groupid = value; }
get { return _groupid; }
}
/// <summary>
/// 提示音
/// </summary>
public string sound
{
set { _sound = value; }
get { return _sound; }
}
/// <summary>
/// 真实姓名
/// </summary>
public string tname
{
set { _tname = value; }
get { return _tname; }
}
/// <summary>
/// email
/// </summary>
public string email
{
set { _email = value; }
get { return _email; }
}
/// <summary>
/// 性别
/// </summary>
public int? gender
{
set { _gender = value; }
get { return _gender; }
}
/// <summary>
/// 手机
/// </summary>
public string mobile
{
set { _mobile = value; }
get { return _mobile; }
}
/// <summary>
/// 电话
/// </summary>
public string phone
{
set { _phone = value; }
get { return _phone; }
}
/// <summary>
///
/// </summary>
public string msn
{
set { _msn = value; }
get { return _msn; }
}
/// <summary>
///
/// </summary>
public string qq
{
set { _qq = value; }
get { return _qq; }
}
/// <summary>
///
/// </summary>
public string skype
{
set { _skype = value; }
get { return _skype; }
}
/// <summary>
///
/// </summary>
public string ali
{
set { _ali = value; }
get { return _ali; }
}
/// <summary>
/// 出生日期
/// </summary>
public DateTime birthdate
{
set { _birthdate = value; }
get { return _birthdate; }
}
/// <summary>
/// 地区Code
/// </summary>
public string areacode
{
set { _areacode = value; }
get { return _areacode; }
}
/// <summary>
/// 详细地址
/// </summary>
public string address
{
set { _address = value; }
get { return _address; }
}
/// <summary>
/// 部门
/// </summary>
public string department
{
set { _department = value; }
get { return _department; }
}
/// <summary>
/// 职位
/// </summary>
public string career
{
set { _career = value; }
get { return _career; }
}
/// <summary>
/// 短信余额
/// </summary>
public decimal? sms
{
set { _sms = value; }
get { return _sms; }
}
/// <summary>
/// 积分
/// </summary>
public decimal? integral
{
set { _integral = value; }
get { return _integral; }
}
/// <summary>
/// 资金金额
/// </summary>
public decimal? money
{
set { _money = value; }
get { return _money; }
}
/// <summary>
/// 收款银行
/// </summary>
public string bank
{
set { _bank = value; }
get { return _bank; }
}
/// <summary>
/// 收款账号
/// </summary>
public string account
{
set { _account = value; }
get { return _account; }
}
/// <summary>
/// 支付宝账号
/// </summary>
public string alipay
{
set { _alipay = value; }
get { return _alipay; }
}
/// <summary>
/// 注册IP
/// </summary>
public string regip
{
set { _regip = value; }
get { return _regip; }
}
/// <summary>
/// 注册时间
/// </summary>
public DateTime? regtime
{
set { _regtime = value; }
get { return _regtime; }
}
/// <summary>
/// 最后登陆IP
/// </summary>
public string loginip
{
set { _loginip = value; }
get { return _loginip; }
}
/// <summary>
/// 最后登陆时间
/// </summary>
public DateTime? logintime
{
set { _logintime = value; }
get { return _logintime; }
}
/// <summary>
/// 登陆次数
/// </summary>
public int? logincount
{
set { _logincount = value; }
get { return _logincount; }
}
/// <summary>
/// 授权认证(密钥)
/// </summary>
public string auth
{
set { _auth = value; }
get { return _auth; }
}
/// <summary>
/// 授权认证内容
/// </summary>
public string authvalue
{
set { _authvalue = value; }
get { return _authvalue; }
}
/// <summary>
/// 验证时间
/// </summary>
public DateTime authtime
{
set { _authtime = value; }
get { return _authtime; }
}
/// <summary>
/// 邮箱认证
/// </summary>
public int? vemail
{
set { _vemail = value; }
get { return _vemail; }
}
/// <summary>
/// 手机认证
/// </summary>
public int? vmobile
{
set { _vmobile = value; }
get { return _vmobile; }
}
/// <summary>
/// 实名认证
/// </summary>
public int? vname
{
set { _vname = value; }
get { return _vname; }
}
/// <summary>
/// 验证银行
/// </summary>
public int? vbank
{
set { _vbank = value; }
get { return _vbank; }
}
/// <summary>
/// 验证公司
/// </summary>
public int? vcompany
{
set { _vcompany = value; }
get { return _vcompany; }
}
/// <summary>
/// 验证支付宝
/// </summary>
public int? valipay
{
set { _valipay = value; }
get { return _valipay; }
}
/// <summary>
/// 客服专员
/// </summary>
public string support
{
set { _support = value; }
get { return _support; }
}
/// <summary>
/// 推荐人(限定为用户名)
/// </summary>
public string inviter
{
set { _inviter = value; }
get { return _inviter; }
}
/// <summary>
/// 最后修改时间
/// </summary>
public DateTime? lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int? chat
{
set { _chat = value; }
get { return _chat; }
}
/// <summary>
///
/// </summary>
public int? message
{
set { _message = value; }
get { return _message; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnMember.cs | C# | oos | 11,274 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnShop
{
public EnShop()
{}
#region Model
private int _id;
private int _mid = 0;
private string _title;
private string _letter;
private int _groupid;
private string _attribute;
private string _industry;
private string _productcategory;
private int? _vip = 0;
private string _areacode;
private string _address;
private string _mapapi;
private int? _staffsize;
private string _regyear;
private string _regcity;
private string _buy;
private string _sell;
private string _linkman;
private string _phone;
private string _mphone;
private string _fax;
private string _email;
private string _postcode;
private string _homepage;
private string _domain;
private string _domainip;
private string _icp;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _keywords;
private string _template;
private int? _hits;
private int? _sort;
private int? _marketid;
private int? _cid = 0;
private int? _ctype = 0;
private int? _createmid = 0;
private int? _lastedid = 0;
private DateTime _lastedittime;
private int _auditstatus;
private int _linestatus;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public int mid
{
set { _mid = value; }
get { return _mid; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public int groupid
{
set { _groupid = value; }
get { return _groupid; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string industry
{
set { _industry = value; }
get { return _industry; }
}
/// <summary>
///
/// </summary>
public string productcategory
{
set { _productcategory = value; }
get { return _productcategory; }
}
/// <summary>
///
/// </summary>
public int? vip
{
set { _vip = value; }
get { return _vip; }
}
/// <summary>
///
/// </summary>
public string areacode
{
set { _areacode = value; }
get { return _areacode; }
}
/// <summary>
///
/// </summary>
public string address
{
set { _address = value; }
get { return _address; }
}
/// <summary>
///
/// </summary>
public string mapapi
{
set { _mapapi = value; }
get { return _mapapi; }
}
/// <summary>
///
/// </summary>
public int? staffsize
{
set { _staffsize = value; }
get { return _staffsize; }
}
/// <summary>
///
/// </summary>
public string regyear
{
set { _regyear = value; }
get { return _regyear; }
}
/// <summary>
///
/// </summary>
public string regcity
{
set { _regcity = value; }
get { return _regcity; }
}
/// <summary>
///
/// </summary>
public string buy
{
set { _buy = value; }
get { return _buy; }
}
/// <summary>
///
/// </summary>
public string sell
{
set { _sell = value; }
get { return _sell; }
}
/// <summary>
///
/// </summary>
public string linkman
{
set { _linkman = value; }
get { return _linkman; }
}
/// <summary>
///
/// </summary>
public string phone
{
set { _phone = value; }
get { return _phone; }
}
/// <summary>
///
/// </summary>
public string mphone
{
set { _mphone = value; }
get { return _mphone; }
}
/// <summary>
///
/// </summary>
public string fax
{
set { _fax = value; }
get { return _fax; }
}
/// <summary>
///
/// </summary>
public string email
{
set { _email = value; }
get { return _email; }
}
/// <summary>
///
/// </summary>
public string postcode
{
set { _postcode = value; }
get { return _postcode; }
}
/// <summary>
///
/// </summary>
public string homepage
{
set { _homepage = value; }
get { return _homepage; }
}
/// <summary>
///
/// </summary>
public string domain
{
set { _domain = value; }
get { return _domain; }
}
/// <summary>
///
/// </summary>
public string domainip
{
set { _domainip = value; }
get { return _domainip; }
}
/// <summary>
///
/// </summary>
public string icp
{
set { _icp = value; }
get { return _icp; }
}
/// <summary>
///
/// </summary>
public string surface
{
set { _surface = value; }
get { return _surface; }
}
/// <summary>
///
/// </summary>
public string logo
{
set { _logo = value; }
get { return _logo; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string bannel
{
set { _bannel = value; }
get { return _bannel; }
}
/// <summary>
///
/// </summary>
public string desimage
{
set { _desimage = value; }
get { return _desimage; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string keywords
{
set { _keywords = value; }
get { return _keywords; }
}
/// <summary>
///
/// </summary>
public string template
{
set { _template = value; }
get { return _template; }
}
/// <summary>
///
/// </summary>
public int? hits
{
set { _hits = value; }
get { return _hits; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? marketid
{
set { _marketid = value; }
get { return _marketid; }
}
/// <summary>
///
/// </summary>
public int? cid
{
set { _cid = value; }
get { return _cid; }
}
/// <summary>
///
/// </summary>
public int? ctype
{
set { _ctype = value; }
get { return _ctype; }
}
/// <summary>
///
/// </summary>
public int? createmid
{
set { _createmid = value; }
get { return _createmid; }
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set { _lastedid = value; }
get { return _lastedid; }
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set { _lastedittime = value; }
get { return _lastedittime; }
}
/// <summary>
///
/// </summary>
public int auditstatus
{
set { _auditstatus = value; }
get { return _auditstatus; }
}
/// <summary>
///
/// </summary>
public int linestatus
{
set { _linestatus = value; }
get { return _linestatus; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnShop.cs | C# | oos | 10,308 |
using System;
namespace TREC.Entity
{
/// <summary>
/// sys_action:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnMarketStorey
{
public EnMarketStorey()
{}
#region Model
private int _id;
private int _marketid;
private string _markettitle;
private string _title;
private string _number;
private string _surface;
private string _logo;
private string _thumb;
private string _bannel;
private string _desimage;
private string _descript;
private string _keywords;
private string _template;
private int? _hits;
private int? _sort;
private int? _lastedid=0;
private DateTime _lastedittime;
/// <summary>
///
/// </summary>
public int id
{
set{ _id=value;}
get{return _id;}
}
/// <summary>
///
/// </summary>
public int marketid
{
set{ _marketid=value;}
get{return _marketid;}
}
/// <summary>
///
/// </summary>
public string markettitle
{
set{ _markettitle=value;}
get{return _markettitle;}
}
/// <summary>
///
/// </summary>
public string title
{
set{ _title=value;}
get{return _title;}
}
/// <summary>
///
/// </summary>
public string number
{
set{ _number=value;}
get{return _number;}
}
/// <summary>
///
/// </summary>
public string surface
{
set{ _surface=value;}
get{return _surface;}
}
/// <summary>
///
/// </summary>
public string logo
{
set{ _logo=value;}
get{return _logo;}
}
/// <summary>
///
/// </summary>
public string thumb
{
set{ _thumb=value;}
get{return _thumb;}
}
/// <summary>
///
/// </summary>
public string bannel
{
set{ _bannel=value;}
get{return _bannel;}
}
/// <summary>
///
/// </summary>
public string desimage
{
set{ _desimage=value;}
get{return _desimage;}
}
/// <summary>
///
/// </summary>
public string descript
{
set{ _descript=value;}
get{return _descript;}
}
/// <summary>
///
/// </summary>
public string keywords
{
set{ _keywords=value;}
get{return _keywords;}
}
/// <summary>
///
/// </summary>
public string template
{
set{ _template=value;}
get{return _template;}
}
/// <summary>
///
/// </summary>
public int? hits
{
set{ _hits=value;}
get{return _hits;}
}
/// <summary>
///
/// </summary>
public int? sort
{
set{ _sort=value;}
get{return _sort;}
}
/// <summary>
///
/// </summary>
public int? lastedid
{
set{ _lastedid=value;}
get{return _lastedid;}
}
/// <summary>
///
/// </summary>
public DateTime lastedittime
{
set{ _lastedittime=value;}
get{return _lastedittime;}
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnMarketStorey.cs | C# | oos | 2,963 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace TREC.Entity
{
public class EnSearchItem : IEnumerable
{
public string type { get; set; }
public string title { get; set; }
public string value { get; set; }
public int count { get; set; }
public bool isCur { get; set; }
public IEnumerator GetEnumerator()
{
yield return new EnSearchItem();
}
}
public class EnSearchProductItem : IEnumerable
{
public string type { get; set; }
public string title { get; set; }
public string value { get; set; }
public string brandid { get; set; }
public string brandsid { get; set; }
public string pcategoryid { get; set; }
public int count { get; set; }
public bool isCur { get; set; }
public IEnumerator GetEnumerator()
{
yield return new EnSearchProductItem();
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnSearchItem.cs | C# | oos | 1,067 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnPromotionDef
{
public EnPromotionDef()
{}
#region Model
private int _id;
private string _title;
private int _pid;
private string _attribute;
private string _type;
private string _value;
private string _valueletter;
private string _valuetitle;
private string _thumb;
private string _banner;
private string _descript;
private string _curcountmoney;
private string _curcountpeople;
private string _curstage;
private string _fordio;
private int? _sort;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public int pid
{
set { _pid = value; }
get { return _pid; }
}
/// <summary>
///
/// </summary>
public string attribute
{
set { _attribute = value; }
get { return _attribute; }
}
/// <summary>
///
/// </summary>
public string type
{
set { _type = value; }
get { return _type; }
}
/// <summary>
///
/// </summary>
public string value
{
set { _value = value; }
get { return _value; }
}
/// <summary>
///
/// </summary>
public string valueletter
{
set { _valueletter = value; }
get { return _valueletter; }
}
/// <summary>
///
/// </summary>
public string valuetitle
{
set { _valuetitle = value; }
get { return _valuetitle; }
}
/// <summary>
///
/// </summary>
public string thumb
{
set { _thumb = value; }
get { return _thumb; }
}
/// <summary>
///
/// </summary>
public string banner
{
set { _banner = value; }
get { return _banner; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public string curcountmoney
{
set { _curcountmoney = value; }
get { return _curcountmoney; }
}
/// <summary>
///
/// </summary>
public string curcountpeople
{
set { _curcountpeople = value; }
get { return _curcountpeople; }
}
/// <summary>
///
/// </summary>
public string curstage
{
set { _curstage = value; }
get { return _curstage; }
}
/// <summary>
///
/// </summary>
public string fordio
{
set { _fordio = value; }
get { return _fordio; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnPromotionDef.cs | C# | oos | 3,903 |
using System;
namespace TREC.Entity
{
/// <summary>
/// sys_action:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnConfigType
{
public EnConfigType()
{}
#region Model
private int _id;
private string _title;
private string _mark;
private string _letter;
private string _type;
private int? _sort;
private int? _count;
private string _descript;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string mark
{
set { _mark = value; }
get { return _mark; }
}
/// <summary>
///
/// </summary>
public string letter
{
set { _letter = value; }
get { return _letter; }
}
/// <summary>
///
/// </summary>
public string type
{
set { _type = value; }
get { return _type; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
/// <summary>
///
/// </summary>
public int? count
{
set { _count = value; }
get { return _count; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnConfigType.cs | C# | oos | 2,031 |
using System;
namespace TREC.Entity
{
/// <summary>
/// admin:实体类(属性说明自动提取数据库字段的描述信息)
/// </summary>
[Serializable]
public partial class EnMarketGroup
{
public EnMarketGroup()
{}
#region Model
private int _id;
private string _title;
private string _color;
private string _avatar;
private decimal? _integral;
private decimal? _money;
private int? _adcount;
private int? _shopcount;
private int? _brandcount;
private int? _promotioncount;
private int? _storeycount;
private int? _storeyshopcount;
private int? _adrecommend;
private int? _shoprecommend;
private int? _brandrecommend;
private int? _promotionrecommend;
private int? _lev;
private string _permissions;
private string _descript;
private int? _sort;
/// <summary>
///
/// </summary>
public int id
{
set { _id = value; }
get { return _id; }
}
/// <summary>
///
/// </summary>
public string title
{
set { _title = value; }
get { return _title; }
}
/// <summary>
///
/// </summary>
public string color
{
set { _color = value; }
get { return _color; }
}
/// <summary>
///
/// </summary>
public string avatar
{
set { _avatar = value; }
get { return _avatar; }
}
/// <summary>
///
/// </summary>
public decimal? integral
{
set { _integral = value; }
get { return _integral; }
}
/// <summary>
///
/// </summary>
public decimal? money
{
set { _money = value; }
get { return _money; }
}
/// <summary>
///
/// </summary>
public int? adcount
{
set { _adcount = value; }
get { return _adcount; }
}
/// <summary>
///
/// </summary>
public int? shopcount
{
set { _shopcount = value; }
get { return _shopcount; }
}
/// <summary>
///
/// </summary>
public int? brandcount
{
set { _brandcount = value; }
get { return _brandcount; }
}
/// <summary>
///
/// </summary>
public int? promotioncount
{
set { _promotioncount = value; }
get { return _promotioncount; }
}
/// <summary>
///
/// </summary>
public int? storeycount
{
set { _storeycount = value; }
get { return _storeycount; }
}
/// <summary>
///
/// </summary>
public int? storeyshopcount
{
set { _storeyshopcount = value; }
get { return _storeyshopcount; }
}
/// <summary>
///
/// </summary>
public int? adrecommend
{
set { _adrecommend = value; }
get { return _adrecommend; }
}
/// <summary>
///
/// </summary>
public int? shoprecommend
{
set { _shoprecommend = value; }
get { return _shoprecommend; }
}
/// <summary>
///
/// </summary>
public int? brandrecommend
{
set { _brandrecommend = value; }
get { return _brandrecommend; }
}
/// <summary>
///
/// </summary>
public int? promotionrecommend
{
set { _promotionrecommend = value; }
get { return _promotionrecommend; }
}
/// <summary>
///
/// </summary>
public int? lev
{
set { _lev = value; }
get { return _lev; }
}
/// <summary>
///
/// </summary>
public string permissions
{
set { _permissions = value; }
get { return _permissions; }
}
/// <summary>
///
/// </summary>
public string descript
{
set { _descript = value; }
get { return _descript; }
}
/// <summary>
///
/// </summary>
public int? sort
{
set { _sort = value; }
get { return _sort; }
}
#endregion Model
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Entity/EnMarketGroup.cs | C# | oos | 4,924 |
.tip-yellowsimple {
z-index:1000;
text-align:left;
border:1px solid #c7bf93;
border-radius:4px;
-moz-border-radius:4px;
-webkit-border-radius:4px;
padding:6px 8px;
min-width:50px;
max-width:300px;
color:#000;
background-color:#fff9c9;
/**
* - If you set a background-image, border/padding/background-color will be ingnored.
* You can set any padding to .tip-inner instead if you need.
* - If you want a tiled background-image and border/padding for the tip,
* set the background-image to .tip-inner instead.
*/
}
.tip-yellowsimple .tip-inner {
font:12px/16px arial,helvetica,sans-serif;
}
/* Configure an arrow image - the script will automatically position it on the correct side of the tip */
.tip-yellowsimple .tip-arrow-top {
margin-top:-6px;
margin-left:-5px; /* approx. half the width to center it */
top:0;
left:50%;
width:9px;
height:6px;
background:url(tip-yellowsimple_arrows.gif) no-repeat;
}
.tip-yellowsimple .tip-arrow-right {
margin-top:-4px; /* approx. half the height to center it */
margin-left:0;
top:50%;
left:100%;
width:6px;
height:9px;
background:url(tip-yellowsimple_arrows.gif) no-repeat -9px 0;
}
.tip-yellowsimple .tip-arrow-bottom {
margin-top:0;
margin-left:-5px; /* approx. half the width to center it */
top:100%;
left:50%;
width:9px;
height:6px;
background:url(tip-yellowsimple_arrows.gif) no-repeat -18px 0;
}
.tip-yellowsimple .tip-arrow-left {
margin-top:-4px; /* approx. half the height to center it */
margin-left:-6px;
top:50%;
left:0;
width:6px;
height:9px;
background:url(tip-yellowsimple_arrows.gif) no-repeat -27px 0;
} | 10aaa-10aaa | trunk/TRECommerce/suppler/images/tip-yellowsimple.css | CSS | oos | 1,617 |
$(function () {
$(".msgtable tr:nth-child(odd)").addClass("tr_bg"); //隔行变色
$(".msgtable tr").hover(
function () {
$(this).addClass("tr_hover_col");
},
function () {
$(this).removeClass("tr_hover_col");
}
);
$("input[type='text'].input").focus(function () {
if (!$(this).hasClass("tcal")) {
$(this).addClass("focus");
}
}).blur(function () {
$(this).removeClass("focus");
});
});
//设置为自动高
function SetWinHeight(obj) {
var win = obj;
if (document.getElementById) {
if (win && !window.opera) {
if (win.contentDocument && win.contentDocument.body.offsetHeight)
win.height = win.contentDocument.body.offsetHeight + 100;
else if (win.Document && win.Document.body.scrollHeight)
win.height = win.Document.body.scrollHeight + 100;
}
}
}
//全选取消按钮函数,调用样式如:
function checkAll(chkobj) {
if ($(chkobj).text() == "全选") {
$(chkobj).text("取消");
$(".checkall").each(function () {
if ($(this).attr("disabled") != 'disabled') {
$(this).find("input").attr("checked", true);
}
});
} else {
$(chkobj).text("全选");
$(".checkall input").attr("checked", false);
}
}
//遮罩提示窗口
function jsmsg(w, h, msgtitle, msgbox, url, msgcss) {
$("#msgdialog").remove();
var cssname = "";
switch (msgcss) {
case "Success":
cssname = "icon-01";
break;
case "Error":
cssname = "icon-02";
break;
default:
cssname = "icon-03";
break;
}
var str = "<div id='msgdialog' title='" + msgtitle + "'><p class='" + cssname + "'>" + msgbox + "</p></div>";
$("body").append(str);
$("#msgdialog").dialog({
//title: null,
//show: null,
bgiframe: true,
autoOpen: false,
width: w,
//height: h,
resizable: false,
closeOnEscape: true,
buttons: { "确定": function () { $(this).dialog("close"); } },
modal: true
});
$("#msgdialog").dialog("open");
if (url == "back") {
mainFrame.history.back(-1);
} else if (url != "") {
mainFrame.location.href = url;
}
}
function jsmsgCurPage(w, h, msgtitle, msgbox, url, msgcss) {
$("#msgdialog").remove();
var cssname = "";
switch (msgcss) {
case "Success":
cssname = "icon-01";
break;
case "Error":
cssname = "icon-02";
break;
default:
cssname = "icon-03";
break;
}
var str = "<div id='msgdialog' title='" + msgtitle + "'><p class='" + cssname + "'>" + msgbox + "</p></div>";
$("body").append(str);
$("#msgdialog").dialog({
//title: null,
//show: null,
bgiframe: true,
autoOpen: false,
width: w,
height: h,
resizable: false,
closeOnEscape: true,
buttons: { "确定": function () { $(this).dialog("close"); } },
modal: true
});
$("#msgdialog").dialog("open");
}
//可以自动关闭的提示
function jsprint(msgtitle, url, msgcss) {
$("#msgprint").remove();
var cssname = "";
switch (msgcss) {
case "Success":
cssname = "pcent correct";
break;
case "Error":
cssname = "pcent disable";
break;
default:
cssname = "pcent warning";
break;
}
var str = "<div id=\"msgprint\" class=\"" + cssname + "\">" + msgtitle + "</div>";
$("body").append(str);
$("#msgprint").show();
if (url == "back") {
mainFrame.history.back(-1);
} else if (url != "") {
mainFrame.location.href = url;
}
//3秒后清除提示
setTimeout(function () {
$("#msgprint").fadeOut(500);
//如果动画结束则删除节点
if (!$("#msgprint").is(":animated")) {
$("#msgprint").remove();
}
}, 3000);
}
//可以自动关闭的提示
function jsprintCurPage(msgtitle, url, msgcss) {
$("#msgprint").remove();
var cssname = "";
switch (msgcss) {
case "Success":
cssname = "pcent correct";
break;
case "Error":
cssname = "pcent disable";
break;
default:
cssname = "pcent warning";
break;
}
var str = "<div id=\"msgprint\" class=\"" + cssname + "\">" + msgtitle + "</div>";
$("body").append(str);
$("#msgprint").show();
var outT = 900;
var outT2 = 3000;
if (url == "thickbox") {
outT = 500;
outT2 = 1500;
}
//3秒后清除提示
setTimeout(function () {
$("#msgprint").fadeOut(outT);
//如果动画结束则删除节点
if (!$("#msgprint").is(":animated")) {
$("#msgprint").remove();
}
if (url == "back") {
this.history.back(-1);
} else if (url == "#") {
return;
} else if (url == "thickbox") {
TB_iframeContent.location.href = $("#TB_iframeContent").attr("src");
} else if (url != "") {
this.location.href = url;
}
}, outT2);
}
function SetPermission() {
$("#SetPermission").remove();
var str = "<div id='SetPermission' style='width:100%; position:fixed; z-index:99999999; background:#000; left:0px; top:0px; bottom:0px; right:0px; display:none;'></div>";
$("body").append(str);
$("#SetPermission").css("display", "block").animate({ opacity: 0.1 });
} | 10aaa-10aaa | trunk/TRECommerce/suppler/script/supplercommon.js | JavaScript | oos | 5,880 |
/*
EASY TABS 1.2 Produced and Copyright by Koller Juergen
www.kollermedia.at | www.austria-media.at
Need Help? http:/www.kollermedia.at/archive/2007/07/10/easy-tabs-12-now-with-autochange
You can use this Script for private and commercial Projects, but just leave the two credit lines, thank you.
*/
//EASY TABS 1.2 - MENU SETTINGS
//Set the id names of your tablink (without a number at the end)
var tablink_idname = new Array("tablink")
//Set the id name of your tabcontentarea (without a number at the end)
var tabcontent_idname = new Array("tabcontent")
//Set the number of your tabs
var tabcount = new Array("4")
//Set the Tab wich should load at start (In this Example:Tab 2 visible on load)
var loadtabs = new Array("2")
//Set the Number of the Menu which should autochange (if you dont't want to have a change menu set it to 0)
var autochangemenu = 1;
//the speed in seconds when the tabs should change
var changespeed = 3;
//should the autochange stop if the user hover over a tab from the autochangemenu? 0=no 1=yes
var stoponhover = 0;
//END MENU SETTINGS
/*Swich EasyTabs Functions - no need to edit something here*/
function easytabs(menunr, active) { if (menunr == autochangemenu){currenttab=active;}if ((menunr == autochangemenu)&&(stoponhover==1)) {stop_autochange()} else if ((menunr == autochangemenu)&&(stoponhover==0)) {counter=0;}menunr = menunr-1;for (i=1; i <= tabcount[menunr]; i++){document.getElementById(tablink_idname[menunr]+i).className='tab'+i;document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';}document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';}var timer; counter=0; var totaltabs=tabcount[autochangemenu-1];var currenttab=loadtabs[autochangemenu-1];function start_autochange(){counter=counter+1;timer=setTimeout("start_autochange()",1000);if (counter == changespeed+1) {currenttab++;if (currenttab>totaltabs) {currenttab=1}easytabs(autochangemenu,currenttab);restart_autochange();}}function restart_autochange(){clearTimeout(timer);counter=0;start_autochange();}function stop_autochange(){clearTimeout(timer);counter=0;}
window.onload=function(){
var menucount=loadtabs.length; var a = 0; var b = 1; do {easytabs(b, loadtabs[a]); a++; b++;}while (b<=menucount);
if (autochangemenu!=0){start_autochange();}
} | 10aaa-10aaa | trunk/TRECommerce/suppler/script/easytabs.js | JavaScript | oos | 2,427 |
/*
[Destoon B2B System] Copyright (c) 2008-2011 Destoon.COM
This is NOT a freeware, use is subject to license.txt
*/
.mainInfoTable td{ text-align:left; vertical-align:top}
.i_info {border-bottom:#9CB8CC 1px solid;padding:0 0 10px 10px;}
.i_info li {padding:7px 0 7px 0;}
.i_quick li {width:19%;float:left;text-align:center;padding:20px 0 10px 0;}
.i_quick a {display:block;width:100%;height:100%;}
.i_quick img {margin:0 0 8px 0;}
.i_note {padding:5px;}
.i_note textarea {border:#9CB8CC 1px solid;padding:3px;width:98%;height:80px;word-break:break-all;color:#444444;}
.i_find {margin:10px 0 0 0;background:#F6F9FC;}
.i_find div {padding:3px 8px 3px 10px;background:url('../images/menu_bg.gif') repeat-x;border-bottom:#E4EDF4 1px solid;}
.i_find li {height:22px;line-height:22px;overflow:hidden;padding:0 5px 0 10px;background:url('../images/li_dot.gif') no-repeat 5px 9px;}
.i_head {border:#6C92AD 1px solid;background:url('../images/ihead_bg.gif') repeat-x;height:24px;line-height:24px;padding:0 10px 0 10px;}
.i_body {border:#6C92AD 1px solid;border-top:none;background:#FFFFFF;margin:0 0 10px 0;}
.i_rt {width:300px;background:#E4EDF4;padding:8px;}
.i_sys {padding:5px 5px 5px 8px;}
.i_sys li {height:26px;line-height:26px;overflow:hidden;padding:0 5px 0 15px;background:url('../images/message_sys.gif') no-repeat 0 5px;}
.i_user td {border-bottom:#E4EDF4 1px solid;}
.i_user_l {width:60px;padding:6px 6px 6px 10px;border-right:#E4EDF4 1px solid;color:#005599;}
.lay{top:0px; left:0px; right:0px; bottom:0px; position:fixed; z-index:20000; background:#282828; width:100%; height:100%;}
.diBox{ width:811px; height:537px; position:fixed; z-index:20001; top:50%; left:50%; margin:-280px 0px 0px -410px; background:url('../images/f_d_bg.jpg') no-repeat;}
.diTop{height:83px; width:100%; float:left;}
.diTop ul{margin-left:5px;}
.diTop ul li{float:left; width:134px; height:68px; text-align:center; margin:7px 0px 7px 0px;}
.diTop ul li.cur{background:url('../images/f_d_topbg.jpg') no-repeat;}
.diTop ul li a{color:#00415f; font-weight:bold; padding-top:25px; display:block; }
.diTop ul li.cur a{color:#a1e3ff; font-weight:bold;}
.diTop ul li span{display:block; float:left; text-align:center; line-height:20px; width:100%; color:#fff; font-weight:bold;}
.diTop ul li span.t{color:#9dd0a0}
.diTop ul li span.e{color:#f50}
.diTitle{float:left; width:100%; height:27px; text-align:center; color:#f1f9ff; font-weight:bold; line-height:29px;}
.diFrame{background:url('../images/f_f_bg.jpg') no-repeat; width:100%; height:371px; float:left; padding-top:11px; padding-bottom:10px;}
.diFoot{color:#33a7ed; line-height:27px; text-align:center;}
.diFoot span.w{padding:0px 5px; color:#fff;}
.dicFrame{background:none;}
.dicFrame .FrameCon{margin:0px auto 0px auto; height:360px; width:763px; background:none;}
.FrameCon ul.main li{margin:50px 10px 0px 60px;height:269px; width:169px; cursor:pointer;}
.FrameCon ul.main li:hover{cursor:pointer;}
.FrameCon ul.main li a{ display:block; height:269px; width:169px; text-decoration:none;}
.FrameCon ul.main li.f a{ background:url('../images/1-2.jpg') no-repeat;}
.FrameCon ul.main li.f a.cur,.FrameCon ul.main li.f a:hover,.FrameCon ul.main li:hover{ background:url('../images/1-1.jpg') no-repeat;}
.FrameCon ul.main li.t a{ background:url('../images/2-2.jpg') no-repeat;}
.FrameCon ul.main li.t a.cur,.FrameCon ul.main li.t a:hover{ background:url('../images/2-1.jpg') no-repeat;}
.FrameCon ul.main li.s a{ background:url('../images/3-2.jpg') no-repeat;}
.FrameCon ul.main li.s a.cur,.FrameCon ul.main li.s a:hover{ background:url('../images/3-1.jpg') no-repeat;}
.FrameCon ul.main li a span{ text-decoration:none; display:block; float:left; margin:0px auto; }
.FrameCon ul.main li a span.t{ margin-top:120px; color:#0280b5; font-weight:bold; font-size:14px; width:100%; text-align:center;}
.FrameCon ul.main li a span.c{ font-size:12px; color:#656565; padding:15px;}
.FrameCon ul.main li a.cur span.t,.FrameCon ul.main li a:hover span.t{color:#d11414;}
.FrameCon table.firsForm{width:60%; margin:30px auto 0px auto; position:relative; background:none; }
.FrameCon table.firsForm tr td{color:#5b5b5b; height:30px; line-height:30px; text-align:left; font-size:12px; background:none;}
.FrameCon table.firsForm tr td input,.FrameCon table.firsForm tr td label,.FrameCon table.firsForm tr td textarea,.FrameCon table.firsForm tr td select{margin:0px 3px;}
.FrameCon table.firsForm tr td input.text{width:250px; line-height:20px; height:20px; border:1px solid #abadb3; font-size:12px; background:#fff;}
.FrameCon table.firsForm tr td input.text_focus{width:250px; line-height:20px; height:20px; border:1px solid #017cb6;background:#fff;} | 10aaa-10aaa | trunk/TRECommerce/suppler/css/index.css | CSS | oos | 4,759 |
/*
[Destoon B2B System] Copyright (c) 2008-2011 Destoon.COM
This is NOT a freeware, use is subject to license.txt
*/
.message_head {background:#EFF5FB;border-bottom:#AAC1DE 1px solid;padding:10px 30px 10px 30px;line-height:22px;color:#666666;}
.message_head strong {font-size:14px;color:#000000;}
.message_head span {color:#798699;padding:0 5px 0 2px;}
.message_body {background:#FFFFFF;font-size:14px;line-height:200%;padding:10px 30px 10px 30px;}
.message_body a:link,.message_body a:visited,.message_body a:active {color:#1E5494;text-decoration:underline;}
.message_body a:hover {color:#FF6600;text-decoration:none;}
.message_foot {background:#EFF5FB;border-top:#AAC1DE 1px solid;border-bottom:#AAC1DE 1px solid;padding:10px 30px 10px 30px;} | 10aaa-10aaa | trunk/TRECommerce/suppler/css/message.css | CSS | oos | 756 |
/*
Stylesheet for Tigra Calendar v5.0
Product is Public Domain (Free for any kind of applicaiton, customization and derivative works are allowed)
URL: http://www.softcomplex.com/products/tigra_calendar/
- all image paths are relative to path of stylesheet
- the styles below can be moved into the document or in existing stylesheet
*/
/* input box in default state */
.tcalInput {
background: url('../images/cal.gif') 100% 50% no-repeat;
padding-right: 20px;
cursor: pointer;
}
/* additional properties for input boxe in activated state, above still applies unless in conflict */
.tcalActive {
background-image: url('../images/no_cal.gif');
}
/* container of calendar's pop-up */
#tcal {
position: absolute;
visibility: hidden;
z-index: 100;
width: 170px;
background-color: white;
margin-top: 2px;
padding: 0 2px 2px 2px;
border: 1px solid silver;
-moz-box-shadow: 3px 3px 4px silver;
-webkit-box-shadow: 3px 3px 4px silver;
box-shadow: 3px 3px 4px silver;
-ms-filter: "progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='silver')";
filter: progid:DXImageTransform.Microsoft.Shadow(Strength=4, Direction=135, Color='silver');
}
/* table containing navigation and current month */
#tcalControls {
border-collapse: collapse;
border: 0;
width: 100%;
}
#tcalControls td {
border-collapse: collapse;
border: 0;
padding: 0;
width: 16px;
background-position: 50% 50%;
background-repeat: no-repeat;
cursor: pointer;
}
#tcalControls th {
border-collapse: collapse;
border: 0;
padding: 0;
line-height: 25px;
font-size: 10px;
text-align: center;
font-family: Tahoma, Geneva, sans-serif;
font-weight: bold;
white-space: nowrap;
}
#tcalPrevYear { background-image: url('../images/prev_year.gif'); }
#tcalPrevMonth { background-image: url('../images/prev_mon.gif'); }
#tcalNextMonth { background-image: url('../images/next_mon.gif'); }
#tcalNextYear { background-image: url('../images/next_year.gif'); }
/* table containing week days header and calendar grid */
#tcalGrid {
border-collapse: collapse;
border: 1px solid silver;
width: 100%;
}
#tcalGrid th {
border: 1px solid silver;
border-collapse: collapse;
padding: 3px 0;
text-align: center;
font-family: Tahoma, Geneva, sans-serif;
font-size: 10px;
background-color: gray;
color: white;
height:14px;
color:#000;
}
#tcalGrid td {
border: 0;
border-collapse: collapse;
padding: 2px 0;
text-align: center;
font-family: Tahoma, Geneva, sans-serif;
width: 14%;
font-size: 11px;
cursor: pointer;
}
#tcalGrid td.tcalOtherMonth { color: silver; }
#tcalGrid td.tcalWeekend { background-color: #ACD6F5; }
#tcalGrid td.tcalToday { border: 1px solid red; }
#tcalGrid td.tcalSelected { background-color: #FFB3BE; }
| 10aaa-10aaa | trunk/TRECommerce/suppler/css/tcal.css | CSS | oos | 2,843 |
._jsfileupload{ display:block; float:left; width:450px;}
._fileTools{display:block; float:left;width:450px; margin:0px 0px 5px 0px;}
._fileTools input{height:18px; line-height:18px;}
/*路径显示控件*/
._fileTools ._fileValue{float:left;}
._fileTools .w380{width:250px;}
/*file容器样式*/
._jsfileupload a.files {margin:0 auto;float:left; width:64px;height:18px;overflow:hidden;display:block;border:1px solid #70b1cf;text-decoration:none; background:url(../images/upfilebg.gif) left top no-repeat;}
/*file设为透明,并覆盖整个触发面*/
._jsfileupload a.files input {margin-left:-240px;font-size:20px;cursor:pointer;filter:alpha(opacity=0);opacity:0;}
/*取消点击时的虚线框*/
._jsfileupload a.files,._jsfileuploada.files input{outline:none;/*ff*/hide-focus:expression(this.hideFocus=true);/*ie*/}
/*上传文件时切换图片*/
.filesbg2{background:url(../images/upfilebg2.gif) left top no-repeat!important;}
._jsfileupload .uploading{float:left;background:url(../images/loading.gif) no-repeat left center;padding-left:18px;display:none;line-height:20px;height:20px;}
._jsfileupload input.filelistinput{display:none;}
._filepreview,._filedel{display:block; float:left; padding:4px;} | 10aaa-10aaa | trunk/TRECommerce/suppler/css/fileupload.css | CSS | oos | 1,233 |
using System;
using System.Collections.Generic;
using System.Text;
namespace TREC.Config
{
/// <summary>
/// 配置信息类接口
/// </summary>
public interface IConfigInfo
{
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Config/IConfigInfo.cs | C# | oos | 222 |
using System;
using System.Collections.Generic;
using System.Text;
namespace TREC.Config
{
/// <summary>
/// 网站信息配置类
/// </summary>
public class WebConfigs
{
private static System.Timers.Timer baseConfigTimer = new System.Timers.Timer(60000);
private static WebInfo m_configinfo;
/// <summary>
/// 静态构造函数初始化相应实例和定时器
/// </summary>
static WebConfigs()
{
m_configinfo = WebFileManager.LoadConfig();
baseConfigTimer.AutoReset = true;
baseConfigTimer.Enabled = true;
baseConfigTimer.Elapsed += new System.Timers.ElapsedEventHandler(Timer_Elapsed);
baseConfigTimer.Start();
}
private static void Timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
ResetConfig();
}
/// <summary>
/// 重设配置类实例
/// </summary>
public static void ResetConfig()
{
m_configinfo = WebFileManager.LoadConfig();
}
/// <summary>
/// 获取配置类实例
/// </summary>
/// <returns></returns>
public static WebInfo GetConfig()
{
return WebFileManager.LoadConfig();
}
/// <summary>
/// 保存配置类实例
/// </summary>
/// <param name="WebConfigInfo"></param>
/// <returns></returns>
public static bool SaveConfig(WebInfo webconfiginfo)
{
WebFileManager ecfm = new WebFileManager();
WebFileManager.ConfigInfo = webconfiginfo;
return ecfm.SaveConfig();
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Config/WebConfigs.cs | C# | oos | 1,799 |
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using TRECommon;
namespace TREC.Config
{
/// <summary>
/// 文件配置管理基类
/// </summary>
public class DefaultConfigFileManager
{
/// <summary>
/// 文件所在路径变量
/// </summary>
private static string m_configfilepath;
/// <summary>
/// 临时配置对象变量
/// </summary>
private static IConfigInfo m_configinfo = null;
/// <summary>
/// 锁对象
/// </summary>
private static object m_lockHelper = new object();
/// <summary>
/// 文件所在路径
/// </summary>
public static string ConfigFilePath
{
get { return m_configfilepath; }
set { m_configfilepath = value; }
}
/// <summary>
/// 临时配置对象
/// </summary>
public static IConfigInfo ConfigInfo
{
get { return m_configinfo; }
set { m_configinfo = value; }
}
/// <summary>
/// 加载(反序列化)指定对象类型的配置对象
/// </summary>
/// <param name="fileoldchange">文件加载时间</param>
/// <param name="configFilePath">配置文件所在路径</param>
/// <param name="configinfo">相应的变量 注:该参数主要用于设置m_configinfo变量 和 获取类型.GetType()</param>
/// <returns></returns>
protected static IConfigInfo LoadConfig(ref DateTime fileoldchange, string configFilePath, IConfigInfo configinfo)
{
return LoadConfig(ref fileoldchange, configFilePath, configinfo, true);
}
/// <summary>
/// 加载(反序列化)指定对象类型的配置对象
/// </summary>
/// <param name="fileoldchange">文件加载时间</param>
/// <param name="configFilePath">配置文件所在路径(包括文件名)</param>
/// <param name="configinfo">相应的变量 注:该参数主要用于设置m_configinfo变量 和 获取类型.GetType()</param>
/// <param name="checkTime">是否检查并更新传递进来的"文件加载时间"变量</param>
/// <returns></returns>
protected static IConfigInfo LoadConfig(ref DateTime fileoldchange, string configFilePath, IConfigInfo configinfo, bool checkTime)
{
lock (m_lockHelper)
{
m_configfilepath = configFilePath;
m_configinfo = configinfo;
if (checkTime)
{
DateTime m_filenewchange = System.IO.File.GetLastWriteTime(configFilePath);
//当程序运行中config文件发生变化时则对config重新赋值
if (fileoldchange != m_filenewchange)
{
fileoldchange = m_filenewchange;
m_configinfo = DeserializeInfo(configFilePath, configinfo.GetType());
}
}
else
m_configinfo = DeserializeInfo(configFilePath, configinfo.GetType());
return m_configinfo;
}
}
/// <summary>
/// 反序列化指定的类
/// </summary>
/// <param name="configfilepath">config 文件的路径</param>
/// <param name="configtype">相应的类型</param>
/// <returns></returns>
public static IConfigInfo DeserializeInfo(string configfilepath, Type configtype)
{
return (IConfigInfo)SerializationHelper.Load(configtype, configfilepath);
}
/// <summary>
/// 保存配置实例(虚方法需继承)
/// </summary>
/// <returns></returns>
public virtual bool SaveConfig()
{
return true;
}
/// <summary>
/// 保存(序列化)指定路径下的配置文件
/// </summary>
/// <param name="configFilePath">指定的配置文件所在的路径(包括文件名)</param>
/// <param name="configinfo">被保存(序列化)的对象</param>
/// <returns></returns>
public bool SaveConfig(string configFilePath, IConfigInfo configinfo)
{
return SerializationHelper.Save(configinfo, configFilePath);
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Config/DefaultConfigFileManager.cs | C# | oos | 4,559 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("TREC.Config")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("FORDIO")]
[assembly: AssemblyProduct("TREC.Config")]
[assembly: AssemblyCopyright("Copyright © FORDIO 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("1f8eb6f2-179d-44d6-bd28-716060748b3b")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 10aaa-10aaa | trunk/TRECommerce/TREC.Config/Properties/AssemblyInfo.cs | C# | oos | 1,366 |
using System;
using System.Collections.Generic;
using System.Text;
namespace TREC.Config
{
public interface IConfigFileManager
{
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Config/IConfigFileManager.cs | C# | oos | 159 |
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.IO;
using TRECommon;
namespace TREC.Config
{
/// <summary>
/// 网站信息管理
/// </summary>
class WebFileManager:DefaultConfigFileManager
{
/// <summary>
/// 对象
/// </summary>
private static WebInfo m_configinfo;
/// <summary>
/// 文件修改时间
/// </summary>
private static DateTime m_fileoldchange;
/// <summary>
/// 锁对象
/// </summary>
private static object m_lockHelper = new object();
/// <summary>
/// 初始化文件修改时间和对象实例
/// </summary>
static WebFileManager()
{
m_fileoldchange = System.IO.File.GetLastWriteTime(ConfigFilePath);
m_configinfo = (WebInfo)DefaultConfigFileManager.DeserializeInfo(ConfigFilePath, typeof(WebInfo));
}
/// <summary>
/// 当前的配置实例
/// </summary>
public new static IConfigInfo ConfigInfo
{
get { return m_configinfo; }
set { m_configinfo = (WebInfo)value; }
}
/// <summary>
/// 配置文件所在路径
/// </summary>
public static string filename = null;
/// <summary>
/// 获取配置文件所在路径
/// </summary>
public new static string ConfigFilePath
{
get
{
if (filename == null)
{
HttpContext context = HttpContext.Current;
if (context != null)
{
filename = context.Server.MapPath("~/config/webinfo.config");
if (!File.Exists(filename))
{
filename = context.Server.MapPath("/config/webinfo.config");
}
}
else
{
filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "config/webinfo.config");
}
if (!File.Exists(filename))
{
throw new Exception("发生错误: 虚拟目录或网站../config/下没有正确的webinfo.config文件");
}
}
return filename;
}
}
/// <summary>
/// 返回配置类实例
/// </summary>
/// <returns></returns>
public static WebInfo LoadConfig()
{
ConfigInfo = DefaultConfigFileManager.LoadConfig(ref m_fileoldchange, ConfigFilePath, ConfigInfo);
return ConfigInfo as WebInfo;
}
/// <summary>
/// 保存配置类实例
/// </summary>
/// <returns></returns>
public override bool SaveConfig()
{
return base.SaveConfig(ConfigFilePath, ConfigInfo);
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Config/WebFileManager.cs | C# | oos | 3,170 |
using System;
using System.Collections.Generic;
using System.Text;
namespace TREC.Config
{
[Serializable]
public class WebInfo : IConfigInfo
{
private string _webname = "";
private string _weburl = "";
private string _webtel = "";
private string _webfax = "";
private string _webemail = "";
private string _webcrod = "";
private string _webkeywords = "";
private string _webdescription = "";
private string _webcopyright = "";
private string _templateskin = "default";
/// <summary>
/// 网站名称
/// </summary>
public string WebName
{
set { _webname = value; }
get { return _webname; }
}
/// <summary>
/// 网站地址
/// </summary>
public string WebUrl
{
set { _weburl = value; }
get { return _weburl; }
}
/// <summary>
/// 联系电话
/// </summary>
public string WebTel
{
set { _webtel = value; }
get { return _webtel; }
}
/// <summary>
/// 传真地址
/// </summary>
public string WebFax
{
set { _webfax = value; }
get { return _webfax; }
}
/// <summary>
/// 联系邮箱
/// </summary>
public string WebEmail
{
set { _webemail = value; }
get { return _webemail; }
}
/// <summary>
/// ICP备案
/// </summary>
public string WebCrod
{
set { _webcrod = value; }
get { return _webcrod; }
}
/// <summary>
/// 网站关健字
/// </summary>
public string WebKeywords
{
set { _webkeywords = value; }
get { return _webkeywords; }
}
/// <summary>
/// 网站描述
/// </summary>
public string WebDescription
{
set { _webdescription = value; }
get { return _webdescription; }
}
/// <summary>
/// 公司版权
/// </summary>
public string WebCopyright
{
set { _webcopyright = value; }
get { return _webcopyright; }
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TREC.Config/WebInfo.cs | C# | oos | 2,507 |
using System.Web;
namespace TRECommon
{
public static class SessionHelper
{
/// <summary>
/// 添加Session,调动有效期为20分钟
/// </summary>
/// <param name="strSessionName">Session对象名称</param>
/// <param name="strValue">Session值</param>
public static void Add(string strSessionName, string strValue)
{
HttpContext.Current.Session[strSessionName] = strValue;
HttpContext.Current.Session.Timeout = 20;
}
/// <summary>
/// 添加Session,调动有效期为20分钟
/// </summary>
/// <param name="strSessionName">Session对象名称</param>
/// <param name="strValues">Session值数组</param>
public static void Adds(string strSessionName, string[] strValues)
{
HttpContext.Current.Session[strSessionName] = strValues;
HttpContext.Current.Session.Timeout = 20;
}
/// <summary>
/// 添加Session
/// </summary>
/// <param name="strSessionName">Session对象名称</param>
/// <param name="strValue">Session值</param>
/// <param name="iExpires">调动有效期(分钟)</param>
public static void Add(string strSessionName, string strValue, int iExpires)
{
HttpContext.Current.Session[strSessionName] = strValue;
HttpContext.Current.Session.Timeout = iExpires;
}
/// <summary>
/// 添加Session
/// </summary>
/// <param name="strSessionName">Session对象名称</param>
/// <param name="strValues">Session值数组</param>
/// <param name="iExpires">调动有效期(分钟)</param>
public static void Adds(string strSessionName, string[] strValues, int iExpires)
{
HttpContext.Current.Session[strSessionName] = strValues;
HttpContext.Current.Session.Timeout = iExpires;
}
/// <summary>
/// 读取某个Session对象值
/// </summary>
/// <param name="strSessionName">Session对象名称</param>
/// <returns>Session对象值</returns>
public static string Get(string strSessionName)
{
if (HttpContext.Current.Session[strSessionName] == null)
{
return "";
}
else
{
return HttpContext.Current.Session[strSessionName].ToString();
}
}
/// <summary>
/// 读取某个Session对象值数组
/// </summary>
/// <param name="strSessionName">Session对象名称</param>
/// <returns>Session对象值数组</returns>
public static string[] Gets(string strSessionName)
{
if (HttpContext.Current.Session[strSessionName] == null)
{
return null;
}
else
{
return (string[])HttpContext.Current.Session[strSessionName];
}
}
/// <summary>
/// 删除某个Session对象
/// </summary>
/// <param name="strSessionName">Session对象名称</param>
public static void Del(string strSessionName)
{
HttpContext.Current.Session[strSessionName] = null;
}
}
} | 10aaa-10aaa | trunk/TRECommerce/TRECommon/Cookies&Session/SessionManager.cs | C# | oos | 3,450 |
//======================================================================
// 组织名: Troopsen
// 命名空间名称: WebObject
// 文件名: SessionCookies
// 创建人: Troopsen
// 创建时间: 2011/3/29 13:48:16
//======================================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace TRECommon
{
public class CookiesHelper
{
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
public static void WriteCookie(string strName, string strValue)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))];
if (cookie == null)
{
cookie = new HttpCookie(System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312")));
}
cookie.Value = System.Web.HttpUtility.UrlEncode(strValue, Encoding.GetEncoding("GB2312"));
HttpContext.Current.Response.AppendCookie(cookie);
}
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
public static void WriteCookie(string strName, string key, string strValue)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))];
if (cookie == null)
{
cookie = new HttpCookie(System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312")));
}
cookie[key] = System.Web.HttpUtility.UrlEncode(strValue, Encoding.GetEncoding("GB2312"));
HttpContext.Current.Response.AppendCookie(cookie);
}
/// <summary>
/// 写cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <param name="strValue">值</param>
/// <param name="strValue">过期时间(分钟)</param>
public static void WriteCookie(string strName, string strValue, int expires)
{
HttpCookie cookie = HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))];
if (cookie == null)
{
cookie = new HttpCookie(System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312")));
}
cookie.Value = System.Web.HttpUtility.UrlEncode(strValue, Encoding.GetEncoding("GB2312"));
cookie.Expires = DateTime.Now.AddMinutes(expires);
HttpContext.Current.Response.AppendCookie(cookie);
}
/// <summary>
/// 读cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <returns>cookie值</returns>
public static string GetCookie(string strName)
{
if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))] != null)
return System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))].Value.ToString(), Encoding.GetEncoding("GB2312"));
return "";
}
/// <summary>
/// 读cookie值
/// </summary>
/// <param name="strName">名称</param>
/// <returns>cookie值</returns>
public static string GetCookie(string strName, string key)
{
if (HttpContext.Current.Request.Cookies != null && HttpContext.Current.Request.Cookies[strName] != null && HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))][key] != null)
return System.Web.HttpUtility.UrlDecode(HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))][key].ToString(), Encoding.GetEncoding("GB2312"));
return "";
}
/// <summary>
/// 设置Cookie 过期
/// </summary>
/// <param name="strName"></param>
public static void DelCookie(string strName)
{
if (GetCookie(strName) != "")
{
HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))].Expires.AddDays(-1);
}
}
/// <summary>
/// 设置Cookie 过期
/// </summary>
/// <param name="strName"></param>
public static void DelCookie(string strName,string key)
{
if (GetCookie(System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))) != "")
{
HttpContext.Current.Request.Cookies[System.Web.HttpUtility.UrlEncode(strName, Encoding.GetEncoding("GB2312"))].Expires.AddDays(-1);
}
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Cookies&Session/CookiesManager.cs | C# | oos | 5,251 |
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Web;
using TRECommon;
namespace TRECommon.Plugin
{
//前台方法
//1.新建文件 XXXX.aspx 删除代码文件 只留 .aspx文件
//1-2. 将xxx.aspx 文件 codebind 到 TRECommon.Plugin.ImageVerify
// eg:<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="imageVerify.aspx.cs" Inherits="TRECommon.Plugin.ImageVerify" %>
//2.<asp:image ID="Image1" runat="server" ImageUrl="~/tools/xxx.aspx?model="></asp:image> //model为session键值。防止多页面同时验证。覆盖问题
public class ImageVerify : System.Web.UI.Page
{
override protected void OnInit(EventArgs e)
{
base.OnInit(e);
string t = Request.QueryString["t"] == null ? "1" : Request.QueryString["t"];
int w = Request.QueryString["w"] == null ? 15 : TRECommon.TypeConverter.StrToInt(Request.QueryString["w"]);
int h = Request.QueryString["h"] == null ? 20 : TRECommon.TypeConverter.StrToInt(Request.QueryString["h"]);
int l = Request.QueryString["l"] == null ? 4 : TRECommon.TypeConverter.StrToInt(Request.QueryString["l"]);
string model = Request.QueryString["model"] == null ? "" : Request.QueryString["model"];
string tempCode = "";
switch (t)
{
case "1":
tempCode=WebUtils.GetNumVerify(l);
break;
case "2":
tempCode=WebUtils.GetRandomNumVerify(l);
break;
case "3":
tempCode=WebUtils.GetRandomNumAndLetterVerify(l);
break;
case "4":
tempCode=WebUtils.GetRandomRegionVerifyByLength(l);
break;
default:
tempCode = WebUtils.GetNumVerify(l);
break;
}
CreateVerifyImage(tempCode, w, h);
SessionHelper.Add("_session_" + model, tempCode, 1);
}
private void CreateVerifyImage(string checkCode,int width,int height)
{
if (checkCode == null || checkCode.Trim() == String.Empty)
return;
int iWordWidth = 15;
int iImageWidth = checkCode.Length * iWordWidth;
Bitmap image = new Bitmap(iImageWidth, 20);
Graphics g = Graphics.FromImage(image);
try
{
//生成随机生成器
Random random = new Random();
//清空图片背景色
g.Clear(Color.White);
//画图片的背景噪音点
for (int i = 0; i < 20; i++)
{
int x1 = random.Next(image.Width);
int x2 = random.Next(image.Width);
int y1 = random.Next(image.Height);
int y2 = random.Next(image.Height);
g.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);
}
//画图片的背景噪音线
for (int i = 0; i < 2; i++)
{
int x1 = 0;
int x2 = image.Width;
int y1 = random.Next(image.Height);
int y2 = random.Next(image.Height);
if (i == 0)
{
g.DrawLine(new Pen(Color.Gray, 2), x1, y1, x2, y2);
}
}
for (int i = 0; i < checkCode.Length; i++)
{
string Code = checkCode[i].ToString();
int xLeft = iWordWidth * (i);
random = new Random(xLeft);
int iSeed = DateTime.Now.Millisecond;
int iValue = random.Next(iSeed) % 4;
if (iValue == 0)
{
Font font = new Font("Arial", 13, (FontStyle.Bold | System.Drawing.FontStyle.Italic));
Rectangle rc = new Rectangle(xLeft, 0, iWordWidth, image.Height);
LinearGradientBrush brush = new LinearGradientBrush(rc, Color.Blue, Color.Red, 1.5f, true);
g.DrawString(Code, font, brush, xLeft, 2);
}
else if (iValue == 1)
{
Font font = new System.Drawing.Font("楷体", 13, (FontStyle.Bold));
Rectangle rc = new Rectangle(xLeft, 0, iWordWidth, image.Height);
LinearGradientBrush brush = new LinearGradientBrush(rc, Color.Blue, Color.DarkRed, 1.3f, true);
g.DrawString(Code, font, brush, xLeft, 2);
}
else if (iValue == 2)
{
Font font = new System.Drawing.Font("宋体", 13, (System.Drawing.FontStyle.Bold));
Rectangle rc = new Rectangle(xLeft, 0, iWordWidth, image.Height);
LinearGradientBrush brush = new LinearGradientBrush(rc, Color.Green, Color.Blue, 1.2f, true);
g.DrawString(Code, font, brush, xLeft, 2);
}
else if (iValue == 3)
{
Font font = new System.Drawing.Font("黑体", 13, (System.Drawing.FontStyle.Bold | System.Drawing.FontStyle.Bold));
Rectangle rc = new Rectangle(xLeft, 0, iWordWidth, image.Height);
LinearGradientBrush brush = new LinearGradientBrush(rc, Color.Blue, Color.Green, 1.8f, true);
g.DrawString(Code, font, brush, xLeft, 2);
}
}
////画图片的前景噪音点
for (int i = 0; i < 8; i++)
{
int x = random.Next(image.Width);
int y = random.Next(image.Height);
image.SetPixel(x, y, Color.FromArgb(random.Next()));
}
//画图片的边框线
g.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
System.IO.MemoryStream ms = new System.IO.MemoryStream();
image.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
this.Page.Response.ClearContent();
Response.BinaryWrite(ms.ToArray());
}
finally
{
g.Dispose();
image.Dispose();
}
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Plugin/ImageVerify.cs | C# | oos | 6,884 |
using System;
using System.Data;
using System.Configuration;
using System.Xml;
namespace TRECommon
{
/// <summary>
/// XmlHelper 的摘要说明
/// </summary>
public class XmlHelper
{
public XmlHelper()
{}
/// <summary>
/// 读取数据
/// </summary>
/// <param name="path">路径</param>
/// <param name="node">节点</param>
/// <param name="attribute">属性名,非空时返回该属性值,否则返回串联值</param>
/// <returns>string</returns>
/**************************************************
* 使用示列:
* XmlHelper.Read(path, "/Node", "")
* XmlHelper.Read(path, "/Node/Element[@Attribute='Name']", "Attribute")
************************************************/
public static string Read(string path, string node, string attribute)
{
string value = "";
try
{
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode xn = doc.SelectSingleNode(node);
value = (attribute.Equals("") ? xn.InnerText : xn.Attributes[attribute].Value);
}
catch { }
return value;
}
public static DataTable GetNodeList(string path,string nodelName)
{
DataTable dt = new DataTable();
//DataColumn column = new System.Data.DataColumn();
//try
//{
// XmlDocument doc = new XmlDocument();
// doc.Load(path);
// XmlNodeList xn = doc.GetElementsByTagName(nodelName);
// foreach (XmlNode model in xn)
// {
// column.ColumnName = "xmlName";
// column.DefaultValue = model.Name;
// for (int i = 0; i < model.Attributes.Count; i++)
// {
// DataColumn attcolumn = new System.Data.DataColumn();
// attcolumn.ColumnName = "xmlAttr" + model.Attributes[i].Name;
// attcolumn.DefaultValue=""
// }
// }
//}
//catch { }
return dt;
}
public static DataTable XmlToDataTable(string path)
{
DataSet ds = new System.Data.DataSet();
ds.ReadXml(path);
return ds.Tables.Count >0 ? ds.Tables[0] : new DataTable();
}
/// <summary>
/// 插入数据
/// </summary>
/// <param name="path">路径</param>
/// <param name="node">节点</param>
/// <param name="element">元素名,非空时插入新元素,否则在该元素中插入属性</param>
/// <param name="attribute">属性名,非空时插入该元素属性值,否则插入元素值</param>
/// <param name="value">值</param>
/// <returns></returns>
/**************************************************
* 使用示列:
* XmlHelper.Insert(path, "/Node", "Element", "", "Value")
* XmlHelper.Insert(path, "/Node", "Element", "Attribute", "Value")
* XmlHelper.Insert(path, "/Node", "", "Attribute", "Value")
************************************************/
public static void Insert(string path, string node, string element, string attribute, string value)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode xn = doc.SelectSingleNode(node);
if (element.Equals(""))
{
if (!attribute.Equals(""))
{
XmlElement xe = (XmlElement)xn;
xe.SetAttribute(attribute, value);
}
}
else
{
XmlElement xe = doc.CreateElement(element);
if (attribute.Equals(""))
xe.InnerText = value;
else
xe.SetAttribute(attribute, value);
xn.AppendChild(xe);
}
doc.Save(path);
}
catch { }
}
/// <summary>
/// 修改数据
/// </summary>
/// <param name="path">路径</param>
/// <param name="node">节点</param>
/// <param name="attribute">属性名,非空时修改该节点属性值,否则修改节点值</param>
/// <param name="value">值</param>
/// <returns></returns>
/**************************************************
* 使用示列:
* XmlHelper.Insert(path, "/Node", "", "Value")
* XmlHelper.Insert(path, "/Node", "Attribute", "Value")
************************************************/
public static void Update(string path, string node, string attribute, string value)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode xn = doc.SelectSingleNode(node);
XmlElement xe = (XmlElement)xn;
if (attribute.Equals(""))
xe.InnerText = value;
else
xe.SetAttribute(attribute, value);
doc.Save(path);
}
catch { }
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="path">路径</param>
/// <param name="node">节点</param>
/// <param name="attribute">属性名,非空时删除该节点属性值,否则删除节点值</param>
/// <param name="value">值</param>
/// <returns></returns>
/**************************************************
* 使用示列:
* XmlHelper.Delete(path, "/Node", "")
* XmlHelper.Delete(path, "/Node", "Attribute")
************************************************/
public static void Delete(string path, string node, string attribute)
{
try
{
XmlDocument doc = new XmlDocument();
doc.Load(path);
XmlNode xn = doc.SelectSingleNode(node);
XmlElement xe = (XmlElement)xn;
if (attribute.Equals(""))
xn.ParentNode.RemoveChild(xn);
else
xe.RemoveAttribute(attribute);
doc.Save(path);
}
catch { }
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Xml/XmlHelper.cs | C# | oos | 6,853 |
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
namespace TRECommon
{
public class SerializationHelper
{
private SerializationHelper()
{ }
private static Dictionary<int, XmlSerializer> serializer_dict = new Dictionary<int, XmlSerializer>();
public static XmlSerializer GetSerializer(Type t)
{
int type_hash = t.GetHashCode();
if (!serializer_dict.ContainsKey(type_hash))
serializer_dict.Add(type_hash, new XmlSerializer(t));
return serializer_dict[type_hash];
}
/// <summary>
/// 反序列化
/// </summary>
/// <param name="type">对象类型</param>
/// <param name="filename">文件路径</param>
/// <returns></returns>
public static object Load(Type type, string filename)
{
FileStream fs = null;
try
{
// open the stream...
fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
XmlSerializer serializer = new XmlSerializer(type);
return serializer.Deserialize(fs);
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (fs != null)
fs.Close();
}
}
/// <summary>
/// 序列化
/// </summary>
/// <param name="obj">对象</param>
/// <param name="filename">文件路径</param>
public static bool Save(object obj, string filename)
{
bool success = false;
FileStream fs = null;
// serialize it...
try
{
fs = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite);
XmlSerializer serializer = new XmlSerializer(obj.GetType());
serializer.Serialize(fs, obj);
success = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (fs != null)
fs.Close();
}
return success;
}
/// <summary>
/// xml序列化成字符串
/// </summary>
/// <param name="obj">对象</param>
/// <returns>xml字符串</returns>
public static string Serialize(object obj)
{
string returnStr = "";
XmlSerializer serializer = GetSerializer(obj.GetType());
MemoryStream ms = new MemoryStream();
XmlTextWriter xtw = null;
StreamReader sr = null;
try
{
xtw = new System.Xml.XmlTextWriter(ms, Encoding.UTF8);
xtw.Formatting = System.Xml.Formatting.Indented;
serializer.Serialize(xtw, obj);
ms.Seek(0, SeekOrigin.Begin);
sr = new StreamReader(ms);
returnStr = sr.ReadToEnd();
}
catch (Exception ex)
{
throw ex;
}
finally
{
if (xtw != null)
xtw.Close();
if (sr != null)
sr.Close();
ms.Close();
}
return returnStr;
}
public static object DeSerialize(Type type, string s)
{
byte[] b = System.Text.Encoding.UTF8.GetBytes(s);
try
{
XmlSerializer serializer = GetSerializer(type);
return serializer.Deserialize(new MemoryStream(b));
}
catch (Exception ex)
{
throw ex;
}
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Xml/SerializationHelper.cs | C# | oos | 4,084 |
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using Net.SourceForge.Koogra.Excel;
namespace TRECommon
{
public class ExcelUtils
{
private Workbook book;
public ExcelUtils(string path)
{
this.book = new Workbook(path);
}
public ExcelUtils(System.IO.Stream stream)
{
this.book = new Workbook(stream);
}
protected DataTable SaveAsDataTable(Worksheet sheet)
{
DataTable dt = new DataTable();
uint minRow = 0;
uint maxRow = sheet.Rows.MaxRow;
Row firstRow = sheet.Rows[minRow];
uint minCol = firstRow.Cells.MinCol;
uint maxCol = firstRow.Cells.MaxCol;
for (uint i = minCol; i <= maxCol; i++)
{
dt.Columns.Add(firstRow.Cells[i].FormattedValue());
}
for (uint i = minRow + 1; i <= maxRow; i++)
{
Row row = sheet.Rows[i];
if (row != null)
{
DataRow dr = dt.NewRow();
for (uint j = minCol; j <= maxCol; j++)
{
Cell cell = row.Cells[j];
if (cell != null)
{
dr[Convert.ToInt32(j)] = cell.Value != null ? cell.Value.ToString() : string.Empty;
}
}
dt.Rows.Add(dr);
}
}
return dt;
}
public DataTable ToDataTable(int index)
{
Worksheet sheet = this.book.Sheets[index];
if (sheet == null)
{
throw new ApplicationException(string.Format("索引[{0}]所指定的电子表格不存在!", index));
}
return this.SaveAsDataTable(sheet);
}
public DataTable ToDataTable(string sheetName)
{
Worksheet sheet = this.book.Sheets.GetByName(sheetName);
if (sheet == null)
{
throw new ApplicationException(string.Format("名称[{0}]所指定的电子表格不存在!", sheetName));
}
return this.SaveAsDataTable(sheet);
}
#region 静态方法
/// <summary>
/// 单元格格式为日期时间,使用此方法转换为DateTime类型,若解析失败则返回‘0001-01-01’
/// </summary>
public static DateTime ParseDateTime(string cellValue)
{
DateTime date = default(DateTime);
double value = default(double);
if (double.TryParse(cellValue, out value))
{
date = DateTime.FromOADate(value);
}
else
{
DateTime.TryParse(cellValue, out date);
}
return date;
}
/// <summary>
/// 转换为DataTable(文件路径+表名)
/// </summary>
public static DataTable TranslateToTable(string path, string sheetName)
{
ExcelUtils utils = new ExcelUtils(path);
return utils.ToDataTable(sheetName);
}
/// <summary>
/// 转换为DataTable(文件路径+表索引)
/// </summary>
public static DataTable TranslateToTable(string path, int sheetIndex)
{
ExcelUtils utils = new ExcelUtils(path);
return utils.ToDataTable(sheetIndex);
}
/// <summary>
/// 转换为DataTable(文件路径)
/// </summary>
public static DataTable TranslateToTable(string path)
{
ExcelUtils utils = new ExcelUtils(path);
return utils.ToDataTable(0);
}
/// <summary>
/// 转换为DataTable(内存流+表名)
/// </summary>
public static DataTable TranslateToTable(System.IO.Stream stream, string sheetName)
{
ExcelUtils utils = new ExcelUtils(stream);
return utils.ToDataTable(sheetName);
}
/// <summary>
/// 转换为DataTable(内存流+表索引)
/// </summary>
public static DataTable TranslateToTable(System.IO.Stream stream, int sheetIndex)
{
ExcelUtils utils = new ExcelUtils(stream);
return utils.ToDataTable(sheetIndex);
}
/// <summary>
/// 转换为DataTable(内存流)
/// </summary>
public static DataTable TranslateToTable(System.IO.Stream stream)
{
ExcelUtils utils = new ExcelUtils(stream);
return utils.ToDataTable(0);
}
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Office/ExeclUtils.cs | C# | oos | 5,472 |
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Collections;
using System.Text.RegularExpressions;
namespace TRECommon
{
/// <summary>
/// 搜索引擎处理
/// </summary>
public class SearchEngine
{
/// <summary>
/// 搜索引擎处理
/// </summary>
public SearchEngine() { }
#region 初始化变量
/// <summary>
/// 搜索引擎特征数组
/// </summary>
private string[][] _Enginers = new string[][] {
new string[]{"google","utf8","q","Google"},
new string[]{"baidu","gb2312","wd","百度"},
new string[]{"yahoo","utf8","p","雅虎"},
new string[]{"yisou","utf8","search","一搜"},
new string[]{"live","utf8","q","MSN&Live"},
new string[]{"tom","gb2312","word","TOM"},
new string[]{"163","gb2312","q","网易有道"},
new string[]{"iask","gb2312","k","新浪爱问"},
new string[]{"soso","gb2312","w","腾讯SoSo"},
new string[]{"sogou","gb2312","query","搜狐搜狗"},
new string[]{"zhongsou","gb2312","w","中国搜索"},
new string[]{"3721","gb2312","p","3721"},
new string[]{"openfind","utf8","q","openfind"},
new string[]{"alltheweb","utf8","q","alltheweb"},
new string[]{"lycos","utf8","query","lycos"},
new string[]{"onseek","utf8","q","onseek"}
};
private string _EngineName = "";
/// <summary>
/// 搜索引擎名称
/// </summary>
public string EngineName
{
get
{
return _EngineName;
}
}
private string _Coding = "utf8";
/// <summary>
/// 搜索引擎编码
/// </summary>
public string Coding
{
get
{
return _Coding;
}
}
private string _RegexWord = "";
/// <summary>
/// 搜索引擎关键字查询参数名称
/// </summary>
public string RegexWord
{
get
{
return _RegexWord;
}
}
private string _Regex = @"(";
#endregion
#region 搜索引擎关键字
/// <summary>
/// 建立搜索关键字正则表达式
/// </summary>
/// <param name="myString"></param>
public void EngineRegEx(string myString)
{
for (int i = 0, j = _Enginers.Length; i < j; i++)
{
if (myString.Contains(_Enginers[i][0]))
{
_EngineName = _Enginers[i][3];
_Coding = _Enginers[i][1];
_RegexWord = _Enginers[i][2];
_Regex += _Enginers[i][0] + @".+.*[?/&]" + _RegexWord + @"[=:])(?<key>[^&]*)";
break;
}
}
}
/// <summary>
/// 得到搜索引擎关键字
/// </summary>
/// <param name="myString">url</param>
/// <returns></returns>
public string SearchKey(string myString)
{
if (myString != null && myString != "")
{
EngineRegEx(myString.ToLower());
if (_EngineName != "")
{
Regex myReg = new Regex(_Regex, RegexOptions.IgnoreCase);
Match matche = myReg.Match(myString);
myString = matche.Groups["key"].Value;
//去处表示为空格的+
myString = myString.Replace("+", " ");
if (_Coding == "gb2312")
{
myString = GetUTF8String(myString);
}
else
{
myString = Uri.UnescapeDataString(myString);
}
}
else
myString = "";
}
return myString;
}
/// <summary>
/// 整句转码
/// </summary>
/// <param name="myString"></param>
/// <returns></returns>
public string GetUTF8String(string myString)
{
Regex myReg = new Regex("(?<key>%..%..)", RegexOptions.IgnoreCase);
MatchCollection matches = myReg.Matches(myString);
string myWord;
for (int i = 0, j = matches.Count; i < j; i++)
{
myWord = matches[i].Groups["key"].Value.ToString();
myString = myString.Replace(myWord, GB2312ToUTF8(myWord));
}
return myString;
}
/// <summary>
/// 单字GB2312转UTF8 URL编码
/// </summary>
/// <param name="myString"></param>
/// <returns></returns>
public string GB2312ToUTF8(string myString)
{
string[] myWord = myString.Split('%');
byte[] myByte = new byte[] { Convert.ToByte(myWord[1], 16), Convert.ToByte(myWord[2], 16) };
Encoding GB = Encoding.GetEncoding("GB2312");
Encoding U8 = Encoding.UTF8;
myByte = Encoding.Convert(GB, U8, myByte);
char[] Chars = new char[U8.GetCharCount(myByte, 0, myByte.Length)];
U8.GetChars(myByte, 0, myByte.Length, Chars, 0);
return new string(Chars);
}
#endregion
//判断否为搜索引擎爬虫,并返回其类型
public string isCrawler(string SystemInfo)
{
string[] BotList = new string[] { "Google", "Baidu", "MSN", "Yahoo", "TMCrawler", "iask", "Sogou" };
foreach (string Bot in BotList)
{
if (SystemInfo.ToLower().Contains(Bot.ToLower()))
{
return Bot;
}
}
return "null";
}
/// <summary>
/// 判断当前访问是否来自浏览器软件
/// </summary>
/// <returns>当前访问是否来自浏览器软件</returns>
public static bool IsBrowserGet()
{
string[] BrowserName = { "ie", "opera", "netscape", "mozilla", "konqueror", "firefox" };
string curBrowser = HttpContext.Current.Request.Browser.Type.ToLower();
for (int i = 0; i < BrowserName.Length; i++)
{
if (curBrowser.IndexOf(BrowserName[i]) >= 0)
return true;
}
return false;
}
/// <summary>
/// 判断是否来自搜索引擎链接
/// </summary>
/// <returns>是否来自搜索引擎链接</returns>
public static bool IsSearchEnginesGet()
{
if (HttpContext.Current.Request.UrlReferrer == null)
return false;
string[] SearchEngine = { "google", "yahoo", "msn", "baidu", "sogou", "sohu", "sina", "163", "lycos", "tom", "yisou", "iask", "soso", "gougou", "zhongsou" };
string tmpReferrer = HttpContext.Current.Request.UrlReferrer.ToString().ToLower();
for (int i = 0; i < SearchEngine.Length; i++)
{
if (tmpReferrer.IndexOf(SearchEngine[i]) >= 0)
return true;
}
return false;
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/BSObject/SearchEngine.cs | C# | oos | 7,676 |
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
namespace TRECommon
{
public class WebUtils
{
#region URL
/// <summary>
/// 从URL获取域名
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static string GetDomainFromUrl(string url)
{
if (url == null || url == "") return "";
if (url.ToLower().StartsWith("http://"))
url = url.Remove(0, 7);
string[] parts = url.Split('/');
string domain = "";
List<string> dotcoms = new List<string>() { ".com", ".org", ".net", ".gov" };
for (int i = 0; i < parts.Length; i++)
{
if (parts[i] != "" && parts[i].IndexOf(".") > 0)
{
domain = parts[0];
break;
}
}
if (domain.Length > 0)
{
string[] ds = domain.Split('.');
if (ds.Length == 3 && !dotcoms.Contains(ds[1]))
domain = ds[1] + "." + ds[2];
else if (ds.Length == 4 && dotcoms.Contains(ds[2]))
domain = ds[1] + "." + ds[2] + "." + ds[3];
else if (ds.Length > 4)
{
domain = ds[ds.Length - 3] + "." + ds[ds.Length - 2] + "." + ds[ds.Length - 1];
}
}
return domain;
}
// <summary>
/// 返回url中去掉文件名部分。如/news/2.html 中的/news/
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
public static string GetChannelUrlFromUrl(string url)
{
if (url.IndexOf("?") > 0)
url = url.Remove(url.IndexOf("?"));
if (url.IndexOf('.') > 0)
return url.Substring(0, url.LastIndexOf('/') + 1);
else
{
if (!url.EndsWith("/")) url = url + "/";
return url;
}
}
/// <summary>
/// 获得当前页面的名称
/// </summary>
/// <returns>当前页面的名称</returns>
public static string GetPageName()
{
string[] urlArr = HttpContext.Current.Request.Url.AbsolutePath.Split('/');
return urlArr[urlArr.Length - 1].ToLower();
}
/// <summary>
/// 返回路径
/// </summary>
/// <param name="relativeUrl"></param>
/// <returns></returns>
public static string ResolveUrl(string relativeUrl)
{
if (relativeUrl == null) throw new ArgumentNullException("relativeUrl");
if (relativeUrl.Length == 0 || relativeUrl[0] == '/' ||
relativeUrl[0] == '\\') return relativeUrl;
int idxOfScheme =
relativeUrl.IndexOf(@"://", StringComparison.Ordinal);
if (idxOfScheme != -1)
{
int idxOfQM = relativeUrl.IndexOf('?');
if (idxOfQM == -1 || idxOfQM > idxOfScheme) return relativeUrl;
}
StringBuilder sbUrl = new StringBuilder();
sbUrl.Append(HttpRuntime.AppDomainAppVirtualPath);
if (sbUrl.Length == 0 || sbUrl[sbUrl.Length - 1] != '/') sbUrl.Append('/');
// found question mark already? query string, do not touch!
bool foundQM = false;
bool foundSlash; // the latest char was a slash?
if (relativeUrl.Length > 1
&& relativeUrl[0] == '~'
&& (relativeUrl[1] == '/' || relativeUrl[1] == '\\'))
{
relativeUrl = relativeUrl.Substring(2);
foundSlash = true;
}
else foundSlash = false;
foreach (char c in relativeUrl)
{
if (!foundQM)
{
if (c == '?') foundQM = true;
else
{
if (c == '/' || c == '\\')
{
if (foundSlash) continue;
else
{
sbUrl.Append('/');
foundSlash = true;
continue;
}
}
else if (foundSlash) foundSlash = false;
}
}
sbUrl.Append(c);
}
return sbUrl.ToString();
}
#endregion
#region 验证码
/// <summary>
/// 生成数字
/// </summary>
/// <param name="length"></param>
/// <returns></returns>
public static string GetNumVerify(int length)
{
Random rand = new Random();
string min = "";
string max = "";
for (int i = 0; i < length; i++)
{
min += "1";
max += "9";
}
return (rand.Next(TypeConverter.StrToInt(min), TypeConverter.StrToInt(max)).ToString());
}
/// <summary>
/// 生成随数数字
/// </summary>
/// <param name="length"></param>
/// <returns></returns>
public static string GetRandomNumVerify(int length)
{
string allChar = "0,1,2,3,4,5,6,7,8,9";
string[] allCharArray = allChar.Split(',');
string newCode = "";
Random rand = new Random();
int temp = -1; //临时变量rand实列标志 内容为上次的值 如果值为上次生成的数次则实列新的random
for (int i = 0; i < length; i++)
{
//首次无需执行实列新Random
if (temp != -1)
{
rand = new Random(int.MaxValue - rand.Next(800) - 1);
}
int t = rand.Next(9); //临时变量 位置
//如果本次位置==上次位置则重新实列Randon
if (t == temp)
{
return GetRandomNumVerify(length);
}
temp = t;
newCode += allCharArray[t];
}
return newCode;
}
/// <summary>
/// 生成随数 数字+字母
/// </summary>
/// <param name="length"></param>
/// <returns></returns>
public static string GetRandomNumAndLetterVerify(int length)
{
string allChar = "0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,W,X,Y,Z,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z";
string[] allCharArray = allChar.Split(',');
string randomCode = "";
int temp = -1;
Random rand = new Random();
for (int i = 0; i < length; i++)
{
if (temp != -1)
{
rand = new Random(int.MaxValue - rand.Next(800) - 1);
}
int t = rand.Next(61);
if (temp == t)
{
return GetRandomNumAndLetterVerify(length);
}
temp = t;
randomCode += allCharArray[t];
}
return randomCode;
}
/// <summary>
/// 生成汉字字节
/// </summary>
/// <param name="strlength"></param>
/// <returns></returns>
public static object[] GetRandomRegionVerify(int strlength)
{
//定义一个字符串数组储存汉字编码的组成元素
string[] rBase = new String[16] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
Random rnd = new Random();
//定义一个object数组用来
object[] bytes = new object[strlength];
/**/
/*每循环一次产生一个含两个元素的十六进制字节数组,并将其放入bject数组中
每个汉字有四个区位码组成
区位码第1位和区位码第2位作为字节数组第一个元素
区位码第3位和区位码第4位作为字节数组第二个元素
*/
for (int i = 0; i < strlength; i++)
{
//区位码第1位
int r1 = rnd.Next(11, 14);
string str_r1 = rBase[r1].Trim();
//区位码第2位
rnd = new Random(r1 * unchecked((int)DateTime.Now.Ticks) + i);//更换随机数发生器的种子避免产生重复值
int r2;
if (r1 == 13)
{
r2 = rnd.Next(0, 7);
}
else
{
r2 = rnd.Next(0, 16);
}
string str_r2 = rBase[r2].Trim();
//区位码第3位
rnd = new Random(r2 * unchecked((int)DateTime.Now.Ticks) + i);
int r3 = rnd.Next(10, 16);
string str_r3 = rBase[r3].Trim();
//区位码第4位
rnd = new Random(r3 * unchecked((int)DateTime.Now.Ticks) + i);
int r4;
if (r3 == 10)
{
r4 = rnd.Next(1, 16);
}
else if (r3 == 15)
{
r4 = rnd.Next(0, 15);
}
else
{
r4 = rnd.Next(0, 16);
}
string str_r4 = rBase[r4].Trim();
//定义两个字节变量存储产生的随机汉字区位码
byte byte1 = Convert.ToByte(str_r1 + str_r2, 16);
byte byte2 = Convert.ToByte(str_r3 + str_r4, 16);
//将两个字节变量存储在字节数组中
byte[] str_r = new byte[] { byte1, byte2 };
//将产生的一个汉字的字节数组放入object数组中
bytes.SetValue(str_r, i);
}
return bytes;
}
/// <summary>
/// 生成汉字
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public static string GetRandomRegionVerifyByLength(int num)
{
Encoding gb = Encoding.GetEncoding("gb2312");
//调用函数产生10个随机中文汉字编码
object[] bytes = GetRandomRegionVerify(num);
string strtxt = "";
//根据汉字编码的字节数组解码出中文汉字
for (int i = 0; i < num; i++)
{
strtxt += gb.GetString((byte[])Convert.ChangeType(bytes[i], typeof(byte[])));
}
return strtxt;
}
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/BSObject/WebUtils.cs | C# | oos | 11,372 |
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Web;
using System.Reflection;
using System.Web.UI.WebControls;
namespace TRECommon
{
public class WebControlBind
{
#region DropDownList
public static void DrpBind(Type enumType,DropDownList ddl,string defaultValue,string defaultName)
{
ddl.Items.Clear();
int i = 0;
System.Reflection.FieldInfo[] fields = enumType.GetFields();
string strText = string.Empty;
string strValue = string.Empty;
foreach (FieldInfo field in fields)
{
if (field.FieldType.IsEnum)
{
if (!field.IsSpecialName)
{
ddl.Items.Add(new ListItem(field.Name, field.GetRawConstantValue().ToString()));
}
else
{
ddl.Items.Add(new ListItem(field.Name, i.ToString()));
}
i++;
}
}
}
public static void DrpBind(Type enumType, DropDownList ddl)
{
DrpBind(enumType, ddl, "", "");
}
#endregion
#region RadioList
public static void RadioBind(Type enumType, RadioButtonList ra)
{
ra.Items.Clear();
int i = 0;
System.Reflection.FieldInfo[] fields = enumType.GetFields();
string strText = string.Empty;
string strValue = string.Empty;
foreach (FieldInfo field in fields)
{
if (field.FieldType.IsEnum)
{
if (!field.IsSpecialName)
{
ra.Items.Add(new ListItem(field.Name, field.GetRawConstantValue().ToString()));
}
else
{
ra.Items.Add(new ListItem(field.Name, i.ToString()));
}
i++;
}
}
}
#endregion
#region ChkBoxList
/// <summary>
/// 获取CheckBoxList 获中值[string a,b,c]
/// </summary>
/// <param name="chk">CheckBoxList</param>
/// <returns>string a,b,c</returns>
public static string CheckBoxListSelected(CheckBoxList chk)
{
string chkValue = "";
foreach (ListItem item in chk.Items)
{
chkValue += item.Selected ? item.Value + "," : "";
}
return string.IsNullOrEmpty(chkValue) ? "" : chkValue.Substring(0, chkValue.Length - 1);
}
/// <summary>
/// 判断checkboxlist 是否有选中项
/// </summary>
/// <param name="chk">CheckBoxList</param>
/// <returns>Boolen</returns>
public static bool IsCheckBoxListSelected(CheckBoxList chk)
{
return string.IsNullOrEmpty(CheckBoxListSelected(chk)) ? false : true;
}
/// <summary>
/// CheckBoxList 设置选中项
/// </summary>
/// <param name="chk">CheckBoxList</param>
/// <param name="values">string[] values</param>
public static void CheckBoxListSetSelected(CheckBoxList chk, string[] values)
{
if (values.Length > 0)
{
foreach (ListItem item in chk.Items)
{
if (StringOperation.InArray(item.Value, values, true))
{
item.Selected = true;
}
}
}
}
/// <summary>
/// CheckBoxList 设置选中项
/// </summary>
/// <param name="chk">CheckBoxList</param>
/// <param name="values">string[] values</param>
public static void CheckBoxListSetSelected(CheckBoxList chk, string values)
{
if (values != null && values.Length > 0)
{
string[] v = values.Split(',');
foreach (ListItem item in chk.Items)
{
if (StringOperation.InArray(item.Value, v, true))
{
item.Selected = true;
}
}
}
}
/// <summary>
/// CheckBoxList 绑定 DataView
/// </summary>
/// <param name="chk">CheckBoxList</param>
/// <param name="dt">DataView</param>
public static void CheckBoxListBind(CheckBoxList chk, DataView dv)
{
chk.DataSource = dv;
chk.DataBind();
}
public static void CheckBoxListBind(Type enumType, CheckBoxList chk)
{
chk.Items.Clear();
int i = 0;
System.Reflection.FieldInfo[] fields = enumType.GetFields();
string strText = string.Empty;
string strValue = string.Empty;
foreach (FieldInfo field in fields)
{
if (field.FieldType.IsEnum)
{
chk.Items.Add(new ListItem(field.Name, i.ToString()));
i++;
}
}
}
#endregion
#region List
public static string GetListBoxSelectValues(ListBox l)
{
string v = "";
foreach (ListItem item in l.Items)
{
if (item.Selected == true)
{
v += item.Value + ",";
}
}
if (v != "" && v.Length > 0)
{
return v.Substring(0, v.Length - 1);
}
return v;
}
public static string GetListBoxSelectValuesAll(ListBox l)
{
foreach (ListItem item in l.Items)
{
if (item.Value == "0" && item.Selected==true)
{
return "0";
}
}
return GetListBoxSelectValues(l);
}
public static string GetListBoxSelectValuesAllIdList(ListBox l)
{
string v = "";
foreach (ListItem item in l.Items)
{
if (item.Value == "0" && item.Selected == true)
{
foreach (ListItem i in l.Items)
{
if (i.Value != "0")
{
v += i.Value + ",";
}
}
if (v != "" && v.Length > 0)
{
return v.Substring(0, v.Length - 1);
}
}
}
return GetListBoxSelectValues(l);
}
public static void SetListBoxSelect(ListBox l,string values)
{
if (values != null && values.Length > 0)
{
string[] v = values.Split(',');
foreach (ListItem item in l.Items)
{
item.Selected = false;
if (StringOperation.InArray(item.Value, v))
{
item.Selected = true;
}
}
}
}
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/BSObject/WebControlBind.cs | C# | oos | 7,722 |
using System;
using System.Web;
namespace TRECommon
{
/// <summary>
/// Request操作类
/// </summary>
public class WebRequest
{
/// <summary>
/// 判断当前页面是否接收到了Post请求
/// </summary>
/// <returns>是否接收到了Post请求</returns>
public static bool IsPost()
{
return HttpContext.Current.Request.HttpMethod.Equals("POST");
}
/// <summary>
/// 判断当前页面是否接收到了Get请求
/// </summary>
/// <returns>是否接收到了Get请求</returns>
public static bool IsGet()
{
return HttpContext.Current.Request.HttpMethod.Equals("GET");
}
/// <summary>
/// 返回指定的服务器变量信息
/// </summary>
/// <param name="strName">服务器变量名</param>
/// <returns>服务器变量信息</returns>
public static string GetServerString(string strName)
{
if (HttpContext.Current.Request.ServerVariables[strName] == null)
return "";
return HttpContext.Current.Request.ServerVariables[strName].ToString();
}
/// <summary>
/// 返回上一个页面的地址
/// </summary>
/// <returns>上一个页面的地址</returns>
public static string GetUrlReferrer()
{
string retVal = null;
try
{
retVal = HttpContext.Current.Request.UrlReferrer.ToString();
}
catch { }
if (retVal == null)
return "";
return retVal;
}
/// <summary>
/// 得到当前完整主机头
/// </summary>
/// <returns></returns>
public static string GetCurrentFullHost()
{
HttpRequest request = System.Web.HttpContext.Current.Request;
if (!request.Url.IsDefaultPort)
return string.Format("{0}:{1}", request.Url.Host, request.Url.Port.ToString());
return request.Url.Host;
}
/// <summary>
/// 得到主机头
/// </summary>
/// <returns></returns>
public static string GetHost()
{
return HttpContext.Current.Request.Url.Host;
}
/// <summary>
/// 获取当前请求的原始 URL(URL 中域信息之后的部分,包括查询字符串(如果存在))
/// </summary>
/// <returns>原始 URL</returns>
public static string GetRawUrl()
{
return HttpContext.Current.Request.RawUrl;
}
/// <summary>
/// 获得当前完整Url地址
/// </summary>
/// <returns>当前完整Url地址</returns>
public static string GetUrl()
{
return HttpContext.Current.Request.Url.ToString();
}
/// <summary>
/// 获得指定Url参数的值
/// </summary>
/// <param name="strName">Url参数</param>
/// <returns>Url参数的值</returns>
public static string GetQueryString(string strName)
{
return GetQueryString(strName, false);
}
/// <summary>
/// 获得指定Url参数的值
/// </summary>
/// <param name="strName">Url参数</param>
/// <param name="sqlSafeCheck">是否进行SQL安全检查</param>
/// <returns>Url参数的值</returns>
public static string GetQueryString(string strName, bool sqlSafeCheck)
{
if (HttpContext.Current.Request.QueryString[strName] == null)
return "";
if (sqlSafeCheck && !Validator.IsSafeSqlString(HttpContext.Current.Request.QueryString[strName]))
return "unsafe string";
return HttpContext.Current.Request.QueryString[strName];
}
/// <summary>
/// 返回表单或Url参数的总个数
/// </summary>
/// <returns></returns>
public static int GetParamCount()
{
return HttpContext.Current.Request.Form.Count + HttpContext.Current.Request.QueryString.Count;
}
/// <summary>
/// 获得指定表单参数的值
/// </summary>
/// <param name="strName">表单参数</param>
/// <returns>表单参数的值</returns>
public static string GetFormString(string strName)
{
return GetFormString(strName, false);
}
/// <summary>
/// 获得指定表单参数的值
/// </summary>
/// <param name="strName">表单参数</param>
/// <param name="sqlSafeCheck">是否进行SQL安全检查</param>
/// <returns>表单参数的值</returns>
public static string GetFormString(string strName, bool sqlSafeCheck)
{
if (HttpContext.Current.Request.Form[strName] == null)
return "";
if (sqlSafeCheck && !Validator.IsSafeSqlString(HttpContext.Current.Request.Form[strName]))
return "unsafe string";
return HttpContext.Current.Request.Form[strName];
}
/// <summary>
/// 获得Url或表单参数的值, 先判断Url参数是否为空字符串, 如为True则返回表单参数的值
/// </summary>
/// <param name="strName">参数</param>
/// <returns>Url或表单参数的值</returns>
public static string GetString(string strName)
{
return GetString(strName, false);
}
/// <summary>
/// 获得Url或表单参数的值, 先判断Url参数是否为空字符串, 如为True则返回表单参数的值
/// </summary>
/// <param name="strName">参数</param>
/// <param name="sqlSafeCheck">是否进行SQL安全检查</param>
/// <returns>Url或表单参数的值</returns>
public static string GetString(string strName, bool sqlSafeCheck)
{
if ("".Equals(GetQueryString(strName)))
return GetFormString(strName, sqlSafeCheck);
else
return GetQueryString(strName, sqlSafeCheck);
}
/// <summary>
/// 获得指定Url参数的int类型值
/// </summary>
/// <param name="strName">Url参数</param>
/// <returns>Url参数的int类型值</returns>
public static int GetQueryInt(string strName)
{
return TypeConverter.StrToInt(HttpContext.Current.Request.QueryString[strName], 0);
}
/// <summary>
/// 获得指定Url参数的int类型值
/// </summary>
/// <param name="strName">Url参数</param>
/// <param name="defValue">缺省值</param>
/// <returns>Url参数的int类型值</returns>
public static int GetQueryInt(string strName, int defValue)
{
return TypeConverter.StrToInt(HttpContext.Current.Request.QueryString[strName], defValue);
}
/// <summary>
/// 获得指定表单参数的int类型值
/// </summary>
/// <param name="strName">表单参数</param>
/// <param name="defValue">缺省值</param>
/// <returns>表单参数的int类型值</returns>
public static int GetFormInt(string strName, int defValue)
{
return TypeConverter.StrToInt(HttpContext.Current.Request.Form[strName], defValue);
}
/// <summary>
/// 获得指定Url或表单参数的int类型值, 先判断Url参数是否为缺省值, 如为True则返回表单参数的值
/// </summary>
/// <param name="strName">Url或表单参数</param>
/// <param name="defValue">缺省值</param>
/// <returns>Url或表单参数的int类型值</returns>
public static int GetInt(string strName, int defValue)
{
if (GetQueryInt(strName, defValue) == defValue)
return GetFormInt(strName, defValue);
else
return GetQueryInt(strName, defValue);
}
/// <summary>
/// 获得指定Url参数的float类型值
/// </summary>
/// <param name="strName">Url参数</param>
/// <param name="defValue">缺省值</param>
/// <returns>Url参数的int类型值</returns>
public static float GetQueryFloat(string strName, float defValue)
{
return TypeConverter.StrToFloat(HttpContext.Current.Request.QueryString[strName], defValue);
}
/// <summary>
/// 获得指定表单参数的float类型值
/// </summary>
/// <param name="strName">表单参数</param>
/// <param name="defValue">缺省值</param>
/// <returns>表单参数的float类型值</returns>
public static float GetFormFloat(string strName, float defValue)
{
return TypeConverter.StrToFloat(HttpContext.Current.Request.Form[strName], defValue);
}
/// <summary>
/// 获得指定Url或表单参数的float类型值, 先判断Url参数是否为缺省值, 如为True则返回表单参数的值
/// </summary>
/// <param name="strName">Url或表单参数</param>
/// <param name="defValue">缺省值</param>
/// <returns>Url或表单参数的int类型值</returns>
public static float GetFloat(string strName, float defValue)
{
if (GetQueryFloat(strName, defValue) == defValue)
return GetFormFloat(strName, defValue);
else
return GetQueryFloat(strName, defValue);
}
/// <summary>
/// 获得当前页面客户端的IP
/// </summary>
/// <returns>当前页面客户端的IP</returns>
public static string GetIP()
{
string result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
if (string.IsNullOrEmpty(result))
result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(result))
result = HttpContext.Current.Request.UserHostAddress;
if (string.IsNullOrEmpty(result) || !Validator.IsIP(result))
return "127.0.0.1";
return result;
}
/// <summary>
/// 返回 URL 字符串的编码结果
/// </summary>
/// <param name="str">字符串</param>
/// <returns>编码结果</returns>
public static string UrlEncode(string str)
{
return HttpUtility.UrlEncode(str);
}
/// <summary>
/// 返回 URL 字符串的编码结果
/// </summary>
/// <param name="str">字符串</param>
/// <returns>解码结果</returns>
public static string UrlDecode(string str)
{
return HttpUtility.UrlDecode(str);
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/BSObject/WebRequest.cs | C# | oos | 11,356 |
//======================================================================
// 组织名: Troopsen
// 命名空间名称: Utils
// 文件名: Validator
// 创建人: Troopsen
// 创建时间: 2011/3/11 8:21:25
//======================================================================
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Text.RegularExpressions;
namespace TRECommon
{
public class Validator
{
#region 验证是否为空
/// <summary>
/// 验证字符串是否为空
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool StrIsNullOrEmpty(string str)
{
if (str == null || str.Trim() == string.Empty)
return true;
else
return false;
}
#endregion
/**
/// <summary>
/// 是否为整数
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsInt(int source)
{
string strPatten="";
Regex Reg = new Regex(strPatten);
}
/// <summary>
/// 是否为小数
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsFloat(string source)
{
}
/// <summary>
/// 是否为英文字母
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsEnglish(string source)
{
}
/// <summary>
/// 是否为中文字母
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsChinese(string source)
{
}
/// <summary>
/// 验证邮箱Email
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsEmail(string source)
{
}
/// <summary>
/// 是否为电话号码
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsPhoneNumber(string source)
{
}
/// <summary>
/// 是否为手机号码
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool MobileNumber(string source)
{
}
/// <summary>
/// 是否为时间
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsDate(string source)
{
}
/// <summary>
/// 是否为生日
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsBirthday(string source)
{
}
/// <summary>
/// 是否为年龄
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsAge(int source)
{
}
/// <summary>
/// 是否为身份证号码
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsIDNumber(int source)
{
}
/// <summary>
/// 是否为网址
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsWebSite(string source)
{
}
/// <summary>
/// 是否IP
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsIp(string source)
{
}
/// <summary>
/// 是否为IP6
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsIp6(string source)
{
}
/// <summary>
/// 是否为邮编(中国)
/// </summary>
/// <param name="source"></param>
/// <returns></returns>
public static bool IsZipCode(int source)
{
}
**/
/// <summary>
/// 检测是否是正确的Url
/// </summary>
/// <param name="strUrl">要验证的Url</param>
/// <returns>判断结果</returns>
public static bool IsURL(string strUrl)
{
return Regex.IsMatch(strUrl, @"^(http|https)\://([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{1,10}))(\:[0-9]+)*(/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$");
}
/// <summary>
/// 检测是否符合email格式
/// </summary>
/// <param name="strEmail">要判断的email字符串</param>
/// <returns>判断结果</returns>
public static bool IsValidEmail(string strEmail)
{
return Regex.IsMatch(strEmail, @"^[\w\.]+([-]\w+)*@[A-Za-z0-9-_]+[\.][A-Za-z0-9-_]");
}
public static bool IsValidDoEmail(string strEmail)
{
return Regex.IsMatch(strEmail, @"^@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}
public static string GetEmailHostName(string strEmail)
{
if (strEmail.IndexOf("@") < 0)
{
return "";
}
return strEmail.Substring(strEmail.LastIndexOf("@")).ToLower();
}
/// <summary>
/// 检测是否有Sql危险字符
/// </summary>
/// <param name="str">要判断字符串</param>
/// <returns>判断结果</returns>
public static bool IsSafeSqlString(string str)
{
return !Regex.IsMatch(str, @"[;|,|\/|\(|\)|\[|\]|\}|\{|%|@|\*|!|\']");
}
/// <summary>
/// 检测是否有危险的可能用于链接的字符串
/// </summary>
/// <param name="str">要判断字符串</param>
/// <returns>判断结果</returns>
public static bool IsSafeUserInfoString(string str)
{
return !Regex.IsMatch(str, @"^\s*$|^c:\\con\\con$|[%,\*" + "\"" + @"\s\t\<\>\&]|游客|^Guest");
}
/// <summary>
/// 是否为ip
/// </summary>
/// <param name="ip"></param>
/// <returns></returns>
public static bool IsIP(string ip)
{
return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
}
public static bool IsIPSect(string ip)
{
return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){2}((2[0-4]\d|25[0-5]|[01]?\d\d?|\*)\.)(2[0-4]\d|25[0-5]|[01]?\d\d?|\*)$");
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Validator.cs | C# | oos | 7,571 |
//======================================================================
// 组织名: Troopsen
// 命名空间名称: Common
// 文件名: Utils
// 创建人: Troopsen
// 创建时间: 2011/3/29 9:25:10
//======================================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
using System.Security.Cryptography;
using System.Web;
namespace TRECommon
{
public class Utils
{
//正则表达式
#region 工具 性别
/// <summary>
/// 性别 数字 0=女 1=男 2=保密 转换为字符
/// </summary>
/// <param name="value">值</param>
/// <param name="defValue">缺省值</param>
/// <returns></returns>
public static string GetSexStrValue(int value, string defValue)
{
if (value == 0)
return "女";
else if (value == 1)
return "男";
else if (value == 2)
return "保密";
return defValue;
}
/// <summary>
/// 性别 数字 0=女 1=男 2=保密 转换为字符 默认保密
/// </summary>
/// <param name="value">值</param>
/// <returns></returns>
public static string GetSexStrValue(int value)
{
return GetSexStrValue(value, "保密");
}
#endregion
#region 工具 是否
public static string GetYesNoIntToStr(int value)
{
return value == 0 ? "否" : "是";
}
public static string GetYesNoBoolToStr(bool value)
{
return value == true ? "是" : "否";
}
public static int GetYesNoStrToInt(string value)
{
return value == "是" ? 1 : 0;
}
public static int GetYesNoBoolToInt(bool value)
{
return value == true ? 1 : 0;
}
public static bool GetYesNoStrToBool(string value)
{
return value == "是" ? true : false;
}
public static bool GetYesNoIntToBool(int value)
{
return value == 0 ? false : true;
}
#endregion
#region 工具 文件
/// <summary>
/// 返回文件是否存在
/// </summary>
/// <param name="filename">文件名</param>
/// <returns>是否存在</returns>
public static bool FileExists(string filename)
{
return System.IO.File.Exists(filename);
}
#endregion
#region 工具 路径
/// <summary>
/// 获得当前绝对路径
/// </summary>
/// <param name="strPath">指定的路径</param>
/// <returns>绝对路径</returns>
public static string GetMapPath(string strPath)
{
if (HttpContext.Current != null)
{
return HttpContext.Current.Server.MapPath(strPath);
}
else //非web程序引用
{
strPath = strPath.Replace("/", "\\");
if (strPath.StartsWith("\\"))
{
strPath = strPath.Substring(strPath.IndexOf('\\', 1)).TrimStart('\\');
}
return System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, strPath);
}
}
#endregion
#region 工具 IP
/// <summary>
/// 返回指定IP是否在指定的IP数组所限定的范围内, IP数组内的IP地址可以使用*表示该IP段任意, 例如192.168.1.*
/// </summary>
/// <param name="ip"></param>
/// <param name="iparray"></param>
/// <returns></returns>
public static bool InIPArray(string ip, string[] iparray)
{
string[] userip = StringOperation.SplitString(ip, @".");
for (int ipIndex = 0; ipIndex < iparray.Length; ipIndex++)
{
string[] tmpip = StringOperation.SplitString(iparray[ipIndex], @".");
int r = 0;
for (int i = 0; i < tmpip.Length; i++)
{
if (tmpip[i] == "*")
return true;
if (userip.Length > i)
{
if (tmpip[i] == userip[i])
r++;
else
break;
}
else
break;
}
if (r == 4)
return true;
}
return false;
}
#endregion
#region 工具 加密
/// <summary>
/// MD5函数
/// </summary>
/// <param name="str">原始字符串</param>
/// <returns>MD5结果</returns>
public static string MD5(string str)
{
byte[] b = Encoding.UTF8.GetBytes(str);
b = new MD5CryptoServiceProvider().ComputeHash(b);
string ret = "";
for (int i = 0; i < b.Length; i++)
ret += b[i].ToString("x").PadLeft(2, '0');
return ret;
}
/// <summary>
/// SHA256函数
/// </summary>
/// /// <param name="str">原始字符串</param>
/// <returns>SHA256结果</returns>
public static string SHA256(string str)
{
byte[] SHA256Data = Encoding.UTF8.GetBytes(str);
SHA256Managed Sha256 = new SHA256Managed();
byte[] Result = Sha256.ComputeHash(SHA256Data);
return Convert.ToBase64String(Result); //返回长度为44字节的字符串
}
#endregion
#region 随机数
public static string Create2Rond()
{
Random rnd = new Random();
return rnd.Next(9, 100).ToString();
}
#endregion
#region 正则获取图片路径
public static StringBuilder GetImgUrl(string text)
{
StringBuilder str = new StringBuilder();
string pat = @"<img\s+[^>]*\s*src\s*=\s*([']?)(?<url>\S+)'?[^>]*>";
Regex r = new Regex(pat, RegexOptions.Compiled);
Match m = r.Match(text.ToLower());
//int matchCount = 0;
while (m.Success)
{
Group g = m.Groups[2];
str.Append(g).Append(",");
m = m.NextMatch();
}
return str.Replace("\"", "");
}
#endregion
#region 处理存在数据库中for xml path的数据
/// <summary>
/// 返回匹配多个的集合值
/// </summary>
/// <param name="start">开始html tag</param>
/// <param name="end">结束html tag</param>
/// <param name="html">html</param>
/// <returns></returns>
//public static List<string> GetHtmls(string start, string end, string html)
//{
// IList list = new List<string>();
// try
// {
// string pattern = string.Format("{0}(?<g>(.|[\r\n])+?){1}", start, end);//匹配URL的模式,并分组
// MatchCollection mc = Regex.Matches(html, pattern);//满足pattern的匹配集合
// if (mc.Count != 0)
// {
// foreach (Match match in mc)
// {
// GroupCollection gc = match.Groups;
// list.Add(gc["g"].Value);
// }
// }
// }
// catch { }
// return list;
//}
//public static string GetHtml(string start, string end, string html)
//{
// string ret = string.Empty;
// try
// {
// string pattern = string.Format("{0}(?<g>(.|[\r\n])+?)?{1}", start, end);//匹配URL的模式,并分组
// ret = Regex.Match(html, pattern).Groups["g"].Value;
// }
// catch { }
// return ret;
//}
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Utils.cs | C# | oos | 8,543 |
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
using System.Text;
using System.IO;
using System.Threading;
namespace TRECommon
{
public class ScriptUtils
{
#region Static Property Get BaseUrl(静态属性获取URL地址)
/**/
/// <summary>
/// 这个静态属性的调用必须用以下代码方法调用
/// 代码调用:
/// Response.Write(UIHelper.BaseUrl);
/// </summary>
public static string BaseUrl
{
get
{
//strBaseUrl用于存储URL地址
string strBaseUrl = "";
//获取当前HttpContext下的地址
strBaseUrl += "http://" + HttpContext.Current.Request.Url.Host;
//如果端口不是80的话,那么加入特殊端口
if (HttpContext.Current.Request.Url.Port.ToString() != "80")
{
strBaseUrl += ":" + HttpContext.Current.Request.Url.Port;
}
strBaseUrl += HttpContext.Current.Request.ApplicationPath;
return strBaseUrl + "/";
}
}
#endregion
#region Alert()
/**/
/// <summary>
/// 简单弹出对话框功能
/// 代码调用:
/// UIHelper.Alert(this.Page,"OKOK");
///
///
/// </summary>
/// <param name="pageCurrent">
/// 当前的页面
/// </param>
/// <param name="strMsg">
/// 弹出信息的内容
/// </param>
public static void Alert(System.Web.UI.Page pageCurrent, string strMsg)
{
//Replace \n
strMsg = strMsg.Replace("\n", "file://n/");
//Replace \r
strMsg = strMsg.Replace("\r", "file://r/");
//Replace "
strMsg = strMsg.Replace("\"", "\\\"");
//Replace '
strMsg = strMsg.Replace("\'", "\\\'");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.alert('" + strMsg + "')</script>"
);
//以下代码是兼容.net1.1版本的,但到了2.0时代此API就过时了
//pageCurrent.RegisterStartupScript(
// System.Guid.NewGuid().ToString(),
// "<script>window.alert('" + strMsg + "')</script>"
// );
}
public static void Alert(System.Web.UI.Page pageCurrent, string strMsg, string GoBackUrl)
{
//Replace \n
strMsg = strMsg.Replace("\n", "file://n/");
//Replace \r
strMsg = strMsg.Replace("\r", "file://r/");
//Replace "
strMsg = strMsg.Replace("\"", "\\\"");
//Replace '
strMsg = strMsg.Replace("\'", "\\\'");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.alert('" + strMsg + "');location='" + GoBackUrl + "'</script>"
);
//以下代码是兼容.net1.1版本的,但到了2.0时代此API就过时了
//pageCurrent.RegisterStartupScript(
// System.Guid.NewGuid().ToString(),
// "<script>window.alert('" + strMsg + "')</script>"
// );
}
#endregion
#region ScrollMessage
/**/
/// <summary>
/// 简单的滚动信息栏
/// 代码调用
/// UIHelper.ScrollMessage(this.Page, "滚动的内容");
/// </summary>
/// <param name="pageCurrent">
/// 当前页面
/// </param>
/// <param name="strMsg">
/// 要滚动的信息
/// </param>
public static string ScrollMessage(string strMsg)
{
//Replace \n
strMsg = strMsg.Replace("\n", "file://n/");
//Replace \r
strMsg = strMsg.Replace("\r", "file://r/");
//Replace "
strMsg = strMsg.Replace("\"", "\\\"");
//Replace '
strMsg = strMsg.Replace("\'", "\\\'");
StringBuilder sb = new StringBuilder();
sb.Append("<MARQUEE>");
sb.Append(strMsg);
sb.Append("</MARQUEE>");
return sb.ToString();
//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
// System.Guid.NewGuid().ToString(),sb.ToString());
}
/**/
/// <summary>
/// 指定滚动文字的详细方法
///
/// </summary>
/// <param name="pageCurrent">
/// 当前的页面
/// </param>
/// <param name="strMsg">
/// 要滚动的文字
/// </param>
/// <param name="aligh">
/// align:是设定活动字幕的位置,居左、居中、居右、靠上和靠下三种位置
/// left center right top bottom
/// </param>
/// <param name="bgcolor">
/// 用于设定活动字幕的背景颜色,一般是十六进制数。如#CCCCCC
/// </param>
/// <param name="direction">
/// 用于设定活动字幕的滚动方向是向左、向右、向上、向下
/// left|right|up|down
/// </param>
/// <param name="behavior">
/// 用于设定滚动的方式,主要由三种方式:scroll slide和alternate
///
/// </param>
/// <param name="height">
/// 用于设定滚动字幕的高度
///
/// </param>
/// <param name="hspace">
/// 则设定滚动字幕的宽度
/// </param>
/// <param name="scrollamount">
/// 用于设定活动字幕的滚动距离
/// </param>
/// <param name="scrolldelay">
/// 用于设定滚动两次之间的延迟时间
/// </param>
/// <param name="width"></param>
/// <param name="vspace">
/// 分别用于设定滚动字幕的左右边框和上下边框的宽度
///
/// </param>
/// <param name="loop">
/// 用于设定滚动的次数,当loop=-1表示一直滚动下去,直到页面更新
/// </param>
/// <param name="MarqueejavascriptPath">
/// 脚本的存放位置
/// </param>
/// <returns></returns>
public static string ScrollMessage(System.Web.UI.Page pageCurrent, string strMsg, string aligh, string bgcolor,
string direction, string behavior, string height, string hspace,
string scrollamount, string scrolldelay, string width, string vspace, string loop,
string MarqueejavascriptPath)
{
StreamReader sr = new StreamReader(pageCurrent.MapPath(MarqueejavascriptPath));
StringBuilder sb = new StringBuilder();
string line;
try
{
while ((line = sr.ReadLine()) != null)
{
sb.AppendLine(line);
}
sr.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
sb.Replace("$strMessage", strMsg);
sb.Replace("$aligh", aligh);
sb.Replace("$bgcolor", bgcolor);
sb.Replace("$direction", direction);
sb.Replace("$behavior", behavior);
sb.Replace("$height", height);
sb.Replace("$hspace", hspace);
sb.Replace("$scrollamount", scrollamount);
sb.Replace("$scrolldelay", scrolldelay);
sb.Replace("$width", width);
sb.Replace("$vspace", vspace);
sb.Replace("$loop", loop);
//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
// System.Guid.NewGuid().ToString(), sb.ToString());
return sb.ToString();
}
#endregion
#region Redirect()
/**/
/// <summary>
/// Add the javascript method to redirect page on client
/// Created : Wang Hui, May 18,2006
/// Modified:
/// </summary>
/// <param name="pageCurrent"></param>
/// <param name="strPage"></param>
public static void Redirect(System.Web.UI.Page pageCurrent, string strPage)
{
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.location.href='" + strPage + "'</script>"
);
//以下方法是兼容1.1的,2.0过时
//pageCurrent.RegisterStartupScript(
// System.Guid.NewGuid().ToString(),
// "<script>window.location.href='" + strPage + "'</script>"
// );
}
/**/
/// <summary>
/// 主要用于跳出带有框架的页面
/// </summary>
/// <param name="pageCurrent">当前页面如this.page</param>
/// <param name="strPage">要跳出的页面</param>
public static void RedirectFrame(System.Web.UI.Page pageCurrent, string strPage)
{
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script>window.top.location.href='" + strPage + "'</script>"
);
//以下方法是兼容1.1的,2.0过时
//pageCurrent.RegisterStartupScript(
// System.Guid.NewGuid().ToString(),
// "<script>window.location.href='" + strPage + "'</script>"
// );
}
#endregion
#region AddConfirm
/**/
/// <summary>
/// Add the confirm message to button
/// Created : GuangMing Chu 1,1,2007
/// Modified: GuangMing Chu 1,1,2007
/// Modified: GuangMing Chu 1,1,2007
/// 代码调用:
/// UIHelper.AddConfirm(this.Button1, "真的要删了??");
/// 点确定按钮就会执行事件中的代码,点取消不会
/// </summary>
/// <param name="button">The control, must be a button</param>
/// <param name="strMsg">The popup message</param>
public static void AddConfirm(System.Web.UI.WebControls.Button button, string strMsg)
{
strMsg = strMsg.Replace("\n", "file://n/");
strMsg = strMsg.Replace("\r", "file://r/");
strMsg = strMsg.Replace("\"", "\\\"");
strMsg = strMsg.Replace("\'", "\\\'");
button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
}
/**/
/// <summary>
/// Add the confirm message to button
/// Created : GuangMing Chu, 1 1,2007
/// Modified: GuangMing Chu, 1 1,2007
/// Modified:
/// 代码调用:
/// UIHelper.AddConfirm(this.Button1, "真的要删了??");
/// 点确定按钮就会执行事件中的代码,点取消不会
///
/// </summary>
/// <param name="button">The control, must be a button</param>
/// <param name="strMsg">The popup message</param>
public static void AddConfirm(System.Web.UI.WebControls.ImageButton button, string strMsg)
{
strMsg = strMsg.Replace("\n", "file://n/");
strMsg = strMsg.Replace("\r", "file://r/");
strMsg = strMsg.Replace("\"", "\\\"");
strMsg = strMsg.Replace("\'", "\\\'");
button.Attributes.Add("onClick", "return confirm('" + strMsg + "')");
}
/**/
/// <summary>
/// Add the confirm message to one column of gridview
/// 代码调用:
/// UIHelper myHelp = new UIHelper();
/// myHelp.AddConfirm(this.GridView1,1, "ok");
/// 请使用时注意,此方法的调用必须实例化,调用
/// </summary>
/// <param name="grid">The control, must be a GridView</param>
/// <param name="intColIndex">The column index. It's usually the column which has the "delete" button.</param>
/// <param name="strMsg">The popup message</param>
public static void AddConfirm(System.Web.UI.WebControls.GridView grid, int intColIndex, string strMsg)
{
strMsg = strMsg.Replace("\n", "file://n/");
strMsg = strMsg.Replace("\r", "file://r/");
strMsg = strMsg.Replace("\"", "\\\"");
strMsg = strMsg.Replace("\'", "\\\'");
for (int i = 0; i < grid.Rows.Count; i++)
{
grid.Rows[i].Cells[intColIndex].Attributes.Add("onclick", "return confirm('" + strMsg + "')");
}
}
#endregion
#region AddShowDialog
/**/
/// <summary>
/// Add the javascript method showModalDialog to button
/// 为Button按钮加入一个弹出窗体对话框
/// 代码调用
/// UIHelper.AddShowDialog(this.Button1, "www.sina.com.cn", 300, 300);
///
///
///
/// </summary>
/// <param name="button">The control, must be a button</param>
/// <param name="strUrl">The page url, including query string</param>
/// <param name="intWidth">Width of window</param>
/// <param name="intHeight">Height of window</param>
public static void AddShowDialog(System.Web.UI.WebControls.Button button, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
strScript += "window.showModalDialog(\'" + strUrl + "\',window,strFeatures);return false;";
button.Attributes.Add("onClick", strScript);
}
#endregion
#region AddShowDialog
/**/
/// <summary>
/// Add the javascript method showModalDialog to button
/// </summary>
/// <param name="button">The control, must be a link button</param>
/// <param name="strUrl">The page url, including query string</param>
/// <param name="intWidth">Width of window</param>
/// <param name="intHeight">Height of window</param>
public static void AddShowDialog(System.Web.UI.WebControls.LinkButton button, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
strScript += "window.showModalDialog(\'" + strUrl + "\',strName,strFeatures);return false;";
button.Attributes.Add("onClick", strScript);
}
#endregion
#region AddShowDialog
/**/
/// <summary>
/// Add the javascript method showModalDialog to button
/// </summary>
/// <param name="button">The control, must be a button</param>
/// <param name="strUrl">The page url, including query string</param>
/// <param name="intWidth">Width of window</param>
/// <param name="intHeight">Height of window</param>
public static void AddShowDialog(System.Web.UI.WebControls.ImageButton button, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
strScript += "window.showModalDialog(\'" + strUrl + "\',window,strFeatures);return false;";
button.Attributes.Add("onClick", strScript);
}
#endregion
#region ClearTextBox
/**/
/// <summary>
/// 将选定的TextBox值清空
/// </summary>
/// <param name="myTextBox"></param>
public static void ClearTextBox(System.Web.UI.WebControls.TextBox myTextBox)
{
myTextBox.Attributes.Add("onclick", "this.value=''");
}
#endregion
#region OpenWindow
/**/
/// <summary>
/// Use "window.open" to popup the window
/// Created : Wang Hui, Feb 24,2006
/// Modified: Wang Hui, Feb 24,2006
/// 打开窗体的对话框功能
/// 代码调用:
///
///
/// UIHelper.OpenWindow(this.Page, "www.sina.com.cn", 400, 300);
/// UIHelper.ShowDialog(this.Page, "lsdjf.com", 300, 200);
///
///
///
/// </summary>
/// <param name="strUrl">The url of window, start with "/", not "http://"</param>
/// <param name="intWidth">Width of popup window</param>
/// <param name="intHeight">Height of popup window</param>
public static void OpenWindow(System.Web.UI.Page pageCurrent, string strUrl, int intWidth, int intHeight, int intLeft, int intTop, string WinName)
{
#region 老版本
//string strScript = "";
//strScript += "var strFeatures = 'width:" + intWidth.ToString() + "px;height:" + intHeight.ToString() + "px';";
//strScript += "var strName ='__WIN';";
/**/
////strScript += "alert(strFeatures);";
////--- Add by Wang Hui on Feb 27
//if (strUrl.Substring(0, 1) == "/")
//{
// strUrl = strUrl.Substring(1, strUrl.Length - 1);
//}
/**/
////--- End Add by Wang Hui on Feb 27
//strUrl = BaseUrl + strUrl;
//strScript += "window.open(\"" + strUrl + "\",strName,strFeatures);";
//pageCurrent.RegisterStartupScript(
// System.Guid.NewGuid().ToString(),
// "<script language='javascript'>" + strScript + "</script>"
// );
//pageCurrent.RegisterStartupScript(
// System.Guid.NewGuid().ToString(),
// "<script language='javascript'>" + strScript + "</script>"
// );
#endregion
StringBuilder sb = new StringBuilder();
sb.AppendFormat(@"myleft={0};mytop={1};", intLeft.ToString(), intTop.ToString());
sb.AppendLine();
sb.AppendFormat(@"settings='top=' + mytop + ',left=' + myleft + ',width={0},height={1},location=no,directories=no,menubar=no,toolbar=no,status=no,scrollbars=no,resizable=no,fullscreen=no';",
intWidth.ToString(), intHeight.ToString());
sb.AppendLine();
sb.AppendFormat(@"window.open('{0}','{1}', settings);", strUrl, WinName);
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(),
"<script language='javascript'>" + sb.ToString() + "</script>"
);
}
#endregion
#region ShowDialog
/**/
/// <summary>
/// Use "window.showModalDialog" to show the dialog
/// Created : Wang Hui, Feb 24,2006
/// Modified: Wang Hui, Feb 27,2006
/// 此窗体是模式窗体,和C/S结构中的模式窗体是一致的
/// </summary>
/// <param name="strUrl">The url of dialog, start with "/", not "http://"</param>
/// <param name="intWidth">Width of dialog</param>
/// <param name="intHeight">Height of dialog</param>
public static void ShowDialog(System.Web.UI.Page pageCurrent, string strUrl, int intWidth, int intHeight)
{
string strScript = "";
strScript += "var strFeatures = 'dialogWidth=" + intWidth.ToString() + "px;dialogHeight=" + intHeight.ToString() + "px;center=yes;help=no;status=no';";
strScript += "var strName ='';";
//--- Add by Wang Hui on Feb 27
if (strUrl.Substring(0, 1) == "/")
{
strUrl = strUrl.Substring(1, strUrl.Length - 1);
}
//--- End Add by Wang Hui on Feb 27
strUrl = BaseUrl + "DialogFrame.aspx?URL=" + strUrl;
//strScript += "window.showModalDialog(\"" + strUrl + "\",strName,strFeatures);";
strScript += "window.showModalDialog(\"" + strUrl + "\",window,strFeatures); ";
pageCurrent.ClientScript.RegisterStartupScript(
pageCurrent.GetType(), System.Guid.NewGuid().ToString(),
"<script language='javascript'>" + strScript + "</script>"
);
}
#endregion
#region CloseWindows
/**/
/// <summary>
/// 关闭窗体,没有任何提示的关闭窗体
/// </summary>
/// <param name="pageCurrent"></param>
public static void CloseWindows(System.Web.UI.Page pageCurrent)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script>window.opener=null;window.close();</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
/**/
/// <summary>
/// 有提示信息的关闭窗体
/// </summary>
/// <param name="pageCurrent"></param>
/// <returns></returns>
public static void CloseWindows(System.Web.UI.Page pageCurrent, string strMessage)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script>if(confirm(\"" + strMessage + "\")==true){window.close();}</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
/**/
/// <summary>
/// 有等待时间的关闭窗体
/// </summary>
/// <param name="pageCurrent"></param>
/// <param name="WaitTime">等待时间,以毫秒为记量单位</param>
public static void CloseWindows(System.Web.UI.Page pageCurrent, int WaitTime)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">");
//加入此行功能后没有提提示功能
sb.Append("window.opener=null;");
sb.Append("setTimeout");
sb.Append("(");
sb.Append("'");
sb.Append("window.close()");
sb.Append("'");
sb.Append(",");
sb.Append(WaitTime.ToString());
sb.Append(")");
sb.Append("</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
#endregion
#region ShowStatusBar
public static void ShowStatus(System.Web.UI.Page pageCurrent, string StatusString)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">");
sb.Append("window.status=");
sb.Append("\"");
sb.Append(StatusString);
sb.Append("\"");
sb.Append("</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
#endregion
#region PlayMediaFile
/**/
/// <summary>
/// 调用Media播放mp3或电影文件
/// </summary>
/// <param name="pageCurrent">
/// 当前的页面对象
/// </param>
/// <param name="PlayFilePath">
/// 播放文件的位置
/// </param>
/// <param name="MediajavascriptPath">
/// Mediajavascript的脚本位置
/// </param>
/// <param name="enableContextMenu">
/// 是否可以使用右键
/// 指定是否使右键菜单有效
/// 指定右键是否好用,默认为0不好用
/// 指定为1时就是好用
/// </param>
/// <param name="uiMode">
/// 播放器的大小显示
/// None,mini,或full,指定Windows媒体播放器控制如何显示
/// </param>
public static string PlayMediaFile(System.Web.UI.Page pageCurrent,
string PlayFilePath, string MediajavascriptPath,
string enableContextMenu, string uiMode)
{
StreamReader sr = new StreamReader(pageCurrent.MapPath(MediajavascriptPath));
StringBuilder sb = new StringBuilder();
string line;
try
{
while ((line = sr.ReadLine()) != null)
{
sb.AppendLine(line);
}
sr.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
sb.Replace("$URL", pageCurrent.MapPath(PlayFilePath));
sb.Replace("$enableContextMenu", enableContextMenu);
sb.Replace("$uiMode", uiMode);
//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
// System.Guid.NewGuid().ToString(), sb.ToString());
return sb.ToString();
}
#endregion
#region ShowProgBar
/**/
/// <summary>
/// 主要实现进度条的功能,这段代码的调用就要实现进度的调度
/// 实现主要过程
/// default.aspx.cs是调用页面
/// 放入page_load事件中
/// UIHelper myUI = new UIHelper();
/// Response.Write(myUI.ShowProgBar(this.Page,"../script/progressbar.htm"));
/// Thread thread = new Thread(new ThreadStart(ThreadProc));
/// thread.Start();
/// LoadData();//load数据
/// thread.Join();
/// Response.Write("OK");
///
/// 其中ThreadProc方法为
/// public void ThreadProc()
/// {
/// string strScript = "<script>setPgb('pgbMain','{0}');</script>";
/// for (int i = 0; i <= 100; i++)
/// {
/// System.Threading.Thread.Sleep(10);
/// Response.Write(string.Format(strScript, i));
/// Response.Flush();
/// }
/// }
/// 其中LoadData()
/// public void LoadData()
/// {
/// for (int m = 0; m < 900; m++)
/// {
/// for (int i = 0; i < 900; i++)
/// {
///
/// }
/// }
/// }
///
/// </summary>
/// <param name="pageCurrent"></param>
/// <param name="ShowProgbarScript"></param>
/// <returns></returns>
public static string ShowProgBar(System.Web.UI.Page pageCurrent, string ShowProgbarScript)
{
StreamReader sr = new StreamReader(pageCurrent.MapPath(ShowProgbarScript), System.Text.Encoding.Default);
StringBuilder sb = new StringBuilder();
string line;
try
{
while ((line = sr.ReadLine()) != null)
{
sb.AppendLine(line);
}
sr.Close();
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
//pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
// System.Guid.NewGuid().ToString(), sb.ToString());
return sb.ToString();
}
#endregion
#region fixedHeader
public static string fixedHeader()
{
StringBuilder s = new StringBuilder();
s.Append(@"<table width='100%' border='1' cellspacing='0' style='MARGIN-TOP:-2px'>");
s.Append(@"<TR class='fixedHeaderTr' style='BACKGROUND:navy;COLOR:white'>");
s.Append(@"<TD nowrap>Header A</TD>");
s.Append(@"<TD nowrap>Header B</TD>");
s.Append(@"<TD nowrap>Header C</TD>");
s.Append(@"</TR>");
for (int m = 0; m < 100; m++)
{
s.Append(@"<TR>");
s.Append(@"<TD>A").Append(m).Append("</TD>");
s.Append(@"<TD>B").Append(m).Append("</TD>");
s.Append(@"<TD>C").Append(m).Append("</TD>");
s.Append(@"</TR>");
}
s.Append(@"</table>");
return s.ToString();
}
#endregion
#region refreshPage
public static void refreshPage(System.Web.UI.Page pageCurrent)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">");
sb.Append("window.location.reload(true);");
sb.Append("</script>");
pageCurrent.ClientScript.RegisterStartupScript(pageCurrent.GetType(),
System.Guid.NewGuid().ToString(), sb.ToString());
}
#endregion
#region Page_revealTrans
//进入页面<meta http-equiv="Page-Enter" content="revealTrans(duration=x, transition=y)">
//推出页面<meta http-equiv="Page-Exit" content="revealTrans(duration=x, transition=y)">
//这个是页面被载入和调出时的一些特效。duration表示特效的持续时间,以秒为单位。transition表示使用哪种特效,取值为1-23:
// 0 矩形缩小
// 1 矩形扩大
// 2 圆形缩小
// 3 圆形扩大
// 4 下到上刷新
// 5 上到下刷新
// 6 左到右刷新
// 7 右到左刷新
// 8 竖百叶窗
// 9 横百叶窗
// 10 错位横百叶窗
// 11 错位竖百叶窗
// 12 点扩散
// 13 左右到中间刷新
// 14 中间到左右刷新
// 15 中间到上下
// 16 上下到中间
// 17 右下到左上
// 18 右上到左下
// 19 左上到右下
// 20 左下到右上
// 21 横条
// 22 竖条
// 23 以上22种随机选择一种
public static string Page_revealTrans(System.Web.UI.Page currentPage, string duration,
string transition)
{
StringBuilder sb = new StringBuilder();
sb.Append("<meta http-equiv=\"Page-Enter\"");
sb.Append("content=\"");
sb.Append("revealTrans(duration=" + duration);
sb.Append(",transition=" + transition);
sb.Append(")\">");
//currentPage.ClientScript.RegisterStartupScript(currentPage.GetType(),
// System.Guid.NewGuid().ToString(), sb.ToString());
return sb.ToString();
}
#endregion
/// <summary>
/// 显示一段自定义的输出代码
/// </summary>
/// <param name="page">页面指针,一般为This</param>
public static void ResponseScript(System.Web.UI.Page page, string script)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append(script.Trim());
sb.Append("</script>");
page.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 调用客户端JavaScript函数
/// </summary>
/// <param name="page">页面指针,一般为This</param>
/// <param name="scriptName">函数名,带参数,如:FunA(1);</param>
public static void CallClientScript(System.Web.UI.Page page, string scriptName)
{
String csname = "PopupScript";
Type cstype = page.GetType();
System.Web.UI.ClientScriptManager cs = page.ClientScript;
if (!cs.IsStartupScriptRegistered(cstype, csname))
{
String cstext = scriptName;
cs.RegisterStartupScript(cstype, csname, cstext, true);
}
}
/**/
/// <summary>
/// 弹出对话框(弹出对话框后css会失效)
/// </summary>
/// <param name="message">提示信息</param>
public static void ShowMessage(string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 弹出对话框(不影响css样式)
/// </summary>
/// <param name="page">页面指针,一般为this</param>
/// <param name="scriptKey">脚本键,唯一</param>
/// <param name="message">提示信息</param>
public static void ShowMessage(System.Web.UI.Page page, string scriptKey, string message)
{
System.Web.UI.ClientScriptManager csm = page.ClientScript;
if (!csm.IsClientScriptBlockRegistered(scriptKey))
{
string strScript = "alert('" + message + "');";
csm.RegisterClientScriptBlock(page.GetType(), scriptKey, strScript, true);
}
}
/**/
/// <summary>
/// 为控件添加确认提示对话框
/// </summary>
/// <param name="Control">需要添加提示的对话框</param>
/// <param name="message">提示信息</param>
public static void ShowConfirm(System.Web.UI.WebControls.WebControl Control, string message)
{
Control.Attributes.Add("onclick", "return confirm('" + message + "');");
}
/**/
/**/
/**/
/// <summary>
/// 显示一个弹出窗口,并转向目标页(导航)
/// </summary>
public static void ShowAndRedirect(string message, string url)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("window.location.href=\"" + url.Trim().Replace("'", "") + "\";\n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 显示一个弹出窗口,重新加载当前页
/// </summary>
public static void ShowAndReLoad(string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("window.location.href=window.location.href;\n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 显示一个弹出窗口,刷新当前页(危险的,有可能陷入死循环)
/// </summary>
public static void ShowAndRefresh(string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("document.execCommand('Refresh')");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 显示一个弹出窗口,并关闭当前页
/// </summary>
/// <param name="message"></param>
public static void ShowAndClose(string message)
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append("<script language=\"javascript\">\n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("window.close();\n");
sb.Append("</script>\n");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 显示一个弹出窗口,并转向上一页
/// </summary>
/// <param name="message"></param>
public static void ShowPre(string message)
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("alert(\"" + message.Trim() + "\"); \n");
sb.Append("var p=document.referrer; \n");
sb.Append("window.location.href=p;\n");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 页面重载
/// </summary>
public static void ReLoad()
{
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append("window.location.href=window.location.href;");
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
/**/
/// <summary>
/// 重定向
/// </summary>
public static void Redirect(string url)
{
//string path = "http://" + System.Web.HttpContext.Current.Request.Url.Host + ":" + System.Web.HttpContext.Current.Request.Url.Port + url;
string path = "http://" + System.Web.HttpContext.Current.Request.Url.Host + url;
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\"> \n");
sb.Append(string.Format("window.location.href='{0}';", @path.Replace("'", "")));
sb.Append("</script>");
System.Web.HttpContext.Current.Response.Write(sb.ToString());
}
#region 我的工具
/// <summary>
/// 注册脚本到页面最未端。
/// </summary>
/// <param name="page"></param>
/// <param name="strScript"></param>
public static void RegistScriptAtPageLast(Page page, string strScript)
{
System.Web.UI.HtmlControls.HtmlGenericControl js = new System.Web.UI.HtmlControls.HtmlGenericControl();
js.TagName="script";
js.Attributes.Add("type", "text/javascript");
js.InnerHtml = strScript;
page.Controls.Add(js);
}
#endregion
}
} | 10aaa-10aaa | trunk/TRECommerce/TRECommon/Script/ScriptUtils.cs | C# | oos | 41,090 |
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("TRECommon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("FORDIO")]
[assembly: AssemblyProduct("TRECommon")]
[assembly: AssemblyCopyright("Copyright © FORDIO 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("3dd27aae-11aa-4432-9605-0a314e117e85")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 内部版本号
// 修订号
//
// 可以指定所有这些值,也可以使用“内部版本号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Properties/AssemblyInfo.cs | C# | oos | 1,362 |
//======================================================================
// 组织名: Troopsen
// 命名空间名称: Utils
// 文件名: StringOperation
// 创建人: Troopsen
// 创建时间: 2011/3/10 8:39:00
//======================================================================
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Collections;
namespace TRECommon
{
public class StringOperation
{
//正则表达式
//回车 换行 正则
private static Regex RegexBr = new Regex("@(\r\n)",RegexOptions.IgnoreCase);
#region 长度
/// <summary>
/// 返回字符串真实长度 1英文=1 1中文=2
/// </summary>
/// <param name="str">要判断的字符串</param>
/// <returns>返回长度(int)</returns>
public static int GetStringLength(string str)
{
if (str == string.Empty || str == null || str=="")
return 0;
else
return System.Text.Encoding.Default.GetBytes(str).Length;
}
/// <summary>
/// 获取 不包括 回车 空格 换行 字符串长度
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static int GetNoBRTrimStringLength(string str)
{
return GetStringLength(HTMLUtils.RTrim(str));
}
/// <summary>
/// 获取 不包括 回车 换行 字符串长度
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static int GetNoBRStringLength(string str)
{
return GetStringLength(HTMLUtils.ClearBR(str));
}
/// <summary>
/// 获取 不包括 空格的字符串长度
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static int GetNoTrimStringLength(string str)
{
return GetStringLength(str.Trim());
}
#endregion
#region 是否存在
//==================字符串======================================
public static bool InString(string strSearch,string strSource)
{
return strSource.Contains(strSearch);
}
//==================数组======================================
/// <summary>
/// 判断指定字符串是否属于指定字符串数组中的一个元素
/// </summary>
/// <param name="strSearch">字符串</param>
/// <param name="stringArray">字符串数组</param>
/// <param name="caseInsensetive">是否不区分大小写, true为不区分, false为区分</param>
/// <returns>判断结果</returns>
public static bool InArray(string strSearch, string[] stringArray, bool caseInsensetive)
{
return GetInArrayID(strSearch, stringArray, caseInsensetive) >= 0;
}
/// <summary>
/// 判断指定字符串是否属于指定字符串数组中的一个元素
/// </summary>
/// <param name="str">字符串</param>
/// <param name="stringarray">字符串数组</param>
/// <returns>判断结果</returns>
public static bool InArray(string str, string[] stringarray)
{
return InArray(str, stringarray, false);
}
/// <summary>
/// 判断指定字符串是否属于指定字符串数组中的一个元素
/// </summary>
/// <param name="str">字符串</param>
/// <param name="stringarray">内部以逗号分割单词的字符串</param>
/// <returns>判断结果</returns>
public static bool InArray(string str, string stringarray)
{
return InArray(str, SplitString(stringarray, ","), false);
}
/// <summary>
/// 判断指定字符串是否属于指定字符串数组中的一个元素
/// </summary>
/// <param name="str">字符串</param>
/// <param name="stringarray">内部以逗号分割单词的字符串</param>
/// <param name="strsplit">分割字符串</param>
/// <returns>判断结果</returns>
public static bool InArray(string str, string stringarray, string strsplit)
{
return InArray(str, SplitString(stringarray, strsplit), false);
}
/// <summary>
/// 判断指定字符串是否属于指定字符串数组中的一个元素
/// </summary>
/// <param name="str">字符串</param>
/// <param name="stringarray">内部以逗号分割单词的字符串</param>
/// <param name="strsplit">分割字符串</param>
/// <param name="caseInsensetive">是否不区分大小写, true为不区分, false为区分</param>
/// <returns>判断结果</returns>
public static bool InArray(string str, string stringarray, string strsplit, bool caseInsensetive)
{
return InArray(str, SplitString(stringarray, strsplit), caseInsensetive);
}
#endregion
#region 判断位置
//=================数组========================
/// <summary>
/// 判断指定字符串在指定字符串数组中的位置
/// </summary>
/// <param name="strSearch">字符串</param>
/// <param name="stringArray">字符串数组</param>
/// <param name="caseInsensetive">是否不区分大小写, true为不区分, false为区分</param>
/// <returns>字符串在指定字符串数组中的位置, 如不存在则返回-1</returns>
public static int GetInArrayID(string strSearch, string[] stringArray, bool caseInsensetive)
{
for (int i = 0; i < stringArray.Length; i++)
{
if (caseInsensetive)
{
if (strSearch.ToLower() == stringArray[i].ToLower())
return i;
}
else if (strSearch == stringArray[i])
return i;
}
return -1;
}
/// <summary>
/// 判断指定字符串在指定字符串数组中的位置
/// </summary>
/// <param name="strSearch">字符串</param>
/// <param name="stringArray">字符串数组</param>
/// <returns>字符串在指定字符串数组中的位置, 如不存在则返回-1</returns>
public static int GetInArrayID(string strSearch, string[] stringArray)
{
return GetInArrayID(strSearch, stringArray, true);
}
/// <summary>
/// 去除数组中重复的记录并排序
/// </summary>
/// <param name="array">数组</param>
/// <param name="orderByType">排序方式</param>
/// <returns>处理后的数组</returns>
public static string[] SortAndDdistinct(string[] array, OrderByType orderByType)
{
List<String> result = new List<string>();
string[] newArray = array;
bool isChange = false; //本次循环是否排序过
int j = 0; //排序循环叠加变量
if (OrderByType.ASC == orderByType) //升序
{
for (int i = 0; i < newArray.Length; i++)
{
isChange = false;
for (; j < newArray.Length - 1 - i; j++)
{
if (newArray[j].CompareTo(newArray[j + 1]) > 0) //每次将相对较小大的值放在后面
{
string swap = newArray[j];
newArray[j] = newArray[j + 1];
newArray[j + 1] = swap;
//排序过
isChange = true;
}
}
string value = newArray[newArray.Length - 1 - i];
if (!result.Contains(value)) //如果集合中未包含该元素,则添加
result.Add(value);
//判断是否继续排直接序操作
//如果上次操作未排,则下次不再排序,直接去重复
j = isChange ? 0 : newArray.Length;
}
}
else //降序
{
for (int i = 0; i < newArray.Length; i++)
{
isChange = false;
for (; j < newArray.Length - 1 - i; j++)
{
if (newArray[j].CompareTo(newArray[j + 1]) < 0) //每次将相对较的值放在后面
{
string swap = newArray[j];
newArray[j] = newArray[j + 1];
newArray[j + 1] = swap;
//排序过
isChange = true;
}
}
string value = newArray[newArray.Length - 1 - i];
if (!result.Contains(value)) //如果集合中未包含该元素,则添加
result.Add(value);
//判断是否继续排直接序操作
//如果上次操作未排,则下次不再排序,直接去重复
j = isChange ? 0 : newArray.Length;
}
}
return result.ToArray();
}
/// <summary>
/// 排序方式
/// </summary>
public enum OrderByType
{
ASC, DESC
}
#endregion
#region 载取
/// <summary>
/// 从字符串的指定位置截取指定长度的子字符串
/// </summary>
/// <param name="str"></param>
/// <param name="startIndex">开始位置</param>
/// <param name="length">载取长度</param>
/// <returns></returns>
public static string CutString(string str, int startIndex, int length)
{
if (startIndex >= 0)
{
// 如果载取长度为负数 则从开始位置往左计算载取长度 否则 从指定位置往右计算长度
if (length < 0)
{
length = length * -1;
if (startIndex - length < 0)
{
length = startIndex;
startIndex = 0;
}
else
{
startIndex = startIndex - length;
}
}
if (startIndex > str.Length)
return "";
}
else
{
if (length < 0)
return "";
else
{
if (length + startIndex > 0)
{
length = startIndex + length;
startIndex = 0;
}
else
return "";
}
}
if(str.Length-startIndex<length)
length = str.Length - startIndex;
return str.Substring(startIndex, length);
}
/// <summary>
/// 载取字符串 从指定开始位置载取到结尾
/// </summary>
/// <param name="str"></param>
/// <param name="startIndex"></param>
/// <returns></returns>
public static string CutString(string str, int startIndex)
{
return CutString(str, startIndex, str.Length);
}
/// <summary>
/// 从指定位置载取字符串
/// </summary>
/// <param name="p_SrcString"></param>
/// <param name="p_StartIndex"></param>
/// <param name="p_Length"></param>
/// <param name="p_TailString"></param>
/// <returns></returns>
public static string GetSubString(string p_SrcString, int p_StartIndex, int p_Length, string p_TailString)
{
string myResult = p_SrcString;
Byte[] bComments = Encoding.UTF8.GetBytes(p_SrcString);
foreach (char c in Encoding.UTF8.GetChars(bComments))
{ //当是日文或韩文时(注:中文的范围:\u4e00 - \u9fa5, 日文在\u0800 - \u4e00, 韩文为\xAC00-\xD7A3)
if ((c > '\u0800' && c < '\u4e00') || (c > '\xAC00' && c < '\xD7A3'))
{
//if (System.Text.RegularExpressions.Regex.IsMatch(p_SrcString, "[\u0800-\u4e00]+") || System.Text.RegularExpressions.Regex.IsMatch(p_SrcString, "[\xAC00-\xD7A3]+"))
//当截取的起始位置超出字段串长度时
if (p_StartIndex >= p_SrcString.Length)
return "";
else
return p_SrcString.Substring(p_StartIndex,
((p_Length + p_StartIndex) > p_SrcString.Length) ? (p_SrcString.Length - p_StartIndex) : p_Length);
}
}
if (p_Length >= 0)
{
byte[] bsSrcString = Encoding.Default.GetBytes(p_SrcString);
//当字符串长度大于起始位置
if (bsSrcString.Length > p_StartIndex)
{
int p_EndIndex = bsSrcString.Length;
//当要截取的长度在字符串的有效长度范围内
if (bsSrcString.Length > (p_StartIndex + p_Length))
{
p_EndIndex = p_Length + p_StartIndex;
}
else
{ //当不在有效范围内时,只取到字符串的结尾
p_Length = bsSrcString.Length - p_StartIndex;
p_TailString = "";
}
int nRealLength = p_Length;
int[] anResultFlag = new int[p_Length];
byte[] bsResult = null;
int nFlag = 0;
for (int i = p_StartIndex; i < p_EndIndex; i++)
{
if (bsSrcString[i] > 127)
{
nFlag++;
if (nFlag == 3)
nFlag = 1;
}
else
nFlag = 0;
anResultFlag[i] = nFlag;
}
if ((bsSrcString[p_EndIndex - 1] > 127) && (anResultFlag[p_Length - 1] == 1))
nRealLength = p_Length + 1;
bsResult = new byte[nRealLength];
Array.Copy(bsSrcString, p_StartIndex, bsResult, 0, nRealLength);
myResult = Encoding.Default.GetString(bsResult);
myResult = myResult + p_TailString;
}
}
return myResult;
}
/// <summary>
/// 字符串如果操过指定长度则将超出的部分用指定字符串代替
/// </summary>
/// <param name="p_SrcString">要检查的字符串</param>
/// <param name="p_Length">指定长度</param>
/// <param name="p_TailString">用于替换的字符串</param>
/// <returns>截取后的字符串</returns>
public static string GetSubString(string p_SrcString, int p_Length, string p_TailString)
{
return GetSubString(p_SrcString, 0, p_Length, p_TailString);
}
public static string GetUnicodeSubString(string str, int len, string p_TailString)
{
string result = string.Empty;// 最终返回的结果
int byteLen = System.Text.Encoding.Default.GetByteCount(str);// 单字节字符长度
int charLen = str.Length;// 把字符平等对待时的字符串长度
int byteCount = 0;// 记录读取进度
int pos = 0;// 记录截取位置
if (byteLen > len)
{
for (int i = 0; i < charLen; i++)
{
if (Convert.ToInt32(str.ToCharArray()[i]) > 255)// 按中文字符计算加2
byteCount += 2;
else// 按英文字符计算加1
byteCount += 1;
if (byteCount > len)// 超出时只记下上一个有效位置
{
pos = i;
break;
}
else if (byteCount == len)// 记下当前位置
{
pos = i + 1;
break;
}
}
if (pos >= 0)
result = str.Substring(0, pos) + p_TailString;
}
else
result = str;
return result;
}
#endregion
#region 替换
/// <summary>
/// 自定义的替换字符串函数
/// </summary>
public static string ReplaceString(string SourceString, string SearchString, string ReplaceString, bool IsCaseInsensetive)
{
return Regex.Replace(SourceString, Regex.Escape(SearchString), ReplaceString, IsCaseInsensetive ? RegexOptions.IgnoreCase : RegexOptions.None);
}
#endregion
#region 分割
/// <summary>
/// 分割自符串
/// </summary>
/// <param name="strContent"></param>
/// <param name="strSplit"></param>
/// <returns></returns>
public static string[] SplitString(string strContent, string strSplit)
{
if (!Validator.StrIsNullOrEmpty(strContent))
{
if (strContent.IndexOf(strSplit) < 0)
return new string[] { strContent };
return Regex.Split(strContent, Regex.Escape(strSplit), RegexOptions.IgnoreCase);
}
else
{
return new string[0] { };
}
}
/// <summary>
/// 分割字符串
/// </summary>
/// <returns></returns>
public static string[] SplitString(string strContent, string strSplit, int count)
{
string[] result = new string[count];
string[] splited = SplitString(strContent, strSplit);
for (int i = 0; i < count; i++)
{
if (i < splited.Length)
result[i] = splited[i];
else
result[i] = string.Empty;
}
return result;
}
/// <summary>
/// 过滤字符串数组中每个元素为合适的大小
/// 当长度小于minLength时,忽略掉,-1为不限制最小长度
/// 当长度大于maxLength时,取其前maxLength位
/// 如果数组中有null元素,会被忽略掉
/// </summary>
/// <param name="minLength">单个元素最小长度</param>
/// <param name="maxLength">单个元素最大长度</param>
/// <returns></returns>
public static string[] PadStringArray(string[] strArray, int minLength, int maxLength)
{
if (minLength > maxLength)
{
int t = maxLength;
maxLength = minLength;
minLength = t;
}
int iMiniStringCount = 0;
for (int i = 0; i < strArray.Length; i++)
{
if (minLength > -1 && strArray[i].Length < minLength)
{
strArray[i] = null;
continue;
}
if (strArray[i].Length > maxLength)
strArray[i] = strArray[i].Substring(0, maxLength);
iMiniStringCount++;
}
string[] result = new string[iMiniStringCount];
for (int i = 0, j = 0; i < strArray.Length && j < result.Length; i++)
{
if (strArray[i] != null && strArray[i] != string.Empty)
{
result[j] = strArray[i];
j++;
}
}
return result;
}
/// <summary>
/// 分割字符串
/// </summary>
/// <param name="strContent">被分割的字符串</param>
/// <param name="strSplit">分割符</param>
/// <param name="ignoreRepeatItem">忽略重复项</param>
/// <param name="maxElementLength">单个元素最大长度</param>
/// <returns></returns>
public static string[] SplitString(string strContent, string strSplit, bool ignoreRepeatItem, int maxElementLength)
{
string[] result = SplitString(strContent, strSplit);
return ignoreRepeatItem ? DistinctStringArray(result, maxElementLength) : result;
}
public static string[] SplitString(string strContent, string strSplit, bool ignoreRepeatItem, int minElementLength, int maxElementLength)
{
string[] result = SplitString(strContent, strSplit);
if (ignoreRepeatItem)
{
result = DistinctStringArray(result);
}
return PadStringArray(result, minElementLength, maxElementLength);
}
/// <summary>
/// 分割字符串
/// </summary>
/// <param name="strContent">被分割的字符串</param>
/// <param name="strSplit">分割符</param>
/// <param name="ignoreRepeatItem">忽略重复项</param>
/// <returns></returns>
public static string[] SplitString(string strContent, string strSplit, bool ignoreRepeatItem)
{
return SplitString(strContent, strSplit, ignoreRepeatItem, 0);
}
#endregion
#region 生成
/// <summary>
/// 生成指定数量的html空格符号
/// </summary>
public static string GetStrString(int spacesCount,string str)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < spacesCount; i++)
{
sb.Append(str);
}
return sb.ToString();
}
/// <summary>
/// 生成指定长度的字符串,即生成strLong个str字符串
/// </summary>
/// <param name="strLong">生成的长度</param>
/// <param name="str">以str生成字符串</param>
/// <returns></returns>
public static string StringOfChar(int strLong, string str)
{
string ReturnStr = "";
for (int i = 0; i < strLong; i++)
{
ReturnStr += str;
}
return ReturnStr;
}
#endregion
#region 清空/移除
#endregion
#region 删除重复项
/// <summary>
/// 清除字符串数组中的重复项
/// </summary>
/// <param name="strArray">字符串数组</param>
/// <param name="maxElementLength">字符串数组中单个元素的最大长度</param>
/// <returns></returns>
public static string[] DistinctStringArray(string[] strArray, int maxElementLength)
{
Hashtable h = new Hashtable();
foreach (string s in strArray)
{
string k = s;
if (maxElementLength > 0 && k.Length > maxElementLength)
{
k = k.Substring(0, maxElementLength);
}
h[k.Trim()] = s;
}
string[] result = new string[h.Count];
h.Keys.CopyTo(result, 0);
return result;
}
/// <summary>
/// 清除字符串数组中的重复项
/// </summary>
/// <param name="strArray">字符串数组</param>
/// <returns></returns>
public static string[] DistinctStringArray(string[] strArray)
{
return DistinctStringArray(strArray, 0);
}
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/String/StringOperation.cs | C# | oos | 25,170 |
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
using Microsoft.VisualBasic;
using System.Security.Cryptography;
using System.Web;
namespace TRECommon
{
public class HTMLUtils
{
//回车 换行 正则
private static Regex RegexBr = new Regex("@(\r\n)", RegexOptions.IgnoreCase);
/// <summary>
/// 生成指定数量的html空格符号
/// </summary>
public static string GetSpacesString(int spacesCount)
{
StringBuilder sb = new StringBuilder();
for (int i = 0; i < spacesCount; i++)
{
sb.Append(" ");
}
return sb.ToString();
}
/// <summary>
/// 替换回车换行符为html换行符
/// </summary>
public static string StrFormat(string str)
{
string str2;
if (str == null)
{
str2 = "";
}
else
{
str = str.Replace("\r\n", "<br />");
str = str.Replace("\n", "<br />");
str2 = str;
}
return str2;
}
/// <summary>
/// 转换为简体中文
/// </summary>
public static string ToSChinese(string str)
{
return Strings.StrConv(str, VbStrConv.SimplifiedChinese, 0);
}
/// <summary>
/// 转换为繁体中文
/// </summary>
public static string ToTChinese(string str)
{
return Strings.StrConv(str, VbStrConv.TraditionalChinese, 0);
}
/// <summary>
/// 返回 HTML 字符串的编码结果
/// </summary>
/// <param name="str">字符串</param>
/// <returns>编码结果</returns>
public static string HtmlEncode(string str)
{
return HttpUtility.HtmlEncode(str);
}
/// <summary>
/// 返回 HTML 字符串的解码结果
/// </summary>
/// <param name="str">字符串</param>
/// <returns>解码结果</returns>
public static string HtmlDecode(string str)
{
return HttpUtility.HtmlDecode(str);
}
/// <summary>
/// 移除 字符中的 空格 回车 换行
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string RTrim(string str)
{
for (int i = str.Length; i >= 0; i--)
{
if (str[i].Equals(" ") || str[i].Equals("\r") || str[i].Equals("\n"))
{
str.Remove(i);
}
}
return str;
}
/// <summary>
/// 移除 回车 换行
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string ClearBR(string str)
{
Match m = null;
for (m = RegexBr.Match(str); m.Success; m = m.NextMatch())
{
str = str.Replace(m.Groups[0].ToString(), "");
}
return str;
}
/// <summary>
/// 从HTML中获取文本,保留br,p,img
/// </summary>
/// <param name="HTML"></param>
/// <returns></returns>
public static string GetTextFromHTML(string HTML)
{
System.Text.RegularExpressions.Regex regEx = new System.Text.RegularExpressions.Regex(@"</?(?!br|/?p|img)[^>]*>", System.Text.RegularExpressions.RegexOptions.IgnoreCase);
return regEx.Replace(HTML, "");
}
/// <summary>
/// 将HTML去除
/// </summary>
/// <param name="HTML"></param>
/// <returns></returns>
public static string GetAllTextFromHTML(string Htmlstring)//将HTML去除
{
if (string.IsNullOrEmpty(Htmlstring))
return "";
#region
//删除脚本
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"<script[^>]*?>.*?</script>","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//删除HTML
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"<(.[^>]*)>","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"([/r/n])[/s]+","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"-->","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"<!--.*","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
//Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"<A>.*</A>","");
//Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"<[a-zA-Z]*=/.[a-zA-Z]*/?[a-zA-Z]+=/d&/w=%[a-zA-Z]*|[A-Z0-9]","");
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(quot|#34);","/",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(amp|#38);","&",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(lt|#60);","<",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(gt|#62);",">",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(nbsp|#160);"," ",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(iexcl|#161);","/xa1",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring = System.Text.RegularExpressions.Regex.Replace(Htmlstring,@"&(cent|#162);","/xa2",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(pound|#163);","/xa3",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring,@"&(copy|#169);","/xa9",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring =System.Text.RegularExpressions. Regex.Replace(Htmlstring, @"&#(/d+);","",System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Htmlstring.Replace("<","");
Htmlstring.Replace(">","");
Htmlstring.Replace("/r/n","");
//Htmlstring=HttpContext.Current.Server.HtmlEncode(Htmlstring).Trim();
#endregion
return Htmlstring;
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Html/HtmlUtils.cs | C# | oos | 7,318 |
//======================================================================
// 组织名: Troopsen
// 命名空间名称: Utils
// 文件名: TypeConverts
// 创建人: Troopsen
// 创建时间: 2011/3/10 9:39:00
//======================================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration;
using System.Text.RegularExpressions;
using System.Text;
using System.Drawing;
namespace TRECommon
{
public class TypeConverter
{
#region ToString
/// <summary>
/// 将对象转换为 String
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ObjToStr(object obj)
{
return obj.ToString();
}
/// <summary>
/// 将Int 转换为 string
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static string IntToStr(int value)
{
return ObjToStr(value);
}
/// <summary>
/// 将Bool 转换为 string 英文 'true','false'
/// </summary>
/// <param name="bol"></param>
/// <returns></returns>
public static string BoolToStrEn(bool bol)
{
if (bol == true)
return "true";
else
return "false";
}
/// <summary>
/// 将Bool 转换为 string 中文 是,否
/// </summary>
/// <param name="bol"></param>
/// <returns></returns>
public static string BoolToStrCn(bool bol)
{
if (bol == true)
return "是";
else
return "否";
}
#endregion
#region ToInt
/// <summary>
/// 将对象转换为Int32类型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int ObjectToInt(object expression)
{
return ObjectToInt(expression, 0);
}
/// <summary>
/// 将对象转换为Int32类型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int ObjectToInt(object expression, int defValue)
{
if (expression != null)
return StrToInt(expression.ToString(), defValue);
return defValue;
}
/// <summary>
/// 将字符串转换为Int32类型,转换失败返回0
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static int StrToInt(string str)
{
return StrToInt(str, 0);
}
/// <summary>
/// 将字符串转换为Int32类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static int StrToInt(string str, int defValue)
{
if (string.IsNullOrEmpty(str) || str.Trim().Length >= 11 || !Regex.IsMatch(str.Trim(), @"^([-]|[0-9])[0-9]*(\.\w*)?$"))
return defValue;
int rv;
if (Int32.TryParse(str, out rv))
return rv;
return Convert.ToInt32(StrToFloat(str, defValue));
}
#endregion
#region ToFloat
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float StrToFloat(object strValue, float defValue)
{
if ((strValue == null))
return defValue;
return StrToFloat(strValue.ToString(), defValue);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float ObjectToFloat(object strValue, float defValue)
{
if ((strValue == null))
return defValue;
return StrToFloat(strValue.ToString(), defValue);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float ObjectToFloat(object strValue)
{
return ObjectToFloat(strValue.ToString(), 0);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static float StrToFloat(string strValue)
{
if ((strValue == null))
return 0;
return StrToFloat(strValue.ToString(), 0);
}
/// <summary>
/// string型转换为float型
/// </summary>
/// <param name="strValue">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static float StrToFloat(string strValue, float defValue)
{
if ((strValue == null) || (strValue.Length > 10))
return defValue;
float intValue = defValue;
if (strValue != null)
{
bool IsFloat = Regex.IsMatch(strValue, @"^([-]|[0-9])[0-9]*(\.\w*)?$");
if (IsFloat)
float.TryParse(strValue, out intValue);
}
return intValue;
}
#endregion
#region ToBool
/// <summary>
/// 将String 转换为 Bool
/// </summary>
/// <param name="strValue">需要转输字符串 true 是 or false否</param>
/// <param name="defValue">缺省值</param>
/// <returns></returns>
public static bool StrToBool(string strValue,bool defValue)
{
if (strValue != null)
{
if (string.Compare(strValue, "true", true) == 0 || strValue=="是")
{
return true;
}
else if (string.Compare(strValue, "false", true) == 0 || strValue=="否")
{
return false;
}
}
return defValue;
}
/// <summary>
/// 将String 转换为 Bool 缺省值 false
/// </summary>
/// <param name="strValue">需要转输字符串 true 是 or false否</param>
/// <returns></returns>
public static bool StrToBool(string strValue)
{
return StrToBool(strValue, false);
}
/// <summary>
/// 将 Int 转为 BOOL (intValue < 1 or intValue>0)
/// </summary>
/// <param name="intValue">转要转转换的数字</param>
/// <param name="defValue">缺省值</param>
/// <returns></returns>
public static bool IntToBool(int intValue, bool defValue)
{
if (intValue > 0)
return true;
else if(intValue<1)
return false;
return defValue;
}
/// <summary>
/// 将 Int 转为 BOOL (intValue < 1 or intValue>0) 缺省为 false
/// </summary>
/// <param name="intValue">转要转转换的数字</param>
/// <returns></returns>
public static bool IntToBool(int intValue)
{
return IntToBool(intValue, false);
}
public static bool ObjectToBool(object obectValue)
{
if (obectValue.ToString().ToLower() == "false")
{
return false;
}
return true;
}
#endregion
#region ToData
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime StrToDateTime(string str, DateTime defValue)
{
if (!string.IsNullOrEmpty(str))
{
DateTime dateTime;
if (DateTime.TryParse(str, out dateTime))
return dateTime;
}
return defValue;
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="str">要转换的字符串</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime StrToDateTime(string str)
{
return StrToDateTime(str, DateTime.Now);
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="obj">要转换的对象</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime ObjectToDateTime(object obj)
{
return StrToDateTime(obj.ToString());
}
/// <summary>
/// 将对象转换为日期时间类型
/// </summary>
/// <param name="obj">要转换的对象</param>
/// <param name="defValue">缺省值</param>
/// <returns>转换后的int类型结果</returns>
public static DateTime ObjectToDateTime(object obj, DateTime defValue)
{
return StrToDateTime(obj.ToString(), defValue);
}
#endregion
#region ToColor
/// <summary>
/// 将字符串转换为Color
/// </summary>
/// <param name="color"></param>
/// <returns></returns>
public static Color ToColor(string color)
{
int red, green, blue = 0;
char[] rgb;
color = color.TrimStart('#');
color = Regex.Replace(color.ToLower(), "[g-zG-Z]", "");
switch (color.Length)
{
case 3:
rgb = color.ToCharArray();
red = Convert.ToInt32(rgb[0].ToString() + rgb[0].ToString(), 16);
green = Convert.ToInt32(rgb[1].ToString() + rgb[1].ToString(), 16);
blue = Convert.ToInt32(rgb[2].ToString() + rgb[2].ToString(), 16);
return Color.FromArgb(red, green, blue);
case 6:
rgb = color.ToCharArray();
red = Convert.ToInt32(rgb[0].ToString() + rgb[1].ToString(), 16);
green = Convert.ToInt32(rgb[2].ToString() + rgb[3].ToString(), 16);
blue = Convert.ToInt32(rgb[4].ToString() + rgb[5].ToString(), 16);
return Color.FromArgb(red, green, blue);
default:
return Color.FromName(color);
}
}
#endregion
#region ToDecamal
public static decimal ObjToDeimal(object obj)
{
return obj == null ? 0 : decimal.Parse(obj.ToString());
}
public static decimal StrToDeimal(string str)
{
return string.IsNullOrEmpty(str) ? 0 : decimal.Parse(str);
}
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/TypeConverter.cs | C# | oos | 12,367 |
//======================================================================
// 组织名: Troopsen
// 命名空间名称: Common
// 文件名: SysInfo
// 创建人: Troopsen
// 创建时间: 2011/3/30 21:58:29
//======================================================================
using System;
using Microsoft.Win32;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Web;
using System.Text;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace TRECommon
{
public class SysInfo
{
#region CpuUsage类
/// <summary>
/// Defines an abstract base class for implementations of CPU usage counters.
/// </summary>
public abstract class CpuUsage
{
/// <summary>
/// Creates and returns a CpuUsage instance that can be used to query the CPU time on this operating system.
/// </summary>
/// <returns>An instance of the CpuUsage class.</returns>
/// <exception cref="NotSupportedException">This platform is not supported -or- initialization of the CPUUsage object failed.</exception>
public static CpuUsage Create()
{
if (m_CpuUsage == null)
{
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
m_CpuUsage = new CpuUsageNt();
else if (Environment.OSVersion.Platform == PlatformID.Win32Windows)
m_CpuUsage = new CpuUsage9x();
else
throw new NotSupportedException();
}
return m_CpuUsage;
}
/// <summary>
/// Determines the current average CPU load.
/// </summary>
/// <returns>An integer that holds the CPU load percentage.</returns>
/// <exception cref="NotSupportedException">One of the system calls fails. The CPU time can not be obtained.</exception>
public abstract int Query();
/// <summary>
/// Holds an instance of the CPUUsage class.
/// </summary>
private static CpuUsage m_CpuUsage = null;
}
//------------------------------------------- win 9x ---------------------------------------
/// <summary>
/// Inherits the CPUUsage class and implements the Query method for Windows 9x systems.
/// </summary>
/// <remarks>
/// <p>This class works on Windows 98 and Windows Millenium Edition.</p>
/// <p>You should not use this class directly in your code. Use the CPUUsage.Create() method to instantiate a CPUUsage object.</p>
/// </remarks>
internal sealed class CpuUsage9x : CpuUsage
{
/// <summary>
/// Initializes a new CPUUsage9x instance.
/// </summary>
/// <exception cref="NotSupportedException">One of the system calls fails.</exception>
public CpuUsage9x()
{
try
{
// start the counter by reading the value of the 'StartStat' key
RegistryKey startKey = Registry.DynData.OpenSubKey(@"PerfStats\StartStat", false);
if (startKey == null)
throw new NotSupportedException();
startKey.GetValue(@"KERNEL\CPUUsage");
startKey.Close();
// open the counter's value key
m_StatData = Registry.DynData.OpenSubKey(@"PerfStats\StatData", false);
if (m_StatData == null)
throw new NotSupportedException();
}
catch (NotSupportedException e)
{
throw e;
}
catch (Exception e)
{
throw new NotSupportedException("Error while querying the system information.", e);
}
}
/// <summary>
/// Determines the current average CPU load.
/// </summary>
/// <returns>An integer that holds the CPU load percentage.</returns>
/// <exception cref="NotSupportedException">One of the system calls fails. The CPU time can not be obtained.</exception>
public override int Query()
{
try
{
return (int)m_StatData.GetValue(@"KERNEL\CPUUsage");
}
catch (Exception e)
{
throw new NotSupportedException("Error while querying the system information.", e);
}
}
/// <summary>
/// Closes the allocated resources.
/// </summary>
~CpuUsage9x()
{
try
{
m_StatData.Close();
}
catch { }
// stopping the counter
try
{
RegistryKey stopKey = Registry.DynData.OpenSubKey(@"PerfStats\StopStat", false);
stopKey.GetValue(@"KERNEL\CPUUsage", false);
stopKey.Close();
}
catch { }
}
/// <summary>Holds the registry key that's used to read the CPU load.</summary>
private RegistryKey m_StatData;
}
//------------------------------------------- win nt ---------------------------------------
/// <summary>
/// Inherits the CPUUsage class and implements the Query method for Windows NT systems.
/// </summary>
/// <remarks>
/// <p>This class works on Windows NT4, Windows 2000, Windows XP, Windows .NET Server and higher.</p>
/// <p>You should not use this class directly in your code. Use the CPUUsage.Create() method to instantiate a CPUUsage object.</p>
/// </remarks>
internal sealed class CpuUsageNt : CpuUsage
{
/// <summary>
/// Initializes a new CpuUsageNt instance.
/// </summary>
/// <exception cref="NotSupportedException">One of the system calls fails.</exception>
public CpuUsageNt()
{
byte[] timeInfo = new byte[32]; // SYSTEM_TIME_INFORMATION structure
byte[] perfInfo = new byte[312]; // SYSTEM_PERFORMANCE_INFORMATION structure
byte[] baseInfo = new byte[44]; // SYSTEM_BASIC_INFORMATION structure
int ret;
// get new system time
ret = NtQuerySystemInformation(SYSTEM_TIMEINFORMATION, timeInfo, timeInfo.Length, IntPtr.Zero);
if (ret != NO_ERROR)
throw new NotSupportedException();
// get new CPU's idle time
ret = NtQuerySystemInformation(SYSTEM_PERFORMANCEINFORMATION, perfInfo, perfInfo.Length, IntPtr.Zero);
if (ret != NO_ERROR)
throw new NotSupportedException();
// get number of processors in the system
ret = NtQuerySystemInformation(SYSTEM_BASICINFORMATION, baseInfo, baseInfo.Length, IntPtr.Zero);
if (ret != NO_ERROR)
throw new NotSupportedException();
// store new CPU's idle and system time and number of processors
oldIdleTime = BitConverter.ToInt64(perfInfo, 0); // SYSTEM_PERFORMANCE_INFORMATION.liIdleTime
oldSystemTime = BitConverter.ToInt64(timeInfo, 8); // SYSTEM_TIME_INFORMATION.liKeSystemTime
processorCount = baseInfo[40];
}
/// <summary>
/// Determines the current average CPU load.
/// </summary>
/// <returns>An integer that holds the CPU load percentage.</returns>
/// <exception cref="NotSupportedException">One of the system calls fails. The CPU time can not be obtained.</exception>
public override int Query()
{
byte[] timeInfo = new byte[32]; // SYSTEM_TIME_INFORMATION structure
byte[] perfInfo = new byte[312]; // SYSTEM_PERFORMANCE_INFORMATION structure
double dbIdleTime, dbSystemTime;
int ret;
// get new system time
ret = NtQuerySystemInformation(SYSTEM_TIMEINFORMATION, timeInfo, timeInfo.Length, IntPtr.Zero);
if (ret != NO_ERROR)
throw new NotSupportedException();
// get new CPU's idle time
ret = NtQuerySystemInformation(SYSTEM_PERFORMANCEINFORMATION, perfInfo, perfInfo.Length, IntPtr.Zero);
if (ret != NO_ERROR)
throw new NotSupportedException();
// CurrentValue = NewValue - OldValue
dbIdleTime = BitConverter.ToInt64(perfInfo, 0) - oldIdleTime;
dbSystemTime = BitConverter.ToInt64(timeInfo, 8) - oldSystemTime;
// CurrentCpuIdle = IdleTime / SystemTime
if (dbSystemTime != 0)
dbIdleTime = dbIdleTime / dbSystemTime;
// CurrentCpuUsage% = 100 - (CurrentCpuIdle * 100) / NumberOfProcessors
dbIdleTime = 100.0 - dbIdleTime * 100.0 / processorCount + 0.5;
// store new CPU's idle and system time
oldIdleTime = BitConverter.ToInt64(perfInfo, 0); // SYSTEM_PERFORMANCE_INFORMATION.liIdleTime
oldSystemTime = BitConverter.ToInt64(timeInfo, 8); // SYSTEM_TIME_INFORMATION.liKeSystemTime
return (int)dbIdleTime;
}
/// <summary>
/// NtQuerySystemInformation is an internal Windows function that retrieves various kinds of system information.
/// </summary>
/// <param name="dwInfoType">One of the values enumerated in SYSTEM_INFORMATION_CLASS, indicating the kind of system information to be retrieved.</param>
/// <param name="lpStructure">Points to a buffer where the requested information is to be returned. The size and structure of this information varies depending on the value of the SystemInformationClass parameter.</param>
/// <param name="dwSize">Length of the buffer pointed to by the SystemInformation parameter.</param>
/// <param name="returnLength">Optional pointer to a location where the function writes the actual size of the information requested.</param>
/// <returns>Returns a success NTSTATUS if successful, and an NTSTATUS error code otherwise.</returns>
[DllImport("ntdll", EntryPoint = "NtQuerySystemInformation")]
private static extern int NtQuerySystemInformation(int dwInfoType, byte[] lpStructure, int dwSize, IntPtr returnLength);
/// <summary>Returns the number of processors in the system in a SYSTEM_BASIC_INFORMATION structure.</summary>
private const int SYSTEM_BASICINFORMATION = 0;
/// <summary>Returns an opaque SYSTEM_PERFORMANCE_INFORMATION structure.</summary>
private const int SYSTEM_PERFORMANCEINFORMATION = 2;
/// <summary>Returns an opaque SYSTEM_TIMEOFDAY_INFORMATION structure.</summary>
private const int SYSTEM_TIMEINFORMATION = 3;
/// <summary>The value returned by NtQuerySystemInformation is no error occurred.</summary>
private const int NO_ERROR = 0;
/// <summary>Holds the old idle time.</summary>
private long oldIdleTime;
/// <summary>Holds the old system time.</summary>
private long oldSystemTime;
/// <summary>Holds the number of processors in the system.</summary>
private double processorCount;
}
#endregion
/// <summary>
/// 获得Cpu使用率
/// </summary>
/// <returns>返回使用率</returns>
public static int GetCpuUsage()
{
return CpuUsage.Create().Query();
}
/// <summary>
/// 系统信息
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
public static string[] LoadSystemInf(System.Web.UI.Page page)
{
#region 检测系统信息
HttpContext.Current.Response.Expires = 0;
HttpContext.Current.Response.CacheControl = "no-cache";
//取得页面执行开始时间
DateTime stime = DateTime.Now;
//取得服务器相关信息
string[] arrStr = new string[24];
arrStr[0] = page.Server.MachineName; //服务器名称
arrStr[1] = HttpContext.Current.Request.ServerVariables["LOCAL_ADDR"]; //服务器IP地址
arrStr[2] = HttpContext.Current.Request.ServerVariables["SERVER_NAME"]; //服务器域名
int build, major, minor, revision;
build = Environment.Version.Build;
major = Environment.Version.Major;
minor = Environment.Version.Minor;
revision = Environment.Version.Revision;
arrStr[3] = ".NET CLR " + major + "." + minor + "." + build + "." + revision; //.NET解释引擎版本
arrStr[5] = Environment.OSVersion.ToString(); //服务器操作系统
arrStr[6] = HttpContext.Current.Request.ServerVariables["SERVER_SOFTWARE"]; //服务器IIS版本
arrStr[7] = HttpContext.Current.Request.ServerVariables["SERVER_PORT"]; //HTTP访问端口:
arrStr[8] = page.Server.ScriptTimeout.ToString();//服务端脚本执行超时:
//语言应该是浏览者信息, 1.0 final 修改
arrStr[9] = HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]; //语言:
arrStr[10] = DateTime.Now.ToString(); //服务器当前时间:
arrStr[11] = HttpContext.Current.Request.ServerVariables["APPL_PHYSICAL_PATH"]; //虚拟目录绝对路径:
arrStr[12] = HttpContext.Current.Request.ServerVariables["PATH_TRANSLATED"]; //执行文件绝对路径:
arrStr[13] = HttpContext.Current.Request.ServerVariables["HTTPS"]; // HTTPS:
//取得用户浏览器信息
HttpBrowserCapabilities bc = HttpContext.Current.Request.Browser;
arrStr[14] = bc.Browser.ToString(); //浏览器:
arrStr[15] = bc.Cookies.ToString(); // Cookies:
arrStr[16] = bc.Frames.ToString(); // Frames(分栏)
arrStr[17] = bc.JavaApplets.ToString(); // JavaApplets:
arrStr[18] = bc.EcmaScriptVersion.ToString(); // JavaScript:
arrStr[19] = bc.Platform.ToString(); // 浏览者操作系统:
arrStr[20] = bc.VBScript.ToString(); // VBScript:
arrStr[21] = bc.Version.ToString(); // 浏览器版本:
//取得浏览者ip地址,1.0 final 加入
arrStr[22] = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
//取得页面执行结束时间
DateTime etime = DateTime.Now;
//计算页面执行时间
arrStr[23] = ((etime - stime).TotalMilliseconds).ToString();
return arrStr;
#endregion
}
private static string[] browerNames = { "MSIE", "Firefox", "Opera", "Netscape", "Safari", "Lynx", "Konqueror", "Mozilla" };
//private const string[] osNames = { "Win", "Mac", "Linux", "FreeBSD", "SunOS", "OS/2", "AIX", "Bot", "Crawl", "Spider" };
/// <summary>
/// 获得浏览器信息
/// </summary>
/// <returns></returns>
public static string GetClientBrower()
{
string agent = HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
if (!string.IsNullOrEmpty(agent))
{
foreach (string name in browerNames)
{
if (agent.Contains(name))
return name;
}
}
return "Other";
}
/// <summary>
/// 获得操作系统信息
/// </summary>
/// <returns></returns>
public static string GetClientOS()
{
string os = string.Empty;
string agent = System.Web.HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"];
if (agent == null)
return "Other";
if (agent.IndexOf("Win") > -1)
os = "Windows";
else if (agent.IndexOf("Mac") > -1)
os = "Mac";
else if (agent.IndexOf("Linux") > -1)
os = "Linux";
else if (agent.IndexOf("FreeBSD") > -1)
os = "FreeBSD";
else if (agent.IndexOf("SunOS") > -1)
os = "SunOS";
else if (agent.IndexOf("OS/2") > -1)
os = "OS/2";
else if (agent.IndexOf("AIX") > -1)
os = "AIX";
else if (System.Text.RegularExpressions.Regex.IsMatch(agent, @"(Bot|Crawl|Spider)"))
os = "Spiders";
else
os = "Other";
return os;
}
public static string GetClientOS(HttpContext Context)
{
string strSysVersion = "其他";
string strAgentInfo = Context.Request.ServerVariables["HTTP_USER_AGENT"];
if (strAgentInfo.Contains("NT 5.2"))
{
strSysVersion = "Windows 2003";
}
else if (strAgentInfo.Contains("NT 5.1"))
{
strSysVersion = "Windows XP";
}
else if (strAgentInfo.Contains("NT 5"))
{
strSysVersion = "Windows 2000";
}
else if (strAgentInfo.Contains("NT 4.9"))
{
strSysVersion = "Windows ME";
}
else if (strAgentInfo.Contains("NT 4"))
{
strSysVersion = "Windows NT4";
}
else if (strAgentInfo.Contains("NT 98"))
{
strSysVersion = "Windows 98";
}
else if (strAgentInfo.Contains("NT 95"))
{
strSysVersion = "Windows 95";
}
else if (strSysVersion.ToLower().Contains("Mac"))
{
strSysVersion = "Mac";
}
else if (strSysVersion.ToLower().Contains("unix"))
{
strSysVersion = "UNIX";
}
else if (strSysVersion.ToLower().Contains("linux"))
{
strSysVersion = "Linux";
}
else if (strSysVersion.Contains("SunOS"))
{
strSysVersion = "SunOS";
}
return strSysVersion;
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Sys/SysInfo.cs | C# | oos | 19,374 |
using System;
using System.Web;
using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.IO;
namespace TRECommon
{
public class ImageWaterMark
{
/// <summary>
/// 图片水印
/// </summary>
/// <param name="imgPath">服务器图片相对路径</param>
/// <param name="filename">保存文件名</param>
/// <param name="watermarkFilename">水印文件相对路径</param>
/// <param name="watermarkStatus">图片水印位置 0=不使用 1=左上 2=中上 3=右上 4=左中 9=右下</param>
/// <param name="quality">附加水印图片质量,0-100</param>
/// <param name="watermarkTransparency">水印的透明度 1--10 10为不透明</param>
public static void AddImageSignPic(string imgPath, string filename, string watermarkFilename, int watermarkStatus, int quality, int watermarkTransparency)
{
byte[] _ImageBytes = File.ReadAllBytes(Utils.GetMapPath(imgPath));
Image img = Image.FromStream(new System.IO.MemoryStream(_ImageBytes));
filename = HttpContext.Current.Server.MapPath(filename);
if (watermarkFilename.StartsWith("/") == false)
watermarkFilename = "/" + watermarkFilename;
watermarkFilename = Utils.GetMapPath(watermarkFilename);
if (!File.Exists(watermarkFilename))
return;
Graphics g = Graphics.FromImage(img);
//设置高质量插值法
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High;
//设置高质量,低速度呈现平滑程度
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
Image watermark = new Bitmap(watermarkFilename);
if (watermark.Height >= img.Height || watermark.Width >= img.Width)
return;
ImageAttributes imageAttributes = new ImageAttributes();
ColorMap colorMap = new ColorMap();
colorMap.OldColor = Color.FromArgb(255, 0, 255, 0);
colorMap.NewColor = Color.FromArgb(0, 0, 0, 0);
ColorMap[] remapTable = { colorMap };
imageAttributes.SetRemapTable(remapTable, ColorAdjustType.Bitmap);
float transparency = 0.5F;
if (watermarkTransparency >= 1 && watermarkTransparency <= 10)
transparency = (watermarkTransparency / 10.0F);
float[][] colorMatrixElements = {
new float[] {1.0f, 0.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 1.0f, 0.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 1.0f, 0.0f, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, transparency, 0.0f},
new float[] {0.0f, 0.0f, 0.0f, 0.0f, 1.0f}
};
ColorMatrix colorMatrix = new ColorMatrix(colorMatrixElements);
imageAttributes.SetColorMatrix(colorMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
int xpos = 0;
int ypos = 0;
switch (watermarkStatus)
{
case 1:
xpos = (int)(img.Width * (float).01);
ypos = (int)(img.Height * (float).01);
break;
case 2:
xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
ypos = (int)(img.Height * (float).01);
break;
case 3:
xpos = (int)((img.Width * (float).99) - (watermark.Width));
ypos = (int)(img.Height * (float).01);
break;
case 4:
xpos = (int)(img.Width * (float).01);
ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
break;
case 5:
xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
break;
case 6:
xpos = (int)((img.Width * (float).99) - (watermark.Width));
ypos = (int)((img.Height * (float).50) - (watermark.Height / 2));
break;
case 7:
xpos = (int)(img.Width * (float).01);
ypos = (int)((img.Height * (float).99) - watermark.Height);
break;
case 8:
xpos = (int)((img.Width * (float).50) - (watermark.Width / 2));
ypos = (int)((img.Height * (float).99) - watermark.Height);
break;
case 9:
xpos = (int)((img.Width * (float).99) - (watermark.Width));
ypos = (int)((img.Height * (float).99) - watermark.Height);
break;
}
g.DrawImage(watermark, new Rectangle(xpos, ypos, watermark.Width, watermark.Height), 0, 0, watermark.Width, watermark.Height, GraphicsUnit.Pixel, imageAttributes);
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo ici = null;
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType.IndexOf("jpeg") > -1)
ici = codec;
}
EncoderParameters encoderParams = new EncoderParameters();
long[] qualityParam = new long[1];
if (quality < 0 || quality > 100)
quality = 80;
qualityParam[0] = quality;
EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityParam);
encoderParams.Param[0] = encoderParam;
if (ici != null)
img.Save(filename, ici, encoderParams);
else
img.Save(filename);
g.Dispose();
img.Dispose();
watermark.Dispose();
imageAttributes.Dispose();
}
/// <summary>
/// 文字水印
/// </summary>
/// <param name="imgPath">服务器图片相对路径</param>
/// <param name="filename">保存文件名</param>
/// <param name="watermarkText">水印文字</param>
/// <param name="watermarkStatus">图片水印位置 0=不使用 1=左上 2=中上 3=右上 4=左中 9=右下</param>
/// <param name="quality">附加水印图片质量,0-100</param>
/// <param name="fontname">字体</param>
/// <param name="fontsize">字体大小</param>
public static void AddImageSignText(string imgPath, string filename, string watermarkText, int watermarkStatus, int quality, string fontname, int fontsize)
{
byte[] _ImageBytes = File.ReadAllBytes(HttpContext.Current.Server.MapPath(imgPath));
Image img = Image.FromStream(new System.IO.MemoryStream(_ImageBytes));
filename = HttpContext.Current.Server.MapPath(filename);
Graphics g = Graphics.FromImage(img);
Font drawFont = new Font(fontname, fontsize, FontStyle.Regular, GraphicsUnit.Pixel);
SizeF crSize;
crSize = g.MeasureString(watermarkText, drawFont);
float xpos = 0;
float ypos = 0;
switch (watermarkStatus)
{
case 1:
xpos = (float)img.Width * (float).01;
ypos = (float)img.Height * (float).01;
break;
case 2:
xpos = ((float)img.Width * (float).50) - (crSize.Width / 2);
ypos = (float)img.Height * (float).01;
break;
case 3:
xpos = ((float)img.Width * (float).99) - crSize.Width;
ypos = (float)img.Height * (float).01;
break;
case 4:
xpos = (float)img.Width * (float).01;
ypos = ((float)img.Height * (float).50) - (crSize.Height / 2);
break;
case 5:
xpos = ((float)img.Width * (float).50) - (crSize.Width / 2);
ypos = ((float)img.Height * (float).50) - (crSize.Height / 2);
break;
case 6:
xpos = ((float)img.Width * (float).99) - crSize.Width;
ypos = ((float)img.Height * (float).50) - (crSize.Height / 2);
break;
case 7:
xpos = (float)img.Width * (float).01;
ypos = ((float)img.Height * (float).99) - crSize.Height;
break;
case 8:
xpos = ((float)img.Width * (float).50) - (crSize.Width / 2);
ypos = ((float)img.Height * (float).99) - crSize.Height;
break;
case 9:
xpos = ((float)img.Width * (float).99) - crSize.Width;
ypos = ((float)img.Height * (float).99) - crSize.Height;
break;
}
g.DrawString(watermarkText, drawFont, new SolidBrush(Color.White), xpos + 1, ypos + 1);
g.DrawString(watermarkText, drawFont, new SolidBrush(Color.Black), xpos, ypos);
ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo ici = null;
foreach (ImageCodecInfo codec in codecs)
{
if (codec.MimeType.IndexOf("jpeg") > -1)
ici = codec;
}
EncoderParameters encoderParams = new EncoderParameters();
long[] qualityParam = new long[1];
if (quality < 0 || quality > 100)
quality = 80;
qualityParam[0] = quality;
EncoderParameter encoderParam = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, qualityParam);
encoderParams.Param[0] = encoderParam;
if (ici != null)
img.Save(filename, ici, encoderParams);
else
img.Save(filename);
g.Dispose();
img.Dispose();
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/File/ImageWaterMark.cs | C# | oos | 10,510 |
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Text;
namespace TRECommon
{
public class FileManager
{
/// <summary>
/// 根录径
/// </summary>
protected string _path = "";
public string Path
{
get { return _path; }
set { _path = value; }
}
protected string _rootPath = "";
public string RootPath
{
get { return _rootPath; }
set { this._rootPath = value; }
}
public FileManager() { }
public FileManager(string rootpath)
{
RootPath = rootpath;
} //传根目目录
public FileManager(string path, string rootPath)
{
Path = path;
RootPath = rootPath;
}
/// <summary>
/// 新建件夹
/// </summary>
/// <param name="name"></param>
/// <param name="parentName"></param>
/// <returns>0失败 1:成功;</returns>
public static int CreateFolder(string name, string parentName)
{
return CreateFolder(name, parentName, false);
}
/// <summary>
/// 新建文件夹
/// </summary>
/// <param name="name">文件夹名称</param>
/// <param name="parentName">路径</param>
/// <param name="fullpath">是否创建符合参数完整路径</param>
/// <param name="path">路径</param>
/// <returns>0失败 1:成功;</returns>
public static int CreateFolder(string name, string path, bool fullpath)
{
if (fullpath)
{
path = path + "//" + name;
DirectoryInfo di = new DirectoryInfo(path);
di.Create();
if (Directory.Exists(path))
{
return 1;
}
else
{
return 0;
}
}
else
{
DirectoryInfo di = new DirectoryInfo(path);
if (di.Exists)
{
di.CreateSubdirectory(name);
return 1;
}
else
{
return 0;
}
}
}
/// <summary>
/// 删除文件夹
/// </summary>
/// <param name="path"></param>
public static int DeleteFolder(string path)
{
return DeleteFolder(path, false);
}
/// <summary>
/// 删除文件夹
/// </summary>
/// <param name="path">路径</param>
/// <param name="recursive">True 删除 子目录及文件 False 如有子目录则不删除</param>
/// <returns></returns>
public static int DeleteFolder(string path, bool recursive)
{
if (Directory.Exists(path))
{
try
{
Directory.Delete(path, recursive);
return 1;
}
catch (Exception e)
{
return 0;
}
}
else
{
return 0;
}
}
/// <summary>
/// 移动文件夹 如果目标文件夹存在则在该目录下创建原文件夹名,如果目标文件夹不存在。则创建目径文件夹;
/// </summary>
/// <param name="oldPath"></param>
/// <param name="newPath"></param>
public static int MoveFolder(string oldPath, string newPath)
{
if (Directory.Exists(oldPath))
{
if (Directory.Exists(newPath))
{
oldPath = oldPath.EndsWith("\\") ? oldPath.Substring(0, oldPath.Length - 2) : oldPath;
newPath = newPath.EndsWith("\\") ? newPath : newPath + "\\";
string tmp = "";
tmp = oldPath.Substring(oldPath.LastIndexOf("\\") + 1, oldPath.Length - oldPath.LastIndexOf("\\") - 1);
tmp = newPath + tmp + "\\";
Directory.Move(oldPath, tmp);
return 1;
}
else
{
Directory.Move(oldPath, newPath);
return 0;
}
}
else
{
return 1;
}
}
/// <summary>
/// 创建文件
/// </summary>
/// <param name="filename"></param>
/// <param name="path"></param>
public static int CreateFile(string filename, string path)
{
return CreateFile(filename, path, "");
}
/// <summary>
/// 创建文件
/// </summary>
/// <param name="filename"></param>
/// <param name="path"></param>
/// <param name="contents">内容</param>
public static int CreateFile(string filename, string path, string contents)
{
string fullfilename = path.EndsWith("\\") ? path + filename : path + "\\" + filename;
if (File.Exists(fullfilename))
{
return 0; ;
}
else
{
if (contents == null || contents.Length == 0)
{
try
{
FileStream fs = File.Create(fullfilename);
fs.Close();
}
catch (Exception ex) { }
return 1;
}
else
{
try
{
FileStream fs = File.Create(path + "\\" + filename);
byte[] data = new UTF8Encoding().GetBytes(contents);
fs.Write(data, 0, data.Length);
fs.Close();
}
catch (Exception ex)
{ }
return 0;
}
}
}
/// <summary>
/// 读取文件
/// </summary>
/// <param name="name"></param>
/// <param name="parentName"></param>
public static string OpenText(string filename, string path)
{
path = path.EndsWith("\\") ? path + filename : path + "\\" + filename;
StreamReader sr = File.OpenText(path);
StringBuilder output = new StringBuilder();
string rl;
while ((rl = sr.ReadLine()) != null)
{
output.Append(rl);
}
sr.Close();
return output.ToString();
}
/// <summary>
/// 保存文件
/// </summary>
/// <param name="filename">文件名</param>
/// <param name="path">路径</param>
/// <param name="existCreate">文件名果存在是否进行操作,True操作 Flase 不操作</param>
/// <param name="existSave">如果存在是否覆盖 True,覆盖,False,新增</param>
/// <param name="overlay">方式。True,直接覆盖,false,追加至末尾</param>
/// <param name="contents">内容</param>
/// <returns></returns>
public static int SaveFile(string filename, string path, bool existCreate, bool existSave, bool overlay, string contents)
{
string fullfilename = path.EndsWith("\\") ? path + filename : path + "\\" + filename;
if (File.Exists(fullfilename) && !existCreate)
{
return 0;
}
else
{
if (File.Exists(fullfilename))
{
//如果存在及新增保存--新文件名
if (!existSave)
{
string newfullfilename = fullfilename.Substring(0, fullfilename.LastIndexOf(".") - 1);
string ext = fullfilename.Substring(fullfilename.LastIndexOf(".") + 1, fullfilename.Length - fullfilename.LastIndexOf(".") - 1);
int i = 1;
while (true)
{
if (!File.Exists(newfullfilename + "新建文件" + i.ToString() + "." + ext))
{
fullfilename = newfullfilename + "新建文件" + i.ToString() + "." + ext;
break;
}
i++;
}
}
//如果覆盖。直接保存
if (overlay)
{
FileStream fs = File.Create(fullfilename);
byte[] data = new UTF8Encoding().GetBytes(contents);
fs.Write(data, 0, data.Length);
fs.Flush();
fs.Close();
}
else
{
///追加保存
StreamWriter sw = File.AppendText(fullfilename);
sw.WriteLine(contents);
sw.Flush();
sw.Close();
}
}
else
{
//如果文件不存在直接保存
FileStream fs = File.Create(fullfilename);
byte[] data = new UTF8Encoding().GetBytes(contents);
fs.Write(data, 0, data.Length);
fs.Flush();
fs.Close();
}
return 1;
}
}
/// <summary>
/// 删除文件
/// </summary>
/// <param name="path"></param>
public static int DeleteFile(string filename, string path)
{
string fullname = path.EndsWith("\\") ? path + filename : path + "\\" + filename;
if (File.Exists(fullname))
{
try
{
File.Delete(fullname);
return 1;
}
catch(Exception ex)
{
return 0;
}
}
else
{
return 0;
}
}
/// <summary>
/// 移动文件
/// </summary>
/// <param name="oldPath"></param>
/// <param name="newPath"></param>
public static int MoveFile(string oldPath, string newPath)
{
if (File.Exists(oldPath))
{
if (File.Exists(newPath))
{
return 0; ///目标存在同名文件。不允许移动
}
string newName = "";
if (Directory.Exists(newPath))
{
FileInfo fi = new FileInfo(oldPath);
newName = newPath + fi.Name;
}
else
{
newName = newPath;
}
File.Move(oldPath, newName);
return 1;
}
else
{
return 0;
}
}
/// <summary>
/// 复制文件夹
/// </summary>
/// <param name="source"></param>
/// <param name="destination"></param>
/// <returns></returns>
public static bool CopyFolder(string source, string destination)
{
try
{
String[] files;
if (destination[destination.Length - 1] != System.IO.Path.DirectorySeparatorChar)
destination += System.IO.Path.DirectorySeparatorChar;
if (!Directory.Exists(destination)) Directory.CreateDirectory(destination);
files = Directory.GetFileSystemEntries(source);
foreach (string element in files)
{
if (Directory.Exists(element))
CopyFolder(element, destination + System.IO.Path.GetFileName(element));
else
File.Copy(element, destination + System.IO.Path.GetFileName(element), true);
}
return true;
}
catch
{
return false;
}
}
/// <summary>
/// 查看路径下所有文件及文件夹
/// </summary>
/// <param name="path">Server.MapPath(@"~/Upload/")</param>
/// <param name="serarch">按名称搜索 为空不执行 不搜索:该值必须为""</param>
/// <param name="searchOption">搜索时是否包含子目录,1:,0:其它不包含 不搜索该值必须为 0</param>
/// <returns></returns>
public List<FileManagerInfo> GetFileAndFolderList(string path, string serarch, int searchOption)
{
if (path == "") { path = RootPath; }
List<FileManagerInfo> list = new List<FileManagerInfo>();
if (Directory.Exists(path))
{
if (RootPath != path)
{
FileManagerInfo pm = new FileManagerInfo(); //parentModel 根目连接地址
pm.FullName = RootPath;
pm.Name = "根目录";
pm.IsFolder = true;
pm.CreationTime = DateTime.Now;
list.Add(pm);
FileManagerInfo um = new FileManagerInfo(); // upper 上层
um.Name = "上级";
um.FullName = Directory.GetParent(path).FullName;
um.IsFolder = true;
um.CreationTime = DateTime.Now;
list.Add(um);
}
else
{
FileManagerInfo pm = new FileManagerInfo(); //parentModel 根目连接地址
pm.FullName = RootPath;
pm.Name = "根目录";
pm.IsFolder = true;
pm.CreationTime = DateTime.Now;
list.Add(pm);
}
FileInfo[] fileList = GetFileInfoList(path, serarch, searchOption);
DirectoryInfo[] dirList = GetFileFolderInfoList(path, serarch, searchOption);
if (dirList.Length > 0)
{
foreach (DirectoryInfo dm in dirList)
{
FileManagerInfo model = new FileManagerInfo();
model.RootPath = RootPath;
model.FullName = dm.FullName;
model.Name = dm.Name;
model.Extension = dm.Extension;
model.CreationTime = dm.CreationTime;
model.LastAccessTime = dm.LastAccessTime;
model.LastWriteTime = dm.LastWriteTime;
model.IsFolder = true;
list.Add(model);
}
}
if (fileList.Length > 0)
{
foreach (FileInfo fm in fileList)
{
FileManagerInfo model = new FileManagerInfo();
model.RootPath = RootPath;
model.FullName = fm.FullName;
model.Name = fm.Name;
model.Extension = fm.Extension;
model.CreationTime = fm.CreationTime;
model.LastAccessTime = fm.LastAccessTime;
model.LastWriteTime = fm.LastWriteTime;
model.Length = fm.Length;
model.IsFolder = false;
list.Add(model);
}
}
}
return list;
}
/// <summary>
/// 查看路径下的所有文件
/// </summary>
/// <param name="path">完整的文件目录路径</param>
/// <param name="serarch">按名称搜索 为空不执行 不搜索:该值必须为""</param>
/// <param name="searchOption">搜索时是否包含子目录,1:,0:其它不包含 不搜索该值必须为 0</param>
/// <returns> FileInfo[](不为NULL,无数据时返length=0)</returns>
public FileInfo[] GetFileInfoList(string path, string serarch, int searchOption)
{
if (path == "") { path = RootPath; }
if (Directory.Exists(path))
{
DirectoryInfo DirInfo = new DirectoryInfo(path);
FileInfo[] list = DirInfo.GetFiles();
if (serarch == "" && searchOption == 0)
{
list = DirInfo.GetFiles();
}
else
{
list = DirInfo.GetFiles(serarch, searchOption == 1 ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
}
return list;
}
return new FileInfo[0];
}
/// <summary>
/// 查看路径下的子目录
/// </summary>
/// <param name="path">完整的文件目录路径</param>
/// <param name="serarch">按名称搜索 为空不执行 不搜索:该值必须为""</param>
/// <param name="searchOption">搜索时是否包含子目录,1:,0:其它不包含 不搜索该值必须为 0</param>
/// <returns> DirectoryInfo[](不为NULL,无数据时返length=0)</returns>
public DirectoryInfo[] GetFileFolderInfoList(string path, string serarch, int searchOption)
{
if (path == "") { path = RootPath; }
if (Directory.Exists(path))
{
DirectoryInfo DirInfo = new DirectoryInfo(path);
DirectoryInfo[] list = DirInfo.GetDirectories();
if (serarch == "" && searchOption == 0)
{
list = DirInfo.GetDirectories();
}
else
{
list = DirInfo.GetDirectories(serarch, searchOption == 1 ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
}
return list;
}
return new DirectoryInfo[0];
}
public string ShowMessage(string key, string value)
{
return key + "," + value;
}
}
[Serializable]
public class FileManagerInfo
{
protected string _rootPath = "";
protected string _fullName = "";
protected string _name = "";
protected string _extension = "";
protected DateTime _creationTime = DateTime.Now;
protected DateTime _lastAccessTime = DateTime.Now; //上次访问
protected DateTime _lastWriteTime = DateTime.Now; //上次写入
protected long _length = 0;
protected bool _isFolder = false;
public string RootPath
{
get { return _rootPath; }
set { this._rootPath = value; }
}
public string FullName
{
get { return _fullName; }
set { this._fullName = value; }
}
public string Name
{
get { return _name; }
set { this._name = value; }
}
public string Extension
{
get { return _extension; }
set { this._extension = value; }
}
public DateTime CreationTime
{
get { return _creationTime; }
set { this._creationTime = value; }
}
public DateTime LastAccessTime
{
get { return _lastAccessTime; }
set { this._lastAccessTime = value; }
}
public DateTime LastWriteTime
{
get { return _lastWriteTime; }
set { this._lastWriteTime = value; }
}
public long Length
{
get { return _length; }
set { this._length = value; }
}
public bool IsFolder
{
get { return _isFolder; }
set { this._isFolder = value; }
}
}
} | 10aaa-10aaa | trunk/TRECommerce/TRECommon/File/FileManager.cs | C# | oos | 21,124 |
using System;
using System.Web;
namespace TRECommon
{
public class DataCache
{
/// <summary>
/// 获取当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey">键值</param>
/// <returns>Object</returns>
public static object GetCache(string CacheKey)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
return objCache[CacheKey];
}
/// <summary>
/// 设置当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey">键字</param>
/// <param name="objObject">Object</param>
public static void SetCache(string CacheKey, object objObject)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject);
}
/// <summary>
/// 设置当前应用程序指定CacheKey的Cache值
/// </summary>
/// <param name="CacheKey"></param>
/// <param name="objObject"></param>
/// <param name="absoluteExpiration"></param>
/// <param name="slidingExpiration"></param>
public static void SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
objCache.Insert(CacheKey, objObject, null, absoluteExpiration, slidingExpiration);
}
/// <summary>
/// 移除缓存
/// </summary>
/// <param name="CacheKey"></param>
public static void Remove(string CacheKey)
{
System.Web.Caching.Cache objCache = HttpRuntime.Cache;
objCache.Remove(CacheKey);
}
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/Cache/DataCache.cs | C# | oos | 1,851 |
using System;
using System.Collections.Generic;
using System.Text;
namespace TRECommon
{
public class DateTimeUtils
{
#region 工具 时间
/// <summary>
/// 返回标准日期格式string yyyy-MM-dd
/// </summary>
public static string GetDate()
{
return DateTime.Now.ToString("yyyy-MM-dd");
}
/// <summary>
/// 返回指定日期格式
/// </summary>
public static string GetDate(string datetimestr, string replacestr)
{
if (datetimestr == null)
return replacestr;
if (datetimestr.Equals(""))
return replacestr;
try
{
datetimestr = Convert.ToDateTime(datetimestr).ToString("yyyy-MM-dd").Replace("1900-01-01", replacestr);
}
catch
{
return replacestr;
}
return datetimestr;
}
/// <summary>
/// 返回标准时间格式stringHH:mm:ss
/// </summary>
public static string GetTime()
{
return DateTime.Now.ToString("HH:mm:ss");
}
/// <summary>
/// 返回标准时间格式string yyyy-MM-dd HH:mm:ss
/// </summary>
public static string GetDateTime()
{
return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
/// <summary>
/// 返回相对于当前时间的相对天数
/// </summary>
public static string GetDateTime(int relativeday)
{
return DateTime.Now.AddDays(relativeday).ToString("yyyy-MM-dd HH:mm:ss");
}
/// <summary>
/// 返回标准时间格式string yyyy-MM-dd HH:mm:ss:fffffff
/// </summary>
public static string GetDateTimeF()
{
return DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fffffff");
}
/// <summary>
/// 返回标准时间
/// </sumary>
public static string GetStandardDateTime(string fDateTime, string formatStr)
{
if (fDateTime == "0000-0-0 0:00:00")
return fDateTime;
DateTime time = new DateTime(1900, 1, 1, 0, 0, 0, 0);
if (DateTime.TryParse(fDateTime, out time))
return time.ToString(formatStr);
else
return "N/A";
}
/// <summary>
/// 返回标准时间 yyyy-MM-dd HH:mm:ss
/// </sumary>
public static string GetStandardDateTime(string fDateTime)
{
return GetStandardDateTime(fDateTime, "yyyy-MM-dd HH:mm:ss");
}
/// <summary>
/// 返回标准时间 yyyy-MM-dd
/// </sumary>
public static string GetStandardDate(string fDate)
{
return GetStandardDateTime(fDate, "yyyy-MM-dd");
}
/// <summary>
/// 返回相差的秒数
/// </summary>
/// <param name="Time"></param>
/// <param name="Sec"></param>
/// <returns></returns>
public static int StrDateDiffSeconds(string time, int Sec)
{
if (Validator.StrIsNullOrEmpty(time))
return 1;
DateTime dateTime = TypeConverter.StrToDateTime(time, DateTime.Parse("1900-01-01"));
if (dateTime.ToString("yyyy-MM-dd") == "1900-01-01")
return 1;
TimeSpan ts = DateTime.Now - dateTime.AddSeconds(Sec);
if (ts.TotalSeconds > int.MaxValue)
return int.MaxValue;
else if (ts.TotalSeconds < int.MinValue)
return int.MinValue;
return (int)ts.TotalSeconds;
}
/// <summary>
/// 返回相差的分钟数
/// </summary>
/// <param name="time"></param>
/// <param name="minutes"></param>
/// <returns></returns>
public static int StrDateDiffMinutes(string time, int minutes)
{
if (Validator.StrIsNullOrEmpty(time))
return 1;
DateTime dateTime = TypeConverter.StrToDateTime(time, DateTime.Parse("1900-01-01"));
if (dateTime.ToString("yyyy-MM-dd") == "1900-01-01")
return 1;
TimeSpan ts = DateTime.Now - dateTime.AddMinutes(minutes);
if (ts.TotalMinutes > int.MaxValue)
return int.MaxValue;
else if (ts.TotalMinutes < int.MinValue)
return int.MinValue;
return (int)ts.TotalMinutes;
}
/// <summary>
/// 返回相差的小时数
/// </summary>
/// <param name="time"></param>
/// <param name="hours"></param>
/// <returns></returns>
public static int StrDateDiffHours(string time, int hours)
{
if (Validator.StrIsNullOrEmpty(time))
return 1;
DateTime dateTime = TypeConverter.StrToDateTime(time, DateTime.Parse("1900-01-01"));
if (dateTime.ToString("yyyy-MM-dd") == "1900-01-01")
return 1;
TimeSpan ts = DateTime.Now - dateTime.AddHours(hours);
if (ts.TotalHours > int.MaxValue)
return int.MaxValue;
else if (ts.TotalHours < int.MinValue)
return int.MinValue;
return (int)ts.TotalHours;
}
#endregion
}
}
| 10aaa-10aaa | trunk/TRECommerce/TRECommon/DateTime/DateTimeUtils.cs | C# | oos | 5,616 |
/*
* Copyright (c) 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.javanet;
import com.google.api.client.googleapis.GoogleUtils;
import com.google.api.client.http.javanet.NetHttpTransport;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
/**
* Utilities for Google APIs based on {@link NetHttpTransport}.
*
* @since 1.14
* @author Yaniv Inbar
*/
public class GoogleNetHttpTransport {
/**
* Returns a new instance of {@link NetHttpTransport} that uses
* {@link GoogleUtils#getCertificateTrustStore()} for the trusted certificates using
* {@link com.google.api.client.http.javanet.NetHttpTransport.Builder#trustCertificates(KeyStore)}
* .
*
* <p>
* This helper method doesn't provide for customization of the {@link NetHttpTransport}, such as
* the ability to specify a proxy. To do use, use
* {@link com.google.api.client.http.javanet.NetHttpTransport.Builder}, for example:
* </p>
*
* <pre>
static HttpTransport newProxyTransport() throws GeneralSecurityException, IOException {
NetHttpTransport.Builder builder = new NetHttpTransport.Builder();
builder.trustCertificates(GoogleUtils.getCertificateTrustStore());
builder.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 3128)));
return builder.build();
}
* </pre>
*/
public static NetHttpTransport newTrustedTransport()
throws GeneralSecurityException, IOException {
return new NetHttpTransport.Builder().trustCertificates(GoogleUtils.getCertificateTrustStore())
.build();
}
private GoogleNetHttpTransport() {
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/javanet/GoogleNetHttpTransport.java | Java | asf20 | 2,207 |
/*
* Copyright (c) 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Google API's support based on the {@code java.net} package.
*
* @since 1.14
* @author Yaniv Inbar
*/
package com.google.api.client.googleapis.javanet;
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/javanet/package-info.java | Java | asf20 | 754 |
/*
* Copyright (c) 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.apache;
import com.google.api.client.googleapis.GoogleUtils;
import com.google.api.client.http.apache.ApacheHttpTransport;
import java.io.IOException;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
/**
* Utilities for Google APIs based on {@link ApacheHttpTransport}.
*
* @since 1.14
* @author Yaniv Inbar
*/
public final class GoogleApacheHttpTransport {
/**
* Returns a new instance of {@link ApacheHttpTransport} that uses
* {@link GoogleUtils#getCertificateTrustStore()} for the trusted certificates using
* {@link com.google.api.client.http.apache.ApacheHttpTransport.Builder#trustCertificates(KeyStore)}.
*/
public static ApacheHttpTransport newTrustedTransport() throws GeneralSecurityException,
IOException {
return new ApacheHttpTransport.Builder().trustCertificates(
GoogleUtils.getCertificateTrustStore()).build();
}
private GoogleApacheHttpTransport() {
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/apache/GoogleApacheHttpTransport.java | Java | asf20 | 1,582 |
/*
* Copyright (c) 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Google API's support based on the Apache HTTP Client.
*
* @since 1.14
* @author Yaniv Inbar
*/
package com.google.api.client.googleapis.apache;
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/apache/package-info.java | Java | asf20 | 747 |
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.services;
import com.google.api.client.googleapis.batch.BatchRequest;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.util.ObjectParser;
import com.google.api.client.util.Preconditions;
import com.google.api.client.util.Strings;
import java.io.IOException;
import java.util.logging.Logger;
/**
* Abstract thread-safe Google client.
*
* @since 1.12
* @author Yaniv Inbar
*/
public abstract class AbstractGoogleClient {
static final Logger LOGGER = Logger.getLogger(AbstractGoogleClient.class.getName());
/** The request factory for connections to the server. */
private final HttpRequestFactory requestFactory;
/**
* Initializer to use when creating an {@link AbstractGoogleClientRequest} or {@code null} for
* none.
*/
private final GoogleClientRequestInitializer googleClientRequestInitializer;
/**
* Root URL of the service, for example {@code "https://www.googleapis.com/"}. Must be URL-encoded
* and must end with a "/".
*/
private final String rootUrl;
/**
* Service path, for example {@code "tasks/v1/"}. Must be URL-encoded and must end with a "/".
*/
private final String servicePath;
/**
* Application name to be sent in the User-Agent header of each request or {@code null} for none.
*/
private final String applicationName;
/** Object parser or {@code null} for none. */
private final ObjectParser objectParser;
/** Whether discovery pattern checks should be suppressed on required parameters. */
private boolean suppressPatternChecks;
/** Whether discovery required parameter checks should be suppressed. */
private boolean suppressRequiredParameterChecks;
/**
* @param builder builder
*
* @since 1.14
*/
protected AbstractGoogleClient(Builder builder) {
googleClientRequestInitializer = builder.googleClientRequestInitializer;
rootUrl = normalizeRootUrl(builder.rootUrl);
servicePath = normalizeServicePath(builder.servicePath);
if (Strings.isNullOrEmpty(builder.applicationName)) {
LOGGER.warning("Application name is not set. Call Builder#setApplicationName.");
}
applicationName = builder.applicationName;
requestFactory = builder.httpRequestInitializer == null
? builder.transport.createRequestFactory()
: builder.transport.createRequestFactory(builder.httpRequestInitializer);
objectParser = builder.objectParser;
suppressPatternChecks = builder.suppressPatternChecks;
suppressRequiredParameterChecks = builder.suppressRequiredParameterChecks;
}
/**
* Returns the URL-encoded root URL of the service, for example
* {@code "https://www.googleapis.com/"}.
*
* <p>
* Must end with a "/".
* </p>
*/
public final String getRootUrl() {
return rootUrl;
}
/**
* Returns the URL-encoded service path of the service, for example {@code "tasks/v1/"}.
*
* <p>
* Must end with a "/" and not begin with a "/". It is allowed to be an empty string {@code ""} or
* a forward slash {@code "/"}, if it is a forward slash then it is treated as an empty string
* </p>
*/
public final String getServicePath() {
return servicePath;
}
/**
* Returns the URL-encoded base URL of the service, for example
* {@code "https://www.googleapis.com/tasks/v1/"}.
*
* <p>
* Must end with a "/". It is guaranteed to be equal to {@code getRootUrl() + getServicePath()}.
* </p>
*/
public final String getBaseUrl() {
return rootUrl + servicePath;
}
/**
* Returns the application name to be sent in the User-Agent header of each request or
* {@code null} for none.
*/
public final String getApplicationName() {
return applicationName;
}
/** Returns the HTTP request factory. */
public final HttpRequestFactory getRequestFactory() {
return requestFactory;
}
/** Returns the Google client request initializer or {@code null} for none. */
public final GoogleClientRequestInitializer getGoogleClientRequestInitializer() {
return googleClientRequestInitializer;
}
/**
* Returns the object parser or {@code null} for none.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public ObjectParser getObjectParser() {
return objectParser;
}
/**
* Initializes a {@link AbstractGoogleClientRequest} using a
* {@link GoogleClientRequestInitializer}.
*
* <p>
* Must be called before the Google client request is executed, preferably right after the request
* is instantiated. Sample usage:
* </p>
*
* <pre>
public class Get extends HttpClientRequest {
...
}
public Get get(String userId) throws IOException {
Get result = new Get(userId);
initialize(result);
return result;
}
* </pre>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @param httpClientRequest Google client request type
*/
protected void initialize(AbstractGoogleClientRequest<?> httpClientRequest) throws IOException {
if (getGoogleClientRequestInitializer() != null) {
getGoogleClientRequestInitializer().initialize(httpClientRequest);
}
}
/**
* Create an {@link BatchRequest} object from this Google API client instance.
*
* <p>
* Sample usage:
* </p>
*
* <pre>
client.batch()
.queue(...)
.queue(...)
.execute();
* </pre>
*
* @return newly created Batch request
*/
public final BatchRequest batch() {
return batch(null);
}
/**
* Create an {@link BatchRequest} object from this Google API client instance.
*
* <p>
* Sample usage:
* </p>
*
* <pre>
client.batch(httpRequestInitializer)
.queue(...)
.queue(...)
.execute();
* </pre>
*
* @param httpRequestInitializer The initializer to use when creating the top-level batch HTTP
* request or {@code null} for none
* @return newly created Batch request
*/
public final BatchRequest batch(HttpRequestInitializer httpRequestInitializer) {
BatchRequest batch =
new BatchRequest(getRequestFactory().getTransport(), httpRequestInitializer);
batch.setBatchUrl(new GenericUrl(getRootUrl() + "batch"));
return batch;
}
/** Returns whether discovery pattern checks should be suppressed on required parameters. */
public final boolean getSuppressPatternChecks() {
return suppressPatternChecks;
}
/**
* Returns whether discovery required parameter checks should be suppressed.
*
* @since 1.14
*/
public final boolean getSuppressRequiredParameterChecks() {
return suppressRequiredParameterChecks;
}
/** If the specified root URL does not end with a "/" then a "/" is added to the end. */
static String normalizeRootUrl(String rootUrl) {
Preconditions.checkNotNull(rootUrl, "root URL cannot be null.");
if (!rootUrl.endsWith("/")) {
rootUrl += "/";
}
return rootUrl;
}
/**
* If the specified service path does not end with a "/" then a "/" is added to the end. If the
* specified service path begins with a "/" then the "/" is removed.
*/
static String normalizeServicePath(String servicePath) {
Preconditions.checkNotNull(servicePath, "service path cannot be null");
if (servicePath.length() == 1) {
Preconditions.checkArgument(
"/".equals(servicePath), "service path must equal \"/\" if it is of length 1.");
servicePath = "";
} else if (servicePath.length() > 0) {
if (!servicePath.endsWith("/")) {
servicePath += "/";
}
if (servicePath.startsWith("/")) {
servicePath = servicePath.substring(1);
}
}
return servicePath;
}
/**
* Builder for {@link AbstractGoogleClient}.
*
* <p>
* Implementation is not thread-safe.
* </p>
*/
public abstract static class Builder {
/** HTTP transport. */
final HttpTransport transport;
/**
* Initializer to use when creating an {@link AbstractGoogleClientRequest} or {@code null} for
* none.
*/
GoogleClientRequestInitializer googleClientRequestInitializer;
/** HTTP request initializer or {@code null} for none. */
HttpRequestInitializer httpRequestInitializer;
/** Object parser to use for parsing responses. */
final ObjectParser objectParser;
/** The root URL of the service, for example {@code "https://www.googleapis.com/"}. */
String rootUrl;
/** The service path of the service, for example {@code "tasks/v1/"}. */
String servicePath;
/**
* Application name to be sent in the User-Agent header of each request or {@code null} for
* none.
*/
String applicationName;
/** Whether discovery pattern checks should be suppressed on required parameters. */
boolean suppressPatternChecks;
/** Whether discovery required parameter checks should be suppressed. */
boolean suppressRequiredParameterChecks;
/**
* Returns an instance of a new builder.
*
* @param transport The transport to use for requests
* @param rootUrl root URL of the service. Must end with a "/"
* @param servicePath service path
* @param objectParser object parser or {@code null} for none
* @param httpRequestInitializer HTTP request initializer or {@code null} for none
*/
protected Builder(HttpTransport transport, String rootUrl, String servicePath,
ObjectParser objectParser, HttpRequestInitializer httpRequestInitializer) {
this.transport = Preconditions.checkNotNull(transport);
this.objectParser = objectParser;
setRootUrl(rootUrl);
setServicePath(servicePath);
this.httpRequestInitializer = httpRequestInitializer;
}
/** Builds a new instance of {@link AbstractGoogleClient}. */
public abstract AbstractGoogleClient build();
/** Returns the HTTP transport. */
public final HttpTransport getTransport() {
return transport;
}
/**
* Returns the object parser or {@code null} for none.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public ObjectParser getObjectParser() {
return objectParser;
}
/**
* Returns the URL-encoded root URL of the service, for example
* {@code https://www.googleapis.com/}.
*
* <p>
* Must be URL-encoded and must end with a "/".
* </p>
*/
public final String getRootUrl() {
return rootUrl;
}
/**
* Sets the URL-encoded root URL of the service, for example {@code https://www.googleapis.com/}
* .
* <p>
* If the specified root URL does not end with a "/" then a "/" is added to the end.
* </p>
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public Builder setRootUrl(String rootUrl) {
this.rootUrl = normalizeRootUrl(rootUrl);
return this;
}
/**
* Returns the URL-encoded service path of the service, for example {@code "tasks/v1/"}.
*
* <p>
* Must be URL-encoded and must end with a "/" and not begin with a "/". It is allowed to be an
* empty string {@code ""}.
* </p>
*/
public final String getServicePath() {
return servicePath;
}
/**
* Sets the URL-encoded service path of the service, for example {@code "tasks/v1/"}.
*
* <p>
* It is allowed to be an empty string {@code ""} or a forward slash {@code "/"}, if it is a
* forward slash then it is treated as an empty string. This is determined when the library is
* generated and normally should not be changed.
* </p>
*
* <p>
* If the specified service path does not end with a "/" then a "/" is added to the end. If the
* specified service path begins with a "/" then the "/" is removed.
* </p>
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public Builder setServicePath(String servicePath) {
this.servicePath = normalizeServicePath(servicePath);
return this;
}
/** Returns the Google client request initializer or {@code null} for none. */
public final GoogleClientRequestInitializer getGoogleClientRequestInitializer() {
return googleClientRequestInitializer;
}
/**
* Sets the Google client request initializer or {@code null} for none.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public Builder setGoogleClientRequestInitializer(
GoogleClientRequestInitializer googleClientRequestInitializer) {
this.googleClientRequestInitializer = googleClientRequestInitializer;
return this;
}
/** Returns the HTTP request initializer or {@code null} for none. */
public final HttpRequestInitializer getHttpRequestInitializer() {
return httpRequestInitializer;
}
/**
* Sets the HTTP request initializer or {@code null} for none.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public Builder setHttpRequestInitializer(HttpRequestInitializer httpRequestInitializer) {
this.httpRequestInitializer = httpRequestInitializer;
return this;
}
/**
* Returns the application name to be used in the UserAgent header of each request or
* {@code null} for none.
*/
public final String getApplicationName() {
return applicationName;
}
/**
* Sets the application name to be used in the UserAgent header of each request or {@code null}
* for none.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public Builder setApplicationName(String applicationName) {
this.applicationName = applicationName;
return this;
}
/** Returns whether discovery pattern checks should be suppressed on required parameters. */
public final boolean getSuppressPatternChecks() {
return suppressPatternChecks;
}
/**
* Sets whether discovery pattern checks should be suppressed on required parameters.
*
* <p>
* Default value is {@code false}.
* </p>
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public Builder setSuppressPatternChecks(boolean suppressPatternChecks) {
this.suppressPatternChecks = suppressPatternChecks;
return this;
}
/**
* Returns whether discovery required parameter checks should be suppressed.
*
* @since 1.14
*/
public final boolean getSuppressRequiredParameterChecks() {
return suppressRequiredParameterChecks;
}
/**
* Sets whether discovery required parameter checks should be suppressed.
*
* <p>
* Default value is {@code false}.
* </p>
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*
* @since 1.14
*/
public Builder setSuppressRequiredParameterChecks(boolean suppressRequiredParameterChecks) {
this.suppressRequiredParameterChecks = suppressRequiredParameterChecks;
return this;
}
/**
* Suppresses all discovery pattern and required parameter checks.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*
* @since 1.14
*/
public Builder setSuppressAllChecks(boolean suppressAllChecks) {
return setSuppressPatternChecks(true).setSuppressRequiredParameterChecks(true);
}
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClient.java | Java | asf20 | 17,203 |
/*
* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.services.json;
import com.google.api.client.googleapis.batch.BatchRequest;
import com.google.api.client.googleapis.batch.json.JsonBatchCallback;
import com.google.api.client.googleapis.json.GoogleJsonErrorContainer;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.UriTemplate;
import com.google.api.client.http.json.JsonHttpContent;
import java.io.IOException;
/**
* Google JSON request for a {@link AbstractGoogleJsonClient}.
*
* <p>
* Implementation is not thread-safe.
* </p>
*
* @param <T> type of the response
* @since 1.12
* @author Yaniv Inbar
*/
public abstract class AbstractGoogleJsonClientRequest<T> extends AbstractGoogleClientRequest<T> {
/** POJO that can be serialized into JSON content or {@code null} for none. */
private final Object jsonContent;
/**
* @param abstractGoogleJsonClient Google JSON client
* @param requestMethod HTTP Method
* @param uriTemplate URI template for the path relative to the base URL. If it starts with a "/"
* the base path from the base URL will be stripped out. The URI template can also be a
* full URL. URI template expansion is done using
* {@link UriTemplate#expand(String, String, Object, boolean)}
* @param jsonContent POJO that can be serialized into JSON content or {@code null} for none
* @param responseClass response class to parse into
*/
protected AbstractGoogleJsonClientRequest(AbstractGoogleJsonClient abstractGoogleJsonClient,
String requestMethod, String uriTemplate, Object jsonContent, Class<T> responseClass) {
super(abstractGoogleJsonClient, requestMethod, uriTemplate, jsonContent == null ? null
: new JsonHttpContent(abstractGoogleJsonClient.getJsonFactory(), jsonContent)
.setWrapperKey(abstractGoogleJsonClient.getObjectParser().getWrapperKeys().isEmpty()
? null : "data"), responseClass);
this.jsonContent = jsonContent;
}
@Override
public AbstractGoogleJsonClient getAbstractGoogleClient() {
return (AbstractGoogleJsonClient) super.getAbstractGoogleClient();
}
@Override
public AbstractGoogleJsonClientRequest<T> setDisableGZipContent(boolean disableGZipContent) {
return (AbstractGoogleJsonClientRequest<T>) super.setDisableGZipContent(disableGZipContent);
}
@Override
public AbstractGoogleJsonClientRequest<T> setRequestHeaders(HttpHeaders headers) {
return (AbstractGoogleJsonClientRequest<T>) super.setRequestHeaders(headers);
}
/**
* Queues the request into the specified batch request container.
*
* <p>
* Batched requests are then executed when {@link BatchRequest#execute()} is called.
* </p>
* <p>
* Example usage:
* </p>
*
* <pre>
request.queue(batchRequest, new JsonBatchCallback<SomeResponseType>() {
public void onSuccess(SomeResponseType content, HttpHeaders responseHeaders) {
log("Success");
}
public void onFailure(GoogleJsonError e, HttpHeaders responseHeaders) {
log(e.getMessage());
}
});
* </pre>
*
*
* @param batchRequest batch request container
* @param callback batch callback
*/
public final void queue(BatchRequest batchRequest, JsonBatchCallback<T> callback)
throws IOException {
super.queue(batchRequest, GoogleJsonErrorContainer.class, callback);
}
@Override
protected GoogleJsonResponseException newExceptionOnError(HttpResponse response) {
return GoogleJsonResponseException.from(getAbstractGoogleClient().getJsonFactory(), response);
}
/** Returns POJO that can be serialized into JSON content or {@code null} for none. */
public Object getJsonContent() {
return jsonContent;
}
@Override
public AbstractGoogleJsonClientRequest<T> set(String fieldName, Object value) {
return (AbstractGoogleJsonClientRequest<T>) super.set(fieldName, value);
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/json/AbstractGoogleJsonClientRequest.java | Java | asf20 | 4,735 |
/*
* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.services.json;
import com.google.api.client.googleapis.services.AbstractGoogleClient;
import com.google.api.client.googleapis.services.GoogleClientRequestInitializer;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import java.util.Arrays;
import java.util.Collections;
/**
* Thread-safe Google JSON client.
*
* @since 1.12
* @author Yaniv Inbar
*/
public abstract class AbstractGoogleJsonClient extends AbstractGoogleClient {
/**
* @param builder builder
*
* @since 1.14
*/
protected AbstractGoogleJsonClient(Builder builder) {
super(builder);
}
@Override
public JsonObjectParser getObjectParser() {
return (JsonObjectParser) super.getObjectParser();
}
/** Returns the JSON Factory. */
public final JsonFactory getJsonFactory() {
return getObjectParser().getJsonFactory();
}
/**
* Builder for {@link AbstractGoogleJsonClient}.
*
* <p>
* Implementation is not thread-safe.
* </p>
*/
public abstract static class Builder extends AbstractGoogleClient.Builder {
/**
* @param transport HTTP transport
* @param jsonFactory JSON factory
* @param rootUrl root URL of the service
* @param servicePath service path
* @param httpRequestInitializer HTTP request initializer or {@code null} for none
* @param legacyDataWrapper whether using the legacy data wrapper in responses
*/
protected Builder(HttpTransport transport, JsonFactory jsonFactory, String rootUrl,
String servicePath, HttpRequestInitializer httpRequestInitializer,
boolean legacyDataWrapper) {
super(transport, rootUrl, servicePath, new JsonObjectParser.Builder(
jsonFactory).setWrapperKeys(
legacyDataWrapper ? Arrays.asList("data", "error") : Collections.<String>emptySet())
.build(), httpRequestInitializer);
}
@Override
public final JsonObjectParser getObjectParser() {
return (JsonObjectParser) super.getObjectParser();
}
/** Returns the JSON Factory. */
public final JsonFactory getJsonFactory() {
return getObjectParser().getJsonFactory();
}
@Override
public abstract AbstractGoogleJsonClient build();
@Override
public Builder setRootUrl(String rootUrl) {
return (Builder) super.setRootUrl(rootUrl);
}
@Override
public Builder setServicePath(String servicePath) {
return (Builder) super.setServicePath(servicePath);
}
@Override
public Builder setGoogleClientRequestInitializer(
GoogleClientRequestInitializer googleClientRequestInitializer) {
return (Builder) super.setGoogleClientRequestInitializer(googleClientRequestInitializer);
}
@Override
public Builder setHttpRequestInitializer(HttpRequestInitializer httpRequestInitializer) {
return (Builder) super.setHttpRequestInitializer(httpRequestInitializer);
}
@Override
public Builder setApplicationName(String applicationName) {
return (Builder) super.setApplicationName(applicationName);
}
@Override
public Builder setSuppressPatternChecks(boolean suppressPatternChecks) {
return (Builder) super.setSuppressPatternChecks(suppressPatternChecks);
}
@Override
public Builder setSuppressRequiredParameterChecks(boolean suppressRequiredParameterChecks) {
return (Builder) super.setSuppressRequiredParameterChecks(suppressRequiredParameterChecks);
}
@Override
public Builder setSuppressAllChecks(boolean suppressAllChecks) {
return (Builder) super.setSuppressAllChecks(suppressAllChecks);
}
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/json/AbstractGoogleJsonClient.java | Java | asf20 | 4,378 |
/*
* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Contains the basis for the generated service-specific libraries based on the JSON format.
*
* @since 1.12
* @author Yaniv Inbar
*/
package com.google.api.client.googleapis.services.json;
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/json/package-info.java | Java | asf20 | 790 |
/*
* Copyright (c) 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.services.json;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest;
import com.google.api.client.googleapis.services.CommonGoogleClientRequestInitializer;
import java.io.IOException;
/**
* Google JSON client request initializer implementation for setting properties like key and userIp.
*
* <p>
* The simplest usage is to use it to set the key parameter:
* </p>
*
* <pre>
public static final GoogleClientRequestInitializer KEY_INITIALIZER =
new CommonGoogleJsonClientRequestInitializer(KEY);
* </pre>
*
* <p>
* There is also a constructor to set both the key and userIp parameters:
* </p>
*
* <pre>
public static final GoogleClientRequestInitializer INITIALIZER =
new CommonGoogleJsonClientRequestInitializer(KEY, USER_IP);
* </pre>
*
* <p>
* If you want to implement custom logic, extend it like this:
* </p>
*
* <pre>
public static class MyRequestInitializer extends CommonGoogleJsonClientRequestInitializer {
{@literal @}Override
public void initialize(AbstractGoogleJsonClientRequest{@literal <}?{@literal >} request)
throws IOException {
// custom logic
}
}
* </pre>
*
* <p>
* Finally, to set the key and userIp parameters and insert custom logic, extend it like this:
* </p>
*
* <pre>
public static class MyKeyRequestInitializer extends CommonGoogleJsonClientRequestInitializer {
public MyKeyRequestInitializer() {
super(KEY, USER_IP);
}
{@literal @}Override
public void initializeJsonRequest(
AbstractGoogleJsonClientRequest{@literal <}?{@literal >} request) throws IOException {
// custom logic
}
}
* </pre>
*
* <p>
* Subclasses should be thread-safe.
* </p>
*
* @since 1.12
* @author Yaniv Inbar
*/
public class CommonGoogleJsonClientRequestInitializer extends CommonGoogleClientRequestInitializer {
public CommonGoogleJsonClientRequestInitializer() {
super();
}
/**
* @param key API key or {@code null} to leave it unchanged
*/
public CommonGoogleJsonClientRequestInitializer(String key) {
super(key);
}
/**
* @param key API key or {@code null} to leave it unchanged
* @param userIp user IP or {@code null} to leave it unchanged
*/
public CommonGoogleJsonClientRequestInitializer(String key, String userIp) {
super(key, userIp);
}
@Override
public final void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
super.initialize(request);
initializeJsonRequest((AbstractGoogleJsonClientRequest<?>) request);
}
/**
* Initializes a Google JSON client request.
*
* <p>
* Default implementation does nothing. Called from
* {@link #initialize(AbstractGoogleClientRequest)}.
* </p>
*
* @throws IOException I/O exception
*/
protected void initializeJsonRequest(AbstractGoogleJsonClientRequest<?> request)
throws IOException {
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/json/CommonGoogleJsonClientRequestInitializer.java | Java | asf20 | 3,542 |
/*
* Copyright (c) 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* Contains the basis for the generated service-specific libraries.
*
* @since 1.6
* @author Ravi Mistry
*/
package com.google.api.client.googleapis.services;
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/package-info.java | Java | asf20 | 759 |
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.services;
import java.io.IOException;
/**
* Google client request initializer.
*
* <p>
* For example, this might be used to set a key URL query parameter on all requests:
* </p>
*
* <pre>
public class KeyRequestInitializer implements GoogleClientRequestInitializer {
public void initialize(GoogleClientRequest<?> request) {
request.put("key", KEY);
}
}
* </pre>
*
* <p>
* Implementations should be thread-safe.
* </p>
*
* @since 1.12
* @author Yaniv Inbar
*/
public interface GoogleClientRequestInitializer {
/** Initializes a Google client request. */
void initialize(AbstractGoogleClientRequest<?> request) throws IOException;
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/GoogleClientRequestInitializer.java | Java | asf20 | 1,266 |
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.services;
import com.google.api.client.googleapis.MethodOverride;
import com.google.api.client.googleapis.batch.BatchCallback;
import com.google.api.client.googleapis.batch.BatchRequest;
import com.google.api.client.googleapis.media.MediaHttpDownloader;
import com.google.api.client.googleapis.media.MediaHttpUploader;
import com.google.api.client.http.AbstractInputStreamContent;
import com.google.api.client.http.EmptyContent;
import com.google.api.client.http.GZipEncoding;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpContent;
import com.google.api.client.http.HttpHeaders;
import com.google.api.client.http.HttpMethods;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestFactory;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpResponse;
import com.google.api.client.http.HttpResponseException;
import com.google.api.client.http.HttpResponseInterceptor;
import com.google.api.client.http.UriTemplate;
import com.google.api.client.util.GenericData;
import com.google.api.client.util.Preconditions;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
/**
* Abstract Google client request for a {@link AbstractGoogleClient}.
*
* <p>
* Implementation is not thread-safe.
* </p>
*
* @param <T> type of the response
*
* @since 1.12
* @author Yaniv Inbar
*/
public abstract class AbstractGoogleClientRequest<T> extends GenericData {
/** Google client. */
private final AbstractGoogleClient abstractGoogleClient;
/** HTTP method. */
private final String requestMethod;
/** URI template for the path relative to the base URL. */
private final String uriTemplate;
/** HTTP content or {@code null} for none. */
private final HttpContent httpContent;
/** HTTP headers used for the Google client request. */
private HttpHeaders requestHeaders = new HttpHeaders();
/** HTTP headers of the last response or {@code null} before request has been executed. */
private HttpHeaders lastResponseHeaders;
/** Status code of the last response or {@code -1} before request has been executed. */
private int lastStatusCode = -1;
/** Status message of the last response or {@code null} before request has been executed. */
private String lastStatusMessage;
/** Whether to disable GZip compression of HTTP content. */
private boolean disableGZipContent;
/** Response class to parse into. */
private Class<T> responseClass;
/** Media HTTP uploader or {@code null} for none. */
private MediaHttpUploader uploader;
/** Media HTTP downloader or {@code null} for none. */
private MediaHttpDownloader downloader;
/**
* @param abstractGoogleClient Google client
* @param requestMethod HTTP Method
* @param uriTemplate URI template for the path relative to the base URL. If it starts with a "/"
* the base path from the base URL will be stripped out. The URI template can also be a
* full URL. URI template expansion is done using
* {@link UriTemplate#expand(String, String, Object, boolean)}
* @param httpContent HTTP content or {@code null} for none
* @param responseClass response class to parse into
*/
protected AbstractGoogleClientRequest(AbstractGoogleClient abstractGoogleClient,
String requestMethod, String uriTemplate, HttpContent httpContent, Class<T> responseClass) {
this.responseClass = Preconditions.checkNotNull(responseClass);
this.abstractGoogleClient = Preconditions.checkNotNull(abstractGoogleClient);
this.requestMethod = Preconditions.checkNotNull(requestMethod);
this.uriTemplate = Preconditions.checkNotNull(uriTemplate);
this.httpContent = httpContent;
// application name
String applicationName = abstractGoogleClient.getApplicationName();
if (applicationName != null) {
requestHeaders.setUserAgent(applicationName);
}
}
/** Returns whether to disable GZip compression of HTTP content. */
public final boolean getDisableGZipContent() {
return disableGZipContent;
}
/**
* Sets whether to disable GZip compression of HTTP content.
*
* <p>
* By default it is {@code false}.
* </p>
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public AbstractGoogleClientRequest<T> setDisableGZipContent(boolean disableGZipContent) {
this.disableGZipContent = disableGZipContent;
return this;
}
/** Returns the HTTP method. */
public final String getRequestMethod() {
return requestMethod;
}
/** Returns the URI template for the path relative to the base URL. */
public final String getUriTemplate() {
return uriTemplate;
}
/** Returns the HTTP content or {@code null} for none. */
public final HttpContent getHttpContent() {
return httpContent;
}
/**
* Returns the Google client.
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public AbstractGoogleClient getAbstractGoogleClient() {
return abstractGoogleClient;
}
/** Returns the HTTP headers used for the Google client request. */
public final HttpHeaders getRequestHeaders() {
return requestHeaders;
}
/**
* Sets the HTTP headers used for the Google client request.
*
* <p>
* These headers are set on the request after {@link #buildHttpRequest} is called, this means that
* {@link HttpRequestInitializer#initialize} is called first.
* </p>
*
* <p>
* Overriding is only supported for the purpose of calling the super implementation and changing
* the return type, but nothing else.
* </p>
*/
public AbstractGoogleClientRequest<T> setRequestHeaders(HttpHeaders headers) {
this.requestHeaders = headers;
return this;
}
/**
* Returns the HTTP headers of the last response or {@code null} before request has been executed.
*/
public final HttpHeaders getLastResponseHeaders() {
return lastResponseHeaders;
}
/**
* Returns the status code of the last response or {@code -1} before request has been executed.
*/
public final int getLastStatusCode() {
return lastStatusCode;
}
/**
* Returns the status message of the last response or {@code null} before request has been
* executed.
*/
public final String getLastStatusMessage() {
return lastStatusMessage;
}
/** Returns the response class to parse into. */
public final Class<T> getResponseClass() {
return responseClass;
}
/** Returns the media HTTP Uploader or {@code null} for none. */
public final MediaHttpUploader getMediaHttpUploader() {
return uploader;
}
/**
* Initializes the media HTTP uploader based on the media content.
*
* @param mediaContent media content
*/
protected final void initializeMediaUpload(AbstractInputStreamContent mediaContent) {
HttpRequestFactory requestFactory = abstractGoogleClient.getRequestFactory();
this.uploader = new MediaHttpUploader(
mediaContent, requestFactory.getTransport(), requestFactory.getInitializer());
this.uploader.setInitiationRequestMethod(requestMethod);
if (httpContent != null) {
this.uploader.setMetadata(httpContent);
}
}
/** Returns the media HTTP downloader or {@code null} for none. */
public final MediaHttpDownloader getMediaHttpDownloader() {
return downloader;
}
/** Initializes the media HTTP downloader. */
protected final void initializeMediaDownload() {
HttpRequestFactory requestFactory = abstractGoogleClient.getRequestFactory();
this.downloader =
new MediaHttpDownloader(requestFactory.getTransport(), requestFactory.getInitializer());
}
/**
* Creates a new instance of {@link GenericUrl} suitable for use against this service.
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @return newly created {@link GenericUrl}
*/
public GenericUrl buildHttpRequestUrl() {
return new GenericUrl(
UriTemplate.expand(abstractGoogleClient.getBaseUrl(), uriTemplate, this, true));
}
/**
* Create a request suitable for use against this service.
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*/
public HttpRequest buildHttpRequest() throws IOException {
return buildHttpRequest(false);
}
/**
* Create a request suitable for use against this service, but using HEAD instead of GET.
*
* <p>
* Only supported when the original request method is GET.
* </p>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*/
protected HttpRequest buildHttpRequestUsingHead() throws IOException {
return buildHttpRequest(true);
}
/** Create a request suitable for use against this service. */
private HttpRequest buildHttpRequest(boolean usingHead) throws IOException {
Preconditions.checkArgument(uploader == null);
Preconditions.checkArgument(!usingHead || requestMethod.equals(HttpMethods.GET));
String requestMethodToUse = usingHead ? HttpMethods.HEAD : requestMethod;
final HttpRequest httpRequest = getAbstractGoogleClient()
.getRequestFactory().buildRequest(requestMethodToUse, buildHttpRequestUrl(), httpContent);
new MethodOverride().intercept(httpRequest);
httpRequest.setParser(getAbstractGoogleClient().getObjectParser());
// custom methods may use POST with no content but require a Content-Length header
if (httpContent == null && (requestMethod.equals(HttpMethods.POST)
|| requestMethod.equals(HttpMethods.PUT) || requestMethod.equals(HttpMethods.PATCH))) {
httpRequest.setContent(new EmptyContent());
}
httpRequest.getHeaders().putAll(requestHeaders);
if (!disableGZipContent) {
httpRequest.setEncoding(new GZipEncoding());
}
final HttpResponseInterceptor responseInterceptor = httpRequest.getResponseInterceptor();
httpRequest.setResponseInterceptor(new HttpResponseInterceptor() {
public void interceptResponse(HttpResponse response) throws IOException {
if (responseInterceptor != null) {
responseInterceptor.interceptResponse(response);
}
if (!response.isSuccessStatusCode() && httpRequest.getThrowExceptionOnExecuteError()) {
throw newExceptionOnError(response);
}
}
});
return httpRequest;
}
/**
* Sends the metadata request to the server and returns the raw metadata {@link HttpResponse}.
*
* <p>
* Callers are responsible for disconnecting the HTTP response by calling
* {@link HttpResponse#disconnect}. Example usage:
* </p>
*
* <pre>
HttpResponse response = request.executeUnparsed();
try {
// process response..
} finally {
response.disconnect();
}
* </pre>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @return the {@link HttpResponse}
*/
public HttpResponse executeUnparsed() throws IOException {
return executeUnparsed(false);
}
/**
* Sends the media request to the server and returns the raw media {@link HttpResponse}.
*
* <p>
* Callers are responsible for disconnecting the HTTP response by calling
* {@link HttpResponse#disconnect}. Example usage:
* </p>
*
* <pre>
HttpResponse response = request.executeMedia();
try {
// process response..
} finally {
response.disconnect();
}
* </pre>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @return the {@link HttpResponse}
*/
protected HttpResponse executeMedia() throws IOException {
set("alt", "media");
return executeUnparsed();
}
/**
* Sends the metadata request using HEAD to the server and returns the raw metadata
* {@link HttpResponse} for the response headers.
*
* <p>
* Only supported when the original request method is GET. The response content is assumed to be
* empty and ignored. Calls {@link HttpResponse#ignore()} so there is no need to disconnect the
* response. Example usage:
* </p>
*
* <pre>
HttpResponse response = request.executeUsingHead();
// look at response.getHeaders()
* </pre>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @return the {@link HttpResponse}
*/
protected HttpResponse executeUsingHead() throws IOException {
Preconditions.checkArgument(uploader == null);
HttpResponse response = executeUnparsed(true);
response.ignore();
return response;
}
/**
* Sends the metadata request using the given request method to the server and returns the raw
* metadata {@link HttpResponse}.
*/
private HttpResponse executeUnparsed(boolean usingHead) throws IOException {
HttpResponse response;
if (uploader == null) {
// normal request (not upload)
response = buildHttpRequest(usingHead).execute();
} else {
// upload request
GenericUrl httpRequestUrl = buildHttpRequestUrl();
HttpRequest httpRequest = getAbstractGoogleClient()
.getRequestFactory().buildRequest(requestMethod, httpRequestUrl, httpContent);
boolean throwExceptionOnExecuteError = httpRequest.getThrowExceptionOnExecuteError();
response = uploader.setInitiationHeaders(requestHeaders)
.setDisableGZipContent(disableGZipContent).upload(httpRequestUrl);
response.getRequest().setParser(getAbstractGoogleClient().getObjectParser());
// process any error
if (throwExceptionOnExecuteError && !response.isSuccessStatusCode()) {
throw newExceptionOnError(response);
}
}
// process response
lastResponseHeaders = response.getHeaders();
lastStatusCode = response.getStatusCode();
lastStatusMessage = response.getStatusMessage();
return response;
}
/**
* Returns the exception to throw on an HTTP error response as defined by
* {@link HttpResponse#isSuccessStatusCode()}.
*
* <p>
* It is guaranteed that {@link HttpResponse#isSuccessStatusCode()} is {@code false}. Default
* implementation is to call {@link HttpResponseException#HttpResponseException(HttpResponse)},
* but subclasses may override.
* </p>
*
* @param response HTTP response
* @return exception to throw
*/
protected IOException newExceptionOnError(HttpResponse response) {
return new HttpResponseException(response);
}
/**
* Sends the metadata request to the server and returns the parsed metadata response.
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @return parsed HTTP response
*/
public T execute() throws IOException {
return executeUnparsed().parseAs(responseClass);
}
/**
* Sends the metadata request to the server and returns the metadata content input stream of
* {@link HttpResponse}.
*
* <p>
* Callers are responsible for closing the input stream after it is processed. Example sample:
* </p>
*
* <pre>
InputStream is = request.executeAsInputStream();
try {
// Process input stream..
} finally {
is.close();
}
* </pre>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @return input stream of the response content
*/
public InputStream executeAsInputStream() throws IOException {
return executeUnparsed().getContent();
}
/**
* Sends the media request to the server and returns the media content input stream of
* {@link HttpResponse}.
*
* <p>
* Callers are responsible for closing the input stream after it is processed. Example sample:
* </p>
*
* <pre>
InputStream is = request.executeMediaAsInputStream();
try {
// Process input stream..
} finally {
is.close();
}
* </pre>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @return input stream of the response content
*/
protected InputStream executeMediaAsInputStream() throws IOException {
return executeMedia().getContent();
}
/**
* Sends the metadata request to the server and writes the metadata content input stream of
* {@link HttpResponse} into the given destination output stream.
*
* <p>
* This method closes the content of the HTTP response from {@link HttpResponse#getContent()}.
* </p>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @param outputStream destination output stream
*/
public void executeAndDownloadTo(OutputStream outputStream) throws IOException {
executeUnparsed().download(outputStream);
}
/**
* Sends the media request to the server and writes the media content input stream of
* {@link HttpResponse} into the given destination output stream.
*
* <p>
* This method closes the content of the HTTP response from {@link HttpResponse#getContent()}.
* </p>
*
* <p>
* Subclasses may override by calling the super implementation.
* </p>
*
* @param outputStream destination output stream
*/
protected void executeMediaAndDownloadTo(OutputStream outputStream) throws IOException {
if (downloader == null) {
executeMedia().download(outputStream);
} else {
downloader.download(buildHttpRequestUrl(), requestHeaders, outputStream);
}
}
/**
* Queues the request into the specified batch request container using the specified error class.
*
* <p>
* Batched requests are then executed when {@link BatchRequest#execute()} is called.
* </p>
*
* @param batchRequest batch request container
* @param errorClass data class the unsuccessful response will be parsed into or
* {@code Void.class} to ignore the content
* @param callback batch callback
*/
public final <E> void queue(
BatchRequest batchRequest, Class<E> errorClass, BatchCallback<T, E> callback)
throws IOException {
Preconditions.checkArgument(uploader == null, "Batching media requests is not supported");
batchRequest.queue(buildHttpRequest(), getResponseClass(), errorClass, callback);
}
// @SuppressWarnings was added here because this is generic class.
// see: http://stackoverflow.com/questions/4169806/java-casting-object-to-a-generic-type and
// http://www.angelikalanger.com/GenericsFAQ/FAQSections/TechnicalDetails.html#Type%20Erasure
// for more details
@SuppressWarnings("unchecked")
@Override
public AbstractGoogleClientRequest<T> set(String fieldName, Object value) {
return (AbstractGoogleClientRequest<T>) super.set(fieldName, value);
}
/**
* Ensures that the specified required parameter is not null or
* {@link AbstractGoogleClient#getSuppressRequiredParameterChecks()} is true.
*
* @param value the value of the required parameter
* @param name the name of the required parameter
* @throws IllegalArgumentException if the specified required parameter is null and
* {@link AbstractGoogleClient#getSuppressRequiredParameterChecks()} is false
* @since 1.14
*/
protected final void checkRequiredParameter(Object value, String name) {
Preconditions.checkArgument(
abstractGoogleClient.getSuppressRequiredParameterChecks() || value != null,
"Required parameter %s must be specified", name);
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/AbstractGoogleClientRequest.java | Java | asf20 | 20,251 |
/*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.services;
import java.io.IOException;
/**
* Google common client request initializer implementation for setting properties like key and
* userIp.
*
* <p>
* The simplest usage is to use it to set the key parameter:
* </p>
*
* <pre>
public static final GoogleClientRequestInitializer KEY_INITIALIZER =
new CommonGoogleClientRequestInitializer(KEY);
* </pre>
*
* <p>
* There is also a constructor to set both the key and userIp parameters:
* </p>
*
* <pre>
public static final GoogleClientRequestInitializer INITIALIZER =
new CommonGoogleClientRequestInitializer(KEY, USER_IP);
* </pre>
*
* <p>
* If you want to implement custom logic, extend it like this:
* </p>
*
* <pre>
public static class MyRequestInitializer extends CommonGoogleClientRequestInitializer {
{@literal @}Override
public void initialize(AbstractGoogleClientRequest{@literal <}?{@literal >} request)
throws IOException {
// custom logic
}
}
* </pre>
*
* <p>
* Finally, to set the key and userIp parameters and insert custom logic, extend it like this:
* </p>
*
* <pre>
public static class MyRequestInitializer2 extends CommonGoogleClientRequestInitializer {
public MyRequestInitializer2() {
super(KEY, USER_IP);
}
{@literal @}Override
public void initialize(AbstractGoogleClientRequest{@literal <}?{@literal >} request)
throws IOException {
super.initialize(request); // must be called to set the key and userIp parameters
// insert some additional logic
}
}
* </pre>
*
* <p>
* Subclasses should be thread-safe.
* </p>
*
* @since 1.12
* @author Yaniv Inbar
*/
public class CommonGoogleClientRequestInitializer implements GoogleClientRequestInitializer {
/** API key or {@code null} to leave it unchanged. */
private final String key;
/** User IP or {@code null} to leave it unchanged. */
private final String userIp;
public CommonGoogleClientRequestInitializer() {
this(null);
}
/**
* @param key API key or {@code null} to leave it unchanged
*/
public CommonGoogleClientRequestInitializer(String key) {
this(key, null);
}
/**
* @param key API key or {@code null} to leave it unchanged
* @param userIp user IP or {@code null} to leave it unchanged
*/
public CommonGoogleClientRequestInitializer(String key, String userIp) {
this.key = key;
this.userIp = userIp;
}
/**
* Subclasses should call super implementation in order to set the key and userIp.
*
* @throws IOException I/O exception
*/
public void initialize(AbstractGoogleClientRequest<?> request) throws IOException {
if (key != null) {
request.put("key", key);
}
if (userIp != null) {
request.put("userIp", userIp);
}
}
/** Returns the API key or {@code null} to leave it unchanged. */
public final String getKey() {
return key;
}
/** Returns the user IP or {@code null} to leave it unchanged. */
public final String getUserIp() {
return userIp;
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/services/CommonGoogleClientRequestInitializer.java | Java | asf20 | 3,635 |
/*
* Copyright (c) 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis.compute;
import com.google.api.client.auth.oauth2.BearerToken;
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.auth.oauth2.CredentialRefreshListener;
import com.google.api.client.auth.oauth2.TokenResponse;
import com.google.api.client.http.GenericUrl;
import com.google.api.client.http.HttpExecuteInterceptor;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.JsonObjectParser;
import com.google.api.client.util.Beta;
import com.google.api.client.util.Clock;
import com.google.api.client.util.Preconditions;
import java.io.IOException;
import java.util.Collection;
/**
* {@link Beta} <br/>
* Google Compute Engine service accounts OAuth 2.0 credential based on <a
* href="https://developers.google.com/compute/docs/authentication">Authenticating from Google
* Compute Engine</a>.
*
* <p>
* Sample usage:
* </p>
*
* <pre>
public static HttpRequestFactory createRequestFactory(
HttpTransport transport, JsonFactory jsonFactory) {
return transport.createRequestFactory(new GoogleComputeCredential(transport, jsonFactory));
}
* </pre>
*
* <p>
* Implementation is immutable and thread-safe.
* </p>
*
* @since 1.15
* @author Yaniv Inbar
*/
@Beta
public class ComputeCredential extends Credential {
/** Metadata Service Account token server encoded URL. */
public static final String TOKEN_SERVER_ENCODED_URL =
"http://metadata/computeMetadata/v1beta1/instance/service-accounts/default/token";
/**
* @param transport HTTP transport
* @param jsonFactory JSON factory
*/
public ComputeCredential(HttpTransport transport, JsonFactory jsonFactory) {
this(new Builder(transport, jsonFactory));
}
/**
* @param builder builder
*/
protected ComputeCredential(Builder builder) {
super(builder);
}
@Override
protected TokenResponse executeRefreshToken() throws IOException {
GenericUrl tokenUrl = new GenericUrl(getTokenServerEncodedUrl());
HttpRequest request = getTransport().createRequestFactory().buildGetRequest(tokenUrl);
request.setParser(new JsonObjectParser(getJsonFactory()));
return request.execute().parseAs(TokenResponse.class);
}
/**
* {@link Beta} <br/>
* Google Compute Engine credential builder.
*
* <p>
* Implementation is not thread-safe.
* </p>
*/
@Beta
public static class Builder extends Credential.Builder {
/**
* @param transport HTTP transport
* @param jsonFactory JSON factory
*/
public Builder(HttpTransport transport, JsonFactory jsonFactory) {
super(BearerToken.authorizationHeaderAccessMethod());
setTransport(transport);
setJsonFactory(jsonFactory);
setTokenServerEncodedUrl(TOKEN_SERVER_ENCODED_URL);
}
@Override
public ComputeCredential build() {
return new ComputeCredential(this);
}
@Override
public Builder setTransport(HttpTransport transport) {
return (Builder) super.setTransport(Preconditions.checkNotNull(transport));
}
@Override
public Builder setClock(Clock clock) {
return (Builder) super.setClock(clock);
}
@Override
public Builder setJsonFactory(JsonFactory jsonFactory) {
return (Builder) super.setJsonFactory(Preconditions.checkNotNull(jsonFactory));
}
@Override
public Builder setTokenServerUrl(GenericUrl tokenServerUrl) {
return (Builder) super.setTokenServerUrl(Preconditions.checkNotNull(tokenServerUrl));
}
@Override
public Builder setTokenServerEncodedUrl(String tokenServerEncodedUrl) {
return (Builder) super.setTokenServerEncodedUrl(
Preconditions.checkNotNull(tokenServerEncodedUrl));
}
@Override
public Builder setClientAuthentication(HttpExecuteInterceptor clientAuthentication) {
Preconditions.checkArgument(clientAuthentication == null);
return this;
}
@Override
public Builder setRequestInitializer(HttpRequestInitializer requestInitializer) {
return (Builder) super.setRequestInitializer(requestInitializer);
}
@Override
public Builder addRefreshListener(CredentialRefreshListener refreshListener) {
return (Builder) super.addRefreshListener(refreshListener);
}
@Override
public Builder setRefreshListeners(Collection<CredentialRefreshListener> refreshListeners) {
return (Builder) super.setRefreshListeners(refreshListeners);
}
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/compute/ComputeCredential.java | Java | asf20 | 5,226 |
/*
* Copyright (c) 2013 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
/**
* {@link com.google.api.client.util.Beta} <br/>
* Support for <a href="https://developers.google.com/compute/">Google Compute Engine</a>.
*
* @since 1.15
* @author Yaniv Inbar
*/
@com.google.api.client.util.Beta
package com.google.api.client.googleapis.compute;
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/compute/package-info.java | Java | asf20 | 863 |
/*
* Copyright (c) 2010 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
package com.google.api.client.googleapis;
import com.google.api.client.http.EmptyContent;
import com.google.api.client.http.HttpExecuteInterceptor;
import com.google.api.client.http.HttpMethods;
import com.google.api.client.http.HttpRequest;
import com.google.api.client.http.HttpRequestInitializer;
import com.google.api.client.http.UrlEncodedContent;
import java.io.IOException;
/**
* Thread-safe HTTP request execute interceptor for Google API's that wraps HTTP requests inside of
* a POST request and uses {@link #HEADER} header to specify the actual HTTP method.
*
* <p>
* Use this for example for an HTTP transport that doesn't support PATCH like
* {@code NetHttpTransport} or {@code UrlFetchTransport}. By default, only the methods not supported
* by the transport will be overridden. When running behind a firewall that does not support certain
* verbs like PATCH, use the {@link MethodOverride.Builder#setOverrideAllMethods(boolean)}
* constructor instead to specify to override all methods. POST is never overridden.
* </p>
*
* <p>
* This class also allows GET requests with a long URL (> 2048 chars) to be instead sent using
* method override as a POST request.
* </p>
*
* <p>
* Sample usage, taking advantage that this class implements {@link HttpRequestInitializer}:
* </p>
*
* <pre>
public static HttpRequestFactory createRequestFactory(HttpTransport transport) {
return transport.createRequestFactory(new MethodOverride());
}
* </pre>
*
* <p>
* If you have a custom request initializer, take a look at the sample usage for
* {@link HttpExecuteInterceptor}, which this class also implements.
* </p>
*
* @since 1.4
* @author Yaniv Inbar
*/
public final class MethodOverride implements HttpExecuteInterceptor, HttpRequestInitializer {
/**
* Name of the method override header.
*
* @since 1.13
*/
public static final String HEADER = "X-HTTP-Method-Override";
/** Maximum supported URL length. */
static final int MAX_URL_LENGTH = 2048;
/**
* Whether to allow all methods (except GET and POST) to be overridden regardless of whether the
* transport supports them.
*/
private final boolean overrideAllMethods;
/** Only overrides HTTP methods that the HTTP transport does not support. */
public MethodOverride() {
this(false);
}
MethodOverride(boolean overrideAllMethods) {
this.overrideAllMethods = overrideAllMethods;
}
public void initialize(HttpRequest request) {
request.setInterceptor(this);
}
public void intercept(HttpRequest request) throws IOException {
if (overrideThisMethod(request)) {
String requestMethod = request.getRequestMethod();
request.setRequestMethod(HttpMethods.POST);
request.getHeaders().set(HEADER, requestMethod);
if (requestMethod.equals(HttpMethods.GET)) {
// take the URI query part and put it into the HTTP body
request.setContent(new UrlEncodedContent(request.getUrl()));
} else if (request.getContent() == null) {
// Google servers will fail to process a POST unless the Content-Length header is specified
request.setContent(new EmptyContent());
}
}
}
private boolean overrideThisMethod(HttpRequest request) throws IOException {
String requestMethod = request.getRequestMethod();
if (requestMethod.equals(HttpMethods.POST)) {
return false;
}
if (requestMethod.equals(HttpMethods.GET)
? request.getUrl().build().length() > MAX_URL_LENGTH : overrideAllMethods) {
return true;
}
return !request.getTransport().supportsMethod(requestMethod);
}
/**
* Builder for {@link MethodOverride}.
*
* @since 1.12
* @author Yaniv Inbar
*/
public static final class Builder {
/**
* Whether to allow all methods (except GET and POST) to be overridden regardless of whether the
* transport supports them.
*/
private boolean overrideAllMethods;
/** Builds the {@link MethodOverride}. */
public MethodOverride build() {
return new MethodOverride(overrideAllMethods);
}
/**
* Returns whether to allow all methods (except GET and POST) to be overridden regardless of
* whether the transport supports them.
*/
public boolean getOverrideAllMethods() {
return overrideAllMethods;
}
/**
* Sets whether to allow all methods (except GET and POST) to be overridden regardless of
* whether the transport supports them.
*
* <p>
* Default is {@code false}.
* </p>
*/
public Builder setOverrideAllMethods(boolean overrideAllMethods) {
this.overrideAllMethods = overrideAllMethods;
return this;
}
}
}
| 0912116-hsncloudnotes | google-api-client/src/main/java/com/google/api/client/googleapis/MethodOverride.java | Java | asf20 | 5,295 |