public async Task <ReportRenderResponse> GetPdfOnline(string refid, string param)
        {
            ReportRenderResponse resp = null;

            try
            {
                RestRequest request = new RestRequest(ApiConstants.GET_PDF, Method.GET);
                // auth Headers for api
                request.AddHeader(AppConst.BTOKEN, App.Settings.BToken);
                request.AddHeader(AppConst.RTOKEN, App.Settings.RToken);

                request.AddParameter("refid", refid);
                request.AddParameter("param", param);

                IRestResponse response = await HttpClient.ExecuteAsync(request);

                if (response.IsSuccessful)
                {
                    resp = JsonConvert.DeserializeObject <ReportRenderResponse>(response.Content);
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
            return(resp);
        }
        public async Task <bool> Print(int rowId)
        {
            bool success = false;

            try
            {
                if (this.PrintDocs?.Count > 0)
                {
                    PdfService   PdfService = new PdfService();
                    List <Param> param      = new List <Param>();
                    if (this.RenderAsFilterDialog)
                    {
                        foreach (KeyValuePair <string, EbMobileControl> pair in this.ControlDictionary)
                        {
                            EbMobileControl ctrl = pair.Value;
                            if (ctrl is IFileUploadControl || ctrl is EbMobileDataGrid)
                            {
                                continue;
                            }
                            param.Add(new Param
                            {
                                Name  = ctrl.Name,
                                Type  = ((int)ctrl.EbDbType).ToString(),
                                Value = Convert.ToString(ctrl.GetValue())
                            });
                        }
                    }
                    else
                    {
                        param.Add(new Param
                        {
                            Name  = "id",
                            Type  = ((int)EbDbTypes.Int32).ToString(),
                            Value = rowId.ToString()
                        });
                    }

                    ReportRenderResponse r = null;

                    if (NetworkType == NetworkMode.Online)
                    {
                        if (!Utils.IsNetworkReady(this.NetworkType))
                        {
                            Utils.Alert_NoInternet();
                            return(false);
                        }
                        r = await PdfService.GetPdfOnline(this.PrintDocs[0].ObjRefId, JsonConvert.SerializeObject(param));
                    }
                    else if (NetworkType == NetworkMode.Offline)
                    {
                        r = PdfService.GetPdfOffline(this.PrintDocs[0].ObjRefId, JsonConvert.SerializeObject(param));
                    }

                    if (r?.ReportBytea != null)
                    {
                        INativeHelper helper = DependencyService.Get <INativeHelper>();
                        string        root   = App.Settings.AppDirectory;
                        string        path   = helper.NativeRoot + $"/{root}/{AppConst.SHARED_MEDIA}/{App.Settings.Sid.ToUpper()}/PDF{(DateTime.UtcNow.ToString("yyyyMMddHHmmss"))}.pdf";
                        File.WriteAllBytes(path, r.ReportBytea);

                        IAppHandler handler = DependencyService.Get <IAppHandler>();
                        string      res     = await handler.PrintPdfFile(path);

                        if (res != "success")
                        {
                            await Launcher.OpenAsync(new OpenFileRequest
                            {
                                File = new ReadOnlyFile(path)
                            });
                        }
                        success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.Toast("Error: " + ex.Message);
                EbLog.Error("Error in [EbMobileForm.Print] " + ex.Message + " " + ex.StackTrace);
            }
            return(success);
        }