Example #1
0
        private static FieldsBuilder ParseProjection(string projection)
        {
            var fields = new FieldsBuilder();

            if (String.IsNullOrEmpty(projection))
            {
                return(fields);
            }

            var projectionDocument = BsonSerializer.Deserialize <BsonDocument>(projection);

            foreach (var element in projectionDocument)
            {
                var value = element.Value;

                if (value.IsBoolean && value.AsBoolean || value.IsInt32 && value.AsInt32 != 0)
                {
                    fields.Include(element.Name);
                }
                else if (value.IsBoolean && !value.AsBoolean || value.IsInt32 && value.AsInt32 == 0)
                {
                    fields.Exclude(element.Name);
                }
                else
                {
                    throw Errors.InvalidProjectionFormat();
                }
            }

            return(fields);
        }
Example #2
0
        public static IMongoFields ObjectsToFields(IList <object> values)
        {
            if (values == null)
            {
                return(null);
            }

            IMongoFields fields;

            if (values.Count == 1 && (fields = values[0] as IMongoFields) != null)
            {
                return(fields);
            }

            var builder = new FieldsBuilder();

            foreach (var it in values)
            {
                var name = it as string;
                if (name != null)
                {
                    builder.Include(name);
                    continue;
                }
                throw new ArgumentException("Property: Expected either one IMongoFields or one or more String.");
            }
            return(builder);
        }
        private async void OnLoaded(object sender, RoutedEventArgs e)
        {
            await LoadEventOfTheDay();

            var request = new EventListRequest();

            request.Lang   = "ru";
            request.Expand = string.Format("{0},{1}", EventListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.TITLE)
                             .WithField(EventListRequest.FieldNames.SITE_URL)
                             .WithField(EventListRequest.FieldNames.SLUG).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            var res = await request.ExecuteAsync();

            foreach (var result in res.Results)
            {
                Items.Add(new EventViewModel(result.Images.First().Thumbnail.Small, result.Title, result.Place));
            }
        }
Example #4
0
        protected override void TransformComponent(Dynamic.Component component)
        {
            TCM.Component tcmComponent = this.GetTcmComponent();
            TCM.Folder    tcmFolder    = (TCM.Folder)tcmComponent.OrganizationalItem;

            String mergeActionStr = Package.GetValue("MergeAction");

            Dynamic.MergeAction mergeAction;
            if (string.IsNullOrEmpty(mergeActionStr))
            {
                mergeAction = defaultMergeAction;
            }
            else
            {
                mergeAction = (Dynamic.MergeAction)Enum.Parse(typeof(Dynamic.MergeAction), mergeActionStr);
            }

            while (tcmFolder.OrganizationalItem != null)
            {
                if (tcmFolder.MetadataSchema != null)
                {
                    TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmFolder.Metadata, tcmFolder.MetadataSchema);
                    // change
                    FieldsBuilder.AddFields(component.MetadataFields, tcmFields, 1, false, false, mergeAction, Manager);
                }
                tcmFolder = (TCM.Folder)tcmFolder.OrganizationalItem;
            }
        }
        public async Task should_get_newslist()
        {
            var fieldsBuilder = new FieldsBuilder();
            var request       = new NewsListRequest();

            request.Lang   = "ru";
            request.Expand = NewsListRequest.ExpandNames.IMAGES + "," + NewsListRequest.ExpandNames.PLACE;
            request.Fields = fieldsBuilder.WithField(NewsListRequest.FieldNames.TITLE)
                             .WithField(NewsListRequest.FieldNames.IMAGES)
                             .WithField(NewsListRequest.FieldNames.ID)
                             .WithField(NewsListRequest.FieldNames.SLUG)
                             .WithField(NewsListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(NewsListRequest.FieldNames.PLACE)
                             .Build();

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());

            var first = res.Results.First();

            Assert.IsNotNull(first.Id);
            Assert.IsNotNull(first.Place);
            Assert.IsNotNull(first.Images);
        }
