Example #1
1
        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;
        }
Example #2
1
        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;
        }
Example #3
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.04.30
        /// 描述:创建消息
        /// </summary>
        /// <param name="model"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool CreateMessage(MessageModel model, int loginUserId)
        {
            try
            {
                using (var tran = new TransactionScope())
                {
                    using (var edb = new EmeEntities())
                    {
                        var msg = new Message()
                        {
                            MessageType = model.MessageType,
                            Subject = model.Subject,
                            MContent = model.MContent,
                            Receivers = model.Receiver.Count,
                            Openers = 0,
                            Status = ConvertEnum.StatusTypeForActive,
                            CreateBy = model.CreateBy,
                            CreateTime = model.CreateTime
                        };

                        edb.Entry(msg).State = EntityState.Added;
                        edb.SaveChanges();

                        var receiver = from a in model.Receiver
                                       select new MessageReceiver()
                                           {
                                               MessageId = msg.Id,
                                               Receiver = a,
                                               IsRead = false,
                                               Status = ConvertEnum.StatusTypeForActive,
                                               CreateBy = model.CreateBy,
                                               CreateTime = model.CreateTime
                                           };
                        foreach (var messageReceiver in receiver)
                        {
                            edb.Entry(messageReceiver).State = EntityState.Added;
                        }

                        var result = edb.SaveChanges() > 0;

                        tran.Complete();
                        return result;
                    }
                }
            }
            catch (Exception e)
            {
                // 异常日志消息队列
                Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                {
                    ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                    Message = string.Format("EmeBLL-CreateMessage:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                    IsTreat = false,
                    CreateBy = loginUserId,
                    CreateTime = DateTime.Now
                });

                return false;
            }
        }
Example #4
0
        /// <summary>
        /// 创建报表文件格式
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="list"></param>
        /// <returns></returns>
        public int Create(ReportsEntity entity,List<ReportParamsEntity> list)
        {
            if (!entity.ReportNum.IsEmpty())
            {
                return Update(entity,list);
            }
            int line = 0;
            using (TransactionScope ts = new TransactionScope())
            {
                entity.ReportNum = entity.ReportNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReportsEntity)) : entity.ReportNum;
                entity.IncludeAll();
                line += this.Reports.Add(entity);

                if (!list.IsNullOrEmpty())
                {
                    foreach (ReportParamsEntity item in list)
                    {
                        item.ParamNum = item.ParamNum.IsEmpty() ? SequenceProvider.GetSequence(typeof(ReportParamsEntity)) : item.ParamNum;
                        item.ReportNum = entity.ReportNum;
                        item.IncludeAll();
                    }
                    this.ReportParams.Add(list);
                }
                ts.Complete();
            }

            return line;
        }
        public string[] UpdateData(IEntityBase value)
        {
            EConfigHoraSet objE = (EConfigHoraSet)value;
             object[] objRet = null;

             try
             {

            using (TransactionScope tx = new TransactionScope())
            {

               this.DeleteDetail(objE.ColConfigHora, true);

               //objRet = this.UpdateMaster(objE.EConfigHora);

               this.UpdateDetail(objE.ColConfigHora, objRet);

               tx.Complete();

            }

            if (objRet == null)
               return null;

            return new String[] { objRet[0].ToString() };

             }
             catch (Exception ex)
             {

            throw ex;

             }
        }
Example #6
0
	public void Bug()
	{
		string connectionString = cfg.GetProperty("connection.connection_string");
		int id = -1;
		
		using (TransactionScope ts = new TransactionScope())
		{
			// Enlisting DummyEnlistment as a durable resource manager will start
			// a DTC transaction
			System.Transactions.Transaction.Current.EnlistDurable(
				DummyEnlistment.Id,
				new DummyEnlistment(),
				EnlistmentOptions.None);
			
			using (IDbConnection connection = new SqlConnection(connectionString))
			{
				connection.Open();
				using (ISession s = Sfi.OpenSession(connection))
				{
					id = (int)s.Save(new MyTable() { String = "hello!" });
				}
				connection.Close();
			}
			
			// Prior to the patch, an InvalidOperationException exception would occur in the
			// TransactionCompleted delegate at this point with the message, "Disconnect cannot
			// be called while a transaction is in progress". Although the exception can be
			// seen reported in the IDE, NUnit fails to see it, and the test passes. The
			// TransactionCompleted event fires *after* the transaction is committed and so
			// it doesn't affect the success of the transaction
			ts.Complete();
		}
	}
