Exemplo n.º 1
0
        private static void ConvertToContentModel(ContentLogRequest request, List <SpContentLogModel> models, string eventDate, IEnumerable <ComplianceTagModel> tags, IDictionary <string, object> resultRow)
        {
            SpContentLogModel contentModel = new SpContentLogModel();
            var modifiedDate = Convert.ToDateTime(resultRow["ModifiedOWSDATE"]).ToUniversalTime();

            if (modifiedDate >= request.ModifiedDate)
            {
                contentModel.Author            = !string.IsNullOrEmpty(Convert.ToString(resultRow["Author"])) ? resultRow["Author"].ToString() : "";
                contentModel.ComplianceTag     = !string.IsNullOrEmpty(Convert.ToString(resultRow["ComplianceTag"])) ? resultRow["ComplianceTag"].ToString() : "";
                contentModel.ComplainceAssetId = !string.IsNullOrEmpty(Convert.ToString(resultRow["ComplianceAssetId"])) ? resultRow["ComplianceAssetId"].ToString() : "";
                if (!string.IsNullOrEmpty(contentModel.ComplianceTag))
                {
                    contentModel.ComplianceTagId = tags.FirstOrDefault(v => v.TagName == contentModel.ComplianceTag.ToString())?.TagId ?? "";
                }
                contentModel.DocId            = !string.IsNullOrEmpty(Convert.ToString(resultRow["DocId"])) ? resultRow["DocId"].ToString() : "";
                contentModel.DocumentName     = !string.IsNullOrEmpty(Convert.ToString(resultRow["FileName"])) ? resultRow["FileName"].ToString() : "";
                contentModel.DocUrl           = !string.IsNullOrEmpty(Convert.ToString(resultRow["DefaultEncodingURL"])) ? resultRow["DefaultEncodingURL"].ToString() : "";
                contentModel.FileType         = !string.IsNullOrEmpty(Convert.ToString(resultRow["FileType"])) ? resultRow["FileType"].ToString() : "";
                contentModel.LastModifiedTime = modifiedDate;
                contentModel.Title            = !string.IsNullOrEmpty(Convert.ToString(resultRow["Title"])) ? resultRow["Title"].ToString() : "";
                contentModel.ContentTypeId    = !string.IsNullOrEmpty(Convert.ToString(request.ContentTypeId)) ? request.ContentTypeId.ToString() : "";
                contentModel.SpWebUrl         = !string.IsNullOrEmpty(Convert.ToString(resultRow["SPWebUrl"])) ? resultRow["SPWebUrl"].ToString() : "";
                GetEventColumnValue(request, eventDate, resultRow, contentModel, tags);
                models.Add(contentModel);
            }
        }
Exemplo n.º 2
0
        private static void GetEventColumnValue(ContentLogRequest request, string eventDate, IDictionary <string, object> resultRow, SpContentLogModel contentModel, IEnumerable <ComplianceTagModel> labels)
        {
            ctx = GetWebContext(contentModel.SpWebUrl, request, ctx);
            using (ctx)
            {
                var  listId = !string.IsNullOrEmpty(Convert.ToString(resultRow["ListId"])) ? resultRow["ListId"].ToString() : "";
                List list   = ctx.Web.Lists.GetById(listId.ToGuid());
                ctx.Load(list);
                ctx.ExecuteQuery();
                string   listItemId = !string.IsNullOrEmpty(Convert.ToString(resultRow["ListItemID"])) ? resultRow["ListItemID"].ToString() : "";
                ListItem listItem   = list.GetItemById(listItemId);
                ctx.Load(listItem);
                ctx.ExecuteQuery();
                contentModel.LibraryName      = list.Title;
                contentModel.EventColumnValue = !string.IsNullOrEmpty(Convert.ToString(listItem[eventDate])) ? Convert.ToDateTime(listItem[eventDate]) : (DateTime?)null;

                if (string.IsNullOrEmpty(Convert.ToString(resultRow["ComplianceTag"])))
                {
                    contentModel.ComplianceTag     = !string.IsNullOrEmpty(Convert.ToString(listItem["_ComplianceTag"])) ? listItem["_ComplianceTag"].ToString() : "";
                    contentModel.ComplianceTagId   = labels.FirstOrDefault(v => v.TagName == contentModel.ComplianceTag.ToString())?.TagId ?? "";
                    contentModel.ComplainceAssetId = !string.IsNullOrEmpty(Convert.ToString(listItem["ComplianceAssetId"])) ? listItem["ComplianceAssetId"].ToString() : "";
                }
                if (!string.IsNullOrEmpty(contentModel.ComplianceTag) && string.IsNullOrEmpty(Convert.ToString(resultRow["ComplianceAssetId"])))
                {
                    listItem["ComplianceAssetId"] = !string.IsNullOrEmpty(Convert.ToString(resultRow["DocId"])) ? resultRow["DocId"].ToString() : "";
                    listItem.SystemUpdate();
                    ctx.ExecuteQuery();
                    contentModel.ComplainceAssetId = !string.IsNullOrEmpty(Convert.ToString(resultRow["DocId"])) ? resultRow["DocId"].ToString() : "";
                }
            }
        }