Ejemplo n.º 1
0
        /// <inheritdoc/>
        protected override ValueTask <RateLimitLease> AcquireAsyncCore(int tokenCount, CancellationToken cancellationToken = default)
        {
            // These amounts of resources can never be acquired
            if (tokenCount > _options.TokenLimit)
            {
                throw new ArgumentOutOfRangeException(nameof(tokenCount), tokenCount, SR.Format(SR.TokenLimitExceeded, tokenCount, _options.TokenLimit));
            }

            ThrowIfDisposed();

            // Return SuccessfulAcquisition if requestedCount is 0 and resources are available
            if (tokenCount == 0 && _tokenCount > 0)
            {
                Interlocked.Increment(ref _successfulLeasesCount);
                return(new ValueTask <RateLimitLease>(SuccessfulLease));
            }

            lock (Lock)
            {
                if (TryLeaseUnsynchronized(tokenCount, out RateLimitLease? lease))
                {
                    return(new ValueTask <RateLimitLease>(lease));
                }

                // Avoid integer overflow by using subtraction instead of addition
                Debug.Assert(_options.QueueLimit >= _queueCount);
                if (_options.QueueLimit - _queueCount < tokenCount)
                {
                    if (_options.QueueProcessingOrder == QueueProcessingOrder.NewestFirst && tokenCount <= _options.QueueLimit)
                    {
                        // remove oldest items from queue until there is space for the newest acquisition request
                        do
                        {
                            RequestRegistration oldestRequest = _queue.DequeueHead();
                            _queueCount -= oldestRequest.Count;
                            Debug.Assert(_queueCount >= 0);
                            if (!oldestRequest.Tcs.TrySetResult(FailedLease))
                            {
                                // Updating queue count is handled by the cancellation code
                                _queueCount += oldestRequest.Count;
                            }
                            else
                            {
                                Interlocked.Increment(ref _failedLeasesCount);
                            }
                        }while (_options.QueueLimit - _queueCount < tokenCount);
                    }
                    else
                    {
                        Interlocked.Increment(ref _failedLeasesCount);
                        // Don't queue if queue limit reached and QueueProcessingOrder is OldestFirst
                        return(new ValueTask <RateLimitLease>(CreateFailedTokenLease(tokenCount)));
                    }
                }

                CancelQueueState tcs = new CancelQueueState(tokenCount, this, cancellationToken);
                CancellationTokenRegistration ctr = default;
                if (cancellationToken.CanBeCanceled)
                {
                    ctr = cancellationToken.Register(static obj =>
Ejemplo n.º 2
0
    public RequestRegistration requestRegistration(string username, string password, string confirmedPassword)
    {
        RequestRegistration request = new RequestRegistration();

        request.send(username, password, confirmedPassword);
        return(request);
    }
 protected void Page_Unload(object sender, EventArgs e)
 {
     objCommonClass        = null;
     objSqlDataAccessLayer = null;
     objSuspenseAccount    = null;
     objSCPopupMaster      = null;
     objProductMaster      = null;
     objCallRegistration   = null;
 }
Ejemplo n.º 4
0
        /// <inheritdoc/>
        protected override ValueTask <RateLimitLease> WaitAsyncCore(int permitCount, CancellationToken cancellationToken = default)
        {
            // These amounts of resources can never be acquired
            if (permitCount > _options.PermitLimit)
            {
                throw new ArgumentOutOfRangeException(nameof(permitCount), permitCount, SR.Format(SR.PermitLimitExceeded, permitCount, _options.PermitLimit));
            }

            // Return SuccessfulLease if requestedCount is 0 and resources are available
            if (permitCount == 0 && _permitCount > 0 && !_disposed)
            {
                return(new ValueTask <RateLimitLease>(SuccessfulLease));
            }

            // Perf: Check SemaphoreSlim implementation instead of locking
            lock (Lock)
            {
                if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease))
                {
                    return(new ValueTask <RateLimitLease>(lease));
                }

                // Avoid integer overflow by using subtraction instead of addition
                Debug.Assert(_options.QueueLimit >= _queueCount);
                if (_options.QueueLimit - _queueCount < permitCount)
                {
                    if (_options.QueueProcessingOrder == QueueProcessingOrder.NewestFirst && permitCount <= _options.QueueLimit)
                    {
                        // remove oldest items from queue until there is space for the newest request
                        do
                        {
                            RequestRegistration oldestRequest = _queue.DequeueHead();
                            _queueCount -= oldestRequest.Count;
                            Debug.Assert(_queueCount >= 0);
                            oldestRequest.Tcs.TrySetResult(FailedLease);
                        }while (_options.QueueLimit - _queueCount < permitCount);
                    }
                    else
                    {
                        // Don't queue if queue limit reached and QueueProcessingOrder is OldestFirst
                        return(new ValueTask <RateLimitLease>(QueueLimitLease));
                    }
                }

                TaskCompletionSource <RateLimitLease> tcs = new TaskCompletionSource <RateLimitLease>(TaskCreationOptions.RunContinuationsAsynchronously);
                CancellationTokenRegistration         ctr = default;
                if (cancellationToken.CanBeCanceled)
                {
                    ctr = cancellationToken.Register(static obj =>
Ejemplo n.º 5
0
        /// <inheritdoc/>
        protected override ValueTask <RateLimitLease> WaitAsyncCore(int tokenCount, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            // These amounts of resources can never be acquired
            if (tokenCount > _options.TokenLimit)
            {
                throw new ArgumentOutOfRangeException(nameof(tokenCount), $"{tokenCount} token(s) exceeds the permit limit of {_options.TokenLimit}.");
            }

            // Return SuccessfulAcquisition if requestedCount is 0 and resources are available
            if (tokenCount == 0 && _tokenCount > 0)
            {
                return(new ValueTask <RateLimitLease>(SuccessfulLease));
            }

            lock (Lock)
            {
                if (TryLeaseUnsynchronized(tokenCount, out RateLimitLease? lease))
                {
                    return(new ValueTask <RateLimitLease>(lease));
                }

                // Don't queue if queue limit reached
                if (_queueCount + tokenCount > _options.QueueLimit)
                {
                    return(new ValueTask <RateLimitLease>(CreateFailedTokenLease(tokenCount)));
                }

                TaskCompletionSource <RateLimitLease> tcs = new TaskCompletionSource <RateLimitLease>(TaskCreationOptions.RunContinuationsAsynchronously);

                CancellationTokenRegistration ctr;
                if (cancellationToken.CanBeCanceled)
                {
                    ctr = cancellationToken.Register(obj =>
                    {
                        ((TaskCompletionSource <RateLimitLease>)obj).TrySetException(new OperationCanceledException(cancellationToken));
                    }, tcs);
                }

                RequestRegistration registration = new RequestRegistration(tokenCount, tcs, ctr);
                _queue.EnqueueTail(registration);
                _queueCount += tokenCount;
                Debug.Assert(_queueCount <= _options.QueueLimit);

                // handle cancellation
                return(new ValueTask <RateLimitLease>(registration.Tcs.Task));
            }
        }
        /// <inheritdoc/>
        protected override ValueTask <RateLimitLease> WaitAsyncCore(int permitCount, CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            // These amounts of resources can never be acquired
            if (permitCount > _options.PermitLimit)
            {
                throw new ArgumentOutOfRangeException(nameof(permitCount), $"{permitCount} permits exceeds the permit limit of {_options.PermitLimit}.");
            }

            // Return SuccessfulLease if requestedCount is 0 and resources are available
            if (permitCount == 0 && _permitCount > 0)
            {
                return(new ValueTask <RateLimitLease>(SuccessfulLease));
            }

            // Perf: Check SemaphoreSlim implementation instead of locking
            lock (Lock)
            {
                if (TryLeaseUnsynchronized(permitCount, out RateLimitLease? lease))
                {
                    return(new ValueTask <RateLimitLease>(lease));
                }

                // Don't queue if queue limit reached
                if (_queueCount + permitCount > _options.QueueLimit)
                {
                    // Perf: static failed/successful value tasks?
                    return(new ValueTask <RateLimitLease>(QueueLimitLease));
                }

                TaskCompletionSource <RateLimitLease> tcs = new TaskCompletionSource <RateLimitLease>(TaskCreationOptions.RunContinuationsAsynchronously);
                CancellationTokenRegistration         ctr;
                if (cancellationToken.CanBeCanceled)
                {
                    ctr = cancellationToken.Register(obj =>
                    {
                        ((TaskCompletionSource <RateLimitLease>)obj).TrySetException(new OperationCanceledException(cancellationToken));
                    }, tcs);
                }

                RequestRegistration request = new RequestRegistration(permitCount, tcs, ctr);
                _queue.EnqueueTail(request);
                _queueCount += permitCount;
                Debug.Assert(_queueCount <= _options.QueueLimit);

                return(new ValueTask <RateLimitLease>(request.Tcs.Task));
            }
        }
        private void Release(int releaseCount)
        {
            lock (Lock)
            {
                _permitCount += releaseCount;
                Debug.Assert(_permitCount <= _options.PermitLimit);

                while (_queue.Count > 0)
                {
                    RequestRegistration nextPendingRequest =
                        _options.QueueProcessingOrder == QueueProcessingOrder.OldestFirst
                        ? _queue.PeekHead()
                        : _queue.PeekTail();

                    if (_permitCount >= nextPendingRequest.Count)
                    {
                        nextPendingRequest =
                            _options.QueueProcessingOrder == QueueProcessingOrder.OldestFirst
                            ? _queue.DequeueHead()
                            : _queue.DequeueTail();

                        _permitCount -= nextPendingRequest.Count;
                        _queueCount  -= nextPendingRequest.Count;
                        Debug.Assert(_queueCount >= 0);
                        Debug.Assert(_permitCount >= 0);

                        ConcurrencyLease lease = nextPendingRequest.Count == 0 ? SuccessfulLease : new ConcurrencyLease(true, this, nextPendingRequest.Count);
                        // Check if request was canceled
                        if (!nextPendingRequest.Tcs.TrySetResult(lease))
                        {
                            // Queued item was canceled so add count back
                            _permitCount += nextPendingRequest.Count;
                        }
                        nextPendingRequest.CancellationTokenRegistration.Dispose();
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            long   lngCustomerId = 0;
            string strUniqueNo = "", strAltNo = "", strValidNumberCus = "";
            bool   blnFlagSMSCus      = false;
            string strCustomerMessage = "";
            if ((ddlProductDiv.SelectedIndex != 0) && (txtQuantity.Text != "") && (txtComplaintDetails.Text != ""))
            {
                CreateRow();
            }
            if (!blnFlag)
            {
                DataSet dsTemp = (DataSet)ViewState["ds"];
                if (dsTemp.Tables[0].Rows.Count > 0)
                {
                    objCallRegistration.Type             = "INSERT_UPDAT_CUSTOMER_DATA";
                    objCallRegistration.CustomerId       = int.Parse(hdnCustomerId.Value);
                    objCallRegistration.UpdateCustDeatil = "N";
                    objCallRegistration.Active_Flag      = "1";
                    objCallRegistration.Prefix           = ddlPrefix.SelectedValue.ToString();
                    objCallRegistration.FirstName        = txtFirstName.Text.Trim();
                    objCallRegistration.MiddleName       = txtMiddleName.Text.Trim(); // Bhawesh 11 Feb 13
                    objCallRegistration.LastName         = txtLastName.Text.Trim();
                    objCallRegistration.Customer_Type    = "O";                       // for web form outside customer
                    objCallRegistration.Company_Name     = txtCompanyName.Text.Trim();
                    objCallRegistration.Address1         = txtAdd1.Text.ToString();
                    objCallRegistration.Address2         = txtAdd2.Text.ToString();
                    objCallRegistration.Landmark         = txtLandmark.Text.Trim();
                    objCallRegistration.PinCode          = txtPinCode.Text.Trim();
                    objCallRegistration.Country          = "1"; //For country india
                    objCallRegistration.State            = ddlState.SelectedValue.ToString();
                    objCallRegistration.City             = ddlCity.SelectedValue.ToString();

                    if (ddlCity.SelectedValue.ToString() == "0")
                    {
                        objCallRegistration.CityOther = txtOtherCity.Text.Trim();
                    }
                    else
                    {
                        objCallRegistration.CityOther = null;
                    }
                    objCallRegistration.Language = "4";
                    objCallRegistration.Email    = txtEmail.Text.Trim();
                    if ((txtContactNo.Text.Trim().Substring(0, 1) != "0") && (txtContactNo.Text.Trim().Length == 10))
                    {
                        objCallRegistration.UniqueContact_No = "0" + txtContactNo.Text.Trim();
                    }
                    else
                    {
                        objCallRegistration.UniqueContact_No = txtContactNo.Text.Trim();
                    }
                    if (txtAltConatctNo.Text.Trim() == "")
                    {
                        txtAltConatctNo.Text = txtContactNo.Text.Trim();
                    }
                    if (txtAltConatctNo.Text.Trim() != "")
                    {
                        if ((txtAltConatctNo.Text.Trim().Substring(0, 1) != "0") && (txtAltConatctNo.Text.Trim().Length == 10))
                        {
                            objCallRegistration.AltTelNumber = "0" + txtAltConatctNo.Text.Trim();
                        }
                        else
                        {
                            objCallRegistration.AltTelNumber = txtAltConatctNo.Text.Trim();
                        }
                    }
                    else
                    {
                        objCallRegistration.AltTelNumber = txtAltConatctNo.Text.Trim();
                    }
                    if (txtExtension.Text.Trim() == "")
                    {
                        objCallRegistration.Extension = 0;
                    }
                    else
                    {
                        objCallRegistration.Extension = int.Parse(txtExtension.Text.Trim());
                    }


                    // BP : 28 dec 12
                    int SCNo = Convert.ToInt32(TxtSCName.Attributes["SC_SNo"]);
                    if (SCNo == 0)
                    {
                        objCallRegistration.EmpCode = "customer";
                    }
                    else
                    {
                        objCallRegistration.EmpCode = TxtSCName.Text.Trim();
                    }

                    objCallRegistration.SaveCustomerData();

                    if (objCallRegistration.ReturnValue == 1)
                    {
                        lngCustomerId = objCallRegistration.CustomerId;
                    }

                    ArrayList arrListFiles = new ArrayList();
                    //Inserting DraftComplaintDetails
                    if (lngCustomerId > 0)
                    {
                        //uploading Files to Server on Folder Docs/Customer

                        strFileSavePath = ConfigurationSettings.AppSettings["CustomerFilePath"].ToString();
                        dTableFile      = (DataTable)ViewState["dTableFile"];
                        if (flUpload.Value != "")
                        {
                            try
                            {
                                if (!Directory.Exists(strFileSavePath))
                                {
                                    Directory.CreateDirectory(Server.MapPath(strFileSavePath));
                                }
                                strvFileName = flUpload.Value;
                                strFileName  = Path.GetFileName(strvFileName);
                                strExt       = Path.GetExtension(strvFileName);
                                strFileName  = Path.GetFileNameWithoutExtension(strvFileName) + "_" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                                strFileName  = strFileName + strExt;
                                DataRow dRow = dTableFile.NewRow();
                                dRow["FileName"] = strFileName;
                                dTableFile.Rows.Add(dRow);
                                ViewState["dTableFile"] = dTableFile;
                                flUpload.PostedFile.SaveAs(Server.MapPath(strFileSavePath + strFileName));
                            }
                            catch (Exception ex)
                            {
                                CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
                            }
                        }
                        dTableFile = (DataTable)ViewState["dTableFile"];
                        for (intCnt = 0; intCnt < dTableFile.Rows.Count; intCnt++)
                        {
                            arrListFiles.Add(dTableFile.Rows[intCnt]["FileName"].ToString());
                        }
                        //Uploading Files End
                        //Create Temp table for Complaint + SC Name
                        DataTable  dTableTemp      = new DataTable();
                        DataColumn dColNo          = new DataColumn("SNo");
                        DataColumn dColComplaintNo = new DataColumn("ComplaintRefNo");
                        DataColumn dColProd        = new DataColumn("ProductDivision");
                        dTableTemp.Columns.Add(dColNo);
                        dTableTemp.Columns.Add(dColComplaintNo);
                        dTableTemp.Columns.Add(dColProd);
                        // BP : 28 dec 12
                        int SCSNo = Convert.ToInt32(TxtSCName.Attributes["SC_SNo"]);
                        if (SCSNo == 0)
                        {
                            objCallRegistration.EmpCode = "customer";
                        }
                        else
                        {
                            objCallRegistration.EmpCode = TxtSCName.Text.Trim();
                        }

                        for (int intCnt = 0; intCnt < dsTemp.Tables[0].Rows.Count; intCnt++)
                        {
                            objCallRegistration.CustomerId        = lngCustomerId;
                            objCallRegistration.ModeOfReceipt     = dsTemp.Tables[0].Rows[intCnt]["ModeOfReceipt_SNo"].ToString();
                            objCallRegistration.ProductDivision   = dsTemp.Tables[0].Rows[intCnt]["ProductDivision_Sno"].ToString();
                            objCallRegistration.ProductLine       = dsTemp.Tables[0].Rows[intCnt]["ProductLine_Sno"].ToString();
                            objCallRegistration.Language          = dsTemp.Tables[0].Rows[intCnt]["Language_Sno"].ToString();
                            objCallRegistration.IsFiles           = dsTemp.Tables[0].Rows[intCnt]["IsFiles"].ToString();
                            objCallRegistration.Quantity          = int.Parse(dsTemp.Tables[0].Rows[intCnt]["Quantity"].ToString());
                            objCallRegistration.NatureOfComplaint = dsTemp.Tables[0].Rows[intCnt]["NatureOfComplaint"].ToString();
                            objCallRegistration.InvoiceDate       = dsTemp.Tables[0].Rows[intCnt]["InvoiceDate"].ToString();
                            objCallRegistration.PurchasedDate     = dsTemp.Tables[0].Rows[intCnt]["PurchasedDate"].ToString();
                            objCallRegistration.PurchasedFrom     = dsTemp.Tables[0].Rows[intCnt]["PurchasedFrom"].ToString();
                            objCallRegistration.AppointmentReq    = dsTemp.Tables[0].Rows[intCnt]["AppointmentReq"].ToString();
                            objCallRegistration.IsSRF             = dsTemp.Tables[0].Rows[intCnt]["SRF"].ToString();
                            objCallRegistration.Frames            = dsTemp.Tables[0].Rows[intCnt]["Frames"].ToString();
                            objCallRegistration.InvoiceNum        = dsTemp.Tables[0].Rows[intCnt]["InvoiceNum"].ToString();
                            objCallRegistration.State             = ddlState.SelectedValue;
                            objCallRegistration.City = ddlCity.SelectedValue;
                            if (ddlCity.SelectedValue.ToString() == "0")
                            {
                                objCallRegistration.CityOther = txtOtherCity.Text.Trim();
                            }
                            else
                            {
                                objCallRegistration.CityOther = null;
                            }

                            objCallRegistration.BusinessLine = "2";
                            objCallRegistration.Type         = "INSERT_COMPLAINT_DATA_BY_CUSTOMER";
                            objCallRegistration.SaveComplaintData();
                            if (objCallRegistration.ReturnValue == -1)
                            {
                                //Writing Error message to File using CommonClass WriteErrorErrFile method taking arguments as URL of page
                                // trace, error message
                                CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), objCallRegistration.MessageOut.ToString());
                            }
                            if (objCallRegistration.ReturnValue == 1)
                            {
                                #region Save FileData
                                RequestRegistration objCallreg = new RequestRegistration();
                                //Saving FileNames to DB
                                for (int i = 0; i < arrListFiles.Count; i++)
                                {
                                    objCallreg.EmpCode = "customer";
                                    objCallreg.Type    = "INSERT_COMPLAINT_FILES_DATA";
                                    objCallreg.SaveFilesWithComplaintno(objCallRegistration.Complaint_RefNoOUT, arrListFiles[i].ToString());
                                }
                                objCallreg = null;
                                //End Saving
                                #endregion Save FileData

                                # region add a coopy in Feedback Table (For Reporting Purpose only) Bhawesh 18 Apr 13
                                objwscfeedback.Prefix          = objCallRegistration.Prefix;
                                objwscfeedback.FirstName       = objCallRegistration.FirstName;
                                objwscfeedback.MiddleName      = objCallRegistration.MiddleName;
                                objwscfeedback.LastName        = objCallRegistration.LastName;
                                objwscfeedback.Address         = objCallRegistration.Address1 + " " + objCallRegistration.Address2;
                                objwscfeedback.StateSNo        = Convert.ToInt32(objCallRegistration.State);
                                objwscfeedback.CitySNo         = Convert.ToInt32(objCallRegistration.City);
                                objwscfeedback.CompanyName     = objCallRegistration.Company_Name;
                                objwscfeedback.ContactNo       = objCallRegistration.UniqueContact_No;
                                objwscfeedback.Email           = objCallRegistration.Email;
                                objwscfeedback.FeedBackByASCID = Convert.ToInt32(TxtSCName.Attributes["SC_SNo"]);
                                objwscfeedback.FeedbackDesc    = "ComplaintNo: " + objCallRegistration.Complaint_RefNoOUT + ";Detail: " + objCallRegistration.NatureOfComplaint;
                                objwscfeedback.FeedBackTypeID  = Convert.ToInt32(ddlFeedbackType.SelectedValue);
                                objwscfeedback.ProddivSNO      = Convert.ToInt32(objCallRegistration.ProductDivision);
                                objwscfeedback.ProdLineSNO     = Convert.ToInt32(objCallRegistration.ProductLine); // Bhawesh 8-4-13
                                try
                                {
                                    String StrMsg = objwscfeedback.SaveData("INSERT_FEEDBACK");
                                }
                                catch (Exception exx)
                                {
                                    CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), exx.StackTrace.ToString() + "-->" + "Error in Feedback Insert portion " + exx.Message.ToString());
                                }
                                #endregion

                                #region SMS Store to SMS_TRANS Live 4 March 13

                                try
                                {
                                    strUniqueNo = txtContactNo.Text.Trim();
                                    strAltNo    = txtAltConatctNo.Text.Trim();
                                    if (CommonClass.ValidateMobileNumber(strUniqueNo, ref strValidNumberCus))
                                    {
                                        blnFlagSMSCus = true;
                                    }
                                    else if (CommonClass.ValidateMobileNumber(strAltNo, ref strValidNumberCus))
                                    {
                                        blnFlagSMSCus = true;
                                    }
                                    if (blnFlagSMSCus)
                                    {
                                        strCustomerMessage = "Your Complaint No :" + objCallRegistration.Complaint_RefNoOUT + " will be attended soon. Preserve this no for future communications.";
                                        CommonClass.SendSMS(strValidNumberCus, objCallRegistration.Complaint_RefNoOUT, lngCustomerId.ToString(), DateTime.Now.Date.ToString("yyyyMMdd"), "CGL", strCustomerMessage, strCustomerMessage, "CUS");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
                                }

                                #endregion SMS Store to SMS_TRANS

                                #region For Display Final Grid
                                //Creating row for temp table
                                DataRow dRowTEMP = dTableTemp.NewRow();

                                dRowTEMP["SNo"]             = dTableTemp.Rows.Count + 1;
                                dRowTEMP["ProductDivision"] = dsTemp.Tables[1].Rows[intCnt]["ProductDivision"].ToString();
                                dRowTEMP["ComplaintRefNo"]  = objCallRegistration.Complaint_RefNoOUT;
                                dTableTemp.Rows.Add(dRowTEMP);
                                #endregion For Display Final Grid
                            }
                        }

                        LblMsgg.Text = "Thank you for submitting your Complaint we will back to you soon. Your complaint no is " + objCallRegistration.Complaint_RefNoOUT + " .<br/> "
                                       + "Preserve this no. for future communications.";

                        //Assigning DataSource to Grid
                        gvFinal.DataSource = dTableTemp;
                        gvFinal.DataBind();
                        //End
                        //Clear Files For File Upload Grid
                        dTableFile = (DataTable)ViewState["dTableFile"];
                        dTableFile.Rows.Clear();
                        ViewState["dTableFile"] = dTableFile;
                        BindGridFiles();
                        gvFiles.Visible = false;

                        //End
                        //Clear Product Grid
                        dsProduct = (DataSet)ViewState["ds"];
                        dsProduct.Tables[1].Rows.Clear();
                        ViewState["ds"] = dsProduct;
                        BindGridView();
                        gvComm.Visible = false;
                        //End
                        btnSubmit.CausesValidation = true;
                        tableResult.Visible        = true;
                        btnSubmit.Enabled          = false;
                        btnCancel.Enabled          = false;
                        ClearControls();
                        lblMsg.Text = "";
                    }
                }
            }
            else
            {
                lblMsg.Text = "Product division " + ddlProductDiv.SelectedItem.Text + " is already added. You can update data from above listing.";
            }
        }
Ejemplo n.º 9
0
        // Used in tests that test behavior with specific time intervals
        internal void ReplenishInternal(uint nowTicks)
        {
            bool wrapped = false;

            // (uint)TickCount will wrap every ~50 days, we can detect that by checking if the new ticks is less than the last replenishment
            if (nowTicks < _lastReplenishmentTick)
            {
                wrapped = true;
            }

            // method is re-entrant (from Timer), lock to avoid multiple simultaneous replenishes
            lock (Lock)
            {
                // Fix the wrapping by using a long and adding uint.MaxValue in the wrapped case
                long nonWrappedTicks = wrapped ? (long)nowTicks + uint.MaxValue : nowTicks;
                if (nonWrappedTicks - _lastReplenishmentTick < _options.ReplenishmentPeriod.TotalMilliseconds)
                {
                    return;
                }

                _lastReplenishmentTick = nowTicks;

                int availablePermits = _tokenCount;
                TokenBucketRateLimiterOptions options = _options;
                int maxPermits = options.TokenLimit;
                int resourcesToAdd;

                if (availablePermits < maxPermits)
                {
                    resourcesToAdd = Math.Min(options.TokensPerPeriod, maxPermits - availablePermits);
                }
                else
                {
                    // All tokens available, nothing to do
                    return;
                }

                // Process queued requests
                Deque <RequestRegistration> queue = _queue;

                _tokenCount += resourcesToAdd;
                Debug.Assert(_tokenCount <= _options.TokenLimit);
                while (queue.Count > 0)
                {
                    RequestRegistration nextPendingRequest =
                        options.QueueProcessingOrder == QueueProcessingOrder.OldestFirst
                          ? queue.PeekHead()
                          : queue.PeekTail();

                    if (_tokenCount >= nextPendingRequest.Count)
                    {
                        // Request can be fulfilled
                        nextPendingRequest =
                            options.QueueProcessingOrder == QueueProcessingOrder.OldestFirst
                            ? queue.DequeueHead()
                            : queue.DequeueTail();

                        _queueCount -= nextPendingRequest.Count;
                        _tokenCount -= nextPendingRequest.Count;
                        Debug.Assert(_queueCount >= 0);
                        Debug.Assert(_tokenCount >= 0);

                        if (!nextPendingRequest.Tcs.TrySetResult(SuccessfulLease))
                        {
                            // Queued item was canceled so add count back
                            _tokenCount += nextPendingRequest.Count;
                        }
                        nextPendingRequest.CancellationTokenRegistration.Dispose();
                    }
                    else
                    {
                        // Request cannot be fulfilled
                        break;
                    }
                }
            }
        }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        objCallRegistration.Type = "REGISTER_MTO_COMPLAINT";

        // objCallRegistration.CustomerID = int.Parse(hdnCustomerId.Value);

        // save additional info for RSD
        //if (ddlProductDiv.SelectedValue == "31")   //31 live
        //    objRequestReg.SaveWebRequestMTO(hdnwebreqno.Value, txtequipname.Text, txtcoachNo.Text, txtTrainNo.Text, txtAvailblty.Text, txtCommissionDate.Text, txtDateofReporting.Text, txtPoDate.Text);

        objCallRegistration.Prefix          = ddlPrefix.SelectedValue.ToString();
        objCallRegistration.FirstName       = txtFirstName.Text.Trim();
        objCallRegistration.MiddleName      = txtMiddleName.Text.Trim();
        objCallRegistration.LastName        = txtLastName.Text.Trim();
        objCallRegistration.CompanyName     = txtCompanyName.Text.Trim();
        objCallRegistration.OEMCustomerName = TxtOEMCustName.Text.Trim();

        objCallRegistration.Address1    = txtAdd1.Text.ToString();
        objCallRegistration.Address2    = txtAdd2.Text.ToString();
        objCallRegistration.Landmark    = txtLandmark.Text.Trim();
        objCallRegistration.CountrySNo  = Convert.ToInt32(ddlCountry.SelectedValue);
        objCallRegistration.CountryName = ddlCountry.SelectedItem.Text;
        objCallRegistration.City        = TxtCity.Text.Trim();

        objCallRegistration.Email              = txtEmail.Text.Trim();
        objCallRegistration.ContactNo          = txtContactNo.Text.Trim();
        objCallRegistration.AlternateContactNo = txtAltConatctNo.Text.Trim();
        objCallRegistration.Extension          = txtExtension.Text.Trim();
        objCallRegistration.EmpCode            = Membership.GetUser().UserName.ToString();

        objCallRegistration.ProductDivSNo  = Convert.ToInt32(ddlProductDiv.SelectedValue);
        objCallRegistration.ProductLineSno = Convert.ToInt32(ddlProductLine.SelectedValue);
        objCallRegistration.ProductSNo     = Convert.ToInt32(ddlProduct.SelectedValue);
        objCallRegistration.InvoiceNo      = txtInvoiceNum.Text.Trim();
        objCallRegistration.Remarks        = txtComplaintDetails.Text.Trim();

        objCallRegistration.Remarks      = txtComplaintDetails.Text.Trim();
        objCallRegistration.InvoiceNo    = txtInvoiceNum.Text.Trim();
        objCallRegistration.PurchaseDate = txtxPurchaseDate.Text.Trim();

        objCallRegistration.ManufactureDate      = txtPoDate.Text.Trim();
        objCallRegistration.Warranty_Expiry_date = txtWarrantyDate.Text.Trim();
        objCallRegistration.DateOfCommission     = txtCommissionDate.Text.Trim();
        objCallRegistration.DateOfReporting      = txtDateofReporting.Text.Trim();
        objCallRegistration.ProductSRNo          = txtPrdSRNo.Text.Trim();
        objCallRegistration.DispatchDate         = txtDateofDispatch.Text.Trim();

        objCallRegistration.EquipmentName    = txtequipname.Text.Trim();
        objCallRegistration.TrainNo          = txtTrainNo.Text.Trim();
        objCallRegistration.CoachNo          = txtcoachNo.Text.Trim();
        objCallRegistration.AvailablityDepot = txtAvailblty.Text.Trim();
        objCallRegistration.RegisterMTOComplaint();

        ArrayList arrListFiles = new ArrayList();

        if (objCallRegistration.CustomerID > 0)
        {
            #region Upload file

            strFileSavePath = ConfigurationSettings.AppSettings["CustomerFilePath"].ToString();
            dTableFile      = (DataTable)ViewState["dTableFile"];
            if (flUpload.Value != "")
            {
                try
                {
                    if (!Directory.Exists(strFileSavePath))
                    {
                        Directory.CreateDirectory(Server.MapPath(strFileSavePath));
                    }
                    strvFileName = flUpload.Value;
                    strFileName  = Path.GetFileName(strvFileName);
                    strExt       = Path.GetExtension(strvFileName);
                    strFileName  = Path.GetFileNameWithoutExtension(strvFileName) + "_" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                    strFileName  = strFileName + strExt;
                    DataRow dRow = dTableFile.NewRow();
                    dRow["FileName"] = strFileName;
                    dTableFile.Rows.Add(dRow);
                    ViewState["dTableFile"] = dTableFile;
                    flUpload.PostedFile.SaveAs(Server.MapPath(strFileSavePath + strFileName));
                }
                catch (Exception ex)
                {
                    CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
                }
            }
            dTableFile = (DataTable)ViewState["dTableFile"];
            for (intCnt = 0; intCnt < dTableFile.Rows.Count; intCnt++)
            {
                arrListFiles.Add(dTableFile.Rows[intCnt]["FileName"].ToString());
            }
            //Uploading Files End
            #endregion Upload file

            //Create Temp table for Complaint + SC Name
            DataTable  dTableTemp      = new DataTable();
            DataColumn dColNo          = new DataColumn("SNo");
            DataColumn dColComplaintNo = new DataColumn("ComplaintRefNo");
            DataColumn dColProd        = new DataColumn("ProductDivision");
            dTableTemp.Columns.Add(dColNo);
            dTableTemp.Columns.Add(dColComplaintNo);
            dTableTemp.Columns.Add(dColProd);

            if (objCallRegistration.ReturnValue == 1)
            {
                #region Save FileData
                RequestRegistration objCallreg = new RequestRegistration();
                //Saving FileNames to DB
                for (int i = 0; i < arrListFiles.Count; i++)
                {
                    objCallreg.EmpCode = Membership.GetUser().UserName.ToString();
                    objCallreg.Type    = "INSERT_COMPLAINT_FILES_DATA";
                    objCallreg.SaveFilesWithComplaintno(objCallRegistration.Complaint_RefNoOUT, arrListFiles[i].ToString());
                }
                objCallreg = null;
                //End Saving
                #endregion Save FileData

                #region For Display Final Grid
                //Creating row for temp table
                DataRow dRowTEMP = dTableTemp.NewRow();

                dRowTEMP["SNo"]             = dTableTemp.Rows.Count + 1;
                dRowTEMP["ProductDivision"] = ddlProductDiv.SelectedItem.Text;
                dRowTEMP["ComplaintRefNo"]  = objCallRegistration.Complaint_RefNoOUT;
                dTableTemp.Rows.Add(dRowTEMP);
                #endregion
            }

            //Assigning DataSource to Grid
            gvFinal.DataSource = dTableTemp;
            gvFinal.DataBind();
            //End
            //Clear Files For File Upload Grid
            dTableFile = (DataTable)ViewState["dTableFile"];
            dTableFile.Rows.Clear();
            ViewState["dTableFile"] = dTableFile;

            gvFiles.Visible            = false;
            btnSubmit.CausesValidation = true;
            tableResult.Visible        = true;
            btnSubmit.Enabled          = false;
            btnCancel.Enabled          = false;
            ClearControls();
            ClearComplaintDetails();
            lblMsg.Text = "";
        }
        #endregion
    }
Ejemplo n.º 11
0
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            //Assigning values to properties
            objwscCustomerComplaint.WSCCustomerId          = hdnWSCCustomerId.Value;
            objwscCustomerComplaint.Prefix                 = ddlPrefix.SelectedValue.ToString();
            objwscCustomerComplaint.FileName               = txtFirstName.Text.Trim();
            objwscCustomerComplaint.LastName               = txtLastName.Text.Trim();
            objwscCustomerComplaint.Address                = txtAdd1.Text.Trim();
            objwscCustomerComplaint.Company_Name           = txtCompanyName.Text.Trim();
            objwscCustomerComplaint.Contact_No             = txtContactNo.Text.Trim();
            objwscCustomerComplaint.Country_Sno            = Convert.ToInt32(ddlCountry.SelectedValue);
            objwscCustomerComplaint.State_Sno              = Convert.ToInt32(ddlState.SelectedValue);
            objwscCustomerComplaint.City_Sno               = Convert.ToInt32(ddlCity.SelectedValue);
            objwscCustomerComplaint.Email                  = txtEmail.Text.Trim();
            objwscCustomerComplaint.Feedback_Type          = Convert.ToInt32(ddlFeedbackType.SelectedValue);
            objwscCustomerComplaint.Feedback               = txtfeedback.Text.Trim();
            objwscCustomerComplaint.ProductDivisionId      = Convert.ToInt32(ddlProductDiv.SelectedValue);
            objwscCustomerComplaint.ProductLineId          = Convert.ToInt32(ddlProductLine.SelectedValue);
            objwscCustomerComplaint.Rating_Voltage         = txtRating.Text.Trim();
            objwscCustomerComplaint.Manufacturer_Serial_No = txtManufacturerSerialNo.Text.Trim();

            objwscCustomerComplaint.Manufacture_Year    = txtxPurchaseDate.Text.Trim();
            objwscCustomerComplaint.Site_Location       = txtlocation.Text.Trim();
            objwscCustomerComplaint.Nature_of_Complaint = txtCompNature.Text.Trim();
            objwscCustomerComplaint.CGExe_Feedback      = Convert.ToInt32(ddlGCExecutive.SelectedValue.ToString());
            objwscCustomerComplaint.CGExe_Comment       = txtCGExecutive.Text.Trim();
            objwscCustomerComplaint.EmpCode             = Membership.GetUser().UserName.ToString();


            //uploading Files to Server on Folder Docs/Customer
            ArrayList arrListFiles = new ArrayList();
            strFileSavePath = ConfigurationSettings.AppSettings["CustomerFilePath"].ToString();
            dTableFile      = (DataTable)ViewState["dTableFile"];
            if (flUpload.Value != "")
            {
                try
                {
                    if (!Directory.Exists(strFileSavePath))
                    {
                        Directory.CreateDirectory(Server.MapPath(strFileSavePath));
                    }
                    strvFileName = flUpload.Value;
                    strFileName  = Path.GetFileName(strvFileName);
                    strExt       = Path.GetExtension(strvFileName);
                    strFileName  = Path.GetFileNameWithoutExtension(strvFileName) + "_" + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString();
                    strFileName  = strFileName + strExt;
                    DataRow dRow = dTableFile.NewRow();
                    dRow["FileName"] = strFileName;
                    dTableFile.Rows.Add(dRow);
                    ViewState["dTableFile"] = dTableFile;
                    flUpload.PostedFile.SaveAs(Server.MapPath(strFileSavePath + strFileName));
                }
                catch (Exception ex)
                {
                    CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
                }
            }

            dTableFile = (DataTable)ViewState["dTableFile"];
            for (intCnt = 0; intCnt < dTableFile.Rows.Count; intCnt++)
            {
                arrListFiles.Add(dTableFile.Rows[intCnt]["FileName"].ToString());
            }
            //Uploading Files End

            objwscCustomerComplaint.SaveComplaint("UPDATE_CUSTOMER_INFORMATION");

            if (objwscCustomerComplaint.ReturnValue == -1)
            {
                lblMsg.Text = CommonClass.getErrorWarrning(enuErrorWarrning.ErrorInStoreProc, enuMessageType.Error, false, "");
            }
            else
            {
                // Save FileData
                RequestRegistration objCallreg = new RequestRegistration();
                for (int i = 0; i < arrListFiles.Count; i++)
                {
                    objwscCustomerComplaint.SaveFiles(objwscCustomerComplaint.WebRequest_RefNo, arrListFiles[i].ToString());
                }

                //End Saving
                lblMsg.Text = CommonClass.getErrorWarrning(enuErrorWarrning.AddRecord, enuMessageType.UserMessage, false, "");
                //Clear Files For File Upload Grid
                dTableFile = (DataTable)ViewState["dTableFile"];
                dTableFile.Rows.Clear();
                ViewState["dTableFile"] = dTableFile;
                BindGridFiles();
                gvFiles.Visible = false;
                //End

                if (ddlFeedbackType.SelectedValue == "1")
                {
                    //if (hdnProductSrno.Value != "0" || hdnProductSrno.Value != "")
                    //{
                    //Assign Value in Session
                    Session["PRODUCTSRNO"] = hdnProductSrno.Value;
                    Response.Redirect("../pages/MTOServiceRegistration.aspx");
                    //End
                    //Response.Redirect
                    //HttpContext.Current.Items.Add("PRODUCTSRNO", hdnProductSrno.Value);
                    //Server.Transfer("../pages/MTOServiceRegistration.aspx",false);
                    //}
                }
                else
                {
                    sqlParamSrh[1].Value = ddlSearch.SelectedValue.ToString();
                    sqlParamSrh[2].Value = txtSearch.Text.Trim();
                    objCommonClass.BindDataGrid(gvComm, "uspWSCCustomerRegistration", true, sqlParamSrh, lblRowCount);
                    ClearControls();
                }
            }
        }
        catch (Exception ex)
        {
            //Writing Error message to File using CommonClass WriteErrorErrFile method taking arguments as URL of page
            // trace, error message
            CommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
        }
    }
    protected void imgBtnUpdate_Click(object sender, EventArgs e)
    {
        try
        {
            if (hdnSpareId.Value != "")
            {
                objBasicSpare.SpareId            = hdnSpareId.Value;
                objBasicSpare.ProductDivision_Id = Convert.ToInt32(ddlDivision.SelectedValue);
                objBasicSpare.SpareCode          = txtSpareCode.Text.Trim();
                objBasicSpare.SpareDesc          = txtSpareDesc.Text.Trim();
                //objBasicSpare.UOM = txtUOM.Text.Trim();
                objBasicSpare.UOM            = ddlUOM.SelectedValue;
                objBasicSpare.Listprice      = txtListprice.Text.Trim();
                objBasicSpare.Materialgroup  = txtMaterialgroup.Text.Trim();
                objBasicSpare.MaterialType   = ddlMaterialType.SelectedValue.ToString();
                objBasicSpare.SpareObsolete  = rdoSpareObsolete.SelectedValue.ToString();
                objBasicSpare.EssentialSpare = ChkEssentialSpare.SelectedValue.ToString();
                objBasicSpare.SpareMoving    = ddlSpareMoving.SelectedValue.ToString();
                objBasicSpare.SpareValue     = ddlSpareValue.SelectedValue.ToString();
                objBasicSpare.SpareType      = ddlSpareType.SelectedValue.ToString();
                objBasicSpare.MinimumOrder   = txtMinimumOrder.Text.Trim();
                objBasicSpare.Discount       = txtDiscount.Text.Trim();
                //objBasicSpare.fpSparephoto = fpSparephoto.SelectedValue.ToString();

                objBasicSpare.Sparedisposal = ddlSparedisposal.SelectedValue.ToString();
                objBasicSpare.SpareAction   = ddlSpareAction.SelectedValue.ToString();
                objBasicSpare.ActionBy      = Membership.GetUser().UserName.ToString();
                objBasicSpare.ActiveFlag    = rdoStatus.SelectedValue.ToString();
                objBasicSpare.ActionType    = "UPDATE_SPAREMASTER";
                objBasicSpare.SaveSpareMaster();
                objBasicSpare.SpareId = hdnSpareId.Value;
                //uploading Files to Server on Folder Docs/Customer
                ArrayList arrListFiles = new ArrayList();
                dTableFile = (DataTable)ViewState["dTableFile"];
                for (intCnt = 0; intCnt < dTableFile.Rows.Count; intCnt++)
                {
                    arrListFiles.Add(dTableFile.Rows[intCnt]["FileName"].ToString());
                }

                if (objBasicSpare.ReturnValue == -1)
                {
                    //MESSAGE AT ERROR IN STORED PROCEDURE

                    SIMSCommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), objBasicSpare.MessageOut);
                    lblMessage.Text = SIMSCommonClass.getErrorWarrning(SIMSenuErrorWarrning.ErrorInStoreProc, SIMSenuMessageType.Error, false, "");
                }
                else
                {
                    //MESSAGE IF RECORD ALREADY EXIST
                    if (objBasicSpare.MessageOut == "Exists")
                    {
                        lblMessage.Text = SIMSCommonClass.getErrorWarrning(SIMSenuErrorWarrning.DulplicateRecord, SIMSenuMessageType.UserMessage, false, "");
                    }
                    else if (objBasicSpare.MessageOut == "Using in Childs")
                    {
                        lblMessage.Text = SIMSCommonClass.getErrorWarrning(SIMSenuErrorWarrning.ActivateStatusNotChange, SIMSenuMessageType.UserMessage, false, "");
                    }
                    else
                    {
                        //MESSAGE IF RECORD UPDATED SUCCESSFULLY
                        // Save FileData
                        RequestRegistration objCallreg = new RequestRegistration();
                        objBasicSpare.DeleteImageFiles(objBasicSpare.SpareId);
                        for (int i = 0; i < arrListFiles.Count; i++)
                        {
                            objBasicSpare.SaveFiles(objBasicSpare.SpareId, arrListFiles[i].ToString());
                        }

                        //End Saving
                        lblMessage.Text = SIMSCommonClass.getErrorWarrning(SIMSenuErrorWarrning.RecordUpdated, SIMSenuMessageType.UserMessage, false, "");
                        ClearControls();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            lblMessage.Text = SIMSCommonClass.getErrorWarrning(SIMSenuErrorWarrning.ErrorInStoreProc, SIMSenuMessageType.Error, false, "");
            //Writing Error message to File using CommonClass WriteErrorErrFile method taking arguments as URL of page
            // trace, error message
            SIMSCommonClass.WriteErrorErrFile(Request.RawUrl.ToString(), ex.StackTrace.ToString() + "-->" + ex.Message.ToString());
        }
        finally
        {
            BindGrid();
        }
    }
Ejemplo n.º 13
0
 protected void Page_UnLoad(object sender, EventArgs e)
 {
     objCallregistration = null;
 }