Ejemplo n.º 1
0
        private async Task Initialize(CancellationToken cancellationToken)
        {
            _excludedMatchDateEntities.Clear();
            _excludedMatchDateEntities.AddRange(
                await _appDb.ExcludedMatchDateRepository.GetExcludedMatchDatesAsync(
                    _tenantContext.TournamentContext.MatchPlanTournamentId, cancellationToken));

            _availableMatchDateEntities.Clear();
            _availableMatchDateEntities.AddRange(
                await _appDb.AvailableMatchDateRepository.GetAvailableMatchDatesAsync(
                    _tenantContext.TournamentContext.MatchPlanTournamentId, cancellationToken));

            _generatedAvailableMatchDateEntities.Clear();
        }
Ejemplo n.º 2
0
        private static async Task ConvertMessages()
        {
            // display total amount of messages to process
            int totalNumberOfMessages = await MessageGuiHelper.GetTotalNumberOfMessagesAsync();

            Console.WriteLine("Total # of messages to process: {0}. Using batch size: {1}", totalNumberOfMessages, BATCHSIZE);
            var numberOfBatches = (totalNumberOfMessages / BATCHSIZE) + 1;
            var qf = new QueryFactory();
            var q  = qf.Message.OrderBy(MessageFields.MessageID.Ascending())
                     .Exclude(MessageFields.MessageTextAsHTML);

            using (var adapter = new DataAccessAdapter())
            {
                await adapter.StartTransactionAsync(IsolationLevel.ReadCommitted, "Converting UBB to Markdown").ConfigureAwait(false);

                adapter.KeepTrackOfTransactionParticipants = false;
                try
                {
                    var messages = new EntityCollection <MessageEntity>();
                    for (int batchNo = 1; batchNo <= numberOfBatches; batchNo++)
                    {
                        messages.Clear();
                        Console.WriteLine("Batch {0} of {1}", batchNo, numberOfBatches);
                        q.Page(batchNo, BATCHSIZE);
                        Console.Write("\tFetching messages...");
                        adapter.FetchQuery(q, messages);
                        Console.WriteLine("DONE. Messages fetched: {0}", messages.Count);
                        Console.Write("\tParsing messages...");
                        foreach (var message in messages)
                        {
                            string parserLog;
                            string messageAsXml;
                            bool   errorsOccurred;
                            string convertedText = TextParser.TransformUBBMessageStringToHTML(message.MessageText, _parserData, out parserLog, out errorsOccurred, out messageAsXml);
                            if (errorsOccurred)
                            {
                                Console.WriteLine("\nERRORS: {0}", parserLog);
                                Console.WriteLine("MessageID: {0}\nMessage as text:\n{1}--------------\n", message.MessageID, message.MessageText);
                            }
                            else
                            {
                                // html decode, so any &lt; etc. are converted back to the regular characters.
                                message.MessageText = HttpUtility.HtmlDecode(convertedText);
                            }
                        }
                        Console.WriteLine("DONE");
                        Console.Write("\tPersisting batch...");
                        await adapter.SaveEntityCollectionAsync(messages).ConfigureAwait(false);

                        Console.WriteLine("DONE\n");
                    }
                    adapter.Commit();
                }
                catch
                {
                    adapter.Rollback();
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
        public static int Delete(string key)
        {
            int deleted = 0;

            EntityCollection col = GetCollection(key);

            if (col != null)
            {
                int ents = col.Count;

                while (--ents >= 0)
                {
                    if (ents < col.Count)
                    {
                        col[ents].Delete();

                        ++deleted;
                    }
                }

                col.Clear();
            }

            _Collections.Remove(key);

            return(deleted);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Метод для создание массива шариков по концентрической сетке
        /// </summary>
        /// <param name="part">деталь</param>
        /// <param name="sketch">Эскиз</param>
        /// <param name="type">направлние</param>
        /// <param name="planeXOZ">плоскость XOZ</param>
        /// <param name="planeYOZ">плоскость YOZ</param>
        private static void BallsConcentricArray(ksPart part, ksEntity sketch, short type,
                                                 ksEntity planeXOZ, ksEntity planeYOZ)
        {
            ksEntity rotate = part.NewEntity((short)Obj3dType.o3d_bossRotated);
            ksBossRotatedDefinition rotDef = rotate.GetDefinition();

            rotDef.directionType = type;
            rotDef.SetSketch(sketch);
            rotDef.SetSideParam(true, 360);
            ksRotatedParam rotateParam = rotDef.RotatedParam();

            rotate.Create();
            //ОСЬ
            ksEntity axis = part.NewEntity((short)Obj3dType.o3d_axis2Planes);
            ksAxis2PlanesDefinition axisdef = axis.GetDefinition();

            axisdef.SetPlane(1, planeXOZ);
            axisdef.SetPlane(2, planeYOZ);
            axis.Create();
            //Массив по Кругу
            ksEntity circrotate = part.NewEntity((short)Obj3dType.o3d_circularCopy);
            ksCircularCopyDefinition cpyRotDef = circrotate.GetDefinition();

            cpyRotDef.SetAxis(axis);
            cpyRotDef.SetCopyParamAlongDir(8, 45, false, false);
            EntityCollection circcoll = (cpyRotDef.GetOperationArray());

            circcoll.Clear();
            circcoll.Add(rotate);
            circrotate.Create();
        }
Ejemplo n.º 5
0
        public void Clear_RemovesAllItemsFromCollection()
        {
            EntityCollection <IOsmGeometry> target = new EntityCollection <IOsmGeometry>(_data);

            target.Clear();

            Assert.Empty(target);
        }
Ejemplo n.º 6
0
 protected override void OnReset()
 {
     base.OnReset();
     if (_employees != null)
     {
         _employees.Clear();
     }
 }
Ejemplo n.º 7
0
        public virtual void Clear()
        {
            // copy list to keep reference to items after Clear()
            var items = underlyingCollection.ToArray();

            NotifyOwnerChanging();
            items.ForEach(i => NotifyItemChanging(i));
            underlyingCollection.Clear();
            items.ForEach(i => NotifyItemChanged(i));
            NotifyOwnerChanged();
        }
        private void DistinctEntityCollection(EntityCollection entityCollection)
        {
            Entity[]             entities = entityCollection.ToArray();
            IEnumerable <Entity> distinctResult;

            distinctResult = entities.GroupBy(i => i.PrimaryColumnValue).Select(e => e.First());
            entityCollection.Clear();
            foreach (var entity in distinctResult)
            {
                entityCollection.Add(entity);
            }
        }
Ejemplo n.º 9
0
        private void btnGuardarFactura_Click(object sender, EventArgs e)
        {
            var areValid = true;

            errorProvider.Clear();

            if (cmbCiudad.Text == string.Empty)
            {
                errorProvider.SetError(cmbCiudad, "La ciudad no puede estar vacía");
                areValid = false;
            }

            if (!Regex.IsMatch(txtIdFactura.Text, "^[0-9]+$"))
            {
                errorProvider.SetError(txtIdFactura, "Debe ser un número positivo");
                areValid = false;
            }

            if (!areValid)
            {
                return;
            }

            var idFactura = int.Parse(txtIdFactura.Text);

            if (_context.Facturas.Any(factura => factura.Id == idFactura))
            {
                errorProvider.SetError(txtIdFactura, "El id especificado ya existe, selecciona otro");
                return;
            }

            decimal valorTotalFactura = 0;

            _detallesFacturas.ToList().ForEach(detalleFactura => valorTotalFactura += detalleFactura.Cantidad * detalleFactura.Precio);
            txtTotal.Text = valorTotalFactura + "";

            var facturaToSave = new Facturas
            {
                Id              = idFactura,
                Fecha           = dtFecha.Value,
                ValorTotal      = valorTotalFactura,
                Ciudad          = cmbCiudad.Text,
                DetalleFacturas = _detallesFacturas.ToList()
            };

            _context.Facturas.Add(facturaToSave);
            _context.SaveChanges();
            _detallesFacturas.Clear();
            ResetDataGridView();
        }
Ejemplo n.º 10
0
        public void ClearTracker()
        {
            var entityCollection = new EntityCollection <EntityCollectionModel>();
            var entity           = new EntityCollectionModel
            {
                Title = "DbEntityCollectionTests.ClearTracker"
            };

            entityCollection.Update(entity, EntityEntryState.NoChanges);

            entityCollection.Clear();

            Assert.IsFalse(entityCollection.GetEntries().Any());
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Updates the navigation properties.
        /// </summary>
        /// <param name="zentityContext">The zentity context.</param>
        /// <param name="resource">The resource.</param>
        /// <param name="property">The property.</param>
        /// <param name="values">The values.</param>
        private static void UpdateNavigationproperties(ZentityContext zentityContext, ScholarlyWork resource, PropertyInfo property, ReadOnlyCollection <string> values)
        {
            EntityCollection <Contact> contactRelation = property.GetValue(resource, null) as EntityCollection <Contact>;

            if (null != contactRelation)
            {
                contactRelation.Clear();
                var authors = values.Distinct().Where(name => name.Length > 0)
                              .Select(name => new Person
                {
                    Title = name
                });
                ZentityAtomPubStoreWriter.AddPersons(zentityContext, contactRelation, authors);
            }
        }
Ejemplo n.º 12
0
        public void ResetGame()
        {
            EntityCollection.Clear();

            PlayerA = new Tank(new EntityPosition(525, 525), Player.PlayerA)
            {
                Fill = (SolidColorBrush)(new BrushConverter().ConvertFrom("#8FD354")), Orientation = EntityOrientation.Up
            };
            EntityCollection.Add(PlayerA);

            //PlayerB = new Tank(new EntityPosition(1000, 325), Player.PlayerB) { Fill = (SolidColorBrush)(new BrushConverter().ConvertFrom("#4A30DE")), Orientation = EntityOrientation.Left };
            //EntityCollection.Add(PlayerB);

            AddWalls();
        }
Ejemplo n.º 13
0
        private void SetArticleThemes(EntityCollection <Theme> themes, IEnumerable <int> themeIds)
        {
            // получаем коллекцию тем, выбранных пользователем на форме
            var selectedThemes = db.Theme.Where(t => themeIds.Contains(t.id));

            // очищаем список старых тем
            themes.Clear();
            // заполняем список тем теми которые выбрал пользователь
            if (themeIds != null)
            {
                foreach (var theme in selectedThemes)
                {
                    themes.Add(theme);
                }
            }
        }
Ejemplo n.º 14
0
        private void SetArticleAuthors(EntityCollection <Author> authors, IEnumerable <int> authorIds)
        {
            // получаем коллекцию авторов, выбранных пользователем на форме
            var selectedAuthors = db.Author.Where(t => authorIds.Contains(t.id));

            // очищаем список старых авторов
            authors.Clear();
            // заполняем список авторов теми которых выбрал пользователь
            if (authorIds != null)
            {
                foreach (var author in selectedAuthors)
                {
                    authors.Add(author);
                }
            }
        }
Ejemplo n.º 15
0
        public async Task MixedActionWriteAsync()
        {
            var connection       = TestConfiguration.GetConnection();
            var entityCollection = new EntityCollection <TestModel>();
            var pipeline         = new EntityWriterPipeline <TestModel>(connection);
            var reader           = new EntityReader <TestModel>(connection);

            pipeline.AddCollection(entityCollection);

            var updateEntity = new TestModel
            {
                Title = "EntityWriterPipelineTests.MixedActionWriteAsync-UpdateEntity"
            };
            var deleteEntity = new TestModel
            {
                Title = "EntityWriterPipelineTests.MixedActionWriteAsync-DeleteEntity"
            };

            entityCollection.Update(updateEntity, EntityEntryState.Added);
            entityCollection.Update(deleteEntity, EntityEntryState.Added);
            await pipeline.WriteAsync().ConfigureAwait(false);

            entityCollection.Clear();

            var addedEntity = new TestModel
            {
                Title = "EntityWriterPipelineTests.MixedActionWriteAsync-AddEntity"
            };

            updateEntity.Title = "EntityWriterPipelineTests.MixedActionWriteAsync-UpdateEntity-Updated";
            entityCollection.Update(addedEntity, EntityEntryState.Added);
            entityCollection.Update(updateEntity, EntityEntryState.Updated);
            entityCollection.Update(deleteEntity, EntityEntryState.Deleted);
            await pipeline.WriteAsync().ConfigureAwait(false);

            Assert.IsTrue(reader.AsQueryable().Where(e => e.Id == addedEntity.Id).Any());
            Assert.IsFalse(reader.AsQueryable().Where(e => e.Id == deleteEntity.Id).Any());

            var dbEntity = reader.AsQueryable().Where(e => e.Id == updateEntity.Id).FirstOrDefault();

            Assert.AreEqual("EntityWriterPipelineTests.MixedActionWriteAsync-UpdateEntity-Updated", dbEntity.Title);
        }
        /// <summary>
        /// All entity data is cleared and attached gameobjects destroyed. Typically called when one game session ends before another begins.
        /// </summary>
        internal void CleanUpSpawns()
        {
            // Despawn player entities from the player collection and then clear the collection
            if (playerCollection != null)
            {
                foreach (EntityMember player in playerCollection.Members)
                {
                    Despawn(player);
                }
                playerCollection.Clear();
            }

            // Despawn mob entities from the mob colleaciton and clear the collection
            if (mobCollection != null)
            {
                foreach (EntityMember mob in mobCollection.Members)
                {
                    Despawn(mob);
                }
                mobCollection.Clear();
            }
            // ... other entity types
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Handler of the Submit button
        /// Persists changes to the database
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnSubmit_Click(object sender, EventArgs e)
        {
            int savedCount   = 0;
            int deletedCount = 0;

            // A using statement makes sure the Adapter is Dispose.
            using (DataAccessAdapter adapter = new DataAccessAdapter())
            {
                // Start a Transaction
                adapter.StartTransaction(IsolationLevel.ReadCommitted, "CustomersActions");
                try
                {
                    // Save changes of the bound collection to the database. (Inserts/Updates)
                    savedCount = adapter.SaveEntityCollection(_entities, true, false);

                    // Delete entities removed from the bound collection.
                    if (_entitiesToDelete.Count > 0)
                    {
                        deletedCount = adapter.DeleteEntityCollection(_entitiesToDelete);
                        _entitiesToDelete.Clear();
                    }

                    // Commit the Transaction
                    adapter.Commit();
                }
                catch
                {
                    // Rollback the Transaction.
                    adapter.Rollback();
                    throw;
                }
            }

            // Show a feedback message to the user.
            MessageBox.Show("Number of saved records = " + savedCount.ToString() + "\r\nNumber of deleted records = " + deletedCount.ToString());
        }
Ejemplo n.º 18
0
 public void Clear()
 {
     collection.Clear();
 }
Ejemplo n.º 19
0
        private static void ConvertThreadMemos()
        {
            Console.WriteLine("Converting thread memos. ");
            var qf = new QueryFactory();

            using (var adapter = new DataAccessAdapter())
            {
                var totalNumberOfThreads = adapter.FetchScalar <int>(qf.Thread.Select(Functions.CountRow()));
                var numberOfBatches      = (totalNumberOfThreads / BATCHSIZE) + 1;
                Console.WriteLine("Total # of threads to process: {0}. Using batch size: {1}", numberOfBatches, BATCHSIZE);
                var q = qf.Thread.OrderBy(ThreadFields.ThreadID.Ascending());
                adapter.StartTransaction(IsolationLevel.ReadCommitted, "Converting UBB to Markdown");
                adapter.KeepTrackOfTransactionParticipants = false;
                try
                {
                    var threads = new EntityCollection <ThreadEntity>();
                    for (int batchNo = 1; batchNo <= numberOfBatches; batchNo++)
                    {
                        threads.Clear();
                        Console.WriteLine("Batch {0} of {1}", batchNo, numberOfBatches);
                        q.Page(batchNo, BATCHSIZE);
                        Console.Write("\tFetching threads...");
                        adapter.FetchQuery(q, threads);
                        Console.WriteLine("DONE. Threads fetched: {0}", threads.Count);
                        Console.Write("\tParsing memos on threads...");
                        foreach (var thread in threads)
                        {
                            var toConvert = thread.Memo;
                            if (string.IsNullOrWhiteSpace(toConvert))
                            {
                                continue;
                            }
                            // replace CRLF with <space><space>CRLF, as the markdown parser will otherwise collide it with the previous lines which we don't want
                            toConvert = toConvert.Replace(Environment.NewLine, "  " + Environment.NewLine);
                            string parserLog;
                            string messageAsXml;
                            bool   errorsOccurred;
                            string convertedText = TextParser.TransformUBBMessageStringToHTML(toConvert, _parserData, out parserLog, out errorsOccurred, out messageAsXml);
                            if (errorsOccurred)
                            {
                                Console.WriteLine("\nERRORS: {0}", parserLog);
                                Console.WriteLine("ThreadID: {0}\nThread memo as text:\n{1}--------------\n", thread.ThreadID, thread.Memo);
                            }
                            else
                            {
                                // html decode, so any &lt; etc. are converted back to the regular characters.
                                thread.Memo = HttpUtility.HtmlDecode(convertedText);
                            }
                        }
                        Console.WriteLine("DONE");
                        Console.Write("\tPersisting batch...");
                        adapter.SaveEntityCollection(threads);
                        Console.WriteLine("DONE\n");
                    }
                    adapter.Commit();
                }
                catch
                {
                    adapter.Rollback();
                    throw;
                }
            }
        }
 private void SetAuthorThemes(EntityCollection<Theme> themes, IEnumerable<int> themeIds)
 {
     // получаем коллекцию тем, выбранных пользователем на форме
     var selectedThemes = db.Theme.Where(t => themeIds.Contains(t.id));
     // очищаем список старых тем
     themes.Clear();
     // заполняем список тем теми которые выбрал пользователь
     if (themeIds != null)
     {
         foreach (var theme in selectedThemes)
         {
             themes.Add(theme);
         }
     }
 }
 private void SetArticleAuthors(EntityCollection<Author> authors, IEnumerable<int> authorIds)
 {
     // получаем коллекцию авторов, выбранных пользователем на форме
     var selectedAuthors = db.Author.Where(t => authorIds.Contains(t.id));
     // очищаем список старых авторов
     authors.Clear();
     // заполняем список авторов теми которых выбрал пользователь
     if (authorIds != null)
     {
         foreach (var author in selectedAuthors)
         {
             authors.Add(author);
         }
     }
 }