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


C# TransactionScope.Complete方法代码示例

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


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

示例1: AddCWA

        public SigmaResultType AddCWA(TypeCWA objCWA)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@ProjectId", Utilities.ToInt32(userinfo.CurrentProjectId.ToString().Trim())));
            paramList.Add(new SqlParameter("@Name", objCWA.Name.Trim()));
            paramList.Add(new SqlParameter("@Area", objCWA.Area));
            paramList.Add(new SqlParameter("@Description", objCWA.Description.Trim()));
            paramList.Add(new SqlParameter("@CreatedBy", userinfo.SigmaUserId.Trim()));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddCWA", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;

                scope.Complete();
            }

            return result;
        }
开发者ID:paraneye,项目名称:WebService,代码行数:31,代码来源:CWAMgr.cs

示例2: AddEquipment

        public SigmaResultType AddEquipment(TypeEquipment objEquipment)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();

            SigmaResultType result = new SigmaResultType();
            TransactionScope scope = null;

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@EquipmentCodeMain", objEquipment.EquipmentCodeMain.Trim()));
            paramList.Add(new SqlParameter("@EquipmentCodeSub", objEquipment.EquipmentCodeSub.Trim()));
            paramList.Add(new SqlParameter("@Description", objEquipment.Description.Trim()));
            paramList.Add(new SqlParameter("@ThirdLevel", objEquipment.ThirdLevel.Trim()));
            paramList.Add(new SqlParameter("@Spec", objEquipment.Spec.Trim()));
            paramList.Add(new SqlParameter("@EquipmentType", objEquipment.EquipmentType.Trim()));
            paramList.Add(new SqlParameter("@CreatedBy", userinfo.SigmaUserId.Trim()));
            paramList.Add(new SqlParameter("@ModelNumber", objEquipment.ModelNumber.Trim()));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddEquipment", paramList.ToArray());
                result.IsSuccessful = true;
                result.ScalarValue = (int)outParam.Value;

                scope.Complete();
            }

            return result;
        }
开发者ID:paraneye,项目名称:WebService,代码行数:34,代码来源:EquipmentMgr.cs

示例3: TransactionScopeCompleted3

 public void TransactionScopeCompleted3()
 {
     Assert.Throws<InvalidOperationException>(() =>
     {
         using (TransactionScope scope = new TransactionScope())
         {
             scope.Complete();
             scope.Complete();
         }
     });
 }
开发者ID:geoffkizer,项目名称:corefx,代码行数:11,代码来源:TransactionScopeTest.cs

示例4: Editar

        public void Editar(Partido item)
        {
            if (Eleicao.Iniciou)
            {
                throw new Exception("As eleições iniciaram não é possivel fazer essa operação");
            }

            List<Partido> partidoEncontrado = FindByName(item.Nome);
            if (partidoEncontrado.FindAll(partido => partido.Nome == item.Nome).Count != 0
                && partidoEncontrado.FindAll(partido => partido.Slogan == item.Slogan).Count != 0)
            {
                throw new Exception("Nome e slogan ja existentes.");
            }

            using (TransactionScope transacao = new TransactionScope())
            using (IDbConnection connection = new SqlConnection(connectionString))
            {
                IDbCommand comando = connection.CreateCommand();
                comando.CommandText =
                    "UPDATE Partido SET Nome = @paramNome, Slogan = @paramSlogan, Sigla = @paramSigla WHERE IDPartido = @paramIDPartido";
                comando.AddParameter("paramNome", item.Nome);
                comando.AddParameter("paramSlogan", item.Slogan);
                comando.AddParameter("paramSigla", item.Sigla);
                comando.AddParameter("paramIDPartido", item.Id);
                connection.Open();

                comando.ExecuteNonQuery();

                transacao.Complete();
                connection.Close();
            }
        }
开发者ID:ericgottschalk,项目名称:Urna,代码行数:32,代码来源:PartidoRepositorio.cs

