protected void DoesSiteExist(object source, ServerValidateEventArgs args)
        {
            ClarifyGeneric siteGeneric = dataSet.CreateGeneric("site");

            siteGeneric.AppendFilter("site_id", StringOps.Equals, args.Value);
            siteGeneric.Query();

            args.IsValid = siteGeneric.Rows.Count > 0;
        }
Beispiel #2
0
        private void modifyButton_Click(object sender, System.EventArgs e)
        {
            //	Create a generic to update user information
            ClarifyGeneric generic = dataSet.CreateGeneric(userTable);

            //  Query the record by the current users id
            generic.AppendFilter("objid", NumberOps.Equals, (int)session[userTable + ".id"]);

            //	Select the fields to include in the query
            generic.DataFields.Add("first_name");
            generic.DataFields.Add("last_name");
            generic.DataFields.Add("phone");

            //	Execute the query
            generic.Query();

            //	Update the values of the fields from the data on the page
            generic[0]["first_name"] = firstName.Text;
            generic[0]["last_name"]  = lastName.Text;
            generic[0]["phone"]      = phone.Text;

            //	Update the record in the database
            generic[0].Update();

            //	Refresh the session context
            session.RefreshContext();

            //	Reload the page to show updated data
            Response.Redirect("profile.aspx", true);
        }
        public override void DataBind()
        {
            base.DataBind ();

            //	Get the ClarifySession for the current user
            ClarifySession session = Global.GetFCSessionOrLogin();
            ClarifyDataSet dataSet = new ClarifyDataSet(session);

            //	Create a generic for the view "qry_case_view"
            ClarifyGeneric caseGeneric = dataSet.CreateGeneric("qry_case_view");

            //	Set the DataFields to return in the result set of the query
            caseGeneric.DataFields.AddRange(
                new string[]{"id_number","site_name","title","condition","status","creation_time","owner"} );

            //	Set the filter for query the records
            caseGeneric.AppendFilter( "owner", StringOps.Equals, session.UserName);
            caseGeneric.AppendFilter( "condition", StringOps.Like, "Open%");

            //	Set the sorting for the results
            caseGeneric.AppendSort( "creation_time", false );

            //	Query the results
            caseGeneric.Query();

            //	Set the datasource of the grid to the generic
            this.openCasesGrid.DataSource = caseGeneric;

            //	Build the DataGrid by calling DataBind()
            this.openCasesGrid.DataBind();
        }
Beispiel #4
0
        public override void DataBind()
        {
            base.DataBind();

            //	Get the ClarifySession for the current user
            ClarifySession session = Global.GetFCSessionOrLogin();
            ClarifyDataSet dataSet = new ClarifyDataSet(session);


            //	Create a generic for the view "qry_case_view"
            ClarifyGeneric caseGeneric = dataSet.CreateGeneric("qry_case_view");

            //	Set the DataFields to return in the result set of the query
            caseGeneric.DataFields.AddRange(
                new string[] { "id_number", "site_name", "title", "condition", "status", "creation_time", "owner" });

            //	Set the filter for querying the records
            caseGeneric.AppendFilter("creation_time", DateOps.MoreThanOrEqual, DateTime.Now.AddDays(DaysBack * -1));

            //	Set the sorting for the results
            caseGeneric.AppendSort("creation_time", false);

            //	Query the results
            caseGeneric.Query();

            //	Set the datasource of the grid to the generic
            this.casesCreatedGrid.DataSource = caseGeneric;

            //	Build the DataGrid by calling DataBind()
            this.casesCreatedGrid.DataBind();
        }
Beispiel #5
0
        private void addAddress_Click(object sender, System.EventArgs e)
        {
            if (this.address.Text.Trim().Length == 0)
            {
                MessageBox.Show("You must fill in the address.");
                this.address.Focus();
                return;
            }

            if (this.address2.Text.Trim().Length == 0)
            {
                MessageBox.Show("You must fill in the address 2.");
                this.address2.Focus();
                return;
            }

            if (this.city.Text.Trim().Length == 0)
            {
                MessageBox.Show("You must fill in the city.");
                this.city.Focus();
                return;
            }

            if (this.zipCode.Text.Trim().Length == 0)
            {
                MessageBox.Show("You must fill in the ZipCode.");
                this.zipCode.Focus();
                return;
            }

            //	Create new address generic
            ClarifyGeneric addressGen = dataSet.CreateGeneric("address");

            //	Add a new row to the address generic
            GenericDataRow addressRow = addressGen.AddNew();

            //	Set the values of the fields of the generic row
            addressRow["address"]      = address.Text.Trim();
            addressRow["address_2"]    = address2.Text.Trim();
            addressRow["city"]         = city.Text.Trim();
            addressRow["state"]        = state.SelectedItem.ToString().Trim();
            addressRow["city"]         = city.Text.Trim();
            addressRow["zipcode"]      = zipCode.Text.Trim();
            addressRow["update_stamp"] = session.GetCurrentDate();

            //	Relate this new row to existing records by relation and objid
            addressRow.RelateByID(FCApp.LocaleCache.GetCountryObjID(country.SelectedItem.ToString()), "address2country");
            addressRow.RelateByID(FCApp.LocaleCache.GetStateObjID(country.SelectedItem.ToString(), state.SelectedItem.ToString()), "address2state_prov");
            addressRow.RelateByID(FCApp.LocaleCache.GetTimeZoneObjID(timeZone.SelectedItem.ToString()), "address2time_zone");

            //	Commit the new row to the database
            addressRow.Update();

            MessageBox.Show("Address successfully added.");
        }
