Exemplo n.º 1
0
        private static UserActivity ApplyCustomeActivityParams(FileEntry entry, string imgFileName, string actionText, int actionType, int businessValue, string containerId)
        {
            if (entry == null)
            {
                return(null);
            }

            string url;
            var    moduleId       = ProductEntryPoint.ID;
            var    additionalData = "";
            var    securityId     = "0";

            if (entry.RootFolderType == FolderType.BUNCH)
            {
                var title = Global.DaoFactory.GetFolderDao().GetFolder(entry.RootFolderId).Title;

                if (title.StartsWith("projects/project/"))
                {
                    moduleId       = ProjectModuleId;
                    additionalData = "File||";
                    containerId    = title.Replace("projects/project/", "");
                    securityId     = "File||" + containerId;
                }
                else if (title.StartsWith("crm/crm_common/"))
                {
                    moduleId   = CrmModuleId;
                    securityId = "6|" + entry.UniqID;
                }
            }

            if (entry is File)
            {
                url = FileUtility.ExtsWebPreviewed.Contains(FileUtility.GetFileExtension(entry.Title), StringComparer.CurrentCultureIgnoreCase)
                          ? CommonLinkUtility.GetFileWebViewerUrl(entry.ID)
                          : ((File)entry).ViewUrl;
            }
            else
            {
                url = PathProvider.GetFolderUrl((Folder)entry);
            }

            var ua = new UserActivity
            {
                Title        = entry.Title,
                ContentID    = entry.UniqID,
                URL          = url,
                ModuleID     = moduleId,
                ProductID    = moduleId,
                TenantID     = TenantProvider.CurrentTenantID,
                Date         = ASC.Core.Tenants.TenantUtil.DateTimeNow(),
                ImageOptions = new ImageOptions {
                    PartID = ProductEntryPoint.ID, ImageFileName = imgFileName
                },
                ActionText     = actionText,
                UserID         = SecurityContext.CurrentAccount.ID,
                ActionType     = actionType,
                BusinessValue  = businessValue,
                AdditionalData = additionalData,
                ContainerID    = containerId,
                SecurityId     = securityId
            };

            return(ua);
        }
Exemplo n.º 2
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            writer.Write("<link href=" + PathProvider.GetFileStaticRelativePath("common.css") + " type=\"text/css\" rel=\"stylesheet\" />");

            writer.Write("<script type=\"text/javascript\" language=\"javascript\" src=" + PathProvider.GetFileStaticRelativePath("common.js") + "></script>");

            foreach (var srGroup in Items.GetRange(0, (MaxCount < Items.Count) ? MaxCount : Items.Count))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, String.Format("document {0} clearFix", srGroup.Additional.ContainsKey("IsFolder") ? GetFolderCssClass(srGroup.Additional["IsFolder"]) : String.Empty));
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "icon");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "body");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.AddAttribute(HtmlTextWriterAttribute.Href, srGroup.URL);

                writer.AddAttribute(HtmlTextWriterAttribute.Title, srGroup.Name);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "linkHeaderMedium");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.Write(HtmlUtility.SearchTextHighlight(Text, srGroup.Name.HtmlEncode(), false));
                writer.RenderEndTag();

                writer.WriteBreak();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "textSmallDescribe");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                if (srGroup.Additional.ContainsKey("Author"))
                {
                    writer.Write("{0} {1}", Resources.FilesCommonResource.Author, srGroup.Additional["Author"]);
                }
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "separator");
                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write("|");
                writer.RenderEndTag();

                writer.Write("{0} {1}", Resources.FilesCommonResource.TitleUploaded, srGroup.Date);

                if (srGroup.Additional.ContainsKey("Size"))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "separator");
                    writer.RenderBeginTag(HtmlTextWriterTag.Span);
                    writer.Write("|");
                    writer.RenderEndTag();
                    writer.Write("{0} {1}", Resources.FilesCommonResource.Size, srGroup.Additional["Size"]);
                }
                writer.RenderEndTag();

                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "adv");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.Write(HtmlUtility.GetText(Search.FolderPathBuilder((List <Folder>)srGroup.Additional["Container"]), 80));
                writer.RenderEndTag();

                writer.RenderEndTag();
            }

            var str = @"
<script type='text/javascript'>
    jq(function() {
        jq('div.searchResults div.document').each(function() {
            var ftClass;
            if (jq(this).hasClass('thumb-folder')) {
                ftClass = ASC.Files.Utility.getFolderCssClass();
            } else {
                var title = jq(this).find('a.linkHeaderMedium').text().trim();
                ftClass = ASC.Files.Utility.getCssClassByFileTitle(title);
            }
            jq(this).find('div.icon').addClass(ftClass);
        });
    });
</script>";

            writer.Write(str);
        }