/// <summary> /// Add a new project to an account in the TACS.NET database. /// </summary> /// <param name="project">iCampaign.TACS.ProjectProfile: object.</param> /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param> /// <returns>string: Status message.</returns> internal string AddProject(ProjectProfile project, Credentials credentials) { bool errorStatus = false; string result = String.Empty; // Check to see if user has sufficient privilege if (!credentials.AccountOwner) { result = TacsSession.MSG_INSUFPRIV; errorStatus = true; } // If no error exists, create the database objects and insert the record if (!errorStatus) { Data.ProjectsDs.ProjectsDataTable projectTable = new ProjectsDs.ProjectsDataTable(); Data.ProjectsDs.ProjectsRow row = projectTable.NewProjectsRow(); Data.ProjectsDsTableAdapters.ProjectsTableAdapter tableAdapter = new iCampaign.TACS.Data.ProjectsDsTableAdapters.ProjectsTableAdapter(); tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString); try { tableAdapter.Connection.Open(); row.AcctId = credentials.AccountId; row.AppCode = project.ApplicationCode; row.ConnectorType = project.ConnectorType.ToString(); row.CreatedOn = DateTime.Now; row.Database = project.Database; row.DataSource = project.DataSource; row.Password = project.Password; row.Project = project.Project; row.Username = project.Username; projectTable.AddProjectsRow(row); tableAdapter.Update(projectTable); } catch (Exception ex) { errorStatus = true; result = ex.Message; } finally { tableAdapter.Connection.Close(); } } if (!errorStatus) result = TacsSession.MSG_SUCCESS; return result; }
/// <summary> /// Get project profile from TACS.NET database for specified project. /// </summary> /// <param name="project">string: Project name.</param> /// <param name="role">string: Caller role being used.</param> /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param> /// <returns>iCampaign.TACS.ProjectProfile: object.</returns> internal ProjectProfile GetProject(string project, string role, iCampaign.TACS.Client.Credentials credentials) { bool errorStatus = false; ProjectProfile result = new ProjectProfile(); // Check to see if user has sufficient access if (!credentials.HasAccess(role, AccessLevelEnum.Owner)) { errorStatus = true; result.ErrorMessage = TacsSession.MSG_INSUFPRIV; } // Check for valid session token if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken)) { errorStatus = true; result.ErrorMessage = TacsSession.MSG_INVALSESS; } // Check to see if project is valid if (!errorStatus) { if (!TacsSession.IsProjectValid(credentials.ApplicationCode, project)) { errorStatus = true; result.ErrorMessage = TacsSession.MSG_UNKPROJECT; } } // If no error exists, go ahead and get project profile if (!errorStatus) { Data.ProjectsDs.ProjectsDataTable projectTable = new ProjectsDs.ProjectsDataTable(); Data.ProjectsDsTableAdapters.ProjectsTableAdapter tableAdapter = new iCampaign.TACS.Data.ProjectsDsTableAdapters.ProjectsTableAdapter(); Data.ProjectsDs.ProjectsRow row = null; tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString); try { tableAdapter.Connection.Open(); tableAdapter.FillByProject(projectTable, project); row = projectTable[0]; } catch (Exception ex) { result.ErrorMessage = ex.Message; errorStatus = true; } finally { tableAdapter.Connection.Close(); } if (!errorStatus) { result.Project = row.Project; result.ConnectorType = TacsSession.GetConnectorType(row.ConnectorType); result.DataSource = row.DataSource; result.Database = row.Database; result.Username = row.Username; result.Password = row.Password; result.CreatedOn = row.CreatedOn; result.ApplicationCode = row.AppCode; result.AccountId = row.AcctId; result.ErrorMessage = TacsSession.MSG_SUCCESS; } } return result; }