public virtual IHttpActionResult Delete(string id) { try { if (string.IsNullOrEmpty(id)) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, Messages.IdIsMissing))); } View view = GetView(null); if (view == null) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ViewNameNotFound, AppViewName)))); } if (!view.IsDeletable()) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, Messages.ViewIsUnauthorized))); } int?appId = Maps.Instance.AppExists(id, Convert.ToInt32(Maps.Instance.DuradosMap.Database.GetUserID())); if (!appId.HasValue) { return(ResponseMessage(Request.CreateResponse(HttpStatusCode.NotFound, string.Format(Messages.ItemWithIdNotFound, id, AppViewName)))); } string guid = GetMasterGuid(); string qstring = "id=" + guid; try { Durados.Web.Mvc.Infrastructure.ProductMaintenance productMaintenece = new Durados.Web.Mvc.Infrastructure.ProductMaintenance(); productMaintenece.RemoveApp(id); } catch (Exception exception) { Maps.Instance.DuradosMap.Logger.Log("myApps", "delete", id, exception, 1, "The app " + id + " has productMaintenece errors"); } //url = GetDeleteAppUrl(id); //string response = Durados.Web.Mvc.Infrastructure.Http.GetWebRequest(url,string.Empty,string.Empty, 100000); //Dictionary<string, object> ret = Durados.Web.Mvc.UI.Json.JsonSerializer.Deserialize(response); try { CronHelper.DeleteAllCrons(Maps.Instance.AppExists(id).Value.ToString()); } catch (Exception exception) { Maps.Instance.DuradosMap.Logger.Log("myApps", "delete", id, exception, 1, "Failed to delete all app crons"); } try { Webhook webhook = new Webhook(); try { webhook.Send(WebhookType.AppDeleted, GetBody(id, Maps.Instance.DuradosMap.Database.GetCurrentUsername())); Maps.Instance.DuradosMap.Logger.Log("webhook", "AppDeleted", this.Request.Method.Method, null, 3, null, DateTime.Now); } catch (Exception exception) { webhook.HandleException(WebhookType.AppDeleted, exception); } } catch { } string sql = "delete durados_App where name = '" + id + "'"; (new SqlAccess()).ExecuteNonQuery(Maps.Instance.DuradosMap.connectionString, sql); Maps.Instance.DuradosMap.Logger.Log("myApps", "delete", "", null, 1, "The app " + id + " was deleted"); //Maps.Instance.Restart(id); RestHelper.Refresh(id); FarmCachingSingeltone.Instance.ClearMachinesCache(id); //RefreshOldAdmin(id); return(Ok()); } catch (Exception exception) { throw new BackAndApiUnexpectedResponseException(exception, this); } }