private void SaveEntriesForActivity(string activityId, IList <ActivityEntry> entries) { if (CollectionUtils.IsNullOrEmpty(entries)) { return; } object[] insertValues = new object[5]; DoBulkInsert(DETAIL_TABLE_NAME, "Id;ActivityId;Detail;ModifiedOn;OrderIndex", delegate(int currentInsertIndex) { if (currentInsertIndex < entries.Count) { ActivityEntry entry = entries[currentInsertIndex]; insertValues[0] = IdProvider.Get(); insertValues[1] = activityId; insertValues[2] = LimitDbText(entry.Message, MAX_DETAIL_CHARS); insertValues[3] = entry.TimeStamp; insertValues[4] = currentInsertIndex; return(insertValues); } else { return(null); } }); }
public void Save(DataFlow item) { if (item == null) { throw new ArgumentException("Null item"); } DateTime now = DateTime.Now; string id = null; if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, "Id;InfoUrl;Contact;IsProtected;ModifiedBy;ModifiedOn;Code;Description", id, item.InfoUrl, item.ContactUserId, DbUtils.ToDbBool(item.IsProtected), item.ModifiedById, now, item.FlowName, item.Description); } else { DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), "InfoUrl;Contact;IsProtected;ModifiedBy;ModifiedOn;Code;Description", item.InfoUrl, item.ContactUserId, DbUtils.ToDbBool(item.IsProtected), item.ModifiedById, now, item.FlowName, item.Description); } if (id != null) { item.Id = id; } item.ModifiedOn = now; }
public PluginItem SavePlugin(PluginItem item, byte[] zippedBinary) { ExceptionUtils.ThrowIfNull(item, "item"); ExceptionUtils.ThrowIfNull(zippedBinary, "zippedBinary"); string insertColumns = MAP_PLUGIN_COLUMNS + ";ZippedBinary"; string binaryVersion = item.BinaryVersion.ToSortableString(); DateTime now = DateTime.Now; string id = null; if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, insertColumns, id, item.FlowId, binaryVersion, item.ModifiedById, now, zippedBinary); } else { DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), insertColumns, item.Id, item.FlowId, binaryVersion, item.ModifiedById, now, zippedBinary); } if (id != null) { item.Id = id; } item.ModifiedOn = now; return(item); }
private void SaveRequestedFlows(string requestId, IList <AccountAuthorizationRequestFlow> requestedFlows) { if (CollectionUtils.IsNullOrEmpty(requestedFlows)) { return; } object[] insertValues = new object[4]; DoBulkInsert(FLOW_TABLE_NAME, "Id;AccountAuthRequestId;FlowName;AccessGranted", delegate(int currentInsertIndex) { if (currentInsertIndex < requestedFlows.Count) { AccountAuthorizationRequestFlow flow = requestedFlows[currentInsertIndex]; if (string.IsNullOrEmpty(flow.Id)) { flow.Id = IdProvider.Get(); } insertValues[0] = flow.Id; insertValues[1] = requestId; insertValues[2] = flow.FlowName; insertValues[3] = DbUtils.ToDbBool(flow.AccessGranted); return(insertValues); } else { return(null); } }); }
/// <summary> /// Save() /// </summary> public void Save(DataProviderInfo item) { if (item == null) { throw new ArgumentException("Null item"); } DateTime now = DateTime.Now; string id = null; if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, "Id;Code;Provider;ConnectionString;ModifiedBy;ModifiedOn", id, item.Name, item.ProviderType, item.ConnectionString, item.ModifiedById, now); } else { DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), "Code;Provider;ConnectionString;ModifiedBy;ModifiedOn", item.Name, item.ProviderType, item.ConnectionString, item.ModifiedById, now); } if (id != null) { item.Id = id; } item.ModifiedOn = now; }
/// <summary> /// Save() /// </summary> public void Save(PartnerIdentity item) { if (item == null) { throw new ArgumentException("Null item"); } DateTime now = DateTime.Now; string id = null; if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, "Id;Name;Url;ModifiedBy;ModifiedOn;Version", id, item.Name, item.Url, item.ModifiedById, now, item.Version.ToString()); } else { DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), "Name;Url;ModifiedBy;ModifiedOn;Version", item.Name, item.Url, item.ModifiedById, now, item.Version.ToString()); } if (id != null) { item.Id = id; } item.ModifiedOn = now; }
private void SavePoliciesForUser(string accountId, IList <UserAccessPolicy> policies) { if (CollectionUtils.IsNullOrEmpty(policies)) { return; } DateTime now = DateTime.Now; object[] insertValues = new object[7]; DoBulkInsert(POLICY_TABLE_NAME, "Id;AccountId;Type;Qualifier;IsAllowed;ModifiedBy;ModifiedOn", delegate(int currentInsertIndex) { if (currentInsertIndex < policies.Count) { UserAccessPolicy policy = policies[currentInsertIndex]; if (string.IsNullOrEmpty(policy.Id)) { policy.Id = IdProvider.Get(); policy.ModifiedOn = now; } else if (policy.ModifiedOn == default(DateTime)) { policy.ModifiedOn = now; } policy.AccountId = accountId; insertValues[0] = policy.Id; insertValues[1] = policy.AccountId; insertValues[2] = policy.PolicyType.ToString(); insertValues[3] = policy.TypeQualifier; switch (policy.FlowRoleType) { case FlowRoleType.Endpoint: insertValues[4] = "Y"; break; case FlowRoleType.View: insertValues[4] = "V"; break; case FlowRoleType.Modify: insertValues[4] = "M"; break; default: insertValues[4] = "N"; break; } insertValues[5] = policy.ModifiedById; insertValues[6] = policy.ModifiedOn; return(insertValues); } else { return(null); } }); }
public void Save(UserAccount item) { if (item == null) { throw new ArgumentException("Null item"); } DateTime now = DateTime.Now; string id = null; #if DEBUG if (item.NaasAccount.StartsWith("uid=")) { DebugUtils.CheckDebuggerBreak(); } #endif // DEBUG // Check to see if this user already exists if (string.IsNullOrEmpty(item.Id)) { string existingUserId = GetUserIdByName(item.NaasAccount); if (existingUserId != null) { item.Id = existingUserId; } } TransactionTemplate.Execute(delegate { // Update user account table if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, "Id;NAASAccount;IsActive;SystemRole;ModifiedBy;ModifiedOn;IsDeleted", id, item.NaasAccount, DbUtils.ToDbBool(item.IsActive), item.Role.ToString(), item.ModifiedById, now, DbUtils.ToDbBool(false)); } else { id = item.Id; DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), "NAASAccount;IsActive;SystemRole;ModifiedBy;ModifiedOn", item.NaasAccount, DbUtils.ToDbBool(item.IsActive), item.Role.ToString(), item.ModifiedById, now); } // Update policies DeleteAllPoliciesForUser(id); if (item.Role != SystemRoleType.Admin) { SavePoliciesForUser(id, item.Policies); } return(null); }); if (string.IsNullOrEmpty(item.Id)) { item.Id = id; } item.ModifiedOn = now; }
/// <summary> /// Create a node notification. /// </summary> public string CreateNotification(string transactionId, ComplexNotification notification) { string id = IdProvider.Get(); string notifyData = _serializationHelper.SerializeToBase64String(notification); DoInsert(TABLE_NAME, "Id;TransactionId;NotifyData", id, transactionId, notifyData); return(id); }
/// <summary> /// Persist the input data service instance. If the data service already exists, it is updated; otherwise, /// it is created. /// </summary> public void Save(DataService item) { if (item == null) { throw new ArgumentNullException("item"); } DateTime now = DateTime.Now; string id = null; TransactionTemplate.Execute(delegate { try { string implementerString = (item.PluginInfo != null) ? item.PluginInfo.ImplementerString : string.Empty; string authLevel = ServiceRequestAuthorizationType.Basic.ToString(); if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, "Id;Name;FlowId;IsActive;ServiceType;Implementor;AuthLevel;ModifiedBy;ModifiedOn;PublishFlags", id, item.Name, item.FlowId, DbUtils.ToDbBool(item.IsActive), item.Type.ToString(), implementerString, authLevel, item.ModifiedById, now, item.PublishFlags.ToString()); item.Id = id; } else { DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), "Name;FlowId;IsActive;ServiceType;Implementor;AuthLevel;ModifiedBy;ModifiedOn;PublishFlags", item.Name, item.FlowId, DbUtils.ToDbBool(item.IsActive), item.Type.ToString(), implementerString, authLevel, item.ModifiedById, now, item.PublishFlags.ToString()); } SaveServiceArgs(item); SaveServiceDataSources(item); return(null); } catch (Exception) { if (id != null) { item.Id = string.Empty; } throw; } }); if (id != null) { item.Id = id; } item.ModifiedOn = now; }
public void Save(AccountAuthorizationRequest item) { if (item == null) { throw new ArgumentException("Null item"); } string id = null; TransactionTemplate.Execute(delegate { string authorizationAccountId = null, authorizationComments = null; DateTime authorizationGeneratedOn = DbUtils.DB_MIN_DATE; string didCreateInNaas = null; if (item.Response != null) { authorizationAccountId = item.Response.AuthorizationAccountId; authorizationComments = item.Response.AuthorizationComments; authorizationGeneratedOn = item.Response.AuthorizationGeneratedOn; didCreateInNaas = DbUtils.ToDbBool(item.Response.DidCreateInNaas); } if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, MAP_AUTH_REQUEST_COLUMNS, id, item.TransactionId, item.RequestGeneratedOn, item.RequestType, item.NaasAccount, item.FullName, item.OrganizationAffiliation, item.TelephoneNumber, item.EmailAddress, item.AffiliatedNodeId, item.AffiliatedCounty, item.PurposeDescription, StringUtils.Join(",", item.RequestedNodeIds), authorizationAccountId, authorizationComments, authorizationGeneratedOn, didCreateInNaas); } else { id = item.Id; DoSimpleUpdateOne(TABLE_NAME, "Id", id, MAP_AUTH_REQUEST_COLUMNS, id, item.TransactionId, item.RequestGeneratedOn, item.RequestType, item.NaasAccount, item.FullName, item.OrganizationAffiliation, item.TelephoneNumber, item.EmailAddress, item.AffiliatedNodeId, item.AffiliatedCounty, item.PurposeDescription, StringUtils.Join(",", item.RequestedNodeIds), authorizationAccountId, authorizationComments, authorizationGeneratedOn, didCreateInNaas); } // Update flow requests DeleteAllFlowsForRequest(id); SaveRequestedFlows(id, item.RequestedFlows); return(null); }); if (string.IsNullOrEmpty(item.Id)) { item.Id = id; } }
private void SaveAndRun(ScheduledItem item, bool?runNow) { if (item == null) { throw new ArgumentException("Null item"); } DateTime now = DateTime.Now; string id = null; bool isRunNow = runNow.HasValue ? runNow.Value : false; string columnNames = "Name;FlowId;StartOn;EndOn;SourceType;SourceId;SourceFlow;SourceOperation;TargetType;" + "TargetId;TargetFlow;TargetOperation;LastExecuteActivityId;LastExecutedOn;NextRun;" + "FrequencyType;Frequency;ModifiedBy;ModifiedOn;IsActive;IsRunNow;ExecuteStatus"; List <object> columnValues = CollectionUtils.CreateList <object>(item.Name, item.FlowId, DbUtils.ToDbDate(item.StartOn), DbUtils.ToDbDate(item.EndOn), item.SourceType.ToString(), item.SourceId, item.SourceFlow ?? string.Empty, item.SourceRequest ?? string.Empty, item.TargetType.ToString(), item.TargetId, item.TargetFlow ?? string.Empty, item.TargetRequest ?? string.Empty, item.LastExecuteActivityId, DbUtils.ToDbDate(item.LastExecutedOn), DbUtils.ToDbDate(item.NextRunOn), item.FrequencyType.ToString(), item.Frequency, item.ModifiedById, now, DbUtils.ToDbBool(item.IsActive), DbUtils.ToDbBool(isRunNow), item.ExecuteStatus.ToString()); if (AreEndpointUsersEnabled) { columnNames += ";SourceEndpointUser;TargetEndpointUser"; columnValues.AddRange(new object[] { item.SourceEndpointUser, item.TargetEndpointUser }); } TransactionTemplate.Execute(delegate { if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); columnNames = "Id;" + columnNames; columnValues.Insert(0, id); DoInsertWithValues(TABLE_NAME, columnNames, columnValues); } else { DoSimpleUpdateOneWithValues(TABLE_NAME, "Id", item.Id, columnNames, columnValues); } SaveScheduleSourceArgs(id ?? item.Id, item.SourceArgs); return(null); }); if (id != null) { item.Id = id; } item.ModifiedOn = now; }
/// <summary> /// Create a new data request according to the input parameters and return the /// data request id. /// </summary> public string CreateDataRequest(string transactionId, string serviceId, int rowIndex, int maxRowCount, RequestType type, string userCreatorId, ByIndexOrNameDictionary <string> parameters) { string requestId = IdProvider.Get(); TransactionTemplate.Execute(delegate { DoInsert(TABLE_NAME, "Id;TransactionId;ServiceId;RowIndex;MaxRowCount;RequestType;ModifiedBy;ModifiedOn;ParamsByName", requestId, transactionId, serviceId, rowIndex, maxRowCount, type.ToString(), userCreatorId, DateTime.Now, DbUtils.ToDbBool((parameters == null) ? true : parameters.IsByName)); if (!CollectionUtils.IsNullOrEmpty(parameters)) { object[] insertValues = new object[4]; DoBulkInsert(ARGS_TABLE_NAME, "Id;RequestId;ArgName;ArgValue", delegate(int currentInsertIndex) { if (currentInsertIndex < parameters.Count) { insertValues[0] = IdProvider.Get(); insertValues[1] = requestId; if (parameters.IsByName) { insertValues[2] = parameters.KeyAtIndex(currentInsertIndex); } else { insertValues[2] = currentInsertIndex.ToString("D3"); } insertValues[3] = parameters[currentInsertIndex]; return(insertValues); } return(null); }); } return(null); }); return(requestId); }
private void SaveServiceDataSources(DataService item) { TransactionTemplate.Execute(delegate { DoSimpleDelete(SOURCES_TABLE_NAME, "ServiceId", new object[] { item.Id }); if (CollectionUtils.IsNullOrEmpty(item.DataSources)) { return(null); } using (IEnumerator <KeyValuePair <string, DataProviderInfo> > enumeratorObj = item.DataSources.GetEnumerator()) { object[] insertValues = new object[4]; object enumeratorObject = enumeratorObj; // NOTE: Boxing here so that value-type enumerator works // in anonymous delegate DoBulkInsert(SOURCES_TABLE_NAME, "Id;ServiceId;ConnectionId;KeyName", delegate(int currentInsertIndex) { IEnumerator <KeyValuePair <string, DataProviderInfo> > enumerator = (IEnumerator <KeyValuePair <string, DataProviderInfo> >)enumeratorObject; if (enumerator.MoveNext()) { insertValues[0] = IdProvider.Get(); insertValues[1] = item.Id; insertValues[2] = enumerator.Current.Value.Id; insertValues[3] = enumerator.Current.Key; enumeratorObject = enumerator; return(insertValues); } else { return(null); } }); } return(null); }); }
private void SaveNotificationsForUser(string userId, string modifiedByUserId, IList <KeyValuePair <string, NotificationType> > notifications) { if (CollectionUtils.IsNullOrEmpty(notifications)) { return; } DateTime now = DateTime.Now; object[] insertValues = new object[12]; DoBulkInsert(TABLE_NAME, "Id;FlowId;AccountId;OnSolicit;OnQuery;OnSubmit;OnNotify;OnSchedule;OnDownload;OnExecute;ModifiedBy;ModifiedOn", delegate(int currentInsertIndex) { if (currentInsertIndex < notifications.Count) { KeyValuePair <string, NotificationType> notification = notifications[currentInsertIndex]; NotificationType type = notification.Value; insertValues[0] = IdProvider.Get(); insertValues[1] = notification.Key; insertValues[2] = userId; insertValues[3] = DbUtils.ToDbBool((type & NotificationType.OnSolicit) != 0); insertValues[4] = DbUtils.ToDbBool((type & NotificationType.OnQuery) != 0); insertValues[5] = DbUtils.ToDbBool((type & NotificationType.OnSubmit) != 0); insertValues[6] = DbUtils.ToDbBool((type & NotificationType.OnNotify) != 0); insertValues[7] = DbUtils.ToDbBool((type & NotificationType.OnSchedule) != 0); insertValues[8] = DbUtils.ToDbBool((type & NotificationType.OnDownload) != 0); insertValues[9] = DbUtils.ToDbBool((type & NotificationType.OnExecute) != 0); insertValues[10] = modifiedByUserId; insertValues[11] = now; return(insertValues); } else { return(null); } }); }
private void SaveScheduleSourceArgs(string scheduleId, ByIndexOrNameDictionary <string> args) { TransactionTemplate.Execute(delegate { DoSimpleDelete(SOURCE_ARGS_TABLE_NAME, "ScheduleId", new object[] { scheduleId }); if (CollectionUtils.IsNullOrEmpty(args)) { return(null); } object[] insertValues = new object[4]; DoBulkInsert(SOURCE_ARGS_TABLE_NAME, "Id;ScheduleId;Name;Value", delegate(int currentInsertIndex) { if (currentInsertIndex < args.Count) { insertValues[0] = IdProvider.Get(); insertValues[1] = scheduleId; if (args.IsByName) { insertValues[2] = currentInsertIndex.ToString(cIndexFormatString) + args.KeyAtIndex(currentInsertIndex); } else { insertValues[2] = currentInsertIndex.ToString(cIndexFormatString); } insertValues[3] = string.IsNullOrEmpty(args[currentInsertIndex]) ? (object)DBNull.Value : (object)args[currentInsertIndex]; return(insertValues); } else { return(null); } }); return(null); }); }
public void Save(Activity item) { if (item == null) { throw new ArgumentException("Null item"); } DateTime now = DateTime.Now; string id = null; #if DEBUG if (CollectionUtils.IsNullOrEmpty(item.Entries)) { DebugUtils.CheckDebuggerBreak(); } #endif // DEBUG if (!string.IsNullOrEmpty(item.TransactionId)) { if (string.IsNullOrEmpty(item.FlowName) || string.IsNullOrEmpty(item.Operation) || (item.Method == NodeMethod.None)) { NodeMethod method; string operation; string flowName = _transactionDao.GetTransactionFlowName(item.TransactionId, out method, out operation); if (string.IsNullOrEmpty(item.FlowName)) { item.FlowName = flowName; } if (string.IsNullOrEmpty(item.Operation)) { item.Operation = operation; } if (item.Method == NodeMethod.None) { item.Method = method; } } } TransactionTemplate.Execute(delegate { // Update user account table if (string.IsNullOrEmpty(item.Id)) { id = IdProvider.Get(); DoInsert(TABLE_NAME, "Id;Type;TransactionId;IP;ModifiedBy;ModifiedOn;WebMethod;FlowName;Operation", id, item.Type.ToString(), item.TransactionId, item.IP, item.ModifiedById, now, item.Method.ToString(), item.FlowName, item.Operation); } else { id = item.Id; DoSimpleUpdateOne(TABLE_NAME, "Id", item.Id.ToString(), "Type;TransactionId;IP;ModifiedBy;ModifiedOn;WebMethod;FlowName;Operation", item.Type.ToString(), item.TransactionId, item.IP, item.ModifiedById, now, item.Method.ToString(), item.FlowName, item.Operation); DeleteAllEntriesForActivity(id); } // Update policies SaveEntriesForActivity(id, item.Entries); return(null); }); if (string.IsNullOrEmpty(item.Id)) { item.Id = id; } item.ModifiedOn = now; }