protected override void SetValues() { this.SetValuesFormContext(); if (this.linkFormParameters == null) { EbLog.Info($"linkFormParameters empty in '{this.Page.DisplayName}'"); return; } foreach (EbMobileDataColToControlMap map in this.linkFormParameters) { object value = Context[map.ColumnName]; if (map.FormControl == null) { EbLog.Info($"form control not found for column name {map.ColumnName} in page '{this.Page.DisplayName}'"); continue; } if (this.Form.ControlDictionary.TryGetValue(map.FormControl.ControlName, out EbMobileControl ctrl)) { ctrl.SetValue(value); } } base.SetValues(); }
public async Task <List <SolutionInfo> > GetDataAsync() { List <SolutionInfo> sln = new List <SolutionInfo>(); try { await Task.Delay(1); List <SolutionInfo> solutions = Utils.Solutions; string _currentroot = App.Settings.RootUrl.Replace(ApiConstants.PROTOCOL, string.Empty); foreach (SolutionInfo info in solutions) { info.SetLogo(); info.IsCurrent = (info.SolutionName == App.Settings.Sid && info.RootUrl == _currentroot); sln.Add(info); } } catch (Exception ex) { EbLog.Info("Failed to get solution data"); EbLog.Error(ex.Message); } return(sln); }
public void setBackground(string color) { try { if (currentView == null || color == null) { return; } Color xcolor = Color.FromHex(color); if (currentView is EbXLabel xLabel) { xLabel.XBackgroundColor = xcolor; } else { currentView.BackgroundColor = xcolor; } } catch (Exception ex) { EbLog.Info("error at [setBackground] in list evaluator, " + 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); }
public async Task <List <MobilePagesWraper> > GetDataAsync() { List <MobilePagesWraper> objectList = App.Settings.MobilePages ?? new List <MobilePagesWraper>(); if (App.Settings.CurrentUser.IsAdmin) { EbLog.Info($"logged in as [admin], service returning [{objectList.Count}] objects"); return(objectList); } else { EbMobileSettings settings = App.Settings.CurrentApplication.AppSettings; if (settings != null && settings.HasMenuPreloadApi) { if (Utils.HasInternet) { EbLog.Info("Network connection is live and [preload api] connected"); objectList = await GetFromMenuPreload(settings.MenuApi); } else { Utils.Alert_NoInternet(); } } } //filter all pages with respect to current location List <MobilePagesWraper> filter = App.Settings.CurrentUser.FilterByLocation(objectList); return(filter); }
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 Task UnRegisterCurrent() { string registration = Store.GetValue(AppConst.AZURE_REGID); if (!string.IsNullOrEmpty(registration)) { try { Store.Remove(AppConst.AZURE_REGID); bool status = await UnRegisterAsync(registration); EbLog.Info($"AZURE_REGID delete api status: '{status}'"); } catch (Exception ex) { EbLog.Info("Error at unregister AZURE_REGID api"); EbLog.Error(ex.Message); } } else { EbLog.Error("AZURE_REGID empty"); } }
public async Task InitRecievedIntentAction(EbNFData payload) { if (payload.Link == null && App.RootMaster == null) { EbLog.Info("Intentaction aborted, link and rootmaster null"); return; } EbNFLink link = payload.Link; try { if (link.LinkType == EbNFLinkTypes.Action) { await ResolveAction(link); } else if (link.LinkType == EbNFLinkTypes.Page) { await ResolveRedirection(link); } } catch (Exception ex) { EbLog.Info("Unknown error at indent action"); EbLog.Error(ex.Message); } }
protected void SetFrameStyle(EbMobileVisualization viz) { if (!IsHeader) { EbThickness pd = viz.Padding ?? new EbThickness(10); EbThickness mr = viz.Margin ?? new EbThickness(); this.Padding = new Thickness(pd.Left, pd.Top, pd.Right, pd.Bottom); this.Margin = new Thickness(mr.Left, mr.Top, mr.Right, mr.Bottom); DynamicGrid.XAllocated = App.ScreenX - (pd.Left + pd.Right + mr.Left + mr.Right); } try { this.BackgroundColor = Color.FromHex(viz.BackgroundColor ?? "#ffffff"); this.CornerRadius = viz.BorderRadius; if (!IsHeader) { this.BorderColor = Color.FromHex(viz.BorderColor ?? "#ffffff"); this.HasShadow = viz.BoxShadow; } } catch (Exception ex) { EbLog.Info("Frame style issue"); EbLog.Error(ex.Message); } }
private void FillData(List <EbMobileTableCell> CellCollection) { foreach (EbMobileTableCell cell in CellCollection) { if (cell.IsEmpty()) { continue; } foreach (EbMobileControl ctrl in cell.ControlCollection) { try { View view = GetViewByRenderType(ctrl); if (view != null && ctrl is IGridAlignment gridAlign) { view.SetHorrizontalAlign(gridAlign.HorrizontalAlign); view.SetVerticalAlign(gridAlign.VerticalAlign); DynamicGrid.SetPosition(view, cell.RowIndex, cell.ColIndex, gridAlign.RowSpan, gridAlign.ColumnSpan); EvaluateExpression(ctrl, view); } } catch (Exception ex) { EbLog.Info("Failed to resolve grid content type in dynamic frame"); EbLog.Error(ex.Message); } } } }
public List <MobilePagesWraper> FilterByLocation(List <MobilePagesWraper> pages) { if (IsAdmin) { return(new List <MobilePagesWraper>(pages)); } List <MobilePagesWraper> filtered = null; try { List <int> objids = new List <int>(); foreach (string perm in Permissions) { int id = Convert.ToInt32(perm.Split(CharConstants.DASH)[2]); int locid = Convert.ToInt32(perm.Split(CharConstants.COLON)[1]); if (locid == App.Settings.CurrentLocId || locid == -1) { objids.Add(id); } } filtered = pages.Where(item => objids.Contains(item.RefId.ToObjId())).ToList(); } catch (Exception ex) { EbLog.Info("Error in filtering pages by location"); EbLog.Error(ex.Message); } return(filtered ?? new List <MobilePagesWraper>()); }
public static ContentPage ResolveByContext(EbMobileVisualization vis, EbDataRow row, EbMobilePage page) { ContentPage renderer = null; EbMobileContainer container = page.Container; try { if (container is EbMobileForm form) { if (vis.FormMode == WebFormDVModes.New_Mode) { string msg = GetFormRenderInvalidateMsg(page.NetworkMode); if (msg != null && !form.RenderAsFilterDialog) { renderer = new Redirect(msg, MessageType.disconnected); } else { renderer = new FormRender(page, vis.LinkFormParameters, row); } } else { EbMobileDataColToControlMap map = vis.FormId; if (map == null) { EbLog.Info("form id must 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($"formid has invalid value {id}, switching to new mode"); renderer = new FormRender(page, vis.LinkFormParameters, row); } else { EbLog.Info($"formid has value {id}, rendering edit mode"); renderer = new FormRender(page, id); } } } } else if (container is EbMobileVisualization) { renderer = new LinkedListRender(page, vis, row); } else if (container is EbMobileDashBoard) { renderer = new DashBoardRender(page); } } catch (Exception ex) { EbLog.Error(ex.Message); } return(renderer); }
private List <DbParameter> GetParamLocal(EbDataRow row) { var parameters = new List <DbParameter>(); try { string sql = HelperFunctions.B64ToString(this.OfflineQuery.Code); List <string> _parameters = HelperFunctions.GetSqlParams(sql); foreach (string param in _parameters) { object data = row[param]; if (data != null) { parameters.Add(new DbParameter { ParameterName = param, Value = data }); } } } catch (Exception ex) { EbLog.Info("Visualization get parameters from local error"); EbLog.Error(ex.Message); } return(parameters); }
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 ResolveAction(EbNFLink link) { if (link.ActionId != 0) { await App.Navigation.NavigateMasterAsync(new DoAction(link.ActionId)); EbLog.Info("Navigated to action submit : actionid =" + link.ActionId); } else { EbLog.Info("ActionId Empty, Intent action failed"); } }
private void QrScannerCallback(string payload) { SolutionQrMeta meta = null; try { meta = JsonConvert.DeserializeObject <SolutionQrMeta>(payload); } catch (Exception ex) { EbLog.Info("failed to parse qr payload in new solution page"); EbLog.Error(ex.Message); return; } if (meta == null) { return; } Device.BeginInvokeOnMainThread(async() => { try { if (string.IsNullOrEmpty(meta.Sid) || viewModel.IsSolutionExist(meta.Sid)) { Utils.Toast($"{meta.Sid} exist"); return; } EbLayout.ShowLoader(); response = await viewModel.Validate(meta.Sid); if (response.IsValid) { await viewModel.AddSolution(meta.Sid, response); await App.Navigation.NavigateToLogin(isMasterPage); } else { Utils.Toast("invalid qr code meta"); } EbLayout.HideLoader(); } catch (Exception) { EbLayout.HideLoader(); } }); }
private DeviceRegistration GetDevice() { string pns_token = Store.GetValue(AppConst.PNS_TOKEN); EbLog.Info("DEVICE TOKEN:" + pns_token); DeviceRegistration device = new DeviceRegistration() { Handle = pns_token, Tags = this.GetTags(), VendorName = appVendorName }; return(device); }
public async Task UpdateNHRegistration() { if (!Utils.HasInternet) { return; } try { DeviceRegistration device = this.GetDevice(); if (device.Handle == null) { return; } string azure_regid = Store.GetValue(AppConst.AZURE_REGID); if (string.IsNullOrEmpty(azure_regid)) { azure_regid = await this.GetNewRegistration(); await this.CreateOrUpdateRegistration(azure_regid, device); } else { var resp = await this.CreateOrUpdateRegistration(azure_regid, device); if (resp == null || !resp.Status) { azure_regid = await this.GetNewRegistration(); resp = await this.CreateOrUpdateRegistration(azure_regid, device); } if (resp != null) { EbLog.Info(resp.Message); } } EbLog.Info("NH REG ID:" + azure_regid); } catch (Exception ex) { EbLog.Error("Failed to update NHub registration" + ex.Message); } }
private EbMobilePage DeserializeJsonPage() { EbMobilePage mpage = null; try { string regexed = EbSerializers.JsonToNETSTD(this.Json); mpage = EbSerializers.Json_Deserialize <EbMobilePage>(regexed); } catch (Exception ex) { EbLog.Info("DeserializeJsonPage error inside pagewrapper"); EbLog.Error(ex.Message); } return(mpage); }
private EbObject DeserializeJsonObject() { EbObject obj = null; try { string regexed = EbSerializers.JsonToNETSTD(this.Json); obj = EbSerializers.Json_Deserialize <EbObject>(regexed); } catch (Exception ex) { EbLog.Info("DeserializeJsonPage error inside pagewrapper"); EbLog.Error(ex.Message); } return(obj); }
private async Task SaveToCloudDB(MobileFormData data, FormSaveResponse response, int rowId, string pageRefId) { try { WebformData webFormData = data.ToWebFormData(); foreach (MobileTable table in data.Tables) { if (table.Files.Any()) { table.InitFilesToUpload(); bool status = await this.SendAndFillFupData(webFormData, table); if (!status) { throw new Exception("Image Upload faild, breaking form save"); } } } int locid = App.Settings.CurrentLocId; EbLog.Info($"saving record in location {locid}"); PushResponse pushResponse = await FormService.Instance.SendFormDataAsync(pageRefId, webFormData, rowId, this.WebFormRefId, locid); this.LogPushResponse(pushResponse); if (pushResponse.RowAffected > 0) { response.Status = true; response.Message = "Saved successfully :)"; response.PushResponse = pushResponse; } else { throw new Exception(pushResponse.Message); } } catch (Exception ex) { response.Status = false; response.Message = ex.Message; EbLog.Error(ex.Message); } }
private EbDataTable GetDataFromLocal(string value) { try { string sql = HelperFunctions.B64ToString(this.OfflineQuery.Code).TrimEnd(CharConstants.SEMICOLON); string WrpdQuery = $"SELECT * FROM ({sql}) AS WR WHERE WR.{this.ValueMember.ColumnName} = {value} LIMIT 1"; return(App.DataDB.DoQuery(WrpdQuery)); } catch (Exception ex) { EbLog.Info("power select failed to resolve display member from local"); EbLog.Error(ex.Message); } return(null); }
public void UpdateRetryCount(EbDataRow DataRow) { try { int localid = Convert.ToInt32(DataRow["id"]); int retry = Convert.ToInt32(DataRow["eb_retry_count"]); int status = App.DataDB.DoNonQuery($"UPDATE {this.TableName} SET eb_retry_count = {retry + 1} WHERE id = {localid}"); if (status > 0 && retry > 1) { EbLog.Info($"Rety count of {this.TableName}({localid}) updated: {retry + 1}"); } } catch (Exception ex) { EbLog.Error("Rety count increment failed: " + ex.Message); } }
private bool EvaluateValidatorExpr(EbMobileValidator validator, string controlName, string parent) { string expr = validator.Script.GetCode(); string computed = GetComputedExpression(expr, controlName, parent); try { return(evaluator.Execute <bool>(computed)); } catch (Exception ex) { EbLog.Info($"validator script evaluation error in control '{controlName}'"); EbLog.Error(ex.Message); } return(false); }
public override string GetDisplayName4DG(object valueMember) { if (IsSimpleSelect || valueMember == null) { return(null); } string strValue = valueMember?.ToString(); EbDataTable dt = null; if (this.NetworkType == NetworkMode.Offline) { dt = GetDataFromLocal(strValue); } else if (this.NetworkType == NetworkMode.Online) { Param param = new Param { Name = this.ValueMember.ColumnName, Type = ((int)this.ValueMember.Type).ToString(), Value = strValue }; try { MobileDataResponse response = DataService.Instance.GetData(this.DataSourceRefId, 1, 0, new List <Param> { param }, null, null, false); if (response.Data != null && response.Data.Tables.HasLength(2)) { dt = response.Data.Tables[1]; } } catch (Exception ex) { EbLog.Info("power select failed to resolve display member from live"); EbLog.Error(ex.Message); } } if (dt != null && dt.Rows.Any()) { return(Convert.ToString(dt.Rows[0][DisplayMember.ColumnName])); } return(null); }
private void EvaluateDefaultValueExpr(EbMobileControl ctrl, string parent) { string expr = ctrl.DefaultValueExpression.GetCode(); string computed = GetComputedExpression(expr, ctrl.Name, parent); try { object value = evaluator.Execute(computed); ctrl.SetValue(value); ctrl.DefaultExprEvaluated = true; } catch (Exception ex) { EbLog.Info($"Default script evaluation error in control '{ctrl.Name}'"); EbLog.Error(ex.Message); } }
public async Task <EbDataSet> GetDataAsync(string refid) { if (!string.IsNullOrEmpty(refid)) { try { MobileDataResponse response = await DataService.Instance.GetDataFlatAsync(refid); return(response?.Data); } catch (Exception ex) { EbLog.Info("failed to fetch [dashboard] data"); EbLog.Error(ex.Message); } } return(null); }
private void EvaluateValueExpr(EbMobileControl ctrl, string trigger_control, string parent) { string expr = ctrl.ValueExpr.GetCode(); string computed = GetComputedExpression(expr, ctrl.Name, parent); try { object value = evaluator.Execute(computed); ctrl.SetValue(value); ctrl.ValueChanged(trigger_control); } catch (Exception ex) { EbLog.Info($"Value script evaluation error in control '{ctrl.Name}'"); EbLog.Error(ex.Message); } }
public async void SetAddress(double lat, double lng) { try { Geocoder geoCoder = new Geocoder(); Position pos = new Position(lat, lng); IEnumerable <string> possibleAddresses = await geoCoder.GetAddressesForPositionAsync(pos); string address = possibleAddresses.FirstOrDefault(); PickerTextLable.Text = address; } catch (Exception ex) { EbLog.Info("Error at [SetAddress] in googlemap view [GeoCoder]"); EbLog.Info(ex.Message); } }
public override async Task OnControlAction(EbDataRow row) { string columnName = Name + "_action_id"; object actionId = row[columnName]; if (actionId != null) { int id = Convert.ToInt32(actionId); if (id == 0) { EbLog.Info("action_id is zero"); return; } await App.Navigation.NavigateMasterAsync(new DoAction(id)); } }