Android Question How to check Blank Data for Json in JobDone Event

junaidahmed

Well-Known Member
Licensed User
Longtime User
I have used "OkHttpUtils2" to get "JSon" Data.It works fine When I get Full "Json Data",If my sql Query return "Empty" then My Json Data output is "[]"

So if there is No JSon Data the Job goes to failed.

Please advise how can I check Blank Data in JobDone Event.....

 

junaidahmed

Well-Known Member
Licensed User
Longtime User
In Browser it returns "[]",but in Job Done Event it shows an error message as "android.system.Errnoexception:Open failed : ENOENT (No such file or directory)"
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
We can not help if you decide to hide the code you are using.
 
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
Please check my ASPX code and B4A Code

ASP.NET:-
B4X:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BLToolkit.Data;
using KHEXPORTSLIBRARY;
using System.Data;
using System.Data.SqlClient;
using System.IO;
using System.Web.Script.Serialization;
using System.Text;
using Newtonsoft.Json;

namespace SMSDemo
{
    public partial class FrmToDo : System.Web.UI.Page
    {
        DbManager Db = new DbManager();
        DataTable Table = new DataTable();

        public static string StrQuery;
      
        protected void Page_Load(object sender, EventArgs e)
        {
            string c;
            c = Request.QueryString["query"]; //for debugging with the browser
            Table = Db.SetCommand(c).ExecuteDataTable();
            Response.Write(DataTableToJSONWithJSONNet(Table));

        }


        public string DataTableToJSONWithJSONNet(DataTable table)
        {
            string JSONString = string.Empty;
            JSONString = JsonConvert.SerializeObject(table);
            return JSONString;
        }


    }

}

B4ACode:-

B4X:
Sub GetQuery(Query As String,StrJobName As String)
          
   Dim Job As HttpJob
   Job.Initialize(StrJobName, Me)
   Job.PostString("http://103.76.188.138:85/Android/FrmGetQuery.aspx?Query="&Query,"")
   ProgressDialogShow("Calling KHARIND server...")
 
End Sub

Sub JobDone (Job As HttpJob)
 
   Try
       Msgbox(Job.JobName,"")
       Msgbox(Job.GetString(),"")
       If Job.Success Then
           If (Job.JobName = "StageList") Then
               Dim parser As JSONParser
               parser.Initialize(Job.GetString())
               Dim root As List = parser.NextArray
               For Each colroot As Map In root
                   SpinnerMap.Put(colroot.Get("Stage"), colroot.Get("Serial"))
                   CboStage.Add(colroot.Get("Stage"))
               Next
               StrStageCode = CboStage.SelectedItem
           Else if (Job.JobName = "CutSlipDet") Then
               Dim parser As JSONParser
               parser.Initialize(Job.GetString())
               Dim root As List = parser.NextArray
               For Each colroot As Map In root
                   TxtOrderNo.Text = colroot.Get("OrderNo")
                   TxtStyleNo.Text = colroot.Get("Style")
                   TxtColor.Text = colroot.Get("Color")
                   TxtPairs.Text = colroot.Get("Pairs")
               Next
           End If
           ProgressDialogHide
       Else
           Msgbox("Failed","")
           ProgressDialogHide
       End If
       Job.Release
   Catch
       Msgbox(LastException,"")
       ProgressDialogHide
   End Try
 
 
 
End Sub


Sub CmdPrev_Click
   'CboStage.SelectedIndex =  CboStage.SelectedIndex - 1
   GetQuery("Select C.*,L.itemdesc Leather,Li.itemdesc Lining,P.cuttype,P.cutbtc,P.sewtype,P.finbtc FinBTL,P.Image,S.PDesc Hemming  from Arind.Dbo.FnCutSlipMovesNew('" & TxtCutSlipNo.Text & "','" & StrStageCode & "') C Join Arind.Dbo.ProSpec P On P.StyleNo = C.Style Join Arind.Dbo.Leather L On L.itemcode = SubString(P.Leather1,1,6) Left Join Arind.Dbo.Lining Li On Li.itemcode = P.lining Left Join Arind.Dbo.SpecParam S On S.pcode = P.hemtype And S.ptype = 'HM'","CutSlipDet")
End Sub
 
Upvote 0

junaidahmed

Well-Known Member
Licensed User
Longtime User
As per Erel,I have remove above msgbox in JobDone Event.

Actually I have two Job "StageList" and "CutSlipDet"...

The first job is success, and why second job is failed ???
 
Upvote 0
Top