Ejemplo n.º 1
0
        public Ret <ICollection <Group> > Create(Bulk <GroupForm.Create> forms)
        {
            var result = new List <Group>();

            // Validando
            foreach (var form in forms)
            {
                var name = form.Name?.Trim();

                if (string.IsNullOrWhiteSpace(name))
                {
                    return(Ret.Fail(HttpStatusCode.BadRequest, $"O nome de grupo deve ser informado."));
                }

                if (Db.Groups.Any(x => x.Name == name))
                {
                    return(Ret.Fail(HttpStatusCode.Conflict, $"Já existe um grupo de usuário com este nome."));
                }
            }

            // Editando
            foreach (var form in forms)
            {
                var group = new Group
                {
                    Id   = Db.GenerateId(),
                    Name = form.Name.Trim()
                };
                Db.Groups.Add(group);
                result.Add(group);
            }

            return(result);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///   Identifies that entities in a change set failed validation.
 /// </summary>
 /// <param name="changeSet">The change set.</param>
 /// <param name="wasRedressed">
 ///   if set to <c>true</c> [was redressed].
 /// </param>
 /// <returns></returns>
 internal static Exception InvalidData(Bulk.ChangeSet changeSet, bool wasRedressed)
 {
     return new ValidationException(
         wasRedressed ?
         StringResources.InvalidSubmission :
         StringResources.BadMerge);
 }
Ejemplo n.º 3
0
        public Ret <ICollection <Group> > Edit(Bulk <GroupForm.BulkEdit, Group> edits)
        {
            var result = new List <Group>();

            // Validando
            foreach (var edit in edits)
            {
                edit.Record = Db.Groups.FirstOrDefault(x => x.Id == edit.Record.Id);
                if (edit.Record == null)
                {
                    return(Ret.Fail(HttpStatusCode.NotFound, $"O grupo de usuário não existe."));
                }

                var form  = edit.Form;
                var group = edit.Record;

                var name = form.Name ?? group.Name;

                if (string.IsNullOrWhiteSpace(name))
                {
                    return(Ret.Fail(HttpStatusCode.BadRequest, $"O nome do grupo de usuário deve ser informado."));
                }
            }

            // Editando
            foreach (var edit in edits)
            {
                var form  = edit.Form;
                var group = edit.Record;
                group.Name = (form.Name ?? group.Name)?.Trim();
                result.Add(group);
            }

            return(result);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 更申请记录
        ///  Add By zhengsong
        /// Time"2014-11-04
        /// </summary>
        public void bulkInsertFuzhouPostLog(List <FuzhouPostLog> addfuzhouPostLogs)
        {
            var ctx = this.UnitOfWork as LMS_DbContext;

            Bulk.BulkInsert(ctx, "FuzhouPostLogs", addfuzhouPostLogs);
            ctx.SaveChanges();
        }
Ejemplo n.º 5
0
        public IEnumerable <T> GetAll <T>() where T : Entity
        {
            if (typeof(T) == typeof(Stock))
            {
                var s1 = new Stock()
                {
                    Name = "Lager 1"
                };
                var s2 = new Stock()
                {
                    Name = "Lager 2"
                };
                var b = new Bulk()
                {
                    Type = "Nasser Dreck"
                };

                var s1A1 = new Section()
                {
                    Nummer = "s1A1"
                };
                s1A1.Storages.Add(new Storage()
                {
                    Bulk = b, Menge = 12
                });
                s1.Sections.Add(s1A1);

                var s1A2 = new Section()
                {
                    Nummer = "s1A2"
                };
                s1A2.Storages.Add(new Storage()
                {
                    Bulk = b, Menge = 4
                });
                s1.Sections.Add(s1A2);

                var s2A1 = new Section()
                {
                    Nummer = "s2A1"
                };
                s2A1.Storages.Add(new Storage()
                {
                    Bulk = b, Menge = 9
                });
                s2.Sections.Add(s2A1);

                var s2A2 = new Section()
                {
                    Nummer = "s2A2"
                };
                s2A2.Storages.Add(new Storage()
                {
                    Bulk = b, Menge = 9
                });
                s2.Sections.Add(s2A2);
                return(new[] { s1, s2 }.Cast <T>());
            }
            throw new System.NotImplementedException();
        }
        public override async Task DeleteAllAsync(CancellationToken cancellationToken)
        {
            var readModelName = typeof(TReadModel).Name;

            EntityDescriptor descriptor;

            using (var dbContext = _contextProvider.CreateContext())
            {
                descriptor = GetDescriptor(dbContext);
            }

            var rowsAffected = await Bulk.Delete <TDbContext, TReadModel, BulkDeletionModel>(
                _contextProvider,
                _deletionBatchSize,
                cancellationToken,
                entity => new BulkDeletionModel
            {
                Id      = EF.Property <string>(entity, descriptor.Key),
                Version = EF.Property <long>(entity, descriptor.Version)
            },
                setProperties : (model, entry) =>
            {
                descriptor.SetId(entry, model.Id);
                descriptor.SetVersion(entry, model.Version);
            })
                               .ConfigureAwait(false);

            Log.Verbose(
                "Purge {0} read models of type '{1}'",
                rowsAffected,
                readModelName);
        }
Ejemplo n.º 7
0
 public Ret Delete(Bulk <Group> groups)
 {
     foreach (var group in groups)
     {
         Db.Groups.RemoveAll(x => x.Id == group.Id);
     }
     return(Ret.OK());
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Initializes a new instance of this class with the specified file details.
        /// </summary>
        /// <param name="filePath">The path of the bulk file to read.</param>
        /// <param name="resultFileType">The result file type.</param>
        /// <param name="fileFormat">The bulk file format.</param>
        public BulkFileReader(string filePath, ResultFileType resultFileType, Bulk.DownloadFileType fileFormat)
        {
            _bulkFilePath = filePath;

            _isForFullDownload = resultFileType == ResultFileType.FullDownload;

            _bulkStreamReader = new BulkStreamReader(filePath, fileFormat);
        }
Ejemplo n.º 9
0
 public Ret Delete(Bulk <User> users)
 {
     foreach (var user in users)
     {
         Db.Users.RemoveAll(x => x.Id == user.Id);
     }
     return(Ret.OK());
 }
Ejemplo n.º 10
0
        public async Task <IActionResult> Post([FromBody] Bulk values)
        {
            this.logger.LogInformation("Post");
            var pass = new List <string>();
            var fail = new List <string>();

            if (values == null)
            {
                return(this.BadRequest());
            }

            foreach (var item in values.Plans)
            {
                try
                {
                    await this.Save(item, this.appSettings.ServiceEndpoints.Plans + "Plans").ConfigureAwait(false);

                    pass.Add(item.PlanId);
                }
                catch (Exception)
                {
                    fail.Add(item.PlanId);
                }
            }

            foreach (var item in values.Materials)
            {
                try
                {
                    await this.Save(item, this.appSettings.ServiceEndpoints.Materials + "Materials").ConfigureAwait(false);

                    pass.Add(item.MaterialId);
                }
                catch (Exception)
                {
                    fail.Add(item.MaterialId);
                }
            }

            foreach (var item in values.Packs)
            {
                try
                {
                    await this.Save(item, this.appSettings.ServiceEndpoints.Packs + "Packs").ConfigureAwait(false);

                    pass.Add(item.PackId);
                }
                catch (Exception)
                {
                    fail.Add(item.PackId);
                }
            }

            Dictionary <string, List <string> > ret = new()
            {
                { "pass", pass },
                { "fail", fail }
            };
Ejemplo n.º 11
0
        public void TestScenario_Bulk_Index_Delete()
        {
            poco.Id = "1337";

            Client.ExecuteBulk(Bulk <Poco>
                               .Create(IndexName)
                               .Index(poco)
                               .Delete(poco));
        }
Ejemplo n.º 12
0
        public DataSet GetPreviousOrders(Bulk b)
        {
            DBParameterCollection paramCollection = new DBParameterCollection();

            paramCollection.Add(new DBParameter("@RouteID ", b.RouteId));
            paramCollection.Add(new DBParameter("@OrderDate ", b.OrderDate));
            paramCollection.Add(new DBParameter("@TypeId ", b.Type));
            return(_DBHelper.ExecuteDataSet("GetPreviousDayOrders", paramCollection, CommandType.StoredProcedure));
        }
        /// <summary>
        /// Exports to file.
        /// </summary>
        /// <param name="forProvider">For provider.</param>
        public async void ExportToFile(int forProvider)
        {
            using (State.BusyScope())
            {
                Emitter.Publish(Localised.ExportingToFile, DateTime.Now.AsUKDatetime());

                await Bulk.Export(Prepared.SelectedSource, forProvider);
            }
        }
Ejemplo n.º 14
0
        public void TestRemove()
        {
            Bulk <int> bulk = new Bulk <int>(iterationNumber);

            for (int i = 0; i < iterationNumber; i++)
            {
                bulk.Add(1);
            }
            Assert.AreEqual(true, bulk.Remove(1));
        }
Ejemplo n.º 15
0
        public void TestFindIndex()
        {
            Bulk <int> bulk = new Bulk <int>(iterationNumber);

            for (int i = 0; i < iterationNumber; i++)
            {
                bulk.Add(i);
            }
            Assert.AreEqual(5, bulk.FindIndex(5));
        }
Ejemplo n.º 16
0
        public void TestAdd()
        {
            Bulk <int> bulk = new Bulk <int>(iterationNumber);

            for (int i = 0; i < iterationNumber; i++)
            {
                Assert.AreEqual(1, bulk.Add(1));
            }
            Assert.AreEqual(-1, bulk.Add(1));
        }
Ejemplo n.º 17
0
        public void AsyncTestScenario_Bulk_Index_Delete()
        {
            poco.Id = "1337";

            Bulk <Poco>
            .Create(IndexName)
            .Index(poco)
            .Delete(poco)
            .ExecuteAsyncWith(Client);
        }
        /// <summary>
        /// Executes a bulk statement using the asyncronus Bulk API
        /// https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html
        /// </summary>
        /// <param name="bulkQuery"></param>
        /// <returns></returns>
        public async Task ExecuteBulkAsync(Bulk bulkQuery)
        {
            var statement = Generator.Generate(bulkQuery);
            var response  = await LowLevelClient.BulkAsync <string>(bulkQuery.IndexName, statement);

            if (!response.Success)
            {
                throw response.OriginalException ?? new Exception($"Unsuccessful Elastic Request: {response.DebugInformation}");
            }
        }
        /// <summary>
        ///   Initializes a new instance of the
        ///   <see cref="ChangeSetPerformanceScope"/> class.
        /// </summary>
        /// <param name="instanceName">The instance name.</param>
        /// <param name="changeSet">The change set.</param>
        public ChangeSetPerformanceScope(string instanceName, Bulk.ChangeSet changeSet)
        {
            if (!s_enabled)
                return;

            _counters = s_counters.GetOrAdd(instanceName, CounterCollection.Create);
            _size = changeSet.TotalItemsCount;

            _startTicks = Stopwatch.GetTimestamp();
        }
Ejemplo n.º 20
0
        public void TestCount()
        {
            Bulk <int> bulk = new Bulk <int>(iterationNumber);

            for (int i = 0; i < iterationNumber; i++)
            {
                bulk.Add(1);
            }
            Assert.AreEqual(iterationNumber, bulk.Count);
        }
 public Task PurgeSnapshotsAsync(
     CancellationToken cancellationToken)
 {
     return(Bulk.Delete <TDbContext, SnapshotEntity, SnapshotEntity>(
                _contextProvider,
                _deletionBatchSize,
                cancellationToken,
                e => new SnapshotEntity {
         Id = e.Id
     }));
 }
Ejemplo n.º 22
0
        public void TestRemoveAt()
        {
            Bulk <int> bulk = new Bulk <int>(iterationNumber);

            for (int i = 0; i < iterationNumber; i++)
            {
                bulk.Add(i);
            }
            bulk.RemoveAt(5);
            Assert.AreEqual(-1, bulk.FindIndex(5));
        }
Ejemplo n.º 23
0
        private bool UpdateCheck(out Bulk bulkInfo)
        {
            bulkInfo = scry.GetBulkInfo().Data.First(b => b.Type == BulkType.DefaultCards);

            if (localData == null)
            {
                LoadLocalData();
            }

            return(localData == null || bulkInfo.UpdatedAt < localData.UpdatedAt || localData.Version != LOCALDATA_VERSION);
        }
Ejemplo n.º 24
0
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            Dictionary <Identity, string> list = ((Playfield)character.Playfield).ListAvailablePlayfields();
            var messList = new List <MessageBody>();

            foreach (KeyValuePair <Identity, string> pf in list)
            {
                messList.Add(ChatText.Create(character, pf.Key.Instance.ToString().PadLeft(8) + ": " + pf.Value));
            }

            character.Playfield.Publish(Bulk.CreateIM(character.Client, messList.ToArray()));
        }
Ejemplo n.º 25
0
        public async Task <IActionResult> BulkLoad([FromBody] Bulk bulk)
        {
            _dbContext.AddRange(bulk.Events);
            foreach (var feedback in bulk.Feedback)
            {
                feedback.Id = string.IsNullOrEmpty(feedback.Id) ? Guid.NewGuid().ToString("D") : feedback.Id;
            }
            _dbContext.AddRange(bulk.Feedback);
            await _dbContext.SaveChangesAsync();

            return(StatusCode(200));
        }
Ejemplo n.º 26
0
        public void TestIndexer()
        {
            Bulk <int> bulk = new Bulk <int>(iterationNumber);

            for (int i = 0; i < iterationNumber; i++)
            {
                bulk.Add(i);
            }
            for (int i = 0; i < bulk.Count; i++)
            {
                Assert.AreEqual(i, bulk[i]);
            }
        }
 public override int CalculateVersion()
 {
     return(new
     {
         DocumentationUri,
         Patch = Patch.GetETagHashCode(),
         Bulk = Bulk.GetETagHashCode(),
         Filter = Filter.GetETagHashCode(),
         ChangePassword = ChangePassword.GetETagHashCode(),
         Sort = Sort.GetETagHashCode(),
         ETag = ETag.GetETagHashCode(),
         AuthenticationSchemes = AuthenticationSchemes.GetMultiValuedAttributeCollectionVersion()
     }.GetHashCode());
 }
Ejemplo n.º 28
0
        private void InitStep3()
        {
            byte[] data     = { 0x01, 0x86, 0xff, 0x01, 0x00, 0x00, 0x00, 0x00 };
            var    outData4 = Bulk.CreateReport();

            outData4.ReportId = 0x00;
            outData4.Data     = data;
            Bulk.WriteReport(outData4);
            while (outData4.ReadStatus != HidDeviceData.ReadStatus.Success)
            {
                ;
            }
            Bulk.ReadReport(ReadBogus);
        }
        public Task PurgeSnapshotsAsync(
            Type aggregateType,
            CancellationToken cancellationToken)
        {
            var aggregateName = aggregateType.GetAggregateName().Value;

            return(Bulk.Delete <TDbContext, SnapshotEntity, SnapshotEntity>(
                       _contextProvider,
                       _deletionBatchSize,
                       cancellationToken,
                       e => new SnapshotEntity {
                Id = e.Id
            },
                       e => e.AggregateName == aggregateName));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// </summary>
        /// <param name="character">
        /// </param>
        /// <param name="target">
        /// </param>
        /// <param name="args">
        /// </param>
        public override void ExecuteCommand(ICharacter character, Identity target, string[] args)
        {
            List <StatelData> sd = PlayfieldLoader.PFData[character.Playfield.Identity.Instance].Statels;
            var messList         = new List <MessageBody>();

            foreach (StatelData s in sd)
            {
                messList.Add(
                    ChatText.Create(
                        character,
                        ((int)s.StatelIdentity.Type).ToString("X8") + ":" + s.StatelIdentity.Instance.ToString("X8")));
            }

            character.Playfield.Publish(Bulk.CreateIM(character.Client, messList.ToArray()));
        }
Ejemplo n.º 31
0
        public void Render()
        {
            string handlerId =
                Helpers.CurrentHandlerId;
            Bulk bulk = Factory.CreateBulk();

            int queueLength =
                this._Queued.Count;

            while (this._Queued.TryDequeue(out int index))
            {
                IDirective directive = this[index];

                if (!directive.CanAsync || queueLength == 1)
                {
                    this.Render(directive);
                    continue;
                }

                // Directives without content are Attached actions
                // Directives with content may need special care and should be external
                ActionType actionType = directive switch
                {
                    Translation or Static or Elements.Property => ActionType.Attached,
                    AsyncGroup or ControlAsync or ReplaceableTranslation or MessageBlock or SingleAsync => ActionType.External,
                           _ => ActionType.None
                };

                if (actionType == ActionType.None)
                {
                    continue;
                }

                bulk.Add(
                    d =>
                {
                    Helpers.AssignHandlerId(handlerId);
                    this.Render((IDirective)d);
                },
                    directive,
                    actionType
                    );
            }

            bulk.Process();

            this.Deliver();
        }
Ejemplo n.º 32
0
        public void Open()
        {
            Control.OpenDevice();
            Bulk.OpenDevice();
            IsInitialised = false;

            ClearData();

            InitStep1();
            InitStep2();
            InitStep3();

            ClearData();

            IsInitialised = true;
        }
        public void TestDictionaryAdd()
        {
            DriveDictionary <int, Bulk <string> > dict = new DriveDictionary <int, Bulk <string> >("temp", new BinaryFormatter());

            for (int i = 0; i < iterationNumber; i++)
            {
                Bulk <string> bulk = new Bulk <string>(bulksize);
                for (int j = 0; j < bulksize; j++)
                {
                    bulk.Add(teststring);
                }
                dict.Add(i, bulk);
            }

            Assert.AreEqual(dict.Count, iterationNumber);
            dict.Dispose();
        }