Example #1
0
        public void Draw(RenderTarget target, AlphaTexturedPrimitiveShader shader, SpriteBatchDrawOptions options)
        {
            int current = 0;
            VertexBufferPCTDrawOptions vbOptions = new VertexBufferPCTDrawOptions()
            {
                Blending      = options.Blending,
                Transform     = options.Transform,
                PrimitiveType = PrimitiveType.Quads,
            };

            for (int i = 0; i < QueueCount; i++)
            {
                BatchItem item = DrawQueue[i];

                VertexBuffer.UpdateData(Vertices, current, item.Count);

                vbOptions.Texture = item.Texture;
                vbOptions.Start   = 0;
                vbOptions.Count   = item.Count;

                VertexBuffer.Draw(target, shader, vbOptions);

                current += item.Count;
            }
        }
Example #2
0
            public void Push(double[][,] data, double[] expected)
            {
                int i = -1;

                while (true)
                {
                    i++;
                    var j    = i % m_Threads;
                    var item = m_Items[j];
                    if (item == null)
                    {
                        lock (m_BatchItemSync)
                        {
                            item = m_Items[j];
                            if (item == null)
                            {
                                item       = new BatchItem(m_Algorithm);
                                m_Items[j] = item;
                            }
                        }
                    }

                    if (!item.DoIter(data, expected))
                    {
                        continue;
                    }
                    return;
                }
            }
Example #3
0
 public async Task AddFiles(string[] collection)
 {
     Task task = Task.Run(() =>
     {
         foreach (string path in collection)
         {
             BatchItem item = new BatchItem()
             {
                 Actions = Functions
             };
             if (BatchPath.IsDirectory(path))
             {
                 item.Target = new BatchDirectory(path);
             }
             if (BatchPath.IsFile(path))
             {
                 item.Target = new BatchFile(path);
             }
             Items.Add(item);
             item.Commit();
         }
         RefreshDisplay();
     });
     await task;
 }
Example #4
0
    public static void StaticBatching(UnityEngine.GameObject go)
    {
        MeshRenderer[] mrs = go.GetComponentsInChildren <MeshRenderer>();
        _BatchInfos.Clear();

        foreach (MeshRenderer mr in mrs)
        {
            var mat = mr.material;
            if (mat != null)
            {
                BatchItem o;
                if (!_BatchInfos.TryGetValue(mat.name, out o))
                {
                    o = new BatchItem()
                    {
                        MeshList = new List <MeshRenderer>()
                    };
                    _BatchInfos.Add(mat.name, o);
                }

                o.MeshList.Add(mr);
            }
        }

        int index = 0;
        var e     = _BatchInfos.GetEnumerator();

        while (e.MoveNext())
        {
            BatchItem pb = e.Current.Value;

            if (pb.MeshList.Count <= 1)
            {
                continue;
            }

            var root = new GameObject(HobaText.Format("Batch{0}", index++));
            var mt   = pb.MeshList[0].sharedMaterial;

            var goArray   = new GameObject[pb.MeshList.Count];
            var rootTrans = root.transform;
            for (int i = 0; i < pb.MeshList.Count; i++)
            {
                var cc = pb.MeshList[i];
                var g  = cc.gameObject;
                g.transform.parent = rootTrans;

                if (i != 0)
                {
                    cc.sharedMaterial = mt;
                }
                goArray[i] = g;
            }

            StaticBatchingUtility.Combine(goArray, root);
            rootTrans.parent = go.transform;
        }
        e.Dispose();
    }
        private void SendEmail(Guid tenantId, BatchItem batchItem, string toEmail, string subject, string message, EmailSenderOptions Options)
        {
            MailMessage mail   = GetMailMessage(tenantId, batchItem, toEmail, subject, message, Options.emailSender, Options.emailUserName, Options.useHtml);
            SmtpClient  client = GetSmtpClient(Options.emailServer, Options.emailPort, Options.requiresAuthentication,
                                               Options.emailEmail, Options.emailPassword, Options.useSsl);

            client.Send(mail);
        }
        public override IEnumerable <CacheItemResult> GetBatchResult(Type type, IEnumerable <string> keys)
        {
            //产生 field keys
            List <BatchItem> items = new List <BatchItem>();

            foreach (var key in keys)
            {
                ValidParams(key);
                var item = new BatchItem()
                {
                    SourceKey = key,
                    FieldKeys = ObjectHashMappingUtil.GetKeys(type, GetKeyPrefix(key))
                };
                items.Add(item);
            }

            //批量获取数据
            string[] allValues;
            using (var client = CreateRedisClient())
            {
                var allKeys = items.SelectMany(o => o.FieldKeys).ToArray();
                allValues = client.GetValuesFromHash(CacheName, allKeys).ToArray();
            }

            //转换数据为对象
            List <CacheItemResult> outputs = keys.Select(o => new CacheItemResult()).ToList();
            int index = 0;

            foreach (var item in items)
            {
                var output = outputs[index];
                output.Key = item.SourceKey;

                var values = new string[item.FieldKeys.Length];
                Array.Copy(allValues, index * item.FieldKeys.Length, values, 0, values.Length);

                //判断是否命中
                if (values.All(o => String.IsNullOrEmpty(o)))
                {
                    output.IsMissing = true;
                }
                else
                {
                    try
                    {
                        output.Value = ObjectHashMappingUtil.ToObject(type, values);;
                    }
                    catch (Exception ex)
                    {
                        log.WarnFormat("反序列化数据 {0} 发生错误 {1}", output.Key, ex.ToString());
                        output.IsMissing = true;
                    }
                }
                index++;
            }
            TraceCache(keys, outputs.GetMissingKeys().Count());
            return(outputs);
        }
