随笔:64 文章:1 评论:54 引用:1
博客园 首页 发新随笔
发新文章 联系 订阅订阅管理

2007年1月9日

 

      SQL日期和字符串可以相互转化,收藏一个临界时间的SQL:
      SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO
--返回某段时间所有杂志某天的订阅量
--exec pro_rpt_MagazineCreateSubscribe
ALTER           procedure dbo.pro_rpt_AllMagazineSubscribe
as
begin
set nocount on

--用户操作临时表
--oid   nvarchar(200),         --操作对象ID
--etime datetime,              --时间
--edate nvarchar null          --时间的日期部分
create table #userb(
oid nvarchar(
200),
etime datetime,
edate nvarchar(
50null
)
--插入数据

declare @bDate datetime
set @bDate=DateAdd(day,-1,getdate())

declare @eDate datetime
set @eDate=getdate()
declare @beginDate varchar(
50)
set @beginDate=convert(varchar(4),datepart(year,@bDate))+'-'+convert(varchar(2),datepart(month,@bDate))+'-'+convert(varchar(2),datepart(day,@bDate))+' 00:00:00'

declare @endDate varchar(
50)
set @endDate=convert(varchar(4),datepart(year,@eDate))+'-'+convert(varchar(2),datepart(month,@eDate))+'-'+convert(varchar(2),datepart(day,@eDate))+' 00:00:00'


--往用户操作临时表插入所要数据
insert into #userb 
(oid,etime,edate)
SELECT ub.ObjectID,ub.EventTime
,convert(varchar(
4),datepart(year,ub.EventTime))+'-'+convert(varchar(2),datepart(month,ub.EventTime))+'-'+convert(varchar(2),datepart(day,ub.EventTime))
FROM UserBehavior1 
as ub 
WHERE   EventName
='SubscribeMagazine' and ObjectID <> '' and (ub.EventTime between @beginDate and @endDate) -- between @beginDate and @endDate)  --ObjectType<>'Auto' and

--每天下载量的统计表
create table #tsub(
oid nvarchar(
100),
dtime datetime,
--日期
tsub 
decimal(10,2null default 0.00--本日真实下载量
tcsub 
decimal(10,2null default 0.00 --本日处理过下载量
)

--select * from #userb order by edate

insert into #tsub
(oid,dtime,tsub)
select oid,edate,count(edate) 
as cnt from #userb 
group by oid,edate


declare @rannum 
int         --随机数

set @rannum=(select RandomNum from MagzineRandom where CreateTime=@bDate)

update #tsub 
set tcsub=case 
 when  tsub
>=0 and tsub<=5  then tsub*11+@rannum
 when  tsub
>=6 and tsub<=15  then tsub*9+@rannum
 when tsub
>=16  then tsub*7+@rannum


 end
Insert into MagazineSubStat
([ID],MagCode,DTime,TSub,TCSub)
select NewID() ,oid,dtime,tsub,tcsub from #tsub


select 
* from #tsub

drop table #tsub

drop table #userb

end

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

 

 

posted @ 2007-01-09 17:16 Cameo 阅读(59) 评论(1) 编辑
 
      强名称程序集是有一个文件名、一个程序集版本号和一个语言文化(Culture),除此之外,强名称程序集还使用了发布者的私钥进行了签名。 首先创建一对公钥/私钥,命令如下:
      sn -k MyCompany.keys 运行此命令创建了二进制公钥/私钥文件。 为了查看公钥,用以下命令创建只包含公钥的文件:
      sn -p MyCompany.keys MyCompany.PublicKey 
      运行此命令创建的MyCompany.PublicKey只包含公钥,如何查看MyCompany.PublicKey文件里的公钥呢?运行如下命令:
      sn -tp MyCompany.PublicKey 显示的结果 
 
      创建一个强名称程序集:csc  /keyfile:MyCompany.keys  Program.cs
      运行ildasm.exe,查看程序集清单:
      
      命令:csc  /keyfile:MyCompany.keys  Program.cs  C# 编译器看到/keyfile
这个开关,就会打开指定文件MyCompany.keys ,使用私钥进行程序集签名,
并在清单中嵌入公钥,如上图。
posted @ 2007-01-09 09:55 Cameo 阅读(258) 评论(0) 编辑

公告


Powered By: 博客园
模板提供沪江博客