示例5: AddChooseCourse

        /// <summary>
        /// 添加选课
        /// </summary>
        /// <param name="studentNo">学号</param>
        /// <param name="courseNo">课程编号</param>
        public void AddChooseCourse(string studentNo, string courseNo, string termTag, string ClassID)
        {
            try
            {
                string sql = "INSERT INTO [USTA].[dbo].[usta_CoursesStudentsCorrelation] ([studentNo],[courseNo],[Year],[ClassID]) VALUES(@studentNo ,@courseNo,@Year,@ClassID)";
                SqlParameter[] parameters = {
                new SqlParameter("@courseNo", SqlDbType.NChar,20),
                new SqlParameter("@studentNo", SqlDbType.NChar,10),
                new SqlParameter("@Year", SqlDbType.NVarChar,50),
                new SqlParameter("@ClassID", SqlDbType.NVarChar,50)

            };
                parameters[0].Value = courseNo;
                parameters[1].Value = studentNo;
                parameters[2].Value = termTag;
                parameters[3].Value = ClassID;
                using (TransactionScope scope = new TransactionScope())
                {
                    SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters);
                    UpdateSchoolWordAndExperiment(studentNo, courseNo);
                    scope.Complete();
                }

            }
            catch (Exception ex)
            {
               MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
开发者ID:skyaspnet,项目名称:usta,代码行数:39,代码来源:DalOperationAboutStudent.cs

示例6: AddProjectUserDiscipline

        public SigmaResultType AddProjectUserDiscipline(TypeProjectUserDiscipline objProjectUserDiscipline)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            objProjectUserDiscipline.ProjectId = userinfo.CurrentProjectId;

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();

            // Get connection string
            string connStr = ConnStrHelper.getDbConnString();

            List<SqlParameter> paramList = new List<SqlParameter>();
            paramList.Add(new SqlParameter("@ProjectId", objProjectUserDiscipline.ProjectId));
            paramList.Add(new SqlParameter("@SigmaUserId", objProjectUserDiscipline.SigmaUserId));
            paramList.Add(new SqlParameter("@DisciplineCode", objProjectUserDiscipline.DisciplineCode));
            SqlParameter outParam = new SqlParameter("@NewId", SqlDbType.Int);
            outParam.Direction = ParameterDirection.Output;
            paramList.Add(outParam);

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                result.AffectedRow = SqlHelper.ExecuteNonQuery(connStr, CommandType.StoredProcedure, "usp_AddProjectUserDiscipline", paramList.ToArray());
                result.IsSuccessful = true;
                scope.Complete();

            }

            return result;
        }
开发者ID:paraneye,项目名称:WebService,代码行数:29,代码来源:MemberMgr.cs

示例7: AddTariffProperty

        public static Boolean AddTariffProperty(List<DAL.TariffInProperty> tariff)
        {
            Boolean flag = false;
               using (TransactionScope scope = new TransactionScope())
               {
               using (var context = new SycousCon())
               {
                   try
                   {
                       foreach (DAL.TariffInProperty item in tariff)
                       {
                           context.TariffInProperties.AddObject(item);

                       }
                       context.SaveChanges();
                       context.AcceptAllChanges();
                       scope.Complete();
                       flag = true;
                   }
                   catch (Exception ex)
                   {
                       context.Dispose();
                       throw;
                   }
               }// using
               return flag;
               }// trans
        }
开发者ID:arnabknd4,项目名称:scs0400915,代码行数:28,代码来源:DALProperty.cs

示例8: DeleteData

        public int DeleteData(IEntityBase value)
        {
            EConfigHoraSet objE = (EConfigHoraSet)value;

             try
             {

            using (TransactionScope tx = new TransactionScope())
            {

               this.DeleteDetail(objE.ColConfigHora, false);
               //this.DeleteMaster(objE.EConfigHora);

               tx.Complete();

            }

            return 1;

             }
             catch (Exception ex)
             {

            throw ex;

             }
        }
