Sandeep Kumar

Sandeep Kumar

  • 1.1k
  • 684
  • 61.7k

how to tell where I call Service Method to till Task complete

Nov 5 2022 6:28 AM

My problem is when i call web service method in web page then without wait ,process  time out ,

even in my service i have declared   cmd.CommandTimeout = 0;.

so i want to wait untill process finished

Error Screen Shot

 [WebMethod(CacheDuration = 60, Description = "Return MIS Report")]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public DataTable Get_Mis_Report(string fromdt, string todt, int dept, int group, string claass, int contractor, int areaobservation, int area, int Severity, int createdby, string time_millisecond, int ObsAreaId)
    {
        DataTable Dt = new DataTable("mytable");
      //  DataTable DtReport = new DataTable();
        string RetValue = string.Empty;
        var data = string.Empty;
        try
        {

     
            using (SqlConnection con = new SqlConnection(strConnString))
            {
                using (SqlCommand cmd = new SqlCommand("VVS_Get_ObservationDetailsReports", con))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@FromDate", SqlDbType.NVarChar).Value = fromdt;
                    cmd.Parameters.Add("@ToDate", SqlDbType.NVarChar).Value = todt;
                    cmd.Parameters.Add("@Dept", SqlDbType.Int).Value = dept;
                    cmd.Parameters.Add("@GroupID", SqlDbType.Int).Value = group;
                    cmd.Parameters.Add("@classs", SqlDbType.NVarChar).Value = claass;
                    cmd.Parameters.Add("@ContractorID", SqlDbType.Int).Value = contractor;
                    cmd.Parameters.Add("@AreaOfObserv", SqlDbType.Int).Value = areaobservation;
                    cmd.Parameters.Add("@AreaID", SqlDbType.Int).Value = area;
                    cmd.Parameters.Add("@SeverityID", SqlDbType.Int).Value = Severity;
                    cmd.Parameters.Add("@CreatedBy", SqlDbType.Int).Value = createdby;
                    cmd.Parameters.Add("@time_millSecond", SqlDbType.NVarChar).Value = time_millisecond;
                    cmd.Parameters.Add("@GroupNo", SqlDbType.Int).Value = ObsAreaId;
                   
                    cmd.CommandTimeout = 0;

                    SqlDataAdapter adp = new SqlDataAdapter(cmd);
                   
                    adp.Fill(Dt);
                   
                }

            }
          
        }
      
        catch(Exception ex)
        {

        }
        if (Dt.Rows.Count > 0)
        {

            return Dt;
        }
        else
        {
            return Dt;
        }
    }

------------------------------------------------------------------------Another Project where i use Web Service-----------------------------------

 

private void Search(string time_milliseconds)
    {
        string fromdate = txtfrom.Text.Trim();
        string todate = txtto.Text.Trim();
        int dept = Convert.ToInt32(ddlResponsibleDept.SelectedValue.ToString());
        int groupnm = Convert.ToInt32(ddlGroup.SelectedValue.ToString());
        string classs = ddlClass.SelectedItem.ToString();
        int contractor = Convert.ToInt32(ddlContractor.SelectedValue.ToString());
        int areaobsevation = 0;
        int severity = Convert.ToInt32(ddlseverity.SelectedValue.ToString());
        int createdby = 1;
        int area = Convert.ToInt32(ddlArea.SelectedValue.ToString());
        int areaOfObservation = Convert.ToInt32(ddlAreaofObservation.SelectedValue.ToString());
        time_millisecond = DateTime.Now.Millisecond.ToString();
        DataTable data = new DataTable();
        try
        {
            CESC_BBGS_GEN_MOB_APP_SERVICE_WS.CESC_BBGS_GEN_MOB_APP_SERVICE df = new CESC_BBGS_GEN_MOB_APP_SERVICE_WS.CESC_BBGS_GEN_MOB_APP_SERVICE();
            data = df.Get_Mis_Report(fromdate, todate, dept, areaOfObservation, classs, contractor, areaobsevation, area, severity, createdby, time_millisecond, groupnm);
            if (data.Rows.Count > 0)
            {
                txtNoofpeople.Text = data.Rows[0]["Noofpeopleobservedatsite"].ToString();
                txtGPHr.Text = data.Rows[0]["Obs_Hr_GP"].ToString();
                lblTotalMarks.Text = data.Rows[0]["Total_Cal"].ToString();
                lblYesTotalMarks.Text = data.Rows[0]["TotalCalForYes"].ToString();
                txtUAHr.Text = data.Rows[0]["Obs_Hr_UA"].ToString();
                txtPeopleWorkingsafely.Text = data.Rows[0]["Obs_Per_working_safely"].ToString();
                txtIssueclosed.Text = data.Rows[0]["Per_Issueclosed"].ToString();
                grdobservationrpt.DataSource = data;
                grdobservationrpt.DataBind();
            }
            else
            {
                grdobservationrpt.DataSource = null;
                grdobservationrpt.DataBind();
            }
        }
        catch (Exception ex)
        {

        }
    }


Answers (3)