本文整理汇总了C#中ISession.Commit方法的典型用法代码示例。如果您正苦于以下问题:C# ISession.Commit方法的具体用法?C# ISession.Commit怎么用?C# ISession.Commit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISession
的用法示例。
在下文中一共展示了ISession.Commit方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Release
public void Release(ISession session)
{
if (sessionsForThreads.ContainsKey(Thread.CurrentThread.ManagedThreadId))
{
return;
}
session.Commit();
pooledSessionFactory.Release(session);
}
示例2: TestQueueRollbackConsumerListener
public void TestQueueRollbackConsumerListener()
{
connection.Start();
this.session = connection.CreateSession(AcknowledgementMode.Transactional);
ITemporaryQueue queue = session.CreateTemporaryQueue();
IMessageProducer producer = session.CreateProducer(queue);
IMessage message = session.CreateTextMessage("Test Message");
producer.Send(message);
session.Commit();
IMessageConsumer consumer = session.CreateConsumer(queue);
consumer.Listener += new MessageListener(OnMessageListener);
Thread.Sleep(500);
// first try.. should get 2 since there is no delay on the
// first redeliver..
Assert.AreEqual(2, counter);
Thread.Sleep(1000);
// 2nd redeliver (redelivery after 1 sec)
Assert.AreEqual(3, counter);
Thread.Sleep(2000);
// 3rd redeliver (redelivery after 2 seconds) - it should give up after
// that
Assert.AreEqual(4, counter);
// create new message
producer.Send(session.CreateTextMessage("Test Message Again"));
session.Commit();
Thread.Sleep(500);
// it should be committed, so no redelivery
Assert.AreEqual(5, counter);
Thread.Sleep(1500);
// no redelivery, counter should still be 5
Assert.AreEqual(5, counter);
session.Close();
}
示例3: When_saving_a_snapshotable_aggregate_for_each_change
public When_saving_a_snapshotable_aggregate_for_each_change()
{
IEventStore eventStore = new TestInMemoryEventStore();
_snapshotStore = new TestInMemorySnapshotStore();
var snapshotStrategy = new DefaultSnapshotStrategy();
var repository = new SnapshotRepository(_snapshotStore, snapshotStrategy, new Repository(eventStore), eventStore);
_session = new Session(repository);
_aggregate = new TestSnapshotAggregate();
for (var i = 0; i < 150; i++)
{
_session.Add(_aggregate);
_aggregate.DoSomething();
_session.Commit();
}
}
示例4: Setup
public void Setup()
{
IEventStore eventStore = new TestInMemoryEventStore();
var eventPublisher = new TestEventPublisher();
_snapshotStore = new TestInMemorySnapshotStore();
var snapshotStrategy = new DefaultSnapshotStrategy();
var repository = new SnapshotRepository(_snapshotStore, snapshotStrategy, new Repository(eventStore, eventPublisher), eventStore);
_session = new Session(repository);
var aggregate = new TestSnapshotAggregate();
for (int i = 0; i < 20; i++)
{
_session.Add(aggregate);
aggregate.DoSomething();
_session.Commit();
}
}
示例5: SaveCheckOrder
private void SaveCheckOrder()
{
try
{
DataSet ds = Session["InvAdjustmentItem"] as DataSet;
Dictionary<int, int> lstCurrentQuantity = new Dictionary<int, int>();
for (int i = 0; i < this.rptInvCheck.Items.Count; i++)
{
TextBox objBox = this.rptInvCheck.Items[i].FindControl("txtCurrentQuantity") as TextBox;
System.Web.UI.HtmlControls.HtmlInputHidden objSKU = this.rptInvCheck.Items[i].FindControl("hidSKUID") as System.Web.UI.HtmlControls.HtmlInputHidden;
try
{
lstCurrentQuantity.Add(Cast.Int(objSKU.Value), Cast.Int(objBox.Text));
}
catch (Exception ex)
{
WebUtil.ShowMsg(this, "调整数量非法,请重新输入!");
return;
}
}
using (_session = new Session())
{
_session.BeginTransaction();
try
{
INVCheckHead objHead = INVCheckHead.Retrieve(_session, this.txtInvCheckNumber.Text);
bool blnInsert = false;
if (objHead == null)
{
blnInsert = true;
objHead = new INVCheckHead();
objHead.CreateTime = DateTime.Now;
objHead.CreateUser = Magic.Security.SecuritySession.CurrentUser.UserId;
objHead.Note = this.txtMemo.Text;
objHead.OrderNumber = Magic.ERP.ERPUtil.NextOrderNumber(Magic.ERP.Orders.INVCheckHead.ORDER_TYPE_ADJ);
objHead.OrderTypeCode = INVCheckHead.ORDER_TYPE_ADJ;
objHead.Status = Magic.ERP.INVCheckStatus.New;
objHead.Create(_session);
}
else
{
if ((objHead.Status == Magic.ERP.INVCheckStatus.Release) || (objHead.Status == Magic.ERP.INVCheckStatus.Close))
{
WebUtil.ShowMsg(this, "发布以后的盘点单不可以进行修改");
return;
}
objHead.Note = this.txtMemo.Text;
blnInsert = false;
_session.CreateEntityQuery<INVCheckLine>().Where(Exp.Eq("OrderNumber", objHead.OrderNumber)).Delete();
}
objHead.CurrentLineNumber = "";
List<INVCheckLine> List = new List<INVCheckLine>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
INVCheckLine objLine = new INVCheckLine();
objLine.SKUID = Cast.Int(ds.Tables[0].Rows[i]["SKUID"]);
objLine.AreaCode = Cast.String(ds.Tables[0].Rows[i]["AreaCode"]);
objLine.BeforeQty = Cast.Decimal(ds.Tables[0].Rows[i]["BeforeQty"]);
objLine.CurrentQty = lstCurrentQuantity[objLine.SKUID];
objLine.LineNumber = objHead.NextLineNumber();
objLine.LocationCode = Cast.String(ds.Tables[0].Rows[i]["LocationCode"]);
objLine.OrderNumber = objHead.OrderNumber;
objLine.SectionCode = Cast.String(ds.Tables[0].Rows[i]["SectionCode"]);
objLine.Create(_session);
}
objHead.Update(_session, "CurrentLineNumber");
this.txtInvCheckNumber.Text = objHead.OrderNumber;
_session.Commit();
}
catch (Exception ex)
{
_session.Rollback();
throw ex;
}
}
WebUtil.ShowMsg(this, "库存盘点单保存成功", "操作成功");
}
catch (Exception ex)
{
logger.Info("保存库存盘点单", ex);
WebUtil.ShowMsg(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
}
}
示例6: cmdProduct_Click
protected void cmdProduct_Click(object sender, EventArgs e)
{
if (this.txtSkuId.Value.Trim().Length <= 0) return;
bool added = false;
using (_session = new Session())
{
string[] idArray = this.txtSkuId.Value.Trim().Trim(';').Split(';');
try
{
POHead head = POHead.Retrieve(_session, this.OrderNumber);
if (head == null || head.Status != POStatus.New) return;
_session.BeginTransaction();
foreach (string s in idArray)
{
POLine poLine = new POLine();
poLine.OrderNumber = this.OrderNumber;
poLine.SKUID = Cast.Int(s, 0);
if (poLine.SKUID <= 0) continue;
poLine.LineNumber = head.NextLineNumber();
poLine.LineStatus = POLineStatus.Open;
poLine.PurchaseQty = 0M;
poLine.Price = 0M;
//Vendor vendor = null;
//if (head.VendorID > 0) vendor = Vendor.Retrieve(_session, head.VendorID);
//if (vendor != null)
//{
// poLine.TaxID = vendor.TaxID;
// poLine.TaxValue = vendor.Tax;
//}
//else
//{
// poLine.TaxID = 0;
// poLine.TaxValue = 0M;
//}
poLine.TaxID = 0;
poLine.TaxValue = 0M;
poLine.TaxInclusiveAmt = 0M;
poLine.TaxAmt = 0M;
poLine.TaxExlusiveAmt = 0M;
poLine.PlanDate = head.DefaultPlanDate;
poLine.ActualDate = new DateTime(1900, 1, 1);
poLine.ReceiveQty = 0M;
poLine.IQCQty = 0M;
poLine.UnfinishedReceiveQty = 0M;
poLine.ModifyUser = SecuritySession.CurrentUser.UserId;
poLine.ModifyTime = DateTime.Now;
poLine.UnitID = 0;
poLine.Create(_session);
added = true;
}
head.Update(_session, "CurrentLineNumber");
_session.Commit();
if (added)
{
BindPOLine(_session, head);
WebUtil.ShowMsg(this, "订单明细保存成功", "操作成功");
}
}
catch (Exception ex)
{
_session.Rollback();
logger.Info("保存POLine", ex);
WebUtil.ShowError(this, "发生未处理的异常,请刷新页面重新操作,或者联系系统管理员");
}
}
}
示例7: PostApprove
public virtual void PostApprove(ISession session)
{
try
{
session.BeginTransaction();
try
{
this.Close(session);
session.Commit();
}
catch (Exception er2)
{
session.Rollback();
log.Error("���ӵ�" + this._orderNumber + "ǩ����ϣ������Զ��ر�ʱ�����쳣", er2);
return;
}
}
catch (Exception er)
{
log.Error("���ӵ�" + this._orderNumber + "ǩ����ϣ������Զ��ر�ʱ�����쳣", er);
return;
}
}
示例8: AppsOnDeriveRevenues
public static void AppsOnDeriveRevenues(ISession session)
{
var internalOrganisationRevenuesByPeriodByInternalOrganisation = new Dictionary<InternalOrganisation, Dictionary<DateTime, InternalOrganisationRevenue>>();
var internalOrganisationRevenues = session.Extent<InternalOrganisationRevenue>();
foreach (InternalOrganisationRevenue internalOrganisationRevenue in internalOrganisationRevenues)
{
internalOrganisationRevenue.Revenue = 0;
var date = DateTimeFactory.CreateDate(internalOrganisationRevenue.Year, internalOrganisationRevenue.Month, 01);
Dictionary<DateTime, InternalOrganisationRevenue> internalOrganisationRevenuesByPeriod;
if (!internalOrganisationRevenuesByPeriodByInternalOrganisation.TryGetValue(internalOrganisationRevenue.InternalOrganisation, out internalOrganisationRevenuesByPeriod))
{
internalOrganisationRevenuesByPeriod = new Dictionary<DateTime, InternalOrganisationRevenue>();
internalOrganisationRevenuesByPeriodByInternalOrganisation[internalOrganisationRevenue.InternalOrganisation] = internalOrganisationRevenuesByPeriod;
}
InternalOrganisationRevenue revenue;
if (!internalOrganisationRevenuesByPeriod.TryGetValue(date, out revenue))
{
internalOrganisationRevenuesByPeriod.Add(date, internalOrganisationRevenue);
}
}
var revenues = new HashSet<long>();
var salesInvoices = session.Extent<SalesInvoice>();
var year = 0;
foreach (SalesInvoice salesInvoice in salesInvoices)
{
if (year != salesInvoice.InvoiceDate.Year)
{
session.Commit();
year = salesInvoice.InvoiceDate.Year;
}
var date = DateTimeFactory.CreateDate(salesInvoice.InvoiceDate.Year, salesInvoice.InvoiceDate.Month, 01);
foreach (SalesInvoiceItem salesInvoiceItem in salesInvoice.SalesInvoiceItems)
{
if (salesInvoice.ExistBilledFromInternalOrganisation)
{
InternalOrganisationRevenue internalOrganisationRevenue;
Dictionary<DateTime, InternalOrganisationRevenue> internalOrganisationRevenuesByPeriod;
if (!internalOrganisationRevenuesByPeriodByInternalOrganisation.TryGetValue(salesInvoice.BilledFromInternalOrganisation, out internalOrganisationRevenuesByPeriod))
{
internalOrganisationRevenue = CreateInternalOrganisationRevenue(session, salesInvoice);
internalOrganisationRevenuesByPeriod = new Dictionary<DateTime, InternalOrganisationRevenue> { { date, internalOrganisationRevenue } };
internalOrganisationRevenuesByPeriodByInternalOrganisation[salesInvoice.BilledFromInternalOrganisation] = internalOrganisationRevenuesByPeriod;
}
if (!internalOrganisationRevenuesByPeriod.TryGetValue(date, out internalOrganisationRevenue))
{
internalOrganisationRevenue = CreateInternalOrganisationRevenue(session, salesInvoice);
internalOrganisationRevenuesByPeriod[date] = internalOrganisationRevenue;
}
revenues.Add(internalOrganisationRevenue.Id);
internalOrganisationRevenue.Revenue += salesInvoiceItem.TotalExVat;
}
}
}
foreach (InternalOrganisationRevenue internalOrganisationRevenue in internalOrganisationRevenues)
{
if (!revenues.Contains(internalOrganisationRevenue.Id))
{
internalOrganisationRevenue.Delete();
}
}
}
示例9: SMSSender
private static void SMSSender(ISession session, Notification message, ConfigParam config, SendResult state)
{
object s = null;
string errorMessage = null, mobile;
bool error = false;
string errorCode = string.Empty ;
foreach (NotificationReceiver receiver in message.Receivers)
{
s = null;
error = false;
errorMessage = null;
errorCode = "";
//合法性检查
mobile = receiver.PostTo;
if (!CheckSms(ref mobile))
{
log.ErrorFormat("message {0}, receiver: {1} not send: 无效的手机号码", message.NotifyID, receiver.PostTo);
errorMessage = "无效的手机号码";
error = true;
}
//尝试发送
if (!error)
try
{
s = _smsService.SendMessage(config.SMSAccount, config.SMSPassword, message.Content, mobile);
error =_smsService.ParseSendResult(s,out errorCode, out errorMessage);
log.DebugFormat("message {0} sent, receiver: {1}, content: {2}", message.NotifyID, mobile, message.Content);
}
catch (Exception er)
{
//发送过程如果发生异常,异常信息将尝试记入数据库
error = true;
errorMessage = er.Message;
}
//记录发送结果状态
try
{
session.BeginTransaction();
bool success = message.AfterSendDo(receiver, error ? "-99998" : "-99999", errorMessage);
session.Commit();
if (success) state.SuccessCount++;
else state.ErrorCount++;
}
catch (Exception er)
{
//如果记录发送结果状态时发生异常,只能将异常信息记入日志文件
session.Rollback();
state.ErrorCount++;
log.ErrorFormat("message: {0}, receiver: {1}, result code: {2}, result error: {3}, exception: {4}", message.NotifyID, receiver.PostTo, error?"-99998":errorCode, errorMessage, er.Message);
}
}
message.AfterSendDo();
}
示例10: CommitIfNecessary
/*
/// <summary> Close the given NMS QueueRequestor and ignore any thrown exception.
/// This is useful for typical <code>finally</code> blocks in manual NMS code.
/// </summary>
/// <param name="requestor">the NMS QueueRequestor to close (may be <code>null</code>)
/// </param>
*/
// public static void CloseQueueRequestor(QueueRequestor requestor)
// {
// if (requestor != null)
// {
// try
// {
// requestor.Close();
// }
// catch (NMSException ex)
// {
// logger.Debug("Could not close NMS QueueRequestor", ex);
// }
// catch (Exception ex)
// {
// // We don't trust the NMS provider: It might throw RuntimeException or Error.
// logger.Debug("Unexpected exception on closing NMS QueueRequestor", ex);
// }
// }
// }
/// <summary> Commit the Session if not within a distributed transaction.</summary>
/// <remarks>Needs investigation - no distributed tx in .NET messaging providers</remarks>
/// <param name="session">the NMS Session to commit
/// </param>
/// <throws>NMSException if committing failed </throws>
public static void CommitIfNecessary(ISession session)
{
AssertUtils.ArgumentNotNull(session, "ISession must not be null");
session.Commit();
// TODO Investigate
// try {
// session.Commit();
// }
// catch (TransactionInProgressException ex) {
// // TODO Investigate
// // Ignore -> can only happen in case of a JTA transaction.
// }
// catch (IllegalStateException ex) {
// // TODO Investigate
// // Ignore -> can only happen in case of a JTA transaction.
// }
}
示例11: PostApprove
/// <summary>
/// ǩ�����
/// </summary>
/// <param name="session"></param>
public virtual void PostApprove(ISession session)
{
try
{
session.BeginTransaction();
this.Close(session);
session.Commit();
}
catch (Exception er)
{
log.Error((this._orderTypeCode == ORDER_TYPE_CHK ? "sto chk" : "sto adj") + this.OrderNumber + " was approved, error occurs while trying to close this order automatically", er);
session.Rollback();
}
}
示例12: QueryAndBindData
private void QueryAndBindData(ISession session, int pageIndex, int pageSize, bool fetch)
{
int count = 0;
DataSet ds = null;
DateTime start = Cast.DateTime(this.txtDateFrom.Text, DateTime.Now.AddMonths(-1));
DateTime end = Cast.DateTime(this.txtDateTo.Text, DateTime.Now);
this.txtDateFrom.Text = start.ToString("yyyy-MM-dd");
this.txtDateTo.Text = end.ToString("yyyy-MM-dd");
string itemCode = "%" + this.txtItemCode.Text.Trim() + "%";
string itemName = "%" + this.txtItemName.Text.Trim() + "%";
//string color = "%" + this.txtColor.Text.Trim() + "%";
//string size = "%" + this.txtSize.Text.Trim() + "%";
string color = "%%";
string size = "%%";
int all = this.chkAll.Checked ? 1 : 0;
try
{
session.BeginTransaction();
DbSession db = session.DbSession as DbSession;
IDbCommand cmd = db.CreateStoredProcCommand("p_rpt_pur_sale_analysis", new object[] { start, end, all, itemCode, itemName, color, size });
db.ExecuteNonQuery(cmd);
if (fetch)
count = Cast.Int(db.ExecuteScalar(@"
Select Count(1) From(
Select Distinct sku.itm_code
From cus_temp_4_pur_sale_analysis a
Inner Join prd_item_sku sku On a.sku_id=sku.sku_id
) t"));
int startIndex = (pageIndex - 1) * pageSize + 1, endIndex = pageIndex * pageSize;
string sql = string.Format(@"
Select * From(
Select t.*,Rownum As rn From(
Select it.itm_code ItemCode,it.itm_name ItemName
,Sum(a.begin_qty) begin_qty,Sum(a.begin_amt) begin_amt
,Sum(a.pur_qty) pur_qty,Sum(a.pur_amt) pur_amt
,Sum(a.pur_rtn_qty) pur_rtn_qty,Sum(a.pur_rtn_amt) pur_rtn_amt
,Sum(a.sale_qty) sale_qty,Sum(a.sale_amt) sale_amt
,Sum(a.sale_rtn_qty) sale_rtn_qty,Sum(a.sale_rtn_amt) sale_rtn_amt
,Sum(a.chk_qty+a.adj_qty+a.lend_qty+a.lend_rtn_qty+a.used_qty+a.oth_in_qty+a.scrap_qty) other_qty
,Sum(nvl(a.end_qty,0)) end_qty,Sum(nvl(a.end_amt,0)) end_amt
,Sum(nvl(sto.use_qty,0)) sto_qty
From cus_temp_4_pur_sale_analysis a
Left Join inv_stock_sum sto On sto.sku_id=a.sku_id
Inner Join prd_item_sku sku On a.sku_id=sku.sku_id
Inner Join prd_item it On it.itm_id=sku.itm_id
Group By it.itm_code,it.itm_name
Order By it.itm_code
)t
)t2 Where t2.rn>={0} And t2.rn<={1}", startIndex, endIndex);
cmd = db.CreateSqlStringCommand(sql);
ds = db.ExecuteDataSet(cmd);
session.Commit();
}
catch(Exception er)
{
session.Rollback();
WebUtil.ShowError(this, er);
}
this.repeater.DataSource = ds;
this.repeater.DataBind();
if (fetch) this.magicPagerMain.RecordCount = this.magicPagerSub.RecordCount = count;
WebUtil.SetMagicPager(magicPagerMain, pageSize, pageIndex);
WebUtil.SetMagicPager(magicPagerSub, pageSize, pageIndex);
}
示例13: AppsOnDeriveRevenues
public static void AppsOnDeriveRevenues(ISession session)
{
var salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRepByInternalOrganisation =
new Dictionary<InternalOrganisation, Dictionary<Party, Dictionary<Party, Dictionary<ProductCategory, Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>>>>>();
var salesRepPartyProductCategoryRevenues = session.Extent<SalesRepPartyProductCategoryRevenue>();
foreach (SalesRepPartyProductCategoryRevenue salesRepPartyProductCategoryRevenue in salesRepPartyProductCategoryRevenues)
{
salesRepPartyProductCategoryRevenue.Revenue = 0;
var date = DateTimeFactory.CreateDate(salesRepPartyProductCategoryRevenue.Year, salesRepPartyProductCategoryRevenue.Month, 01);
Dictionary<Party, Dictionary<Party, Dictionary<ProductCategory, Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>>>> salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRep;
if (!salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRepByInternalOrganisation.TryGetValue(salesRepPartyProductCategoryRevenue.InternalOrganisation, out salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRep))
{
salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRep = new Dictionary<Party, Dictionary<Party, Dictionary<ProductCategory, Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>>>>();
salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRepByInternalOrganisation[salesRepPartyProductCategoryRevenue.InternalOrganisation] = salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRep;
}
Dictionary<Party, Dictionary<ProductCategory, Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>>> salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByParty;
if (!salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRep.TryGetValue(salesRepPartyProductCategoryRevenue.SalesRep, out salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByParty))
{
salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByParty = new Dictionary<Party, Dictionary<ProductCategory, Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>>>();
salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRep[salesRepPartyProductCategoryRevenue.SalesRep] = salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByParty;
}
Dictionary<ProductCategory, Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>> salesRepPartyProductCategoryRevenuesByPeriodByProductCategory;
if (!salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByParty.TryGetValue(salesRepPartyProductCategoryRevenue.Party, out salesRepPartyProductCategoryRevenuesByPeriodByProductCategory))
{
salesRepPartyProductCategoryRevenuesByPeriodByProductCategory = new Dictionary<ProductCategory, Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>>();
salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByParty[salesRepPartyProductCategoryRevenue.Party] = salesRepPartyProductCategoryRevenuesByPeriodByProductCategory;
}
Dictionary<DateTime, SalesRepPartyProductCategoryRevenue> salesRepPartyProductCategoryRevenuesByPeriod;
if (!salesRepPartyProductCategoryRevenuesByPeriodByProductCategory.TryGetValue(salesRepPartyProductCategoryRevenue.ProductCategory, out salesRepPartyProductCategoryRevenuesByPeriod))
{
salesRepPartyProductCategoryRevenuesByPeriod = new Dictionary<DateTime, SalesRepPartyProductCategoryRevenue>();
salesRepPartyProductCategoryRevenuesByPeriodByProductCategory[salesRepPartyProductCategoryRevenue.ProductCategory] = salesRepPartyProductCategoryRevenuesByPeriod;
}
SalesRepPartyProductCategoryRevenue revenue;
if (!salesRepPartyProductCategoryRevenuesByPeriod.TryGetValue(date, out revenue))
{
salesRepPartyProductCategoryRevenuesByPeriod.Add(date, salesRepPartyProductCategoryRevenue);
}
}
var revenues = new HashSet<long>();
var salesInvoices = session.Extent<SalesInvoice>();
var year = 0;
foreach (SalesInvoice salesInvoice in salesInvoices)
{
if (year != salesInvoice.InvoiceDate.Year)
{
session.Commit();
year = salesInvoice.InvoiceDate.Year;
}
var date = DateTimeFactory.CreateDate(salesInvoice.InvoiceDate.Year, salesInvoice.InvoiceDate.Month, 01);
foreach (SalesInvoiceItem salesInvoiceItem in salesInvoice.SalesInvoiceItems)
{
if (salesInvoiceItem.ExistSalesRep && salesInvoiceItem.ExistProduct && salesInvoiceItem.Product.ExistPrimaryProductCategory)
{
foreach (ProductCategory productCategory in salesInvoiceItem.Product.ProductCategories)
{
CreateProductCategoryRevenue(session, salesRepPartyProductCategoryRevenuesByPeriodByProductCategoryByPartyBySalesRepByInternalOrganisation, productCategory, date, salesInvoiceItem, revenues);
}
}
}
}
foreach (SalesRepPartyProductCategoryRevenue salesRepPartyProductCategoryRevenue in salesRepPartyProductCategoryRevenues)
{
if (!revenues.Contains(salesRepPartyProductCategoryRevenue.Id))
{
salesRepPartyProductCategoryRevenue.Delete();
}
}
}
示例14: using
void IApprovable.PostApprove(ISession session)
{
if (this.ApproveResult == ApproveStatus.Approve)
{
using (ISession newSession = new Session())
{
try
{
session.BeginTransaction();
this.Close(session);
session.Commit();
}
catch (Exception er)
{
newSession.Rollback();
log.Error(string.Format("�ɹ��˻���{0}ǩ����ɣ��Զ�Closeʱ�����쳣", this.OrderNumber), er);
}
}
}
}
示例15: Populate
private void Populate(ISession session)
{
this.c1A = C1.Create(session);
this.c1B = C1.Create(session);
this.c1C = C1.Create(session);
this.c1D = C1.Create(session);
this.c2A = C2.Create(session);
this.c2B = C2.Create(session);
this.c2C = C2.Create(session);
this.c2D = C2.Create(session);
this.c3A = C3.Create(session);
this.c3B = C3.Create(session);
this.c3C = C3.Create(session);
this.c3D = C3.Create(session);
this.c4A = C4.Create(session);
this.c4B = C4.Create(session);
this.c4C = C4.Create(session);
this.c4D = C4.Create(session);
IObject[] allObjects =
{
this.c1A, this.c1B, this.c1C, this.c1D, this.c2A, this.c2B, this.c2C, this.c2D,
this.c3A, this.c3B, this.c3C, this.c3D, this.c4A, this.c4B, this.c4C, this.c4D
};
this.c1A.C1AllorsString = string.Empty; // emtpy string
this.c1A.C1AllorsInteger = -1;
this.c1A.C1AllorsDecimal = 1.1m;
this.c1A.C1AllorsDouble = 1.1d;
this.c1A.C1AllorsBoolean = true;
this.c1A.C1AllorsDateTime = new DateTime(1973, 3, 27, 12, 1, 2, 3, DateTimeKind.Utc);
this.c1A.C1AllorsUnique = new Guid(GuidString);
this.c1A.C1AllorsBinary = new byte[0];
this.c1B.C1AllorsString = "a1";
this.c1B.C1AllorsBinary = new byte[] { 0, 1, 2, 3 };
this.c1B.C1C2one2one = this.c2A;
this.c1B.C1C2many2one = this.c2A;
this.c1C.C1C2many2one = this.c2A;
this.c1B.AddC1C2one2many(this.c2A);
this.c1B.AddC1C2one2many(this.c2B);
this.c1B.AddC1C2one2many(this.c2C);
this.c1B.AddC1C2one2many(this.c2D);
this.c1B.AddC1C2many2many(this.c2A);
this.c1B.AddC1C2many2many(this.c2B);
this.c1B.AddC1C2many2many(this.c2C);
this.c1B.AddC1C2many2many(this.c2D);
this.c1C.C1AllorsString = "a2";
this.c1C.C1AllorsBinary = null;
this.c3A.I34AllorsString = "c3a";
this.c4A.I34AllorsString = "c4a";
foreach (S1234 allorsObject in allObjects)
{
foreach (S1234 addObject in allObjects)
{
allorsObject.AddS1234many2many(addObject);
}
}
session.Commit();
}