开发者ID:ArquitecturaSoftware,项目名称:texfinadev,代码行数:27,代码来源:ConfigHora.cs

示例9: AddCustomFieldWithEquipmentCustomField

        public SigmaResultType AddCustomFieldWithEquipmentCustomField(TypeCustomField objCustomField)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();

            TransactionScope scope = null;
            SigmaResultType result = new SigmaResultType();
            SigmaResultType customField = new SigmaResultType();
            SigmaResultType EquipmentCustomField = new SigmaResultType();
            TypeEquipmentCustomField typeEquipmentCustomField = new TypeEquipmentCustomField();

            typeEquipmentCustomField.EquipmentId = objCustomField.Parentid;
            typeEquipmentCustomField.Value = objCustomField.Value;
            typeEquipmentCustomField.CreatedBy = userinfo.SigmaUserId;
            typeEquipmentCustomField.UpdatedBy = userinfo.SigmaUserId;

            using (scope = new TransactionScope(TransactionScopeOption.Required))
            {
                CustomFieldMgr custom = new CustomFieldMgr();

                customField = custom.AddCustomField(objCustomField);
                typeEquipmentCustomField.CustomFieldId = customField.ScalarValue;
                EquipmentCustomField = AddEquipmentCustomField(typeEquipmentCustomField);

                scope.Complete();
            }

            return result;
        }
开发者ID:paraneye,项目名称:WebService,代码行数:28,代码来源:EquipmentMgr.cs

示例10: InsertAssignDetail

        public void InsertAssignDetail(KcbChidinhcl objKcbChidinhcls, KcbLuotkham objLuotkham, KcbChidinhclsChitiet[] assignDetail)
        {
            using (var scope = new TransactionScope())
             {
                 if (objLuotkham == null) return;
                 foreach (KcbChidinhclsChitiet objAssignDetail in assignDetail)
                 {
                     log.Info("Them moi thong tin cua phieu chi dinh chi tiet voi ma phieu Assign_ID=" +
                              objKcbChidinhcls.IdChidinh);
                     TinhCLS.TinhGiaChiDinhCLS(objLuotkham, objAssignDetail);
                     objAssignDetail.IdDoituongKcb = Utility.Int16Dbnull(objLuotkham.IdDoituongKcb);
                     objAssignDetail.IdChidinh = Utility.Int32Dbnull(objKcbChidinhcls.IdChidinh);
                     objAssignDetail.IdKham = Utility.Int32Dbnull(objKcbChidinhcls.IdKham, -1);
                     decimal PtramBHYT = Utility.DecimaltoDbnull(objLuotkham.PtramBhyt, 0);
                     TinhCLS.GB_TinhPhtramBHYT(objAssignDetail, objLuotkham, PtramBHYT);
                     objAssignDetail.MaLuotkham = objKcbChidinhcls.MaLuotkham;
                     objAssignDetail.IdBenhnhan = objKcbChidinhcls.IdBenhnhan;
                     if (Utility.Int32Dbnull(objAssignDetail.SoLuong) <= 0) objAssignDetail.SoLuong = 1;
                     if (objAssignDetail.IdChitietchidinh <= 0)
                     {

                         objAssignDetail.IsNew = true;
                         objAssignDetail.Save();
                     }
                     else
                     {
                         objAssignDetail.MarkOld();
                         objAssignDetail.IsNew = false;
                         objAssignDetail.Save();
                     }
                 }
                 scope.Complete();
             }
        }
开发者ID:khaha2210,项目名称:CodeNewHis,代码行数:34,代码来源:KCB_CHIDINH_CANLAMSANG.cs

