protected override IEnumerable <ActionBase> CollectActions(SenseNet.ContentRepository.Content context, string backUrl) { var actList = new List <ActionBase>(); if (context == null) { return(actList); } actList.AddRange(base.CollectActions(context, backUrl)); var appApprove = ApplicationStorage.Instance.GetApplication("Approve", context, PortalContext.Current.DeviceName); var appEdit = ApplicationStorage.Instance.GetApplication("Edit", context, PortalContext.Current.DeviceName); var appDelete = ApplicationStorage.Instance.GetApplication("Delete", context, PortalContext.Current.DeviceName); var action = appApprove.CreateAction(context, backUrl, null); action.Text = "Approve"; actList.Add(action); action = appEdit.CreateAction(context, backUrl, null); action.Text = "Edit"; actList.Add(action); action = appDelete.CreateAction(context, backUrl, null); action.Text = "Delete"; actList.Add(action); return(actList); }
public static object CheckIndexIntegrity(SenseNet.ContentRepository.Content content, bool recurse) { var path = content == null ? null : content.Path; CompletionState completionState; using (var readerFrame = LuceneManager.GetIndexReaderFrame()) completionState = CompletionState.ParseFromReader(readerFrame.IndexReader); var lastDatabaseId = LuceneManager.GetLastStoredIndexingActivityId(); var channel = SenseNet.ContentRepository.DistributedApplication.ClusterChannel; var appDomainName = channel == null ? null : channel.ReceiverName; return(new { AppDomainName = appDomainName, LastStoredActivity = lastDatabaseId, LastProcessedActivity = completionState.LastActivityId, GapsLength = completionState.GapsLength, Gaps = completionState.Gaps, Differences = Check(path, recurse) }); }
public static bool isof(SenseNet.ContentRepository.Content c, string type) { return(c.ContentType.IsInstaceOfOrDerivedFrom(type)); }
public override object Execute(SenseNet.ContentRepository.Content content, params object[] parameters) { SenseNet.ContentRepository.Storage.Node.Copy(content.Path, (string)parameters[0]); return(null); }
private void CreateContent(HttpContext context) { try { //---- content type var contentTypeName = GetRequestParameter("contenttype"); if (String.IsNullOrEmpty(contentTypeName)) { WriteError("Parameter 'contenttype' cannot be null or empty.", context); return; } var contentType = ContentType.GetByName(contentTypeName); if (contentType == null) { WriteError("Content type not found: " + contentTypeName, context); return; } //---- create content var snPath = GetRequestParameter("snpath"); if (String.IsNullOrEmpty(snPath)) { WriteError("Parameter 'snpath' cannot be null or empty.", context); return; } using (new SenseNet.ContentRepository.Storage.Security.SystemAccount()) { BenchmarkCounter.Reset(); benchmarkTimer = Stopwatch.StartNew(); benchmarkTimer.Restart(); var parentPath = RepositoryPath.GetParentPath(snPath); BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.GetParentPath, benchmarkTimer.ElapsedTicks); benchmarkTimer.Restart(); var parent = Node.LoadNode(parentPath); if (parent == null) { WriteError("Cannot load the parent: " + snPath, context); return; } BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.LoadParent, benchmarkTimer.ElapsedTicks); benchmarkTimer.Restart(); var contentName = RepositoryPath.GetFileName(snPath); var content = SnContent.CreateNew(contentTypeName, parent, contentName); BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.ContentCreate, benchmarkTimer.ElapsedTicks); benchmarkTimer.Restart(); //---- create binary if (contentTypeName == "File") { var fsPath = GetRequestParameter("fspath"); if (String.IsNullOrEmpty(snPath)) { WriteError("Parameter 'fspath' cannot be null or empty if the content type is 'File'.", context); return; } using (var stream = context.Request.InputStream) { var binaryData = new BinaryData(); binaryData.FileName = fsPath; //.Replace("$amp;", "&"); binaryData.SetStream(stream); content["Binary"] = binaryData; BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.BinarySet, benchmarkTimer.ElapsedTicks); benchmarkTimer.Restart(); using (new SenseNet.ContentRepository.Storage.Security.SystemAccount()) content.Save(); } } else { BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.BinarySet, benchmarkTimer.ElapsedTicks); benchmarkTimer.Restart(); content.Save(); } BenchmarkCounter.IncrementBy(BenchmarkCounter.CounterName.FullSave, benchmarkTimer.ElapsedTicks); benchmarkTimer.Restart(); } } catch (Exception e) { //WriteError(String.Concat(e.Message, "\r", e.StackTrace), context); Logger.WriteException(e); WriteError(e, context); return; } WriteCounters(context); context.Response.StatusCode = 200; context.Response.Write("ok"); }