コード例 #1
0
        private void OnEventModified(DataServiceManagerTask task)
        {
            var evt = task.Events.FirstOrDefault();

            if (evt != null)
            {
                if (evt.ADCEvent.ID != String.Empty)
                {
                    if (_useASDB)
                    {
                        Expression <Func <ASDB, Boolean> > exp = info => info.Identifier == evt.ADCEvent.ID;
                        var result = Execute(exp).ToList();
                        evt.Content = GetContentFromDBResultAsdb(result, evt);
                    }
                    else
                    {
                        Expression <Func <MediaInfo, Boolean> > exp = info => info.Identifier == evt.ADCEvent.ID;
                        var result = Execute(exp).ToList();
                        evt.Content = GetContentFromDBResultAdc(result, evt);
                    }

                    if (DataBaseFieldsRetrieved != null)
                    {
                        DataBaseFieldsRetrieved(this,
                                                new EventsDBFieldsEventArgs(task.Server, task.List,
                                                                            task.Events.Select(
                                                                                info =>
                                                                                new EventsDatabaseFields(
                                                                                    info.ADCEventId,
                                                                                    info.Content))));
                    }
                }
            }
        }
コード例 #2
0
        private void OnEventsAdded(DataServiceManagerTask task)
        {
            var count = 0;
            var ids   = new List <String>();

            var resultAdc  = new List <MediaInfo>();
            var resultAsdb = new List <ASDB>();

            foreach (var ev in task.Events)
            {
                if (ev.ADCEvent.ID != String.Empty)
                {
                    if (!ids.Contains(ev.ADCEvent.ID))
                    {
                        ids.Add(ev.ADCEvent.ID);
                        count++;
                    }
                }

                if (count == 100)
                {
                    if (_useASDB)
                    {
                        resultAsdb.AddRange(Execute(GetSearchSimpleExpressionASDB(ids)).ToList());
                    }
                    else
                    {
                        resultAdc.AddRange(Execute(GetSearchSimpleExpressionADC(ids)).ToList());
                    }

                    ids.Clear();
                    count = 0;
                }

                if (_stopBackground)
                {
                    return;
                }
            }

            if (_stopBackground)
            {
                return;
            }

            if (count > 0)
            {
                if (_useASDB)
                {
                    resultAsdb.AddRange(Execute(GetSearchSimpleExpressionASDB(ids)).ToList());
                }
                else
                {
                    resultAdc.AddRange(Execute(GetSearchSimpleExpressionADC(ids)).ToList());
                }

                ids.Clear();
            }

            // Set database fields (e.g. content)
            var fields = new List <EventsDatabaseFields>();

            foreach (var ev in task.Events)
            {
                if (ev.ADCEvent.ID != String.Empty)
                {
                    ev.Content = _useASDB
                                     ? GetContentFromDBResultAsdb(resultAsdb, ev)
                                     : GetContentFromDBResultAdc(resultAdc, ev);
                    fields.Add(new EventsDatabaseFields(ev.ADCEventId, ev.Content));
                }
            }

            if (DataBaseFieldsRetrieved != null)
            {
                DataBaseFieldsRetrieved(this,
                                        new EventsDBFieldsEventArgs(task.Server, task.List, fields));
            }
        }