Example #6
0
 void ParseFields(string key, object obj, FieldsBuilder f)
 {
     f = f == null ? new FieldsBuilder() : f;
     if (key.ToLower() == "$fields")
     {
         if (obj is FrameDLRObject)
         {
             var dobj = (FrameDLRObject)obj;
             foreach (var k in dobj.Keys)
             {
                 ParseFields(k, dobj.GetValue(k), f);
             }
         }
     }
     else
     {
         if (obj is FrameDLRObject)
         {
             var dobj = (FrameDLRObject)obj;
             foreach (var k in dobj.Keys)
             {
                 if (k.ToLower() == "$slice")
                 {
                     if (dobj.GetValue(k) is int)
                     {
                         f = f.Slice(key, IntStd.ParseStd(dobj.GetValue(k)).Value);
                     }
                 }
             }
         }
     }
 }
Example #7
0
        public async Task <IMovieListResponse> GetMovies(string next)
        {
            var request = new MovieListRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;
            request.Expand     = MovieListRequest.ExpandNames.POSTER;

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(MovieListRequest.FieldNames.ID)
                             .WithField(MovieListRequest.FieldNames.POSTER)
                             .WithField(MovieListRequest.FieldNames.IMAGES)
                             .WithField(MovieListRequest.FieldNames.AGE_RESTRICTION)
                             .WithField(MovieListRequest.FieldNames.YEAR)
                             .WithField(MovieListRequest.FieldNames.COUNTRY)
                             .WithField(MovieListRequest.FieldNames.RUNNING_TIME)
                             .WithField(MovieListRequest.FieldNames.TITLE).Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
        public async Task should_get_event_details()
        {
            var request = new EventListRequest();

            request.Lang = "ru";

            var fieldBuilder = new FieldsBuilder();

            request.Fields      = fieldBuilder.WithField(EventListRequest.FieldNames.ID).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            //then
            var res = await request.ExecuteAsync();

            var first = res.Results.First();

            var detailsRequest = new EventDetailsRequest();

            detailsRequest.EventId = first.Id;
            var actual = await detailsRequest.ExecuteAsync();

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Id, first.Id);
        }
        public async Task should_get_place_comments()
        {
            var request = new PlaceListRequest();

            request.Lang = "ru";

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);

            var first           = res.Results.First();
            var commentsRequest = new PlaceCommentsRequest();

            commentsRequest.PlaceId = first.Id;
            var fieldBuilder = new FieldsBuilder();

            commentsRequest.Fields = fieldBuilder.WithField(CommentFields.USER)
                                     .WithField(CommentFields.ID)
                                     .WithField(CommentFields.IS_DELETED)
                                     .WithField(CommentFields.DATE_POSTED)
                                     .WithField(CommentFields.REPLIES_COUNT)
                                     .WithField(CommentFields.REPLY_TO)
                                     .WithField(CommentFields.TEXT)
                                     .WithField(CommentFields.THREAD)
                                     .Build();

            var commentsResponse = await commentsRequest.ExecuteAsync();

            Assert.IsNotNull(commentsResponse);
        }
Example #10
0
        public IEnumerable <AggregatedValue> Find(DateTime startDate, DateTime endDate, Dictionary <string, List <string> > props)
        {
            MongoCollection <StoredCounter> items = MongoDb.GetCollection <StoredCounter>("countersData");
            IMongoQuery   q      = Query.And(Query.GTE("date", startDate), Query.LT("date", endDate));
            FieldsBuilder fields = new FieldsBuilder();

            //fields.Include("date", "data.Max", "data.Min", "data.Count", "data.Avg", "data.Sum");
            fields.Include("date", "data");


            foreach (KeyValuePair <string, List <string> > prop in props)
            {
                string fieldName = "props." + prop.Key;
                fields.Include(fieldName);
                if (prop.Value.Count == 0)
                {
                    q = Query.And(q, Query.Exists(fieldName));
                }
                else if (prop.Value.Count == 1)
                {
                    q = Query.And(q, Query.EQ(fieldName, prop.Value.First()));
                }
                else
                {
                    q = Query.And(q, Query.In(fieldName, prop.Value.Cast <BsonString>()));
                }
            }

            MongoCursor cursor = items.Find(q);

            cursor.SetFields(fields);
            cursor.SetSortOrder(SortBy.Ascending("date"));
            Stopwatch sw    = Stopwatch.StartNew();
            var       found = cursor.Cast <object>().ToList();

            sw.Stop();
            Console.WriteLine(found.Count + " entries fetched from db in " + sw.ElapsedMilliseconds + " ms");
            sw.Restart();
            var parsed = found.Cast <StoredCounter>().Select(ParseAggregatedValue).ToList();

            sw.Stop();
            Console.WriteLine(parsed.Count + " entries parsed in " + sw.ElapsedMilliseconds + " ms");
            sw.Restart();
            var result = parsed.Compact().ToList();

            sw.Stop();
            Console.WriteLine(found.Count + " entries compacted to " + result.Count + " in " + sw.ElapsedMilliseconds + " ms");
            return(result);
        }
