private void DeleteNodeJSFunction(Durados.DeleteEventArgs e) { NodeJS nodeJS = new NodeJS(); string ruleId = e.PrimaryKey; DataRow ruleRow = Map.GetConfigDatabase().Views[Rule].GetDataRow(ruleId); string viewId = ruleRow[Rules].ToString(); string viewName = null; if (viewId != null) { viewName = new ConfigAccess().GetViewNameByPK(viewId, Map.GetConfigDatabase().ConnectionString); if (string.IsNullOrEmpty(viewName)) { throw new Durados.DuradosException(string.Format(Messages.ViewNameNotFound, viewId)); } } else { throw new Durados.DuradosException(string.Format(Messages.ViewNameNotFound, string.Empty)); } string actionName = ruleRow[Name].ToString(); string functionName = Map.AppName + "_" + viewName + "_" + actionName; string folder = Map.AppName + "/" + viewName + "/" + actionName; nodeJS.Delete(folder, functionName); }
protected override void AfterDeleteAfterCommit(Durados.DeleteEventArgs e) { base.AfterDeleteAfterCommit(e); if (Map.Database.AutoCommit) { RefreshConfigCache(); } }
protected override void BeforeDelete(Durados.DeleteEventArgs e) { if (IsNodeJSFunction(e)) { DeleteNodeJSFunction(e); } base.BeforeDelete(e); }
protected override void AfterDeleteBeforeCommit(Durados.DeleteEventArgs e) { base.AfterDeleteBeforeCommit(e); string name = e.PrevRow["Name"].ToString(); Maps.Instance.Delete(name); try { int id = Convert.ToInt32(e.PrimaryKey); System.Data.SqlClient.SqlConnectionStringBuilder scsb = new System.Data.SqlClient.SqlConnectionStringBuilder(Maps.Instance.ConnectionString); string mapServer = scsb.DataSource; MapDataSet.durados_SqlConnectionRow systemConnectionRow = ((MapDataSet.durados_AppRow)e.PrevRow).durados_SqlConnectionRowByFK_durados_App_durados_SqlConnection_System; if (systemConnectionRow != null) { string systemServer = systemConnectionRow.IsServerNameNull() ? null : systemConnectionRow.ServerName; string systemDatabase = systemConnectionRow.IsCatalogNull() ? null : systemConnectionRow.Catalog; if (string.IsNullOrEmpty(systemServer) || systemServer.Equals(mapServer)) { DropDatabase(systemDatabase); } } MapDataSet.durados_SqlConnectionRow appConnectionRow = ((MapDataSet.durados_AppRow)e.PrevRow).durados_SqlConnectionRowByFK_durados_App_durados_SqlConnection; if (appConnectionRow != null) { string appServer = appConnectionRow.IsServerNameNull() ? null : appConnectionRow.ServerName; string appDatabase = appConnectionRow.IsCatalogNull() ? null : appConnectionRow.Catalog; if (string.IsNullOrEmpty(appServer) || appServer.Equals(mapServer)) { if (Maps.DropAppDatabase) { if (!HasOtherConnectios(appDatabase)) { DropDatabase(appDatabase); } } } } //DeleteConfig(id); //DeleteUploads(id); } catch (Exception exception) { Map.Logger.Log(GetControllerNameForLog(this.ControllerContext), "AfterDeleteBeforeCommit", exception.Source, exception, 2, "delete databases and config"); } }
private bool IsNodeJSFunction(Durados.DeleteEventArgs e) { DataRow ruleRow = Map.GetConfigDatabase().Views["Rule"].GetDataRow(e.PrimaryKey); return(IsNodeJSFunction(ruleRow["WorkflowAction"])); }