本文整理汇总了C#中ISession类的典型用法代码示例。如果您正苦于以下问题:C# ISession类的具体用法?C# ISession怎么用?C# ISession使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ISession类属于命名空间,在下文中一共展示了ISession类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
public void Execute(ISession session, long taskId, DateTime sentDate)
{
bool closeSession = false;
if (session == null)
{
session = _businessSafeSessionManager.Session;
closeSession = true;
}
var systemUser = session.Load<UserForAuditing>(SystemUser.Id);
var taskDueTomorrowEscalation = new EscalationTaskDueTomorrow()
{
TaskId = taskId,
TaskDueTomorrowEmailSentDate = sentDate,
CreatedBy = systemUser,
CreatedOn = DateTime.Now
};
session.Save(taskDueTomorrowEscalation);
//Log4NetHelper.Log.Debug("Saved EscalationTaskDueTomorrow sent indicator");
if (closeSession)
{
session.Close();
}
}
示例2: CreatePurchaseRCV
public static RCVHead CreatePurchaseRCV(ISession session, int userId, string poNumber, string note)
{
RCVHead head = new RCVHead();
head._refOrderType = head._originalOrderType = POHead.ORDER_TYPE;
head._refOrderNumber = head._orginalOrderNumber = poNumber.Trim().ToUpper();
#region ���
//��ʱ������ɹ��ջ����������òɹ������ķ�ʽ
if (string.IsNullOrEmpty(head._refOrderNumber))
throw new Exception("�ɹ�����Ϊ��");
POHead po = POHead.Retrieve(session, head._refOrderNumber);
if (po == null)
throw new Exception(string.Format("�ɹ�����{0}������", head._refOrderNumber));
if (po.Status != POStatus.Release)
throw new Exception(string.Format("�ɹ�����{0}���Ƿ���״̬�������Խ����ջ���ҵ", head._refOrderNumber));
if (po.ApproveResult != ApproveStatus.Approve)
throw new Exception(string.Format("�ɹ�����{0}��û�����ǩ�ˣ������Խ����ջ���ҵ", head._refOrderNumber));
#endregion
head._orderTypeCode = RCVHead.ORD_TYPE_PUR;
head._orderNumber = ERPUtil.NextOrderNumber(head._orderTypeCode);
head._objectID = po.VendorID;
head._locationCode = po.LocationCode;
head._createUser = userId;
head._note = note.Trim();
EntityManager.Create(session, head);
return head;
}
示例3: RecreateDb
public void RecreateDb(ISession session)
{
InitSessionFactory();
var sessionSource = new SessionSource(_fluentConfiguration);
sessionSource.BuildSchema(session);
session.Flush();
}
示例4: HandleEvent
public void HandleEvent(EggIncubatorStatusEvent evt, ISession session)
{
Logger.Write(evt.WasAddedNow
? session.Translation.GetTranslation(TranslationString.IncubatorPuttingEgg, evt.KmRemaining)
: session.Translation.GetTranslation(TranslationString.IncubatorStatusUpdate, evt.KmRemaining),
LogLevel.Egg);
}
示例5: IsExistsCode
private void IsExistsCode(ISession session, Storehouse sh)
{
ICriteria criteria = session.CreateCriteria(typeof(Storehouse));
ICriterion criterion = null;
if (sh.Id != Guid.Empty)
{
criterion = Restrictions.Not(Restrictions.IdEq(sh.Id));
criteria.Add(criterion);
}
criterion = Restrictions.Eq("StoreCode", sh.StoreCode);
criteria.Add(criterion);
//统计
criteria.SetProjection(
Projections.ProjectionList()
.Add(Projections.Count("Id"))
);
int count = (int)criteria.UniqueResult();
if (count > 0)
{
throw new EasyJob.Tools.Exceptions.StorehouseCodeIsExistsException();//库存Code已经存在
}
}
示例6: ChangeCommitted
internal static bool ChangeCommitted(this ISessionPersistentObject al,CRUD Operation, IImportContext iic, ISession session)
{
if (al == null)
throw new Exception("Algo Error");
bool needtoregister = false;
IObjectStateCycle oa = al;
switch (Operation)
{
case CRUD.Created:
needtoregister = true;
session.Save(al);
break;
case CRUD.Update:
session.Update(al);
oa.HasBeenUpdated();
break;
case CRUD.Delete:
session.Delete(al);
oa.SetInternalState(ObjectState.Removed,iic);
break;
}
al.Context = null;
return needtoregister;
}
示例7: Set
public void Set(ISession value)
{
if (value != null)
{
HttpContext.Current.Items.Add("NhbSession", value);
}
}
示例8: Store
public void Store(ISession session)
{
if (_nhSessions.Contains(GetThreadName()))
_nhSessions[GetThreadName()] = session;
else
_nhSessions.Add(GetThreadName(), session);
}
示例9: session_MessageToUser
void session_MessageToUser(ISession sender, SessionEventArgs e)
{
this.ParentForm.BeginInvoke(new MethodInvoker(delegate()
{
CF_displayMessage(e.Message);
}));
}
示例10: SessionAccess
public SessionAccess(ISession session)
{
if (session == null)
throw new ArgumentNullException("session");
this.session = session;
}
示例11: EmployeeRepository
public EmployeeRepository(ISession session)
{
if (session == null)
throw new ArgumentNullException("session");
this.session = session;
}
示例12: getExistingOrNewSession
private ISession getExistingOrNewSession(NHibernate.ISessionFactory factory)
{
if (HttpContext.Current != null)
{
ISession session = GetExistingWebSession();
if (session == null)
{
session = openSessionAndAddToContext(factory);
}
else if (!session.IsOpen)
{
session = openSessionAndAddToContext(factory);
}
return session;
}
if (currentSession == null)
{
currentSession = factory.OpenSession();
}
else if (!currentSession.IsOpen)
{
currentSession = factory.OpenSession();
}
return currentSession;
}
示例13: RegionRepository
public RegionRepository(ISession session)
{
DataTable table;
_ds = new DataSet("Province");
DataSet p = session.CreateObjectQuery("select PRV_ID as Province_ID,PRV_CODE as \"Code\",PRV_NAME as \"Name\",PRV_ALIAS as \"Alias\" from Province")
.Attach(typeof(Province))
.DataSet();
table = p.Tables[0];
table.TableName = "p";
table.Constraints.Add("PK_p", table.Columns["Province_ID"], true);
p.Tables.Clear();
_ds.Tables.Add(table);
DataSet c = session.CreateObjectQuery("select PRV_ID as Province_ID,CITY_ID as City_ID,CITY_CODE as City_Code,CITY_NAME as \"Name\" from City")
.Attach(typeof(City))
.DataSet();
table = c.Tables[0];
table.TableName = "c";
table.Constraints.Add("PK_c", table.Columns["City_ID"], true);
c.Tables.Clear();
_ds.Tables.Add(table);
DataSet d = session.CreateObjectQuery("select CITY_ID as City_ID,DST_ID as District_ID,DST_NAME as \"Name\",DST_ZIPCODE as Zip_Code,DST_SHIP_TO as Door2Door from District")
.Attach(typeof(District))
.DataSet();
table = d.Tables[0];
table.TableName = "d";
table.Constraints.Add("PK_d", table.Columns["District_ID"], true);
d.Tables.Clear();
_ds.Tables.Add(table);
}
示例14: GetAllICQInfo
/// <summary>
/// Requests a full set of information about an ICQ account
/// </summary>
/// <param name="sess">A <see cref="ISession"/> object</param>
/// <param name="screenname">The account for which to retrieve information</param>
public static void GetAllICQInfo(ISession sess, string screenname)
{
if (!ScreennameVerifier.IsValidICQ(screenname))
{
throw new ArgumentException(screenname + " is not a valid ICQ screenname", "screenname");
}
SNACHeader sh = new SNACHeader();
sh.FamilyServiceID = (ushort) SNACFamily.ICQExtensionsService;
sh.FamilySubtypeID = (ushort) ICQExtensionsService.MetaInformationRequest;
sh.Flags = 0x0000;
sh.RequestID = Session.GetNextRequestID();
ByteStream stream = new ByteStream();
stream.WriteUshort(0x0001);
stream.WriteUshort(0x000A);
stream.WriteUshort(0x0008);
stream.WriteUint(uint.Parse(sess.ScreenName));
stream.WriteUshortLE(0x07D0);
stream.WriteUshortLE((ushort) sh.RequestID);
stream.WriteUshort(0x04B2);
stream.WriteUint(uint.Parse(screenname));
SNACFunctions.BuildFLAP(Marshal.BuildDataPacket(sess, sh, stream));
}
示例15: turnOnStatistics
private static bool turnOnStatistics(ISession session)
{
var onOff = session.SessionFactory.Statistics.IsStatisticsEnabled;
session.SessionFactory.Statistics.IsStatisticsEnabled = true;
session.SessionFactory.Statistics.Clear();
return onOff;
}