private void handlePublishing(Document doc, documentCarrier carrier, umbraco.BusinessLogic.User user) { switch (carrier.PublishAction) { case documentCarrier.EPublishAction.Publish: doc.Publish(user); umbraco.library.PublishSingleNode(doc.Id); break; case documentCarrier.EPublishAction.Unpublish: doc.Publish(user); umbraco.library.UnPublishSingleNode(doc.Id); break; case documentCarrier.EPublishAction.Ignore: if (doc.Published) { doc.Publish(user); umbraco.library.PublishSingleNode(doc.Id); } else { doc.Publish(user); umbraco.library.UnPublishSingleNode(doc.Id); } break; } }
public void update(documentCarrier carrier, string username, string password) { Authenticate(username, password); if (carrier.Id == 0) { throw new Exception("ID must be specifed when updating"); } if (carrier == null) { throw new Exception("No carrier specified"); } umbraco.BusinessLogic.User user = GetUser(username, password); Document doc = null; try { doc = new Document(carrier.Id); } catch {} if (doc == null) { // We assign the new values: doc.ReleaseDate = carrier.ReleaseDate; } doc.ExpireDate = carrier.ExpireDate; if (carrier.ParentID != 0) { doc.Move(carrier.ParentID); } if (carrier.Name.Length != 0) { doc.Text = carrier.Name; } // We iterate the properties in the carrier if (carrier.DocumentProperties != null) { foreach (documentProperty updatedproperty in carrier.DocumentProperties) { umbraco.cms.businesslogic.property.Property property = doc.getProperty(updatedproperty.Key); if (property == null) { } else { property.Value = updatedproperty.PropertyValue; } } } handlePublishing(doc, carrier, user); }
public documentCarrier read(int id, string username, string password) { Authenticate(username, password); umbraco.cms.businesslogic.web.Document doc = null; try { doc = new umbraco.cms.businesslogic.web.Document(id); } catch {} if (doc == null) { throw new Exception("Could not load Document with ID: " + id); } documentCarrier carrier = createCarrier(doc); return(carrier); }
public int create(documentCarrier carrier, string username, string password) { Authenticate(username, password); // Some validation if (carrier == null) throw new Exception("No carrier specified"); if (carrier.ParentID == 0) throw new Exception("Document needs a parent"); if (carrier.DocumentTypeID == 0) throw new Exception("Documenttype must be specified"); if (carrier.Id != 0) throw new Exception("ID cannot be specifed when creating. Must be 0"); if (carrier.Name == null || carrier.Name.Length == 0) carrier.Name = "unnamed"; umbraco.BusinessLogic.User user = GetUser(username, password); // We get the documenttype umbraco.cms.businesslogic.web.DocumentType docType = new umbraco.cms.businesslogic.web.DocumentType(carrier.DocumentTypeID); if (docType == null) throw new Exception("DocumenttypeID " + carrier.DocumentTypeID + " not found"); // We create the document Document newDoc = Document.MakeNew(carrier.Name, docType, user, carrier.ParentID); newDoc.ReleaseDate = carrier.ReleaseDate; newDoc.ExpireDate = carrier.ExpireDate; // We iterate the properties in the carrier if (carrier.DocumentProperties != null) { foreach (documentProperty updatedproperty in carrier.DocumentProperties) { umbraco.cms.businesslogic.property.Property property = newDoc.getProperty(updatedproperty.Key); if (property == null) throw new Exception("property " + updatedproperty.Key + " was not found"); property.Value = updatedproperty.PropertyValue; } } // We check the publishaction and do the appropiate handlePublishing(newDoc, carrier, user); // We return the ID of the document..65 return newDoc.Id; }
private documentCarrier createCarrier(Document doc) { documentCarrier carrier = new documentCarrier(); carrier.ExpireDate = doc.ExpireDate; carrier.ReleaseDate = doc.ReleaseDate; carrier.Id = doc.Id; carrier.Name = doc.Text; try { carrier.ParentID = doc.Parent.Id; } catch { } carrier.Published = doc.Published; carrier.HasChildren = doc.HasChildren; var props = doc.getProperties; foreach (umbraco.cms.businesslogic.property.Property prop in props) { documentProperty carrierprop = new documentProperty(); if (prop.Value == System.DBNull.Value) { carrierprop.PropertyValue = null; } else { carrierprop.PropertyValue = prop.Value; } carrierprop.Key = prop.PropertyType.Alias; carrier.DocumentProperties.Add(carrierprop); } return(carrier); }
private void handlePublishing(Document doc, documentCarrier carrier, umbraco.BusinessLogic.User user) { switch (carrier.PublishAction) { case documentCarrier.EPublishAction.Publish: if (doc.PublishWithResult(user)) { umbraco.library.UpdateDocumentCache(doc.Id); } break; case documentCarrier.EPublishAction.Unpublish: if (doc.PublishWithResult(user)) { umbraco.library.UnPublishSingleNode(doc.Id); } break; case documentCarrier.EPublishAction.Ignore: if (doc.Published) { if (doc.PublishWithResult(user)) { umbraco.library.UpdateDocumentCache(doc.Id); } } else { if (doc.PublishWithResult(user)) { umbraco.library.UpdateDocumentCache(doc.Id); } } break; } }
public int create(documentCarrier carrier, string username, string password) { Authenticate(username, password); // Some validation if (carrier == null) { throw new Exception("No carrier specified"); } if (carrier.ParentID == 0) { throw new Exception("Document needs a parent"); } if (carrier.DocumentTypeID == 0) { throw new Exception("Documenttype must be specified"); } if (carrier.Id != 0) { throw new Exception("ID cannot be specifed when creating. Must be 0"); } if (carrier.Name == null || carrier.Name.Length == 0) { carrier.Name = "unnamed"; } umbraco.BusinessLogic.User user = GetUser(username, password); // We get the documenttype umbraco.cms.businesslogic.web.DocumentType docType = new umbraco.cms.businesslogic.web.DocumentType(carrier.DocumentTypeID); if (docType == null) { throw new Exception("DocumenttypeID " + carrier.DocumentTypeID + " not found"); } // We create the document Document newDoc = Document.MakeNew(carrier.Name, docType, user, carrier.ParentID); newDoc.ReleaseDate = carrier.ReleaseDate; newDoc.ExpireDate = carrier.ExpireDate; // We iterate the properties in the carrier if (carrier.DocumentProperties != null) { foreach (documentProperty updatedproperty in carrier.DocumentProperties) { umbraco.cms.businesslogic.property.Property property = newDoc.getProperty(updatedproperty.Key); if (property == null) { throw new Exception("property " + updatedproperty.Key + " was not found"); } property.Value = updatedproperty.PropertyValue; } } // We check the publishaction and do the appropiate handlePublishing(newDoc, carrier, user); // We return the ID of the document..65 return(newDoc.Id); }
private documentCarrier createCarrier(Document doc) { documentCarrier carrier = new documentCarrier(); carrier.ExpireDate = doc.ExpireDate; carrier.ReleaseDate = doc.ReleaseDate; carrier.Id = doc.Id; carrier.Name = doc.Text; try { carrier.ParentID = doc.Parent.Id; } catch { } carrier.Published = doc.Published; carrier.HasChildren = doc.HasChildren; var props = doc.GenericProperties; foreach (umbraco.cms.businesslogic.property.Property prop in props) { documentProperty carrierprop = new documentProperty(); if (prop.Value == System.DBNull.Value) { carrierprop.PropertyValue = null; } else { carrierprop.PropertyValue = prop.Value; } carrierprop.Key = prop.PropertyType.Alias; carrier.DocumentProperties.Add(carrierprop); } return carrier; }
private void handlePublishing(Document doc, documentCarrier carrier, umbraco.BusinessLogic.User user) { switch (carrier.PublishAction) { case documentCarrier.EPublishAction.Publish: if (doc.PublishWithResult(user)) { umbraco.library.UpdateDocumentCache(doc); } break; case documentCarrier.EPublishAction.Unpublish: if (doc.PublishWithResult(user)) { umbraco.library.UnPublishSingleNode(doc); } break; case documentCarrier.EPublishAction.Ignore: if (doc.Published) { if (doc.PublishWithResult(user)) { umbraco.library.UpdateDocumentCache(doc); } } else { if (doc.PublishWithResult(user)) { umbraco.library.UpdateDocumentCache(doc); } } break; } }
public void update(documentCarrier carrier, string username, string password) { Authenticate(username, password); if (carrier.Id == 0) throw new Exception("ID must be specifed when updating"); if (carrier == null) throw new Exception("No carrier specified"); umbraco.BusinessLogic.User user = GetUser(username, password); Document doc = null; try { doc = new Document(carrier.Id); } catch { } if (doc == null) // We assign the new values: doc.ReleaseDate = carrier.ReleaseDate; doc.ExpireDate = carrier.ExpireDate; if (carrier.ParentID != 0) { doc.Move(carrier.ParentID); } if (carrier.Name.Length != 0) { doc.Text = carrier.Name; } // We iterate the properties in the carrier if (carrier.DocumentProperties != null) { foreach (documentProperty updatedproperty in carrier.DocumentProperties) { umbraco.cms.businesslogic.property.Property property = doc.getProperty(updatedproperty.Key); if (property == null) { } else { property.Value = updatedproperty.PropertyValue; } } } handlePublishing(doc, carrier, user); }