国庆到了,祝大家节日快乐,散分~

科技互联人生 2005-09-30 08:26:34
国庆到了,祝大家节日快乐,散分~
顺便调查一下大家都有哪些活动吧!

我先来讲,打算先去书店逛逛,买几本书回去闭关研读,
工作太忙,都没时间读书了哇~
...全文
260 56 打赏 收藏 转发到动态 举报
写回复
用AI写文章
56 条回复
切换为时间正序
请发表友善的回复…
发表回复
科技互联人生 2006-05-11
  • 打赏
  • 举报
回复
/// <summary>
/// Delete an object
/// </summary>
/// <param name="obj"></param>
public static void DeleteObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.Delete(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}

/// <summary>
/// Find by HQL
/// </summary>
/// <param name="obj"></param>
public static System.Collections.IList Find(string HQL)
{
ISession session = CurrentSession();
System.Collections.IList list = null;
try
{
list = session.Find(HQL);
}
catch (Exception ex)
{
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
return list;
}

/// <summary>
/// To get the specify object from DB
/// </summary>
/// <param name="ClassType"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static Object GetObject(Type ClassType, object ID)
{
ISession session = CurrentSession();
object Getobj = null;
try
{
Getobj = session.Get(ClassType, ID);
return Getobj;
}
catch (Exception ex)
{
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}

}

/// <summary>
/// To see whether an object exists
/// </summary>
/// <param name="ClassType"></param>
/// <param name="obj"></param>
/// <returns></returns>
public static bool ObjExist(Type ClassType, object ID)
{
object Getobj = GetObject(ClassType, ID);
if (Getobj == null)
{
return false;
}
else
{
return true;
}
}
#endregion

#region For making hbm2ddl

/// <summary>
/// DDL file path
/// </summary>
private static string DllOutPutPath = @"D:\\HbmDDL.txt";

/// <summary>
/// Configuration file name
/// </summary>
private static string DllMappingFile = "hibernate.cfg.xml";
/// <summary>
/// Make DDL file
/// </summary>
/// <param name="hbmConfigurationfile">The hbm configuration file</param>
public static void MakeDDL(string hbmConfigurationfile)
{
if (!System.IO.File.Exists(hbmConfigurationfile))
{
return;
}
NHibernate.Cfg.Configuration Cfg = null;
try
{
Cfg= new Configuration().Configure(hbmConfigurationfile);
}
catch (Exception e)
{
Logger.Error(e.Message);
throw new HibernateException(e);
}
NHibernate.Tool.hbm2ddl.SchemaExport schemaExport = new NHibernate.Tool.hbm2ddl.SchemaExport(Cfg);
schemaExport.SetOutputFile(DllOutPutPath);
schemaExport.Create(false, false);
//schemaExport.Execute(false, false, false, false);
}
/// <summary>
/// Make DDL file
/// </summary>
public static void MakeDDL()
{
MakeDDL(DllMappingFile);
}
#endregion
}
}
科技互联人生 2006-05-11
  • 打赏
  • 举报
回复
using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
using System.Data;

using Training.Common;
using NHibernate.Cfg;
using NHibernate;
using NHibernate.Engine;

