Ejemplo n.º 1
0
        public VersionCompareViewModel Compare(ApiCall call)
        {
            var sitedb = call.WebSite.SiteDb();

            long id1 = call.GetIntValue("id1");
            long id2 = call.GetIntValue("id2");

            if (id1 == 0 && id2 == 0)
            {
                return(null);
            }
            if (id1 > -1 && id2 > -1)
            {
                if (id1 > id2)
                {
                    long id3 = id1;
                    id1 = id2;
                    id2 = id3;
                }
            }

            LogEntry prelog = sitedb.Log.Get(id1);

            if (prelog != null)
            {
                if (prelog.IsTable)
                {
                    return(GetTableCompareModel(call, sitedb, id1, id2));
                }
                else
                {
                    return(GetStoreCompareModel(call, sitedb, id1, id2));
                }
            }

            return(new VersionCompareViewModel());
        }
Ejemplo n.º 2
0
        public PagedListViewModel <Data.Logging.SqlLog> List(ApiCall apiCall)
        {
            var pageIndex = apiCall.GetIntValue("pageIndex");

            var list = SqlLogService.QueryByWeek(
                apiCall.GetValue("week"),
                apiCall.GetValue("keyword"),
                apiCall.GetValue("type"),
                apiCall.WebSite.Id,
                pageIndex, PageSize, out var total);

            return(new PagedListViewModel <Data.Logging.SqlLog>
            {
                List = list,
                PageNr = pageIndex,
                PageSize = PageSize,
                TotalCount = total,
                TotalPages = (total / PageSize) + (total % PageSize > 0 ? 1 : 0)
            });
        }
Ejemplo n.º 3
0
        public List <ItemVersionViewModel> Versions(ApiCall call)
        {
            Guid KeyHash       = call.GetGuidValue("KeyHash");
            int  StoreNameHash = call.GetIntValue("StoreNameHash");

            if (KeyHash == default(Guid) || StoreNameHash == 0)
            {
                return(null);
            }
            var logs = call.WebSite.SiteDb().Log.Store.Where(o => o.KeyHash == KeyHash && o.StoreNameHash == StoreNameHash).SelectAll();

            List <ItemVersionViewModel> list = new List <ItemVersionViewModel>();

            foreach (var item in logs.OrderByDescending(o => o.Id))
            {
                list.Add(new ItemVersionViewModel()
                {
                    LastModified = item.UpdateTime, Id = item.Id, UserName = Data.GlobalDb.Users.GetUserName(item.UserId)
                });
            }

            return(list);
        }
Ejemplo n.º 4
0
        public VersionCompareViewModel Compare(ApiCall call)
        {
            var sitedb = call.WebSite.SiteDb();

            long id1 = call.GetIntValue("id1");
            long id2 = call.GetIntValue("id2");

            if (id1 == 0 && id2 == 0)
            {
                return(null);
            }
            if (id1 > -1 && id2 > -1)
            {
                if (id1 > id2)
                {
                    long id3 = id1;
                    id1 = id2;
                    id2 = id3;
                }
            }
            VersionCompareViewModel model = new VersionCompareViewModel()
            {
                Id1 = id1, Id2 = id2
            };

            LogEntry prelog = sitedb.Log.Get(id1);

            if (prelog != null)
            {
                var      repo = sitedb.GetRepository(prelog.StoreName);
                LogEntry nextlog;
                if (id2 == -1)
                {
                    nextlog   = sitedb.Log.Store.Where(o => o.KeyHash == prelog.KeyHash && o.StoreNameHash == prelog.StoreNameHash).OrderByDescending().FirstOrDefault();
                    model.Id2 = nextlog.Id;
                }
                else
                {
                    nextlog = sitedb.Log.Get(id2);
                }

                ISiteObject itemone = repo.GetByLog(prelog);
                ISiteObject itemtwo = null;
                if (nextlog.EditType != EditType.Delete)
                {
                    itemtwo = repo.GetByLog(nextlog);
                }

                model.Title1 = itemone.Name;
                model.Title2 = itemtwo != null ? itemtwo.Name : string.Empty;
                if (itemone is Image)
                {
                    string baseurl = call.WebSite.BaseUrl();

                    string url1 = (Sites.Systems.Routes.SystemRouteTemplate.Replace("{objecttype}", repo.ModelType.Name).Replace("{nameorid}", prelog.Id.ToString()));
                    string url2 = Sites.Systems.Routes.SystemRouteTemplate.Replace("{objecttype}", repo.ModelType.Name).Replace("{nameorid}", nextlog.Id.ToString());

                    model.DataType = VersionDataType.Image;
                    model.Source1  = Kooboo.Lib.Helper.UrlHelper.Combine(baseurl, url1);

                    model.Source2 = Kooboo.Lib.Helper.UrlHelper.Combine(baseurl, url2);
                }
                else
                {
                    model.Source1  = Sites.Service.ObjectService.GetSummaryText(itemone);
                    model.Source2  = Sites.Service.ObjectService.GetSummaryText(itemtwo);
                    model.DataType = VersionDataType.String;
                }
            }
            return(model);
        }