Example #11
0
        public async Task should_get_something()
        {
            var request = new MovieListRequest();

            request.Lang = "ru";
            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(MovieListRequest.FieldNames.ID)
                             .WithField(MovieListRequest.FieldNames.SITE_URL)
                             .WithField(MovieListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(MovieListRequest.FieldNames.SLUG)
                             .WithField(MovieListRequest.FieldNames.TITLE)
                             .WithField(MovieListRequest.FieldNames.DESCRIPTION)
                             .WithField(MovieListRequest.FieldNames.BODY_TEXT)
                             .WithField(MovieListRequest.FieldNames.IS_EDITORS_CHOICE)
                             .WithField(MovieListRequest.FieldNames.FAVORITES_COUNT)
                             .WithField(MovieListRequest.FieldNames.GENRES)
                             .WithField(MovieListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(MovieListRequest.FieldNames.ORIGINAL_TITLE)
                             .WithField(MovieListRequest.FieldNames.LOCALE)
                             .WithField(MovieListRequest.FieldNames.COUNTRY)
                             .WithField(MovieListRequest.FieldNames.YEAR)
                             .WithField(MovieListRequest.FieldNames.LANGUAGE)
                             .WithField(MovieListRequest.FieldNames.RUNNING_TIME)
                             .WithField(MovieListRequest.FieldNames.BUDGET_CURRENCY)
                             //.WithField(MovieListRequest.FieldNames.BUDGET) Пока не работает ((
                             .WithField(MovieListRequest.FieldNames.MPAA_RATING)
                             .WithField(MovieListRequest.FieldNames.AGE_RESTRICTION)
                             .WithField(MovieListRequest.FieldNames.STARS)
                             .WithField(MovieListRequest.FieldNames.DIRECTOR)
                             .WithField(MovieListRequest.FieldNames.WRITER)
                             .WithField(MovieListRequest.FieldNames.AWARDS)
                             .WithField(MovieListRequest.FieldNames.TRAILER)
                             .WithField(MovieListRequest.FieldNames.IMAGES)
                             .WithField(MovieListRequest.FieldNames.POSTER)
                             .WithField(MovieListRequest.FieldNames.URL)
                             .WithField(MovieListRequest.FieldNames.IMDB_URL)
                             .WithField(MovieListRequest.FieldNames.IMDB_RATING).Build();

            request.Expand = MovieListRequest.ExpandNames.IMAGES + "," + MovieListRequest.ExpandNames.POSTER;

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());
        }
        public async Task should_get_events_with_fields_2()
        {
            var request = new EventListRequest();

            request.Lang   = "ru";
            request.Expand = string.Format("{0},{1},{2},{3},{4}",
                                           EventListRequest.ExpandNames.IMAGES,
                                           EventListRequest.ExpandNames.PLACE,
                                           EventListRequest.ExpandNames.LOCATION,
                                           EventListRequest.ExpandNames.DATES,
                                           EventListRequest.ExpandNames.PARTICIPANTS);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.COMMENTS_COUNT)
                             .WithField(EventListRequest.FieldNames.CATEGORIES)
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.DATES)
                             .WithField(EventListRequest.FieldNames.FAVORITES_COUNT)
                             .WithField(EventListRequest.FieldNames.AGE_RESTRICTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.IS_FREE)
                             .WithField(EventListRequest.FieldNames.BODY_TEXT)
                             .WithField(EventListRequest.FieldNames.LOCATION)
                             .WithField(EventListRequest.FieldNames.PARTICIPANTS)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.SHORT_TITLE)
                             .WithField(EventListRequest.FieldNames.SITE_URL)
                             .WithField(EventListRequest.FieldNames.SLUG).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = Location.Spb;

            var res = await request.ExecuteAsync();

            Assert.IsNotNull(res);
            Assert.IsTrue(res.Count > 0);
            Assert.IsNotNull(res.Next);
            Assert.IsTrue(res.Results.Any());

            var first = res.Results.First();

            Assert.IsNotNull(first.BodyText);
            Assert.IsNotNull(first.CommentsCount);
        }
        protected override void TransformComponent(Dynamic.Component component)
        {
            TCM.Component tcmComponent = this.GetTcmComponent();
            TCM.Folder    tcmFolder    = (TCM.Folder)tcmComponent.OrganizationalItem;

            while (tcmFolder.OrganizationalItem != null)
            {
                if (tcmFolder.MetadataSchema != null)
                {
                    TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmFolder.Metadata, tcmFolder.MetadataSchema);
                    FieldsBuilder.AddFields(component.MetadataFields, tcmFields, Manager);
                }
                tcmFolder = (TCM.Folder)tcmFolder.OrganizationalItem;
            }
        }
