protected static FR_L5DO_GUSfAUID_1246 Execute(DbConnection Connection, DbTransaction Transaction, P_L5DO_GUSfAUID_1246 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_L5DO_GUSfAUID_1246(); returnValue.Result = new L5DO_GUSfAUID_1246(); #region ORM_CMN_Account_ApplicationSubscription var query2 = new ORM_CMN_Account_ApplicationSubscription.Query(); query2.Application_RefID = Parameter.ApplicationID; query2.Tenant_RefID = securityTicket.TenantID; query2.Account_RefID = Parameter.CurrentUserID; query2.IsDeleted = false; query2.IsDisabled = false; var hasSubscription = ORM_CMN_Account_ApplicationSubscription.Query.Exists(Connection, Transaction, query2); returnValue.Result.HasSubscription = hasSubscription; #endregion return(returnValue); #endregion UserCode }
protected static FR_L6US_GAUTDfT_1343_Array Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6US_GAUTDfT_1343_Array(); //Put your code here List <L6US_GAUTDfT_1343> tempResult = new List <L6US_GAUTDfT_1343>(); var tempUsers = cls_Get_UsersBasicInfo_for_TenantID.Invoke(Connection, Transaction, securityTicket).Result; ORM_CMN_Account_ApplicationSubscription.Query appSubscriptionQuery = new ORM_CMN_Account_ApplicationSubscription.Query(); Guid ApplicationID = Guid.Parse(WebConfigurationManager.AppSettings["ApplicationID"].ToString()); foreach (var currentUser in tempUsers) { L6US_GAUTDfT_1343 tempResultItem = new L6US_GAUTDfT_1343(); tempResultItem.User_ID = currentUser.USR_AccountID; tempResultItem.User_FirsName = currentUser.FirstName; tempResultItem.User_LastName = currentUser.LastName; tempResultItem.User_Email = currentUser.PrimaryEmail; P_L5US_GARfAID_1319 userRightsParameter = new P_L5US_GARfAID_1319(); userRightsParameter.Account_ID = tempResultItem.User_ID; tempResultItem.User_AccountRights = cls_Get_AccountRights_for_AccountID.Invoke(Connection, Transaction, userRightsParameter, securityTicket).Result; L6US_GAMDMDfAU_1317a tempUser = new L6US_GAMDMDfAU_1317a(); appSubscriptionQuery.Account_RefID = currentUser.USR_AccountID; appSubscriptionQuery.IsDeleted = false; appSubscriptionQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Account_ApplicationSubscription> tempSubscriptionResult = ORM_CMN_Account_ApplicationSubscription.Query.Search(Connection, Transaction, appSubscriptionQuery); if (tempSubscriptionResult != null && tempSubscriptionResult.Count > 0) { tempResultItem.User_HasAccessToApp = tempSubscriptionResult.Exists(ts => ts.Application_RefID == ApplicationID && !ts.IsDisabled); } else { tempResultItem.User_HasAccessToApp = false; } tempResultItem.IsAdmin = false; tempResultItem.IsManager = false; tempResultItem.IsDeveloper = false; tempResult.Add(tempResultItem); } returnValue.Result = tempResult.ToArray(); return(returnValue); #endregion UserCode }
protected static FR_L2AS_GUSfA_1609 Execute(DbConnection Connection, DbTransaction Transaction, P_L2AS_GUSfA_1609 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L2AS_GUSfA_1609(); returnValue.Result = new L2AS_GUSfA_1609(); var hasSubscription = false; var isTenantSubscribed = false; #region ORM_CMN_Tenant_ApplicationSubscription var query1 = new ORM_CMN_Tenant_ApplicationSubscription.Query(); query1.Application_RefID = Parameter.ApplicationID; query1.Tenant_RefID = securityTicket.TenantID; query1.IsDeleted = false; query1.IsDisabled = false; var subscription = ORM_CMN_Tenant_ApplicationSubscription.Query.Search(Connection, Transaction, query1); if (subscription.Count() == 0) { returnValue.Result.HasSubscription = false; returnValue.Result.IsTenantSubscribed = false; return(returnValue); } isTenantSubscribed = true; #endregion #region ORM_CMN_Account_ApplicationSubscription var query2 = new ORM_CMN_Account_ApplicationSubscription.Query(); query2.Application_RefID = subscription.First().Application_RefID; query2.Tenant_RefID = securityTicket.TenantID; query2.Account_RefID = securityTicket.AccountID; query2.IsDeleted = false; query2.IsDisabled = false; hasSubscription = ORM_CMN_Account_ApplicationSubscription.Query.Exists(Connection, Transaction, query2); returnValue.Result.HasSubscription = hasSubscription; returnValue.Result.IsTenantSubscribed = isTenantSubscribed; returnValue.Result.Configuration = subscription.FirstOrDefault().Configuration; #endregion return(returnValue); #endregion UserCode }
protected static FR_Guid Execute(DbConnection Connection, DbTransaction Transaction, P_L5US_SSU_1847 Parameter, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { //Leave UserCode region to enable user code saving #region UserCode var returnValue = new FR_Guid(); var userAccount = new ORM_USR_Account(); var result = userAccount.Load(Connection, Transaction, Parameter.USR_AccountID); if (result.Status == FR_Status.Success) { //Get business participant via userAccount var businessParticipant = new ORM_CMN_BPT_BusinessParticipant(); businessParticipant.Load(Connection, Transaction, userAccount.BusinessParticipant_RefID); //Load person var personInfo = new ORM_CMN_PER_PersonInfo(); personInfo.Load(Connection, Transaction, businessParticipant.IfNaturalPerson_CMN_PER_PersonInfo_RefID); //Load communication contacts for person P_L2CN_GCCfPI_1222 contactsParam = new P_L2CN_GCCfPI_1222(); contactsParam.PersonInfoID = personInfo.CMN_PER_PersonInfoID; var contactsForPersonInfo = cls_Get_ComunicationContacts_for_PersonInfoID.Invoke(Connection, Transaction, contactsParam, securityTicket).Result.ToList(); if (!Parameter.IsInitialSave) { if (Parameter.IsDeleted) { #region Delete var queryApplicationSubscription = new ORM_CMN_Account_ApplicationSubscription.Query(); queryApplicationSubscription.Application_RefID = Parameter.ApplicationID; queryApplicationSubscription.Account_RefID = userAccount.USR_AccountID; queryApplicationSubscription.Tenant_RefID = securityTicket.TenantID; var foundApplicationSubscription = ORM_CMN_Account_ApplicationSubscription.Query.SoftDelete(Connection, Transaction, queryApplicationSubscription); return(new FR_Guid(FR_Base.Status_OK, userAccount.USR_AccountID)); #endregion } #region Edit personInfo.FirstName = Parameter.FirstName_ContactPerson; personInfo.LastName = Parameter.LastName_ContactPerson; personInfo.Save(Connection, Transaction); var employeeTemp = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee.Query() { BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (employeeTemp == null) { var newEmployee = new ORM_CMN_BPT_EMP_Employee(); newEmployee.CMN_BPT_EMP_EmployeeID = Guid.NewGuid(); newEmployee.BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; newEmployee.StandardFunction = "APOAdminEmployee"; newEmployee.Tenant_RefID = securityTicket.TenantID; newEmployee.Save(Connection, Transaction); } var address = new ORM_CMN_Address(); address.Load(Connection, Transaction, personInfo.Address_RefID); address.Street_Name = Parameter.Street_Name; address.Street_Number = Parameter.Street_Number; address.City_Name = Parameter.Town; address.City_PostalCode = Parameter.ZIP; address.Save(Connection, Transaction); try { //telephone var telephone = contactsForPersonInfo.Where(i => i.Type == EnumUtils.GetEnumDescription(EComunactionContactType.Phone)) .First().Contacts; if (telephone.Count() == 1) { var contactID = telephone[0].CMN_PER_CommunicationContactID; var contactTelephone = new ORM_CMN_PER_CommunicationContact(); contactTelephone.Load(Connection, Transaction, contactID); contactTelephone.Content = Parameter.Contact_Telephone; contactTelephone.Save(Connection, Transaction); } } catch { //Log this } #region CommentedUsefull-PreviousWayOfContactEmailHandling //try //{ // //email // var email = contactsForPersonInfo.Where(i => i.Type == EnumUtils.GetEnumDescription(EComunactionContactType.Email)) // .First().Contacts; // if (email.Count() == 1) // { // var contactID = email[0].CMN_PER_CommunicationContactID; // var contactEmail = new ORM_CMN_PER_CommunicationContact(); // contactEmail.Load(Connection, Transaction, contactID); // contactEmail.Content = Parameter.Contact_Email; // contactEmail.Save(Connection, Transaction); // } //} //catch //{ // //Log this //} #endregion #endregion } #region SaveGroup var userAccountToGroup = ORM_USR_Account_2_Group.Query.Search(Connection, Transaction, new ORM_USR_Account_2_Group.Query() { USR_Account_RefID = userAccount.USR_AccountID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (userAccountToGroup == null) { var newGroup = new ORM_USR_Account_2_Group(); newGroup.AssignmentID = Guid.NewGuid(); newGroup.USR_Account_RefID = userAccount.USR_AccountID; newGroup.USR_Group_RefID = Parameter.USR_GroupID; newGroup.Creation_Timestamp = DateTime.Now; newGroup.Tenant_RefID = securityTicket.TenantID; newGroup.Save(Connection, Transaction); } else { userAccountToGroup.USR_Group_RefID = Parameter.USR_GroupID; userAccountToGroup.Save(Connection, Transaction); } #endregion #region SaveEmployee var employee = ORM_CMN_BPT_EMP_Employee.Query.Search(Connection, Transaction, new ORM_CMN_BPT_EMP_Employee.Query() { BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID, Tenant_RefID = securityTicket.TenantID, IsDeleted = false }).SingleOrDefault(); if (employee == null) { var newEmployee = new ORM_CMN_BPT_EMP_Employee(); newEmployee.CMN_BPT_EMP_EmployeeID = Guid.NewGuid(); newEmployee.BusinessParticipant_RefID = businessParticipant.CMN_BPT_BusinessParticipantID; newEmployee.StandardFunction = "APOAdminEmployee"; newEmployee.Tenant_RefID = securityTicket.TenantID; newEmployee.Save(Connection, Transaction); } #endregion #region CreateOrUpdateContactEmail var emailTypeProperty = EnumUtils.GetEnumDescription(EComunactionContactType.Email); var contactEmailTypeQuery = new ORM_CMN_PER_CommunicationContact_Type.Query(); contactEmailTypeQuery.Type = emailTypeProperty; contactEmailTypeQuery.Tenant_RefID = securityTicket.TenantID; var contactEmailType = ORM_CMN_PER_CommunicationContact_Type.Query.Search(Connection, Transaction, contactEmailTypeQuery).FirstOrDefault(); //Search for default contact email and create it if don't exist var defaultContactEmailQuery = new ORM_CMN_PER_CommunicationContact.Query(); defaultContactEmailQuery.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; defaultContactEmailQuery.Contact_Type = contactEmailType.CMN_PER_CommunicationContact_TypeID; defaultContactEmailQuery.Tenant_RefID = securityTicket.TenantID; var defaultContactEmail = ORM_CMN_PER_CommunicationContact.Query.Search(Connection, Transaction, defaultContactEmailQuery).FirstOrDefault(); if (defaultContactEmail == null) { defaultContactEmail = new ORM_CMN_PER_CommunicationContact(); defaultContactEmail.PersonInfo_RefID = personInfo.CMN_PER_PersonInfoID; defaultContactEmail.Contact_Type = contactEmailType.CMN_PER_CommunicationContact_TypeID; defaultContactEmail.IsDefaultForContactType = true; defaultContactEmail.Tenant_RefID = securityTicket.TenantID; } defaultContactEmail.Content = Parameter.Contact_Email; defaultContactEmail.IsDefaultForContactType = true; defaultContactEmail.Save(Connection, Transaction); #endregion } else { FR_Guid error = new FR_Guid(); error.ErrorMessage = "No Such ID."; error.Status = FR_Status.Error_Internal; return(error); } return(new FR_Guid(FR_Base.Status_OK, userAccount.USR_AccountID)); #endregion UserCode }
protected static FR_L6US_GAMDMDfAU_1317 Execute(DbConnection Connection, DbTransaction Transaction, CSV2Core.SessionSecurity.SessionSecurityTicket securityTicket = null) { #region UserCode var returnValue = new FR_L6US_GAMDMDfAU_1317(); //Put your code here L6US_GAMDMDfAU_1317 tempResult = new L6US_GAMDMDfAU_1317(); Guid ApplicationID = Guid.Parse(WebConfigurationManager.AppSettings["ApplicationID"].ToString()); List <L6US_GAMDMDfAU_1317a> tempUsers = new List <L6US_GAMDMDfAU_1317a>(); //Retrieve users ORM_USR_Account.Query userQuery = new ORM_USR_Account.Query(); userQuery.Tenant_RefID = securityTicket.TenantID; userQuery.IsDeleted = false; List <ORM_USR_Account> resultUsers = ORM_USR_Account.Query.Search(Connection, Transaction, userQuery); ORM_CMN_Account_ApplicationSubscription.Query appSubscriptionQuery = new ORM_CMN_Account_ApplicationSubscription.Query(); foreach (var currentUser in resultUsers) { L6US_GAMDMDfAU_1317a tempUser = new L6US_GAMDMDfAU_1317a(); appSubscriptionQuery.Account_RefID = currentUser.USR_AccountID; appSubscriptionQuery.IsDeleted = false; appSubscriptionQuery.Tenant_RefID = securityTicket.TenantID; List <ORM_CMN_Account_ApplicationSubscription> tempSubscriptionResult = ORM_CMN_Account_ApplicationSubscription.Query.Search(Connection, Transaction, appSubscriptionQuery); if (tempSubscriptionResult != null && tempSubscriptionResult.Count > 0) { tempUser.User_IsSubscribed = tempSubscriptionResult.Exists(ts => ts.Application_RefID == ApplicationID && !ts.IsDisabled); } else { tempUser.User_IsSubscribed = false; } tempUsers.Add(tempUser); } tempResult.ActiveUsers = tempUsers.ToArray(); ORM_TMS_PRO_Project.Query projectsQuery = new ORM_TMS_PRO_Project.Query(); projectsQuery.Tenant_RefID = securityTicket.TenantID; projectsQuery.IsDeleted = false; projectsQuery.IsArchived = false; tempResult.ProjectsCount = ORM_TMS_PRO_Project.Query.Search(Connection, Transaction, projectsQuery).Count; ORM_TMS_QuickTask_Type.Query quickTaskQuery = new ORM_TMS_QuickTask_Type.Query(); quickTaskQuery.Tenant_RefID = securityTicket.TenantID; quickTaskQuery.IsDeleted = false; tempResult.WorkingTimeTypesCount = ORM_TMS_QuickTask_Type.Query.Search(Connection, Transaction, quickTaskQuery).Count; ORM_TMS_PRO_DeveloperTask_Priority.Query developerTaskPrioritiesQuery = new ORM_TMS_PRO_DeveloperTask_Priority.Query(); developerTaskPrioritiesQuery.Tenant_RefID = securityTicket.TenantID; developerTaskPrioritiesQuery.IsDeleted = false; tempResult.DeveloperTaskPrioritiesCount = ORM_TMS_PRO_DeveloperTask_Priority.Query.Search(Connection, Transaction, developerTaskPrioritiesQuery).Count; ORM_TMP_PRO_ProjectMember_Type.Query projectMemberTypeQuery = new ORM_TMP_PRO_ProjectMember_Type.Query(); projectMemberTypeQuery.Tenant_RefID = securityTicket.TenantID; projectMemberTypeQuery.IsDeleted = false; tempResult.ProjectMemberTypesCount = ORM_TMP_PRO_ProjectMember_Type.Query.Search(Connection, Transaction, projectMemberTypeQuery).Count; //ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query chargingLevelQuery = new ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query(); //chargingLevelQuery.Tenant_RefID = securityTicket.TenantID; //chargingLevelQuery.IsDeleted = false; //tempResult.PriceGradesCount = ORM_CMN_BPT_InvestedWorkTime_ChargingLevel.Query.Search(Connection, Transaction, chargingLevelQuery).Count; tempResult.PriceGradesCount = cls_Get_PriceGrades_for_Tenant.Invoke(Connection, Transaction, securityTicket).Result.ToList().Count; tempResult.PlannedProjectsCount = 6; returnValue.Result = tempResult; return(returnValue); #endregion UserCode }