Example #7
0
        public void Abandon(int masterSysNo, int userSysNo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {

                //�����dz�ʼ״̬
                POInfo dbInfo = LoadPO(masterSysNo);
                if ( dbInfo == null )
                    throw new BizException("does not exist this po sysno");
                if ( dbInfo.Status != (int)AppEnum.POStatus.Origin )
                    throw new BizException("status is not origin now, abandon failed");

                //���� ���š�״̬�������
                Hashtable ht = new Hashtable(4);

                ht.Add("SysNo", masterSysNo);
                ht.Add("Status", (int)AppEnum.POStatus.Abandon);
                if ( 1!=new PODac().UpdateMaster(ht))
                    throw new BizException("expected one-row update failed, verify failed ");

                ProductIDManager.GetInstance().AbandonProductIDsByPO(masterSysNo);

                scope.Complete();
            }
        }
Example #8
0
        public void UpdateClient(Client client)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Db.ExecuteNonQuery("usp_Client_UpdateClient", CommandType.StoredProcedure,
                    new DbParameter[] {
                               Db.CreateParameter("ClientId", client.ClientId),
                               Db.CreateParameter("ClientName", client.ClientName),
                               Db.CreateParameter("ContactName", client.ContactName),
                               Db.CreateParameter("Phone", client.Phone),
                               Db.CreateParameter("Email", client.Email),
                               Db.CreateParameter("TIN", client.TIN),
                               Db.CreateParameter("PrivateClientDetails", client.PrivateClientDetails),
                               Db.CreateParameter("OtherClientDetails", client.OtherClientDetails),
                               Db.CreateParameter("BillingAddress", client.BillingAddress),
                               Db.CreateParameter("City", client.City),
                               Db.CreateParameter("StateCode", client.StateCode),
                               Db.CreateParameter("Zip", client.Zip),
                               Db.CreateParameter("Country", client.Country),
                               Db.CreateParameter("ShipToDifferentAddress", client.ShipToDifferentAddress),
                               Db.CreateParameter("ShippingAddress", client.ShippingAddress),
                               Db.CreateParameter("ShippingCity", client.ShippingCity),
                               Db.CreateParameter("ShippingStateCode", client.ShippingStateCode),
                               Db.CreateParameter("ShippingZip", client.ShippingZip),
                               Db.CreateParameter("ShippingCountry", client.ShippingCountry)

                 });
                scope.Complete();
            }
        }
Example #9
0
        public static ActionResult Capnhatgia(long id, decimal don_gia, byte cachtinh_gia)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {

                        new Update(NoitruPhanbuonggiuong.Schema)
                                             .Set(NoitruPhanbuonggiuong.Columns.DonGia).EqualTo(don_gia)
                                             .Set(NoitruPhanbuonggiuong.Columns.CachtinhGia).EqualTo(cachtinh_gia)
                                             .Where(NoitruPhanbuonggiuong.Columns.Id).IsEqualTo(id).Execute();
                    }
                    scope.Complete();
                    return ActionResult.Success;

                }
            }
            catch (Exception exception)
            {
                Utility.CatchException(exception);
                return ActionResult.Error;
            }
        }
Example #10
0
        public static Boolean DeletedDirectDebit(DirectDebit debit)
        {
            using (TransactionScope scope = new TransactionScope())
            {
                Boolean bol = false;
                using (var context = new SycousCon())
                {
                    try
                    {
                        var Update = context.DirectDebits.Where(c => c.ID == debit.ID&& c.IsDeleted==0&&c.IsApproved==0);

                        foreach (DirectDebit p in Update)
                        {
                            p.IsDeleted = 2;
                            p.ModifyBy = debit.ModifyBy;
                            p.ModifyDate = DateTime.Now;

                        }//
                        context.SaveChanges();
                        context.AcceptAllChanges();
                        scope.Complete();
                        context.Dispose();
                        bol = true;
                    }
                    catch (Exception ex)
                    {
                        context.Dispose();
                        throw;
                    }

                }// using
                return bol;
            } //trans
        }