Example #7
0
        /// <summary>
        /// Add batch item.
        /// </summary>
        /// <param name="textureKey">Texture key.</param>
        protected void AddBatch(int textureKey, BatchItem batchItem)
        {
            // Start new batch if required
            if (!batches.ContainsKey(textureKey))
            {
                batches.Add(textureKey, new List <BatchItem>());
            }

            // Add to batch
            batches[textureKey].Add(batchItem);
        }
Example #8
0
        public Task CreateTask(T input)
        {
            var batchItem = new BatchItem
            {
                Tcs   = new TaskCompletionSource <int>(),
                Input = input
            };

            _subject.OnNext(batchItem);
            return(batchItem.Tcs.Task);
        }
        public async Task <IActionResult> AddBatchItem([FromBody] BatchItem batchItem)
        {
            _batchService.AddBatchItem(batchItem);
            var result = await _unitOfWork.SaveAsync();

            if (result > 0)
            {
                return(Ok(result));
            }

            return(StatusCode(500, "Unable to add new batch item."));
        }
Example #10
0
        public void GivenConnectionWhenRetryShouldUseConfiguredBehavior()
        {
            var configuration = new ConfigurationBuilder()
                                .Build();

            var retryBehaviorMock = new Mock <IRetryBehavior>();
            var serviceProvider   = new ServiceCollection()
                                    .AddBusCore(configuration, builder =>
            {
                builder.SetConnectionString("amqp://*****:*****@localhost:5672/")
                .IgnoreCertificate()
                .SetSerializer <BusSerializer>()
                .UseRetryBehabior(retryBehaviorMock.Object);
            })
                                    .BuildServiceProvider();

            var connection = serviceProvider.GetService <BusConnection>();

            var       exchange   = Exchange.Default;
            var       queue      = Queue.Create(Guid.NewGuid().ToString());
            var       routingKey = RoutingKey.Create(queue.Name.Value);
            BatchItem item       = null;

            connection.Publish(exchange, queue, routingKey, "Message");

            var autoResetEvent = new AutoResetEvent(false);

            connection.PublishSuccessed += items =>
            {
                item = items.First();
                autoResetEvent.Set();
            };

            autoResetEvent.WaitOne();

            retryBehaviorMock.Setup(x => x.ShouldRetry(1, 5))
            .Returns(true)
            .Verifiable();
            retryBehaviorMock.Setup(x => x.GetWaitTime(1))
            .Returns(TimeSpan.FromMinutes(5))
            .Verifiable();

            connection.Subscribe <string>(exchange, queue, routingKey, 1, (scope, message) =>
            {
                throw new Exception("Test");
            });

            autoResetEvent.WaitOne();

            item.Should().NotBeNull();
            item.Queue.Name.Value.Should().EndWith("5m");
            retryBehaviorMock.VerifyAll();
        }
