public void DeleteSiteByObjid(int objid) { ClarifyDataAccessWS clarifyDA = new ClarifyDataAccessWS(session); DataModifier generic = clarifyDA.CreateDataModifier(); DeleteModifier delete = generic.CreateDeleteModifier("site", "site"); delete.AppendUniqueFilter("objid", objid.ToString()); ModifierResultProtocol[] results = generic.Update(); Assert.AreEqual(objid, results[0].Objid); }
public string InsertSiteGetIDNum() { ClarifyDataAccessWS clarifyDA = new ClarifyDataAccessWS(session); string siteIDNum = session.GetNextNumScheme("Site ID"); DataModifier generic = clarifyDA.CreateDataModifier(); InsertModifier insert = generic.CreateInsertModifier("SiteInsert", "site"); insert.SetField("site_id", siteIDNum); insert.SetField("name", "unit test"); insert.SetField("type", "1"); ModifierResultProtocol[] result = generic.Update(); return(siteIDNum); }
public int InsertSiteGetObjid() { ClarifyDataAccessWS clarifyDA = new ClarifyDataAccessWS(session); string siteIDNum = session.GetNextNumScheme("Site ID"); DataModifier generic = clarifyDA.CreateDataModifier(); InsertModifier insert = generic.CreateInsertModifier("SiteInsert", "site"); insert.SetField("site_id", siteIDNum); insert.SetField("name", "unit test"); insert.SetField("type", "1"); ModifierResultProtocol[] results = generic.Update(); return results[0].Objid; }
public void DeleteSiteByObjid(int objid) { ClarifyDataAccessWS clarifyDA = new ClarifyDataAccessWS(session); DataModifier generic = clarifyDA.CreateDataModifier(); DeleteModifier delete = generic.CreateDeleteModifier("site", "site"); delete.AppendUniqueFilter("objid", objid.ToString()); ModifierResultProtocol[] results = generic.Update(); Assert.AreEqual(objid, results[0].Objid); }
private void CreateNewContact() { try { EnableValidators(); Page.Validate(); if (Page.IsValid) { // Create new Clarify Data Access Web Service Client ClarifyDataAccessWS dataAccess = new ClarifyDataAccessWS(Global.ClarifySessWS); // Create a DataModifier for modifying data on the database DataModifier dataModifier = dataAccess.CreateDataModifier(); // Create modify items for the tables we want to insert new records InsertModifier contactInsert = dataModifier.CreateInsertModifier("contactInsert", "contact"); InsertModifier contactRoleInsert = dataModifier.CreateInsertModifier("contactRoleInsert", "contact_role"); InsertModifier siteInsert = dataModifier.CreateInsertModifier("siteInsert", "site"); InsertModifier addressInsert = dataModifier.CreateInsertModifier("addressInsert", "address"); ReferenceModifier stateProvRef = dataModifier.CreateReferenceModifier("stateProvRef", "state_prov"); ReferenceModifier timezoneRef = dataModifier.CreateReferenceModifier("timezoneRef", "time_zone"); ReferenceModifier countryRef = dataModifier.CreateReferenceModifier("countryRef", "country"); // Append fields that we want to insert values into contactInsert.SetField("first_name", this.firstName.Text); contactInsert.SetField("last_name", this.lastName.Text); contactInsert.SetField("phone", this.phoneNumber.Text); // Relate this inserted record to another Modifier contactInsert.RelateRecord("contact2contact_role", contactRoleInsert); contactRoleInsert.SetField("role_name", "Default"); contactRoleInsert.SetField("primary_site", "1"); contactRoleInsert.RelateRecord("contact_role2site", siteInsert); // Get next Site ID from web service string siteID = Global.ClarifySessWS.GetNextNumScheme("Site ID"); siteInsert.SetField("site_id", siteID); siteInsert.SetField("name", this.siteName.Text); siteInsert.RelateRecord("cust_primaddr2address", addressInsert); siteInsert.RelateRecord("cust_billaddr2address", addressInsert); siteInsert.RelateRecord("cust_shipaddr2address", addressInsert); addressInsert.SetField("address", this.address1.Text); addressInsert.SetField("address_2", this.address2.Text); addressInsert.SetField("city", this.city.Text); addressInsert.SetField("state", this.state.SelectedValue); addressInsert.SetField("zipcode", this.zip.Text); addressInsert.RelateRecord("address2state_prov", stateProvRef); addressInsert.RelateRecord("address2time_zone", timezoneRef); addressInsert.RelateRecord("address2country", countryRef); // This we select an existing record to use as a relation for addressInsert stateProvRef.AppendUniqueFilter("full_name", this.state.SelectedValue); timezoneRef.AppendUniqueFilter("name", "CST"); countryRef.AppendUniqueFilter("name", "USA"); // Run the query and retrieve the results ModifierResultProtocol[] results = dataModifier.Update(); // Show the results to the user System.Text.StringBuilder sb = new System.Text.StringBuilder(); foreach (ModifierResultProtocol result in results) { if (sb.Length > 0) { sb.Append("<br/>"); } sb.Append(string.Format("{0} on table [{1}] with objid of [{2}]", result.Action, result.Table, result.Objid)); } this.messageLabel.Text = String.Format("<b>Save successful.</b><br/>" + sb.ToString()); // Clear form ClearEntryFields(); } } catch (SoapException ex) { string message = ex.Detail.InnerText.Trim().Length > 0 ? ex.Detail.InnerText.Trim() : ex.Message; this.messageLabel.Text += String.Format("<b>Error adding contact.</b><br/>{0}", message.Replace("\n", "<br/>")); } }