public IEnumerable <Model.ActivityNo> GetPage(Model.Page page) { using (IDbConnection cn = new MySqlConnection(cns)) { string sql = "with a as(select row_number() over(order by endTime desc) as num,activity.* from activity)"; return(cn.Query <Model.ActivityNo>(sql, page)); } }
public ActionResult getVerifyPage([FromBody] Model.Page page) { var result = DAL.Activity.Instance.GetVerifyPage(page); if (result.Count() == 0) return Json(Result.Err("返回记录数为0")); else return Json(Result.Ok(result)); }
public ActionResult getPage([FormBody] Model.Page page) { var result = DAL.UserInfo.Instance.GetPage(page); if (result.Count() == 0) return Ok(Result.Err("返回记录为0")); else return Ok(Result.Ok(result)); }
public IEnumerable <Model.Activity> GetVerifyPage(Model.Page page) { using (IDbConnection cn = new MySqlConnection(cns)) { string sql = "with a as(select row_number() over(order by endTime desc) as num, activityId,activityName,endTime,activityPicture,summary,activityVerify,userName,recommend,recommendtime,endTime>=now() as activityStatus from activity where activityVerify='审核通过')"; return(cn.Query <Model.Activity>(sql, page)); } }
public IEnumerable <Model.Comment> GetPage(Model.Page page) { using (IDbConnection cn = new MySqlConnection(cns)) { string sql = "with a as(select row_number() over(order by commentTime desc) as num, Comment.*,workName from Comment join workinfo on Comment.workId=workinfo.workId)"; return(cn.Query <Model.Comment>(sql, page)); } }
public IEnumerable <Model.CommentNo> GetPage(Model.Page page) { using (IDbConnection cn = new MySqlConnection(cns)) { string sql = "with a as(select row_number() over(order by commentTime desc) as num, Comment.*,workName from Comment join workinfo on Comment.workId=workinfo.workId)"; sql += "select * from a where num between (@pageIn-1)*@pageSize+1 and @pageIndex*@pageSize;"; return(cn.Query <Model.CommentNo>(sql, page)); } }
public IEnumerable <Model.ActivityNo> GetPage(Model.Page page) { using (IDbConnection cn = new MySqlConnection(cns)) { string sql = "with a as(select row_number() over (order by endTime desc) as num,activity.* from activity)"; sql += "select * from a where num between (@pageIndex-1)*@pageSize+1 and @pageIndex*@pageSize;"; return(cn.Query <Model.ActivityNo>(sql, page)); } }
public IEnumerable <Model.UserInfoNo> GetPage(Model.Page page) { using (IDbConnection cn = new MySqlConnection(cns)) { string sql = "with a as(select row_number() over(order by username) as num, userinfo.* from useinfo)"; sql += "select * from a where num between (@pageIndex-1)*@pageSize+1 and @pageIndex*@pageSize; "; return(cn.Query <Model.UserInfoNo>(sql, page)); } }
public IEnumerable <Model.Activity> GetVerifyPage(Model.Page page) { using (IDbConnection cn = new MySqlConnection(cns)) { string sql = "select activityId,activityName,endTime,activityPicture,summary,activityVerify,userName,recommend,recommendtime,activityIntroduction,endTime>=now() as activityStatus from activity where activityId=@id"; sql += "select* from a where num between (@pageIndex-1)*@pageSize+1 and @pageIndex*@pageSize;"; return(cn.Query <Model.Activity>(sql, page)); } }
public ActionResult getPage([FromBody] Model.Page page) { var result = DAL.UserInfo.Instance.GetPage(page); if (result.Count() == 0) { return(Json(Result.Err("返回记录数为0"))); } else { return(Json(Result.Ok(result))); } }
public ActionResult getPage([FromBody] Model.Page page) { Console.WriteLine(page); var result = DAL.Comment.Instance.GetPage(page); Console.WriteLine(result); if (result.Count() == 0) { return(Json(Result.Err("返回记录数为0"))); } else { return(Json(Result.Ok(result))); } }
public static string SaveBitmapReturnPath(byte[] imageByte, Model.Page Page) { int pageId; var bitmapImg = ByteArrayToBitmapImage(imageByte); if (Page == null) { using (SQLiteConnection connection = new SQLiteConnection(DatabaseHelper.dbFile)) { try { pageId = int.Parse(connection.Query <SqliteSequence>("SELECT * FROM sqlite_sequence") .ToList().Where(s => s.name == "Page") .FirstOrDefault() .seq ); } catch (Exception err) { pageId = 1; } } } else { pageId = Page.Id; } string DirectoryPath = Path.Combine(Environment.CurrentDirectory, "Screenshot"); Directory.CreateDirectory(DirectoryPath); string filePath = Path.Combine(Environment.CurrentDirectory, "Screenshot", "image-" + pageId + ".png"); BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(bitmapImg)); using (var fileStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { encoder.Save(fileStream); } return(filePath); }
public static string SaveCroppedBitmapReturnPath(BitmapImage image, Model.Page Page) { string DirectoryPath = Path.Combine(Environment.CurrentDirectory, "Screenshot"); Directory.CreateDirectory(DirectoryPath); string filePath = Path.Combine(Environment.CurrentDirectory, "Screenshot", "__cropped__image-" + Page.Id + ".png"); BitmapEncoder encoder = new PngBitmapEncoder(); encoder.Frames.Add(BitmapFrame.Create(image)); using (var fileStream = new System.IO.FileStream(filePath, System.IO.FileMode.Create)) { encoder.Save(fileStream); } return(filePath); }
public Model.ProvisioningTemplate ToProvisioningTemplate(Stream template, String identifier) { if (template == null) { throw new ArgumentNullException("template"); } // Crate a copy of the source stream MemoryStream sourceStream = new MemoryStream(); template.CopyTo(sourceStream); sourceStream.Position = 0; // Check the provided template against the XML schema if (!this.IsValid(sourceStream)) { // TODO: Use resource file throw new ApplicationException("The provided template is not valid!"); } sourceStream.Position = 0; XDocument xml = XDocument.Load(sourceStream); XNamespace pnp = XMLConstants.PROVISIONING_SCHEMA_NAMESPACE_2015_12; // Prepare a variable to hold the single source formatted template V201512.ProvisioningTemplate source = null; // Prepare a variable to hold the resulting ProvisioningTemplate instance Model.ProvisioningTemplate result = new Model.ProvisioningTemplate(); // Determine if we're working on a wrapped SharePointProvisioningTemplate or not if (xml.Root.Name == pnp + "Provisioning") { // Deserialize the whole wrapper V201512.Provisioning wrappedResult = XMLSerializer.Deserialize<V201512.Provisioning>(xml); // Handle the wrapper schema parameters if (wrappedResult.Preferences != null && wrappedResult.Preferences.Parameters != null && wrappedResult.Preferences.Parameters.Length > 0) { foreach (var parameter in wrappedResult.Preferences.Parameters) { result.Parameters.Add(parameter.Key, parameter.Text != null ? parameter.Text.Aggregate(String.Empty, (acc, i) => acc + i) : null); } } // Handle Localizations if (wrappedResult.Localizations != null) { result.Localizations.AddRange( from l in wrappedResult.Localizations select new Localization { LCID = l.LCID, Name = l.Name, ResourceFile = l.ResourceFile, }); } foreach (var templates in wrappedResult.Templates) { // Let's see if we have an in-place template with the provided ID or if we don't have a provided ID at all source = templates.ProvisioningTemplate.FirstOrDefault(spt => spt.ID == identifier || String.IsNullOrEmpty(identifier)); // If we don't have a template, but there are external file references if (source == null && templates.ProvisioningTemplateFile.Length > 0) { // Otherwise let's see if we have an external file for the template var externalSource = templates.ProvisioningTemplateFile.FirstOrDefault(sptf => sptf.ID == identifier); Stream externalFileStream = this._provider.Connector.GetFileStream(externalSource.File); xml = XDocument.Load(externalFileStream); if (xml.Root.Name != pnp + "ProvisioningTemplate") { throw new ApplicationException("Invalid external file format. Expected a ProvisioningTemplate file!"); } else { source = XMLSerializer.Deserialize<V201512.ProvisioningTemplate>(xml); } } if (source != null) { break; } } } else if (xml.Root.Name == pnp + "ProvisioningTemplate") { var IdAttribute = xml.Root.Attribute("ID"); // If there is a provided ID, and if it doesn't equal the current ID if (!String.IsNullOrEmpty(identifier) && IdAttribute != null && IdAttribute.Value != identifier) { // TODO: Use resource file throw new ApplicationException("The provided template identifier is not available!"); } else { source = XMLSerializer.Deserialize<V201512.ProvisioningTemplate>(xml); } } #region Basic Properties // Translate basic properties result.Id = source.ID; result.Version = (Double)source.Version; result.SitePolicy = source.SitePolicy; result.ImagePreviewUrl = source.ImagePreviewUrl; result.DisplayName = source.DisplayName; result.Description = source.Description; if (source.Properties != null && source.Properties.Length > 0) { result.Properties.AddRange( (from p in source.Properties select p).ToDictionary(i => i.Key, i => i.Value)); } #endregion #region Property Bag // Translate PropertyBagEntries, if any if (source.PropertyBagEntries != null) { result.PropertyBagEntries.AddRange( from bag in source.PropertyBagEntries select new Model.PropertyBagEntry { Key = bag.Key, Value = bag.Value, Indexed = bag.Indexed, Overwrite = bag.OverwriteSpecified ? bag.Overwrite : false, }); } #endregion #region Web Settings if (source.WebSettings != null) { result.WebSettings = new Model.WebSettings { NoCrawl = source.WebSettings.NoCrawlSpecified ? source.WebSettings.NoCrawl : false, RequestAccessEmail = source.WebSettings.RequestAccessEmail, WelcomePage = source.WebSettings.WelcomePage, Title = source.WebSettings.Title, Description = source.WebSettings.Description, SiteLogo = source.WebSettings.SiteLogo, AlternateCSS = source.WebSettings.AlternateCSS, MasterPageUrl = source.WebSettings.MasterPageUrl, CustomMasterPageUrl = source.WebSettings.CustomMasterPageUrl, WebTemplate = source.WebSettings.WebTemplate }; } #endregion #region Regional Settings if (source.RegionalSettings != null) { result.RegionalSettings = new Model.RegionalSettings() { AdjustHijriDays = source.RegionalSettings.AdjustHijriDaysSpecified ? source.RegionalSettings.AdjustHijriDays : 0, AlternateCalendarType = source.RegionalSettings.AlternateCalendarTypeSpecified ? source.RegionalSettings.AlternateCalendarType.FromSchemaToTemplateCalendarTypeV201512() : Microsoft.SharePoint.Client.CalendarType.None, CalendarType = source.RegionalSettings.CalendarTypeSpecified ? source.RegionalSettings.CalendarType.FromSchemaToTemplateCalendarTypeV201512() : Microsoft.SharePoint.Client.CalendarType.None, Collation = source.RegionalSettings.CollationSpecified ? source.RegionalSettings.Collation : 0, FirstDayOfWeek = source.RegionalSettings.FirstDayOfWeekSpecified ? (System.DayOfWeek)Enum.Parse(typeof(System.DayOfWeek), source.RegionalSettings.FirstDayOfWeek.ToString()) : System.DayOfWeek.Sunday, FirstWeekOfYear = source.RegionalSettings.FirstWeekOfYearSpecified ? source.RegionalSettings.FirstWeekOfYear : 0, LocaleId = source.RegionalSettings.LocaleIdSpecified ? source.RegionalSettings.LocaleId : 1033, ShowWeeks = source.RegionalSettings.ShowWeeksSpecified ? source.RegionalSettings.ShowWeeks : false, Time24 = source.RegionalSettings.Time24Specified ? source.RegionalSettings.Time24 : false, TimeZone = !String.IsNullOrEmpty(source.RegionalSettings.TimeZone) ? Int32.Parse(source.RegionalSettings.TimeZone) : 0, WorkDayEndHour = source.RegionalSettings.WorkDayEndHourSpecified ? source.RegionalSettings.WorkDayEndHour.FromSchemaToTemplateWorkHourV201512() : Model.WorkHour.PM0600, WorkDays = source.RegionalSettings.WorkDaysSpecified ? source.RegionalSettings.WorkDays : 5, WorkDayStartHour = source.RegionalSettings.WorkDayStartHourSpecified ? source.RegionalSettings.WorkDayStartHour.FromSchemaToTemplateWorkHourV201512() : Model.WorkHour.AM0900, }; } else { result.RegionalSettings = null; } #endregion #region Supported UI Languages if (source.SupportedUILanguages != null && source.SupportedUILanguages.Length > 0) { result.SupportedUILanguages.AddRange( from l in source.SupportedUILanguages select new SupportedUILanguage { LCID = l.LCID, }); } #endregion #region Audit Settings if (source.AuditSettings != null) { result.AuditSettings = new Model.AuditSettings { AuditLogTrimmingRetention = source.AuditSettings.AuditLogTrimmingRetentionSpecified ? source.AuditSettings.AuditLogTrimmingRetention : 0, TrimAuditLog = source.AuditSettings.TrimAuditLogSpecified ? source.AuditSettings.TrimAuditLog : false, AuditFlags = source.AuditSettings.Audit.Aggregate(Microsoft.SharePoint.Client.AuditMaskType.None, (acc, next) => acc |= (Microsoft.SharePoint.Client.AuditMaskType)Enum.Parse(typeof(Microsoft.SharePoint.Client.AuditMaskType), next.AuditFlag.ToString())), }; } #endregion #region Security // Translate Security configuration, if any if (source.Security != null) { if (source.Security.AdditionalAdministrators != null) { result.Security.AdditionalAdministrators.AddRange( from user in source.Security.AdditionalAdministrators select new Model.User { Name = user.Name, }); } if (source.Security.AdditionalOwners != null) { result.Security.AdditionalOwners.AddRange( from user in source.Security.AdditionalOwners select new Model.User { Name = user.Name, }); } if (source.Security.AdditionalMembers != null) { result.Security.AdditionalMembers.AddRange( from user in source.Security.AdditionalMembers select new Model.User { Name = user.Name, }); } if (source.Security.AdditionalVisitors != null) { result.Security.AdditionalVisitors.AddRange( from user in source.Security.AdditionalVisitors select new Model.User { Name = user.Name, }); } if (source.Security.SiteGroups != null) { result.Security.SiteGroups.AddRange( from g in source.Security.SiteGroups select new Model.SiteGroup(g.Members != null ? from m in g.Members select new Model.User { Name = m.Name } : null) { AllowMembersEditMembership = g.AllowMembersEditMembershipSpecified ? g.AllowMembersEditMembership : false, AllowRequestToJoinLeave = g.AllowRequestToJoinLeaveSpecified ? g.AllowRequestToJoinLeave : false, AutoAcceptRequestToJoinLeave = g.AutoAcceptRequestToJoinLeaveSpecified ? g.AutoAcceptRequestToJoinLeave : false, Description = g.Description, OnlyAllowMembersViewMembership = g.OnlyAllowMembersViewMembershipSpecified ? g.OnlyAllowMembersViewMembership : false, Owner = g.Owner, RequestToJoinLeaveEmailSetting = g.RequestToJoinLeaveEmailSetting, Title = g.Title, }); } if (source.Security.Permissions != null) { if (source.Security.Permissions.RoleAssignments != null && source.Security.Permissions.RoleAssignments.Length > 0) { result.Security.SiteSecurityPermissions.RoleAssignments.AddRange (from ra in source.Security.Permissions.RoleAssignments select new Model.RoleAssignment { Principal = ra.Principal, RoleDefinition = ra.RoleDefinition, }); } if (source.Security.Permissions.RoleDefinitions != null && source.Security.Permissions.RoleDefinitions.Length > 0) { result.Security.SiteSecurityPermissions.RoleDefinitions.AddRange (from rd in source.Security.Permissions.RoleDefinitions select new Model.RoleDefinition( from p in rd.Permissions select (Microsoft.SharePoint.Client.PermissionKind)Enum.Parse(typeof(Microsoft.SharePoint.Client.PermissionKind), p.ToString())) { Description = rd.Description, Name = rd.Name, }); } } } #endregion #region Site Columns // Translate Site Columns (Fields), if any if ((source.SiteFields != null) && (source.SiteFields.Any != null)) { result.SiteFields.AddRange( from field in source.SiteFields.Any select new Model.Field { SchemaXml = field.OuterXml, }); } #endregion #region Content Types // Translate ContentTypes, if any if ((source.ContentTypes != null) && (source.ContentTypes != null)) { result.ContentTypes.AddRange( from contentType in source.ContentTypes select new ContentType( contentType.ID, contentType.Name, contentType.Description, contentType.Group, contentType.Sealed, contentType.Hidden, contentType.ReadOnly, (contentType.DocumentTemplate != null ? contentType.DocumentTemplate.TargetName : null), contentType.Overwrite, (contentType.FieldRefs != null ? (from fieldRef in contentType.FieldRefs select new Model.FieldRef(fieldRef.Name) { Id = Guid.Parse(fieldRef.ID), Hidden = fieldRef.Hidden, Required = fieldRef.Required }) : null) ) { DocumentSetTemplate = contentType.DocumentSetTemplate != null ? new Model.DocumentSetTemplate( contentType.DocumentSetTemplate.WelcomePage, contentType.DocumentSetTemplate.AllowedContentTypes != null ? (from act in contentType.DocumentSetTemplate.AllowedContentTypes select act.ContentTypeID) : null, contentType.DocumentSetTemplate.DefaultDocuments != null ? (from dd in contentType.DocumentSetTemplate.DefaultDocuments select new Model.DefaultDocument { ContentTypeId = dd.ContentTypeID, FileSourcePath = dd.FileSourcePath, Name = dd.Name, }) : null, contentType.DocumentSetTemplate.SharedFields != null ? (from sf in contentType.DocumentSetTemplate.SharedFields select Guid.Parse(sf.ID)) : null, contentType.DocumentSetTemplate.WelcomePageFields != null ? (from wpf in contentType.DocumentSetTemplate.WelcomePageFields select Guid.Parse(wpf.ID)) : null ) : null, DisplayFormUrl = contentType.DisplayFormUrl, EditFormUrl = contentType.EditFormUrl, NewFormUrl = contentType.NewFormUrl, } ); } #endregion #region List Instances // Translate Lists Instances, if any if (source.Lists != null) { result.Lists.AddRange( from list in source.Lists select new Model.ListInstance( (list.ContentTypeBindings != null ? (from contentTypeBinding in list.ContentTypeBindings select new Model.ContentTypeBinding { ContentTypeId = contentTypeBinding.ContentTypeID, Default = contentTypeBinding.Default, }) : null), (list.Views != null ? (from view in list.Views.Any select new Model.View { SchemaXml = view.OuterXml, }) : null), (list.Fields != null ? (from field in list.Fields.Any select new Model.Field { SchemaXml = field.OuterXml, }) : null), (list.FieldRefs != null ? (from fieldRef in list.FieldRefs select new Model.FieldRef(fieldRef.Name) { DisplayName = fieldRef.DisplayName, Hidden = fieldRef.Hidden, Required = fieldRef.Required, Id = Guid.Parse(fieldRef.ID) }) : null), (list.DataRows != null ? (from dataRow in list.DataRows select new Model.DataRow( (from dataValue in dataRow.DataValue select dataValue).ToDictionary(k => k.FieldName, v => v.Value), dataRow.Security.FromSchemaToTemplateObjectSecurityV201512(), dataRow.Src )).ToList() : null), (list.FieldDefaults != null ? (from fd in list.FieldDefaults select fd).ToDictionary(k => k.FieldName, v => v.Value) : null), list.Security.FromSchemaToTemplateObjectSecurityV201512(), (list.Folders != null ? (new List<Model.Folder>(from folder in list.Folders select folder.FromSchemaToTemplateFolderV201512())) : null) ) { ContentTypesEnabled = list.ContentTypesEnabled, Description = list.Description, DocumentTemplate = list.DocumentTemplate, EnableVersioning = list.EnableVersioning, EnableMinorVersions = list.EnableMinorVersions, DraftVersionVisibility = list.DraftVersionVisibility, EnableModeration = list.EnableModeration, Hidden = list.Hidden, MinorVersionLimit = list.MinorVersionLimitSpecified ? list.MinorVersionLimit : 0, MaxVersionLimit = list.MaxVersionLimitSpecified ? list.MaxVersionLimit : 0, OnQuickLaunch = list.OnQuickLaunch, EnableAttachments = list.EnableAttachments, EnableFolderCreation = list.EnableFolderCreation, RemoveExistingContentTypes = list.RemoveExistingContentTypes, TemplateFeatureID = !String.IsNullOrEmpty(list.TemplateFeatureID) ? Guid.Parse(list.TemplateFeatureID) : Guid.Empty, RemoveExistingViews = list.Views != null ? list.Views.RemoveExistingViews : false, TemplateType = list.TemplateType, Title = list.Title, Url = list.Url, }); } #endregion #region Features // Translate Features, if any if (source.Features != null) { if (result.Features.SiteFeatures != null && source.Features.SiteFeatures != null) { result.Features.SiteFeatures.AddRange( from feature in source.Features.SiteFeatures select new Model.Feature { Id = new Guid(feature.ID), Deactivate = feature.Deactivate, }); } if (result.Features.WebFeatures != null && source.Features.WebFeatures != null) { result.Features.WebFeatures.AddRange( from feature in source.Features.WebFeatures select new Model.Feature { Id = new Guid(feature.ID), Deactivate = feature.Deactivate, }); } } #endregion #region Custom Actions // Translate CustomActions, if any if (source.CustomActions != null) { if (result.CustomActions.SiteCustomActions != null && source.CustomActions.SiteCustomActions != null) { result.CustomActions.SiteCustomActions.AddRange( from customAction in source.CustomActions.SiteCustomActions select new Model.CustomAction { CommandUIExtension = (customAction.CommandUIExtension != null && customAction.CommandUIExtension.Any != null) ? (new XElement("CommandUIExtension", from x in customAction.CommandUIExtension.Any select x.ToXElement())) : null, Description = customAction.Description, Enabled = customAction.Enabled, Group = customAction.Group, ImageUrl = customAction.ImageUrl, Location = customAction.Location, Name = customAction.Name, Rights = customAction.RightsSpecified ? customAction.Rights.ToBasePermissions(): new BasePermissions(), ScriptBlock = customAction.ScriptBlock, ScriptSrc = customAction.ScriptSrc, Sequence = customAction.SequenceSpecified ? customAction.Sequence : 100, Title = customAction.Title, Url = customAction.Url, }); } if (result.CustomActions.WebCustomActions != null && source.CustomActions.WebCustomActions != null) { result.CustomActions.WebCustomActions.AddRange( from customAction in source.CustomActions.WebCustomActions select new Model.CustomAction { CommandUIExtension = (customAction.CommandUIExtension != null && customAction.CommandUIExtension.Any != null) ? (new XElement("CommandUIExtension", from x in customAction.CommandUIExtension.Any select x.ToXElement())) : null, Description = customAction.Description, Enabled = customAction.Enabled, Group = customAction.Group, ImageUrl = customAction.ImageUrl, Location = customAction.Location, Name = customAction.Name, Rights = customAction.RightsSpecified ? customAction.Rights.ToBasePermissions() : new BasePermissions(), ScriptBlock = customAction.ScriptBlock, ScriptSrc = customAction.ScriptSrc, Sequence = customAction.SequenceSpecified ? customAction.Sequence : 100, Title = customAction.Title, Url = customAction.Url, }); } } #endregion #region Files // Translate Files, if any if (source.Files != null) { result.Files.AddRange( from file in source.Files select new Model.File(file.Src, file.Folder, file.Overwrite, file.WebParts != null ? (from wp in file.WebParts select new Model.WebPart { Order = (uint)wp.Order, Zone = wp.Zone, Title = wp.Title, Contents = wp.Contents.InnerXml }) : null, file.Properties != null ? file.Properties.ToDictionary(k => k.Key, v => v.Value) : null, file.Security.FromSchemaToTemplateObjectSecurityV201512() ) ); } #endregion #region Pages // Translate Pages, if any if (source.Pages != null) { List<V201512.Page> pages = new List<V201512.Page>(); if (null != source.Pages.PublishingPage) { pages.AddRange(source.Pages.PublishingPage.Select(p => (V201512.Page)p)); } if (null != source.Pages.ContentPage) { pages.AddRange(source.Pages.ContentPage.Select(p => (V201512.Page)p)); } if (null != source.Pages.Page) { pages.AddRange(source.Pages.Page); } foreach (var page in pages) { var pageLayout = WikiPageLayout.OneColumn; switch (page.Layout) { case V201512.WikiPageLayout.OneColumn: pageLayout = WikiPageLayout.OneColumn; break; case V201512.WikiPageLayout.OneColumnSidebar: pageLayout = WikiPageLayout.OneColumnSideBar; break; case V201512.WikiPageLayout.TwoColumns: pageLayout = WikiPageLayout.TwoColumns; break; case V201512.WikiPageLayout.TwoColumnsHeader: pageLayout = WikiPageLayout.TwoColumnsHeader; break; case V201512.WikiPageLayout.TwoColumnsHeaderFooter: pageLayout = WikiPageLayout.TwoColumnsHeaderFooter; break; case V201512.WikiPageLayout.ThreeColumns: pageLayout = WikiPageLayout.ThreeColumns; break; case V201512.WikiPageLayout.ThreeColumnsHeader: pageLayout = WikiPageLayout.ThreeColumnsHeader; break; case V201512.WikiPageLayout.ThreeColumnsHeaderFooter: pageLayout = WikiPageLayout.ThreeColumnsHeaderFooter; break; case V201512.WikiPageLayout.Custom: pageLayout = WikiPageLayout.Custom; break; } var webparts = (page.WebParts != null ? (from wp in page.WebParts select new Model.WebPart { Title = wp.Title, Column = (uint)wp.Column, Row = (uint)wp.Row, Contents = wp.Contents.InnerXml, Zone = wp.Zone, Order = (uint)wp.Order }).ToList() : null); var security = page.Security.FromSchemaToTemplateObjectSecurityV201512(); var fields = (page.Fields != null && page.Fields.Length > 0) ? (from f in page.Fields select f).ToDictionary(i => i.FieldName, i => i.Value) : null; Model.Page modelPage = null; if (page is V201512.PublishingPage) { modelPage = new Model.PublishingPage(page.Url, ((V201512.PublishingPage)page).PageTitle, ((V201512.PublishingPage)page).HTML, ((V201512.PublishingPage)page).PageLayoutUrl, page.Overwrite, webparts, false, security, fields); } else if (page is V201512.ContentPage) { modelPage = new Model.ContentPage(page.Url, ((V201512.ContentPage)page).HTML, page.Overwrite, webparts, false, security, fields); } else { modelPage = new Model.Page(page.Url, page.Overwrite, pageLayout, webparts, security, fields); } result.Pages.Add(modelPage); } } #endregion #region Taxonomy // Translate Termgroups, if any if (source.TermGroups != null) { result.TermGroups.AddRange( from termGroup in source.TermGroups select new Model.TermGroup( !string.IsNullOrEmpty(termGroup.ID) ? Guid.Parse(termGroup.ID) : Guid.Empty, termGroup.Name, new List<Model.TermSet>( from termSet in termGroup.TermSets select new Model.TermSet( !string.IsNullOrEmpty(termSet.ID) ? Guid.Parse(termSet.ID) : Guid.Empty, termSet.Name, termSet.LanguageSpecified ? (int?)termSet.Language : null, termSet.IsAvailableForTagging, termSet.IsOpenForTermCreation, termSet.Terms != null ? termSet.Terms.FromSchemaTermsToModelTermsV201512() : null, termSet.CustomProperties != null ? termSet.CustomProperties.ToDictionary(k => k.Key, v => v.Value) : null) { Description = termSet.Description, }) ) { Description = termGroup.Description, }); } #endregion #region Composed Looks // Translate ComposedLook, if any if (source.ComposedLook != null) { result.ComposedLook.BackgroundFile = source.ComposedLook.BackgroundFile; result.ComposedLook.ColorFile = source.ComposedLook.ColorFile; result.ComposedLook.FontFile = source.ComposedLook.FontFile; result.ComposedLook.Name = source.ComposedLook.Name; result.ComposedLook.Version = source.ComposedLook.Version; } #endregion #region Workflows if (source.Workflows != null) { result.Workflows = new Model.Workflows( (source.Workflows.WorkflowDefinitions != null && source.Workflows.WorkflowDefinitions.Length > 0) ? (from wd in source.Workflows.WorkflowDefinitions select new Model.WorkflowDefinition( (wd.Properties != null && wd.Properties.Length > 0) ? (from p in wd.Properties select p).ToDictionary(i => i.Key, i => i.Value) : null) { AssociationUrl = wd.AssociationUrl, Description = wd.Description, DisplayName = wd.DisplayName, DraftVersion = wd.DraftVersion, FormField = wd.FormField != null ? wd.FormField.OuterXml : null, Id = Guid.Parse(wd.Id), InitiationUrl = wd.InitiationUrl, Published = wd.PublishedSpecified ? wd.Published : false, RequiresAssociationForm = wd.RequiresAssociationFormSpecified ? wd.RequiresAssociationForm : false, RequiresInitiationForm = wd.RequiresInitiationFormSpecified ? wd.RequiresInitiationForm : false, RestrictToScope = wd.RestrictToScope, RestrictToType = wd.RestrictToType.ToString(), XamlPath = wd.XamlPath, }) : null, (source.Workflows.WorkflowSubscriptions != null && source.Workflows.WorkflowSubscriptions.Length > 0) ? (from ws in source.Workflows.WorkflowSubscriptions select new Model.WorkflowSubscription( (ws.PropertyDefinitions != null && ws.PropertyDefinitions.Length > 0) ? (from pd in ws.PropertyDefinitions select pd).ToDictionary(i => i.Key, i => i.Value) : null) { DefinitionId = Guid.Parse(ws.DefinitionId), Enabled = ws.Enabled, EventSourceId = ws.EventSourceId, EventTypes = (new String[] { ws.ItemAddedEvent? "ItemAdded" : null, ws.ItemUpdatedEvent? "ItemUpdated" : null, ws.WorkflowStartEvent? "WorkflowStart" : null }).Where(e => e != null).ToList(), ListId = ws.ListId, ManualStartBypassesActivationLimit = ws.ManualStartBypassesActivationLimitSpecified ? ws.ManualStartBypassesActivationLimit : false, Name = ws.Name, ParentContentTypeId = ws.ParentContentTypeId, StatusFieldName = ws.StatusFieldName, }) : null ); } #endregion #region Search Settings if (source.SearchSettings != null) { result.SearchSettings = source.SearchSettings.OuterXml; } #endregion #region Publishing if (source.Publishing != null) { result.Publishing = new Model.Publishing( (Model.AutoCheckRequirementsOptions)Enum.Parse(typeof(Model.AutoCheckRequirementsOptions), source.Publishing.AutoCheckRequirements.ToString()), source.Publishing.DesignPackage != null ? new Model.DesignPackage { DesignPackagePath = source.Publishing.DesignPackage.DesignPackagePath, MajorVersion = source.Publishing.DesignPackage.MajorVersionSpecified ? source.Publishing.DesignPackage.MajorVersion : 0, MinorVersion = source.Publishing.DesignPackage.MinorVersionSpecified ? source.Publishing.DesignPackage.MinorVersion : 0, PackageGuid = Guid.Parse(source.Publishing.DesignPackage.PackageGuid), PackageName = source.Publishing.DesignPackage.PackageName, } : null, source.Publishing.AvailableWebTemplates != null && source.Publishing.AvailableWebTemplates.Length > 0 ? (from awt in source.Publishing.AvailableWebTemplates select new Model.AvailableWebTemplate { LanguageCode = awt.LanguageCodeSpecified ? awt.LanguageCode : 1033, TemplateName = awt.TemplateName, }) : null, source.Publishing.PageLayouts != null && source.Publishing.PageLayouts.PageLayout != null && source.Publishing.PageLayouts.PageLayout.Length > 0 ? (from pl in source.Publishing.PageLayouts.PageLayout select new Model.PageLayout { IsDefault = pl.Path == source.Publishing.PageLayouts.Default, Path = pl.Path, }) : null ); } #endregion #region AddIns if (source.AddIns != null && source.AddIns.Length > 0) { result.AddIns.AddRange( from addin in source.AddIns select new Model.AddIn { PackagePath = addin.PackagePath, Source = addin.Source.ToString(), }); } #endregion #region Providers // Translate Providers, if any if (source.Providers != null) { foreach (var provider in source.Providers) { if (!String.IsNullOrEmpty(provider.HandlerType)) { var handlerType = Type.GetType(provider.HandlerType, false); if (handlerType != null) { result.Providers.Add( new Model.Provider { Assembly = handlerType.Assembly.FullName, Type = handlerType.FullName, Configuration = provider.Configuration != null ? provider.Configuration.ToProviderConfiguration() : null, Enabled = provider.Enabled, }); } } } } #endregion return (result); }
public ActionResult getPage([FromBody] Model.Page page) { var result = DAL.Activity.Instance.GetPage(page); }