Exemplo n.º 1
0
        /// <summary>
        /// Initialize instance of Roles tabbed document.
        /// </summary>
        /// <param name="project">string: Project name.</param>
        public Roles(MainForm parent, string project)
        {
            if (project.Length == 0)
                throw new System.ArgumentNullException("You must provide a valid project name.");
            _ParentForm = parent;
            projectName = project;
            this.Text = project + " - [Roles]";

            //  Initialize components
            InitializeComponent();
            dataTable = new iCampaign.TACS.Data.RolesDs.RolesDataTable();
            tableAdapter = new iCampaign.TACS.Data.RolesDsTableAdapters.RolesTableAdapter();
            tableAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);
            GetRecord();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initialize instance of the project tabbed document.
        /// </summary>
        /// <param name="parent">MainForm: object.</param>
        /// <param name="aid">long: Account id.</param>
        public Project(MainForm parent, long aid)
        {
            //  Initialize properties
            acctId = aid;
            _ParentForm = parent;
            dataTable = new iCampaign.TACS.Data.ProjectsDs.ProjectsDataTable();
            tableAdapter = new iCampaign.TACS.Data.ProjectsDsTableAdapters.ProjectsTableAdapter();
            tableAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);
            appTable = new iCampaign.TACS.Data.ApplicationsDs.ApplicationsDataTable();
            appTableAdapter = new iCampaign.TACS.Data.ApplicationsDsTableAdapters.ApplicationsTableAdapter();
            appTableAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);
            roleTable = new iCampaign.TACS.Data.RolesDs.RolesDataTable();
            roleAdapter = new iCampaign.TACS.Data.RolesDsTableAdapters.RolesTableAdapter();
            roleAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);

            //  Initialize tabbed document controls
            InitializeComponent();
            InitializeDocument();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initialize instance of the project tabbed document.
        /// </summary>
        /// <param name="parent">MainForm: object.</param>
        /// <param name="proj">string: Project name.</param>
        public Project(MainForm parent, long aid, string proj)
        {
            //  Check the arguments
            if (proj.Length == 0)
            {
                throw new System.ArgumentException("You must provide an project name value.");
            }
            else
            {
                project = proj;
                acctId = aid;
            }

            //  Initialize properties
            _ParentForm = parent;
            dataTable = new iCampaign.TACS.Data.ProjectsDs.ProjectsDataTable();
            tableAdapter = new iCampaign.TACS.Data.ProjectsDsTableAdapters.ProjectsTableAdapter();
            tableAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);
            appTable = new iCampaign.TACS.Data.ApplicationsDs.ApplicationsDataTable();
            appTableAdapter = new iCampaign.TACS.Data.ApplicationsDsTableAdapters.ApplicationsTableAdapter();
            appTableAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);
            roleTable = new iCampaign.TACS.Data.RolesDs.RolesDataTable();
            roleAdapter = new iCampaign.TACS.Data.RolesDsTableAdapters.RolesTableAdapter();
            roleAdapter.Connection = new System.Data.SqlClient.SqlConnection(TacsSession.ConnectionString);

            //  Initialize tabbed document controls
            InitializeComponent();
            InitializeDocument();
            GetRecord();
        }
Exemplo n.º 4
0
        /// <summary>
        /// Add a new security role to the specified project.
        /// </summary>
        /// <param name="newRole">iCampaign.TACS.Role: object.</param>
        /// <param name="role">string: Caller role being used.</param>
        /// <param name="credentials">iCampaign.TACS.Client.Credentials: object.</param>
        public string AddRole(Role newRole, string role, Credentials credentials)
        {
            string result = String.Empty;
            bool errorStatus = false;

            //  Check to see if user has sufficient access
            if (!credentials.HasAccess(role, AccessLevelEnum.Owner) || credentials.AccountOwner)
            {
                errorStatus = true;
                result = TacsSession.MSG_INSUFPRIV;
            }

            //  Check for valid session token
            if (!TacsSession.IsTokenValid(credentials.Username, credentials.SessionToken))
            {
                errorStatus = true;
                result = TacsSession.MSG_INVALSESS;
            }

            //  Verify that a role name was provided
            if (newRole.Name.Length == 0)
            {
                errorStatus = true;
                result = TacsSession.MSG_INVALROLE;
            }

            //  If no error condition exists, go ahead and add the new role
            if (!errorStatus)
            {
                Data.RolesDs.RolesDataTable rolesTable = new RolesDs.RolesDataTable();
                Data.RolesDs.RolesRow rolesRow = rolesTable.NewRolesRow();
                Data.RolesDsTableAdapters.RolesTableAdapter tableAdapter =
                    new iCampaign.TACS.Data.RolesDsTableAdapters.RolesTableAdapter();
                tableAdapter.Connection = new SqlConnection(TacsSession.ConnectionString);
                try
                {
                    rolesRow.RoleName = newRole.Name;
                    rolesRow.AccessLevel = (int)newRole.AccessLevel;
                    rolesTable.AddRolesRow(rolesRow);
                    tableAdapter.Connection.Open();
                    tableAdapter.Update(rolesTable);
                    result = TacsSession.MSG_SUCCESS;
                }
                catch (Exception ex)
                {
                    errorStatus = true;
                    result = ex.Message;
                }
                finally
                {
                    tableAdapter.Connection.Close();
                }
            }

            return result;
        }