当前位置: 首页>>代码示例>>C#>>正文


C# esTransactionScope.Complete方法代码示例

本文整理汇总了C#中EntitySpaces.Interfaces.esTransactionScope.Complete方法的典型用法代码示例。如果您正苦于以下问题:C# esTransactionScope.Complete方法的具体用法?C# esTransactionScope.Complete怎么用?C# esTransactionScope.Complete使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EntitySpaces.Interfaces.esTransactionScope的用法示例。


在下文中一共展示了esTransactionScope.Complete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestTransactions

		public void TestTransactions()
		{
			switch (aggTest.es.Connection.Name)
			{
				case "SQLStoredProcEnterprise":
				case "SQLDynamicEnterprise":
				case "ORACLEStoredProcEnterprise":
				case "ORACLEDynamicEnterprise":
				case "VistaDBDynamic":
					Assert.Ignore("Using esTransactionScope only");
					break;

				default:
                    int tempId1 = 0;
                    int tempId2 = 0;

                    aggTest = new AggregateTest();
                    AggregateTest aggTest2 = new AggregateTest();

                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        aggTest.Save();
                        tempId1 = aggTest.Id.Value;
                        aggTest2.Save();
                        tempId2 = aggTest2.Id.Value;

                        scope.Complete();
                    }

                    aggTest = new AggregateTest();
                    Assert.IsTrue(aggTest.LoadByPrimaryKey(tempId1));
                    aggTest.MarkAsDeleted();
                    aggTest.Save();

                    aggTest = new AggregateTest();
                    Assert.IsTrue(aggTest.LoadByPrimaryKey(tempId2));
                    aggTest.MarkAsDeleted();
                    aggTest.Save();

					break;
			}
		}
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:42,代码来源:TransactionFixture.cs