Example #11
0
        public static Boolean CreateDirectDebit(DirectDebit mdirectdebit)
        {
            Boolean flag = false;

                using (TransactionScope scope = new TransactionScope())
                {
                    using (var context = new SycousCon())
                    {
                        try
                        {
                            context.DirectDebits.AddObject(mdirectdebit);
                            context.SaveChanges();
                            scope.Complete();
                            context.AcceptAllChanges();
                            flag = true;
                        }
                        catch (Exception ex)
                        {
                            context.Dispose();
                            throw;
                        }
                    }
                }

            return flag;
        }
        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;
             }
        }
		/// <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;
			}
		}
Example #14
0
        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;
        }
Example #15
0
        public SigmaResultType AddSigmaUserSigmaRole(TypeSigmaUserSigmaRole objSigmaUserSigmaRole)
        {
            TypeUserInfo userinfo = AuthMgr.GetUserInfo();
            objSigmaUserSigmaRole.CreatedBy = userinfo.SigmaUserId;
            //objSigmaUserSigmaRole.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("@SigmaRoleId", objSigmaUserSigmaRole.SigmaRoleId));
            paramList.Add(new SqlParameter("@SigmaUserId", objSigmaUserSigmaRole.SigmaUserId));
            paramList.Add(new SqlParameter("@ReportTo", objSigmaUserSigmaRole.ReportTo));
            paramList.Add(new SqlParameter("@ReportToRole", objSigmaUserSigmaRole.ReportToRole));
            paramList.Add(new SqlParameter("@IsDefault", objSigmaUserSigmaRole.IsDefault));
            paramList.Add(new SqlParameter("@ProjectId", objSigmaUserSigmaRole.ProjectId));
            paramList.Add(new SqlParameter("@CreatedBy", objSigmaUserSigmaRole.CreatedBy));

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

                scope.Complete();
            }

            return result;
        }
Example #16
0
    //删除区间
    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, "删除失败!");
        }
    }
Example #17
0
 public int AddClient(Client client)
 {
     using (TransactionScope scope = new TransactionScope())
     {
         DbParameter parameter = null;
         parameter = Db.CreateParameter("ClientId", DbType.Int32, 8);
         parameter.Direction = ParameterDirection.Output;
         Db.ExecuteNonQuery("usp_Client_InsertClientDetails", CommandType.StoredProcedure,
             new DbParameter[] {
                        parameter,
                        Db.CreateParameter("ClientName", client.ClientName),
                        Db.CreateParameter("ContactName", client.ContactName),
                        Db.CreateParameter("Phone", client.Phone),
                        Db.CreateParameter("Email", client.Email),
                        Db.CreateParameter("TIN", client.TIN),
                        Db.CreateParameter("PrivateClientDetails", client.PrivateClientDetails),
                        Db.CreateParameter("OtherClientDetails", client.OtherClientDetails),
                        Db.CreateParameter("BillingAddress", client.BillingAddress),
                        Db.CreateParameter("City", client.City),
                        Db.CreateParameter("StateCode", client.StateCode),
                        Db.CreateParameter("Zip", client.Zip),
                        Db.CreateParameter("Country", client.Country),
                        Db.CreateParameter("ShipToDifferentAddress", client.ShipToDifferentAddress),
                        Db.CreateParameter("ShippingAddress", client.ShippingAddress),
                        Db.CreateParameter("ShippingCity", client.ShippingCity),
                        Db.CreateParameter("ShippingStateCode", client.ShippingStateCode),
                        Db.CreateParameter("ShippingZip", client.ShippingZip),
                        Db.CreateParameter("ShippingCountry", client.ShippingCountry),
                        Db.CreateParameter("Status", client.Status)
          });
         scope.Complete();
         return (int)parameter.Value;
     }
 }
Example #18
0
        public static ActionResult CapnhatSoluong(long id, int soluongngay,byte cachtinhsoluong)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sh = new SharedDbConnectionScope())
                    {

                      new Update(NoitruPhanbuonggiuong.Schema)
                                             .Set(NoitruPhanbuonggiuong.Columns.SoLuong).EqualTo(soluongngay)
                                             .Set(NoitruPhanbuonggiuong.Columns.CachtinhSoluong).EqualTo(cachtinhsoluong)
                                             .Where(NoitruPhanbuonggiuong.Columns.Id).IsEqualTo(id).Execute();
                    }
                    scope.Complete();
                    return ActionResult.Success;

                }
            }
            catch (Exception exception)
            {
                Utility.CatchException(exception);
                return ActionResult.Error;
            }
        }
        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();
             }
        }
