Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSaveTranxAlert_Click(object sender, EventArgs e)
        {
            try
            {
                dsSchemes  = (DataSet)Session["UnsubscribedSchemes"];
                customerVo = (CustomerVo)Session[SessionContents.CustomerVo];
                userVo     = (UserVo)Session[SessionContents.UserVo];
                EventID    = int.Parse(Session[SessionContents.EventID].ToString());
                customerId = customerVo.CustomerId;
                userId     = userVo.UserId;


                if (dsSchemes.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in dsSchemes.Tables[0].Rows)
                    {
                        if (dr["PASP_SchemePlanCode"].ToString() == ddlScheme.SelectedItem.Value.ToString())
                        {
                            alertVo = new AlertsSetupVo();

                            alertVo.CustomerId   = customerId;
                            alertVo.EventID      = int.Parse(Session[SessionContents.EventID].ToString());
                            alertVo.SchemeID     = int.Parse(ddlScheme.SelectedItem.Value.ToString());
                            alertVo.TargetID     = int.Parse(dr["CMFA_AccountId"].ToString());
                            alertVo.EventMessage = "Transaction has been Captured";

                            alertsBo.SaveConfirmationAlert(alertVo, userId);
                        }
                    }
                }
                BindSubscribedEventsGridView(customerId, EventID);
                trAddNewTranxAlt.Visible = false;
                trTranxSave.Visible      = false;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "CustomerTransactionalAlertManagement.ascx:btnSaveTranxAlert_Click()");

                object[] objects = new object[0];

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        protected void btnSaveConditionAlert_Click(object sender, EventArgs e)
        {
            try
            {
                dsAssets   = (DataSet)Session["UnsubscribedAssets"];
                customerVo = (CustomerVo)Session[SessionContents.CustomerVo];
                userVo     = (UserVo)Session[SessionContents.UserVo];
                EventID    = int.Parse(Session[SessionContents.EventID].ToString());
                customerId = customerVo.CustomerId;
                userId     = userVo.UserId;


                if (dsAssets.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow dr in dsAssets.Tables[0].Rows)
                    {
                        if (dr["AssetId"].ToString() == ddlScheme.SelectedItem.Value.ToString())
                        {
                            alertVo = new AlertsSetupVo();

                            alertVo.CustomerId  = customerId;
                            alertVo.EventID     = int.Parse(Session[SessionContents.EventID].ToString());
                            alertVo.SchemeID    = int.Parse(ddlScheme.SelectedItem.Value.ToString());
                            alertVo.TargetID    = int.Parse(dr["TargetId"].ToString());
                            alertVo.Condition   = ddlCondition.SelectedItem.Value.ToString();
                            alertVo.PresetValue = float.Parse(txtPresetValue.Text.ToString());

                            if (alertVo.Condition == ">")
                            {
                                alertVo.EventMessage = "Current Value has crossed " + alertVo.PresetValue;
                            }
                            if (alertVo.Condition == "<")
                            {
                                alertVo.EventMessage = "Current Value has fallen below " + alertVo.PresetValue;
                            }
                            if (alertVo.Condition == ">=")
                            {
                                alertVo.EventMessage = "Current Value has gone up to " + alertVo.PresetValue;
                            }
                            if (alertVo.Condition == "<=")
                            {
                                alertVo.EventMessage = "Current Value has dropped to " + alertVo.PresetValue;
                            }
                            if (alertVo.Condition == "=")
                            {
                                alertVo.EventMessage = "Current Value is equal to " + alertVo.PresetValue;
                            }

                            alertsBo.SaveOccurrenceAlert(alertVo, userId);
                        }
                    }
                }
                BindSubscribedEventsGridView(customerId, EventID);
                trAddNewCondition.Visible = false;
                trAddNewEvent.Visible     = false;
                trConditionSave.Visible   = false;
            }
            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }
            catch (Exception Ex)
            {
                BaseApplicationException exBase       = new BaseApplicationException(Ex.Message, Ex);
                NameValueCollection      FunctionInfo = new NameValueCollection();

                FunctionInfo.Add("Method", "CustomerDataAlertManagement.ascx:btnSaveConditionAlert_Click()");

                object[] objects = new object[0];

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }
        private void BindSubscribedEventsGridView(int customerId, int EventID)
        {
            try
            {
                userVo     = (UserVo)Session[SessionContents.UserVo];
                customerVo = (CustomerVo)Session[SessionContents.CustomerVo];
                userId     = userVo.UserId;
                customerId = customerVo.CustomerId;
                gvConditionalAlerts.DataSource = null;
                gvConditionalAlerts.DataBind();

                //function that retrieves the customer subscribed alerts from the DB
                AlertSetupList = alertsBo.GetCustomerSubscribedOccurrenceAlerts(customerId, EventID, mypager.CurrentPage, out count);
                //setting the pager
                if (count > 0)
                {
                    lblTotalRows.Text = hdnRecordCount.Value = count.ToString();
                    tblPager.Visible  = true;
                }
                //if alerts are subscribed runs the piece of code below else displays that events dont exist
                if (AlertSetupList.Count > 0)
                {
                    DataTable dtAlertSetup = new DataTable();

                    // creating a datatable with all the necessary details to bind to the gridview
                    dtAlertSetup.Columns.Add("EventSetupID");
                    dtAlertSetup.Columns.Add("Details");
                    dtAlertSetup.Columns.Add("CurrentValue");
                    dtAlertSetup.Columns.Add("Condition");
                    dtAlertSetup.Columns.Add("PresetValue");
                    dtAlertSetup.Columns.Add("Message");

                    DataRow drAlertSetup;
                    for (int i = 0; i < AlertSetupList.Count; i++)
                    {
                        drAlertSetup = dtAlertSetup.NewRow();
                        alertVo      = new AlertsSetupVo();
                        alertVo      = AlertSetupList[i];
                        //assigns the setupid to each row as a Datakey
                        drAlertSetup[0] = alertVo.EventSetupID.ToString().Trim();
                        //Details is a combination of the event name and scheme name
                        drAlertSetup[1] = alertVo.EventName.ToString().Trim() + " : " + alertVo.SchemeName.ToString();

                        if (alertVo.CurrentValue.ToString() != "" || alertVo.CurrentValue.ToString() != null)
                        {
                            drAlertSetup[2] = alertVo.CurrentValue.ToString();
                        }

                        if (alertVo.Condition.ToString().Trim() != "")
                        {
                            drAlertSetup[3] = alertVo.Condition.ToString().Trim();
                        }

                        if (alertVo.PresetValue.ToString() != null || alertVo.PresetValue.ToString() != "")
                        {
                            drAlertSetup[4] = alertVo.PresetValue.ToString();
                        }

                        if (alertVo.EventMessage.ToString().Trim() != "" || alertVo.EventMessage.ToString().Trim() != null)
                        {
                            //Message that gets displayed when the alert is triggered
                            drAlertSetup[5] = alertVo.EventMessage.ToString().Trim();
                        }
                        else
                        {
                            drAlertSetup[5] = "";
                        }


                        dtAlertSetup.Rows.Add(drAlertSetup);
                    }

                    // binding the datatable to the gridview and making the grid visible
                    gvConditionalAlerts.DataSource = dtAlertSetup;
                    gvConditionalAlerts.DataBind();
                    gvConditionalAlerts.Visible = true;
                    lblMessage.Visible          = false;
                    this.GetPageCount();
                }
                else
                {
                    lblMessage.Visible = true;
                }
            }

            catch (BaseApplicationException Ex)
            {
                throw Ex;
            }

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

                FunctionInfo.Add("Method", "CustomerDataAlertManagement.ascx:BindSubscribedEventsGridView()");

                object[] objects = new object[0];

                FunctionInfo = exBase.AddObject(FunctionInfo, objects);
                exBase.AdditionalInformation = FunctionInfo;
                ExceptionManager.Publish(exBase);
                throw exBase;
            }
        }