示例11: InitialiseDatabase

		public void InitialiseDatabase(Result result)
		{
			if (!result.Succeeded)
				return;

			SqlConnection conn = null;
			try
			{
				using (TransactionScope scope = new TransactionScope())
				{
					conn = (SqlConnection)DatabaseManager.DatabaseEngine.GetConnection();
					SqlServer2005Database db = (SqlServer2005Database)DatabaseManager.DatabaseEngine;
					Result r = db.ExecuteScript(conn, ResourceLoader.LoadTextResource("Sprocket.Web.FileManager.SqlServer2005.scripts.sql"));
					if (!r.Succeeded)
					{
						result.SetFailed(r.Message);
						return;
					}
					scope.Complete();
				}
			}
			finally
			{
				DatabaseManager.DatabaseEngine.ReleaseConnection(conn);
			}
			return;
		}
开发者ID:Erls-Corporation,项目名称:Sprocket.0.4-binaries-source,代码行数:27,代码来源:SqlServer2005FileManagerDataLayer.cs

示例12: DeleteData

        public int DeleteData(IEntityBase value)
        {
            EProcPlani objE = (EProcPlani)value;

             try
             {

            using (TransactionScope tx = new TransactionScope())
            {

               //this.DeleteDetail(objE.EProcPlani, false);
               this.DeleteMaster(objE);

               tx.Complete();

            }

            return 1;

             }
             catch
             {
            return 0;
             }
        }
开发者ID:ArquitecturaSoftware,项目名称:texfinadev,代码行数:25,代码来源:ProcPlani.cs

示例13: Button2_Command

    //删除区间
    protected void Button2_Command(object sender, CommandEventArgs e)
    {
        int regionId = Convert.ToInt32(e.CommandArgument);

        bool success = false;
        using (TransactionScope ts = new TransactionScope())
        {
            DataTable lists = item_bll.GetItemListByRegionId(userId, regionId);
            foreach (DataRow dr in lists.Rows)
            {
                int itemId = Convert.ToInt32(dr["ItemID"]);
                int itemAppId = Convert.ToInt32(dr["ItemAppID"]);

                success = item_bll.DeleteItem(userId, itemId, itemAppId);
                if (!success)
                {
                    break;
                }
            }

            ts.Complete();
        }

        if (success)
        {
            Utility.Alert(this, "删除成功。", "QuJianTongJi.aspx");
        }
        else
        {
            Utility.Alert(this, "删除失败!");
        }
    }
开发者ID:pyfxl,项目名称:fxlweb,代码行数:33,代码来源:QuJianTongJi.aspx.cs

示例14: Save

		/// <summary>
		/// データ登録
		/// </summary>
		/// <param name="query">SQL文字列</param>
		/// <param name="args">パラメータ</param>
		/// <returns>True:正常終了 / False:エラー</returns>
		public static int Save(string query, params SQLiteParameter[] args)
		{
			using (var connector = new SqliteConnector())
			using (var command = new SQLiteCommand(query, connector.Connection))
			{
				SqliteCommander.SetParameters(command, args);

				connector.Open();
                
                int result = 0;

                using (var tran = new TransactionScope())
                {
                    result = command.ExecuteNonQuery();

                    if (0 < result)
                    {
                        tran.Complete();
                    }
                }

				connector.Close();

				return result;
			}
		}
开发者ID:KentaYamada,项目名称:KntLibrary.SQLiteDAO,代码行数:32,代码来源:SqliteCommander.cs

示例15: CreateEnergy

        public static Boolean CreateEnergy(Energy energy)
        {
            Boolean flag = false;
              if (!(IsExistingEnergy(energy)))
              {
              using (TransactionScope scope = new TransactionScope())
              {
                  using (var context = new SycousCon())
                  {
                      try
                      {
                          context.Energies.AddObject(energy);
                          context.SaveChanges();
                          scope.Complete();
                          context.AcceptAllChanges();
                          flag = true;
                      }
                      catch (Exception ex)
                      {
                          context.Dispose();
                          throw;
                      }
                  }//
              }// using
              }//if

              return flag;
        }
开发者ID:arnabknd4,项目名称:scs0400915,代码行数:28,代码来源:DALEnergy.cs


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