Example #20
0
        public ActionResult UpdateDynamicValues(List<DynamicValue> lstValues)
        {
            try
            {
                using (var scope = new TransactionScope())
                {
                    using (var sp = new SharedDbConnectionScope())
                    {
                        foreach (DynamicValue _object in lstValues)
                        {
                            if (_object.Id > 0)
                            {
                                _object.MarkOld();
                                _object.IsNew = false;
                                _object.Save();
                            }
                            else//Insert
                            {
                                _object.IsNew = true;

                                _object.Save();
                            }
                        }
                    }
                    scope.Complete();
                    return ActionResult.Success;
                }
            }
            catch (Exception exception)
            {
                Utility.ShowMsg(exception.Message);
                return ActionResult.Error;
            }
        }
		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;
		}
Example #22
0
        public ActionResult Disassociate(string provider, string providerUserId)
        {
            string ownerAccount = OAuthWebSecurity.GetUserName(provider, providerUserId);
            ManageMessageId? message = null;

            // Only disassociate the account if the currently logged in user is the owner
            if (ownerAccount == User.Identity.Name)
            {
                // Use a transaction to prevent the user from deleting their last login credential
                using (
                    var scope = new TransactionScope(TransactionScopeOption.Required,
                        new TransactionOptions { IsolationLevel = IsolationLevel.Serializable }))
                {
                    bool hasLocalAccount = OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name));
                    if (hasLocalAccount || OAuthWebSecurity.GetAccountsFromUserName(User.Identity.Name).Count > 1)
                    {
                        OAuthWebSecurity.DeleteAccount(provider, providerUserId);
                        scope.Complete();
                        message = ManageMessageId.RemoveLoginSuccess;
                    }
                }
            }

            return RedirectToAction("Manage", new { Message = message });
        }
        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;

             }
        }
Example #24
0
        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();
            }
        }
Example #25
0
        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;
        }
Example #26
0
        public ActionResult Index()
        {
            var outParam = new SqlParameter
            {
                ParameterName = "@result",
                Direction = ParameterDirection.Output,
                SqlDbType = SqlDbType.Int
            };

            List<Boolean> _BUEvent = db.Database.SqlQuery<Boolean>("sp_InsertIntoBuEventLog @result OUT", outParam).ToList();

            using (TransactionScope transaction = new TransactionScope())
            {

                bool result = _BUEvent.FirstOrDefault();
                if (result)
                {
                    var _vwSendEmail = (db.vwSendEmails.Where(a => a.CREATEDDATE == CurrentDate).Select(a => new { a.KDKC, a.email, a.NMKC,a.TAHUN,a.BULAN,a.MINGGU })).Distinct();
                    int count = 0;
                    foreach(var sending in _vwSendEmail)
                    {
                        MemoryStream memory = new MemoryStream();
                        PdfDocument document = new PdfDocument() { Url = string.Format("http://localhost:1815/AutoMail/PreviewPage?kdkc={0}", sending.KDKC) };
                        PdfOutput output = new PdfOutput() { OutputStream = memory };

                        PdfConvert.ConvertHtmlToPdf(document, output);
                        memory.Position = 0;
                        var SubjectName = string.Format("Reminder Masa Habis PKS Badan Usaha T{0} B{1} M{2}", sending.TAHUN, sending.BULAN, sending.MINGGU);
                        var attchName = string.Format("ReminderMasaHabisPKSBadanUsahaT{0}B{1}M{2}", sending.TAHUN, sending.BULAN, sending.MINGGU);
                        ContentType ct = new ContentType(MediaTypeNames.Application.Pdf);
                        Attachment data = new Attachment(memory, ct);
                        data.Name = attchName;
                        MailMessage message = new MailMessage();
                        message.To.Add(new MailAddress(sending.email));
                        message.From = new MailAddress("irfan.kacrut@gmail.com", "Legal-InHealth Reminder ");
                        message.Subject = SubjectName;
                        message.Attachments.Add(data);
                        message.Body = sending.NMKC;
                        SmtpClient client = new SmtpClient();

                        try
                        {
                            client.Send(message);
                        }
                        catch (Exception ex)
                        {

                            ViewData["SendingException"] = string.Format("Exception caught in SendErrorLog: {0}",ex.ToString());
                            return View("ErrorSending", ViewData["SendingException"]);
                        }
                        data.Dispose();
                        // Close the log file.
                        memory.Close();
                        count += 1;
                    }
                }
                transaction.Complete();
            }
            return View();
        }
        /// <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();
            }
        }
        public void Init()
        {
            _trans = new TransactionScope();
            // make connection
            db = new ApplicationDbContext();

            //make controller
            controller = new ReviewController { DbContext = db };

            // seed the database if empty
            if (db.Members.Count() == 0)
            {
                new Migrations.Configuration().SeedDebug(db);
                Console.WriteLine("Seeded DB");
            }
            else
            {
                Console.WriteLine("DB Already seeded");
            }

            Review validTestReview = new Review();
            Game game = db.Games.FirstOrDefault();
            Member member = db.Members.FirstOrDefault();
            validTestReview.Game_Id = game.Id;
            validTestReview.Game = game;
            validTestReview.Author = member;
            validTestReview.Rating = 3;
            validTestReview.Body = "Great Game!";
            validTestReview.Subject = "Review Title";
            validTestReview.IsApproved = false;
            validTestReview.Aprover_Id = null;

            db.Reviews.Add(validTestReview);
            db.SaveChanges();
        }
