//private bool IsRouteFree(string url) { // // make sure URL is unique and does not conflict with a controller // foreach (Route route in RouteTable.Routes) { // if (url == route.Defaults["controller"].ToString().ToLower()) // return false; // if (url == route.Defaults["action"].ToString().ToLower()) // return false; // } // return true; //} private void Save(Models.Page record, bool isNew) { // add any code to update other fields/tables here //record.Fields.Picture.MetaData = record.GetMetaData(); record.Save(); //record.Resources.Save(); CheckLock(record); lockobj.UnLockTable(record.GetTableName(), record.ID); PageCache.Rebuild(); #if AutocompletePhrase AutocompletePhrase.AddPagePhrase(record); #endif // save subform or related checkboxes here eg record.Lines.Save(); }
private void Save(Models.Article record, bool isNew) { // add any code to update other fields/tables here record.DateAdded = DateTime.Now; record.Save(); // delete all keyword for this article and its related urls and documents. AutocompletePhrase.AddPhrase("Article", record.ID, record.MetaKeywords, true); // save subform or related checkboxes here eg record.Lines.Save(); //ifsubform: record.example.Save(); foreach (var articleDocument in record.ArticleDocuments) { BewebCore.ThirdParty.SearchTextExtractor.CheckAttachmentsForDocOrPDFText(articleDocument); } CheckLock(record); lockobj.UnLockTable(record.GetTableName(), record.ID); ArticleCache.Rebuild(); }
/// <summary> /// Deletes the given record or displays validation errors if cannot delete /// GET: /Admin/Article/Delete/5 /// </summary> public ActionResult Delete(int id, string returnPage) { var record = Models.Article.LoadID(id); // first delete any child records that are OK to delete //ifsubform: record.example.DeleteAll(); record.ArticleURLs.DeleteAll(false); record.ArticleDocuments.DeleteAll(false); // then prevent deletion if any other related records exist string issues = record.CheckForDependentRecords(); if (issues.IsNotBlank()) { Web.ErrorMessage = "Cannot delete this record. " + issues; return(RedirectToEdit(record.ID)); } CheckLock(record); lockobj.UnLockTable(record.GetTableName(), record.ID); //ifsubform: record.example.Save(); // is this needed? // delete the keywords DeletePhrase(string tableName, int recordID) { AutocompletePhrase.DeletePhrase("Article", record.ID); // do the same for the document titles foreach (var document in record.ArticleDocuments) { AutocompletePhrase.DeletePhrase("ArticleDocument", document.ID); } // do the same for the url titles foreach (var url in record.ArticleURLs) { AutocompletePhrase.DeletePhrase("ArticleURL", url.ID); } record.ArticleURLs.Save(); record.ArticleDocuments.Save(); record.Delete(); ArticleCache.Rebuild(); Web.InfoMessage = "Record deleted."; return(Redirect(returnPage)); }
public ActionResult RunDailyTasks() { Logging.dlog("RunDailyTasks"); Web.CacheClearAll(); // if there is anything to do every day, do it here #if AutocompletePhrase // re-do autocomplete phrases for expired content (assumes content tends to expire daily) AutocompletePhrase.AutocompletePhraseCleanup(); #endif #if ModificationLog //daily remove old mod logs if (BewebData.GetValueInt(new Sql("select count(*) from sys.objects where name like ", "ModificationLogTemp".SqlizeLike()), 0) > 0) { // remove the temp table if it exists new Sql("drop table ModificationLogTemp").Execute(); } var s = @" select * into ModificationLogTemp from ModificationLog where UpdateDate > getdate()-90; truncate table ModificationLog; set identity_insert ModificationLog ON; insert into ModificationLog ([ModificationLogID],[UpdateDate],[PersonID],[TableName],[RecordID],[ActionType],[UserName],[ChangeDescription],[RecordIDChar]) select [ModificationLogID],[UpdateDate],[PersonID],[TableName],[RecordID],[ActionType],[UserName],[ChangeDescription],[RecordIDChar] from ModificationLogTemp; set identity_insert ModificationLog OFF; drop table ModificationLogTemp"; new Sql(s).Execute(); #endif Logging.dlog("RunDailyTasks start"); //TASKS here //update the run time in the database Settings.All.ScheduledTaskLastDailyRunTime = DateTime.Now; Settings.All.Save(); //SendEMail.SendDeadLetter("RunDailyTasks",30); Logging.dlog("RunDailyTasks done"); return(Content("OK")); }