Exemple #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();
        }
        internal List <AppUser> LoadCredentials()
        {
            var allCreds = new TableStore(KindName).GetAllBlobs();

            if (allCreds == null)
            {
                return(new List <AppUser>());
            }

            return((from credString in allCreds
                    select DbSaveableEntity.fromJson <AppUser>(credString)).ToList());
        }
Exemple #3
0
        private void MenuSmmaries_Click(object sender, RoutedEventArgs e)
        {
            var addRecordsFromTablet = false;

            if (addRecordsFromTablet)
            {
                //we have records that couldn't be synced from the tablet
                var toSave      = new List <CloudEntity>();
                var txt         = File.ReadAllText("Assets\\unsyncd.txt");
                var outEntities = txt.DecompressFromBase64String();

                var now      = DateTime.Now.AddDays(-8);
                var asBinary = now.ToBinary();

                var processors = new Dictionary <string, List <CloudEntity> >();
                foreach (var outEntity in outEntities)
                {
                    var ppdataset = DbSaveableEntity.fromJson <GeneralEntityDataset>(new KindItem(outEntity.DataBlob));
                    var saveable  = new DbSaveableEntity(ppdataset)
                    {
                        kindName = new KindName(ppdataset.FormName)
                    };
                    if (!processors.ContainsKey(ppdataset.FormName))
                    {
                        processors[ppdataset.FormName] = new List <CloudEntity>();
                    }
                    var cloudEntity = new CloudEntity()
                    {
                        Id       = saveable.Id.Value,
                        EntityId = saveable.EntityId.Value,
                        EditDay  = now.toYMDInt(),
                        EditDate = asBinary,
                        DataBlob = saveable
                                   .getJson()
                                   .Encrypt()
                                   .Value,
                        FormName     = ppdataset.FormName,
                        KindMetaData = saveable.Entity.KindMetaData ?? string.Empty
                    };
                    processors[ppdataset.FormName].Add(cloudEntity);
                }
                foreach (var item in processors)
                {
                    new KindDataProcessor()
                    .addToProcessingQueue(item.Key, item.Value);
                }
                //we save them to local
                AppInstance.Instance.CloudDbInstance.RefreshLocalEntities(setProgressValue);
            }

            MessageBox.Show("Menu item clicked ");
        }
Exemple #4
0
        protected void ShowMyView()
        {
            SetContentView(myView);
            addDefaultNavBehaviours();
            bindDateDialogEventsForView(myView);

            setDefaultValuesForView(myView);
            loadClientFromIntent();

            if (isInEditMode())
            {
                //means we have data to edit
                var jsonRecord     = this.Intent.GetStringExtra(Constants.BUNDLE_DATATOEDIT);
                var saveableEntity = DbSaveableEntity
                                     .fromJson <GeneralEntityDataset>(new KindItem(jsonRecord));
                //var saveableEntity = JsonConvert
                //    .DeserializeObject<GeneralEntityDataset>(jsonRecord);
                if (saveableEntity != null)
                {
                    var viewFields  = GetFieldsForView(myView);
                    var indexedData = saveableEntity.FieldValues;
                    var fvp         = getNameValuePairs(viewFields, indexedData);
                    setViewData(fvp);
                }
                else
                {
                    //we abort and show the home page
                }
            }
            else if (IsFirstPage && CurrentClient != null)
            {
                //if requires selection of client, we show the client selection dialog
                //loadClientFromIntent();

                //load client information if it has any indexed fields
                var viewFields  = GetFieldsForView(myView);
                var indexedData = CurrentClient.ToValuesList();
                var fvp         = getNameValuePairs(viewFields, indexedData);

                //remove date of visit field
                fvp.RemoveAll(t => t.Field.name == Constants.FIELD_PPX_DATEOFVISIT ||
                              t.Field.name == Constants.FIELD_VMMC_DATEOFVISIT
                              );
                setViewData(fvp);
            }
        }
Exemple #5
0
        public static string deidentifyBlob(this string dataBlob, string formName)
        {
            var toReturn = string.Empty;
            //we deserialise the blob to its base form
            var deserialised = DbSaveableEntity.fromJson <GeneralEntityDataset>(
                new KindItem(dataBlob)
                );
            var fieldValues = deserialised.FieldValues;

            //we get the field dictionary for this entity

            //we read each field, and deidentify if needed based on field attributes

            //and copy to out object

            //copy out object to the out entity

            return(dataBlob);
        }