近期项目总结与反思

        为了方便以后的工作学习中查阅,以及对前段时间的一个反思,对近期做过项目里面的一下知识点、技术细节总结一下:

  一、股票在线查询项目(http://dr.788111.com/)

这个项目用到的知识点并不是很多,主要表现为:webservicecookiesessionxml、文件的压缩和解压操作等等。

其中,登陆、注册用到cookie是出现了一些问题,经过一些时间的处理调试最终正常,读写cookie操作如下:

     

ExpandedBlockStart.gif 代码
// 存储cookie信息        
                 HttpCookie cookie  =  HttpContext.Current.Request.Cookies[ " name " ];
                 
if  (cookie  ==   null )
                 {
                     cookie 
=   new  HttpCookie( " name " );

                 }
                 cookie.Value 
= Mobile;
                 cookie.Domain 
=   " 788111.com " ;
                 cookie.Expires 
=  DateTime.Now.AddDays( 1 );                 HttpContext.Current.Response.AppendCookie(cookie);
                 

                 
// 读取cookie信息
                HttpCookie usercookie  =  HttpContext.Current.Request.Cookies[ " user " ];               

                

        
///   <summary>
        
///  清除cookie
        
///   </summary>
        
///   <param name="strName"> cookie名称 </param>

        
public   void  ClearCookie( string  strName)
        {
         
if  (HttpContext.Current.Request.Cookies[strName]  !=   null )
          {
          HttpContext.Current.Response.Cookies[strName].Value 
=   null ;         HttpContext.Current.Response.Cookies[strName].Domain  =   " 788111.com " ;

          HttpContext.Current.Response.Cookies[strName].Expires 
=   new  DateTime( 1999 10 12 );

            }
        } 

 

 

 1  ///   <summary>
 2       ///  日志记录类
 3       ///   </summary>
 4       public   static   class  Log
 5      {
 6           public   static   string  GetLogDirectory( string  category)
 7          {
 8 
 9               string  baseDirectory  =   string .Empty;
10 
11               if  ((HttpContext.Current  !=   null &&  (HttpContext.Current.Server  !=   null ))
12 
13              {
14 
15                  baseDirectory  =  HttpContext.Current.Server.MapPath( " ~ " );
16              }
17 
18               else
19              {
20                  baseDirectory  =  AppDomain.CurrentDomain.BaseDirectory;
21 
22              }
23 
24               if  ((baseDirectory[baseDirectory.Length  -   1 !=   ' / ' &&  (baseDirectory[baseDirectory.Length  -   1 !=   ' \\ ' ))
25 
26              {
27 
28             baseDirectory  =  baseDirectory  +   @" \ " ;
29 
30              }
31 
32              baseDirectory  =   string .Format( @" {0}Log\{1}\ " , baseDirectory, category);
33 
34               if  ( ! Directory.Exists(baseDirectory))
35 
36              {
37 
38             Directory.CreateDirectory(baseDirectory);
39              }
40 
41               return  baseDirectory;
42          }
43   
44 
45           ///   <summary>   
46           ///   </summary>
47           ///   <param name="e"></param>
48           public   static   void  SaveException(Exception e)
49          {
50              SaveException(e,  string .Empty);
51 
52          } 
53 
54           public   static   void  SaveException(Exception e,  string  memo)
55          {
56              FileStream stream  =   new  FileStream(GetLogDirectory( " Common " +  DateTime.Now.ToString( " yyyy-MM-dd " +   " .txt " , FileMode.Append, FileAccess.Write, FileShare.Delete  |  FileShare.ReadWrite);
57 
58              StreamWriter writer  =   new  StreamWriter(stream);
59 
60              writer.WriteLine( " ======================================== " );
61              writer.WriteLine( string .Format( " Memo:\t{0} " , memo));
62              writer.WriteLine( string .Format( " DateTime:\t{0} " , DateTime.Now.ToShortTimeString()));
63 
64              writer.WriteLine( string .Format( " Message:\t{0} " , e.Message));
65              writer.WriteLine( string .Format( " StackTrace:\r\n----------\r\n{0}\r\n----------\r\n\r\n\r\n " , e.StackTrace));
66              stream.Flush();
67              writer.Close();
68              stream.Close();
69              stream.Dispose();
70              writer.Dispose();
71          } 
72 
73           public   static   void  SaveNote( string  note)
74          {
75 
76              FileStream stream  =   new  FileStream(GetLogDirectory( " Common " +  DateTime.Now.ToString( " yyyy-MM-dd " +   " .txt " , FileMode.Append, FileAccess.Write, FileShare.Delete  |  FileShare.ReadWrite);
77              StreamWriter writer  =   new  StreamWriter(stream);
78              writer.WriteLine( " ========================================= " );
79              writer.WriteLine( string .Format( " Note:\t{0} " , note));            writer.WriteLine( string .Format( " DateTime:\t{0}\r\n\r\n " ,DateTime.Now.ToShortTimeString()));
80              stream.Flush();
81              writer.Close();
82              stream.Close();
83              tream.Dispose();
84              writer.Dispose();
85          }
86  }
87 
88 

 

 

这个日志记录类主要是便于记录错误信息,以及一些重要的信息。

 

这个项目中还用到了一个比较重要的资源,即图表控件,如图所示信息:


图表控件是用的的一个免费FusionCharts控件,可以生成许多类型的图表,能够满足一般的业务需求。具体应用方式方法这里就不再多说明,主要是提醒自己有这样一个应用,方便日后使用。

 

这个项目虽然比较小,但上线后出现了不少的问题。总结了一下,主要表现为:代码编写不够规范,可读写差、思路不够严谨、可扩展性不强。其中突出表现为:代码编写不够规范。希望自己能清醒的注意到这个问题的严重性,认真规范编码,严谨编码。一步步提高个人分析、编码能力……

转载于:https://www.cnblogs.com/zzxbest/archive/2010/03/22/1691583.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值