/// <summary>
        /// Action <code>ActionAddress_CreateOrUpdate</code> that represents the Service Studio user action
        ///  <code>Address_CreateOrUpdate</code> <p> Description: This action creates or updates the give
        /// n address.</p>
        /// </summary>
        public static void ActionAddress_CreateOrUpdate(HeContext heContext, ENAddressEntityRecord inParamAddressR, out long outParamAddressId)
        {
            lcoAddress_CreateOrUpdate result    = new lcoAddress_CreateOrUpdate();
            lcvAddress_CreateOrUpdate localVars = new lcvAddress_CreateOrUpdate(inParamAddressR);

            try {
                // new address?
                if (((localVars.inParamAddressR.ssId == Convert.ToInt64(BuiltInFunction.NullIdentifier()))))
                {
                    // creation info
                    // AddressR.Active = True
                    localVars.inParamAddressR.ssActive = true;
                    // AddressR.CreatedDate = CurrDateTime
                    localVars.inParamAddressR.ssCreatedDate = BuiltInFunction.CurrDateTime();
                    // AddressR.CreatedBy = GetUserId
                    localVars.inParamAddressR.ssCreatedBy = BuiltInFunction.GetUserId();
                }

                // update info
                // AddressR.LastUpdatedDate = CurrDateTime
                localVars.inParamAddressR.ssLastUpdatedDate = BuiltInFunction.CurrDateTime();
                // AddressR.LastUpdatedBy = GetUserId
                localVars.inParamAddressR.ssLastUpdatedBy = BuiltInFunction.GetUserId();
                // CreateOrUpdateAddress
                ExtendedActions.CreateOrUpdateAddress(heContext, localVars.inParamAddressR.ChangedAttributes, (((RCAddressRecord)localVars.inParamAddressR)), out localVars.resCreateOrUpdateAddress_outParamId);

                // AddressId = CreateOrUpdateAddress.Id
                result.outParamAddressId = localVars.resCreateOrUpdateAddress_outParamId;
            }             // try

            finally {
                outParamAddressId = result.outParamAddressId;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Action <code>ActionAddressType_GetOrCreateByLabel</code> that represents the Service Studio user
        ///  action <code>AddressType_GetOrCreateByLabel</code> <p> Description: Gets or creates the addres
        /// s type for that label.</p>
        /// </summary>
        public static void ActionAddressType_GetOrCreateByLabel(HeContext heContext, string inParamLabel, out long outParamAddressTypeId)
        {
            lcoAddressType_GetOrCreateByLabel result    = new lcoAddressType_GetOrCreateByLabel();
            lcvAddressType_GetOrCreateByLabel localVars = new lcvAddressType_GetOrCreateByLabel(inParamLabel);

            try {
                // Query datasetGetAddressTypesByLabel
                int datasetGetAddressTypesByLabel_maxRecords = 0;
                localVars.queryResGetAddressTypesByLabel_outParamList = FuncActionAddressType_GetOrCreateByLabel.datasetGetAddressTypesByLabel(heContext, datasetGetAddressTypesByLabel_maxRecords, IterationMultiplicity.Never, out localVars.queryResGetAddressTypesByLabel_outParamCount, localVars.inParamLabel
                                                                                                                                               );

                // exists?
                if (((!localVars.queryResGetAddressTypesByLabel_outParamList.Empty)))
                {
                    // AddressTypeId = GetAddressTypesByLabel.List.Current.AddressType.Id
                    result.outParamAddressTypeId = localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType.ssId;
                }
                else
                {
                    // set AddressType
                    // GetAddressTypesByLabel.List.Current.AddressType.Label = Label
                    localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType.ssLabel = localVars.inParamLabel;
                    // GetAddressTypesByLabel.List.Current.AddressType.Active = True
                    localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType.ssActive = true;
                    // GetAddressTypesByLabel.List.Current.AddressType.CreatedDate = CurrDateTime
                    localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType.ssCreatedDate = BuiltInFunction.CurrDateTime();
                    // GetAddressTypesByLabel.List.Current.AddressType.CreatedBy = GetUserId
                    localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType.ssCreatedBy = BuiltInFunction.GetUserId();
                    // GetAddressTypesByLabel.List.Current.AddressType.LastUpdatedDate = CurrDateTime
                    localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType.ssLastUpdatedDate = BuiltInFunction.CurrDateTime();
                    // GetAddressTypesByLabel.List.Current.AddressType.LastUpdatedBy = GetUserId
                    localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType.ssLastUpdatedBy = BuiltInFunction.GetUserId();
                    // CreateAddressType
                    ExtendedActions.CreateAddressType(heContext, (((RCAddressTypeRecord)localVars.queryResGetAddressTypesByLabel_outParamList.CurrentRec.ssENAddressType)), out localVars.resCreateAddressType_outParamId);

                    // AddressTypeId = CreateAddressType.Id
                    result.outParamAddressTypeId = localVars.resCreateAddressType_outParamId;
                }
            }             // try

            finally {
                outParamAddressTypeId = result.outParamAddressTypeId;
            }
        }
Esempio n. 3
0
        public static int CreateProcessInstance(HeContext heContext, int tenantId, ObjectKey espaceSSKey, ObjectKey processSSKey, int parentActivityId, int parentProcessId, out Pair <int, ObjectKey> startActivity)
        {
            int       startActivityId;
            ObjectKey activityDefKey;
            int       newProcessId;

            using (Transaction trans = DatabaseAccess.ForSystemDatabase.GetRequestTransaction()) {
                int processDefId = 0;
                int topProcessId = 0;
                int createdBy    = 0;

                using (IDataReader reader = DBRuntimePlatform.Instance.GetProcessDefinition(trans, processSSKey, espaceSSKey)) {
                    if (reader.Read())
                    {
                        processDefId = reader.SafeGet <int>("ID");
                    }
                    else
                    {
                        throw new DataBaseException("No process definition exists with key '" + processSSKey + "'.");
                    }
                }


                if (parentActivityId != BuiltInFunction.NullIdentifier())
                {
                    int parentTenantId;
                    parentProcessId = DBRuntimePlatform.Instance.GetParentProcessId(trans, parentActivityId, out parentTenantId);
                }

                if (parentProcessId != BuiltInFunction.NullIdentifier())
                {
                    topProcessId = DBRuntimePlatform.Instance.GetTopProcessId(trans, parentProcessId);
                }
                else
                {
                    // Is not sub-process so we need to set the CreatedBy field
                    createdBy = heContext.Session.UserId;
                }

                newProcessId = DBRuntimePlatform.Instance.CreateProcess(trans, tenantId, BuiltInFunction.CurrDateTime(), createdBy, processDefId, parentProcessId, parentActivityId, topProcessId, ProcessStatus.Active);

                int    activityDefId = 0;
                string activityDefName;

                using (IDataReader reader = DBRuntimePlatform.Instance.GetActivityDefinitionsForKind(trans, newProcessId, ActivityKind.Start)) {
                    if (reader.Read())
                    {
                        activityDefId   = reader.SafeGet <int>("ID");
                        activityDefKey  = ObjectKey.Parse(reader.SafeGet <string>("SS_KEY"));
                        activityDefName = reader.SafeGet <string>("NAME", string.Empty);
                    }
                    else
                    {
                        throw new DataBaseException("No active " + ActivityKind.Start.ToString() + " activity exists for process #" + newProcessId + ".");
                    }
                }

                startActivityId = CreateActivityInstance(heContext, trans, tenantId, activityDefId, newProcessId, activityDefName, 0, null);
            }

            startActivity = Pair.Create(startActivityId, activityDefKey);

            return(newProcessId);
        }