public CreateCollection CreateCollection(string name)
        {
            CreateCollection result = null;

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            try
            {
                var formData = new MultipartFormDataContent();

                if (!string.IsNullOrEmpty(name))
                {
                    var nameContent = new StringContent(name, Encoding.UTF8, HttpMediaType.TEXT_PLAIN);
                    nameContent.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json");
                    formData.Add(nameContent, "name");
                }

                result = this.Client.PostAsync($"{this.Endpoint}{PATH_COLLECTIONS}")
                         .WithArgument("api_key", ApiKey)
                         .WithArgument("version", VERSION_DATE_2016_05_20)
                         .WithBodyContent(formData)
                         .As <CreateCollection>()
                         .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
예제 #2
0
        public string GetMultiTrackKml()
        {
            trackNo = trackNo + 1;
            Kml      kml             = NewGxKml();
            Document updatedDocument = GetUpdatedDocument();

            if (trackNo == 1)
            {
                kml.Feature = updatedDocument;
                return(StringOf(kml));
            }

            CreateCollection createCollection = new CreateCollection();

            createCollection.Add(updatedDocument);

            Update update = new Update();

            update.AddUpdate(createCollection);

            NetworkLinkControl networkLinkControl = new NetworkLinkControl();

            networkLinkControl.Cookie = $"seq={lastSeq}";
            networkLinkControl.Update = update;

            kml.NetworkLinkControl = networkLinkControl;
            return(StringOf(kml));
        }
        /// <summary>
        /// Provides in-place (destructive) processing of the <see cref="Update"/>.
        /// </summary>
        /// <param name="update">The update instance.</param>
        /// <param name="file">
        /// A KmlFile containing the <c>Update</c> and the update targets.
        /// </param>
        /// <exception cref="ArgumentNullException">file is null.</exception>
        public static void Process(this Update update, KmlFile file)
        {
            if (file == null)
            {
                throw new ArgumentNullException("file");
            }

            foreach (var child in update.Updates)
            {
                ChangeCollection change = child as ChangeCollection;
                if (change != null)
                {
                    ProcessChange(change, file);
                    continue;
                }

                CreateCollection create = child as CreateCollection;
                if (create != null)
                {
                    ProcessCreate(create, file);
                    continue;
                }

                DeleteCollection delete = child as DeleteCollection;
                if (delete != null)
                {
                    ProcessDelete(delete, file);
                }
            }
        }
        public async Task CreateCollectionEmitsEvent()
        {
            var collectionName        = "1111";
            var collectionDescription = "1111";
            var tokenPrefix           = "1111";
            var mode = new CollectionMode(new Nft(200));

            var collectionCreatedTask = new TaskCompletionSource <Created>();
            var createCollection      = new CreateCollection(collectionName, collectionDescription, tokenPrefix, mode);

            using var blockClient = CreateClient();
            blockClient.CollectionManagement.CollectionCreated += (sender, @event) =>
            {
                if (AddressUtils.GetAddrFromPublicKey(@event.Account).Equals(Configuration.Alice.Address))
                {
                    collectionCreatedTask.SetResult(@event);
                }
            };

            using var client = CreateClient();
            client.CollectionManagement.CreateCollection(createCollection, new Address(Configuration.Alice.Address), Configuration.Alice.PrivateKey);

            await collectionCreatedTask.Task
            .WithTimeout(TimeSpan.FromMinutes(1));

            var created = collectionCreatedTask.Task.Result;

            Assert.NotNull(created);
            Output.WriteLine($"Created collection with id: {created.Id}");
        }
예제 #5
0
        public void When(CreateCollection createCollection)
        {
            Contracts.EnsureNotNullCommand(createCollection, "Create collection command was null");
            Contracts.EnsureString(createCollection.Name,string.IsNullOrWhiteSpace,  "Collection name was null or empty");
            Contracts.EnsureInt(createCollection.WipLimit, i => i >= 0, "Wip value was less than or equal to 0");

            Update(createCollection, c => c.Create(createCollection.Identity, createCollection.Name, createCollection.WipLimit));
        }
예제 #6
0
 public string CreateCollection(CreateCollection createCollection, Address sender, string privateKey)
 {
     return(_nftClient.MakeCallWithReconnect(application => application.SubmitExtrinsicObject(
                                                 createCollection,
                                                 Module,
                                                 CreateCollectionMethod,
                                                 sender,
                                                 privateKey), _nftClient.Settings.MaxReconnectCount));
 }
예제 #7
0
 public Dictionary <string, string> GetUrlParameters()
 {
     return(new Dictionary <string, string>
     {
         { "database", Database },
         { "collection", Collection },
         { "createCollection", CreateCollection.ToString() },
         { "waitForSync", WaitForSync.ToString() },
     });
 }
예제 #8
0
        //private ScorocodeCollection collection;

        public RequestCreateCollection(ScorocodeSdkStateHolder stateHolder, string collectionName,
            bool isUseDocsACL, ScorocodeACL ACL) : base(stateHolder)
        {
            collection = new CreateCollection(collectionName, isUseDocsACL, ACL);
            //    this.collection = new ScorocodeCollection()
            //            .setCollectionName(collectionName)
            //            .setUseDocsACL(isUseDocsACL)
            //            .setACL(ACL)
            //            .setNotify(false)
            //            .setTriggers(new ScorocodeTriggers());
        }
예제 #9
0
        public async Task <ViewCollection> CreateCollectionAsync([FromBody] CreateCollection createCollection)
        {
            var collection = createCollection.GetModel();

            _context.Collections.Add(collection);
            await _context.SaveChangesAsync();

            _logger.LogInformation($"Created collection #{collection.Id}.");

            return(ViewCollection.Create(collection));
        }
        public async Task <Collection> CreateCollection(int profileId, CreateCollection collection)
        {
            Collection newCollection = new Collection {
                Title     = collection.Title,
                ProfileId = profileId
            };

            _context.Collections.Add(newCollection);
            await _context.SaveChangesAsync();

            return(newCollection);
        }
예제 #11
0
    public void Create()
    {
        if (_savingInProgress)
        {
            return;
        }

        _savingInProgress = true;

        foreach (var validator in AllValidators())
        {
            validator.Validate();
        }

        if (AllValidators().SelectMany(v => v.ValidationErrors).Any())
        {
            return;
        }

        var size      = (uint)CustomDataSize();
        var address   = GameSettings.Address;
        var publicKey = AddressUtils.GetPublicKeyFromAddr(address);


        var fieldsSchema = _fieldScripts
                           .Select(f => new NftFieldSchema(f.FieldName, f.FieldSize ?? 0))
                           .ToList();


        void Cleanup()
        {
            NftClient.CollectionManagement.CollectionCreated -= Handler;
            _updateQueue.Enqueue(() => onCloseCollection?.Invoke());
            _savingInProgress = false;
        }

        void Handler(object sender, Created created)
        {
            if (publicKey.Bytes.SequenceEqual(created.Account.Bytes))
            {
                var schema = new NftCollectionSchema(fieldsSchema, created.Id);
                schema.Save();
                Cleanup();
            }
        }

        NftClient.CollectionManagement.CollectionCreated += Handler;

        var createCollection = new CreateCollection(nameField.text, descriptionField.text, tokenPrefixField.text, new CollectionMode(new Nft(size)));

        NftClient.CollectionManagement.CreateCollection(createCollection, new Address(address), GameSettings.PrivateKey);
    }
예제 #12
0
 public Dictionary <string, string> GetUrlParameters()
 {
     return(new Dictionary <string, string>
     {
         { "database", Database },
         { "type", Type.ToString().ToLower() },
         { "waitForSync", WaitForSync.ToString() },
         { "complete", Complete.ToString() },
         { "details", Details.ToString() },
         { "collection", Collection },
         { "createCollection", CreateCollection.ToString() },
     });
 }
예제 #13
0
        private void OnGetCollection(CreateCollection collection, string customData)
        {
            if (collection != null)
            {
                Log.Debug("TestVisualRecognition", "Get Collection succeded!");
                Log.Debug("TestVisualRecognition", "collectionID: {0} | collection name: {1} | collection images: {2}", collection.collection_id, collection.name, collection.images);
            }
            else
            {
                Log.Debug("TestVisualRecognition", "Get Collection failed!");
            }

            m_RetrieveCollectionDetailsTested = true;
            Test(collection != null);
        }
        public string AuthoritySearch()
        {
            var collectionId   = "PoliceAuthorityCollection";
            var bucket         = "bhavesh-aws-bucket";
            var photo          = "recognition/BM.jpg";
            var photoToBeAdded = "download-2.jpg";

            if (CreateCollection.Collection(collectionId).Equals("OK"))
            {
                AddFaces.FaceAddition(collectionId, bucket, photoToBeAdded);
            }
            else
            {
                return("Error occurred");
            }
            return(SearchFacesMatchingImage.RecogniseFaceMatchFromS3(collectionId, bucket, photo));
        }
예제 #15
0
 private static void ProcessCreate(CreateCollection create, KmlFile file)
 {
     foreach (Container source in create)
     {
         if (source.TargetId != null)
         {
             // Make sure it was found and that the target was a Container
             if (file.FindObject(source.TargetId) is Container target)
             {
                 foreach (Feature feature in source.Features)
                 {
                     Feature clone = feature.Clone(); // We never give the original source.
                     target.AddFeature(clone);
                     file.AddFeature(clone);
                 }
             }
         }
     }
 }
예제 #16
0
 private static void ProcessCreate(CreateCollection create, KmlFile file)
 {
     foreach (var source in create)
     {
         if (source.TargetId != null)
         {
             Container target = file.FindObject(source.TargetId) as Container;
             if (target != null) // Make sure it was found and that the target was a Container
             {
                 foreach (var feature in source.Features)
                 {
                     var clone = feature.Clone(); // We never give the original source.
                     target.AddFeature(clone);
                     file.AddFeature(clone);
                 }
             }
         }
     }
 }
예제 #17
0
        public void TestInlineUpdate()
        {
            var document = new Document();

            document.AddStyle(new Style {
                Id = "style0"
            });

            var create = new CreateCollection {
                document
            };

            var update = new Update();

            update.AddUpdate(create);

            Update output = StyleResolver.InlineStyles(update);

            // Make sure it didn't change anything
            SampleData.CompareElements(update, output);
        }
예제 #18
0
        /// <summary>
        /// 调用这个方法以刷新闭合站和闭合差
        /// </summary>
        protected void RefreshClosed()
        {
            #region 用于枚举闭合环的本地函数
            SettlementPointBase[] Closed()
            {
                var list    = new LinkedList <SettlementPointBase>();
                var isFixed = this is SettlementPointFixed;

                foreach (var item in this.To <INode>().AncestorsAll.OfType <SettlementPointBase>())
                {
                    list.AddLast(item);
                    if (item.Name == Name || (isFixed && item is SettlementPointFixed))        //检查是否为闭合或附合
                    {
                        return(list.ToArray());
                    }
                }
                return(CreateCollection.Empty(list));
            }

            #endregion
            var closed = Closed();
            if (closed.Any())
            {
                var closedPoint = closed[^ 1];
        public CreateCollection GetCollection(string collectionId)
        {
            CreateCollection result = null;

            if (string.IsNullOrEmpty(collectionId))
            {
                throw new ArgumentNullException(nameof(collectionId));
            }

            try
            {
                result = this.Client.GetAsync($"{this.Endpoint}{string.Format(PATH_COLLECTION, collectionId)}")
                         .WithArgument("api_key", ApiKey)
                         .WithArgument("version", VERSION_DATE_2016_05_20)
                         .As <CreateCollection>()
                         .Result;
            }
            catch (AggregateException ae)
            {
                throw ae.Flatten();
            }

            return(result);
        }
        public async Task <ActionResult <CollectionDto> > CreateCollection(int profileId, [FromBody] CreateCollection collection)
        {
            if (profileId != collection.ProfileId)
            {
                return(BadRequest());
            }
            Collection newCollection = await profileCollectionRepository.CreateCollection(profileId, collection);

            CollectionDto newCollectionDto = await collectionRepository.GetCollection(newCollection.CollectionId);

            return(CreatedAtAction("GetCollection", new { profileId = newCollection.ProfileId, collectionId = newCollection.CollectionId }, newCollectionDto));
        }
예제 #21
0
 /// <inheritdoc cref="SettlementPointFixed(string, IUnit{IUTLength}?, IUnit{IUTLength}, INode?)"/>
 /// <param name="Known">索引本次沉降观测中,高程已知的点的名称和高程,
 /// 如果为<see langword="null"/>,则代表除基准点外没有已知点</param>
 public SettlementPointRoot(string Name, IUnit <IUTLength> High, IEnumerable <KeyValuePair <string, IUnit <IUTLength> > >?Known)
     : base(Name, null, High, null)
 {
     this.Known = (Known ?? CreateCollection.Empty(Known)).ToDictionary(false);
 }
예제 #22
0
 /// <summary>
 /// Adds the specified <see cref="CreateCollection"/> to <see cref="Updates"/>.
 /// </summary>
 /// <param name="update">The <c>Create</c> to add.</param>
 /// <exception cref="ArgumentNullException">update is null.</exception>
 /// <exception cref="InvalidOperationException">
 /// update belongs to another <see cref="Element"/>.
 /// </exception>
 public void AddUpdate(CreateCollection update)
 {
     this.AddChild(update);
 }