Example #14
0
        protected override void TransformPage(Dynamic.Page page)
        {
            GeneralUtils.TimedLog("start TransformPage with id " + page.Id);

            Page           tcmPage = this.GetTcmPage();
            StructureGroup tcmSG   = (StructureGroup)tcmPage.OrganizationalItem;

            String mergeActionStr = Package.GetValue("MergeAction");

            Dynamic.MergeAction mergeAction;
            if (!string.IsNullOrEmpty(mergeActionStr))
            {
                try
                {
                    mergeAction = (Dynamic.MergeAction)Enum.Parse(typeof(Dynamic.MergeAction), mergeActionStr);
                }
                catch
                {
                    GeneralUtils.TimedLog("unexpected merge action " + mergeActionStr + ", using default");
                    mergeAction = defaultMergeAction;
                }
            }
            else
            {
                GeneralUtils.TimedLog("no merge action specified, using default");
                mergeAction = defaultMergeAction;
            }
            GeneralUtils.TimedLog("using merge action " + mergeAction.ToString());

            while (tcmSG != null)
            {
                GeneralUtils.TimedLog("found structure group with id " + tcmSG.Id);

                if (tcmSG.MetadataSchema != null)
                {
                    TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmSG.Metadata, tcmSG.MetadataSchema);
                    GeneralUtils.TimedLog(string.Format("about to merge {0} fields on structure group with {1} fields on page ", tcmFields.Count, page.MetadataFields.Count));

                    // change
                    FieldsBuilder.AddFields(page.MetadataFields, tcmFields, LinkLevels, false, false, mergeAction, Manager);
                    GeneralUtils.TimedLog(string.Format("finished merging, we now have {0} fields on structure group and {1} fields on page ", tcmFields.Count, page.MetadataFields.Count));
                }
                tcmSG = tcmSG.OrganizationalItem as StructureGroup;
            }
        }
Example #15
0
        protected override void TransformPage(Dynamic.Page page)
        {
            GeneralUtils.TimedLog("start TransformPage with id " + page.Id);

            Page           tcmPage        = this.GetTcmPage();
            StructureGroup tcmSG          = (StructureGroup)tcmPage.OrganizationalItem;
            String         mergeActionStr = Package.GetValue("MergeAction");

            while (tcmSG != null)
            {
                if (tcmSG.MetadataSchema != null)
                {
                    TCM.Fields.ItemFields tcmFields = new TCM.Fields.ItemFields(tcmSG.Metadata, tcmSG.MetadataSchema);
                    FieldsBuilder.AddFields(page.MetadataFields, tcmFields, Manager);
                }
                tcmSG = tcmSG.OrganizationalItem as StructureGroup;
            }
            GeneralUtils.TimedLog("finished TransformPage");
        }