namespace Training.BusinessProvider
{
public static class HibUnit
{
#region For data operation

/// <summary>
/// The singleton Sessionfactory
/// </summary>
private static NHibernate.ISessionFactory SessionFactory = null;

/// <summary>
/// The configuration file name
/// </summary>
private static string ConfigFileName = "hibernate.cfg.xml";

/// <summary>
/// Gets the sessionfactory
/// </summary>
/// <param name="assemblyName">Application assembly name ,configuration will search the objects in the assembly</param>
/// <returns></returns>
private static ISessionFactory GetSessionFactory(string assemblyName)
{
if (SessionFactory != null)
{
return SessionFactory;
}
NHibernate.Cfg.Configuration Cfg = null;
try
{
Cfg = new Configuration().Configure(ConfigFileName);
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
if (assemblyName != null)
{
System.Reflection.Assembly aa = System.Reflection.Assembly.Load(assemblyName);
Cfg.AddAssembly(aa);
}
try
{
SessionFactory = Cfg.BuildSessionFactory();
return SessionFactory;
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
}

/// <summary>
/// Another method of gets sessions
/// </summary>
/// <returns></returns>
private static ISessionFactory GetSessionFactory()
{
return GetSessionFactory(null);
}

/// <summary>
/// Get session
/// </summary>
/// <returns></returns>
public static ISession CurrentSession()
{
ISessionFactory factory = GetSessionFactory();
try
{
ISession Session = factory.OpenSession();
return Session;
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
}

/// <summary>
/// Reload configuration
/// </summary>
public static void ReloadConfig()
{
SessionFactory = null;
}

/// <summary>
/// Use Hibernate to execute SQL statment
/// </summary>
/// <param name="query"></param>
/// <returns></returns> IList
public static System.Collections.IList ExecuteSQL(string query)
{
System.Collections.IList result = new ArrayList();

ISessionFactoryImplementor s = (ISessionFactoryImplementor) GetSessionFactory();
IDbCommand cmd = s.ConnectionProvider.Driver.CreateCommand();
cmd.CommandText = query;

IDbConnection conn = s.OpenConnection();
try
{
cmd.Connection = conn;
IDataReader rs = cmd.ExecuteReader();

while (rs.Read())
{
int fieldCount = rs.FieldCount;
object[] values = new Object[fieldCount];
for (int i = 0; i < fieldCount; i++)
{
values[i] = rs.GetValue(i);
}
result.Add(values);
}
}
catch (Exception e)
{
NHibernate.HibernateException ex = new HibernateException(e);
Logger.Error(e.Message);
throw (ex);
}
finally
{
s.CloseConnection(conn);
}
return result;
}

/// <summary>
/// Saves an object to DB
/// </summary>
/// <param name="obj"></param>
public static void SaveObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.Save(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}

/// <summary>
/// Update an object to DB
/// </summary>
/// <param name="obj"></param>
public static void UpdateObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.Update(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}

/// <summary>
/// SaveOrUpdate an object to DB
/// </summary>
/// <param name="obj"></param>
public static void SaveOrUpdateObject(Object obj)
{
ISession session = CurrentSession();
ITransaction tr = session.BeginTransaction();
try
{
session.SaveOrUpdate(obj);
tr.Commit();
}
catch (Exception ex)
{
tr.Rollback();
Logger.Error(ex.Message);
throw (ex);
}
finally
{
if (session.IsOpen)
{
session.Close();
}
}
}
科技互联人生 2006-05-11
  • 打赏
  • 举报
回复
http://download.microsoft.com/download/0/7/e/07e204a1-4d21-471c-acb9-efd7b98831d8/winfxsetup.exe

http://download.microsoft.com/download/a/3/a/a3a0d427-6065-4c9a-a4a3-734e11bfdaa1/winfxsetup.exe

------------------------------------------------------------------
http://download.microsoft.com/download/8/1/c/81c912c1-893b-4603-8c40-bf128444a932/WindowsSDK_Readme_FebCTP.htm


http://download.microsoft.com/download/8/1/c/81c912c1-893b-4603-8c40-bf128444a932/6.0.5308.0.9.WindowsSDK_Vista_idw.DVD.Rel.img


http://download.microsoft.com/download/8/1/c/81c912c1-893b-4603-8c40-bf128444a932/Setup.exe
hoowoo 2005-10-04
  • 打赏
  • 举报
回复
现在学习ASP.NET 2.0
呵呵!!
teachme123 2005-10-03
  • 打赏
  • 举报
回复
学习
richardingding 2005-10-03
  • 打赏
  • 举报
回复
mark一下
终于可以好好的休息一下了
jialw 2005-10-03
  • 打赏
  • 举报
回复
学习
truewill 2005-10-03
  • 打赏
  • 举报
回复
终于可以睡到中午了 ^_^
mywebcom 2005-10-01
  • 打赏
  • 举报
回复
普天同庆!
yufenfeila 2005-10-01
  • 打赏
  • 举报
回复
节日快乐!

到处转转
xilo 2005-10-01
  • 打赏
  • 举报
回复
看书,上网,睡觉。。。
gyf19 2005-10-01
  • 打赏
  • 举报
回复
节日快乐!
Overriding 2005-09-30
  • 打赏
  • 举报
回复
买几本书回去闭关研读
==============
楼主比较幸福,我回家干几天体力活。
commars 2005-09-30
  • 打赏
  • 举报
回复
节日快乐!
wdcszl 2005-09-30
  • 打赏
  • 举报
回复
学习
gyf19 2005-09-30
  • 打赏
  • 举报
回复
祝大家国庆节快乐!!!节日看书,好久没有看书。
Alden 2005-09-30
  • 打赏
  • 举报
回复
I{
showrock 2005-09-30
  • 打赏
  • 举报
回复
节日快乐~明开始休息了~准备去迷笛音乐节休闲一下~
健者天行 2005-09-30
  • 打赏
  • 举报
回复
节日快乐,同乐!
supermarrio 2005-09-30
  • 打赏
  • 举报
回复
我根maomilaile(阿来) 一样,准备要找工作了,原来的单位不行了。大家国庆快乐哈^_^
加载更多回复(36)

7,765

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