/// <summary>
        /// Automatically called by IIS on every request
        /// </summary>
        /// <param name="context">An <see cref="T:System.Web.HttpApplication" /> that provides access to the methods, properties, and events common to all application objects within an ASP.NET application</param>
        /// <exception cref="System.ArgumentNullException">the HTTP context</exception>
        public void Init(HttpApplication context)
        {
            if (context == null) throw new ArgumentNullException("context");

            exceptionManager = new ExceptionPolicyFactory().CreateManager();
            context.EndRequest += this.OnError;
        }
        public void TestInitialize()
        {
            this.container = new UnityContainer();
            ContainerBootstrapper.Configure(container);

            this.ldapStore = container.Resolve<IProfileStore>();
            this.exceptionMgr = container.Resolve<ExceptionManager>();
        }
Exemplo n.º 3
0
        public UserRepository(IProfileStore profileStore, ExceptionManager exManager, IUnityContainer container)
        {
            this.profileStore = profileStore;
            this.exManager = exManager;
            this.container = container;

            AExpenseEvents.Log.UserRepositoryInitialized(Membership.ApplicationName);
        }
        public void TestInitialize()
        {
            obsListener = new ObservableEventListener();
            obsListener.EnableEvents(AExpenseEvents.Log, EventLevel.LogAlways, Keywords.All);

            DatabaseHelper.CleanLoggingDB(TracingDatabaseConnectionString);

            this.container = new UnityContainer();
            ContainerBootstrapper.Configure(container);

            this.ldapStore = container.Resolve<IProfileStore>();
            this.exceptionMgr = container.Resolve<ExceptionManager>();

        }
Exemplo n.º 5
0
        internal static ExceptionManager BuildExceptionManagerConfig(LogWriter logWriter, DocumentModel doc)
        {
            var loggingAndReplacing = new List<ExceptionPolicyEntry>
            {
                new ExceptionPolicyEntry(typeof (Exception),
                    PostHandlingAction.ThrowNewException,
                    new IExceptionHandler[]
                     {
                       new MyLoggingExceptionHandler("Error", 9000, TraceEventType.Error,
                         "Simulation Exception", 5, typeof(TextExceptionFormatter), logWriter, doc),
                       new ReplaceHandler(ErrorMsg,
                         typeof(Exception))
                     })
            };

            var policies = new List<ExceptionPolicyDefinition>();
            policies.Add(new ExceptionPolicyDefinition("LoggingAndReplacingException", loggingAndReplacing));
            ExceptionManager exManager = new ExceptionManager(policies);
            return exManager;
        }
Exemplo n.º 6
0
    private void ConfigureExceptionHandlingBlock()
    {
      var policies = new List<ExceptionPolicyDefinition>();

      var mappings = new NameValueCollection();
      mappings.Add("FaultID", "{Guid}");
      mappings.Add("FaultMessage", "{Message}");

      var salaryServicePolicy = new List<ExceptionPolicyEntry>
            {
                new ExceptionPolicyEntry(typeof(Exception),
                    PostHandlingAction.ThrowNewException,
                    new IExceptionHandler[]
                    {
                        new FaultContractExceptionHandler(typeof(SalaryCalculationFault), "Service Error. Please contact your administrator", mappings)
                    })
            };
      policies.Add(new ExceptionPolicyDefinition("SalaryServicePolicy", salaryServicePolicy));
      ExceptionManager exManager = new ExceptionManager(policies);
      ExceptionPolicy.SetExceptionManager(exManager);
    }
Exemplo n.º 7
0
    static void Main(string[] args)
    {
      #region Create the required objects

      LoggingConfiguration loggingConfiguration = BuildLoggingConfig();
      LogWriter logWriter = new LogWriter(loggingConfiguration);
      //Logger.SetLogWriter(logWriter, false);

      // Create the default ExceptionManager object from the configuration settings.
      //ExceptionPolicyFactory policyFactory = new ExceptionPolicyFactory();
      //exManager = policyFactory.CreateManager();

      // Create the default ExceptionManager object programatically
      exManager = BuildExceptionManagerConfig(logWriter);

      // Create an ExceptionPolicy to illustrate the static HandleException method
      ExceptionPolicy.SetExceptionManager(exManager);


      #endregion

      #region Main menu routines

      var app = new MenuDrivenApplication("Exception Handling Block Developer's Guide Examples",
          DefaultNoExceptionShielding,
          WithWrapExceptionShielding,
          WithWrapExceptionShieldingStatic,
          WithReplaceExceptionShielding,
          LoggingTheException,
          ShieldingExceptionsInWCF,
          ExecutingCodeAroundException,
          ProvidingAdminAssistance);

      app.Run();

      #endregion
    }
        public UserVo GetUser(string username)
        {
            UserVo    userVo = null;
            Database  db;
            DbCommand getUserCmd;
            DataSet   getUserDs;
            DataRow   dr;

            try
            {
                db         = DatabaseFactory.CreateDatabase("wealtherp");
                getUserCmd = db.GetStoredProcCommand("SP_GetUser");
                db.AddInParameter(getUserCmd, "@U_LoginId", DbType.String, username.ToString());
                getUserDs = db.ExecuteDataSet(getUserCmd);
                if (getUserDs.Tables[0].Rows.Count > 0)
                {
                    userVo = new UserVo();
                    dr     = getUserDs.Tables[0].Rows[0];

                    userVo.UserId     = int.Parse(dr["U_UserId"].ToString());
                    userVo.Password   = dr["U_Password"].ToString();
                    userVo.MiddleName = dr["U_MiddleName"].ToString();
                    userVo.LastName   = dr["U_LastName"].ToString();
                    userVo.FirstName  = dr["U_FirstName"].ToString();
                    userVo.Email      = dr["U_Email"].ToString();
                    userVo.UserType   = dr["U_UserType"].ToString();
                    userVo.LoginId    = dr["U_LoginId"].ToString();
                    if (dr["U_IsTempPassword"].ToString() != "")
                    {
                        userVo.IsTempPassword = int.Parse(dr["U_IsTempPassword"].ToString());
                    }
                    if (dr["U_Theme"].ToString() != "")
                    {
                        userVo.theme = dr["U_Theme"].ToString();
                    }
                }
            }



            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "UserDao.cs:GetUser()");


                object[] objects = new object[1];
                objects[0] = username;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(userVo);
        }
Exemplo n.º 9
0
        /// <summary>Gets the differences compared with anhoter item</summary>
        /// <param name="item1">Item to compare</param>
        /// <returns>String with the differences compared with anhoter item</returns>
        public string Differences(BaseItem item1)
        {
            string source     = "Differences(BaseItem)";
            var    res        = new StringBuilder();
            var    variances  = new List <Variance>();
            var    properties = this.GetType().GetProperties();

            foreach (var property in properties)
            {
                var propertyAttributes = property.GetCustomAttributes(true);

                if (propertyAttributes.Contains(new DifferenciableAttribute(true)))
                {
                    var variance = new Variance
                    {
                        PropertyName = property.Name,
                        NewValue     = property.GetValue(this, null),
                        OldValue     = property.GetValue(item1, null)
                    };

                    if (variance.NewValue == null && variance.OldValue == null)
                    {
                        continue;
                    }

                    if (variance.NewValue == null && variance.OldValue != null)
                    {
                        variances.Add(variance);
                    }
                    else if (variance.NewValue != null && variance.OldValue == null)
                    {
                        variances.Add(variance);
                    }
                    else if (variance.OldValue.GetType().FullName.StartsWith("Giso", StringComparison.Ordinal))
                    {
                        string va = variance.NewValue.GetType().GetProperty("Id").GetValue(variance.NewValue, null).ToString();
                        string vb = variance.OldValue.GetType().GetProperty("Id").GetValue(variance.OldValue, null).ToString();
                        if (va != vb)
                        {
                            variances.Add(variance);
                        }
                    }
                    else if (!variance.NewValue.Equals(variance.OldValue))
                    {
                        variances.Add(variance);
                    }
                }
            }

            bool first = true;

            foreach (var variance in variances)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    res.Append("|");
                }

                try
                {
                    if (variance.OldValue == null && variance.NewValue == null)
                    {
                        continue;
                    }

                    if (variance.OldValue == null && variance.NewValue != null)
                    {
                        string newValue = variance.NewValue.ToString();
                        res.Append(variance.PropertyName).Append("::null-->").Append(newValue);
                    }
                    else if (variance.OldValue.GetType().Name.ToUpperInvariant().Equals("string", StringComparison.OrdinalIgnoreCase))
                    {
                        if (variance.NewValue == null)
                        {
                            res.Append(variance.PropertyName).Append(@"::""""-->null");
                        }
                        else
                        {
                            res.Append(variance.PropertyName).AppendFormat(CultureInfo.InvariantCulture, @"::""""-->{0}", variance.NewValue);
                        }
                    }
                    else if (variance.NewValue == null)
                    {
                        string oldValue = variance.OldValue.GetType().GetProperty("Id").GetValue(variance.OldValue, null).ToString();
                        res.Append(variance.PropertyName).Append("::").Append(oldValue).Append("-->null");
                    }
                    else if (variance.OldValue.GetType().FullName.StartsWith("Giso", StringComparison.Ordinal))
                    {
                        string oldValue = variance.OldValue.GetType().GetProperty("Id").GetValue(variance.OldValue, null).ToString();
                        string newValue = variance.NewValue.GetType().GetProperty("Id").GetValue(variance.NewValue, null).ToString();
                        res.Append(variance.PropertyName).Append("::").Append(oldValue).Append("-->").Append(newValue);
                    }
                    else
                    {
                        res.Append(variance.PropertyName).Append("::").Append(variance.OldValue).Append("-->").Append(variance.NewValue);
                    }
                }
                catch (SqlException ex)
                {
                    ExceptionManager.Trace(ex, source);
                }
                catch (ArgumentException ex)
                {
                    ExceptionManager.Trace(ex, source);
                }
                catch (FormatException ex)
                {
                    ExceptionManager.Trace(ex, source);
                }
                catch (NullReferenceException ex)
                {
                    ExceptionManager.Trace(ex, source);
                }
                catch (NotSupportedException ex)
                {
                    ExceptionManager.Trace(ex, source);
                }
            }

            return(res.ToString());
        }
