Ejemplo n.º 1
0
        //public void updateRecordSummaryTable()
        //{
        //    var query = "select count(*) from {0}";
        //    var allBlobs = GetAllBobs();
        //    var clientRecords = (from record in allBlobs
        //                         select new PPDataSet().fromJson(record));
        //    var allRecords = (
        //        from record in clientRecords
        //        let val = record.FieldValues
        //            .FirstOrDefault(f => f.Name == Constants.FIELD_PPX_DATEOFVISIT)
        //        where val != null
        //        let visitDate = string.IsNullOrWhiteSpace(val.Value) ? DateTime.MinValue : Convert.ToDateTime(val.Value)
        //        select new RecordSummary()
        //        {
        //            Id = record.Id.Value,
        //            EntityId = record.EntityId.Value,
        //            KindName = record.FormName,
        //            //Constants.PPX_KIND_DISPLAYNAMES[record.FormName],
        //            VisitDate = visitDate
        //        }).ToList();

        //    var db = new LocalDB3().DB;
        //    allRecords.ForEach(t => db.InsertOrReplace(t));
        //    var allSaved = db.Table<RecordSummary>().ToList();
        //}

        public void updateRecordSummaryTable()
        {
            var allBlobs      = GetAllBobs();
            var clientRecords = (from record in allBlobs
                                 select DbSaveableEntity.fromJson <GeneralEntityDataset>(record)
                                 //select new GeneralEntityDataset().fromJson(record)
                                 ).ToList();
            var allRecords = (
                from record in clientRecords
                let val = record.FieldValues
                          .FirstOrDefault(f => f.Name == ContextManager.FIELD_VISITDATE)
                          where val != null
                          let visitDate = string.IsNullOrWhiteSpace(val.Value) ? DateTime.MinValue : Convert.ToDateTime(val.Value)
                                          select new RecordSummary()
            {
                Id = record.Id.Value,
                EntityId = record.EntityId.Value,
                KindName = record.FormName,
                VisitDate = visitDate
            }).ToList();

            var db = new LocalDB3().DB;

            allRecords.ForEach(t => db.InsertOrReplace(t));
            var allSaved = db.Table <RecordSummary>().ToList();
        }
        public virtual int GetCount()
        {
            var all = new LocalDB3().DB
                      .ExecuteScalar <int>("select count(*) from " + _kindName);

            return(all);
        }
        public virtual int Update(List <T> clients)
        {
            var all = new LocalDB3().DB
                      .UpdateAll(clients);

            return(all);
        }
Ejemplo n.º 4
0
        public void InitialiseAppResources(AssetManager assetManager, Activity context)
        {
            AppDomain.CurrentDomain.UnhandledException += uncaughtExceptionHandler;
            //ContextManager = null;
            ModuleContext    = null;
            _assetManager    = assetManager;
            _mainContext     = context;
            TemporalViewData = new Dictionary <int, List <FieldValuePair> >();
            ApiAssets        = new Dictionary <string, string>();
            //we read the api key file
            var inputStream = assetManager.Open(Constants.API_KEYFILE);
            var jsonObject  = System.Json.JsonValue.Load(inputStream);

            foreach (var assetName in Constants.ASSET_LIST)
            {
                ApiAssets[assetName] =
                    jsonObject.decryptAndGetApiSetting(assetName);
            }

            //we need to have this class initialised
            LocalEntityStoreInstance = new LocalEntityStore();
            LocalEntityStoreInstance.buildTables(false);

            CloudDbInstance = new CloudDb(_assetManager);

            //Android.OS.Build.Serial
            var configuration = new LocalDB3().DB.Table <DeviceConfiguration>().FirstOrDefault();

            Configuration = configuration;
        }
        public virtual int InsertOrReplace(List <T> clients)
        {
            var db = new LocalDB3().DB;

            foreach (var client in clients)
            {
                db.InsertOrReplace(client);
            }
            return(0);
        }
        public virtual List <T> Get()
        {
            var all = new LocalDB3().DB
                      .Table <T>()
                      .ToList <T>()
                      .OrderByDescending(t => t.CoreActivityDate)
                      .ToList();

            all.ForEach(t => { t.build(); });
            return(all);
        }
