protected override void AfterCreateAfterCommit(Durados.CreateEventArgs e) { base.AfterCreateAfterCommit(e); if (Map.Database.AutoCommit) { RefreshConfigCache(); } }
protected override void BeforeCreate(Durados.CreateEventArgs e) { HandleFriendlyName(e); if (IsNodeJSFunction(e)) { CreateNodeJSFunction(e); } WriteToAnalytics(e); base.BeforeCreate(e); }
private void WriteToAnalytics(Durados.CreateEventArgs e) { try { string username = GetUsername(); Durados.WorkflowAction workflowAction = GetActionType(e); string name = GetActionName(e); string type = IsFunction(e) ? "function" : "action"; switch (workflowAction) { case Durados.WorkflowAction.NodeJS: SendAnalyticsInfo(username, "LambdaAdded", new Dictionary <string, object>() { { "rule", name }, { "type", type } }); break; case Durados.WorkflowAction.Lambda: SendAnalyticsInfo(username, "LambdaLinked", new Dictionary <string, object>() { { "rule", name }, { "type", type } }); break; //case Durados.WorkflowAction.JavaScript: // if (IsFunction(e)) // { // SendAnalyticsInfo(username, "AddedFunction", new Dictionary<string, object>() { { "rule", name } }); // } // else if (IsIntegration(e)) // { // SendAnalyticsInfo(username, "AddedIntegration", new Dictionary<string, object>() { { "rule", name } }); // } // else // { // SendAnalyticsInfo(username, "AddedRule", new Dictionary<string, object>() { { "rule", name } }); // } // break; default: break; } } catch { } }
private void CreateNodeJSFunction(Durados.CreateEventArgs e) { NodeJS nodeJS = new NodeJS(); string fileName = null; if (e.Values.ContainsKey(FileName)) { fileName = e.Values[FileName].ToString(); } string viewId = null; if (e.Values.ContainsKey("Rules_Parent")) { viewId = e.Values["Rules_Parent"].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)); } } string actionName = e.Values[Name].ToString(); string cloudProvider = GetCloudVendor(e.Values); if (fileName == null) { fileName = actionName + ".zip"; } string functionName = Map.AppName + "_" + viewName + "_" + actionName; string folder = Map.AppName + "/" + viewName + "/" + actionName; nodeJS.Create(Maps.NodeJSBucket, folder, fileName, functionName, "handler", "handler", cloudProvider); }
private void HandleFriendlyName(Durados.CreateEventArgs e) { string friendlyName = GetFriendlyName(e.Values); if (e.View.Name == "Rule") { if (e.Values.ContainsKey(friendlyNameFieldName) && (e.Values[friendlyNameFieldName] == null || e.Values[friendlyNameFieldName].ToString().Equals(string.Empty))) { e.Values[friendlyNameFieldName] = friendlyName; } else if (e.Values.ContainsKey(FriendlyNameFieldName) && (e.Values[FriendlyNameFieldName] == null || e.Values[FriendlyNameFieldName].ToString().Equals(string.Empty))) { e.Values[FriendlyNameFieldName] = friendlyName; } else { e.Values.Add(FriendlyNameFieldName, friendlyName); } } }
private bool IsNodeJSFunction(Durados.CreateEventArgs e) { return(IsNodeJSFunction(e.Values["WorkflowAction"])); }
private bool IsIntegration(Durados.CreateEventArgs e) { return(e.Values.ContainsKey(ActionType) && e.Values[ActionType] != null && e.Values[ActionType].Equals("Integration")); }