Example #16
0
        /// <summary>
        /// 执行DBExpress动作
        /// </summary>
        /// <param name="express"></param>
        /// <returns></returns>
        public object Excute(DBExpress express)
        {
            if (express is MongoExpress)
            {
                var            mexpress       = (MongoExpress)express;
                dynamic        dexpress       = mexpress.ToExpress();
                string         collectionname = ComFunc.nvl(dexpress.table);
                QueryDocument  q      = dexpress.query;
                UpdateDocument u      = dexpress.update;
                FieldsBuilder  f      = dexpress.fields;
                FrameDLRObject insert = dexpress.insert;

                if (server.State == MongoServerState.Disconnected)
                {
                    server.Reconnect();
                }
                var collection = database.GetCollection <FrameDLRObject>(collectionname);
                if (mexpress.CurrentAct == DBExpress.ActType.Update)
                {
                    collection.Update(q, u, UpdateFlags.Upsert);
                    return(true);
                }
                else if (mexpress.CurrentAct == DBExpress.ActType.Insert)
                {
                    collection.Insert(insert);
                    return(true);
                }
                else if (mexpress.CurrentAct == DBExpress.ActType.Delete)
                {
                    collection.Remove(q);
                    return(true);
                }
                else
                {
                    var cursor = collection.Find(q).SetFields(f);
                    return(cursor.ToList());
                }
            }
            else
            {
                return(false);
            }
        }
Example #17
0
        public async Task <IEventsOfTheDayResponse> GetEventOfTheDay(string next)
        {
            var request = new EventsOfTheDayRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventsOfTheDayRequest.FieldsNames.DATE)
                             .WithField(EventsOfTheDayRequest.FieldsNames.EVENT)
                             .WithField(EventsOfTheDayRequest.FieldsNames.LOCATION)
                             .Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