Example #11
0
        public Task <int> InsertData(int item)
        {
            var tcs  = new TaskCompletionSource <int>();
            var task = new BatchItem
            {
                Item = item,
                TaskCompletionSource = tcs
            };

            _channel.Writer.TryWrite(task);
            return(tcs.Task);
        }
Example #12
0
        internal bool BatchItemCreate(Guid tenantId, int?itemTimeOut, BatchItem info)
        {
            try
            {
                var cmd = CreateProcedureCommand("dbo.BatchItem_Create");
                cmd.AppendGuid("@guidTenantId", tenantId);
                if (itemTimeOut.HasValue)
                {
                    cmd.AppendInt("@intItemTimeOut", itemTimeOut.Value);
                }
                cmd.AppendGuid("@guidBatchItemId", info.BatchItemId);
                cmd.AppendGuid("@guidBatchTypeId", info.BatchTypeId);
                cmd.AppendMediumText("@strName", info.Name);
                if (info.Priority.HasValue)
                {
                    cmd.AppendTinyInt("@tiPriority", (byte)info.Priority.Value);
                }
                if (info.RetryCount.HasValue)
                {
                    cmd.AppendSmallInt("@siRetryCount", (short)info.RetryCount.Value);
                }
                if (info.NextRunTime != DateTime.MinValue)
                {
                    cmd.AppendDateTime("@dtNextRunTime", info.NextRunTime);
                }
                cmd.AppendXSmallText("@strEntityId", info.EntityId);
                cmd.AppendGuid("@guidReferenceId", info.ReferenceId);
                cmd.AppendTinyInt("@tiStatus", (byte)info.Status);
                cmd.AppendXLargeText("@strFailedReason", info.FailedReason);
                if (info.AuditDetails != null)
                {
                    if (info.AuditDetails.CreatedBy != Guid.Empty)
                    {
                        cmd.AppendGuid("@guidCreatedBy", info.AuditDetails.CreatedBy);
                    }
                }
                if (info.StartTime.HasValue && info.StartTime != DateTime.MinValue)
                {
                    cmd.AppendDateTime("@dtStartTime", info.StartTime.Value);
                }
                if (info.EndTime.HasValue && info.EndTime != DateTime.MinValue)
                {
                    cmd.AppendDateTime("@dtEndTime", info.EndTime.Value);
                }

                ExecuteCommand(cmd);
                return(true);
            }
            catch (SqlException e)
            {
                throw ReportAndTranslateException(e, "DataBatchItem::BatchItem_Create");
            }
        }
 public BaseSpriteBatch()
 {
     m_vertexBuffer          = new VertexBufferPCT(BufferUsageHint.DynamicDraw);
     m_vertices              = new VertexPCT[100 * 4];
     m_verticesCount         = 0;
     m_previousVerticesCount = 0;
     m_active             = false;
     m_drawQueue          = new BatchItem[20];
     m_queueCount         = 0;
     m_activeItem         = new BatchItem();
     m_activeItem.Texture = null;
     m_activeItem.Count   = 0;
 }
Example #14
0
 internal bool BatchItemUpdateStatus(Guid tenantId, BatchItem info)
 {
     try
     {
         var cmd = CreateProcedureCommand("dbo.BatchItem_UpdateStatus");
         cmd.AppendGuid("@guidTenantId", tenantId);
         cmd.AppendGuid("@guidBatchItemId", info.BatchItemId);
         cmd.AppendTinyInt("@tiStatus", (byte)info.Status);
         ExecuteCommand(cmd);
         return(true);
     }
     catch (SqlException e)
     {
         throw ReportAndTranslateException(e, "DataBatchItem::BatchItem_UpdateStatus");
     }
 }
