public Derived2EncoderBase(IEncoder <TBase1, TRoot1> base1Encoder, IEncoder <TBase2, TRoot2> base2Encoder, string derivationTypeName, Guid guidNamespace)
        {
            Base1Encoder = base1Encoder;
            Base2Encoder = base2Encoder;
            var name = $"{derivationTypeName}<{Base1Encoder.Name}, {Base2Encoder.Name}>";

            Guid = GuidUtil.Create(guidNamespace, name);
            Name = name;
        }
示例#2
0
        public Derived1EncoderBase(IEncoder <TBase, TRoot> baseEncoder, IEncoder <TRoot, TRoot> rootEncoder, string derivationTypeName, Guid guidNamespace)
        {
            BaseEncoder = baseEncoder;
            RootEncoder = rootEncoder;
            var name = $"{derivationTypeName}<{BaseEncoder.Name}>";

            Guid = GuidUtil.Create(guidNamespace, name);
            Name = name;
        }
        private void SearchInternal(Guid sessionId, DateTime from, DateTime to, IEnumerable <Item> items,
                                    bool ascendingSortOrder, CancellationToken cancellationToken)
        {
            // This implementation is for demo purposes only: creates dummy search result per camera and selected accessory type.
            // Respecting the provided sort order(i.e.delivering results in that order) can help reduce "flickering results" in the results
            // list in Smart Client. Since this sample is based on random trigger times, respecting the sort order does not make much sense.
            // If however you retrieve results from a database or similar, it is very much encouraged to respect the provided sort order.

            var totalSpan          = (to - from).TotalMilliseconds;
            var rnd                = new Random(37);
            var accessoryTypeValue = SearchCriteria.GetFilterValues(AccessoryTypeFilter).OfType <SelectionFilterValue>().FirstOrDefault();

            if (accessoryTypeValue == null)
            {
                return;
            }

            foreach (var selectedAccessoryTypeId in accessoryTypeValue.SelectedIds)
            {
                const string title = "A person with an accessory found!";
                foreach (Item camera in items)
                {
                    var triggerTime = totalSpan * rnd.NextDouble();
                    var endTime     = from.AddMilliseconds(triggerTime + totalSpan / 5);
                    var id          = GuidUtil.Create(SCPeopleWithAccessoriesSearchAgentPlugin.PluginId,
                                                      title,
                                                      camera.FQID.ObjectId.ToString(),
                                                      from.AddMilliseconds(triggerTime).Ticks.ToString(CultureInfo.InvariantCulture),
                                                      endTime.Ticks.ToString(CultureInfo.InvariantCulture));
                    var result = new SCPeopleWithAccessoriesSearchResultData(id)
                    {
                        Title        = title,
                        Item         = camera,
                        RelatedItems = null,
                        BeginTime    = from.AddMilliseconds(triggerTime - totalSpan / 10),
                        TriggerTime  = from.AddMilliseconds(triggerTime),
                        EndTime      = endTime,
                        Accessory    = AccessoryTypeFilter.AccessoryTypes[selectedAccessoryTypeId]
                    };
                    FireSearchResultsReadyEvent(sessionId, new[] { result });
                }
            }
        }
        private void SearchInternal(Guid sessionId, DateTime from, DateTime to, IEnumerable <Item> items,
                                    bool ascendingSortOrder, CancellationToken cancellationToken)
        {
            // This implementation is for demo purposes only: creates dummy search result per camera.
            // Respecting the provided sort order(i.e.delivering results in that order) can help reduce "flickering results" in the results
            // list in Smart Client. Since this sample is based on random trigger times, respecting the sort order does not make much sense.
            // If however you retrieve results from a database or similar, it is very much encouraged to respect the provided sort order.

            var totalSpan     = (to - from).TotalMilliseconds;
            var ordinal       = 0;
            var speciesValue  = (StringFilterValue)SearchCriteria.GetFilterValues(SpeciesFilter).FirstOrDefault();
            var activityValue = (BoolFilterValue)SearchCriteria.GetFilterValues(ActivityFilter).FirstOrDefault();
            var rnd           = new Random(37);

            foreach (Item camera in items)
            {
                var          triggerTime = totalSpan * rnd.NextDouble();
                const string title       = "Animal found!";
                var          endTime     = from.AddMilliseconds(triggerTime + totalSpan / 5);
                var          id          = GuidUtil.Create(SCAnimalsSearchAgentPlugin.PluginId,
                                                           title,
                                                           camera.FQID.ObjectId.ToString(),
                                                           from.AddMilliseconds(triggerTime).Ticks.ToString(CultureInfo.InvariantCulture),
                                                           endTime.Ticks.ToString(CultureInfo.InvariantCulture));
                var result = new AnimalsSearchResultData(id)
                {
                    Title        = title,
                    Item         = camera,
                    RelatedItems = null,
                    BeginTime    = from.AddMilliseconds(triggerTime - totalSpan / 10),
                    TriggerTime  = from.AddMilliseconds(triggerTime),
                    EndTime      = endTime,
                    WarningText  = activityValue != null && activityValue.Value && ordinal == 1 ? $"Animal is eating" : "",
                    Species      = speciesValue != null ? speciesValue.Text : PickRandomSpecies(rnd),
                    Ordinal      = ordinal++,
                };
                FireSearchResultsReadyEvent(sessionId, new[] { result });
            }
        }
示例#5
0
 public StringEncoder(Encoding encoding)
 {
     Encoding = encoding;
     Name     = $"String {Encoding.WebName}";
     Guid     = GuidUtil.Create(GuidNamespace, Encoding.WebName);
 }
示例#6
0
        public static ID GenerateItemId(Item accountItem, MediaServiceEntityData mediaData)
        {
            string key = string.Format("MediaFramework_{0}_{1}", accountItem.TemplateID, mediaData.EntityId);

            return(new ID(GuidUtil.Create(GuidUtil.UrlNamespace, key)));
        }