Beispiel #6
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());
        }
Beispiel #7
0
        public static ClarifyGeneric CreateGenericWithFields(this ClarifyDataSet dataSet, string objectName, params string[] fields)
        {
            if (fields == null || fields.Length < 1)
            {
                fields = new[] { "objid" }
            }
            ;

            var generic = dataSet.CreateGeneric(objectName);

            generic.DataFields.AddRange(fields);

            return(generic);
        }
    }
Beispiel #8
0
        static void Main(string[] args)
        {
            try
            {
                // Initialize ClarifyApplication
                FCApp = ClarifyApplication.Initialize();

                // Create a new ClarifySession
                ClarifySession sess = FCApp.CreateSession();

                //Create a new ClarifyDataSet
                ClarifyDataSet ds = new ClarifyDataSet(sess);

                //	Create a new ClarifyGeneric object for address records
                ClarifyGeneric generic = ds.CreateGeneric("address");

                //	Check for address xml file
                if (!File.Exists(ADDRESS_PATH))
                {
                    Console.WriteLine("Unable to find \"{0}\".", ADDRESS_PATH);
                    Console.WriteLine("Please ensure this file is in the same directory as the exe.");

                    //	Exit application
                    Console.WriteLine("Press Enter to exit...");
                    Console.ReadLine();
                    return;
                }

                //	Load address.xml into a XmlDocument
                XmlDocument doc = new XmlDocument();
                doc.Load(ADDRESS_PATH);

                //	Insert new address records into the database.
                InsertRecords(doc, generic);

                //	Exit application
                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine("There was an unhandled exception when running the demo.");
                Console.WriteLine();
                Console.WriteLine(ex);
            }
        }
Beispiel #9
0
        private void LoadModificationsIntoHashtableLookup(ModifierProtocol[] queryItems)
        {
            foreach (ModifierProtocol item in queryItems)
            {
                if (modifyItems.ContainsKey(item.Name))
                {
                    throw new InvalidOperationException(string.Format("Duplicate modification name '{0}'.", item.Name));
                }

                if (!ClarifyApplication.Instance.SchemaCache.IsValidTableOrView(item.Table))
                {
                    throw new InvalidOperationException(
                              string.Format("'{0}' is an invalid table name on modification item '{1}'.", item.Table, item.Name));
                }

                item.ClarifyGeneric = dataSet.CreateGeneric(item.Table);

                modifyItems.Add(item.Name, item);
            }
        }
        static void Main(string[] args)
        {
            try
            {
                // Initialize ClarifyApplication
                FCApp = ClarifyApplication.Initialize();

                // Create a new ClarifySession
                ClarifySession sess = FCApp.CreateSession();

                //Create a new ClarifyDataSet
                ClarifyDataSet ds = new ClarifyDataSet(sess);

                //	Create a new ClarifyGeneric object for address records
                ClarifyGeneric generic = ds.CreateGeneric("address");

                //	Check for address xml file
                if( !File.Exists(ADDRESS_PATH) )
                {
                    Console.WriteLine("Unable to find \"{0}\".", ADDRESS_PATH);
                    Console.WriteLine("Please ensure this file is in the same directory as the exe.");

                    //	Exit application
                    Console.WriteLine("Press Enter to exit...");
                    Console.ReadLine();
                    return;
                }

                //	Load address.xml into a XmlDocument
                XmlDocument doc = new XmlDocument();
                doc.Load(ADDRESS_PATH);

                //	Insert new address records into the database.
                InsertRecords(doc, generic);

                //	Exit application
                Console.WriteLine("Press Enter to exit...");
                Console.ReadLine();
            }
            catch( Exception ex )
            {
                Console.WriteLine("There was an unhandled exception when running the demo.");
                Console.WriteLine();
                Console.WriteLine(ex);
            }
        }