Ejemplo n.º 7
0
        protected async Task <int> getClientSummaryReport(ClientLookupProvider <T> lookupProvider
                                                          , Dictionary <string, string> kindDisplayNames)
        {
            //or we can write to file and email
            //var file = AppInstance.Instance.writeToFile("stuff to write");

            var countRes = AppInstance.Instance.ModuleContext.GetAllBobsCount();
            var asList   = (from item in countRes
                            let displayItem = new NameValuePair()
            {
                Name = kindDisplayNames[item.Name],
                Value = item.Value
            }
                            select displayItem.toDisplayText()).ToList();
            var resList = new List <string>()
            {
                Resources.GetString(Resource.String.sys_summary_blobcount),
                NameValuePair.getHeaderText()
            };

            resList.AddRange(asList);

            //also add client summary
            var recCount           = lookupProvider.GetCount();
            var clientSummaryCount = new NameValuePair()
            {
                Name  = "Client Summary",
                Value = recCount.ToString()
            };

            resList.Add(clientSummaryCount.toDisplayText());

            var summaryInfo = new LocalDB3().DB.Query <NameValuePair>(
                string.Format(
                    "select KindName as Name, count(*) as Value from {0} group by KindName",
                    Constants.KIND_DERIVED_RECORDSUMMARY)
                );

            resList.Add(System.Environment.NewLine);
            resList.Add("Summary of Records in " + Constants.KIND_DERIVED_RECORDSUMMARY);
            var asStringList = (from nvp in summaryInfo
                                select nvp.toDisplayText()).ToList();

            resList.AddRange(asStringList);
            var asText = string.Join(System.Environment.NewLine, resList);

            setTextResults(asText);
            return(0);
        }
Ejemplo n.º 8
0
        protected virtual void saveClientSummary(List <NameValuePair> data, KindKey clientId)
        {
            var clientSummary = new GeneralEntityDataset()
            {
                Id          = clientId,
                FormName    = _kindName.Value,
                EntityId    = clientId,
                FieldValues = getIndexedFormData(data)
            };

            var db = new LocalDB3().DB;
            //var count = db.Table<ppx.PPClientSummary>().Count();
            var ppclient = new T().Load(clientSummary) as T;

            new LocalDB3().DB.InsertOrReplace(ppclient);

            //count = db.Table<ppx.PPClientSummary>().Count();
        }
Ejemplo n.º 9
0
        void showAdminPage()
        {
            SetContentView(Resource.Layout.AdminOptionsLayout);

            var currentSettings = new LocalDB3().DB.Table <DeviceConfiguration>().FirstOrDefault();

            if (currentSettings == null)
            {
                var uuid        = Guid.NewGuid().ToString("N");
                var tDeviceUUID = FindViewById <TextView>(Resource.Id.tDeviceUUID);
                tDeviceUUID.Text = uuid;

                var buttonSaveDeviceConf = FindViewById <Button>(Resource.Id.buttonSaveDeviceConf);
                buttonSaveDeviceConf.Click += buttonSaveDeviceConf_Click;
            }
            else
            {
                //hide the save button
                var buttonSaveDeviceConf = FindViewById <Button>(Resource.Id.buttonSaveDeviceConf);
                buttonSaveDeviceConf.Visibility = Android.Views.ViewStates.Gone;

                var tDeviceSerial = FindViewById <EditText>(Resource.Id.tDeviceSerial);
                tDeviceSerial.Text = currentSettings.Serial;

                var tDeviceUUID = FindViewById <TextView>(Resource.Id.tDeviceUUID);
                tDeviceUUID.Text = currentSettings.UUID;
            }

            //we dont want the user to do anything else if device is not yet set up
            if (currentSettings == null)
            {
                return;
            }

            var buttonSaveChanges = FindViewById <Button>(Resource.Id.buttonSaveChanges);

            buttonSaveChanges.Click += SaveUserOptions_Click;

            //buttonAdminLogOut
            var buttonAdminLogOut = FindViewById <Button>(Resource.Id.buttonAdminLogOut);

            buttonAdminLogOut.Click += buttonAdminLogOut_Click;
            //(sender, e)=> { Activity.Finish(); };

            //buttonAdminViewUsers
            var buttonAdminViewUsers = FindViewById <Button>(Resource.Id.buttonAdminViewUsers);

            buttonAdminViewUsers.Click += buttonAdminViewUsers_Click;

            //buttonClearClientData
            var buttonClearClientData = FindViewById <Button>(Resource.Id.buttonClearClientData);

            buttonClearClientData.Click += buttonClearClientData_Click;

            //buttonRebuildIndexes
            var buttonRebuildIndexes = FindViewById <Button>(Resource.Id.buttonRebuildIndexes);

            buttonRebuildIndexes.Click += buttonRebuildIndexes_Click;

            //buttonReuploadData
            var buttonReuploadData = FindViewById <Button>(Resource.Id.buttonReuploadData);

            buttonReuploadData.Click += buttonReuploadData_Click;
        }