一、系统架构
     1、数据存储:Linq to sql类(dbml文件)
     2、业务逻辑:Csla
        将数据存储变成一个个和表结构无关的对象,以便在UI层处理。其中对象也可以作为对象的属性,
     这样要获取或者改变对象的属性,只需要一层层调用就可以。
        Csla中,一个对象可分为三块:
           a.属性定义,如:

Property
private static PropertyInfo<Guid> IdProperty = RegisterProperty<Guid>(p => p.PondId);
public Guid PondId
{
get { return GetProperty(IdProperty); }
internal set { SetProperty(IdProperty, value); }
}

 

 

           b.方法定义,如:

public static Ponderation GetPonderation(Guid pondId)
{
return DataPortal.FetchChild<Ponderation>(pondId);
}

 

           c.数据操作,如:

Data
private void Child_Fetch(Guid pondId)
{
using (var ctx = ContextManager<ASR.DalLinq.ASRdbDataContext>
.GetManager(DataBase.ASR))
{
var data
= (from p in ctx.DataContext.PonderationSettings
where p.PondID == pondId
select p).SingleOrDefault();
if (data != null)
{
using (BypassPropertyChecks)
{
PondId
= pondId;
PondName
= data.PondName;
}
// get child data
LoadProperty(LatitudeProperty, PonderationLatitude.GetPonderationLatitude(pondId));
LoadProperty(ParamsProperty, PonderationParamList.GetPonderationParamList(pondId));
}
}
}

 

    3、UI层

         该层主要负责页面的显示以及数据在页面间的传输。


、遇到的问题及最终解决方案

    1、UpdatePanel内控件引起页面所有UpdatePanel更新

         a.UpdateMode有两个属性值,一个是always,另外一个是conditional。默认是always,该模式下会引起页面所有UpdatePanel更

     新,说以设为conditional就不会一个控件引起页面所有UpdatePaner更新了。

         b.ChildrenAsTriggers,当UpdatePanel设为conditional时,指示来自UpdatePanel 控件的即时子控件的回发是否更新面板的内

     容。当你有UpdatePanel嵌套时,你希望里面的UpdatePanel更新是不会引起外面的更新,就将外面的UpdatePanel的

     ChildrenAsTriggers属性设为false。

         c.PostBackTrigger,UpdatePanel中所有的控件默认的是异步回送,即只对UpdatePanel有效。而如果要某个控件引发页面回送,

     则把它加入PostBackTrigger。

     2、mschart自定义字符串组做为坐标轴,及mschart在IE6显示的问题

         a.mschart自定义字符串组做为坐标轴

Axis
private void setAxis(ArrayList str, Axis axis)
{
int i = 1;
foreach (string _str in str)
{
axis.CustomLabels.Add(i
- 0.5, i + 0.5, _str);
i
++;
}

}

         b.默认配置中,mschart在IE6显示为红叉

           创建一个TempImages文件夹,然后将Chart的两个属性做如下设置:

           ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)"  ImageStorageMode="UseImageLocation"

      3、对象在页面间传输

           由于对象在页面中传输如果用sission有可能丢失,用Viewstates传输会因为数据量太大影响页面显示速度。最后采用外部文件序列

       化方法,只需用viewstates传输地址即可。

Serialize
public static void Serialize(T solution, string address)
{
BinaryFormatter binFormat
= new BinaryFormatter();
using (Stream fStream = new FileStream(address, FileMode.Create,
FileAccess.Write, FileShare.None))
{
binFormat.Serialize(fStream, solution);
}
}

public static T Deserialize(string address)
{
BinaryFormatter binFormat
= new BinaryFormatter();
//T result = null;
using (Stream fStream = File.OpenRead(address))
{
T result
= (T)binFormat.Deserialize(fStream);
return result;
}
}

      4、枚举

           a.枚举的遍历
               foreach(   Scorecity   in   enum.getvalues(   typeof(   Score)   )   )  
                {

                }

           b.字符串转枚举

               Score enumtype;  
               string   strTypeB   =   "EE";  
               enumtype   =   (Score)Enum.Parse(typeof(Score),strTypeB);

           c.枚举转字符串

              myScore     enumtype = Score.EE;

              string strTypeB = Enum.GetName(typeof(myScore ), enumtype);

      5、其它

          a.数据库连接不要写在循环中,如果循环很多,则响应时间无法想象。我1500次循环花了10多分钟才打开页面。

            可以在循环外将数据取出后在内存中读取。

          b.viewstates中不要存大数据,否则页面加载时间无法想象。因为viewstates中的数据是加密的,所以文件长度会加长很多。

            可以将序列化的大数据存入文件后,viewstates存地址就可。在不必要的地方可以把viewstates禁用掉,以节省加载时间。

          c.usercontrol相关性,各usercontrol以及页面之间最好不要有依赖关系,即尽量降低耦合。

            可以用页面刷新就传值存到usercontrol的viewstates(宁可降低页面加载效率)代替parent.parent这种依赖性的获取。否则,

          当页面改动时会很麻烦。

          d.当在页面很多地方都要用到同一数据时,可以用属性来获得设置或获得该数据。          

posted on 2010-05-10 17:55  长风一剑  阅读(405)  评论(0编辑  收藏  举报