Example #29
0
        /// <summary>
        /// Starts a new Amnesia session with a remote application
        /// </summary>
        public Session(string appUrl, ILog log)
        {
            this.log = log ?? NullLog.Instance;

            this.serviceUrl = appUrl + Amnesia.Settings.Current.HandlerPath;

            // Start a new distributed transaction
            TxScope = new TransactionScope(TransactionScopeOption.Required, TransactionTimeout);
            var request = new Handler.StartSessionRequest();
            Transaction tx = Transaction.Current;
            request.Transaction = tx;

            var response = request.Send(serviceUrl);
            LogResponse(response);

            response.ReceivedByClient();

            // Monitor the distributed transaction in order to detect if its aborted remotely.
            tx.EnlistVolatile(new AbortNotification((o, e) =>
            {
                if (isDisposed)
                    return;

                if (request.Transaction.TransactionInformation.Status == TransactionStatus.Aborted)
                {
                    Session.IsRollbackPending = true;
                }
            }),
            EnlistmentOptions.None);
        }
Example #30
0
        /// <summary>
        /// ����rma��
        /// </summary>
        /// <param name="rmaInfo"></param>
        public void AddRMA(RMAInfo rmaInfo)
        {
            TransactionOptions options = new TransactionOptions();
            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                if(!this.IfExistOpenedRMA(rmaInfo.SOSysNo))
                {
                    Hashtable leftHash = this.GetLeftRMAQty(rmaInfo.SOSysNo);
                    foreach(RMAItemInfo item in rmaInfo.ItemHash.Values)
                    {
                        if(item.RMAQty>(int)leftHash[item.ProductSysNo])
                            throw new BizException("����д�ı�����Ʒ�����������۵���ʵ�ʹ�����������ȷ���豣�޵���Ʒ��Ϊ�˵�����");
                    }
                    rmaInfo.SysNo = SequenceDac.GetInstance().Create("RMA_Sequence");
                    rmaInfo.RMAID = this.BuildRMAID(rmaInfo.SysNo);
                    rmaInfo.SubmitInfo = this.GetRMASnapShot(rmaInfo);
                    rmaInfo.Status = (int)AppEnum.RMAStatus.Origin;
                    this.InsertMaster(rmaInfo);
                    foreach(RMAItemInfo rmaItem in rmaInfo.ItemHash.Values)
                    {
                        rmaItem.RMASysNo = rmaInfo.SysNo;
                        this.InsertItem(rmaItem);
                    }
                }
                else
                    throw new BizException("�����۵��Ѿ�����һ�ű��޵��ڴ����У�������������ύ�µı������룬����ϵORS�̳ǿͷ�");
                scope.Complete();
            }
        }