Example #18
0
        public async Task <ISelectionListResponse> GetSelections(string next)
        {
            var request = new SelectionListRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;
            request.Expand     = SelectionListRequest.ExpandNames.IMAGES;

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(SelectionListRequest.FieldNames.ID)
                             .WithField(SelectionListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(SelectionListRequest.FieldNames.TITLE).Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
Example #19
0
        void WhereExpress(FrameDLRObject obj, QueryDocument query, FieldsBuilder fields)
        {
            var rtn = FrameDLRObject.CreateInstance();

            foreach (var k in obj.Keys)
            {
                if (k.ToLower() != "$fields")
                {
                    var lq = WhereExpress(k, obj.GetValue(k));
                    foreach (var q in lq)
                    {
                        query.Add(q.ToBsonDocument());
                    }
                }
                else
                {
                    var f = new FieldsBuilder();
                    ParseFields(k, obj.GetValue(k), fields);
                }
            }
        }
Example #20
0
        public async Task <IEventListResponse> GetEvents(string next, FilterDefinition filterDefinition)
        {
            if (filterDefinition == null)
            {
                throw new ArgumentNullException(nameof(filterDefinition));
            }

            var request = new EventListRequest();

            request.Lang        = _culture;
            request.TextFormat  = TextFormatEnum.Plain;
            request.Next        = next;
            request.IsFree      = filterDefinition.IsFree;
            request.Categories  = filterDefinition.Categories;
            request.ActualSince = filterDefinition.ActualSince;
            request.ActualUntil = filterDefinition.ActualUntil;
            request.Expand      = string.Format("{0},{1}", EventListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(EventListRequest.FieldNames.DESCRIPTION)
                             .WithField(EventListRequest.FieldNames.ID)
                             .WithField(EventListRequest.FieldNames.IMAGES)
                             .WithField(EventListRequest.FieldNames.PLACE)
                             .WithField(EventListRequest.FieldNames.IS_FREE)
                             .WithField(EventListRequest.FieldNames.PRICE)
                             .WithField(EventListRequest.FieldNames.TITLE)
                             .WithField(EventListRequest.FieldNames.DATES)
                             .WithField(EventListRequest.FieldNames.CATEGORIES)
                             .WithField(EventListRequest.FieldNames.AGE_RESTRICTION).Build();
            request.ActualSince = DateTime.Today;
            request.Location    = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
Example #21
0
        public async Task should_get_movie_details()
        {
            var request = new MovieListRequest();

            request.Lang = "ru";

            var fieldBuilder = new FieldsBuilder();

            request.Fields   = fieldBuilder.WithField(MovieListRequest.FieldNames.ID).Build();
            request.Location = Location.Spb;

            //then
            var res = await request.ExecuteAsync();

            var first = res.Results.First();

            var detailsRequest = new MovieDetailsRequest();

            detailsRequest.MovieId = first.Id;
            var actual = await detailsRequest.ExecuteAsync();

            Assert.IsNotNull(actual);
            Assert.AreEqual(actual.Id, first.Id);
        }
Example #22
0
        public async Task <INewsListResponse> GetNews(string next)
        {
            var request = new NewsListRequest();

            request.Lang       = _culture;
            request.TextFormat = TextFormatEnum.Plain;
            request.Next       = next;
            request.Expand     = string.Format("{0},{1}", NewsListRequest.ExpandNames.IMAGES, EventListRequest.ExpandNames.PLACE);

            var fieldBuilder = new FieldsBuilder();

            request.Fields = fieldBuilder
                             .WithField(NewsListRequest.FieldNames.DESCRIPTION)
                             .WithField(NewsListRequest.FieldNames.ID)
                             .WithField(NewsListRequest.FieldNames.IMAGES)
                             .WithField(NewsListRequest.FieldNames.PLACE)
                             .WithField(NewsListRequest.FieldNames.PUBLICATION_DATE)
                             .WithField(NewsListRequest.FieldNames.TITLE).Build();
            request.Location = _location;

            var res = await request.ExecuteAsync();

            return(res);
        }
Example #23
0
        protected override FrameDLRObject ParseExpress(FrameDLRObject obj)
        {
            var            rtn            = FrameDLRObject.CreateInstance();
            var            query          = new QueryDocument(true);
            var            update         = new UpdateDocument(true);
            FrameDLRObject insert         = FrameDLRObject.CreateInstance(FrameDLRFlags.SensitiveCase);
            var            fields         = new FieldsBuilder();
            var            collectionname = "";

            foreach (var k in obj.Keys)
            {
                if (k.StartsWith("$"))
                {
                    if (k.ToLower() == "$where")
                    {
                        WhereExpress((FrameDLRObject)obj.GetValue(k), query, fields);
                    }
                    else if (k.ToLower() == "$table")
                    {
                        if (obj.GetValue(k) is string)
                        {
                            collectionname = ComFunc.nvl(obj.GetValue(k));
                        }
                    }
                }
                else
                {
                    var v = obj.GetValue(k);
                    if (this.CurrentAct == ActType.Query)
                    {
                        if (v is bool)
                        {
                            var bisinclude = (bool)v;
                            if (bisinclude)
                            {
                                fields.Include(k);
                            }
                            else
                            {
                                fields.Exclude(k);
                            }
                        }
                    }
                    else if (this.CurrentAct == ActType.Insert)
                    {
                        insert.SetValue(k, v);
                    }
                    else
                    {
                        if (!(v is FrameDLRObject))
                        {
                            update.Add(k, BsonValue.Create(v));
                        }
                    }
                }
            }
            rtn.query  = query;
            rtn.update = update;
            rtn.insert = insert;
            rtn.fields = fields;
            rtn.table  = collectionname;
            return(rtn);
        }
Example #24
0
 public FieldBuilder(ref FieldsBuilder fieldsBuilder, ref Main.Field field)
 {
     _fieldsBuilder = fieldsBuilder;
     _field         = field;
 }
 public FieldBuilder(ref FieldsBuilder fieldsBuilder, ref Main.Field field) {
     _fieldsBuilder = fieldsBuilder;
     _field = field;
 }