예제 #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());
        }
예제 #2
0
파일: SqlLog.cs 프로젝트: weedkiller/Kooboo
        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)
            });
        }
예제 #3
0
파일: SiteLog.cs 프로젝트: xhute/Kooboo
        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);
        }
예제 #4
0
파일: SiteLog.cs 프로젝트: xhute/Kooboo
        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);
        }