private void UpdateErrorDraftIds(List <int> DraftIds) { try { List <string> depT = new List <string>(); int i; List <EbMobileForm> FormCollection = EbPageHelper.GetOfflineForms(); foreach (EbMobileForm Form in FormCollection) { if (depT.Contains(Form.TableName)) { continue; } EbDataTable dt = Form.GetDraftIds(); foreach (EbDataRow dr in dt.Rows) { i = Convert.ToInt32(dr[0]); if (!DraftIds.Contains(i)) { Form.UpdateDraftAsSynced(Convert.ToInt32(dr[1]), i); } } } } catch (Exception ex) { EbLog.Error("UpdateErrorDraftIds: " + ex.Message); } }
public async void InitNavigation() { EbMobileSettings settings = App.Settings.CurrentApplication?.AppSettings; IMasterPage master; if (settings != null && !string.IsNullOrEmpty(settings.DashBoardRefId)) { EbMobilePage page = EbPageHelper.GetPage(settings.DashBoardRefId); if (page != null && page.Container is EbMobileDashBoard) { master = new DashBoardRender(page); } else { EbLog.Info("Default application dashboard not found, check object permissions"); master = new Home(); } } else { master = new Home(); } master.UpdateMasterLayout(); await Detail.Navigation.PushAsync((Page)master); }
protected override async Task NavigateToFabLink() { if (IsTapped || EbPageHelper.IsShortTap()) { return; } IsTapped = true; Loader msgLoader = EbLayout.GetMessageLoader(); msgLoader.IsVisible = true; msgLoader.Message = "Loading..."; string linkRefID = Visualization.UseLinkSettings ? Visualization.LinkRefId : Visualization.FabLinkRefId; EbMobilePage page = EbPageHelper.GetPage(linkRefID); if (page != null && page.Container is EbMobileForm form) { form.NetworkType = page.NetworkMode; string failMsg = await EbPageHelper.ValidateFormRendering(form, msgLoader, this.ContextRecord); if (failMsg == null) { await App.Navigation.NavigateMasterAsync(new FormRender(page, Visualization, ContextRecord)); } else { await App.Navigation.NavigateMasterAsync(new Redirect(failMsg)); } } msgLoader.IsVisible = false; IsTapped = false; }
public static EbMobileForm ResolveDependency(this EbMobileForm sourceForm) { try { EbMobilePage autogenvis = EbPageHelper.GetPage(sourceForm.AutoGenMVRefid); if (autogenvis != null) { string linkref = (autogenvis.Container as EbMobileVisualization).LinkRefId; if (!string.IsNullOrEmpty(linkref)) { EbMobilePage linkpage = EbPageHelper.GetPage(linkref); if (linkpage != null && linkpage.Container is EbMobileVisualization viz) { EbMobilePage innerlink = EbPageHelper.GetPage(viz.LinkRefId); if (innerlink != null && innerlink.Container is EbMobileForm mf) { return(mf); } } } } } catch (Exception ex) { EbLog.Info("Failed to resolve form dependencies"); EbLog.Error(ex.Message); } return(null); }
public async virtual Task OnControlAction(EbDataRow row) { if (string.IsNullOrEmpty(this.LinkRefId)) { return; } EbMobilePage page = EbPageHelper.GetPage(this.LinkRefId) ?? EbPageHelper.GetExternalPage(this.LinkRefId); if (page != null) { EbMobileContainer container = page.Container; if (container is EbMobileForm) { if (this.FormMode == WebFormDVModes.New_Mode) { await App.Navigation.NavigateMasterAsync(new FormRender(page, this.LinkFormParameters, row)); } else { try { var map = this.FormId; if (map == null) { EbLog.Info("form id should be set"); throw new Exception("Form rendering exited! due to null value for 'FormId'"); } else { int id = Convert.ToInt32(row[map.ColumnName]); if (id <= 0) { EbLog.Info("id has ivalid value" + id); throw new Exception("Form rendering exited! due to invalid id"); } await App.Navigation.NavigateMasterAsync(new FormRender(page, id)); } } catch (Exception ex) { EbLog.Error(ex.Message); } } } else if (container is EbMobileVisualization) { await App.Navigation.NavigateMasterAsync(new ListRender(page, row)); } } }
private async Task EditButtonClicked() { EbMobilePage page = EbPageHelper.GetPage(Context.SourceFormRefId); if (page != null) { int id = Convert.ToInt32(ContextRecord["id"]); if (id != 0) { FormRender Renderer = new FormRender(page, id); await App.Navigation.NavigateMasterAsync(Renderer); } } }
private async Task ResolveRedirection(EbNFLink link) { if (string.IsNullOrEmpty(link.LinkRefId)) { EbLog.Info("Intentaction link type is page but linkrefid null"); return; } EbMobilePage page = EbPageHelper.GetPage(link.LinkRefId); if (page != null) { EbLog.Info("Intentaction page rendering :" + page.DisplayName); ContentPage renderer = EbPageHelper.GetPageByContainer(page); await App.Navigation.NavigateMasterAsync(renderer); } else { EbLog.Info("Intentaction page not found for linkrefid:" + link.LinkRefId); } }
private async void OnClick(object sender, EventArgs e) { if (isTapped) { return; } try { isTapped = true; EbMobilePage page = EbPageHelper.GetPage(LinkRefId); if (page != null) { EbPageRenderer renderer = await EbPageHelper.GetRenderer(page); if (renderer.IsReady) { EbLog.Info(renderer.Message); await App.Navigation.NavigateMasterAsync(renderer.Renderer); } else { EbLog.Error("unable to create renderer, [DataLink] " + renderer.Message); } } else { EbLog.Warning("page not found in [DataLink], Check permission"); } } catch (Exception ex) { EbLog.Info("[EbMobileDashboard] click navigation error"); EbLog.Error(ex.Message); } isTapped = false; }
private void AdjustButtonContainer() { if (viewModel.Form.PrintDocs?.Count > 0) { if (viewModel.Form.RenderAsFilterDialog) { ButtonGrid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star); (ButtonGrid.Children[0] as Button).IsVisible = false; (ButtonGrid.Children[1] as Button).IsVisible = true; viewModel.MsgLoader.Message = "Loading..."; } else { ButtonGrid.ColumnDefinitions[0].Width = new GridLength(1, GridUnitType.Star); ButtonGrid.ColumnDefinitions[1].Width = new GridLength(1, GridUnitType.Star); (ButtonGrid.Children[1] as Button).IsVisible = true; } } if (!viewModel.Form.RenderAsFilterDialog) { string msg = EbPageHelper.GetFormRenderInvalidateMsg(viewModel.NetworkType); if (msg != null) { (ButtonGrid.Children[0] as Button).IsVisible = false; (ButtonGrid.Children[1] as Button).IsVisible = false; SaveButton.IsEnabled = false; App.Navigation.PopByRenderer(true); Utils.Toast(msg); } if (viewModel.Mode == FormMode.EDIT) { if (!EbPageHelper.HasEditPermission(App.Settings.CurrentUser, viewModel.Page.RefId)) { viewModel.IsEditButtonVisible = false; } } } }
private void DeleteUnwantedRecords() { try { List <EbMobileForm> FormCollection = EbPageHelper.GetOfflineForms(); foreach (EbMobileForm Form in FormCollection) { DateTime date = DateTime.UtcNow.AddDays(-7); DbParameter[] parameter = new DbParameter[] { new DbParameter { ParameterName = "@strdate", DbType = (int)EbDbTypes.String, Value = date.ToString("yyyyMMdd", CultureInfo.InvariantCulture) } }; string query = Form.GetDeleteQuery(); int rowsAffected = App.DataDB.DoNonQuery(query, parameter); EbLog.Info(rowsAffected + " row(s) deleted from " + Form.TableName + " and its lines table"); } } catch (Exception ex) { EbLog.Error(ex.Message); } }
private string GetErrorDraftIds() { List <int> draft_ids = new List <int>(); int i; try { var depT = new List <string>(); List <EbMobileForm> FormCollection = EbPageHelper.GetOfflineForms(); foreach (EbMobileForm Form in FormCollection) { if (depT.Contains(Form.TableName)) { continue; } EbDataTable dt = Form.GetDraftIds(); foreach (EbDataRow dr in dt.Rows) { i = Convert.ToInt32(dr[0]); if (!draft_ids.Contains(i)) { draft_ids.Add(i); } } } } catch (Exception ex) { EbLog.Error("GetErrorDraftIds: " + ex.Message); } return(JsonConvert.SerializeObject(draft_ids)); }
public async Task <SyncResponse> PushDataToCloud(Loader loader = null) { SyncResponse response = new SyncResponse() { Status = true }; int totalRecords = 0, failedCount = 0; try { List <EbMobileForm> FormCollection = EbPageHelper.GetOfflineForms(); WebformData webdata = new WebformData(); var depT = new List <string>(); int localid; foreach (EbMobileForm Form in FormCollection) { if (depT.Contains(Form.TableName)) { continue; } EbMobileForm DependencyForm = Form.ResolveDependency(); if (DependencyForm != null) { depT.Add(DependencyForm.TableName); } EbDataTable SourceData = Form.GetLocalData(); totalRecords += SourceData.Rows.Count; string msg = $"Pushing {Form.DisplayName} {{0}} of {SourceData.Rows.Count}"; for (int i = 0; i < SourceData.Rows.Count; i++) { if (loader != null) { Device.BeginInvokeOnMainThread(() => { loader.Message = string.Format(msg, i + 1); }); } localid = Convert.ToInt32(SourceData.Rows[i]["id"]); EbLog.Info(string.Format(msg, i + 1) + "; Local Id: " + localid); Form.UpdateRetryCount(SourceData.Rows[i]); PushResponse resp = await SendRecord(webdata, Form, SourceData, SourceData.Rows[i], i); if (resp.RowAffected <= 0) { response.Status = false; failedCount++; EbLog.Error("Push Data Failed: " + resp.Message + "; " + resp.MessageInt); } else { Form.FlagLocalRow(resp); if (DependencyForm != null)//// error submission must be consider [flow pending...] { await PushDependencyData(webdata, Form, DependencyForm, resp.RowId, resp.LocalRowId); } } } } if (response.Status) { response.Message = "Push completed"; DeleteUnwantedRecords(); } else if (failedCount > 0) { response.Message = $"{failedCount} of {totalRecords} failed to push"; } EbLog.Info(response.Message); } catch (Exception ex) { response.Status = false; response.Message = "Push failed: " + ex.Message; EbLog.Error(ex.Message); } return(response); }
public ReportRenderResponse GetPdfOffline(string refid, string param) { if (!string.IsNullOrEmpty(refid)) { EbReport Report = null; try { Report = (EbReport)EbPageHelper.GetWebObjects(refid); Report.IsLastpage = false; Report.WatermarkImages = new Dictionary <int, byte[]>(); Report.WaterMarkList = new List <object>(); Report.ValueScriptCollection = new Dictionary <string, string>(); Report.AppearanceScriptCollection = new Dictionary <string, string>(); // Report.LinkCollection = new Dictionary<string, List<Common.Objects.EbControl>>(); Report.GroupSummaryFields = new Dictionary <string, List <EbDataField> >(); Report.PageSummaryFields = new Dictionary <string, List <EbDataField> >(); Report.ReportSummaryFields = new Dictionary <string, List <EbDataField> >(); Report.GroupFooters = new Dictionary <string, ReportGroupItem>(); Report.Groupheaders = new Dictionary <string, ReportGroupItem>(); Report.CultureInfo = new CultureInfo("en-IN", false); Report.Parameters = JsonConvert.DeserializeObject <List <Param> >(param); Report.Ms1 = new MemoryStream(); if (Report?.OfflineQuery.Code != string.Empty) { string query = Report.OfflineQuery.GetCode(); Report.DataSet = App.DataDB.DoQueries(query, Report.Parameters.ToDbParams().ToArray()); } float _width = Report.WidthPt - Report.Margin.Left;// - Report.Margin.Right; float _height = Report.HeightPt - Report.Margin.Top - Report.Margin.Bottom; Report.HeightPt = _height; iTextSharp.text.Rectangle rec = new iTextSharp.text.Rectangle(_width, _height); Report.Doc = new Document(rec); Report.Doc.SetMargins(Report.Margin.Left, Report.Margin.Right, Report.Margin.Top, Report.Margin.Bottom); Report.Writer = PdfWriter.GetInstance(Report.Doc, Report.Ms1); Report.Writer.Open(); Report.Doc.Open(); Report.Doc.AddTitle(Report.DocumentName); Report.Writer.PageEvent = new HeaderFooter(Report); Report.Writer.CloseStream = true;//important Report.Canvas = Report.Writer.DirectContent; Report.PageNumber = Report.Writer.PageNumber; FillingCollections(Report); Report.Doc.NewPage(); Report.DrawReportHeader(); if (Report?.DataSet?.Tables.Count > 0 && Report?.DataSet?.Tables[Report.DetailTableIndex]?.Rows.Count > 0) { Report.DrawDetail(); } else { Report.DrawPageHeader(); Report.detailEnd += 30; Report.DrawPageFooter(); Report.DrawReportFooter(); throw new Exception("Dataset is null, refid " + Report.DataSourceRefId); } Report.DrawReportFooter(); } catch (Exception e) { ColumnText ct = new ColumnText(Report.Canvas); Phrase phrase; if (Report?.DataSet?.Tables[Report.DetailTableIndex]?.Rows.Count > 0) { phrase = new Phrase("Something went wrong. Please check the parameters or contact admin"); } else { phrase = new Phrase("No Data available. Please check the parameters or contact admin"); } phrase.Font.Size = 10; float y = Report.HeightPt - (Report.ReportHeaderHeight + Report.Margin.Top + Report.PageHeaderHeight); ct.SetSimpleColumn(phrase, Report.LeftPt + 30, y - 30, Report.WidthPt - 30, y, 15, Element.ALIGN_CENTER); ct.Go(); } Report.Doc.Close(); if (Report.UserPassword != string.Empty || Report.OwnerPassword != string.Empty) { Report.SetPassword(); } string name = Report.DocumentName; if (Report.DataSourceRefId != string.Empty) { Report.DataSet.Tables.Clear(); Report.DataSet = null; } return(new ReportRenderResponse { ReportName = name, ReportBytea = Report.Ms1.ToArray(), CurrentTimestamp = Report.CurrentTimestamp }); } else { EbLog.Error(" PDF report Refid is null"); return(null); } }