示例#1
0
        public async Task <Key> Save(DbSaveableEntity saveableEntity)
        {
            var assets    = AppInstance.Instance.ApiAssets;
            var projectId = assets[Constants.ASSET_PROJECT_ID];
            var now       = DateTime.Now;
            var entity    = new Entity()
            {
                Key = new Key()
                {
                    PartitionId = new PartitionId()
                    {
                        NamespaceId = "", ProjectId = projectId
                    },
                    Path = new List <PathElement>()
                    {
                        new PathElement()
                        {
                            Kind = saveableEntity.kindName.Value,
                            Name = saveableEntity.Id.Value
                        }
                    }
                },
                Properties = new Dictionary <string, Value>()
                {
                    { "id", new Value()
                      {
                          StringValue = saveableEntity.Id.Value
                      } },
                    { "entityid", new Value()
                      {
                          StringValue = saveableEntity.EntityId.Value
                      } },
                    //{"dateadded", new Value() { IntegerValue = now.toYMDInt() } },
                    { "editday", new Value()
                      {
                          IntegerValue = now.toYMDInt()
                      } },
                    { "editdate", new Value()
                      {
                          IntegerValue = now.ToBinary()
                      } },
                    { "datablob", new Value()
                      {
                          ExcludeFromIndexes = true,
                          StringValue        = saveableEntity
                                               .getJson()
                                               .Encrypt()
                                               .Value
                      } },
                    { "kindmetadata", new Value()
                      {
                          StringValue = saveableEntity.Entity.KindMetaData ?? string.Empty
                      } }
                }
            };
            var datastore = GetDatastoreService(GetDefaultCredential(assets, _assetManager), assets);

            return(await SaveToCloud(datastore, projectId, entity));
        }
示例#2
0
        public int AddToOutQueue(DbSaveableEntity saveableEntity)
        {
            var asString  = saveableEntity.getJson();
            var outEntity = new OutEntity()
            {
                Id       = saveableEntity.Id.Value,
                DataBlob = asString
            };
            var res = new OutDb().DB.InsertOrReplace(outEntity);

            return(res);
        }