Exemple #1
0
        public List <PushItemViewModel> PushItems(ApiCall call)
        {
            List <PushItemViewModel> result = new List <PushItemViewModel>();

            var sitedb = call.WebSite.SiteDb();

            foreach (var item in sitedb.Synchronization.GetPushItems(call.ObjectId))
            {
                var siteojbect = ObjectService.GetSiteObject(sitedb, item);
                if (siteojbect == null)
                {
                    continue;
                }
                ChangeType changetype = ChangeType.Add;
                if (item.EditType == IndexedDB.EditType.Delete)
                {
                    changetype = ChangeType.Delete;
                }
                else if (item.EditType == IndexedDB.EditType.Update)
                {
                    changetype = ChangeType.Update;
                }

                PushItemViewModel viewmodel = new PushItemViewModel
                {
                    Id           = item.Id,
                    ObjectType   = ConstTypeService.GetModelType(siteojbect.ConstType).Name,
                    Name         = LogService.GetLogDisplayName(sitedb, item),
                    KoobooType   = siteojbect.ConstType,
                    ChangeType   = changetype,
                    LastModified = siteojbect.LastModified,
                    LogId        = item.Id
                };

                viewmodel.Size = CalculateUtility.GetSizeString(ObjectService.GetSize(siteojbect));

                if (siteojbect.ConstType == ConstObjectType.Image)
                {
                    viewmodel.Thumbnail = ThumbnailService.GenerateThumbnailUrl(siteojbect.Id, 50, 50, call.WebSite.Id);
                }

                result.Add(viewmodel);
            }

            return(result);
        }
Exemple #2
0
        public List <PushItemViewModel> PushItems(ApiCall call)
        {
            List <PushItemViewModel> result = new List <PushItemViewModel>();

            var sitedb = call.WebSite.SiteDb();
            var kdb    = Kooboo.Data.DB.GetKDatabase(call.Context.WebSite);

            foreach (var item in sitedb.Synchronization.GetPushItems(call.ObjectId))
            {
                ChangeType changetype = ChangeType.Add;
                if (item.EditType == IndexedDB.EditType.Delete)
                {
                    changetype = ChangeType.Delete;
                }
                else if (item.EditType == IndexedDB.EditType.Update)
                {
                    changetype = ChangeType.Update;
                }

                if (item.IsTable)
                {
                    var table = Data.DB.GetTable(kdb, item.TableName);
                    if (table != null)
                    {
                        var logdata = table.GetLogData(item);
                        PushItemViewModel viewmodel = new PushItemViewModel
                        {
                            Id         = item.Id,
                            ObjectType = Kooboo.Data.Language.Hardcoded.GetValue("Table", call.Context),
                            Name       = LogService.GetTableDisplayName(sitedb, item, call.Context),
                            // KoobooType = siteojbect.ConstType,
                            ChangeType   = changetype,
                            LastModified = item.UpdateTime,
                            LogId        = item.Id
                        };
                        result.Add(viewmodel);
                    }
                }
                else
                {
                    var siteojbect = ObjectService.GetSiteObject(sitedb, item);
                    if (siteojbect == null)
                    {
                        continue;
                    }

                    PushItemViewModel viewmodel = new PushItemViewModel
                    {
                        Id           = item.Id,
                        ObjectType   = ConstTypeService.GetModelType(siteojbect.ConstType).Name,
                        Name         = LogService.GetLogDisplayName(sitedb, item),
                        KoobooType   = siteojbect.ConstType,
                        ChangeType   = changetype,
                        LastModified = siteojbect.LastModified,
                        LogId        = item.Id
                    };

                    viewmodel.Size = CalculateUtility.GetSizeString(ObjectService.GetSize(siteojbect));

                    if (siteojbect.ConstType == ConstObjectType.Image)
                    {
                        viewmodel.Thumbnail = ThumbnailService.GenerateThumbnailUrl(siteojbect.Id, 50, 50, call.WebSite.Id);
                    }

                    result.Add(viewmodel);
                }
            }

            return(result.OrderBy(o => o.LogId).ToList());
        }