Exemplo n.º 10
0
        private void BindFolioGridView()
        {
            int Count;

            try
            {
                customerVo = (CustomerVo)Session["CustomerVo"];

                FolioList = CustomerTransactionBo.GetCustomerMFFolios(portfolioId, customerVo.CustomerId, mypager.CurrentPage, out Count);

                // lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                if (FolioList == null)
                {
                    lblMessage.Visible     = true;
                    lblCurrentPage.Visible = false;
                    lblTotalRows.Visible   = false;
                    DivPager.Visible       = false;
                    gvMFFolio.DataSource   = null;
                    gvMFFolio.DataBind();
                    btnTransferFolio.Visible = false;
                }
                else
                {
                    lblMessage.Visible     = false;
                    lblTotalRows.Visible   = true;
                    lblCurrentPage.Visible = true;
                    DivPager.Visible       = true;
                    DataTable dtMFFolio = new DataTable();

                    dtMFFolio.Columns.Add("FolioId");
                    dtMFFolio.Columns.Add("Folio No");
                    dtMFFolio.Columns.Add("AMC Name");
                    dtMFFolio.Columns.Add("Name");// original costumer name from folio uploads
                    dtMFFolio.Columns.Add("Mode Of Holding");
                    dtMFFolio.Columns.Add("A/C Opening Date");


                    DataRow drMFFolio;

                    for (int i = 0; i < FolioList.Count; i++)
                    {
                        drMFFolio    = dtMFFolio.NewRow();
                        FolioVo      = new CustomerAccountsVo();
                        FolioVo      = FolioList[i];
                        drMFFolio[0] = FolioVo.AccountId.ToString();
                        drMFFolio[1] = FolioVo.AccountNum.ToString();
                        drMFFolio[2] = FolioVo.AMCName.ToString();
                        drMFFolio[3] = FolioVo.Name.ToString();
                        drMFFolio[4] = FolioVo.ModeOfHolding.ToString();
                        if (FolioVo.AccountOpeningDate != DateTime.MinValue)
                        {
                            drMFFolio[5] = FolioVo.AccountOpeningDate.ToShortDateString();
                        }
                        else
                        {
                            drMFFolio[5] = string.Empty;
                        }
                        dtMFFolio.Rows.Add(drMFFolio);
                    }
                    gvMFFolio.DataSource = dtMFFolio;
                    gvMFFolio.DataBind();
                }



                lblTotalRows.Text = hdnRecordCount.Value = Count.ToString();
                if (Count > 0)
                {
                    DivPager.Style.Add("display", "visible");
                }
                else
                {
                    DivPager.Style.Add("display", "none");
                    lblCurrentPage.Text = "";
                    lblCurrentPage.Text = "";
                }

                this.GetPageCount();
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "CustomerMFFolioView.ascx:BindFolioGridView()");
                object[] objects = new object[2];
                objects[0]   = customerVo;
                objects[1]   = portfolioId;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        protected void btnCustomerProfile_Click(object sender, EventArgs e)
        {
            List <int> customerIds = null;

            try
            {
                if (chkdummypan.Checked)
                {
                    customerVo.DummyPAN = 1;
                }
                else
                {
                    customerVo.DummyPAN = 0;
                }
                if (Validation())
                {
                    customerIds = new List <int>();
                    if (rbtnIndividual.Checked)
                    {
                        customerVo.Type       = "IND";
                        customerVo.FirstName  = txtFirstName.Text.ToString();
                        customerVo.MiddleName = txtMiddleName.Text.ToString();
                        customerVo.LastName   = txtLastName.Text.ToString();

                        customerVo.TaxStatusCustomerSubTypeId = Int16.Parse(ddlCustomerSubType.SelectedValue.ToString());
                        // customerVo.AccountId = txtClientCode.Text.Trim();
                        customerVo.CustCode       = txtClientCode.Text.Trim();
                        customerVo.IsRealInvestor = chkRealInvestor.Checked;

                        if (ddlSalutation.SelectedIndex == 0)
                        {
                            customerVo.Salutation = "";
                        }
                        else
                        {
                            customerVo.Salutation = ddlSalutation.SelectedValue.ToString();
                        }
                        userVo.FirstName  = txtFirstName.Text.ToString();
                        userVo.MiddleName = txtMiddleName.Text.ToString();
                        userVo.LastName   = txtLastName.Text.ToString();
                    }
                    else if (rbtnNonIndividual.Checked)
                    {
                        customerVo.Type = "NIND";

                        customerVo.TaxStatusCustomerSubTypeId = Int16.Parse(ddlCustomerSubType.SelectedValue.ToString());
                        //    customerVo.AccountId = txtClientCode.Text.Trim();
                        customerVo.IsRealInvestor = chkRealInvestor.Checked;
                        customerVo.CustCode       = txtClientCode.Text.Trim();
                        customerVo.CompanyName    = txtCompanyName.Text.ToString();
                        customerVo.FirstName      = txtCompanyName.Text.ToString();
                        customerVo.LastName       = txtFirstName.Text.ToString();
                        customerVo.MiddleName     = txtMiddleName.Text.ToString();
                        //customerVo.FirstName = txtLastName.Text.ToString();
                        userVo.LastName = txtCompanyName.Text.ToString();
                    }

                    //customerVo.CustomerId = customerBo.GenerateId();
                    customerVo.BranchId = int.Parse(ddlAdviserBranchList.SelectedValue);
                    //customerVo.SubType = ddlCustomerSubType.SelectedItem.Value;
                    customerVo.Email  = txtEmail.Text.ToString();
                    customerVo.PANNum = txtPanNumber.Text.ToString();
                    userVo.Email      = txtEmail.Text.ToString();
                    userVo.UserType   = "Customer";
                    customerVo.Dob    = DateTime.MinValue;
                    if (chkdummypan.Checked)
                    {
                        customerVo.DummyPAN = 1;
                    }
                    else
                    {
                        customerVo.DummyPAN = 0;
                    }
                    if (!string.IsNullOrEmpty(txtMobileNumber.Text.ToString()))
                    {
                        customerVo.Mobile1 = Convert.ToInt64(txtMobileNumber.Text.ToString());
                    }
                    else
                    {
                        customerVo.Mobile1 = 0;
                    }
                    customerVo.ProfilingDate              = DateTime.Today;
                    customerVo.RBIApprovalDate            = DateTime.MinValue;
                    customerVo.CommencementDate           = DateTime.MinValue;
                    customerVo.RegistrationDate           = DateTime.MinValue;
                    customerVo.RmId                       = int.Parse(ddlAdviseRMList.SelectedValue.ToString());
                    customerPortfolioVo.IsMainPortfolio   = 1;
                    customerPortfolioVo.PortfolioTypeCode = "RGL";
                    customerPortfolioVo.PortfolioName     = "MyPortfolio";
                    customerIds            = customerBo.CreateCompleteCustomer(customerVo, userVo, customerPortfolioVo, tempUserVo.UserId);
                    Session["customerIds"] = customerIds;
                    if (customerIds != null)
                    {
                        CustomerFamilyVo familyVo = new CustomerFamilyVo();
                        CustomerFamilyBo familyBo = new CustomerFamilyBo();
                        familyVo.AssociateCustomerId = customerIds[1];
                        familyVo.CustomerId          = customerIds[1];
                        familyVo.Relationship        = "SELF";
                        familyBo.CreateCustomerFamily(familyVo, customerIds[1], userVo.UserId);
                    }
                    Session["CustomerVo"] = customerBo.GetCustomer(customerIds[1]);
                    if (rbtnNonIndividual.Checked)
                    {
                        // ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "leftpane", "loadcontrol('CustomerNonIndividualAdd','none');", true);
                        Response.Redirect("ControlHost.aspx?pageid=CustomerNonIndividualAdd&RmId=" + customerVo.RmId + "", false);
                    }
                    else if (rbtnIndividual.Checked)
                    {
                        //ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "leftpane", "loadcontrol('CustomerIndividualAdd','none');", true);
                        Response.Redirect("ControlHost.aspx?pageid=EditCustomerIndividualProfile&RmId=" + customerVo.RmId + "&action=" + "Edit" + "", false);
                    }
                }
                else
                {
                }
            }

            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "CustomerType.ascx:btnCustomerProfile_Click()");

                object[] objects = new object[5];
                objects[0] = customerPortfolioVo;
                objects[1] = customerVo;
                objects[2] = rmVo;
                objects[3] = userVo;
                objects[4] = customerIds;
                objects[5] = assetInterest;


                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        public async Task CreateYEnviar(LlaveQR llave, Usuario usuario)
        {
            try
            {
                UsuarioManager mngU = new UsuarioManager();
                Usuario        u    = null;
                try
                {
                    u = mngU.RetrieveAll().FindAll(FindCorreo).First <Usuario>();
                }
                catch (Exception ex)
                {
                    throw new BussinessException(12);
                }
                //validar si existe
                if (u != null)
                {
                    //validar estado del usuario
                    switch (u.ValorEstado)
                    {
                    case "3":
                        //El usuario existe pero aún no ha verificado su cuenta
                        throw new BussinessException(8);

                    case "2":
                        //El usuario existe pero su contraseña ha expirado
                        throw new BussinessException(9);

                    case "0":
                        //El usuario existe pero se encuentra inactivo
                        throw new BussinessException(9);
                    }

                    var mngRoles   = new Rol_UsuarioManager();
                    var rolUsuario = new Rol_Usuario
                    {
                        IdUsuario = u.Identificacion,
                        IdRol     = "CLT"
                    };
                    var roles = mngRoles.RetrieveAllById(rolUsuario);
                    //validar que el usuario sea un cliente

                    foreach (Rol_Usuario rol in roles)
                    {
                        if (rol.IdRol.Equals("CLT") == false)
                        {
                            throw new Exception("El usuario no es válido");
                        }
                    }


                    var QR = new LlaveQR();
                    do
                    {
                        llave.CodigoQR = RandomString(8);
                        QR             = crudLlaveQR.Retrieve <LlaveQR>(llave);
                    } while (QR != null);

                    llave.ImagenQR = getImagenQR(llave.CodigoQR);

                    crudLlaveQR.Create(llave);
                    await EnviarCorreoManager.GetInstance().ExecuteCorreoCodigoQR(u.Correo, llave);
                }
                else
                {
                    //no existe ese usuario
                    throw new BussinessException(12);
                }

                bool FindCorreo(Usuario usu)
                {
                    if (usu.Correo == usuario.Correo)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }
        }
Exemplo n.º 13
0
        protected void BindGrid(int CurrentPage)
        {
            try
            {
                Dictionary <string, string> genDictParent = new Dictionary <string, string>();
                Dictionary <string, string> genDictCity   = new Dictionary <string, string>();

                rmVo = (RMVo)Session["rmVo"];
                int count = 0;
                lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                // advisorStaffBo.GetCustomerList(rmVo.RMId, "C").ToString();
                if (customerVo.RelationShip == "SELF")
                {
                    customerList = advisorStaffBo.GetCustomerForAssociation(customerVo.CustomerId, rmVo.RMId, mypager.CurrentPage, hdnSort.Value.ToString(), out count);
                }
                else
                {
                    customerList = null;
                }
                lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                if (customerList == null)
                {
                    lblMessage.Text        = "Customer already associated, cannot make more associations";
                    mypager.Visible        = false;
                    btnAssociate.Visible   = false;
                    lblCurrentPage.Visible = false;
                    lblTotalRows.Visible   = false;
                    trRelationShip.Visible = false;
                }
                else
                {
                    trRelationShip.Visible = true;
                    lblMessage.Text        = "Customer List";
                    lblMessage.CssClass    = "HeaderText";
                    mypager.Visible        = true;
                    btnAssociate.Visible   = true;
                    lblCurrentPage.Visible = true;
                    lblTotalRows.Visible   = true;
                    DataTable dtRMCustomer = new DataTable();

                    dtRMCustomer.Columns.Add("CustomerId");
                    dtRMCustomer.Columns.Add("AssociationId");

                    dtRMCustomer.Columns.Add("Customer Name");
                    dtRMCustomer.Columns.Add("Email");

                    DataRow drRMCustomer;


                    for (int i = 0; i < customerList.Count; i++)
                    {
                        drRMCustomer    = dtRMCustomer.NewRow();
                        customerVo      = new CustomerVo();
                        customerVo      = customerList[i];
                        drRMCustomer[0] = customerVo.CustomerId.ToString();
                        drRMCustomer[1] = customerVo.AssociationId.ToString();
                        drRMCustomer[2] = customerVo.FirstName.ToString() + " " + customerVo.MiddleName.ToString() + " " + customerVo.LastName.ToString();
                        drRMCustomer[3] = customerVo.Email.ToString();

                        dtRMCustomer.Rows.Add(drRMCustomer);
                    }
                    gvCustomers.DataSource = dtRMCustomer;
                    gvCustomers.DataBind();
                    this.GetPageCount();
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "CustomerAssociatesAdd.ascx:BindGrid()");
                object[] objects = new object[5];
                objects[0]   = CurrentPage;
                objects[1]   = rmVo;
                objects[2]   = customerVo;
                objects[3]   = customerList;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Exemplo n.º 14
0
				internal ExceptionInfo(ExceptionManager _enclosing, Jump node, Node finallyBlock)
				{
					this._enclosing = _enclosing;
					this.node = node;
					this.finallyBlock = finallyBlock;
					this.handlerLabels = new int[BodyCodegen.EXCEPTION_MAX];
					this.exceptionStarts = new int[BodyCodegen.EXCEPTION_MAX];
					this.currentFinally = null;
				}
        public void ProcessWithReturnValueReturnsCorrectValueWhenNoExceptionThrown()
        {
            var policies = new Dictionary<string, ExceptionPolicyDefinition>();
            var policy1Entries = new Dictionary<Type, ExceptionPolicyEntry>
            {
                {
                    typeof (ArithmeticException),
                    new ExceptionPolicyEntry(typeof (ArithmeticException),
                        PostHandlingAction.NotifyRethrow,
                        new IExceptionHandler[] {new TestExceptionHandler("handler11")})
                },
                {
                    typeof (ArgumentException),
                    new ExceptionPolicyEntry(typeof (ArgumentException),
                        PostHandlingAction.ThrowNewException,
                        new IExceptionHandler[] {new TestExceptionHandler("handler12")})
                },
                {
                    typeof (ArgumentOutOfRangeException),
                    new ExceptionPolicyEntry(typeof (ArgumentOutOfRangeException),
                        PostHandlingAction.None,
                        new IExceptionHandler[] {new TestExceptionHandler("handler13")})
                }
            };
            policies.Add("policy1", new ExceptionPolicyDefinition("policy1", policy1Entries));

            ExceptionManager manager = new ExceptionManager(policies);

            int result = manager.Process(() => 42, "policy1");
            Assert.AreEqual(42, result);
        }
Exemplo n.º 16
0
 /// <summary>
 /// This method has been used to initialize the exception manager for the complete application
 /// </summary>
 /// <remarks></remarks>
 /// </summary>
 public static void InitializeExceptionManager()
 {
     ESalesUnityContainer.Container.AddNewExtension<EnterpriseLibraryCoreExtension>();
     AppErrorManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();
 }
Exemplo n.º 17
0
        private static void OnException(UnhandledExceptionEventArgs e, IMusicSession Ims)
        {
            if (_EventDone)
                return;

            ExceptionManager em = new ExceptionManager(Ims, e.ExceptionObject);

            SilentException se = e.ExceptionObject as SilentException;

            bool sendemail = (se!=null) ? se.SendEmail : (MessageBox.Show(
                string.Format("Music Collection encountered a fatal error and needs to close.{0}Click Ok to allow music collection to communicate details about the error to administator.{0}This will help improving Music collection quality. {0}", Environment.NewLine)
                , "Fatal Error Detected", MessageBoxButton.OKCancel) == MessageBoxResult.OK);

            em.Deal(sendemail);

            _EventDone = true;
        }
Exemplo n.º 18
0
        protected virtual void InitServices()
        {
#if !DEBUG || ANALYTICS
            FlurryWP8SDK.Api.StartSession(FlurryCredentials.Key);
            var exceptionManager = new ExceptionManager(Application);
            BugSenseHandler.Instance.InitAndStartSession(exceptionManager, App.CurrentApp.RootVisual as PhoneApplicationFrame, BugSenseCredentials.Key);

            var navService = IoC.Get<INavigationService>();
            System.Windows.Navigation.NavigatedEventHandler navigated = null;
            navigated = (sender, e) =>
            {
                firstNavDone = true;
                if (navService != null)
                    navService.Navigated -= navigated;
            };
            if (navService != null)
                navService.Navigated += navigated;
            
            exceptionManager.UnhandledException += (s, e) =>
            {
                if (firstNavDone)
                    Execute.OnUIThread(() =>
                    {
                        e.Handled = MessageBox.Show("Something unexpected happened. We will log this problem and fix it as soon as possible. \nIs it ok to send the report?",
                            "uh-oh :(", MessageBoxButton.OKCancel) == MessageBoxResult.Cancel;
                        if (!e.Handled)
                            LogError(e.ExceptionObject, "");
                    });
                else
                    LogError(e.ExceptionObject, "Before first navigation");
            };
#else
            App.Current.UnhandledException += (s, e) =>
                {
                    Execute.OnUIThread(() =>
                    {
                        e.Handled = MessageBox.Show("Continue after this exception?\n" + e.ExceptionObject.Message,
                            "uh-oh :(", MessageBoxButton.OKCancel) == MessageBoxResult.OK;
                    });
                };
#endif
        }
Exemplo n.º 19
0
        public ActionResult Edit(CaseProgressNote caseprogressnote, int caseID, int?caseMemberID)
        {
            caseprogressnote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
            try
            {
                //if (caseprogressnote.NoteDate > DateTime.Today)
                //{
                //    throw new CustomException("Note date can't be future date.");
                //}
                //validate data
                if (ModelState.IsValid)
                {
                    //<JL:Comment:No need to check access again on post. On edit we are already checking permission.>
                    //if (caseprogressnote.ID > 0 && caseprogressnote.CreatedByWorkerID != CurrentLoggedInWorker.ID && CurrentLoggedInWorkerRoleIDs.IndexOf(1) == -1 && (CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) == -1))
                    //{
                    //    WebHelper.CurrentSession.Content.ErrorMessage = "You are not eligible to do this action";
                    //    //return Json(new { success = true, url = Url.Action(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty }) });
                    //    return RedirectToAction(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty });
                    //}
                    //</JL:Comment:07/08/2017>

                    //call the repository function to save in database
                    caseprogressnoteRepository.InsertOrUpdate(caseprogressnote);
                    caseprogressnoteRepository.Save();
                    if (caseprogressnote.CaseMembersIds != null && caseprogressnote.CaseMembersIds.Count() > 0)
                    {
                        foreach (var item in caseprogressnote.CaseMembersIds)
                        {
                            CaseProgressNoteMembers caseProgressNoteMembers = new CaseProgressNoteMembers();
                            caseProgressNoteMembers.CaseMemberID       = Convert.ToInt32(item);
                            caseProgressNoteMembers.CaseProgressNoteID = Convert.ToInt32(caseprogressnote.ID);
                            caseProgressNoteMembersRepository.InsertOrUpdate(caseProgressNoteMembers);
                            caseProgressNoteMembersRepository.Save();
                        }
                    }

                    //redirect to list page after successful operation
                    if (caseprogressnote.IsInitialContact)
                    {
                        return(RedirectToAction(Constants.Actions.InitialContact, new { caseID = caseprogressnote.CaseID }));
                    }
                    else
                    {
                        return(RedirectToAction(Constants.Actions.Edit, new { noteID = caseprogressnote.ID, caseID = caseprogressnote.CaseID }));
                    }
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            caseprogressnote.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (caseprogressnote.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }
                }
            }
            catch (CustomException ex)
            {
                caseprogressnote.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                caseprogressnote.ErrorMessage = Constants.Messages.UnhandelledError;
            }
            if (caseMemberID.HasValue && caseMemberID.Value > 0)
            {
                caseprogressnote.CaseMemberID = caseMemberID.Value;
                CaseMember caseMember = casememberRepository.Find(caseprogressnote.CaseMemberID);
                if (caseMember != null)
                {
                    ViewBag.DisplayID = caseMember.DisplayID;
                }
            }
            else
            {
                Case varCase = caseRepository.Find(caseID);
                if (varCase != null)
                {
                    ViewBag.DisplayID = varCase.DisplayID;
                }
            }
            //return view with error message if the operation is failed
            return(View(caseprogressnote));
        }
Exemplo n.º 20
0
        public static ActionResult PDF(
            int companyId,
            bool externa,
            string from,
            bool interna,
            bool provider,
            bool status0,
            bool status1,
            bool status2,
            bool status3,
            bool status4,
            bool status5,
            string to,
            string filterText,
            string listOrder)
        {
            var source = "AuditoryExportList";
            var res    = ActionResult.NoAction;
            var user   = HttpContext.Current.Session["User"] as ApplicationUser;

            Dictionary = HttpContext.Current.Session["Dictionary"] as Dictionary <string, string>;
            var    company = new Company(companyId);
            string path    = HttpContext.Current.Request.PhysicalApplicationPath;

            if (!path.EndsWith(@"\", StringComparison.OrdinalIgnoreCase))
            {
                path = string.Format(CultureInfo.InvariantCulture, @"{0}\", path);
            }

            var formatedDescription = ToolsPdf.NormalizeFileName(company.Name);

            string fileName = string.Format(
                CultureInfo.InvariantCulture,
                @"{0}_{1}_{2:yyyyMMddhhmmss}.pdf",
                Dictionary["Item_Auditories"],
                formatedDescription,
                DateTime.Now);


            var pdfDoc = new iTS.Document(iTS.PageSize.A4.Rotate(), 40, 40, 80, 50);
            var writer = iTextSharp.text.pdf.PdfWriter.GetInstance(pdfDoc,
                                                                   new FileStream(
                                                                       string.Format(CultureInfo.InvariantCulture, @"{0}Temp\{1}", path, fileName),
                                                                       FileMode.Create));

            writer.PageEvent = new TwoColumnHeaderFooter
            {
                CompanyLogo = string.Format(CultureInfo.InvariantCulture, @"{0}\images\logos\{1}.jpg", path, company.Id),
                IssusLogo   = string.Format(CultureInfo.InvariantCulture, "{0}issus.png", path),
                Date        = string.Format(CultureInfo.InvariantCulture, "{0:dd/MM/yyyy}", DateTime.Now),
                CreatedBy   = user.UserName,
                CompanyId   = company.Id,
                CompanyName = company.Name,
                Title       = Dictionary["Item_Auditories"].ToUpperInvariant()
            };

            pdfDoc.Open();

            var titleTable = new iTSpdf.PdfPTable(1);

            titleTable.SetWidths(new float[] { 50f });
            titleTable.AddCell(new iTSpdf.PdfPCell(new iTS.Phrase(string.Format(CultureInfo.InvariantCulture, "{0} - {1}", Dictionary["Item_EquipmentList"], company.Name), ToolsPdf.LayoutFonts.TitleFont))
            {
                HorizontalAlignment = iTS.Element.ALIGN_CENTER,
                Border = iTS.Rectangle.NO_BORDER
            });

            //------ CRITERIA
            var criteriatable = new iTSpdf.PdfPTable(4)
            {
                WidthPercentage = 100
            };

            criteriatable.SetWidths(new float[] { 10f, 50f, 10f, 80f });

            #region texts

            string criteriaProccess = Dictionary["Common_All_Male_Plural"];

            string periode = string.Empty;
            if (!string.IsNullOrEmpty(from) && string.IsNullOrEmpty(to))
            {
                periode = Dictionary["Item_Incident_List_Filter_From"] + " " + from;
            }
            else if (string.IsNullOrEmpty(from) && !string.IsNullOrEmpty(to))
            {
                periode = Dictionary["Item_Incident_List_Filter_To"] + " " + to;
            }
            else if (!string.IsNullOrEmpty(from) && !string.IsNullOrEmpty(to))
            {
                periode = from + " - " + to;
            }
            else
            {
                periode = Dictionary["Common_All_Male"];
            }

            string typetext  = string.Empty;
            bool   firtsType = false;
            if (interna)
            {
                typetext += Dictionary["Item_Adutory_Type_Label_0"];
                firtsType = false;
            }
            if (externa)
            {
                typetext += firtsType ? string.Empty : ", ";
                typetext += Dictionary["Item_Adutory_Type_Label_1"];
                firtsType = false;
            }
            if (provider)
            {
                typetext += firtsType ? string.Empty : ", ";
                typetext += Dictionary["Item_Adutory_Type_Label_2"];
            }
            if (firtsType)
            {
                typetext = Dictionary["Common_All_Female_Plural"];
            }

            string statustext  = string.Empty;
            bool   firstStatus = false;
            if (status0)
            {
                statustext += Dictionary["Item_Adutory_Status_Label_0"];
                firstStatus = false;
            }
            if (status1)
            {
                statustext += firstStatus ? string.Empty : ", ";
                statustext += Dictionary["Item_Adutory_Status_Label_1"];
                firstStatus = false;
            }
            if (status2)
            {
                statustext += firstStatus ? string.Empty : ", ";
                statustext += Dictionary["Item_Adutory_Status_Label_2"];
                firstStatus = false;
            }
            if (status3)
            {
                statustext += firstStatus ? string.Empty : ", ";
                statustext += Dictionary["Item_Adutory_Status_Label_3"];
                firstStatus = false;
            }
            if (status4)
            {
                statustext += firstStatus ? string.Empty : ", ";
                statustext += Dictionary["Item_Adutory_Status_Label_4"];
                firstStatus = false;
            }
            if (status5)
            {
                statustext += firstStatus ? string.Empty : ", ";
                statustext += Dictionary["Item_Adutory_Status_Label_5"];
            }
            if (firstStatus)
            {
                statustext = Dictionary["Common_All_Male_Plural"];
            }


            #endregion

            criteriatable.AddCell(ToolsPdf.CriteriaCellLabel(Dictionary["Common_Period"]));
            criteriatable.AddCell(ToolsPdf.CriteriaCellData(periode));
            criteriatable.AddCell(ToolsPdf.CriteriaCellLabel(Dictionary["Item_Auditory_Filter_Type"]));
            criteriatable.AddCell(ToolsPdf.CriteriaCellData(typetext));
            criteriatable.AddCell(ToolsPdf.CriteriaCellLabel(Dictionary["Item_Auditory_Filter_Status"]));
            criteriatable.AddCell(ToolsPdf.CriteriaCellData(statustext));
            if (!string.IsNullOrEmpty(filterText))
            {
                criteriatable.AddCell(ToolsPdf.CriteriaCellLabel(Dictionary["Common_PDF_Filter_Contains"]));
                criteriatable.AddCell(ToolsPdf.CriteriaCellData(filterText));
            }
            else
            {
                criteriatable.AddCell(ToolsPdf.CriteriaCellData(string.Empty));
                criteriatable.AddCell(ToolsPdf.CriteriaCellData(string.Empty));
            }

            pdfDoc.Add(criteriatable);
            //---------------------------

            var tableWidths = new float[] { 40f, 10f, 10f, 10f, 10f, 10f };
            var table       = new iTSpdf.PdfPTable(tableWidths.Length)
            {
                WidthPercentage     = 100,
                HorizontalAlignment = 1,
                SpacingBefore       = 20f,
                SpacingAfter        = 30f
            };

            table.SetWidths(tableWidths);

            table.AddCell(ToolsPdf.HeaderCell(Dictionary["Item_Auditory_ListHeader_Name"]));
            table.AddCell(ToolsPdf.HeaderCell(Dictionary["Item_Auditory_Filter_Type"]));
            table.AddCell(ToolsPdf.HeaderCell(Dictionary["Item_Auditory_ListHeader_Status"]));
            table.AddCell(ToolsPdf.HeaderCell(Dictionary["Item_Auditory_ListHeader_Planned"]));
            table.AddCell(ToolsPdf.HeaderCell(Dictionary["Item_Auditory_ListHeader_Closed"]));
            table.AddCell(ToolsPdf.HeaderCell(Dictionary["Item_Auditory_ListHeader_Ammount"]));

            int cont = 0;
            var data = new List <Auditory>();
            using (var cmd = new SqlCommand("Auditory_Filter"))
            {
                using (var cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["cns"].ConnectionString))
                {
                    cmd.Connection  = cnn;
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add(DataParameter.Input("@CompanyId", companyId));
                    cmd.Parameters.Add(DataParameter.Input("@From", from));
                    cmd.Parameters.Add(DataParameter.Input("@To", to));
                    cmd.Parameters.Add(DataParameter.Input("@TypeInterna", interna));
                    cmd.Parameters.Add(DataParameter.Input("@TypeExterna", externa));
                    cmd.Parameters.Add(DataParameter.Input("@TypeProveedor", provider));
                    cmd.Parameters.Add(DataParameter.Input("@Status0", status0));
                    cmd.Parameters.Add(DataParameter.Input("@Status1", status1));
                    cmd.Parameters.Add(DataParameter.Input("@Status2", status2));
                    cmd.Parameters.Add(DataParameter.Input("@Status3", status3));
                    cmd.Parameters.Add(DataParameter.Input("@Status4", status4));
                    cmd.Parameters.Add(DataParameter.Input("@Status5", status5));
                    try
                    {
                        cmd.Connection.Open();
                        using (var rdr = cmd.ExecuteReader())
                        {
                            while (rdr.Read())
                            {
                                var newAuditory = new Auditory
                                {
                                    Id          = rdr.GetInt64(ColumnsAuditoryFilter.Id),
                                    Description = rdr.GetString(ColumnsAuditoryFilter.Nombre),
                                    Amount      = rdr.GetDecimal(ColumnsAuditoryFilter.Amount),
                                    Status      = rdr.GetInt32(ColumnsAuditoryFilter.Status),
                                    Type        = rdr.GetInt32(ColumnsAuditoryFilter.Type)
                                };

                                if (!rdr.IsDBNull(ColumnsAuditoryFilter.PlannedOn))
                                {
                                    newAuditory.PlannedOn = rdr.GetDateTime(ColumnsAuditoryFilter.PlannedOn);
                                }

                                if (!rdr.IsDBNull(ColumnsAuditoryFilter.ValidatedOn))
                                {
                                    newAuditory.ValidatedOn = rdr.GetDateTime(ColumnsAuditoryFilter.ValidatedOn);
                                }

                                data.Add(newAuditory);
                            }
                        }
                    }
                    catch (SqlException ex)
                    {
                        ExceptionManager.Trace(ex, source);
                    }
                    catch (FormatException ex)
                    {
                        ExceptionManager.Trace(ex, source);
                    }
                    catch (NullReferenceException ex)
                    {
                        ExceptionManager.Trace(ex, source);
                    }
                    finally
                    {
                        if (cmd.Connection.State != ConnectionState.Closed)
                        {
                            cmd.Connection.Close();
                        }
                    }
                }
            }

            switch (listOrder.ToUpperInvariant())
            {
            default:
            case "TH1|ASC":
                data = data.OrderBy(d => d.Status).ToList();
                break;

            case "TH1|DESC":
                data = data.OrderByDescending(d => d.Status).ToList();
                break;

            case "TH2|ASC":
                data = data.OrderBy(d => d.Description).ToList();
                break;

            case "TH2|DESC":
                data = data.OrderByDescending(d => d.Description).ToList();
                break;

            case "TH3|ASC":
                data = data.OrderBy(d => d.PlannedOn).ToList();
                break;

            case "TH3|DESC":
                data = data.OrderByDescending(d => d.PlannedOn).ToList();
                break;

            case "TH4|ASC":
                data = data.OrderBy(d => d.ValidatedOn).ToList();
                break;

            case "TH4|DESC":
                data = data.OrderByDescending(d => d.ValidatedOn).ToList();
                break;

            case "TH5|ASC":
                data = data.OrderBy(d => d.Amount).ToList();
                break;

            case "TH5|DESC":
                data = data.OrderByDescending(d => d.Amount).ToList();
                break;
            }

            foreach (var auditory in data)
            {
                if (!string.IsNullOrEmpty(filterText))
                {
                    var match = auditory.Description;
                    if (match.IndexOf(filterText, StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        continue;
                    }
                }
                cont++;
                string statustextCell = string.Empty;
                switch (auditory.Status)
                {
                case 0: statustextCell = Dictionary["Item_Adutory_Status_Label_0"]; break;

                case 1: statustextCell = Dictionary["Item_Adutory_Status_Label_1"]; break;

                case 2: statustextCell = Dictionary["Item_Adutory_Status_Label_2"]; break;

                case 3: statustextCell = Dictionary["Item_Adutory_Status_Label_3"]; break;

                case 4: statustextCell = Dictionary["Item_Adutory_Status_Label_4"]; break;

                case 5: statustextCell = Dictionary["Item_Adutory_Status_Label_5"]; break;
                }

                string typetextCell = string.Empty;
                switch (auditory.Type)
                {
                case 0: typetextCell = Dictionary["Item_Adutory_Type_Label_0"]; break;

                case 1: typetextCell = Dictionary["Item_Adutory_Type_Label_1"]; break;

                case 2: typetextCell = Dictionary["Item_Adutory_Type_Label_2"]; break;
                }

                table.AddCell(ToolsPdf.DataCell(auditory.Description));
                table.AddCell(ToolsPdf.DataCellCenter(typetextCell));
                table.AddCell(ToolsPdf.DataCellCenter(statustextCell));
                table.AddCell(ToolsPdf.DataCellCenter(auditory.PlannedOn));
                table.AddCell(ToolsPdf.DataCellCenter(auditory.ValidatedOn));
                table.AddCell(ToolsPdf.DataCellMoney(auditory.Amount));
            }

            table.AddCell(new iTSpdf.PdfPCell(new iTS.Phrase(string.Format(
                                                                 CultureInfo.InvariantCulture,
                                                                 @"{0}: {1}",
                                                                 Dictionary["Common_RegisterCount"],
                                                                 cont), ToolsPdf.LayoutFonts.Times))
            {
                Border     = iTS.Rectangle.TOP_BORDER,
                Padding    = 6f,
                PaddingTop = 4f,
                Colspan    = 4
            });

            table.AddCell(new iTSpdf.PdfPCell(new iTS.Phrase(string.Empty, ToolsPdf.LayoutFonts.Times))
            {
                Border  = iTS.Rectangle.TOP_BORDER,
                Colspan = 4
            });

            pdfDoc.Add(table);
            pdfDoc.CloseDocument();
            res.SetSuccess(string.Format(CultureInfo.InvariantCulture, @"{0}Temp/{1}", ConfigurationManager.AppSettings["siteUrl"], fileName));
            return(res);
        }
        public void Setup()
        {
            settings = new ExceptionHandlingSettings();

            var exceptionPolicyData1 = new ExceptionPolicyData("policy1");
            settings.ExceptionPolicies.Add(exceptionPolicyData1);
            var exceptionType11 = new ExceptionTypeData("ArgumentNullException", typeof(ArgumentNullException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData1.ExceptionTypes.Add(exceptionType11);
            exceptionType11.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            var exceptionType12 = new ExceptionTypeData("ArgumentException", typeof(ArgumentException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData1.ExceptionTypes.Add(exceptionType12);
            exceptionType12.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            exceptionType12.ExceptionHandlers.Add(
                new WrapHandlerData("handler2", "message", typeof(Exception).AssemblyQualifiedName));


            var exceptionPolicyData2 = new ExceptionPolicyData("policy2");
            settings.ExceptionPolicies.Add(exceptionPolicyData2);
            var exceptionType21 = new ExceptionTypeData("ArgumentNullException", typeof(ArgumentNullException),
                                                        PostHandlingAction.NotifyRethrow);
            exceptionPolicyData2.ExceptionTypes.Add(exceptionType21);
            exceptionType21.ExceptionHandlers.Add(
                new WrapHandlerData("handler1", "message", typeof(Exception).AssemblyQualifiedName));
            exceptionType21.ExceptionHandlers.Add(
                new WrapHandlerData("handler3", "message", typeof(Exception).AssemblyQualifiedName));

            this.manager = (ExceptionManager)this.settings.BuildExceptionManager();
        }
        protected void btnAddBankDetails_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    rmVo       = (RMVo)Session["rmVo"];
                    customerVo = (CustomerVo)Session["CustomerVo"];
                    userVo     = (UserVo)Session["UserVo"];
                    rmId       = rmVo.RMId;


                    customerVo.FirstName = txtCompanyName.Text.ToString();
                    //customerVo.MiddleName = txtMiddleName.Text.ToString();
                    //customerVo.LastName = txtLastName.Text.ToString();
                    customerVo.ContactFirstName  = txtFirstName.Text.ToString();
                    customerVo.ContactMiddleName = txtMiddleName.Text.ToString();
                    customerVo.ContactLastName   = txtLastName.Text.ToString();
                    customerVo.CompanyName       = txtCompanyName.Text.ToString();
                    customerVo.CustCode          = txtCustomerCode.Text.ToString();
                    customerVo.Salutation        = ddlSalutation.SelectedItem.Value.ToString();
                    if (txtDateofRegistration.Text != string.Empty)
                    {
                        customerVo.RegistrationDate = DateTime.Parse(txtDateofRegistration.Text.ToString());
                    }
                    else
                    {
                        customerVo.RegistrationDate = DateTime.MinValue;
                    }
                    if (txtDateofCommencement.Text != string.Empty)
                    {
                        customerVo.CommencementDate = DateTime.Parse(txtDateofCommencement.Text.ToString());
                    }
                    else
                    {
                        customerVo.CommencementDate = DateTime.MinValue;
                    }
                    if (txtDateofProfiling.Text != string.Empty)
                    {
                        customerVo.ProfilingDate = DateTime.Parse(txtDateofProfiling.Text.ToString());
                    }
                    else
                    {
                        customerVo.ProfilingDate = DateTime.MinValue;
                    }

                    customerVo.RegistrationPlace = txtRegistrationPlace.Text.ToString();
                    customerVo.CompanyWebsite    = txtCompanyWebsite.Text.ToString();
                    customerVo.RmId            = rmId;
                    customerVo.PANNum          = txtPanNumber.Text.ToString();
                    customerVo.RegistrationNum = txtRocRegistration.Text.ToString();
                    customerVo.Adr1Line1       = txtCorrAdrLine1.Text.ToString();
                    customerVo.Adr1Line2       = txtCorrAdrLine2.Text.ToString();
                    customerVo.Adr1Line3       = txtCorrAdrLine3.Text.ToString();
                    customerVo.Adr1PinCode     = int.Parse(txtCorrAdrPinCode.Text.ToString());
                    customerVo.Adr1City        = txtCorrAdrCity.Text.ToString();
                    customerVo.Adr1State       = ddlCorrAdrState.SelectedItem.Value.ToString();
                    customerVo.Adr1Country     = ddlCorrAdrCountry.SelectedItem.Value.ToString();
                    if (chkCorrPerm.Checked)
                    {
                        customerVo.Adr2Line1   = txtCorrAdrLine1.Text.ToString();
                        customerVo.Adr2Line2   = txtCorrAdrLine2.Text.ToString();
                        customerVo.Adr2Line3   = txtCorrAdrLine3.Text.ToString();
                        customerVo.Adr2PinCode = int.Parse(txtCorrAdrPinCode.Text.ToString());
                        customerVo.Adr2City    = txtCorrAdrCity.Text.ToString();
                        customerVo.Adr2State   = ddlCorrAdrState.Text.ToString();
                        customerVo.Adr2Country = ddlCorrAdrCountry.Text.ToString();
                    }
                    else
                    {
                        customerVo.Adr2Line1   = txtPermAdrLine1.Text.ToString();
                        customerVo.Adr2Line2   = txtPermAdrLine2.Text.ToString();
                        customerVo.Adr2Line3   = txtPermAdrLine3.Text.ToString();
                        customerVo.Adr2PinCode = int.Parse(txtPermAdrPinCode.Text.ToString());
                        customerVo.Adr2City    = txtPermAdrCity.Text.ToString();
                        customerVo.Adr2State   = ddlPermAdrState.Text.ToString();
                        customerVo.Adr2Country = ddlPermAdrCountry.Text.ToString();
                    }
                    customerVo.ResISDCode    = int.Parse(txtPhoneNo1Isd.Text.ToString());
                    customerVo.ResSTDCode    = int.Parse(txtPhoneNo1Std.Text.ToString());
                    customerVo.ResPhoneNum   = int.Parse(txtPhoneNo1.Text.ToString());
                    customerVo.OfcISDCode    = int.Parse(txtPhoneNo2Isd.Text.ToString());
                    customerVo.OfcSTDCode    = int.Parse(txtPhoneNo2Std.Text.ToString());
                    customerVo.OfcPhoneNum   = int.Parse(txtPhoneNo2.Text.ToString());
                    customerVo.Fax           = int.Parse(txtFax.Text.ToString());
                    customerVo.ISDFax        = int.Parse(txtFaxIsd.Text.ToString());
                    customerVo.STDFax        = int.Parse(txtFaxStd.Text.ToString());
                    customerVo.Email         = txtEmail.Text.ToString();
                    customerVo.MaritalStatus = null;
                    customerVo.Nationality   = null;
                    customerVo.Occupation    = null;
                    customerVo.Qualification = null;
                    customerVo.MarriageDate  = DateTime.Parse("1990-01-01 00:00:00.000");
                    //customerBo.CreateCustomer(customerVo, customerVo.RmId,userVo.UserId,0);
                    customerBo.UpdateCustomer(customerVo);

                    Session["Check"] = "CustomerAdd";
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('AddBankDetails','none');", true);
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }

            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "CustomerNonIndividualAdd.ascx:btnAddBankDetails_Click()");
                object[] objects = new object[4];
                objects[0]   = rmVo;
                objects[1]   = rmId;
                objects[2]   = customerVo;
                objects[3]   = userVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// Processes the CMD key.
        /// </summary>
        /// <param name="msg">The MSG.</param>
        /// <param name="keyData">The key data.</param>
        /// <returns></returns>
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            try
            {
                const int WM_KEYDOWN    = 0x100;
                const int WM_SYSKEYDOWN = 0x104;
                if ((msg.Msg == WM_KEYDOWN) || (msg.Msg == WM_SYSKEYDOWN))
                {
                    if (!string.IsNullOrEmpty(this.FindTextBox.Text) && !string.IsNullOrEmpty(noofrows))
                    {
                        if (keyData.Equals(Keys.Control | Keys.P))
                        {
                            this.previewOperation();
                        }
                        if (keyData.Equals(Keys.F3))
                        {
                            if (this.nextcount == 1)
                            {
                                this.nextcount = int.Parse(noofrows) + 1;
                            }

                            this.nextcount = this.nextcount - 1;
                            if (this.nextcount > 0)
                            {
                                this.ItemTextBox.Text = this.quickfinditem.F9610_GetQuickFindItem[nextcount - 1]["Item"].ToString();
                                keyid = int.Parse(this.quickfinditem.F9610_GetQuickFindItem[nextcount - 1]["KeyID"].ToString());

                                this.FormMaster_FormVisibility(false);

                                this.RecordCountLabel.Text = nextcount + " / " + noofrows + " " + "Found";
                                SliceReloadActiveRecord sliceReloadActiveRecord;
                                sliceReloadActiveRecord.MasterFormNo  = this.formno;
                                sliceReloadActiveRecord.SelectedKeyId = keyid;
                                //OnD9030_F9030_LoadSliceDetails(new DataEventArgs<SliceReloadActiveRecord>(sliceReloadActiveRecord));

                                OnQuickFind_KeyId(this, new DataEventArgs <SliceReloadActiveRecord>(sliceReloadActiveRecord));

                                int[] currentformno = new int[2];
                                currentformno[0] = this.formno;
                                currentformno[1] = keyid;
                                this.SetGnrlProperties(this, new DataEventArgs <int[]>(currentformno));
                                int[] currentformdetails = new int[3];
                                currentformdetails[0] = this.formno;
                                currentformdetails[1] = keyid;
                                currentformdetails[2] = 1;
                                this.SetReportAdditionalProperties(this, new DataEventArgs <int[]>(currentformdetails));
                                // CheckPageStatus(this, new DataEventArgs<Button>(this.NextButton));
                            }
                        }
                        else if (keyData.Equals(Keys.F4))
                        {
                            if (this.nextcount.ToString() == noofrows)
                            {
                                this.nextcount = 0;
                            }

                            if (this.quickfinditem.F9610_GetQuickFindItem.Rows.Count > 0)
                            {
                                this.ItemTextBox.Text = this.quickfinditem.F9610_GetQuickFindItem[nextcount]["Item"].ToString();
                                keyid = int.Parse(this.quickfinditem.F9610_GetQuickFindItem[nextcount]["KeyID"].ToString());

                                this.FormMaster_FormVisibility(false);

                                this.nextcount             = this.nextcount + 1;
                                this.RecordCountLabel.Text = nextcount + " / " + noofrows + " " + "Found";
                                SliceReloadActiveRecord sliceReloadActiveRecord;
                                sliceReloadActiveRecord.MasterFormNo  = this.formno;
                                sliceReloadActiveRecord.SelectedKeyId = keyid;
                                //OnD9030_F9030_LoadSliceDetails(new DataEventArgs<SliceReloadActiveRecord>(sliceReloadActiveRecord));

                                OnQuickFind_KeyId(this, new DataEventArgs <SliceReloadActiveRecord>(sliceReloadActiveRecord));

                                // CheckPageStatus(this, new DataEventArgs<Button>(this.NextButton));
                                int[] currentformno = new int[2];
                                currentformno[0] = this.formno;
                                currentformno[1] = keyid;
                                this.SetGnrlProperties(this, new DataEventArgs <int[]>(currentformno));
                                int[] currentformdetails = new int[3];
                                currentformdetails[0] = this.formno;
                                currentformdetails[1] = keyid;
                                currentformdetails[2] = 1;
                                this.SetReportAdditionalProperties(this, new DataEventArgs <int[]>(currentformdetails));
                            }
                        }


                        if (keyData.Equals(Keys.Escape))
                        {
                            if (this.CloseButton.Enabled)
                            {
                                this.closeOperation();
                            }
                            else
                            {
                                this.Close();
                                this.DialogResult = DialogResult.Cancel;
                            }
                        }
                    }
                    else
                    {
                        if (!string.IsNullOrEmpty(noofrows))
                        {
                            if (keyData.Equals(Keys.Control | Keys.P))
                            {
                                this.previewOperation();
                            }
                        }
                        if (keyData.Equals(Keys.Escape))
                        {
                            this.Close();
                            this.DialogResult = DialogResult.Cancel;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
            }
            finally
            {
                if (!string.IsNullOrEmpty(this.FindTextBox.Text) && !string.IsNullOrEmpty(noofrows))
                {
                    if (keyData.Equals(Keys.F3) || keyData.Equals(Keys.F4))
                    {
                        this.FormMaster_FormVisibility(true);
                    }
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
Exemplo n.º 24
0
 /// <summary>
 /// Resets the global exception manager.
 /// </summary>
 public static void Reset()
 {
     exceptionManager = null;
 }
Exemplo n.º 25
0
        private void LoadZoningGrid()
        {
            try
            {
                int emptyRows;
                this.Cursor = Cursors.WaitCursor;
                this.zoningDetailsData.ListZoning.Clear();
                this.zoningDetailsData = this.form3040Control.WorkItem.F3040_GetZoningDetails();
                this.ZoningDataGridDataTableRowCount = this.zoningDetailsData.ListZoning.Rows.Count;
                ////to set the ZoningDataGridView focus
                ////this.ZoningDataGridView.Focus();
                if (this.ZoningDataGridDataTableRowCount > 0)
                {
                    ////if the no of visiable rows(grid) is greater than the actual rows from the Datatable ---
                    //// --- then a temp datatable with empty rows are merged with ListZoning datatable
                    if (this.ZoningDataGridView.NumRowsVisible > this.ZoningDataGridDataTableRowCount)
                    {
                        emptyRows = this.ZoningDataGridView.NumRowsVisible - this.ZoningDataGridDataTableRowCount;

                        for (int i = 0; i < emptyRows; i++)
                        {
                            this.zoningDetailsData.ListZoning.AddListZoningRow(this.zoningDetailsData.ListZoning.NewListZoningRow());
                        }
                    }
                    else
                    {
                        this.zoningDetailsData.ListZoning.AddListZoningRow(this.zoningDetailsData.ListZoning.NewListZoningRow());
                    }

                    ////this.GenericMgmtAcceptButton.Enabled = true;
                    this.ZoningDataGridView.DataSource       = this.zoningDetailsData.ListZoning;
                    this.ZoningDataGridView.Rows[0].Selected = true;
                    ////TerraScanCommon.SetDataGridViewPosition(this.ZoningDataGridView, 0);
                }
                else
                {
                    for (int i = 0; i < this.ZoningDataGridView.NumRowsVisible; i++)
                    {
                        this.zoningDetailsData.ListZoning.AddListZoningRow(this.zoningDetailsData.ListZoning.NewListZoningRow());
                    }

                    ////this.GenericMgmtAcceptButton.Enabled = false;
                    this.ZoningDataGridView.DataSource       = this.zoningDetailsData.ListZoning;
                    this.ZoningDataGridView.Rows[0].Selected = false;
                }

                this.ZoningDataGridView.Enabled = true;

                ////to enable or disable the vertical scroll bar
                if (this.zoningDetailsData.ListZoning.Rows.Count > this.ZoningDataGridView.NumRowsVisible)
                {
                    this.ZoningGridVerticalScroll.Visible = false;
                }
                else
                {
                    this.ZoningGridVerticalScroll.Visible = true;
                }
            }
            catch (SoapException e)
            {
                ExceptionManager.ManageException(e, ExceptionManager.ActionType.Display, this.ParentForm);
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
        public void HandleForwardsHandlingToConfiguredExceptionEntry()
        {
            var policies = new Dictionary<string, ExceptionPolicyDefinition>();
            var policy1Entries = new Dictionary<Type, ExceptionPolicyEntry>
            {
                {
                    typeof (ArithmeticException),
                    new ExceptionPolicyEntry(typeof (ArithmeticException),
                        PostHandlingAction.NotifyRethrow,
                        new IExceptionHandler[] {new TestExceptionHandler("handler11")})
                },
                {
                    typeof (ArgumentException),
                    new ExceptionPolicyEntry(typeof (ArgumentException),
                        PostHandlingAction.ThrowNewException,
                        new IExceptionHandler[] {new TestExceptionHandler("handler12")})
                },
                {
                    typeof (ArgumentOutOfRangeException),
                    new ExceptionPolicyEntry(typeof (ArgumentOutOfRangeException),
                        PostHandlingAction.None,
                        new IExceptionHandler[] {new TestExceptionHandler("handler13")})
                }
            };

            policies.Add("policy1", new ExceptionPolicyDefinition("policy1", policy1Entries));

            var manager = new ExceptionManager(policies);

            // is the exception rethrown?
            Exception thrownException = new ArithmeticException();
            Assert.IsTrue(manager.HandleException(thrownException, "policy1"));
            Assert.AreEqual(1, TestExceptionHandler.HandlingNames.Count);
            Assert.AreEqual("handler11", TestExceptionHandler.HandlingNames[0]);

            // is the new exception thrown?
            TestExceptionHandler.HandlingNames.Clear();
            thrownException = new ArgumentException();
            try
            {
                manager.HandleException(thrownException, "policy1");
                Assert.Fail("should have thrown");
            }
            catch (Exception e)
            {
                Assert.AreSame(thrownException, e.InnerException);
                Assert.AreEqual(1, TestExceptionHandler.HandlingNames.Count);
                Assert.AreEqual("handler12", TestExceptionHandler.HandlingNames[0]);
            }

            // is the exception swallowed? action == None
            TestExceptionHandler.HandlingNames.Clear();
            thrownException = new ArgumentOutOfRangeException();
            Assert.IsFalse(manager.HandleException(thrownException, "policy1"));
            Assert.AreEqual(1, TestExceptionHandler.HandlingNames.Count);
            Assert.AreEqual("handler13", TestExceptionHandler.HandlingNames[0]);

            // is the unknwon exception rethrown?
            TestExceptionHandler.HandlingNames.Clear();
            thrownException = new Exception();
            Assert.IsTrue(manager.HandleException(thrownException, "policy1"));
            Assert.AreEqual(0, TestExceptionHandler.HandlingNames.Count);
        }
Exemplo n.º 27
0
        private void ZoningDataGridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.RowIndex == 0)
                {
                    this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                    this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                    this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                }

                bool hasValues = false;
                if (e.RowIndex >= 1)
                {
                    if ((string.IsNullOrEmpty(this.ZoningDataGridView["ZoningCode", (e.RowIndex - 1)].Value.ToString().Trim())) && (string.IsNullOrEmpty(this.ZoningDataGridView["Zoning", (e.RowIndex - 1)].Value.ToString().Trim())))
                    {
                        if (e.RowIndex + 1 < ZoningDataGridView.RowCount)
                        {
                            for (int i = e.RowIndex; i < ZoningDataGridView.RowCount; i++)
                            {
                                if (!string.IsNullOrEmpty(this.ZoningDataGridView.Rows[i].Cells["ZoningCode"].Value.ToString().Trim()) && !string.IsNullOrEmpty(this.ZoningDataGridView.Rows[i].Cells["Zoning"].Value.ToString().Trim()))
                                {
                                    hasValues = true;
                                    break;
                                }
                            }

                            if (hasValues)
                            {
                                this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                                this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                                this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                            }
                            else
                            {
                                if ((string.IsNullOrEmpty(this.ZoningDataGridView["ZoningCode", e.RowIndex].Value.ToString().Trim())) && (string.IsNullOrEmpty(this.ZoningDataGridView["Zoning", e.RowIndex].Value.ToString().Trim())))
                                {
                                    this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = true;
                                    this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = true;
                                }
                                else
                                {
                                    this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                                    this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                                    this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                                }
                            }
                        }
                        else
                        {
                            this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = true;
                            this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = true;
                        }
                    }
                    else
                    {
                        this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                        this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                        this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                    }
                }

                this.currentRowIndex = e.RowIndex;
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.Display, this.ParentForm);
            }
        }
        private void BindRMforBranchDropdown(int branchId, int branchHeadId)
        {
            try
            {
                if (advisorVo.A_AgentCodeBased != 1)
                {
                    DataSet ds = advisorBranchBo.GetAllRMsWithOutBMRole(branchId, branchHeadId);
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        ddlAdviseRMList.DataSource     = ds.Tables[0];
                        ddlAdviseRMList.DataValueField = ds.Tables[0].Columns["RmID"].ToString();
                        ddlAdviseRMList.DataTextField  = ds.Tables[0].Columns["RMName"].ToString();
                        // ddlAdviseRMList.SelectedValue = "4682";
                        ddlAdviseRMList.DataBind();
                        //ddlAdviseRMList.Items.Remove("No RM Available");
                        //ddlAdviseRMList.Items.Insert(0, new ListItem("Select", "Select"));
                        //CompareValidator2.ValueToCompare = "Select";
                        //CompareValidator2.ErrorMessage = "Please select a RM";
                    }
                    else
                    {
                        if (!IsPostBack)
                        {
                            ddlAdviseRMList.Items.Insert(0, new ListItem("Select", "Select"));
                            CompareValidator2.ValueToCompare = "Select";
                            CompareValidator2.ErrorMessage   = "Please select a RM";
                        }
                        else
                        {
                            if (rbtnNonIndividual.Checked == true)
                            {
                                if ((IsPostBack) && (ddlAdviserBranchList.SelectedIndex == 0))
                                {
                                    ddlAdviseRMList.Items.Clear();
                                    ddlAdviseRMList.Items.Insert(0, new ListItem("Select", "Select"));
                                    CompareValidator2.ValueToCompare = "Select";
                                    CompareValidator2.ErrorMessage   = "Please select a RM";
                                }
                                else
                                {
                                    ddlAdviseRMList.Items.Clear();
                                    ddlAdviseRMList.Items.Remove("Select");
                                    ddlAdviseRMList.Items.Insert(0, new ListItem("No RM Available", "No RM Available"));
                                    CompareValidator2.ValueToCompare = "No RM Available";
                                    CompareValidator2.ErrorMessage   = "Cannot Add Customer Without a RM";
                                }
                            }
                            else
                            {
                                if ((IsPostBack) && (ddlAdviserBranchList.SelectedIndex == 0))
                                {
                                    ddlAdviseRMList.Items.Clear();
                                    ddlAdviseRMList.Items.Insert(0, new ListItem("Select", "Select"));
                                    CompareValidator2.ValueToCompare = "Select";
                                    CompareValidator2.ErrorMessage   = "Please select a RM";
                                }
                                else
                                {
                                    ddlAdviseRMList.Items.Clear();
                                    ddlAdviseRMList.Items.Remove("Select");
                                    ddlAdviseRMList.Items.Insert(0, new ListItem("No RM Available", "No RM Available"));
                                    CompareValidator2.ValueToCompare = "No RM Available";
                                    CompareValidator2.ErrorMessage   = "Cannot Add Customer Without a RM";
                                }
                            }
                        }
                    }
                }
                else
                {
                    DataSet Rmds = new DataSet();
                    //DataTable Rmlist = Rmds.Tables[0];
                    //Rmlist.Columns.Add("RmID");
                    //Rmlist.Columns.Add("RMName");
                    Rmds = advisorBranchBo.GetRMRoleForAgentBased(advisorVo.advisorId);

                    if (Rmds.Tables[0].Rows.Count > 0)
                    {
                        ddlAdviseRMList.DataSource     = Rmds;
                        ddlAdviseRMList.DataValueField = Rmds.Tables[0].Columns["RmID"].ToString();
                        ddlAdviseRMList.DataTextField  = Rmds.Tables[0].Columns["RMName"].ToString();
                        ddlAdviseRMList.DataBind();
                        ddlAdviseRMList.Enabled = false;
                    }
                    else
                    {
                        ddlAdviseRMList.Enabled = false;
                    }
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "AdviserMFMIS.ascx:BindBranchDropDown()");

                object[] objects = new object[4];

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Exemplo n.º 29
0
        private void ZoningDataGridView_RowEnter(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                ////if (e.RowIndex == 0)
                ////{
                ////    this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                ////    this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly = false;
                ////    this.ZoningDataGridView.Rows[e.RowIndex].Selected = false;
                ////}

                bool hasValues = false;
                if (e.RowIndex >= 1)
                {
                    if ((string.IsNullOrEmpty(this.ZoningDataGridView["ZoningCode", (e.RowIndex - 1)].Value.ToString().Trim())) && (string.IsNullOrEmpty(this.ZoningDataGridView["Zoning", (e.RowIndex - 1)].Value.ToString().Trim())))
                    {
                        if (e.RowIndex + 1 < ZoningDataGridView.RowCount)
                        {
                            for (int i = e.RowIndex; i < ZoningDataGridView.RowCount; i++)
                            {
                                if (!string.IsNullOrEmpty(this.ZoningDataGridView.Rows[i].Cells["ZoningCode"].Value.ToString().Trim()) && !string.IsNullOrEmpty(this.ZoningDataGridView.Rows[i].Cells["Zoning"].Value.ToString().Trim()))
                                {
                                    hasValues = true;
                                    break;
                                }
                            }

                            if (hasValues)
                            {
                                this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                                this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                                this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                            }
                            else
                            {
                                if ((string.IsNullOrEmpty(this.ZoningDataGridView["ZoningCode", e.RowIndex].Value.ToString().Trim())) && (string.IsNullOrEmpty(this.ZoningDataGridView["Zoning", e.RowIndex].Value.ToString().Trim())))
                                {
                                    this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = true;
                                    this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = true;
                                }
                                else
                                {
                                    this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                                    this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                                    this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                                }
                            }
                        }
                        else
                        {
                            this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = true;
                            this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = true;
                        }
                    }
                    else
                    {
                        this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                        this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                        this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                    }
                }

                if (e.RowIndex == 0)
                {
                    this.ZoningDataGridView["ZoningCode", e.RowIndex].ReadOnly = false;
                    this.ZoningDataGridView["Zoning", e.RowIndex].ReadOnly     = false;
                    this.ZoningDataGridView.Rows[e.RowIndex].Selected          = false;
                }

                if ((this.ZoningDataGridView["Zoning", e.RowIndex].Value != null))
                {
                    this.HeaderZoneLabel.Text = this.ZoningDataGridView.Rows[e.RowIndex].Cells["Zoning"].Value.ToString();

                    ////which will be sent to the attachment and comment button
                    int.TryParse(this.ZoningDataGridView.Rows[e.RowIndex].Cells["ZoningID"].Value.ToString(), out this.currentKeyId);

                    if (!this.ZoningSaveButton.Enabled)
                    {
                        this.SetAdditionalOperationCount(this.currentKeyId);
                    }
                    else
                    {
                        this.SetAdditionalOperationCount(this.currentKeyId);
                    }

                    if (this.currentKeyId > 0)
                    {
                        /////to set the audit link label text
                        this.ZoningIDAuditlinkLabel.Text    = SharedFunctions.GetResourceString("tAA_Zoning[ZoningID]: ") + this.currentKeyId;
                        this.ZoningIDAuditlinkLabel.Visible = true;
                    }
                    else
                    {
                        this.ZoningIDAuditlinkLabel.Visible = false;
                    }
                }

                this.currentRowIndex = e.RowIndex;
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.Display, this.ParentForm);
            }
        }
        /// <summary>
        /// Execute a flow.
        /// </summary>
        /// <param name="flowManifest"></param>
        /// <param name="hostRuntimeSettings"></param>
        public override void Execute(string flowManifest, HostRuntimeSettings settings)
        {
            // This base call sets up the this.CurrentExecutingFlowManifest.
            base.Execute(flowManifest, settings);

            //
            // First of all clear previous status information
            //
            this.m_statusInformation.Clear();


            FlowManifest manifest = this.CurrentExecutingFlowManifest; //= null;

            System.Globalization.CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
            try
            {
                //XmlDocument xdManifest = new XmlDocument();
                //xdManifest.LoadXml(flowManifest);
                //manifest = new FlowManifest(xdManifest);
                if (this.BindingConfig == null)
                {
                    //
                    // Initialize the application cache.
                    //
                    this.ApplicationCache = new Hashtable();

                    //
                    // Set data directory
                    //
                    this.DataDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Data");
                    if (!Directory.Exists(this.DataDirectory))
                    {
                        Directory.CreateDirectory(this.DataDirectory);
                    }

                    //
                    // Set config directory
                    //
                    this.ConfigDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config");
                    if (!Directory.Exists(this.ConfigDirectory))
                    {
                        //Directory.CreateDirectory(this.ConfigDirectory);
                        throw new HostRuntimeException("Missing Config directory in package file.");
                    }

                    //
                    // Load configuration data.
                    //
                    XmlDocument xdRetrival = new XmlDocument();
                    xdRetrival.Load(Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Config"), "Binding.xml"));
                    this.BindingConfig            = new RetrivalBindingConfig(xdRetrival);
                    this.ProgressItem.Description = this.BindingConfig.Description;
                }

                //
                // Reset progress item.
                //
                this.ProgressItem.ErrorInfo     = "";
                this.ProgressItem.ExecutionTime = TimeSpan.Zero;
                this.ProgressItem.StartTime     = DateTime.Now;
                this.ProgressItem.Status        = "Running";


                //
                // Create output directory and session object.
                //
                string outputDirectory = FileSystem.NormalizeDirectoryPath(Path.Combine(settings.OutputDirectory, manifest.GUID.ToString()));
                if (!Directory.Exists(outputDirectory))
                {
                    Directory.CreateDirectory(outputDirectory);
                }
                manifest.RetrivalOutputDirectory = outputDirectory;

                //
                // Create temp directory.
                //
                string tempDirectory = FileSystem.NormalizeDirectoryPath(Path.Combine(settings.TempDirectory, manifest.GUID.ToString()));
                if (!Directory.Exists(tempDirectory))
                {
                    Directory.CreateDirectory(tempDirectory);
                }

                //
                // Execute generator.
                //
                DateTime dtBefore = DateTime.Now;
                this.BindingConfig.IRetrivalRef.Retrive(manifest.InputParameters, this.ApplicationCache, tempDirectory, this.ConfigDirectory, this.DataDirectory, outputDirectory, this);
                DateTime dtAfter = DateTime.Now;
                this.AddExecutionTime(dtAfter - dtBefore);

                this.ProgressItem.Status = "OK";

                //
                // Delete temp directory.
                //
                try
                {
                    FileSystem.DeleteDirectoryStructure(tempDirectory);
                }
                catch (Exception) { }

                //
                // Always perform a garbage collection after generation. Some generators, like powerpoint etc., hold
                // on to objects that make processes like powerpoint to keep running. We have to run the finalizers so
                // that they are released.
                //
                GC.Collect();
                GC.WaitForPendingFinalizers();
                GC.Collect();
                GC.WaitForPendingFinalizers();

                //
                // If Retrival has ended the execution flow return now.
                //
                if (this.EndFlow)
                {
                    return;
                }


                //
                // Providers have executed. Pass message to destination and log.
                //
                string msmqPath = settings.DestinationMsmqPath;
                try
                {
                    manifest.FlowStatus = FlowStatus.CompletedRetrival;

                    //
                    // Send to generator.
                    //
                    using (MessageQueue mqPublisher = new MessageQueue(settings.DestinationMsmqPath))
                    {
                        mqPublisher.Formatter = new BinaryMessageFormatter();

                        System.Messaging.Message msgPublisher = new System.Messaging.Message();
                        msgPublisher.Formatter = new BinaryMessageFormatter();
                        msgPublisher.Body      = manifest.ToXmlDocument().OuterXml;
                        msgPublisher.Label     = string.Format("{0} - {1}", manifest.FlowID, manifest.FlowStatus.ToString());

                        mqPublisher.Send(msgPublisher);
                    }
                    //
                    // Send message to log.
                    //
                    if (settings.Log && this.LogToEvents)
                    {
                        msmqPath = settings.EventsMsmqPath;
                        using (MessageQueue mqLog = new MessageQueue(settings.EventsMsmqPath))
                        {
                            mqLog.Formatter = new BinaryMessageFormatter();

                            System.Messaging.Message msgLog = new System.Messaging.Message();
                            msgLog.Formatter = new BinaryMessageFormatter();
                            msgLog.Body      = manifest.ToXmlDocument().OuterXml;
                            msgLog.Label     = string.Format("{0} - {1}", manifest.FlowID, manifest.FlowStatus.ToString());

                            mqLog.Send(msgLog);
                        }
                    }
                }
                catch (StackOverflowException)
                {
                    throw;
                }
                catch (OutOfMemoryException)
                {
                    throw;
                }
                catch (ThreadAbortException)
                {
                    throw;
                }
                catch (Exception x)
                {
                    string msg = string.Format("Failure to send message to MSMQ Path: {0}\r\nFlow: {0}.", msmqPath, manifest.GUID.ToString());
                    throw new HostRuntimeException(msg, x);
                }
            }
            catch (StackOverflowException)
            {
                throw;
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch (ThreadAbortException)
            {
                throw;
            }
            catch (Exception x)
            {
                this.ProgressItem.Status    = "Failure";
                this.ProgressItem.ErrorInfo = string.Format("Type:\r\n{0}\r\n\r\nSource:\r\n{1}\r\n\r\nMessage:\r\n{2}\r\n\r\nStack Trace:\r\n{3}", x.GetType().FullName, (x.Source != null) ? x.Source : "<NULL>", x.Message, x.StackTrace);
                HostRuntimeException hre = new HostRuntimeException("Retrival.HostRuntime's RealRetrival.Execute method failed.", x);
                ExceptionManager.PublishException(hre, "Error");

                //
                // Uphold failure policy. Save packet to failure directory.
                //
                if (manifest != null)
                {
                    //
                    // Save FlowManifest to failure directory.
                    //
                    string failureDirectory = Path.Combine(settings.FailureDirectory, manifest.GUID.ToString());
                    try
                    {
                        if (Directory.Exists(failureDirectory))
                        {
                            FileSystem.DeleteDirectoryStructure(failureDirectory);
                        }
                        Directory.CreateDirectory(failureDirectory);
                        manifest.ToXmlDocument().Save(Path.Combine(failureDirectory, "FlowManifest.xml"));
                    }
                    catch (StackOverflowException)
                    {
                        throw;
                    }
                    catch (OutOfMemoryException)
                    {
                        throw;
                    }
                    catch (ThreadAbortException)
                    {
                        throw;
                    }
                    catch (Exception x2)
                    {
                        ExceptionManager.PublishException(new HostRuntimeException("Failed to uphold failure policy.", x2), "Error");
                    }
                    //
                    // If log, then log the failed execution.
                    //
                    if (settings.Log && this.LogToEvents)
                    {
                        try
                        {
                            manifest.FlowStatus = FlowStatus.ErrorRetrival;

                            using (MessageQueue mqLog = new MessageQueue(settings.EventsMsmqPath))
                            {
                                mqLog.Formatter = new BinaryMessageFormatter();

                                System.Messaging.Message msgLog = new System.Messaging.Message();
                                msgLog.Formatter = new BinaryMessageFormatter();
                                msgLog.Body      = manifest.ToXmlDocument().OuterXml;
                                msgLog.Label     = manifest.FlowID;

                                mqLog.Send(msgLog);
                            }
                        }
                        catch (StackOverflowException)
                        {
                            throw;
                        }
                        catch (OutOfMemoryException)
                        {
                            throw;
                        }
                        catch (ThreadAbortException)
                        {
                            throw;
                        }
                        catch (Exception x3)
                        {
                            ExceptionManager.PublishException(new HostRuntimeException("Failure logging error to log.", x3), "Error");
                        }
                    } // if ( settings.Log ...
                }     // if ( packet != null ...
            }         // catch ( Exception x ...
            finally
            {
                Thread.CurrentThread.CurrentCulture = cultureInfo;
            }
        }
Exemplo n.º 31
0
        private void F3040_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                if (!e.CloseReason.Equals(CloseReason.ApplicationExitCall))
                {
                    if (e.CloseReason.Equals(CloseReason.UserClosing))
                    {
                        if (this.ZoningSaveButton.Enabled)
                        {
                            switch (MessageBox.Show(SharedFunctions.GetResourceString("CancelForm") + this.AccessibleName + " ?", ConfigurationManager.AppSettings["ApplicationName"].ToString(), MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question))
                            {
                            case DialogResult.Yes:
                            {
                                try
                                {
                                    this.CheckEmptyRowsAvaliable();
                                    ////when save is made this form will close
                                    if (this.saveStatus)
                                    {
                                        this.DialogResult = DialogResult.Cancel;
                                        e.Cancel          = false;
                                    }
                                    else
                                    {
                                        e.Cancel = true;
                                    }
                                }
                                catch (SoapException ex)
                                {
                                    ////TODO : Need to find specific exception and handle it.
                                    ExceptionManager.ManageException(ex, ExceptionManager.ActionType.Display, this.ParentForm);
                                }
                                catch (Exception ex)
                                {
                                    ExceptionManager.ManageException(ex, ExceptionManager.ActionType.Display, this.ParentForm);
                                }

                                break;
                            }

                            case DialogResult.No:
                            {
                                this.DialogResult = DialogResult.Cancel;
                                e.Cancel          = false;
                                break;
                            }

                            case DialogResult.Cancel:
                            {
                                e.Cancel          = true;
                                this.DialogResult = DialogResult.None;
                                break;
                            }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.ManageException(ex, ExceptionManager.ActionType.CloseCurrentForm, this.ParentForm);
            }
        }
        public int CreateUser(UserVo userVo)
        {
            int       userId = 0;
            Database  db;
            DbCommand createUserCmd;

            try
            {
                db            = DatabaseFactory.CreateDatabase("wealtherp");
                createUserCmd = db.GetStoredProcCommand("SP_CreateUser");
                db.AddInParameter(createUserCmd, "@U_Password", DbType.String, userVo.Password);
                db.AddInParameter(createUserCmd, "@U_FirstName", DbType.String, userVo.FirstName.ToString());
                if (userVo.MiddleName != null)
                {
                    db.AddInParameter(createUserCmd, "@U_MiddleName", DbType.String, userVo.MiddleName.ToString());
                }
                else
                {
                    db.AddInParameter(createUserCmd, "@U_MiddleName", DbType.String, DBNull.Value);
                }
                if (userVo.LastName != null)
                {
                    db.AddInParameter(createUserCmd, "@U_LastName", DbType.String, userVo.LastName.ToString());
                }
                else
                {
                    db.AddInParameter(createUserCmd, "@U_LastName", DbType.String, DBNull.Value);
                }

                db.AddInParameter(createUserCmd, "@U_Email", DbType.String, userVo.Email.ToString());

                db.AddInParameter(createUserCmd, "@U_UserType", DbType.String, userVo.UserType.ToString());
                db.AddInParameter(createUserCmd, "@U_LoginId", DbType.String, userVo.LoginId);
                db.AddInParameter(createUserCmd, "@U_CreatedBy", DbType.String, 100);  //temp
                db.AddInParameter(createUserCmd, "@U_ModifiedBy", DbType.String, 100); //temp
                db.AddOutParameter(createUserCmd, "@U_UserId", DbType.Int32, 10);
                if (db.ExecuteNonQuery(createUserCmd) != 0)
                {
                    userId = int.Parse(db.GetParameterValue(createUserCmd, "U_UserId").ToString());
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "UserDao.cs:CreateUser()");


                object[] objects = new object[1];
                objects[0] = userVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
            return(userId);
        }
Exemplo n.º 33
0
        //Laws Lu,2005/10/28,修改	缓解性能问题,改用Reader
        public override void Execute(string commandText, string[] parameters, Type[] parameterTypes, object[] parameterValues)
        {
            OpenConnection();
            using (OdbcCommand command = (OdbcCommand)this.Connection.CreateCommand())
            {
                command.CommandText = this.changeParameterPerfix(commandText);

                for (int i = 0; i < parameters.Length; i++)
                {
                    command.Parameters.Add(parameters[i], CSharpType2OdbcType(parameterTypes[i])).Value = parameterValues[i];
                    //					command.CommandText =   ChangeParameterPerfix(command.CommandText, parameters[i]);
                }
                if (this.Transaction != null)
                {
                    command.Transaction = (OdbcTransaction)this.Transaction;
                }
                DateTime dtStart = new DateTime();
                try
                {
                    //修改	在Debug模式下不允许Log日志文件
#if DEBUG
                    dtStart = DateTime.Now;
                    Log.Info("************StartDateTime:" + dtStart.ToString() + "," + dtStart.Millisecond);
                    Log.Info(" Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#endif
                    command.ExecuteNonQuery();
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif
                }
                catch (System.Data.OleDb.OleDbException e)
                {
                    //added by leon.li @20130311
                    Log.Error(e.StackTrace);
                    //end added
                    Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif

                    if (e.ErrorCode == -2147217873)
                    {
                        ExceptionManager.Raise(this.GetType(), "$ERROR_DATA_ALREADY_EXIST", e);
                    }
                    else
                    {
                        ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                    }
                }
                catch (Exception e)
                {
                    //added by leon.li @20130311
                    Log.Error(e.StackTrace);
                    //end added
                    Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif

                    ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                }
            }
        }
Exemplo n.º 34
0
        public ActionResult Create(CaseProgressNote caseProgressNote, int caseID, int?caseMemberID)
        {
            caseProgressNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
            try
            {
                //if (caseProgressNote.NoteDate > DateTime.Today)
                //{
                //    throw new CustomException("Note date can't be future date.");
                //}

                //validate data
                if (ModelState.IsValid)
                {
                    caseProgressNote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                    caseprogressnoteRepository.InsertOrUpdate(caseProgressNote);
                    caseprogressnoteRepository.Save();

                    if (caseProgressNote.IsInitialContact)
                    {
                        if (caseProgressNote.CaseMembersIds != null && caseProgressNote.CaseMembersIds.Count() > 0)
                        {
                            foreach (var item in caseProgressNote.CaseMembersIds)
                            {
                                CaseProgressNoteMembers caseProgressNoteMembers = new CaseProgressNoteMembers();
                                caseProgressNoteMembers.CaseMemberID       = Convert.ToInt32(item);
                                caseProgressNoteMembers.CaseProgressNoteID = Convert.ToInt32(caseProgressNote.ID);
                                caseProgressNoteMembersRepository.InsertOrUpdate(caseProgressNoteMembers);
                                caseProgressNoteMembersRepository.Save();
                            }
                        }
                        else
                        {
                            throw new CustomException("Select atleast one family member");
                        }
                    }
                    else
                    {
                        if (caseProgressNote.CaseMemberID > 0)
                        {
                            CaseProgressNoteMembers caseProgressNoteMembers = new CaseProgressNoteMembers();
                            caseProgressNoteMembers.CaseMemberID       = caseProgressNote.CaseMemberID;
                            caseProgressNoteMembers.CaseProgressNoteID = Convert.ToInt32(caseProgressNote.ID);
                            caseProgressNoteMembersRepository.InsertOrUpdate(caseProgressNoteMembers);
                            caseProgressNoteMembersRepository.Save();
                        }
                        else
                        {
                            throw new CustomException("Please select family or family member");
                        }
                    }
                    //Audit Log
                    if (caseProgressNote.IsInitialContact)
                    {
                        return(RedirectToAction(Constants.Actions.Index, Constants.Controllers.CaseWorker, new { caseID = caseProgressNote.CaseID, caseMemberID = caseMemberID }));
                    }
                    else
                    {
                        return(RedirectToAction(Constants.Actions.Edit, new { noteID = caseProgressNote.ID, caseID = caseProgressNote.CaseID, caseMemberID = caseMemberID }));
                    }
                }
                else
                {
                    foreach (var modelStateValue in ViewData.ModelState.Values)
                    {
                        foreach (var error in modelStateValue.Errors)
                        {
                            caseProgressNote.ErrorMessage = error.ErrorMessage;
                            break;
                        }
                        if (caseProgressNote.ErrorMessage.IsNotNullOrEmpty())
                        {
                            break;
                        }
                    }
                }
            }
            catch (CustomException ex)
            {
                caseProgressNote.ErrorMessage = ex.UserDefinedMessage;
            }
            catch (Exception ex)
            {
                ExceptionManager.Manage(ex);
                caseProgressNote.ErrorMessage = Constants.Messages.UnhandelledError;
            }
            if (caseMemberID.HasValue && caseMemberID.Value > 0)
            {
                caseProgressNote.CaseMemberID = caseMemberID.Value;
                CaseMember caseMember = casememberRepository.Find(caseProgressNote.CaseMemberID);
                if (caseMember != null)
                {
                    ViewBag.DisplayID = caseMember.DisplayID;
                }
            }
            else
            {
                Case varCase = caseRepository.Find(caseID);
                if (varCase != null)
                {
                    ViewBag.DisplayID = varCase.DisplayID;
                }
            }
            return(View(caseProgressNote));
        }
Exemplo n.º 35
0
        //This method is shared between create and save
        private ActionResult UpdateStaffOrganisation()
        {
            // Get the updated model
            var model = GetUpdatedModel();

            // Test to see if there are any errors
            var errors = ModelState
                         .Where(x => x.Value.Errors.Count > 0)
                         .Select(x => new { x.Key, x.Value.Errors[0].ErrorMessage })
                         .ToArray();

            //Set flags false
            SetFlagsFalse(model);

            // Test to see if the model has validated correctly
            if (ModelState.IsValid)
            {
                // Create service instance
                IUcbService sc = UcbService;

                //Attempt update
                try
                {
                    // Map model to data contract
                    StaffOrganisationDC StaffOrganisationItem = Mapper.Map <StaffOrganisationDC>(model.StaffOrganisationItem);

                    StaffOrganisationVMDC returnedObject = null;

                    if (null == model.StaffOrganisationItem.Code || model.StaffOrganisationItem.Code == Guid.Empty)
                    {
                        // Call service to create new StaffOrganisation item
                        returnedObject = sc.CreateStaffOrganisation(CurrentUser, CurrentUser, appID, "", StaffOrganisationItem);
                    }
                    else
                    {
                        // Call service to update StaffOrganisation item
                        returnedObject = sc.UpdateStaffOrganisation(CurrentUser, CurrentUser, appID, "", StaffOrganisationItem);
                    }

                    // Close service communication
                    ((ICommunicationObject)sc).Close();

                    // Retrieve item returned by service
                    var createdStaffOrganisation = returnedObject.StaffOrganisationItem;

                    // Map data contract to model
                    model.StaffOrganisationItem = Mapper.Map <StaffOrganisationModel>(createdStaffOrganisation);

                    //After creation some of the fields are display only so we need the resolved look up nmames
                    ResolveFieldCodesToFieldNamesUsingLists(model);

                    // Set access context to Edit mode
                    model.AccessContext = StaffOrganisationAccessContext.Edit;

                    // Save version of item returned by service into session
                    sessionManager.StaffOrganisationServiceVersion = model.StaffOrganisationItem;
                    sessionManager.CurrentStaffOrganisation        = model.StaffOrganisationItem;

                    // Remove the state from the model as these are being populated by the controller and the HTML helpers are being populated with
                    // the POSTED values and not the changed ones.
                    ModelState.Clear();
                    model.Message = Resources.MESSAGE_UPDATE_SUCCEEDED;
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                    model.Message = message;

                    return(View(model));
                }
            }

            return(View(model));
        }
Exemplo n.º 36
0
        public ActionResult SaveAjax(CaseProgressNote caseprogressnote)
        {
            //id=0 means add operation, update operation otherwise
            bool isNew = caseprogressnote.ID == 0;

            //validate data
            if (ModelState.IsValid)
            {
                if (caseprogressnote.NoteDate > DateTime.Today)
                {
                    throw new CustomException("Note date can't be future date.");
                }
                try
                {
                    //<JL:Comment:No need to check access again on post. On edit we are already checking permission.>
                    //if (caseprogressnote.ID > 0 && caseprogressnote.CreatedByWorkerID != CurrentLoggedInWorker.ID && CurrentLoggedInWorkerRoleIDs.IndexOf(1) == -1 && (CurrentLoggedInWorkerRoleIDs.IndexOf(SiteConfigurationReader.RegionalManagerRoleID) == -1))
                    //{
                    //    WebHelper.CurrentSession.Content.ErrorMessage = "You are not eligible to do this action";
                    //    return Json(new { success = true, url = Url.Action(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty }) });
                    //    //return RedirectToAction(Constants.Actions.AccessDenied, Constants.Controllers.Home, new { Area = String.Empty });
                    //}
                    //</JL:Comment:07/08/2017>

                    caseprogressnote.LastUpdatedByWorkerID = CurrentLoggedInWorker.ID;
                    caseprogressnoteRepository.InsertOrUpdate(caseprogressnote);
                    caseprogressnoteRepository.Save();
                    //Audit log
                    var caseprogressmembers = caseProgressNoteMembersRepository.SearchMembers(caseprogressnote.ID);
                    foreach (var item in caseprogressmembers)
                    {
                        caseProgressNoteMembersRepository.Delete(item);
                    }
                    if (caseprogressnote.CaseMembersIds != null && caseprogressnote.CaseMembersIds.Count() > 0)
                    {
                        foreach (var item in caseprogressnote.CaseMembersIds)
                        {
                            CaseProgressNoteMembers caseProgressNoteMembers = new CaseProgressNoteMembers();
                            caseProgressNoteMembers.CaseMemberID       = Convert.ToInt32(item);
                            caseProgressNoteMembers.CaseProgressNoteID = Convert.ToInt32(caseprogressnote.ID);
                            caseProgressNoteMembersRepository.InsertOrUpdate(caseProgressNoteMembers);
                            caseProgressNoteMembersRepository.Save();
                        }
                    }


                    if (isNew)
                    {
                        caseprogressnote.SuccessMessage = "Case Progress Note has been added successfully";
                    }
                    else
                    {
                        caseprogressnote.SuccessMessage = "Case Progress Note has been updated successfully";
                    }
                }
                catch (CustomException ex)
                {
                    caseprogressnote.ErrorMessage = ex.UserDefinedMessage;
                }
                catch (Exception ex)
                {
                    ExceptionManager.Manage(ex);
                    caseprogressnote.ErrorMessage = Constants.Messages.UnhandelledError;
                }
            }
            else
            {
                foreach (var modelStateValue in ViewData.ModelState.Values)
                {
                    foreach (var error in modelStateValue.Errors)
                    {
                        caseprogressnote.ErrorMessage = error.ErrorMessage;
                        break;
                    }
                    if (caseprogressnote.ErrorMessage.IsNotNullOrEmpty())
                    {
                        break;
                    }
                }
            }
            //return the status message in json
            if (caseprogressnote.ErrorMessage.IsNotNullOrEmpty())
            {
                return(Json(new { success = false, data = this.RenderPartialViewToString(Constants.PartialViews.Alert, caseprogressnote) }));
            }
            else
            {
                return(Json(new { success = true, data = this.RenderPartialViewToString(Constants.PartialViews.Alert, caseprogressnote) }));
            }
        }
Exemplo n.º 37
0
        public ActionResult DeleteStaffOrganisation(FormCollection collection)
        {
            var model = GetUpdatedModel();

            if (model.IsDeleteConfirmed == "True")
            {
                //Set flags false
                SetFlagsFalse(model);

                model.IsDeleteConfirmed = "False";

                // Create service instance
                IUcbService sc = UcbService;

                try
                {
                    // Call service to delete the item
                    sc.DeleteStaffOrganisation(CurrentUser, CurrentUser, appID, "", model.StaffOrganisationItem.Code.ToString(), model.StaffOrganisationItem.RowIdentifier.ToString());

                    // Close service communication
                    ((ICommunicationObject)sc).Close();

                    // Remove the current values from session
                    sessionManager.CurrentStaffOrganisation        = null;
                    sessionManager.StaffOrganisationServiceVersion = null;

                    // Remove the state from the model as these are being populated by the controller and the HTML helpers are being populated with
                    // the POSTED values and not the changed ones.
                    ModelState.Clear();

                    // Create new item but keep any lists
                    model.StaffOrganisationItem = new StaffOrganisationModel();

                    // Set message to return to user
                    model.Message = Resources.MESSAGE_DELETE_SUCCEEDED;

                    // Set access context to Edit mode
                    model.AccessContext = StaffOrganisationAccessContext.Create;

                    // Redirect to the search screen
                    return(View(model));
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                    model.Message = message;

                    return(View(model));
                }
            }
            else
            {
                //Set flags false
                SetFlagsFalse(model);
                model.Message           = Resources.MESSAGE_DELETECONFIRMATION;
                model.IsDeleteConfirmed = "True";
            }

            return(View(model));
        }
        public override bool OnCommandSave()
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                // do you want to save?
                if (MessageDialog.ShowConfirmationMsg(this, Util.GetMessageText(eMsgId.COM0001)) != DialogButton.Yes)
                {
                    return(false);
                }

                AppEnvironment.Database.BeginTrans();
                // End

                // TODO : ¶éÒà¡Ô´µÃǨÊͺ¢éÍÁÙÅàÃÕºÃéÍÂáÅéÇ ¡ç¨Ð·Ó¡Òà save â´Â¢Öé¹ÍÂÙè¡Ñº screen mode
                UserGroupDTO data = new UserGroupDTO();
                data.GroupName   = txtGroupName.Text;
                data.Description = txtDescription.Text;
                data.CreateUser  = AppEnvironment.UserLogin;
                data.UpdateUser  = AppEnvironment.UserLogin;
                data.GroupID     = -1;
                switch (ScreenMode)
                {
                case eScreenMode.Add:
                    data.GroupID = BizUserGroup.AddNew(data);
                    break;

                case eScreenMode.Edit:
                    data.GroupID = Convert.ToInt32(gvResult.CurrentRow.Cells[(int)eColDetail.GroupID].Value);
                    BizUserGroup.Update(data);
                    break;
                }
                // Update GroupMapping
                BizUserGroup.UpdateGroupMapping(data.GroupID, UserIDFromListView());

                // Wirachai T. 2008 05 30
                AppEnvironment.Database.CommitTrans();
                // End


                // »ÃѺ»Ãا mode ¢Í§ screen »Ñ¨¨ºÑ¹
                OnCommandRefresh();
                SetScreenMode(eScreenMode.View);

                return(true);
            }
            catch (BusinessException ex)
            {
                if (AppEnvironment.Database.HasTransaction)
                {
                    AppEnvironment.Database.RollbackTrans();
                }

                ExceptionManager.ManageException(this, ex);
                return(false);
            }
            catch (Exception ex)
            {
                if (AppEnvironment.Database.HasTransaction)
                {
                    AppEnvironment.Database.RollbackTrans();
                }

                ExceptionManager.ManageException(this, ex);
                return(false);
            }
            finally
            {
                this.Cursor      = Cursors.Default;
                gvResult.Enabled = true;
            }
        }
Exemplo n.º 39
0
 public UserRepository(IProfileStore profileStore, ExceptionManager exManager, IUnityContainer container)
 {
     this.profileStore = profileStore;
     this.exManager = exManager;
     this.container = container;
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                if (Validation())
                {
                    rmId = rmVo.RMId;
                    if (Session["Current_Link"].ToString() == "RMLeftPane")
                    {
                        userVo = (UserVo)Session["UserVo"];


                        txtDateofProfiling.Text = DateTime.Today.Date.ToString();

                        customerVo.ContactFirstName  = txtFirstName.Text.ToString();
                        customerVo.ContactMiddleName = txtMiddleName.Text.ToString();
                        customerVo.ContactLastName   = txtLastName.Text.ToString();
                        customerVo.FirstName         = txtCompanyName.Text.ToString();
                        customerVo.CompanyName       = txtCompanyName.Text.ToString();
                        customerVo.CustCode          = txtCustomerCode.Text.ToString();
                        //customerVo.Salutation = ddlSalutation.SelectedItem.Value.ToString();
                        if (txtDateofRegistration.Text != "")
                        {
                            customerVo.RegistrationDate = DateTime.Parse(txtDateofRegistration.Text.ToString());
                        }
                        else
                        {
                            customerVo.RegistrationDate = DateTime.MinValue;
                        }
                        if (txtDateofCommencement.Text != "")
                        {
                            customerVo.CommencementDate = DateTime.Parse(txtDateofCommencement.Text.ToString());
                        }
                        else
                        {
                            customerVo.CommencementDate = DateTime.MinValue;
                        }
                        if (txtDateofProfiling.Text != "")
                        {
                            customerVo.ProfilingDate = DateTime.Parse(txtDateofProfiling.Text.ToString());
                        }
                        else
                        {
                            customerVo.ProfilingDate = DateTime.MinValue;
                        }
                        customerVo.RegistrationPlace = txtRegistrationPlace.Text.ToString();
                        customerVo.CompanyWebsite    = txtCompanyWebsite.Text.ToString();
                        customerVo.RmId            = rmId;
                        customerVo.PANNum          = txtPanNumber.Text.ToString();
                        customerVo.RegistrationNum = txtRocRegistration.Text.ToString();
                        customerVo.Adr1Line1       = txtCorrAdrLine1.Text.ToString();
                        customerVo.Adr1Line2       = txtCorrAdrLine2.Text.ToString();
                        customerVo.Adr1Line3       = txtCorrAdrLine3.Text.ToString();
                        customerVo.Adr1PinCode     = int.Parse(txtCorrAdrPinCode.Text.ToString());
                        customerVo.Adr1City        = txtCorrAdrCity.Text.ToString();
                        customerVo.Adr1State       = ddlCorrAdrState.SelectedItem.Value.ToString();
                        customerVo.Adr1Country     = ddlCorrAdrCountry.SelectedItem.Value.ToString();
                        if (chkCorrPerm.Checked)
                        {
                            customerVo.Adr2Line1   = txtCorrAdrLine1.Text.ToString();
                            customerVo.Adr2Line2   = txtCorrAdrLine2.Text.ToString();
                            customerVo.Adr2Line3   = txtCorrAdrLine3.Text.ToString();
                            customerVo.Adr2PinCode = int.Parse(txtCorrAdrPinCode.Text.ToString());
                            customerVo.Adr2City    = txtCorrAdrCity.Text.ToString();
                            customerVo.Adr2State   = ddlCorrAdrState.Text.ToString();
                            customerVo.Adr2Country = ddlCorrAdrCountry.Text.ToString();
                        }
                        else
                        {
                            customerVo.Adr2Line1   = txtPermAdrLine1.Text.ToString();
                            customerVo.Adr2Line2   = txtPermAdrLine2.Text.ToString();
                            customerVo.Adr2Line3   = txtPermAdrLine3.Text.ToString();
                            customerVo.Adr2PinCode = int.Parse(txtPermAdrPinCode.Text.ToString());
                            customerVo.Adr2City    = txtPermAdrCity.Text.ToString();
                            customerVo.Adr2State   = ddlPermAdrState.Text.ToString();
                            customerVo.Adr2Country = ddlPermAdrCountry.Text.ToString();
                        }
                        customerVo.ResISDCode    = int.Parse(txtPhoneNo1Isd.Text.ToString());
                        customerVo.ResSTDCode    = int.Parse(txtPhoneNo1Std.Text.ToString());
                        customerVo.ResPhoneNum   = int.Parse(txtPhoneNo1.Text.ToString());
                        customerVo.OfcISDCode    = int.Parse(txtPhoneNo2Isd.Text.ToString());
                        customerVo.OfcSTDCode    = int.Parse(txtPhoneNo2Std.Text.ToString());
                        customerVo.OfcPhoneNum   = int.Parse(txtPhoneNo2.Text.ToString());
                        customerVo.Fax           = int.Parse(txtFax.Text.ToString());
                        customerVo.ISDFax        = int.Parse(txtFaxIsd.Text.ToString());
                        customerVo.STDFax        = int.Parse(txtFaxStd.Text.ToString());
                        customerVo.Email         = txtEmail.Text.ToString();
                        customerVo.MaritalStatus = null;
                        Session["Customer"]      = "Customer";
                        //  customerBo.CreateCustomer(customerVo, customerVo.RmId,userVo.UserId);
                        if (Session["customerIds"] != null)
                        {
                            List <int> customerIds = new List <int>();
                            //int customerId = customerIds[1];
                            customerIds           = (List <int>)Session["CustomerIds"];
                            customerVo.CustomerId = customerIds[1];
                            customerBo.UpdateCustomer(customerVo);
                            Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('RMCustomer','none');", true);
                            // Session.Remove("CustomerIds");
                        }



                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('RMCustomer','none');", true);
                    }

                    else if (Session["Current_Link"].ToString() == "RMCustomerNonIndividualLeftPane")
                    {
                        CustomerVo newCustomerVo = new CustomerVo();
                        UserVo     newUserVo     = new UserVo();

                        newUserVo.FirstName  = txtFirstName.Text.ToString();
                        newUserVo.MiddleName = txtMiddleName.Text.ToString();
                        newUserVo.LastName   = txtLastName.Text.ToString();
                        newUserVo.Email      = txtEmail.Text.ToString();
                        newUserVo.UserType   = "Customer";

                        customerVo.FirstName  = txtFirstName.Text.ToString();
                        customerVo.MiddleName = txtMiddleName.Text.ToString();
                        customerVo.LastName   = txtLastName.Text.ToString();

                        if (txtEmail.Text == "")
                        {
                            customerVo.Email = txtFirstName.Text.ToString() + "@mail.com";
                        }
                        else
                        {
                            customerVo.Email = txtEmail.Text.ToString();
                        }
                        newCustomerVo.Type = "NIND";

                        txtDateofProfiling.Text = DateTime.Today.Date.ToString();

                        if (txtDateofRegistration.Text != "")
                        {
                            customerVo.RegistrationDate = DateTime.Parse(txtDateofRegistration.Text.ToString());
                        }
                        else
                        {
                            customerVo.RegistrationDate = DateTime.MinValue;
                        }
                        if (txtDateofCommencement.Text != "")
                        {
                            customerVo.CommencementDate = DateTime.Parse(txtDateofCommencement.Text.ToString());
                        }
                        else
                        {
                            customerVo.CommencementDate = DateTime.MinValue;
                        }
                        if (txtDateofProfiling.Text != "")
                        {
                            customerVo.ProfilingDate = DateTime.Parse(txtDateofProfiling.Text.ToString());
                        }
                        else
                        {
                            customerVo.ProfilingDate = DateTime.MinValue;
                        }

                        newCustomerVo.FirstName   = txtFirstName.Text.ToString();
                        newCustomerVo.MiddleName  = txtMiddleName.Text.ToString();
                        newCustomerVo.LastName    = txtLastName.Text.ToString();
                        newCustomerVo.CompanyName = txtCompanyName.Text.ToString();
                        newCustomerVo.CustCode    = txtCustomerCode.Text.ToString();
                        newCustomerVo.Salutation  = ddlSalutation.SelectedItem.Value.ToString();

                        newCustomerVo.RegistrationPlace = txtRegistrationPlace.Text.ToString();
                        newCustomerVo.CompanyWebsite    = txtCompanyWebsite.Text.ToString();
                        newCustomerVo.RmId            = rmId;
                        newCustomerVo.PANNum          = txtPanNumber.Text.ToString();
                        newCustomerVo.RegistrationNum = txtRocRegistration.Text.ToString();
                        newCustomerVo.Adr1Line1       = txtCorrAdrLine1.Text.ToString();
                        newCustomerVo.Adr1Line2       = txtCorrAdrLine2.Text.ToString();
                        newCustomerVo.Adr1Line3       = txtCorrAdrLine3.Text.ToString();
                        newCustomerVo.Adr1PinCode     = int.Parse(txtCorrAdrPinCode.Text.ToString());
                        newCustomerVo.Adr1City        = txtCorrAdrCity.Text.ToString();
                        if (ddlCorrAdrState.SelectedIndex != 0)
                        {
                            newCustomerVo.Adr1State = ddlCorrAdrState.SelectedItem.Value.ToString();
                        }
                        else
                        {
                            newCustomerVo.Adr1State = null;
                        }
                        newCustomerVo.Adr1Country = ddlCorrAdrCountry.SelectedItem.Value.ToString();
                        if (chkCorrPerm.Checked)
                        {
                            newCustomerVo.Adr2Line1   = txtCorrAdrLine1.Text.ToString();
                            newCustomerVo.Adr2Line2   = txtCorrAdrLine2.Text.ToString();
                            newCustomerVo.Adr2Line3   = txtCorrAdrLine3.Text.ToString();
                            newCustomerVo.Adr2PinCode = int.Parse(txtCorrAdrPinCode.Text.ToString());
                            newCustomerVo.Adr2City    = txtCorrAdrCity.Text.ToString();
                            if (ddlCorrAdrState.SelectedIndex != 0)
                            {
                                newCustomerVo.Adr2State = ddlCorrAdrState.Text.ToString();
                            }
                            else
                            {
                                newCustomerVo.Adr2State = null;
                            }
                            newCustomerVo.Adr2Country = ddlCorrAdrCountry.Text.ToString();
                        }
                        else
                        {
                            newCustomerVo.Adr2Line1   = txtPermAdrLine1.Text.ToString();
                            newCustomerVo.Adr2Line2   = txtPermAdrLine2.Text.ToString();
                            newCustomerVo.Adr2Line3   = txtPermAdrLine3.Text.ToString();
                            newCustomerVo.Adr2PinCode = int.Parse(txtPermAdrPinCode.Text.ToString());
                            newCustomerVo.Adr2City    = txtPermAdrCity.Text.ToString();
                            if (ddlPermAdrState.SelectedIndex != 0)
                            {
                                newCustomerVo.Adr2State = ddlPermAdrState.Text.ToString();
                            }
                            else
                            {
                                newCustomerVo.Adr2State = null;
                            }
                            newCustomerVo.Adr2Country = ddlPermAdrCountry.Text.ToString();
                        }
                        newCustomerVo.ResISDCode    = int.Parse(txtPhoneNo1Isd.Text.ToString());
                        newCustomerVo.ResSTDCode    = int.Parse(txtPhoneNo1Std.Text.ToString());
                        newCustomerVo.ResPhoneNum   = int.Parse(txtPhoneNo1.Text.ToString());
                        newCustomerVo.OfcISDCode    = int.Parse(txtPhoneNo2Isd.Text.ToString());
                        newCustomerVo.OfcSTDCode    = int.Parse(txtPhoneNo2Std.Text.ToString());
                        newCustomerVo.OfcPhoneNum   = int.Parse(txtPhoneNo2.Text.ToString());
                        newCustomerVo.Fax           = int.Parse(txtFax.Text.ToString());
                        newCustomerVo.ISDFax        = int.Parse(txtFaxIsd.Text.ToString());
                        newCustomerVo.STDFax        = int.Parse(txtFaxStd.Text.ToString());
                        newCustomerVo.Email         = txtEmail.Text.ToString();
                        newCustomerVo.MaritalStatus = null;


                        customerPortfolioVo.CustomerId        = customerFamilyVo.AssociateCustomerId;
                        customerPortfolioVo.IsMainPortfolio   = 1;
                        customerPortfolioVo.PortfolioTypeCode = "RGL";
                        customerPortfolioVo.PMSIdentifier     = "";
                        customerPortfolioVo.PortfolioName     = "Default";



                        List <int> CustomerIds = new List <int>();
                        CustomerIds = customerBo.CreateCompleteCustomer(newCustomerVo, newUserVo, customerPortfolioVo, userVo.UserId);
                        customerFamilyVo.AssociateCustomerId = CustomerIds[1];
                        customerFamilyVo.Relationship        = Session["relationship"].ToString();


                        customerFamilyBo.CreateCustomerFamily(customerFamilyVo, customerVo.CustomerId, userVo.UserId);
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "leftpane", "loadcontrol('RMCustomer','none');", true);
                    }
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }

            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "CustomerNonIndividualAdd.ascx:btnSubmit_Click()");
                object[] objects = new object[4];
                objects[0] = rmVo;
                objects[1] = rmId;
                objects[2] = customerVo;
                objects[3] = userVo;

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Exemplo n.º 41
0
        public override int ExecuteWithReturn(string commandText, string[] parameters, Type[] parameterTypes, object[] parameterValues)
        {
            int iReturn = 0;

            OpenConnection();
            using (OracleCommand command = (OracleCommand)this.Connection.CreateCommand())
            {
                command.CommandText = this.changeParameterPerfix(commandText);

                for (int i = 0; i < parameters.Length; i++)
                {
                    command.Parameters.Add(parameters[i], CSharpType2OracleType(parameterTypes[i])).Value = parameterValues[i];
                    //					command.CommandText =   ChangeParameterPerfix(command.CommandText, parameters[i]);
                }
                if (this.Transaction != null)
                {
                    //command.Transaction = (OracleTransaction)this.Transaction;
                }
                DateTime dtStart = new DateTime();
                try
                {
                    //修改	在Debug模式下不允许Log日志文件
#if DEBUG
                    dtStart = DateTime.Now;
                    Log.Info("************StartDateTime:" + dtStart.ToString() + "," + dtStart.Millisecond);
                    Log.Info(" Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#endif
                    iReturn = command.ExecuteNonQuery();
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif
                }
                catch (Oracle.DataAccess.Client.OracleException e)
                {
                    //added by leon.li @20130311
                    Log.Error(e.StackTrace);
                    //end added
                    Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif
                }
                catch (Exception e)
                {
                    //added by leon.li @20130311
                    Log.Error(e.StackTrace);
                    //end added
                    Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif

                    ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                }
                finally
                {
                    if (this.Transaction == null)
                    {
                        CloseConnection();
                    }
                }
                return(iReturn);
            }
        }
        public string CheckIn(Reserva res)
        {
            string salida       = "";
            int    idHabitacion = res.IdHabitacion;
            string idHotel      = res.IdHotel;
            int    codigoRes    = res.Codigo;

            var crudReserva = new ReservaCrudFactory();

            var llave = new LlaveQR()
            {
                CodigoQR = res.idQR
            };

            try
            {
                llave = crudLlaveQR.Retrieve <LlaveQR>(llave);
                if (llave == null)
                {
                    // La llave QR no existe
                    throw new BussinessException(20);
                }

                var reserva = new Reserva()
                {
                    Codigo = llave.IdReserva
                };

                res = crudReserva.Retrieve <Reserva>(reserva);
                res.IdHabitacion = idHabitacion;

                if (res.IdHotel.Equals(idHotel) && llave.IdReserva == codigoRes)
                {
                    switch (llave.EstadoQR)
                    {
                    case "2":
                        // La llave QR se encuentra inactiva
                        throw new BussinessException(57);

                    case "3":
                        // La llave QR ya expiró
                        throw new BussinessException(58);
                    }

                    switch (res.Estado)
                    {
                    case "0":
                        // La reserva ya terminó!
                        throw new BussinessException(18);

                    case "1":
                        salida = "Adelante!";
                        break;

                    case "2":
                        if (res.FechaInicio.Date.CompareTo(DateTime.Now.Date) <= 0)
                        {
                            salida     = "Check in exitoso!";
                            res.Estado = "1";
                            crudReserva.Update(res);
                        }
                        else
                        {
                            // La fecha no es válida!
                            throw new BussinessException(19);
                        }

                        break;

                    case "3":
                        // La reserva está cancelada!
                        throw new BussinessException(18);
                    }
                }
                else
                {
                    // El código no pertenece a esta reservación
                    throw new BussinessException(23);
                }
            }
            catch (Exception ex)
            {
                ExceptionManager.GetInstance().Process(ex);
            }

            return(salida);
        }
Exemplo n.º 43
0
        public override DataSet Query(string commandText, string[] parameters, Type[] parameterTypes, object[] parameterValues)
        {
            OpenConnection();
            //OleDbDataAdapter dataAdapter = (OleDbDataAdapter)this.GetDbDataAdapter();
            using (OracleCommand command = (OracleCommand)this.Connection.CreateCommand())
            {
                command.CommandText = this.changeParameterPerfix(commandText);

                for (int i = 0; i < parameters.Length; i++)
                {
                    command.Parameters.Add(parameters[i], CSharpType2OracleType(parameterTypes[i])).Value = parameterValues[i];
                    //					dataAdapter.SelectCommand.CommandText = ChangeParameterPerfix(dataAdapter.SelectCommand.CommandText, parameters[i]);
                }
                if (this.Transaction != null)
                {
//					command.Transaction = (OracleTransaction)this.Transaction;
                }

                DataSet          dataSet = new DataSet();
                DateTime         dtStart = new DateTime();
                OracleDataReader reader  = null;
                try
                {
                    //修改	在Debug模式下不允许Log日志文件
#if DEBUG
                    dtStart = DateTime.Now;
                    Log.Info("************StartDateTime:" + dtStart.ToString() + "," + dtStart.Millisecond);
                    Log.Info(" Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#endif

                    reader = command.ExecuteReader();
                    //command.

#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif


                    DataTable dt = new DataTable();
                    while (reader.Read())
                    {
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            if (!dt.Columns.Contains(reader.GetName(i)))
                            {
                                DataColumn dc = new DataColumn(reader.GetName(i), reader.GetFieldType(i));

                                dt.Columns.Add(dc);
                            }
                        }

                        DataRow dr = dt.NewRow();
                        for (int i = 0; i < reader.FieldCount; i++)
                        {
                            /*
                             * if(reader.GetValue(i) is String)
                             * {
                             *      string dbValue = reader.GetValue(i).ToString();
                             *      dbValue = dbValue.Replace("\0","");
                             *      dbValue = dbValue.Replace("\r\n","");
                             *      dbValue = dbValue.Replace("\r","");
                             *      dbValue = dbValue.Replace("\n","");
                             *      dr[reader.GetName(i)] = dbValue ;
                             * }
                             * else
                             * {
                             *      dr[reader.GetName(i)] = reader.GetValue(i);
                             * }
                             */
                            object objOraVal = reader.GetOracleValue(i);
                            if (objOraVal is Oracle.DataAccess.Types.OracleString)
                            {
                                string dbValue = objOraVal.ToString();
                                dbValue = dbValue.Replace("\0", "");
                                dbValue = dbValue.Replace("\r\n", "");
                                dbValue = dbValue.Replace("\r", "");
                                dbValue = dbValue.Replace("\n", "");
                                dr[reader.GetName(i)] = dbValue;
                            }
                            else
                            {
                                if ((dt.Columns[i].DataType == typeof(int) ||
                                     dt.Columns[i].DataType == typeof(decimal)) &&
                                    (objOraVal == DBNull.Value || objOraVal.ToString() == string.Empty))
                                {
                                    dr[reader.GetName(i)] = 0;
                                }
                                else
                                {
                                    dr[reader.GetName(i)] = objOraVal.ToString();
                                }
                            }
                        }
                        dt.Rows.Add(dr);
                    }
                    reader.Close();
                    dataSet.Tables.Add(dt);
                    //dataSet.Tables.Add(dt);

                    //dataAdapter.Fill(dataSet);
                }
                catch (Exception e)
                {
                    reader.Close();
                    //added by leon.li @20130311
                    Log.Error(e.StackTrace);
                    //end added
                    Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif

                    ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                }
                finally
                {
                    if (this.Transaction == null)
                    {
                        CloseConnection();
                    }
                }

                return(dataSet);
            }
        }
Exemplo n.º 44
0
        /// <summary>
        /// Sets the global exception manager.
        /// </summary>
        /// <param name="exceptionManager">The exception manager.</param>
        /// <param name="throwIfSet"><see langword="true"/> to throw an exception if the manager is already set; otherwise, <see langword="false"/>. Defaults to <see langword="true"/>.</param>
        /// <exception cref="InvalidOperationException">The manager is already set and <paramref name="throwIfSet"/> is <see langword="true"/>.</exception>
        public static void SetExceptionManager(ExceptionManager exceptionManager, bool throwIfSet = true)
        {
            var currentExceptionManager = ExceptionPolicy.exceptionManager;
            if (currentExceptionManager != null && throwIfSet)
            {
                throw new InvalidOperationException(Resources.ExceptionManagerAlreadySet);
            }

            ExceptionPolicy.exceptionManager = exceptionManager;
        }
Exemplo n.º 45
0
 protected override void Act()
 {
     this.manager = this.factory.CreateManager();
 }
Exemplo n.º 46
0
        static void Main(string[] args)
        {
            #region Resolve the required object

            // Resolve the default ExceptionManager object from the container.
            exManager = EnterpriseLibraryContainer.Current.GetInstance<ExceptionManager>();

            #endregion

            #region Main menu routines

            var app = new MenuDrivenApplication("Exception Handling Block Developer's Guide Examples",
                DefaultNoExceptionShielding,
                WithWrapExceptionShielding,
                WithReplaceExceptionShielding,
                LoggingTheException,
                ShieldingExceptionsInWCF,
                ExecutingCodeAroundException,
                ProvidingAdminAssistance);

            app.Run();

            #endregion
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            List <int> customerIds = null;

            try
            {
                if (chkdummypan.Checked)
                {
                    customerVo.DummyPAN = 1;
                }
                else
                {
                    customerVo.DummyPAN = 0;
                }
                Nullable <DateTime> dt = new DateTime();
                customerIds             = new List <int>();
                lblPanDuplicate.Visible = false;
                if (Validation())
                {
                    lblPanDuplicate.Visible = false;
                    userVo = new UserVo();
                    if (rbtnIndividual.Checked)
                    {
                        rmVo            = (RMVo)Session["rmVo"];
                        tempUserVo      = (UserVo)Session["userVo"];
                        customerVo.RmId = rmVo.RMId;
                        if (customerVo.RmId == rmVo.RMId)
                        {
                            customerVo.RmId = int.Parse(ddlAdviseRMList.SelectedValue.ToString());
                        }
                        else
                        {
                            customerVo.RmId = int.Parse(ddlAdviseRMList.SelectedValue);
                        }
                        customerVo.Type = "IND";

                        customerVo.TaxStatusCustomerSubTypeId = Int16.Parse(ddlCustomerSubType.SelectedValue.ToString());
                        customerVo.CustCode       = txtClientCode.Text.Trim();
                        customerVo.IsRealInvestor = chkRealInvestor.Checked;
                        customerVo.FirstName      = txtFirstName.Text.ToString();
                        customerVo.MiddleName     = txtMiddleName.Text.ToString();
                        customerVo.LastName       = txtLastName.Text.ToString();
                        if (ddlSalutation.SelectedIndex == 0)
                        {
                            customerVo.Salutation = "";
                        }
                        else
                        {
                            customerVo.Salutation = ddlSalutation.SelectedValue.ToString();
                        }

                        userVo.FirstName  = txtFirstName.Text.ToString();
                        userVo.MiddleName = txtMiddleName.Text.ToString();
                        userVo.LastName   = txtLastName.Text.ToString();
                    }
                    else if (rbtnNonIndividual.Checked)
                    {
                        rmVo       = (RMVo)Session["rmVo"];
                        tempUserVo = (UserVo)Session["userVo"];
                        //customerVo.RmId = rmVo.RMId;
                        //customerVo.RmId = int.Parse(ddlAdviseRMList.SelectedValue.ToString());
                        if (customerVo.RmId == rmVo.RMId)
                        {
                            customerVo.RmId = int.Parse(ddlAdviseRMList.SelectedValue.ToString());
                        }
                        else
                        {
                            customerVo.RmId = int.Parse(ddlAdviseRMList.SelectedValue);
                        }
                        customerVo.Type = "NIND";

                        customerVo.TaxStatusCustomerSubTypeId = Int16.Parse(ddlCustomerSubType.SelectedValue.ToString());
                        customerVo.CustCode       = txtClientCode.Text.Trim();
                        customerVo.IsRealInvestor = chkRealInvestor.Checked;
                        customerVo.CompanyName    = txtCompanyName.Text.ToString();
                        customerVo.FirstName      = txtCompanyName.Text.ToString();
                        userVo.FirstName          = txtCompanyName.Text.ToString();
                    }
                    if (customerVo.BranchId == rmVo.BranchId)
                    {
                        customerVo.BranchId = int.Parse(ddlAdviserBranchList.SelectedValue);
                    }
                    else
                    {
                        customerVo.BranchId = int.Parse(ddlAdviserBranchList.SelectedValue);
                    }

                    //if (chkprospect.Checked)
                    //{
                    //    customerVo.IsProspect = 1;
                    //}
                    //else
                    //{
                    //    customerVo.IsProspect = 0;
                    //}

                    //customerVo.SubType = ddlCustomerSubType.SelectedItem.Value;
                    customerVo.Email  = txtEmail.Text.ToString();
                    customerVo.PANNum = txtPanNumber.Text.ToString();
                    if (!string.IsNullOrEmpty(txtMobileNumber.Text.ToString()))
                    {
                        customerVo.Mobile1 = Convert.ToInt64(txtMobileNumber.Text.ToString());
                    }
                    else
                    {
                        customerVo.Mobile1 = 0;
                    }
                    customerVo.Dob              = DateTime.MinValue;
                    customerVo.RBIApprovalDate  = DateTime.MinValue;
                    customerVo.CommencementDate = DateTime.MinValue;
                    customerVo.RegistrationDate = DateTime.MinValue;
                    customerVo.Adr1State        = null;
                    customerVo.Adr2State        = null;
                    customerVo.ProfilingDate    = DateTime.Today;
                    customerVo.UserId           = userVo.UserId;
                    userVo.Email = txtEmail.Text.ToString();
                    customerPortfolioVo.IsMainPortfolio   = 1;
                    customerPortfolioVo.PortfolioTypeCode = "RGL";
                    customerPortfolioVo.PortfolioName     = "MyPortfolio";
                    customerVo.ViaSMS   = 1;
                    customerIds         = customerBo.CreateCompleteCustomer(customerVo, userVo, customerPortfolioVo, tempUserVo.UserId);
                    Session["Customer"] = "Customer";

                    if (customerIds != null)
                    {
                        CustomerFamilyVo familyVo = new CustomerFamilyVo();
                        CustomerFamilyBo familyBo = new CustomerFamilyBo();
                        familyVo.AssociateCustomerId = customerIds[1];
                        familyVo.CustomerId          = customerIds[1];
                        familyVo.Relationship        = "SELF";
                        familyBo.CreateCustomerFamily(familyVo, customerIds[1], userVo.UserId);

                        if (page == "Entry")
                        {
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "leftpane", "loadcontrol('OrderEntry','?CustomerId=" + familyVo.CustomerId + " ');", true);
                        }
                        else
                        {
                            ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "MyScript", "alert('Customer Added Successfully!!');", true);
                        }
                        ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "leftpane", "loadcontrol('AdviserCustomer','none');", true);
                        //trSumbitSuccess.Visible = true;
                        MakeReadonlyControls();
                        if (Request.QueryString["AddMFCustLinkId"] != null)
                        {
                            lblPanDuplicate.Visible = false;
                            MakeReadonlyControls();
                            Response.Write("<script>alert('Customer has been successfully added');</script>");
                            Response.Write("<script>window.close();</" + "script>");
                        }
                    }
                }
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();
                FunctionInfo.Add("Method", "CustomerType.ascx:btnSubmit_Click()");
                object[] objects = new object[5];
                objects[0]   = customerIds;
                objects[1]   = customerVo;
                objects[2]   = rmVo;
                objects[3]   = userVo;
                objects[4]   = customerPortfolioVo;
                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
Exemplo n.º 48
0
        public override void Execute(string commandText, string[] parameters, Type[] parameterTypes, object[] parameterValues)
        {
            OpenConnection();
            using (OracleCommand command = (OracleCommand)this.Connection.CreateCommand())
            {
                command.CommandText = this.changeParameterPerfix(commandText);

                for (int i = 0; i < parameters.Length; i++)
                {
                    if (parameterValues[i].ToString() == string.Empty)
                    {
                        parameterValues[i] = DBNull.Value;
                    }
                    command.Parameters.Add(parameters[i], CSharpType2OracleType(parameterTypes[i])).Value = parameterValues[i];
                    //					command.CommandText =   ChangeParameterPerfix(command.CommandText, parameters[i]);
                }
                if (this.Transaction != null)
                {
//					command.Transaction = (OracleTransaction)this.Transaction;
                }
                DateTime dtStart = new DateTime();
                try
                {
                    //2006/09/12 新增 读取配置文件Log日志文件
                    XmlDocument xmldoc = new XmlDocument();
                    string      constr = "";
                    xmldoc.Load(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\dblog.xml");

                    XmlNodeReader xr = new XmlNodeReader(xmldoc);

                    while (xr.Read())
                    {
                        if (xr.GetAttribute("name") == "BS")
                        {
                            ProgramBool = xr.ReadString();
                        }
                        if (xr.GetAttribute("name") == "Constr")
                        {
                            constr = xr.ReadString();
                        }
                    }


                    if (ProgramBool == "true")
                    {
                        db.dblog1(constr, this.spellCommandText(command.CommandText, parameterValues));
                    }

                    command.ExecuteNonQuery();

                    //修改	在Debug模式下不允许Log日志文件
#if DEBUG
                    dtStart = DateTime.Now;
                    Log.Info("************StartDateTime:" + dtStart.ToString() + "," + dtStart.Millisecond);
                    Log.Info(" Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#endif

#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif
                }
                catch (Oracle.DataAccess.Client.OracleException e)
                {
                    //added by leon.li @20130311
                    Log.Error(e.StackTrace);
                    //end added
                    Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif
                }
                catch (Exception e)
                {
                    //added by leon.li @20130311
                    Log.Error(e.StackTrace);
                    //end added
                    Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    TimeSpan ts    = dtEnd - dtStart;
                    Log.Info("************EndDateTime:" + dtEnd.ToString() + "," + dtEnd.Millisecond + "*********"
                             + "Cost: " + ts.Seconds + ":" + ts.Milliseconds);
#endif

                    ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                }
                finally
                {
                    if (this.Transaction == null)
                    {
                        CloseConnection();
                    }
                }
            }
        }
        public void ProcessWithReturnValueProcessesExceptionsOnThrow()
        {
            var policies = new Dictionary<string, ExceptionPolicyDefinition>();
            var policy1Entries = new Dictionary<Type, ExceptionPolicyEntry>
            {
                {
                    typeof (ArithmeticException),
                    new ExceptionPolicyEntry(typeof (ArithmeticException),
                        PostHandlingAction.NotifyRethrow,
                        new IExceptionHandler[] {new TestExceptionHandler("handler11")})
                },
                {
                    typeof (ArgumentException),
                    new ExceptionPolicyEntry(typeof (ArgumentException),
                        PostHandlingAction.ThrowNewException,
                        new IExceptionHandler[] {new TestExceptionHandler("handler12")})
                },
                {
                    typeof (ArgumentOutOfRangeException),
                    new ExceptionPolicyEntry(typeof (ArgumentOutOfRangeException),
                        PostHandlingAction.None,
                        new IExceptionHandler[] {new TestExceptionHandler("handler13")})
                }
            };
            policies.Add("policy1", new ExceptionPolicyDefinition("policy1", policy1Entries));

            var manager = new ExceptionManager(policies);

            // is the exception rethrown?
            Exception thrownException = new ArithmeticException();
            try
            {
                Exception ex1 = thrownException;
                int result = manager.Process(() =>
                {
                    throw ex1;
#pragma warning disable 162 // Unreachable code
                    return 37;
#pragma warning restore 162
                }, "policy1");
                Assert.Fail("should have thrown");
            }
            catch (Exception e)
            {
                Assert.AreSame(thrownException, e);
                Assert.AreEqual(1, TestExceptionHandler.HandlingNames.Count);
                Assert.AreEqual("handler11", TestExceptionHandler.HandlingNames[0]);
            }

            // is the exception swallowed? action == None
            TestExceptionHandler.HandlingNames.Clear();
            thrownException = new ArgumentOutOfRangeException();
            Exception ex3 = thrownException;
            int swallowedResult = manager.Process(() =>
            {
                throw ex3;
#pragma warning disable 162 // Unreachable code
                return 17;
#pragma warning restore 162
            }, -20, "policy1");
            Assert.AreEqual(1, TestExceptionHandler.HandlingNames.Count);
            Assert.AreEqual("handler13", TestExceptionHandler.HandlingNames[0]);
            Assert.AreEqual(-20, swallowedResult);
        }
Exemplo n.º 50
0
 internal void InitEnterpriseBlocks(DocumentModel doc)
 {
     LoggingConfiguration loggingConfiguration = LoggingSupport.BuildLoggingConfig(this);
     m_OutputWriter = new LogWriter(loggingConfiguration);
     m_ExManager = ExceptionSupport.BuildExceptionManagerConfig(m_OutputWriter, doc);
 }
Exemplo n.º 51
0
        /// <summary>
        /// 执行Procedure
        /// </summary>
        /// <param name="commandText">Procedure名称</param>
        /// <param name="parameters">参数列表</param>
        public override void ExecuteProcedure(string commandText, ref ArrayList parameters)
        {
            OpenConnection();
            using (SqlCommand command = (SqlCommand)this.Connection.CreateCommand())
            {
                command.CommandText = commandText;
                command.CommandType = CommandType.StoredProcedure;

                object[] parameterValues = new object[parameters.Count];
                for (int i = 0; i < parameters.Count; i++)
                {
                    SqlParameter para = new SqlParameter();
                    para.ParameterName = ((ProcedureParameter)parameters[i]).Name;
                    para.SqlDbType     = CSharpType2SqlType(((ProcedureParameter)parameters[i]).Type);
                    if (((ProcedureParameter)parameters[i]).Length != 0)
                    {
                        para.Size = ((ProcedureParameter)parameters[i]).Length;
                    }
                    else
                    {
                        para.Size = 100;
                    }
                    if (((ProcedureParameter)parameters[i]).Direction != DirectionType.Input)
                    {
                        para.Direction = (ParameterDirection)System.Enum.Parse(typeof(ParameterDirection), System.Enum.GetName(typeof(DirectionType), ((ProcedureParameter)parameters[i]).Direction));
                    }
                    else
                    {
                        para.Direction = ParameterDirection.Input;
                    }
                    para.Value         = ((ProcedureParameter)parameters[i]).Value;
                    parameterValues[i] = para;
                    command.Parameters.Add(para);
                }
                if (this.Transaction != null)
                {
                    command.Transaction = (SqlTransaction)this.Transaction;
                }
#if DEBUG
                DateTime dtStart = DateTime.Now;
                string   sqlText = this.spellCommandText(command.CommandText, parameterValues);
#endif
                try
                {
                    //2006/09/12 新增 读取配置文件Log日志文件
                    XmlDocument   xmldoc = null;
                    XmlNodeReader xr     = null;
                    try
                    {
                        string constr = "";
                        if (!this.AllowSQLLog && this.SQLLogConnectString == String.Empty)
                        {
                            xmldoc = new XmlDocument();

                            xmldoc.Load(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "\\dblog.xml");

                            xr = new XmlNodeReader(xmldoc);

                            while (xr.Read())
                            {
                                if (xr.GetAttribute("name") == "BS")
                                {
                                    this.AllowSQLLog = (xr.ReadString() == "false" ? false : true);
                                }
                                if (xr.GetAttribute("name") == "Constr")
                                {
                                    this.SQLLogConnectString = xr.ReadString();
                                }
                            }
                        }


                        if (this.AllowSQLLog && this.SQLLogConnectString != String.Empty)
                        {
                            //Laws Lu,2007/04/03 Log executing user
                            //db.dblog1(constr,this.spellCommandText(command.CommandText,parameterValues);
                            //db.dblog1(this.SQLLogConnectString, this.spellCommandText(command.CommandText, parameterValues), this.ExecuteUser);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error(ex.Message);
                    }
                    finally
                    {
                        if (xr != null)
                        {
                            xr.Close();
                        }
                        if (xmldoc != null)
                        {
                            xmldoc.Clone();
                        }
                    }

                    command.ExecuteNonQuery();
                    for (int i = 0; i < parameters.Count; i++)
                    {
                        if (((ProcedureParameter)parameters[i]).Direction != DirectionType.Input)
                        {
                            ((ProcedureParameter)parameters[i]).Value = ((SqlParameter)parameterValues[i]).Value;
                        }
                    }

#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    RecordLog("Execute SQL", sqlText, dtStart, dtEnd);
#endif
                }
                catch (System.Data.OleDb.OleDbException e)
                {
                    //Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    RecordLog("Execute SQL", sqlText, dtStart, dtEnd);
#endif

                    if (e.ErrorCode == -2147217873)
                    {
                        //ExceptionManager.Raise(this.GetType(), "$ERROR_DATA_ALREADY_EXIST", e);
                        ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                    }
                    else
                    {
                        ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                    }
                }
                catch (Exception e)
                {
                    //Log.Error(e.Message + " Parameter SQL:" + this.spellCommandText(command.CommandText, parameterValues));
#if DEBUG
                    DateTime dtEnd = DateTime.Now;
                    RecordLog("Execute SQL", sqlText, dtStart, dtEnd);
#endif

                    ExceptionManager.Raise(this.GetType(), "$Error_Command_Execute", e);
                }
                finally
                {
                    //Laws Lu,2006/12/20 修改如果自动关闭为True并且不在Transaction中时才会自动关闭Connection
                    if (this.Transaction == null && AutoCloseConnection == true)
                    {
                        CloseConnection();
                    }
                }
            }
        }