Example #15
0
        public void AddBatchItem(BatchItem model)
        {
            // TODO: Add in foreign keys so items can be added by id instead of having to be looked up in services
            var batch             = _unitOfWork.BatchRepository.GetBatch(model.BatchId).Result;
            var batchUpdateReason = _unitOfWork.BatchUpdateReasonRepository.Get(model.ReasonId).Result;

            // idealy use an auto-mapper
            var batchItem = new Entities.BatchItem
            {
                Batch             = batch,
                Quantity          = model.Quantity,
                BatchUpdateReason = batchUpdateReason
            };

            _unitOfWork.BatchItemRepository.Add(batchItem);
        }
 void fillFakeData() {
     BatchItem bitem = new BatchItem() { IsChecked = false, Firmware = "0,6,3445", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#1" };
     items.Add(bitem);
     bitem = new BatchItem() { IsChecked = false, Firmware = "0,6,3445", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#1" };
     items.Add(bitem);
     bitem = new BatchItem() { IsEnabled = false, IsChecked = false, Firmware = "5.20", Manufacturer = "Axis", Model = "P3301", Name = "Axis camera" };
     items.Add(bitem);
     bitem = new BatchItem() { IsChecked = false, Firmware = "0,6,3415", Manufacturer = "Synesis", Model = "DK-255", Name = "Name#2" };
     items.Add(bitem);
     bitem = new BatchItem() { IsChecked = false, Firmware = "0,6,3446", Manufacturer = "Synesis", Model = "DK-255", Name = "Name#3" };
     items.Add(bitem);
     bitem = new BatchItem() { IsEnabled = false, IsChecked = false, Firmware = "0,6,3446", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#4" };
     items.Add(bitem);
     bitem = new BatchItem() { IsChecked = false, Firmware = "0,6,2445", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#5" };
     items.Add(bitem);
     bitem = new BatchItem() { IsChecked = false, Firmware = "0,6,3745", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#6" };
     items.Add(bitem);
 }
Example #17
0
        void fillFakeData()
        {
            BatchItem bitem = new BatchItem()
            {
                IsChecked = false, Firmware = "0,6,3445", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#1"
            };

            items.Add(bitem);
            bitem = new BatchItem()
            {
                IsChecked = false, Firmware = "0,6,3445", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#1"
            };
            items.Add(bitem);
            bitem = new BatchItem()
            {
                IsEnabled = false, IsChecked = false, Firmware = "5.20", Manufacturer = "Axis", Model = "P3301", Name = "Axis camera"
            };
            items.Add(bitem);
            bitem = new BatchItem()
            {
                IsChecked = false, Firmware = "0,6,3415", Manufacturer = "Synesis", Model = "DK-255", Name = "Name#2"
            };
            items.Add(bitem);
            bitem = new BatchItem()
            {
                IsChecked = false, Firmware = "0,6,3446", Manufacturer = "Synesis", Model = "DK-255", Name = "Name#3"
            };
            items.Add(bitem);
            bitem = new BatchItem()
            {
                IsEnabled = false, IsChecked = false, Firmware = "0,6,3446", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#4"
            };
            items.Add(bitem);
            bitem = new BatchItem()
            {
                IsChecked = false, Firmware = "0,6,2445", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#5"
            };
            items.Add(bitem);
            bitem = new BatchItem()
            {
                IsChecked = false, Firmware = "0,6,3745", Manufacturer = "Synesis", Model = "DK-455", Name = "Name#6"
            };
            items.Add(bitem);
        }
        public UpgradeBatchTaskView(IActivityContext <Unit> context)
        {
            this.context = context;

            items         = new ObservableCollection <BatchItem>();
            manufacturers = new ObservableCollection <string>();
            models        = new ObservableCollection <string>();

            CommonList = new List <BatchItem>();
            BatchTaskEventArgs evargs = context.container.Resolve <BatchTaskEventArgs>();

            nvtSession = evargs.session;;

            evargs.Devices.ForEach(dev => {
                BatchItem bitem        = new BatchItem(dev);
                bitem.PropertyChanged += new PropertyChangedEventHandler((object sender, PropertyChangedEventArgs e) => {
                    CanUpgrade();
                });
                CommonList.Add(bitem);
            });

            this.CommandBindings.Add(
                new CommandBinding(
                    UpgradeBatchTaskView.UpgradeCommand,
                    (s, a) => {
                OnUpgrade();
            }
                    )
                );

            this.CommandBindings.Add(
                new CommandBinding(
                    UpgradeBatchTaskView.CancelCommand,
                    (s, a) => {
                Success();
            }
                    )
                );

            InitializeComponent();

            BindData();
            Localization();
        }
Example #19
0
        public RestoreBatchTaskView(IActivityContext <Unit> context)
        {
            this.activityContext = context;

            items         = new ObservableCollection <BatchItem>();
            manufacturers = new ObservableCollection <string>();
            models        = new ObservableCollection <string>();
            firmwares     = new ObservableCollection <string>();

            CommonList = new List <BatchItem>();
            BatchTaskEventArgs evargs = context.container.Resolve <BatchTaskEventArgs>();

            nvtSession = evargs.session;
            ;

            evargs.Devices.ForEach(dev => {
                BatchItem bitem = new BatchItem(dev);
                CommonList.Add(bitem);
            });

            this.CommandBindings.Add(
                new CommandBinding(
                    RestoreBatchTaskView.RestoreCommand,
                    (s, a) => {
                OnRestore();
            }
                    )
                );

            this.CommandBindings.Add(
                new CommandBinding(
                    RestoreBatchTaskView.CancelCommand,
                    (s, a) => {
                Success();
            }
                    )
                );

            InitializeComponent();

            BindData();
            Localization();
        }
        private void EnqueueCurrent()
        {
            int currentQueueVerticesCount = m_verticesCount - m_previousVerticesCount;

            m_previousVerticesCount = m_verticesCount;

            if (currentQueueVerticesCount > 0)
            {
                if (m_queueCount >= m_drawQueue.Length)
                {
                    Array.Resize(ref m_drawQueue, m_queueCount * 2);
                }

                BatchItem item = m_activeItem;
                item.Count = currentQueueVerticesCount;
                m_drawQueue[m_queueCount] = item;

                ++m_queueCount;
            }
        }
Example #21
0
 internal bool BatchItemUpdate(Guid tenantId, int?itemTimeOut, BatchItem info)
 {
     try
     {
         var cmd = CreateProcedureCommand("dbo.BatchItem_Update");
         cmd.AppendGuid("@guidTenantId", tenantId);
         if (itemTimeOut.HasValue)
         {
             cmd.AppendInt("@intItemTimeOut", itemTimeOut.Value);
         }
         cmd.AppendGuid("@guidBatchItemId", info.BatchItemId);
         cmd.AppendTinyInt("@tiStatus", (byte)info.Status);
         cmd.AppendXLargeText("@strFailedReason", info.FailedReason);
         ExecuteCommand(cmd);
         return(true);
     }
     catch (SqlException e)
     {
         throw ReportAndTranslateException(e, "DataBatchItem::BatchItem_Update");
     }
 }
Example #22
0
        public async ValueTask CreateTask(T input)
        {
            var tcs       = new ManualResetValueTaskSource <int>();
            var batchItem = new BatchItem
            {
                Vts   = tcs,
                Input = input
            };
            var valueTask = _channel.Writer.WriteAsync(batchItem);

            if (!valueTask.IsCompleted)
            {
                await valueTask;
            }

            var finalValueTask = new ValueTask(batchItem.Vts, tcs.Version);

            if (!finalValueTask.IsCompleted)
            {
                await finalValueTask;
            }
        }
Example #23
0
        void StartRestore(BatchItem bitem, string binPath)
        {
            NvtSessionFactory sessionFactory = new NvtSessionFactory(LoadCurrentAccount());

            IdentitySubscriptions.Add(sessionFactory.CreateSession(bitem.Device.Uris)
                                      .ObserveOnCurrentDispatcher()
                                      .Subscribe(isession => {
                OdmSession odmsession = new OdmSession(isession);
                var async             = odmsession.RestoreSystem(binPath);

                var taskFact       = BackgroundTask.CreateForAsync(async.ObserveOnCurrentDispatcher(), bitem.Device);
                var backgroundTask = taskFact(
                    result => CompleteWith(() => {
                }),
                    error => CompleteWith(() => {
                    activityContext.Error(error);
                })
                    );
                BackgroundTaskManager.tasks.Add(backgroundTask);
            }, err => {
                dbg.Error(err);
            }));
        }
        private void TryToCreateSalesInvoiceWithIncorrectTotalInBatch()
        {
            Tracer.WriteLine("Try to create Sales Invoice with incorrect total in batch...");

            // Prepare batch items.
            SalesInvoiceGenerationParameters parameters = GetParametersForSingleSalesInvoiceCreation();
            BatchItem<SalesInvoiceCreditNoteDto>[] batchSalesInvoices = new BatchItem<SalesInvoiceCreditNoteDto>[2];
            for (int i = 0; i < batchSalesInvoices.Length; i++)
            {
                batchSalesInvoices[i] = new BatchItem<SalesInvoiceCreditNoteDto>
                {
                    item = SampleDtoGenerator.GenerateSalesInvoice(parameters),
                    opCode = BatchOperationCodes.Create
                };
            }
            batchSalesInvoices[batchSalesInvoices.Length - 1].item.total = 123;

            // Execute batch operation.
            BatchItemProcessResult<SalesInvoiceCreditNoteDto>[] batchResult = ApiClientProvider.Default.SalesInvoices.ProcessBatch(batchSalesInvoices);

            // Display batch results.
            PrintBatchResult(batchResult, "Sales Invoice");
        }
        private void TryToCreateCashReceiptWithIncorrectTotalInBatch()
        {
            Tracer.WriteLine("Try to create Cash Receipt with incorrect total in batch...");

            // Prepare batch items.
            CashReceiptGenerationParameters parameters = GetParametersForSingleCashReceiptCreation(false);
            BatchItem<CashReceiptDto>[] batchCashReceipts = new BatchItem<CashReceiptDto>[2];
            for (int i = 0; i < batchCashReceipts.Length; i++)
            {
                batchCashReceipts[i] = new BatchItem<CashReceiptDto>
                {
                    item = SampleDtoGenerator.GenerateCashReceipt(parameters),
                    opCode = BatchOperationCodes.Create
                };
            }
            batchCashReceipts[batchCashReceipts.Length - 1].item.total = 123;

            // Execute batch operation.
            BatchItemProcessResult<CashReceiptDto>[] batchResult = ApiClientProvider.Default.CashReceipts.ProcessBatch(batchCashReceipts);

            // Display batch results.
            PrintBatchResult(batchResult, "Cash Receipt");
        }
        private MailMessage GetMailMessage(Guid tenantId, BatchItem batchItem, string toEmail, string subject, string message, string defaultSenderEmail, string defaultSenderDisplayName = null, bool useHtml = true)
        {
            MailAddress sender;

            if (string.IsNullOrEmpty(defaultSenderEmail))
            {
                throw new ArgumentException("No sender mail address was provided");
            }
            else
            {
                sender = !string.IsNullOrEmpty(defaultSenderDisplayName) ?
                         new MailAddress(defaultSenderEmail, defaultSenderDisplayName) : new MailAddress(defaultSenderEmail);
            }

            MailMessage mail = new MailMessage()
            {
                From       = sender,
                Subject    = subject,
                Body       = message,
                IsBodyHtml = useHtml
            };

            //get batch content
            var batchContent = _managerBatchItem.GetBatchContents(tenantId, batchItem.BatchItemId);

            if (batchContent.Count > 0)
            {
                byte[]       attachment   = Convert.FromBase64String(batchContent[0].Content);
                MemoryStream memoryStream = new MemoryStream(attachment);
                mail.Attachments.Add(new Attachment(memoryStream, "UserExport.xlsx", MediaTypeNames.Application.Pdf));
            }



            mail.To.Add(toEmail);
            return(mail);
        }
Example #27
0
        private static BatchItem ReadInfo(SqlDataReader reader)
        {
            var info = new BatchItem
            {
                BatchItemId  = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0),
                BatchTypeId  = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1),
                Name         = reader.IsDBNull(2) ? string.Empty : reader.GetString(2),
                Priority     = reader.IsDBNull(3) ? 0 : reader.GetByte(3),
                RetryCount   = reader.IsDBNull(4) ? 0 : reader.GetInt16(4),
                NextRunTime  = reader.IsDBNull(5) ? DateTime.UtcNow : reader.GetDateTime(5),
                EntityId     = reader.IsDBNull(6) ? string.Empty : reader.GetString(6),
                ReferenceId  = reader.IsDBNull(7) ? Guid.Empty : reader.GetGuid(7),
                Status       = reader.IsDBNull(8) ? EmailEnum.ReadyToSend : (EmailEnum)reader.GetByte(8),
                FailedReason = reader.IsDBNull(9) ? string.Empty : reader.GetString(9),
                AuditDetails = new Entities.Common.AuditDetail {
                    CreatedBy    = reader.IsDBNull(10) ? Guid.Empty : reader.GetGuid(10),
                    CreationDate = reader.IsDBNull(11) ? DateTime.UtcNow : reader.GetDateTime(11),
                },
                StartTime = reader.IsDBNull(12) ? DateTime.UtcNow : reader.GetDateTime(12),
                EndTime   = reader.IsDBNull(13) ? DateTime.UtcNow : reader.GetDateTime(13)
            };

            return(info);
        }
 bool IAdminBatchItem.BatchItemUpdateStatus(Guid tenantId, BatchItem info)
 {
     return(_data.BatchItemUpdateStatus(tenantId, info));
 }
Example #29
0
        private void ProcessBatch()
        {
            //Initialize - Get Video Frame Counts
            Parallel.ForEach(Items, item =>
            {
                item.TotalFrames = new VideoInfo(item.File).TotalFrames;
            });

            Dispatcher.Invoke(() =>
            {
                lblCountProgress.Content   = "0/" + Items.Count;
                lblPercentProgress.Content = "0%";
                lblTime.Content            = "N/A";
            });

            dontStop = true;
            var       working           = false;
            var       reachedEndOfVideo = false;
            BatchItem currentItem       = null;

            WindowManager.ProcessorWindow.Controller.Pipeline.OnReachedEndOfVideo += () => reachedEndOfVideo = true;

            //While there is work to do
            while (dontStop && (working || Items.Any(i => i.Status == BatchItemStatus.NotStarted)))
            {
                if (!working)
                {
                    currentItem = Items.First(i => i.Status == BatchItemStatus.NotStarted);

                    WindowManager.ProcessorWindow.LoadParamsFromJSON(currentItem.ParamsText);

                    reachedEndOfVideo = false;

                    currentItem.TimeStarted = DateTime.Now;
                    currentItem.Status      = BatchItemStatus.Working;

                    Dispatcher.Invoke(() =>
                    {
                        WindowManager.ShowProcessorWindow(currentItem.File, oneFrame: false);

                        dataGrid.DataContext = null;
                        dataGrid.DataContext = Items;
                    });

                    working = true;
                }
                else //working
                {
                    //Check if finished
                    if (reachedEndOfVideo)
                    {
                        currentItem.Status = BatchItemStatus.Finished;
                        WindowManager.ProcessorWindow.SaveCSV((object)currentItem.File);

                        var timeTaken = DateTime.Now - currentItem.TimeStarted;
                        var fps       = currentItem.TotalFrames / timeTaken.TotalSeconds;

                        var framesRemaining = Items
                                              .Where(i => i.Status == BatchItemStatus.NotStarted)
                                              .Sum(i => i.TotalFrames);

                        var timeRemaining = TimeSpan.FromSeconds(framesRemaining / fps);

                        var itemsRemaining = Items
                                             .Count(i => i.Status == BatchItemStatus.NotStarted);

                        var itemsFinished   = (Items.Count - itemsRemaining);
                        var percentFinished = (int)Math.Round(1.0 * itemsFinished / Items.Count * 100, 0);

                        Dispatcher.Invoke(() =>
                        {
                            lblTime.Content            = timeRemaining.ToString(@"hh\ \h\ mm\ \m\ ss\ \s");
                            lblCountProgress.Content   = itemsFinished + "/" + Items.Count;
                            lblPercentProgress.Content = percentFinished + "%";
                            Show();

                            dataGrid.DataContext = null;
                            dataGrid.DataContext = Items;
                        });


                        working = false;
                    }

                    Thread.Sleep(100);
                }
            }

            WindowManager.HideProcessorWindow();
            Dispatcher.Invoke(ExpandWindow);

            if (dontStop)
            {
                MessageBox.Show("The batch is complete");
            }
            else
            {
                currentItem.Status = BatchItemStatus.NotStarted;
            }

            Dispatcher.Invoke(new Action(() =>
            {
                dataGrid.ItemsSource = null;
                dataGrid.ItemsSource = Items;
            }));
        }
Example #30
0
 static int CompareDepth(BatchItem item1, BatchItem item2)
 {
     return item2.LayerDepth.CompareTo(item1.LayerDepth);
 }
 bool IManagerBatchItem.BatchItemUpdate(Guid tenantId, int?itemTimeOut, BatchItem info)
 {
     return(_admin.BatchItemUpdate(tenantId, itemTimeOut, info));
 }
 bool IManagerBatchItem.BatchItemUpdateStatus(Guid tenantId, BatchItem info)
 {
     return(_admin.BatchItemUpdateStatus(tenantId, info));
 }
Example #33
0
 private BatchItem GetFreeBatchItem()
 {
     BatchItem item;
     if (_freeBatchItemQueue.Count > 0)
         item = _freeBatchItemQueue.Dequeue();
     else
         item = new BatchItem();
     _batchItemList.Add(item);
     return item;
 }
Example #34
0
 private bool TryPush(Texture tex, Material material, BeginMode mode)
 {
     if (last.texture != tex || last.mode != mode || last.material != material)
     {
         last = new BatchItem() { texture = tex, mode = mode, startIndex = vbuffer.IndexOffset, material = material };
         dipQueue.Enqueue(last);
         return true;
     }
     return false;
 }
 public void Init()
 {
     instance = new BatchItem();
 }
Example #36
0
        public void End()
        {
            if (!began) throw new Exception("Call begin first");

            if (current == null)
            {
                current = defaultMaterial;
            }

            if (dipQueue.Count != 0)
            {

                vbuffer.Bind();
                vbuffer.UpdateVertexBuffer();
                vbuffer.UpdateIndexBuffer();

                do
                {
                    var b = dipQueue.Dequeue();
                    int count = (dipQueue.Count > 0 ? dipQueue.Peek().startIndex : vbuffer.IndexOffset) - b.startIndex;

                    Material material = b.material;
                    if (material == null)
                    {
                        material = defaultMaterial;
                    }
                    if (current != material)
                    {
                        current = material;
                        ResetShader(current.Shader);
                    }

                    Matrix4 m = trans * proj;
                    current.SetParameter("WPV", m);
                    current.SetShaderUniforms();

                    //GL.BindTexture(TextureTarget.Texture2D, b.texture);
                    b.texture.Bind(0);
                    FlushBuffer(b.mode, b.startIndex, count);
                    elementsCounter += count;
                } while (dipQueue.Count > 0);
                last = new SpriteBatch.BatchItem() { texture = null, startIndex = -1, mode = BeginMode.Triangles };
            }
            began = false;
        }
 bool IAdminBatchItem.BatchItemUpdate(Guid tenantId, int?itemTimeOut, BatchItem info)
 {
     return(_data.BatchItemUpdate(tenantId, itemTimeOut, info));
 }