示例2: LinqMaterializeTest

 protected override void LinqMaterializeTest(int count)
 {
     using (var ts = new esTransactionScope())
     {
         var simplests = new SimplestsCollection();
         int i = 0;
         while (i < count)
         {
             simplests.Load(_db, _db.GetTable<Simplests>().Where(o => o.Id > 0));
             foreach (var o in simplests)
                 if (++i >= count)
                     break;
         }
         ts.Complete();
     }
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:16,代码来源:EntitySpacesTest.cs

示例3: NativeQueryTest

 protected override void NativeQueryTest(int count)
 {
     using (var ts = new esTransactionScope())
     {
         for (int i = 0; i < count; i++)
         {
             var simplests = new SimplestsCollection();
             var id = i % InstanceCount;
             simplests.Query.Where(simplests.Query.Id == id);
             if (simplests.Query.Load())
                 foreach (var simplest in simplests)
                 {
                     // Doing nothing, just enumerate
                 }
         }
         ts.Complete();
     }
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:18,代码来源:EntitySpacesTest.cs

示例4: CompiledLinqQueryTest

 protected override void CompiledLinqQueryTest(int count)
 {
     using (var ts = new esTransactionScope())
     {
         for (int i = 0; i < count; i++)
         {
             var id = i % InstanceCount;
             var query = new SimplestsCollection();
             query.Load(_db, _compiledQuery(_db, id));
             foreach (var simplest in query)
             {
                 // Doing nothing, just enumerate
             }
         }
         ts.Complete();
     }
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:17,代码来源:EntitySpacesTest.cs

示例5: FetchTest

 protected override void FetchTest(int count)
 {
     long sum = (long) count * (count - 1) / 2;
     using (var ts = new esTransactionScope())
     {
         for (int i = 0; i < count; i++)
         {
             var id = (long) i % InstanceCount;
             var simplest = new Simplests();
             simplest.LoadByPrimaryKey(id);
             sum -= simplest.Id.Value;
         }
         ts.Complete();
     }
     if (count <= InstanceCount)
         Assert.AreEqual(0, sum);
 }
开发者ID:sdanyliv,项目名称:ormbattle,代码行数:17,代码来源:EntitySpacesTest.cs

示例6: TestFailedTransaction

        public void TestFailedTransaction()
        {
            switch (aggTest.es.Connection.Name)
            {
                case "SQLStoredProcEnterprise":
                case "SQLDynamicEnterprise":
                case "ORACLEStoredProcEnterprise":
                case "ORACLEDynamicEnterprise":
                case "VistaDBDynamic":
                    Assert.Ignore("Using esTransactionScope only");
                    break;

                default:
                    try
                    {
                        aggTest = new AggregateTest();
                        AggregateTest aggTest2 = new AggregateTest();
                        int tempId1 = -1;
                        int tempId2 = -1;
                        aggTest2.str().HireDate = "1/1/1";

                        using (esTransactionScope scope = new esTransactionScope())
                        {
                            try
                            {
                                aggTest.Save();
                                tempId1 = aggTest.Id.Value;
                                aggTest2.Save();
                                tempId2 = aggTest2.Id.Value;

                                throw new Exception();

                                scope.Complete();
                            }
                            catch
                            {
                            }
                        }
                        aggTest = new AggregateTest();
                        Assert.IsFalse(aggTest.LoadByPrimaryKey(tempId1));

                        aggTest = new AggregateTest();
                        Assert.IsFalse(aggTest.LoadByPrimaryKey(tempId2));
                    }
                    catch (Exception ex)
                    {
                        Assert.Fail(ex.ToString());
                    }
                    break;
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:51,代码来源:TransactionFixture.cs

示例7: SaveDynamicCollection_InsertsUpdates

        private static DataTable SaveDynamicCollection_InsertsUpdates(esDataRequest request)
        {
            DataTable dataTable = CreateDataTable(request);

            using (esTransactionScope scope = new esTransactionScope())
            {
                using (SADataAdapter da = new SADataAdapter())
                {
                    da.AcceptChangesDuringUpdate = false;
                    da.ContinueUpdateOnError = request.ContinueUpdateOnError;

                    SACommand cmd = null;

                    if (!request.IgnoreComputedColumns)
                    {
                        da.RowUpdated += new SARowUpdatedEventHandler(OnRowUpdated);
                    }

                    foreach (esEntitySavePacket packet in request.CollectionSavePacket)
                    {
                        if (packet.RowState != esDataRowState.Added && packet.RowState != esDataRowState.Modified) continue;

                        DataRow row = dataTable.NewRow();
                        dataTable.Rows.Add(row);

                        switch (packet.RowState)
                        {
                            case esDataRowState.Added:
                                cmd = da.InsertCommand = Shared.BuildDynamicInsertCommand(request, packet.ModifiedColumns);
                                SetModifiedValues(request, packet, row);
                                break;

                            case esDataRowState.Modified:
                                cmd = da.UpdateCommand = Shared.BuildDynamicUpdateCommand(request, packet.ModifiedColumns);
                                SetOriginalValues(request, packet, row, false);
                                SetModifiedValues(request, packet, row);
                                row.AcceptChanges();
                                row.SetModified();
                                break;
                        }

                        request.Properties["esDataRequest"] = request;
                        request.Properties["esEntityData"] = packet;
                        dataTable.ExtendedProperties["props"] = request.Properties;

                        DataRow[] singleRow = new DataRow[1];
                        singleRow[0] = row;

                        try
                        {
                            esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);

                            #region Profiling

                            if (sTraceHandler != null)
                            {
                                using (esTraceArguments esTrace = new esTraceArguments(request, cmd, packet, "SaveCollectionDynamic", System.Environment.StackTrace))
                                {
                                    try
                                    {
                                        da.Update(singleRow);
                                    }
                                    catch (Exception ex)
                                    {
                                        esTrace.Exception = ex.Message;
                                        throw;
                                    }
                                }
                            }
                            else

                            #endregion Profiling

                            {
                                da.Update(singleRow);
                            }

                            if (row.HasErrors)
                            {
                                request.FireOnError(packet, row.RowError);
                            }
                        }
                        finally
                        {
                            esTransactionScope.DeEnlist(cmd);
                            dataTable.Rows.Clear();
                        }
                    }
                }

                scope.Complete();
            }

            return dataTable;
        }
开发者ID:jssgarcia,项目名称:ESLite,代码行数:95,代码来源:DataProvider.cs

示例8: SaveDynamicCollection_Deletes

        static private DataTable SaveDynamicCollection_Deletes(esDataRequest request)
        {
            SACommand cmd = null;

            DataTable dataTable = CreateDataTable(request);

            using (esTransactionScope scope = new esTransactionScope())
            {
                using (SADataAdapter da = new SADataAdapter())
                {
                    da.AcceptChangesDuringUpdate = false;
                    da.ContinueUpdateOnError = request.ContinueUpdateOnError;

                    try
                    {
                        da.ContinueUpdateOnError = request.ContinueUpdateOnError;

                        cmd = da.DeleteCommand = Shared.BuildDynamicDeleteCommand(request, request.CollectionSavePacket[0]);
                        esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);

                        DataRow[] singleRow = new DataRow[1];

                        // Delete each record
                        foreach (esEntitySavePacket packet in request.CollectionSavePacket)
                        {
                            DataRow row = dataTable.NewRow();
                            dataTable.Rows.Add(row);

                            SetOriginalValues(request, packet, row, true);
                            row.AcceptChanges();
                            row.Delete();

                            singleRow[0] = row;
                            da.Update(singleRow);

                            if (row.HasErrors)
                            {
                                request.FireOnError(packet, row.RowError);
                            }

                            dataTable.Rows.Clear(); // ADO.NET won't let us reuse the same DataRow
                        }
                    }
                    finally
                    {
                        esTransactionScope.DeEnlist(cmd);
                    }
                }
                scope.Complete();
            }

            return request.Table;
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:53,代码来源:DataProvider.cs

示例9: RadGrid1_InsertCommand

        protected void RadGrid1_InsertCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)
        {
            GridEditableItem editedItem = e.Item as GridEditableItem;
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
            DateTime TransDateMonth = DateTime.Now;
            try
            {
                TransDateMonth = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate;
            }
            catch (Exception ex)
            {
                string error = ex.Message;
            }
            int transDateMonth = TransDateMonth.Month;
            //perubahan terakhir, autonumber mengikuti bulan transaksi, bukan bulan berjalan
            //string month = DateTime.Now.Month.ToString().Trim();
            string month = transDateMonth.ToString().Trim();
            string autonumber = "";
            if (month.Length == 1)
                month = ('0' + month).Trim();

            Trans Trans = new Trans();
            //Auto Number
            AutoNumberingQuery anQ = new AutoNumberingQuery();
            anQ.SelectAll();
            anQ.Where(anQ.KaMonth == month, anQ.KaYear == DateTime.Now.Year.ToString().Trim());
            AutoNumberingCollection anColl = new AutoNumberingCollection();

            anColl.Load(anQ);
            //KelAnggaranQuery kaQ = new KelAnggaranQuery();
            //kaQ.SelectAll();
            //kaQ.Where(kaQ.KaCode == (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedValue.Trim());
            //KelAnggaranCollection kaColl = new KelAnggaranCollection();

            //kaColl.Load(kaQ);            

            if (anColl.Count == 0)
            {
                AutoNumberingCollection anCollection = new AutoNumberingCollection();
                AutoNumbering aN = new AutoNumbering();
                aN = anCollection.AddNew();
                aN.KaYear = DateTime.Now.Year.ToString().Trim();
                aN.KaMonth = month;
                aN.LastNumber = 1;
                aN.PrefixNumber = "000";
                //AutoNumbering an = new AutoNumbering { KaYear = DateTime.Now.Year.ToString().Trim(), KaMonth = month, LastNumber = 1, PrefixNumber = "000" };
                autonumber = String.Format("{0}{1}{2}-0001", autonumber, DateTime.Now.Year.ToString().Trim(), month);
                //an.Save();

                try
                {
                    TransCollection transCollection = new TransCollection();
                    Trans = transCollection.AddNew();
                    //Trans.KaCode = (userControl.FindControl("cmbTransCODE") as RadComboBox).SelectedItem.Value;
                    Trans.KaCode = (userControl.FindControl("HiddenField1") as HiddenField).Value;
                    Trans.TransNumber = autonumber.ToUpper();
                    Trans.CekBgNumber = (userControl.FindControl("txtCek") as RadTextBox).Text;
                    //Trans.Amount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value - (userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value);
                    Trans.DebitAmount = Convert.ToDecimal((userControl.FindControl("txtDebitAmount") as RadNumericTextBox).Value);
                    Trans.CreditAmount = Convert.ToDecimal((userControl.FindControl("txtCreditAmount") as RadNumericTextBox).Value);
                    Trans.Descript = (userControl.FindControl("txtDESC") as RadTextBox).Text;
                    Trans.KasId = (userControl.FindControl("cmbKasID") as RadComboBox).SelectedValue.ToUpper();
                    Trans.TransDate = (DateTime)(userControl.FindControl("dtpTransDate") as RadDatePicker).DbSelectedDate;
                    Trans.UserInsert = "toro";
                    Trans.TglInsert = DateTime.Now;
                    Trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"];
                    Trans.Isverified = false;
                    Trans.IsClosed = false;

                    using (esTransactionScope scope = new esTransactionScope())
                    {
                        anCollection.Save();
                        transCollection.Save();
                        scope.Complete();
                    }  
                }
                catch (Exception ex)
                {
                    string es = ex.Message;
                }
                finally
                {
                    RadGrid1.Rebind();
                }
            }
            else
                foreach (AutoNumbering aa in anColl)
                {
                    string i = (aa.LastNumber + 1).ToString().Trim();
                    if (i.Length == 1)
                        autonumber = String.Format("{0}{1}{2}-000{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 2)
                        autonumber = String.Format("{0}{1}{2}-00{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 3)
                        autonumber = String.Format("{0}{1}{2}-0{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    if (i.Length == 4)
                        autonumber = String.Format("{0}{1}{2}-{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                    AutoNumbering anb = new AutoNumbering();
                    AutoNumberingCollection anCollection = new AutoNumberingCollection();
                    anb = anCollection.AddNew();
//.........这里部分代码省略.........
开发者ID:trogalko,项目名称:Rscm_Bku,代码行数:101,代码来源:TransaksiKasBendaharaPengguna.aspx.cs

示例10: Submit

		/// <summary>
		/// Used to Save the data to the database
		/// </summary>
		/// <returns>True if Successful</returns>
        public override bool Submit(ChangeSet changeSet)
        {
            try
            {
                using (esTransactionScope scope = new esTransactionScope())
                {
                    bool success= base.Submit(changeSet);

                    if (success)
                    {
                        scope.Complete();
                    }

                    return success;
                }
            }
            catch (Exception ex)
            {
                if (!HandleError(ex))
                {
                    throw;
                }

                return true;
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:30,代码来源:esDomainService.cs

示例11: SaveDynamicCollection_InsertsUpdates

        static private DataTable SaveDynamicCollection_InsertsUpdates(esDataRequest request)
        {
            DataTable dataTable = CreateDataTable(request);

            using (esTransactionScope scope = new esTransactionScope())
            {
                using (VistaDBDataAdapter da = new VistaDBDataAdapter())
                {
                    da.AcceptChangesDuringUpdate = false;
                    da.ContinueUpdateOnError = request.ContinueUpdateOnError;

                    VistaDBCommand cmd = null;

                    if (!request.IgnoreComputedColumns)
                    {
                        da.RowUpdated += new VistaDBRowUpdatedEventHandler(OnRowUpdated);
                    }

                    foreach (esEntitySavePacket packet in request.CollectionSavePacket)
                    {
                        if (packet.RowState != esDataRowState.Added && packet.RowState != esDataRowState.Modified) continue;

                        DataRow row = dataTable.NewRow();
                        dataTable.Rows.Add(row);

                        switch (packet.RowState)
                        {
                            case esDataRowState.Added:
                                cmd = da.InsertCommand = Shared.BuildDynamicInsertCommand(request, packet.ModifiedColumns);
                                SetModifiedValues(request, packet, row);
                                break;

                            case esDataRowState.Modified:
                                cmd = da.UpdateCommand = Shared.BuildDynamicUpdateCommand(request, packet.ModifiedColumns);
                                SetOriginalValues(request, packet, row, false);
                                SetModifiedValues(request, packet, row);
                                row.AcceptChanges();
                                row.SetModified();
                                break;
                        }

                        request.Properties["esDataRequest"] = request;
                        request.Properties["esEntityData"] = packet;
                        dataTable.ExtendedProperties["props"] = request.Properties;

                        DataRow[] singleRow = new DataRow[1];
                        singleRow[0] = row;

                        try
                        {
                            esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
                            da.Update(singleRow);

                            if (row.HasErrors)
                            {
                                request.FireOnError(packet, row.RowError);
                            }
                        }
                        finally
                        {
                            esTransactionScope.DeEnlist(cmd);
                            dataTable.Rows.Clear();
                        }

                        if (!row.HasErrors && cmd.Parameters != null)
                        {
                            foreach (VistaDBParameter param in cmd.Parameters)
                            {
                                switch (param.Direction)
                                {
                                    case ParameterDirection.Output:
                                    case ParameterDirection.InputOutput:

                                        packet.CurrentValues[param.SourceColumn] = param.Value;
                                        break;
                                }
                            }
                        }

                        cmd.Dispose();
                    }
                }

                scope.Complete();
            }

            return dataTable;
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-Architecture,代码行数:88,代码来源:DataProvider.cs

示例12: cmdSave_Click

        protected void cmdSave_Click(object sender, EventArgs e)
        {
            //ADD
            Trans trans = new Trans();
            string Descript = txtDescription.Text;
            string CreditAmoun = txtCreditAmount.Text;
            if (Request.QueryString["BKU_ID"] == null)
            {
                int TransDateMonth = ((DateTime)dtpTransDate.SelectedDate).Month;
                string month = TransDateMonth.ToString().Trim();
                string autonumber = "";
                if (month.Length == 1)
                    month = ('0' + month).Trim();

                //Trans Trans = new Trans();
                //Auto Number
                AutoNumberingQuery anQ = new AutoNumberingQuery();
                anQ.SelectAll();
                anQ.Where(anQ.KaMonth == month, anQ.KaYear == DateTime.Now.Year.ToString().Trim());
                AutoNumberingCollection anColl = new AutoNumberingCollection();
                anColl.Load(anQ);
                //New month, new autonumber
                if (anColl.Count == 0)
                {
                    AutoNumberingCollection anCollection = new AutoNumberingCollection();
                    AutoNumbering aN = new AutoNumbering();
                    aN = anCollection.AddNew();
                    aN.KaYear = DateTime.Now.Year.ToString().Trim();
                    aN.KaMonth = month;
                    aN.LastNumber = 1;
                    aN.PrefixNumber = "000";
                    autonumber = String.Format("{0}{1}{2}-0001", autonumber, DateTime.Now.Year.ToString().Trim(), month);
                    try
                    {
                        Decimal DebitAmount = 0;
                        Decimal CreditAmount = 0;
                        TransCollection transColl = new TransCollection();
                        trans = transColl.AddNew();
                        trans.TransNumber = autonumber.ToUpper();
                        trans.KaCode = cmbTransCode.SelectedValue;
                        trans.TransDate = dtpTransDate.SelectedDate;
                        trans.KasId = cmbKasID.SelectedValue;
                        trans.Descript = txtDescription.Text;
                        trans.CekBgNumber = txtCekBG.Text;
                        if (Decimal.TryParse(txtDebitAmount.Text, out DebitAmount))
                            trans.DebitAmount = DebitAmount;
                        else
                            trans.DebitAmount = 0;
                        if (Decimal.TryParse(txtCreditAmount.Text, out CreditAmount))
                            trans.CreditAmount = CreditAmount;
                        else
                            trans.CreditAmount = 0;
                        trans.UserInsert = HttpContext.Current.Session["UserId"].ToString();
                        trans.TglInsert = DateTime.Now;
                        trans.Isverified = false;
                        trans.IsClosed = false;
                        trans.PeriodId = (Int32)HttpContext.Current.Session["_periodeId"];

                        using (esTransactionScope scope = new esTransactionScope())
                        {
                            anCollection.Save();
                            transColl.Save();
                            scope.Complete();
                        }
                    }
                    catch (Exception ex)
                    {
                        string es = ex.Message;
                    }
                }
                // If month already exist, increment autonumber
                else
                {
                    foreach (AutoNumbering aa in anColl)
                    {
                        string i = (aa.LastNumber + 1).ToString().Trim();
                        if (i.Length == 1)
                            autonumber = String.Format("{0}{1}{2}-000{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                        if (i.Length == 2)
                            autonumber = String.Format("{0}{1}{2}-00{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                        if (i.Length == 3)
                            autonumber = String.Format("{0}{1}{2}-0{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                        if (i.Length == 4)
                            autonumber = String.Format("{0}{1}{2}-{3}", autonumber, aa.KaYear, aa.KaMonth, i);
                        AutoNumbering anb = new AutoNumbering();
                        AutoNumberingCollection anCollection = new AutoNumberingCollection();
                        anb = anCollection.AddNew();
                        if (anb.LoadByPrimaryKey((long)aa.Id))
                        {
                            anb.LastNumber = aa.LastNumber + 1;

                            try
                            {
                                Decimal DebitAmount = 0;
                                Decimal CreditAmount = 0;
                                TransCollection transColl = new TransCollection();
                                trans = transColl.AddNew();
                                trans.TransNumber = autonumber.ToUpper();
                                trans.KaCode = cmbTransCode.SelectedValue;
                                trans.TransDate = dtpTransDate.SelectedDate;
//.........这里部分代码省略.........
开发者ID:trogalko,项目名称:Rscm_Bku,代码行数:101,代码来源:TransaksiKasBendaharaPenggunaCUD.aspx.cs

示例13: SaveStoredProcCollection


//.........这里部分代码省略.........
                                if (param.Direction == ParameterDirection.Output)
                                {
                                    param.Value = null;
                                }
                                else
                                {
                                    if (packet.CurrentValues.ContainsKey(param.SourceColumn))
                                    {
                                        param.Value = packet.CurrentValues[param.SourceColumn];
                                    }
                                    else
                                    {
                                        param.Value = null;
                                    }
                                }
                            }
                        }

                        #endregion Preprocess Parameters

                        #region Execute Command

                        try
                        {
                            int count;

                            #region Profiling

                            if (sTraceHandler != null)
                            {
                                using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "SaveCollectionStoredProcedure", System.Environment.StackTrace))
                                {
                                    try
                                    {
                                        count = cmd.ExecuteNonQuery();
                                    }
                                    catch (Exception ex)
                                    {
                                        esTrace.Exception = ex.Message;
                                        throw;
                                    }
                                }
                            }
                            else

                            #endregion Profiling

                            {
                                count = cmd.ExecuteNonQuery();
                            }

                            if (count < 1)
                            {
                                throw new esConcurrencyException("Update failed to update any records @ " + cmd.CommandText);
                            }
                        }
                        catch (Exception ex)
                        {
                            exception = true;
                            request.FireOnError(packet, ex.Message);
                            if (!request.ContinueUpdateOnError)
                            {
                                throw;
                            }
                        }

                        #endregion Execute Command

                        #region Postprocess Parameters

                        if (!exception && packet.RowState != esDataRowState.Deleted && cmd.Parameters != null)
                        {
                            foreach (SqlParameter param in cmd.Parameters)
                            {
                                switch (param.Direction)
                                {
                                    case ParameterDirection.Output:
                                    case ParameterDirection.InputOutput:

                                        packet.CurrentValues[param.SourceColumn] = param.Value;
                                        break;
                                }
                            }
                        }

                        #endregion Postprocess Parameters
                    }

                    scope.Complete();
                }
            }
            finally
            {
                if (cmdInsert != null) esTransactionScope.DeEnlist(cmdInsert);
                if (cmdUpdate != null) esTransactionScope.DeEnlist(cmdUpdate);
                if (cmdDelete != null) esTransactionScope.DeEnlist(cmdDelete);
            }

            return null;
        }
开发者ID:jssgarcia,项目名称:ESLite,代码行数:101,代码来源:DataProvider.cs

示例14: SaveDynamicCollection


//.........这里部分代码省略.........
            {
                SqlCommand cmd = null;
                bool exception = false;

                foreach (esEntitySavePacket packet in request.CollectionSavePacket)
                {
                    exception = false;
                    cmd = null;

                    switch (packet.RowState)
                    {
                        case esDataRowState.Added:
                            cmd = Shared.BuildDynamicInsertCommand(request, packet);
                            break;

                        case esDataRowState.Modified:
                            cmd = Shared.BuildDynamicUpdateCommand(request, packet);
                            break;

                        case esDataRowState.Deleted:
                            cmd = Shared.BuildDynamicDeleteCommand(request, packet);
                            break;

                        case esDataRowState.Unchanged:
                            continue;
                    }

                    try
                    {
                        esTransactionScope.Enlist(cmd, request.ConnectionString, CreateIDbConnectionDelegate);
                        int count;

                        #region Profiling

                        if (sTraceHandler != null)
                        {
                            using (esTraceArguments esTrace = new esTraceArguments(request, cmd, "SaveCollectionDynamic", System.Environment.StackTrace))
                            {
                                try
                                {
                                    count = cmd.ExecuteNonQuery(); ;
                                }
                                catch (Exception ex)
                                {
                                    esTrace.Exception = ex.Message;
                                    throw;
                                }
                            }
                        }
                        else

                        #endregion Profiling

                        {
                            count = cmd.ExecuteNonQuery();
                        }

                        if (count < 1)
                        {
                            throw new esConcurrencyException("Update failed to update any records for Table " + Shared.CreateFullName(request));
                        }
                    }
                    catch (Exception ex)
                    {
                        exception = true;

                        request.FireOnError(packet, ex.Message);

                        if (!request.ContinueUpdateOnError)
                        {
                            throw;
                        }
                    }
                    finally
                    {
                        esTransactionScope.DeEnlist(cmd);
                        cmd.Dispose();
                    }

                    if (!exception && packet.RowState != esDataRowState.Deleted && cmd.Parameters != null)
                    {
                        foreach (SqlParameter param in cmd.Parameters)
                        {
                            switch (param.Direction)
                            {
                                case ParameterDirection.Output:
                                case ParameterDirection.InputOutput:

                                    packet.CurrentValues[param.SourceColumn] = param.Value;
                                    break;
                            }
                        }
                    }
                }

                scope.Complete();
            }

            return null;
        }
开发者ID:jssgarcia,项目名称:ESLite,代码行数:101,代码来源:DataProvider.cs

示例15: CopyAnnotationData

        private void CopyAnnotationData(int fromAnnotationId, int toAnnotationId)
        {
            Annotation ann = new Annotation();
            if (!ann.LoadByPrimaryKey(toAnnotationId))
            {
                MessageBox.Show("To Annotation Not found");
                return;
            }

            ann = new Annotation();
            if (!ann.LoadByPrimaryKey(fromAnnotationId))
            {
                MessageBox.Show("From Annotation Not found");
                return;
            }

            Dictionary<int, int> axisKeys = new Dictionary<int, int>();
            Dictionary<int, int> seriesKeys = new Dictionary<int,int>();

            using (esTransactionScope scope = new esTransactionScope())
            {
                foreach (AnnotationPlot annPlot in ann.AnnotationPlotCollectionByAnnotationId)
                {
                    AnnotationPlot annPlotClone = new AnnotationPlot();
                    annPlotClone.AnnotationId = toAnnotationId;
                    annPlotClone.RegionId = annPlot.RegionId;
                    annPlotClone.Description = annPlot.Description;
                    annPlotClone.Title = annPlot.Title;
                    annPlotClone.Type = annPlot.Type;
                    annPlotClone.DimensionCount = annPlot.DimensionCount;
                    annPlotClone.Save();

                    foreach (AnnotationPlotAxis annPlotAxis in annPlot.AnnotationPlotAxisCollectionByPlotId)
                    {
                        AnnotationPlotAxis annPlotAxisClone =  new AnnotationPlotAxis();
                        annPlotAxisClone.PlotId = annPlotClone.Id;
                        annPlotAxisClone.Label = annPlotAxis.Label;
                        annPlotAxisClone.MinValue = annPlotAxis.MinValue;
                        annPlotAxisClone.MaxValue = annPlotAxis.MaxValue;
                        annPlotAxisClone.Scale = annPlotAxis.Scale;
                        annPlotAxisClone.Type = annPlotAxis.Type;
                        annPlotAxisClone.Dimension = annPlotAxis.Dimension;
                        annPlotAxisClone.Save();
                        axisKeys.Add(annPlotAxis.Id.Value, annPlotAxisClone.Id.Value);
                    }

                    foreach (AnnotationPlotSeries annPlotSeries in annPlot.AnnotationPlotSeriesCollectionByPlotId)
                    {
                        AnnotationPlotSeries annPlotSeriesClone = new AnnotationPlotSeries();
                        annPlotSeriesClone.PlotId = annPlotClone.Id;
                        annPlotSeriesClone.Description = annPlotSeries.Description;
                        annPlotSeriesClone.ColorRGB = annPlotSeries.ColorRGB;
                        annPlotSeriesClone.Save();
                        seriesKeys.Add(annPlotSeries.Id.Value, annPlotSeriesClone.Id.Value);
                    }
                }

                foreach (AnnotationPlot annPlot in ann.AnnotationPlotCollectionByAnnotationId)
                {
                    foreach (AnnotationPlotAxis annPlotAxis in annPlot.AnnotationPlotAxisCollectionByPlotId)
                    {
                        foreach (AnnotationPlotAxisData annPlotAxisData in annPlotAxis.AnnotationPlotAxisDataCollectionByAxisId)
                        {
                            AnnotationPlotAxisData annPlotAxisDataClone = new AnnotationPlotAxisData();
                            annPlotAxisDataClone.AxisId = axisKeys[annPlotAxisData.AxisId.Value];
                            annPlotAxisDataClone.SeriesId  = seriesKeys[annPlotAxisData.SeriesId.Value];
                            annPlotAxisDataClone.DataBin = annPlotAxisData.DataBin;
                            annPlotAxisDataClone.Save();
                        }
                    }

                    foreach (AnnotationPlotSeries annPlotSeries in annPlot.AnnotationPlotSeriesCollectionByPlotId)
                    {
                        foreach (AnnotationPlotAxisData annPlotAxisData in annPlotSeries.AnnotationPlotAxisDataCollectionBySeriesId)
                        {
                            AnnotationPlotAxisData annPlotAxisDataClone = new AnnotationPlotAxisData();
                            annPlotAxisDataClone.Query.Where(
                                annPlotAxisDataClone.Query.AxisId == axisKeys[annPlotAxisData.AxisId.Value] &&
                                annPlotAxisDataClone.Query.SeriesId == seriesKeys[annPlotAxisData.SeriesId.Value]);

                            if (!annPlotAxisDataClone.Query.Load())
                            {
                                annPlotAxisDataClone = new AnnotationPlotAxisData();
                                annPlotAxisDataClone.AxisId = axisKeys[annPlotAxisData.AxisId.Value];
                                annPlotAxisDataClone.SeriesId = seriesKeys[annPlotAxisData.SeriesId.Value];
                                annPlotAxisDataClone.DataBin = annPlotAxisData.DataBin;
                                annPlotAxisDataClone.Save();
                            }
                        }
                    }
                }
                scope.Complete();
            }
        }
开发者ID:stacyjeptha,项目名称:EntitySpaces-CompleteSource,代码行数:94,代码来源:FormMain.cs


注:本文中的EntitySpaces.Interfaces.esTransactionScope.Complete方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。