Esempio n. 1
0
 public void MergeFormData(WebformData FormData, WebFormSchema FormSchema)
 {
     if (FormData.MultipleTables.ContainsKey(this.TableName) && FormData.MultipleTables[this.TableName].Count > 0)
     {
         SingleTable rows = FormData.MultipleTables[this.TableName];
         for (int i = 0; i < rows.Count; i++)
         {
             if (rows[i].RowId > 0)
             {
                 rows.RemoveAt(i--);
             }
         }
         if (rows.Count == 1)//one new entry// need to write code for 'AfterSaveRoutines'
         {
             foreach (TableSchema t in FormSchema.Tables)
             {
                 if (t.TableName != this.TableName)
                 {
                     FormData.MultipleTables.Remove(t.TableName);// approval execution, hence removing other data if present
                 }
             }
             string[] str_t = { FormConstants.stage_unique_id, FormConstants.action_unique_id, FormConstants.eb_my_actions_id, FormConstants.comments };
             for (int i = 0; i < str_t.Length; i++)
             {
                 EbControl con = this.Controls.Find(e => e.Name == str_t[i]);
                 FormData.MultipleTables[this.TableName][0].SetEbDbType(con.Name, con.EbDbType);
                 FormData.MultipleTables[this.TableName][0].SetControl(con.Name, con);
             }
         }
     }
 }
        public async Task <WebformData> GetFormLiveDataAsync(string refid, int row_id, int loc_id)
        {
            WebformData wd;

            try
            {
                RestRequest request = new RestRequest("api/get_formdata", Method.GET);
                request.AddParameter("refid", refid);
                request.AddParameter("row_id", row_id);
                request.AddParameter("loc_id", loc_id);

                // auth Headers for api
                request.AddHeader(AppConst.BTOKEN, App.Settings.BToken);
                request.AddHeader(AppConst.RTOKEN, App.Settings.RToken);

                IRestResponse iresp = await HttpClient.ExecuteAsync(request);

                MobileFormDataResponse response = JsonConvert.DeserializeObject <MobileFormDataResponse>(iresp.Content);
                wd = response.Data;
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
                wd = new WebformData();
            }
            return(wd);
        }
        public object ExecuteEmailRetriever(EbApi Api, Service Service, EbStaticFileClient FileClient, bool isMq)
        {
            try
            {
                EbConnectionFactory EbConnectionFactory = new EbConnectionFactory(Api.SolutionId, Api.Redis);
                if (EbConnectionFactory.EmailRetrieveConnection[this.MailConnection] != null)
                {
                    RetrieverResponse retrieverResponse = EbConnectionFactory.EmailRetrieveConnection[this.MailConnection].Retrieve(Service, this.DefaultSyncDate, FileClient, Api.SolutionId, isMq, SubmitAttachmentAsMultipleForm);

                    EbWebForm _form = Api.Redis.Get <EbWebForm>(this.Reference);
                    SchemaHelper.GetWebFormSchema(_form);
                    if (!(_form is null))
                    {
                        WebformData data = _form.GetEmptyModel();

                        foreach (RetrieverMessage _m in retrieverResponse?.RetrieverMessages)
                        {
                            InsertFormData(_form, data, _m, this.Reference, Api.SolutionId, Api.UserObject, Api.Redis, Service, EbConnectionFactory);
                        }
                    }
                    else
                    {
                        throw new ApiException("[ExecuteEmailRetriever], form objects is not in redis.");
                    }
                }
                else
                {
                    throw new ApiException("[ExecuteEmailRetriever], mail connection doesn't exist.");
                }
            }
        public static Dictionary <string, List <FileMetaInfo> > ToFilesMeta(this WebformData data)
        {
            Dictionary <string, List <FileMetaInfo> > files = new Dictionary <string, List <FileMetaInfo> >();

            try
            {
                foreach (KeyValuePair <string, SingleTable> st in data.ExtendedTables)
                {
                    foreach (SingleRow row in st.Value)
                    {
                        if (row.Columns.Count > 0)
                        {
                            SingleColumn        info     = row.Columns[0];
                            List <FileMetaInfo> fileMeta = JsonConvert.DeserializeObject <List <FileMetaInfo> >(info.Value.ToString());
                            files.Add(st.Key, fileMeta);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
                EbLog.Error(ex.StackTrace);
            }
            return(files);
        }
Esempio n. 5
0
        public WebformData ToWebFormData()
        {
            WebformData wd = new WebformData(this.MasterTable);

            foreach (MobileTable table in this.Tables)
            {
                wd.MultipleTables.Add(table.TableName, new SingleTable());

                foreach (var row in table)
                {
                    var srow = new SingleRow
                    {
                        RowId    = row.RowId,
                        LocId    = App.Settings.CurrentLocId,
                        IsUpdate = (row.RowId > 0)
                    };

                    foreach (var col in row.Columns)
                    {
                        srow.Columns.Add(new SingleColumn
                        {
                            Name  = col.Name,
                            Value = col.Value,
                            Type  = (int)col.Type
                        });
                    }

                    wd.MultipleTables[table.TableName].Add(srow);
                }
            }
            return(wd);
        }
Esempio n. 6
0
        private async Task <PushResponse> SendRecord(WebformData webdata, EbMobileForm Form, EbDataTable Dt, EbDataRow DataRow, int RowIndex)
        {
            PushResponse response = null;

            try
            {
                ClearWebFormData(webdata);
                SingleTable SingleTable = new SingleTable();

                int       localid = Convert.ToInt32(DataRow["id"]);
                SingleRow row     = this.GetRow(Form, Dt, DataRow, RowIndex);
                SingleTable.Add(row);
                webdata.MultipleTables.Add(Form.TableName, SingleTable);

                await Form.UploadFiles(localid, webdata);

                this.GetLinesEnabledData(localid, Form, webdata);
                if (FormService.Instance == null)
                {
                    new FormService();
                }
                response = await FormService.Instance.SendFormDataAsync(null, webdata, 0, Form.WebFormRefId, row.LocId);

                response.LocalRowId = localid;
            }
            catch (Exception ex)
            {
                EbLog.Error("SyncServices.PushRow---" + ex.Message);
            }
            return(response);
        }
 public PsDmHelper(EbWebForm ebForm, List <EbControl> drPsList, WebformData _FormData, Service service)
 {
     this.ebForm    = ebForm;
     this.drPsList  = drPsList;
     this._FormData = _FormData;
     this.service   = service;
 }
Esempio n. 8
0
        private void GetLinesEnabledData(int localid, EbMobileForm form, WebformData formData)
        {
            try
            {
                Dictionary <string, EbMobileControl> controls = form.ChildControls.ToControlDictionary();

                foreach (var ctrl in controls.Values)
                {
                    if (ctrl is ILinesEnabled Ilines)
                    {
                        SingleTable st = new SingleTable();
                        formData.MultipleTables.Add(Ilines.TableName, st);

                        EbDataTable data = Ilines.GetLocalData(form.TableName, localid);

                        foreach (var dr in data.Rows)
                        {
                            SingleRow row = new SingleRow {
                                LocId = Convert.ToInt32(dr["eb_loc_id"])
                            };
                            row.Columns.AddRange(Ilines.GetColumnValues(data.Columns, dr));
                            st.Add(row);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                EbLog.Error(ex.Message);
            }
        }
Esempio n. 9
0
        public static _FG_WebForm GetCSharpFormGlobals(EbWebForm _this, WebformData _formdata)
        {
            _FG_WebForm fG_WebForm = new _FG_WebForm();

            GetCSharpFormGlobalsRec(fG_WebForm, _this, _formdata);
            return(fG_WebForm);
        }
Esempio n. 10
0
        public static FG_Root GetCSharpFormGlobals_NEW(EbWebForm _this, WebformData _formdata, WebformData _formdataBkUp, IDatabase DataDB, DbConnection DbCon, bool isSrcForm)
        {
            FG_User   fG_User   = new FG_User(_this.UserObj.UserId, _this.UserObj.FullName, _this.UserObj.Email, _this.UserObj.Roles);
            FG_System fG_System = new FG_System();
            FG_DataDB fG_DataDB = null;

            if (DataDB != null)
            {
                DelegateTest OutDelObj = new DelegateTest(DataDB, DbCon);
                fG_DataDB = new FG_DataDB(OutDelObj.ExecuteScalar);
            }
            WebformData _formdataEmpty = _this.GetEmptyModel();

            if (_formdata == null)
            {
                _formdata = _formdataEmpty;
            }
            else
            {
                _formdata.DGsRowDataModel = _formdataEmpty.DGsRowDataModel;
            }
            FG_Locations fG_Locations = Get_FG_Locations(_this.SolutionObj.Locations);
            int          createdBy    = _this.TableRowId <= 0 ? _this.UserObj.UserId : _formdata.CreatedBy;
            string       createdAt    = _this.TableRowId <= 0 ? DateTime.UtcNow.ConvertFromUtc(_this.UserObj.Preference.TimeZone).ToString(FormConstants.yyyyMMdd_HHmmss, CultureInfo.InvariantCulture) : _formdata.CreatedAt;
            FG_WebForm   fG_WebForm   = new FG_WebForm(_this.TableName, _this.TableRowId, _this.LocationId, _this.RefId, createdBy, createdAt);

            GetCSharpFormGlobalsRec_NEW(fG_WebForm, _this, _formdata, _formdataBkUp);

            return(new FG_Root(fG_WebForm, fG_User, fG_System, isSrcForm, fG_DataDB, fG_Locations));
        }
Esempio n. 11
0
        private async Task PushDependencyData(WebformData webdata, EbMobileForm sourceForm, EbMobileForm dependencyForm, int liveId, int localId)
        {
            try
            {
                string RefColumn = $"{sourceForm.TableName}_id";
                string query     = string.Format(StaticQueries.STARFROM_TABLE_WDEP, dependencyForm.GetQuery(), dependencyForm.TableName, RefColumn, localId);

                EbDataTable dt = App.DataDB.DoQuery(query);

                if (dt.Rows.Any())
                {
                    SingleTable SingleTable = new SingleTable();

                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        FillLiveId(dt, dt.Rows[i], liveId, RefColumn);

                        PushResponse resp = await SendRecord(webdata, dependencyForm, dt, dt.Rows[i], i);

                        if (resp.RowAffected <= 0)
                        {
                            continue;
                        }
                        dependencyForm.FlagLocalRow(resp);
                    }
                }
            }
            catch (Exception ex)
            {
                EbLog.Error("SyncServices.PushDependencyData---" + ex.Message);
            }
        }
        public async Task <PushResponse> SendFormDataAsync(string pageRefId, WebformData WebFormData, int RowId, string WebFormRefId, int LocId)
        {
            try
            {
                RestRequest request = new RestRequest(ApiConstants.PUSH_DATA, Method.POST);
                request.AddParameter("webform_data", JsonConvert.SerializeObject(WebFormData));
                request.AddParameter("rowid", RowId);
                request.AddParameter("refid", WebFormRefId);
                request.AddParameter("locid", LocId);
                request.AddParameter("mobile_refid", pageRefId);

                // auth Headers for api
                request.AddHeader(AppConst.BTOKEN, App.Settings.BToken);
                request.AddHeader(AppConst.RTOKEN, App.Settings.RToken);

                IRestResponse response = await HttpClient.ExecuteAsync(request);

                return(JsonConvert.DeserializeObject <PushResponse>(response.Content));
            }
            catch (Exception e)
            {
                EbLog.Error(e.Message);
            }
            return(null);
        }
Esempio n. 13
0
        public static List <FG_WebForm> GetEmptyDestinationModelGlobals(List <EbWebForm> DestForms)
        {
            List <FG_WebForm> fG_WebFormsList = new List <FG_WebForm>();

            for (int i = 0; i < DestForms.Count; i++)
            {
                EbWebForm   Form       = DestForms[i];
                WebformData _formdata  = Form.GetEmptyModel();
                int         createdBy  = Form.TableRowId <= 0 ? Form.UserObj.UserId : _formdata.CreatedBy;
                string      createdAt  = Form.TableRowId <= 0 ? DateTime.UtcNow.ConvertFromUtc(Form.UserObj.Preference.TimeZone).ToString(FormConstants.yyyyMMdd_HHmmss, CultureInfo.InvariantCulture) : _formdata.CreatedAt;
                FG_WebForm  fG_WebForm = new FG_WebForm(Form.TableName, Form.TableRowId, Form.LocationId, Form.RefId, createdBy, createdAt);
                GetCSharpFormGlobalsRec_NEW(fG_WebForm, Form, _formdata, null);
                fG_WebFormsList.Add(fG_WebForm);
            }
            return(fG_WebFormsList);
        }
        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);
            }
        }
Esempio n. 15
0
        //get formdata as globals for c# script engine
        public static FormAsGlobal GetFormAsGlobal(EbWebForm _this, WebformData _formData, EbControlContainer _container = null, FormAsGlobal _globals = null)
        {
            if (_container == null)
            {
                _container = _this;
            }
            if (_globals == null)
            {
                _globals = new FormAsGlobal {
                    Name = _this.Name
                }
            }
            ;

            ListNTV listNTV = new ListNTV();

            if (_formData.MultipleTables.ContainsKey(_container.TableName))
            {
                for (int i = 0; i < _formData.MultipleTables[_container.TableName].Count; i++)
                {
                    foreach (EbControl control in _container.Controls)
                    {
                        if (control is EbControlContainer)
                        {
                            FormAsGlobal g = new FormAsGlobal();
                            g.Name = (control as EbControlContainer).Name;
                            _globals.AddContainer(g);
                            g = GetFormAsGlobal(_this, _formData, control as EbControlContainer, g);
                        }
                        else
                        {
                            NTV n = GetNtvFromFormData(_formData, _container.TableName, i, control.Name);
                            if (n != null)
                            {
                                listNTV.Columns.Add(n);
                            }
                        }
                    }
                }
                _globals.Add(listNTV);
            }
            return(_globals);
        }
        public static EbDataSet ToDataSet(this WebformData data)
        {
            EbDataSet ds = new EbDataSet();

            try
            {
                foreach (KeyValuePair <string, SingleTable> st in data.MultipleTables)
                {
                    EbDataTable dt = new EbDataTable {
                        TableName = st.Key
                    };
                    for (int i = 0; i < st.Value.Count; i++)
                    {
                        EbDataRow dr = dt.NewDataRow();
                        for (int k = 0; k < st.Value[i].Columns.Count; k++)
                        {
                            SingleColumn sc = st.Value[i].Columns[k];

                            if (i == 0)
                            {
                                EbDataColumn dc = new EbDataColumn
                                {
                                    ColumnIndex = k,
                                    Type        = (EbDbTypes)sc.Type,
                                    ColumnName  = sc.Name
                                };
                                dt.Columns.Add(dc);
                            }
                            dr.Add((object)sc.Value);
                        }
                        dt.Rows.Add(dr);
                    }
                    ds.Tables.Add(dt);
                }
            }
            catch (Exception ex)
            {
                EbLog.Info("WebformData to dataset operation failed");
                EbLog.Error(ex.StackTrace);
            }
            return(ds);
        }
Esempio n. 17
0
        private static NTV GetNtvFromFormData(WebformData _formData, string _table, int _row, string _column)
        {
            NTV ntv = null;

            if (_formData.MultipleTables.ContainsKey(_table))
            {
                foreach (SingleColumn col in _formData.MultipleTables[_table][_row].Columns)
                {
                    if (col.Name.Equals(_column))
                    {
                        ntv = new NTV()
                        {
                            Name  = _column,
                            Type  = (EbDbTypes)col.Type,
                            Value = col.Value
                        };
                        break;
                    }
                }
            }
            return(ntv);
        }
        public async Task UploadFiles(int RowId, WebformData WebFormData)
        {
            ControlDictionary = ChildControls.ToControlDictionary();

            List <FileWrapper> Files = new List <FileWrapper>();

            foreach (var pair in ControlDictionary)
            {
                if (pair.Value is EbMobileFileUpload)
                {
                    string pattern = $"{this.TableName}-{RowId}-{pair.Value.Name}*";
                    Files.AddRange(HelperFunctions.GetFilesByPattern(pattern, pair.Value.Name));
                }
            }

            if (Files.Count > 0)
            {
                var ApiFiles = await FormService.Instance.SendFilesAsync(Files);

                WebFormData.FillFromSendFileResp(Files, ApiFiles);
            }
        }
 private async Task InitializeFormData()
 {
     try
     {
         if (IsOffline())
         {
             this.formData = await FormDataService.GetFormLocalDataAsync(this.Form, this.RowId);
         }
         else if (IsOnline())
         {
             if (webFormData == null)
             {
                 webFormData = await FormDataService.GetFormLiveDataAsync(this.Page.RefId, this.RowId, App.Settings.CurrentLocId);
             }
             this.formData  = webFormData?.ToDataSet();
             this.filesData = webFormData?.ToFilesMeta();
         }
     }
     catch (Exception ex)
     {
         EbLog.Error($"InitializeFormData error in form edit '{this.Page.DisplayName}'");
         EbLog.Error(ex.Message);
     }
 }
        private async Task <bool> SendAndFillFupData(WebformData webformdata, MobileTable table)
        {
            if (table.NewFiles.Any())
            {
                try
                {
                    List <ApiFileData> resp = await FormService.Instance.SendFilesAsync(table.NewFiles);

                    webformdata.FillFromSendFileResp(table.NewFiles, resp);
                    webformdata.FillUploadedFileRef(table.OldFiles);

                    if (!webformdata.ExtendedTables.Any())
                    {
                        EbLog.Error("Image upload response empty, breaking save");
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    EbLog.Error("SendFilesAsync error :: " + ex.Message);
                }
            }
            return(true);
        }
Esempio n. 21
0
        public static FormAsGlobal GetFormAsFlatGlobal(EbWebForm _this, WebformData _formdata)
        {
            Dictionary <string, string> grid = new Dictionary <string, string>();

            EbControl[] Allctrls = _this.Controls.FlattenAllEbControls();
            for (int i = 0; i < Allctrls.Length; i++)
            {
                if (Allctrls[i] is EbDataGrid)
                {
                    grid.Add((Allctrls[i] as EbDataGrid).TableName, (Allctrls[i] as EbDataGrid).Name);
                }
            }

            FormAsGlobal _globals = new FormAsGlobal {
                Name = _this.Name
            };
            ListNTV listNTV = new ListNTV();

            try
            {
                foreach (KeyValuePair <string, SingleTable> item in _formdata.MultipleTables)
                {
                    if (grid.ContainsKey(item.Key))
                    {
                        FormAsGlobal _grid = new FormAsGlobal {
                            Name = grid[item.Key]
                        };
                        for (int j = 0; j < item.Value.Count; j++)
                        {
                            ListNTV _gridline = new ListNTV();
                            foreach (SingleColumn col in item.Value[j].Columns)
                            {
                                if (col.Name != "id" && col.Name != "eb_row_num")
                                {
                                    NTV n = GetNtvFromFormData(_formdata, item.Key, j, col.Name);
                                    if (n != null)
                                    {
                                        _gridline.Columns.Add(n);
                                    }
                                }
                            }
                            _grid.Add(_gridline);
                        }
                        _globals.AddContainer(_grid);
                    }
                    else
                    {
                        foreach (SingleColumn col in item.Value[0].Columns)
                        {
                            if (!(col.Name == "id" && item.Key != _formdata.MasterTable) && item.Value.Count == 1)
                            {
                                NTV n = GetNtvFromFormData(_formdata, item.Key, 0, col.Name);
                                if (n != null)
                                {
                                    listNTV.Columns.Add(n);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception in GetFormAsFlatGlobal. Message : " + ex.Message);
                Console.WriteLine(ex.StackTrace);
            }

            _globals.Add(listNTV);
            return(_globals);
        }
Esempio n. 22
0
        private static void GetCSharpFormGlobalsRec_NEW(FG_WebForm fG_WebForm, EbControlContainer _container, WebformData _formdata, WebformData _formdataBkUp)
        {
            SingleTable Table     = _formdata.MultipleTables.ContainsKey(_container.TableName) ? _formdata.MultipleTables[_container.TableName] : new SingleTable();
            SingleTable TableBkUp = _formdataBkUp != null && _formdataBkUp.MultipleTables.ContainsKey(_container.TableName) ? _formdataBkUp.MultipleTables[_container.TableName] : new SingleTable();

            if (_container is EbDataGrid)
            {
                fG_WebForm.DataGrids.Add(GetDataGridGlobal(_container as EbDataGrid, Table, _formdata.DGsRowDataModel[_container.TableName]));
            }
            else if (_container is EbReview)
            {
                fG_WebForm.Review = GetReviewGlobal(_container as EbReview, Table, TableBkUp);
            }
            else
            {
                foreach (EbControl _control in _container.Controls)
                {
                    if (_control is EbControlContainer)
                    {
                        GetCSharpFormGlobalsRec_NEW(fG_WebForm, _control as EbControlContainer, _formdata, _formdataBkUp);
                    }
                    else
                    {
                        object data = null;
                        Dictionary <string, object> Metas = new Dictionary <string, object>();
                        if (_control is EbAutoId && fG_WebForm.__mode == "new")// && fG_WebForm.id == 0
                        {
                            data = FG_Constants.AutoId_PlaceHolder;
                        }
                        else
                        {
                            SingleColumn psSC = null;
                            if (Table.Count > 0 && Table[0].GetColumn(_control.Name) != null && !(_control is EbAutoId)) //(!(_control is EbAutoId) || (_control is EbAutoId && fG_WebForm.__mode == "edit")))// && fG_WebForm.id > 0
                            {
                                data = Table[0][_control.Name];
                                psSC = Table[0].GetColumn(_control.Name);
                            }
                            else if (TableBkUp.Count > 0 && TableBkUp[0].GetColumn(_control.Name) != null)
                            {
                                data = TableBkUp[0][_control.Name];
                                psSC = TableBkUp[0].GetColumn(_control.Name);
                            }
                            else if (Table.Count > 0 && Table[0].GetColumn(_control.Name) != null)// Hint: For BatchDataPusher, AutoId available in 'Table' only
                            {
                                data = Table[0][_control.Name];
                                psSC = Table[0].GetColumn(_control.Name);
                            }
                            if (psSC != null && _control is IEbPowerSelect)
                            {
                                Metas.Add(FG_Constants.Columns, psSC.R);
                            }
                        }
                        if (_control is EbAutoId ebAI)
                        {
                            Metas.Add(FG_Constants.SerialLength, ebAI.Pattern?.SerialLength ?? 0);
                        }

                        fG_WebForm.FlatCtrls.Controls.Add(new FG_Control(_control.Name, _control.ObjType, data, Metas));
                    }
                }
            }
        }
 public FormRenderVME(EbMobilePage page, int rowId, WebformData data) : base(page)
 {
     Mode        = FormMode.EDIT;
     RowId       = rowId;
     webFormData = data;
 }
 //edit
 public FormRender(EbMobilePage page, int rowId, WebformData data)
 {
     InitializeComponent();
     BindingContext = viewModel = new FormRenderVME(page, rowId, data);
 }
Esempio n. 25
0
        private static void GetCSharpFormGlobalsRec(_FG_WebForm fG_WebForm, EbControlContainer _container, WebformData _formdata)
        {
            SingleTable Table = _formdata.MultipleTables.ContainsKey(_container.TableName) ? _formdata.MultipleTables[_container.TableName] : new SingleTable();

            if (_container is EbDataGrid)
            {
                _FG_DataGrid fG_DataGrid = new _FG_DataGrid(_container as EbDataGrid, Table);
                fG_WebForm.DataGrids.Add(fG_DataGrid);
            }
            else if (_container is EbReview)
            {
                fG_WebForm.Review = new _FG_Review(_container as EbReview, Table);
            }
            else
            {
                foreach (EbControl _control in _container.Controls)
                {
                    if (_control is EbControlContainer)
                    {
                        GetCSharpFormGlobalsRec(fG_WebForm, _control as EbControlContainer, _formdata);
                    }
                    else
                    {
                        object data = null;
                        if (_formdata.MultipleTables.ContainsKey(_container.TableName) && _formdata.MultipleTables[_container.TableName].Count > 0)
                        {
                            data = _formdata.MultipleTables[_container.TableName][0][_control.Name];
                        }
                        fG_WebForm.FlatCtrls.Controls.Add(new _FG_Control(_control, data));
                    }
                }
            }
        }
Esempio n. 26
0
        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);
        }
Esempio n. 27
0
 private void ClearWebFormData(WebformData wd)
 {
     wd.MultipleTables.Clear();
     wd.ExtendedTables.Clear();
 }