private void createButton_Click(object sender, System.EventArgs e)
        {
            Page.Validate();

            if (Page.IsValid)
            {
                try
                {
                    // Create toolkit instance
                    InterfacesToolkit toolkit = new InterfacesToolkit(session);

                    ToolkitResult addressResult = toolkit.CreateAddress(address1.Text, city.Text,
                                                                        state.SelectedValue, zip.Text, country.SelectedValue, timeZone.SelectedValue);

                    // Create setup parameter object with min required parameters.
                    CreateSiteSetup setup = new CreateSiteSetup(SiteType.Customer, SiteStatus.Active, addressResult.Objid);

                    // Set any additional information for creating the site
                    setup.SiteName  = siteName.Text;
                    setup.SiteIDNum = session.GetNextNumScheme("Site ID");

                    // Actually create the site
                    ToolkitResult result = toolkit.CreateSite(setup);

                    ResetFormData();
                    message.Text = "Site created successfully with IDNum '" + result.IDNum + "'.";
                }
                catch (Exception ex)
                {
                    message.Text = ex.Message;
                }
            }
        }
Exemplo n.º 2
0
        public string[] GenerateEmployees(int count)
        {
            var ds          = new ClarifyDataSet(_session);
            var privGeneric = ds.CreateGeneric("privclass");

            var privClass    = Guid.NewGuid().ToString();
            var privClassRow = privGeneric.AddNew();

            privClassRow["class_name"]  = privClass;
            privClassRow["access_mask"] = "FFFFFFF FFFF FFFFTFFFFFF FF FF FFFFFF FFF";
            privClassRow["trans_mask"]  = new string('1', 255);
            privClassRow["member_type"] = "Employee";
            privClassRow.Update();

            var interfacesToolkit = new InterfacesToolkit(_session);
            var addressObjId      = interfacesToolkit.CreateAddress("123 street", "Austin", "TX", "78759", "USA", "CST").Objid;

            var siteSetup = new CreateSiteSetup(SiteType.Customer, SiteStatus.Active, addressObjId)
            {
                SiteIDNum = _session.GetNextNumScheme("Site ID"),
                SiteName  = Guid.NewGuid().ToString()
            };

            var siteResult = interfacesToolkit.CreateSite(siteSetup);
            var employees  = new List <string>();

            for (var i = 0; i < count; i++)
            {
                var login = "******".ToFormat(Guid.NewGuid().ToString("N").Substring(0, 10));
                var email = "{0}@test.dovetailsoftware.com".ToFormat(login);

                var createEmployeeSetup = new CreateEmployeeSetup("Employee " + i, "Dovetail", login,
                                                                  "password", siteResult.IDNum, email, "CSR")
                {
                    WorkGroup    = "Quality Engineer",
                    IsActive     = true,
                    Phone        = randomString(10),
                    IsSupervisor = false
                };


                var createEmployeeResult = interfacesToolkit.CreateEmployee(createEmployeeSetup);
                _instructions.Add(new CleanupInstruction("employee", createEmployeeResult.Objid));

                var userId = (int)new SqlHelper("SELECT employee2user FROM table_employee WHERE objid = {0}".ToFormat(createEmployeeResult.Objid)).ExecuteScalar();
                _instructions.Add(new CleanupInstruction("user", userId));

                employees.Add(login);
            }

            _instructions.Add(new CleanupInstruction("site", siteResult.Objid));
            _instructions.Add(new CleanupInstruction("privclass", privClassRow.DatabaseIdentifier()));

            return(employees.ToArray());
        }
        private void createButton_Click(object sender, System.EventArgs e)
        {
            Page.Validate();

            if(Page.IsValid)
            {
                try
                {
                    // Create toolkit instance
                    InterfacesToolkit toolkit = new InterfacesToolkit( session );

                    ToolkitResult addressResult = toolkit.CreateAddress(address1.Text, city.Text,
                        state.SelectedValue, zip.Text, country.SelectedValue, timeZone.SelectedValue);

                    // Create setup parameter object with min required parameters.
                    CreateSiteSetup setup = new CreateSiteSetup(SiteType.Customer,SiteStatus.Active, addressResult.Objid);

                    // Set any additional information for creating the site
                    setup.SiteName = siteName.Text;
                    setup.SiteIDNum = session.GetNextNumScheme("Site ID");

                    // Actually create the site
                    ToolkitResult result = toolkit.CreateSite( setup );

                    ResetFormData();
                    message.Text = "Site created successfully with IDNum '" + result.IDNum + "'.";
                }
                catch(Exception ex)
                {
                    message.Text = ex.Message;
                }
            }
        }