public void TestAutoSubscription()
        {
            var testHub = new MessagesHub();

            var instance = new HandlerObject();

            var subscriptions = MessagesUtils.AutoSubscribe(instance, testHub);

            using (Disposable.FromAction(() =>
            {
                foreach (var s in subscriptions)
                {
                    s.Subscription.Dispose();
                }
            }))
            {
                string str1  = "value1";
                string str2  = "value2";
                int    ival1 = 77;

                Assert.AreEqual(instance.StrValue, string.Empty);
                Assert.AreEqual(instance.IntValue, 0);

                NotificationMessage1.Broadcast(str1, testHub);

                Assert.AreEqual(instance.StrValue, str1);

                NotificationMessage2.Broadcast(str2, ival1, testHub);

                Assert.AreEqual(instance.StrValue, str2);
                Assert.AreEqual(instance.IntValue, ival1);
            }

            Assert.Throws <Exception>(() =>
            {    // all subscriptions must gone after using (...) block
                NotificationMessage1.Broadcast(string.Empty, testHub);
            });
        }
示例#2
0
    protected void btnSaveProduct_Click(object sender, EventArgs e)
    {
        int intUserId = int.Parse(Session["UserId"].ToString());

        try
        {
            DALmstOrder        objDALmstOrder          = new DALmstOrder();
            DALmstRefundAmount objDALmstRefundAmount   = new DALmstRefundAmount();
            DataSet            dsobjDALmstRefundAmount = new DataSet();

            if (txtRefundAmount.Text != "0")
            {
                int      nOrderId              = int.Parse(Request.QueryString["OrderId"].ToString());
                int      nCustomerId           = int.Parse(lblId.Text);
                int      nLanguageId           = 1;
                DateTime dtPaymentReceived     = DateTime.Parse(txtPaymentDueDate.Text);
                float    fRefundAmount         = float.Parse(txtRefundAmount.Text);
                int      nCutomerAccountTypeId = int.Parse(ddlCutomerAccounttype.SelectedValue);
                string   cReferenceNumber      = txtReferencenumber.Text;
                string   cNotes = txtNotes.Text;

                float TotalAmount = float.Parse(lblTotal.Text);
                if (fRefundAmount == TotalAmount)
                {
                    objDALmstOrder.UpdateStatusAfterTakePayment(nOrderId, intUserId, "Return", dtPaymentReceived);


                    objDALmstRefundAmount.InsertRow(nOrderId, nCustomerId, dtPaymentReceived, fRefundAmount, nCutomerAccountTypeId, cReferenceNumber, cNotes, intUserId, true, nLanguageId, false, "", "", "", "");

                    #region //START: Enter Log


                    string strchatUserNAme = Session["ChatUsername"].ToString();

                    string strCustomerName = "";

                    DALCustomer objCustomer = new DALCustomer();
                    DataSet     dsCustomer  = new DataSet();
                    dsCustomer = objCustomer.SelectRow(nCustomerId, intUserId);
                    if (dsCustomer.Tables[0].Rows.Count > 0)
                    {
                        strCustomerName = dsCustomer.Tables[0].Rows[0]["cCustomerFirstName"].ToString() + " " + dsCustomer.Tables[0].Rows[0]["cCustomerLastName"].ToString();
                    }

                    string    strDescription = "Refund payment for 'CN'" + nOrderId + "(" + strCustomerName + ")";
                    DALmstLog objLog         = new DALmstLog();
                    objLog.InsertRow(cReferenceNumber, strDescription, "insert", strchatUserNAme, DateTime.Now, intUserId, 0, true, false, "", "", "");

                    strDescription = "Full Refund payment for 'CN'" + nOrderId + "(" + strCustomerName + ")";

                    objLog.InsertRow(cReferenceNumber, strDescription, "insert", strchatUserNAme, DateTime.Now, intUserId, 0, true, false, "", "", "");

                    #endregion

                    Response.Redirect("ViewInvoice.aspx?PageId=0");
                }
                else if (fRefundAmount > TotalAmount)
                {
                    string strTitleN       = "Take Payment";
                    string strdescriptions = "The amount cannot be more than the credit available to the customer.";
                    NotificationMessage1.NotificationDetails(strTitleN, strdescriptions);
                }
                else
                {
                    objDALmstRefundAmount.InsertRow(nOrderId, nCustomerId, dtPaymentReceived, fRefundAmount, nCutomerAccountTypeId, cReferenceNumber, cNotes, intUserId, true, nLanguageId, false, "", "", "", "");

                    #region //START: Enter Log


                    string strchatUserNAme = Session["ChatUsername"].ToString();

                    string strCustomerName = "";

                    DALCustomer objCustomer = new DALCustomer();
                    DataSet     dsCustomer  = new DataSet();
                    dsCustomer = objCustomer.SelectRow(nCustomerId, intUserId);
                    if (dsCustomer.Tables[0].Rows.Count > 0)
                    {
                        strCustomerName = dsCustomer.Tables[0].Rows[0]["cCustomerFirstName"].ToString() + " " + dsCustomer.Tables[0].Rows[0]["cCustomerLastName"].ToString();
                    }

                    string    strDescription = "Refund amount for 'CN'" + nOrderId + "(" + strCustomerName + ")";
                    DALmstLog objLog         = new DALmstLog();
                    objLog.InsertRow(cReferenceNumber, strDescription, "insert", strchatUserNAme, DateTime.Now, intUserId, 0, true, false, "", "", "");


                    #endregion

                    Response.Redirect("ViewInvoice.aspx?PageId=0");
                }
            }


            else
            {
                string strTitleN       = "";
                string strdescriptions = "The Amount field cannot be $0.00. Please enter an amount other than zero.";
                NotificationMessage1.NotificationDetails(strTitleN, strdescriptions);
            }
        }
        catch (Exception ex)
        {
            DALExceptionDetail objDALExceptionDetail = new DALExceptionDetail();
            objDALExceptionDetail.InsertRow(ex.Message, "RefundToCustomer.aspx", intUserId, DateTime.Now, true);
        }
    }