本文整理汇总了C#中Kooboo.CMS.Common.JsonResultData.AddErrorMessage方法的典型用法代码示例。如果您正苦于以下问题:C# JsonResultData.AddErrorMessage方法的具体用法?C# JsonResultData.AddErrorMessage怎么用?C# JsonResultData.AddErrorMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Kooboo.CMS.Common.JsonResultData
的用法示例。
在下文中一共展示了JsonResultData.AddErrorMessage方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishPage
public ActionResult PublishPage(RemotePagePublishingModel model, string @return)
{
var resultEntry = new JsonResultData(ModelState);
if (ModelState.IsValid)
{
if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue)
{
resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty.".Localize());
}
else
{
foreach (string uuid in model.Pages)
{
foreach (string endpoint in model.RemoteEndPoints)
{
var queue = new RemotePublishingQueue()
{
PublishingObject = PublishingObject.Page,
SiteName = Site.Name,
UserId = User.Identity.Name,
UtcCreationDate = DateTime.UtcNow,
RemoteEndpoint = endpoint,
ObjectUUID = uuid,
ObjectTitle = uuid,
Status = QueueStatus.Pending
};
if (model.Schedule)
{
if (model.UtcTimeToPublish.HasValue)
{
queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
}
if (model.UtcTimeToUnpublish.HasValue)
{
queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
}
}
else
{
queue.UtcTimeToPublish = DateTime.UtcNow;
}
resultEntry.RunWithTry((data) =>
{
_manager.Add(queue);
});
}
}
resultEntry.RedirectUrl = @return;
}
}
return Json(resultEntry);
}
示例2: PublishPage
public ActionResult PublishPage(LocalPagePublishingModel model, string @return)
{
var resultEntry = new JsonResultData(ModelState);
if (ModelState.IsValid)
{
if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue)
{
resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty".Localize());
}
else if (model.Schedule)
{
foreach (string uuid in model.Pages)
{
var queue = new LocalPublishingQueue()
{
PublishingObject = PublishingObject.Page,
SiteName = Site.Name,
UserId = User.Identity.Name,
UtcCreationDate = DateTime.UtcNow,
ObjectUUID = uuid,
ObjectTitle = uuid,
Status = QueueStatus.Pending
};
if (model.UtcTimeToPublish.HasValue)
{
queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
}
if (model.UtcTimeToUnpublish.HasValue)
{
queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
}
resultEntry.RunWithTry((data) =>
{
_manager.Add(queue);
});
}
resultEntry.RedirectUrl = @return;
}
else
{
foreach (string uuid in model.Pages)
{
var page = new Page(Site, uuid);
Kooboo.CMS.Sites.Services.ServiceFactory.PageManager.Publish(page, false, false, false, DateTime.UtcNow, DateTime.UtcNow, User.Identity.Name);
}
resultEntry.RedirectUrl = @return;
}
}
return Json(resultEntry);
}
示例3: PublishTextContent
public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel model, string @return)
{
if (model.TextFolderMappings == null || model.TextFolderMappings.Length == 0)
{
ModelState.AddModelError("TextFolderMappings", "Required".Localize());
}
var resultEntry = new JsonResultData(ModelState);
if (ModelState.IsValid)
{
if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue)
{
resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty.");
}
else
{
TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual();
for (int i = 0, j = model.TextContents.Length; i < j; i++)
{
var content = textFolder.CreateQuery().WhereEquals("UUID", model.TextContents[i]).FirstOrDefault();
if (content != null)
{
foreach (string mapping in model.TextFolderMappings)
{
var queue = new RemotePublishingQueue()
{
PublishingObject = PublishingObject.TextContent,
SiteName = Site.Name,
UserId = User.Identity.Name,
UtcCreationDate = DateTime.UtcNow,
TextFolderMapping = mapping,
ObjectUUID = content.IntegrateId,
ObjectTitle = model.ObjectTitles[i],
Status = QueueStatus.Pending
};
if (model.Schedule)
{
if (model.UtcTimeToPublish.HasValue)
{
queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
}
if (model.UtcTimeToUnpublish.HasValue)
{
queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
}
}
else
{
queue.UtcTimeToPublish = DateTime.UtcNow;
}
resultEntry.RunWithTry((data) =>
{
_manager.Add(queue);
});
}
}
}
resultEntry.RedirectUrl = @return;
}
}
return Json(resultEntry);
}
示例4: PublishTextContent
public ActionResult PublishTextContent(CreateTextContentPublishingQueueViewModel model, string @return)
{
var resultEntry = new JsonResultData(ModelState);
if (ModelState.IsValid)
{
if (model.Schedule && !model.UtcTimeToPublish.HasValue && !model.UtcTimeToUnpublish.HasValue)
{
resultEntry.AddErrorMessage("UtcTimeToPublish and UtcTimeToUnpublish can not be both empty".Localize());
}
else if (model.Schedule)
{
TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual();
for (int i = 0, j = model.TextContents.Length; i < j; i++)
{
var content = textFolder.CreateQuery().WhereEquals("UUID", model.TextContents[i]).FirstOrDefault();
var queue = new LocalPublishingQueue(Site, Kooboo.UniqueIdGenerator.GetInstance().GetBase32UniqueId(10))
{
PublishingObject = PublishingObject.TextContent,
UserId = User.Identity.Name,
UtcCreationDate = DateTime.UtcNow,
ObjectUUID = content.IntegrateId,
ObjectTitle = model.ObjectTitles[i],
Status = QueueStatus.Pending
};
if (model.UtcTimeToPublish.HasValue)
{
queue.UtcTimeToPublish = model.UtcTimeToPublish.Value.ToUniversalTime();
}
if (model.UtcTimeToUnpublish.HasValue)
{
queue.UtcTimeToUnpublish = model.UtcTimeToUnpublish.Value.ToUniversalTime();
}
resultEntry.RunWithTry((data) =>
{
_manager.Add(queue);
});
}
resultEntry.RedirectUrl = @return;
}
else
{
TextFolder textFolder = new TextFolder(Repository.Current, model.LocalFolderId).AsActual();
foreach (string uuid in model.TextContents)
{
Kooboo.CMS.Content.Services.ServiceFactory.TextContentManager.Update(textFolder, uuid, "Published", true, User.Identity.Name);
}
resultEntry.RedirectUrl = @return;
}
}
return Json(resultEntry);
}
示例5: Publish
public virtual ActionResult Publish(string siteName)
{
if(string.IsNullOrWhiteSpace(siteName))
throw new ArgumentNullException("siteName");
var site = SiteHelper.Parse(siteName);
if (site == null)
throw new NullReferenceException("site");
site = site.AsActual();
var rootSite = SiteHelper.GetRootSite(site).AsActual();
if (string.IsNullOrWhiteSpace(rootSite.ClientId))
throw new Exception("Customer ID is not specified".Localize());
var ip = rootSite.FrontendDefaultIp;
var path = Path.Combine(site.PhysicalPath, rootSite.FrontendPhysicalPath);
var protocol = rootSite.FrontendDefaultProtocol;
var port = rootSite.FrontendDefaultPort;
var appPoolName = rootSite.FrontendDefaultApplicationPoolName;
var name = site.UID; //string.Format("Frontend.{0}.{1}", rootSite.ClientId, siteName);
//Chek domain name
//
if (site.Domains == null || site.Domains.Length == 0)
{
var result = new JsonResultData(ModelState);
result.AddErrorMessage("Before publish site you must specify the domain name (System/Settings/Domain/Domains)".Localize());
return Json(result);
}
try
{
//Create web site
//
IISHelper.CreateWebSite(appPoolName, name, protocol, ip, site.Domains.ToArray(), port, path);
}
catch (Exception e)
{
var result = new JsonResultData();
result.AddException(new Exception("Fail to publication.".Localize() + " " + e.Message, e));
return Json(result);
}
//Result
//
var data = new JsonResultData(ModelState);
data.ReloadPage = true;
return Json(data);
}