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 ClarifyGeneric TraverseEmployee(ClarifyGeneric actEntryGeneric) { _userGeneric = actEntryGeneric.TraverseWithFields("act_entry2user", "objid", "login_name"); _employeeGeneric = _userGeneric.TraverseWithFields("user2employee", "first_name", "last_name", "e_mail"); return(_employeeGeneric); }
public ClarifyGeneric TraverseEmployee(ClarifyGeneric actEntryGeneric) { _userGeneric = actEntryGeneric.TraverseWithFields("act_entry2user", "objid", "login_name"); _employeeGeneric = _userGeneric.TraverseWithFields("user2employee", "first_name", "last_name", "e_mail"); return _employeeGeneric; }
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(); }
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; }
public override int GetHashCode() { unchecked { int result = (ClarifyGeneric != null ? ClarifyGeneric.GetHashCode() : 0); result = (result * 397) ^ (Model != null ? Model.GetHashCode() : 0); result = (result * 397) ^ (NewRoot != null ? NewRoot.GetHashCode() : 0); return(result); } }
private static IEnumerable <SDKUserQueue> findQueues(ClarifyGeneric queueGeneric) { var queues = queueGeneric.DataRows().Select(row => new SDKUserQueue { DatabaseIdentifier = Convert.ToInt32(row.UniqueID), Name = row["title"].ToString() }); return(queues); }
public static ClarifyGeneric Filter(this ClarifyGeneric generic, Func <FilterExpression, Filter> filterFunction) { var filterExpression = new FilterExpression(); var filter = filterFunction(filterExpression); generic.Filter.AddFilter(filter); return(generic); }
public IEnumerable <HistoryItem> Assemble(ClarifyGeneric actEntryGeneric, IDictionary <int, ActEntryTemplate> templatesByCode, HistoryRequest historyRequest) { actEntryGeneric.DataFields.AddRange("act_code", "entry_time", "addnl_info", "proxy"); if (!historyRequest.ShowAllActivities) { var activeCodes = templatesByCode.Values.Where(t => !t.IsVerbose).Select(d => d.Code).ToArray(); actEntryGeneric.Filter(f => f.IsIn("act_code", activeCodes)); } //adding related generics expected by any fancy act entry templates var templateRelatedGenerics = traverseRelatedGenerics(actEntryGeneric, templatesByCode); _employeeAssembler.TraverseEmployee(actEntryGeneric); _contactAssembler.TraverseContact(actEntryGeneric); if (historyRequest.HistoryItemLimit.HasValue) { actEntryGeneric.MaximumRows = historyRequest.HistoryItemLimit.Value; } actEntryGeneric.Query(); var actEntryDTOS = actEntryGeneric.DataRows().Select(actEntryRecord => { var id = historyRequest.WorkflowObject.Id; if (historyRequest.WorkflowObject.IsChild) { //child objects are loaded in bulk so historyRequest.WorkflowObject.Id is not the correct id //find the act_entry's parent generic id field value var info = WorkflowObjectInfo.GetObjectInfo(actEntryGeneric.ParentRelation.TargetName); var parentId = actEntryRecord.AsInt(actEntryGeneric.ParentRelation.Name); var parentRow = actEntryGeneric.ParentGeneric.DataRows().First(r => r.DatabaseIdentifier() == parentId); id = (info.HasIDFieldName) ? parentRow[info.IDFieldName].ToString() : Convert.ToString(parentRow.DatabaseIdentifier()); } var code = actEntryRecord.AsInt("act_code"); return(new ActEntry { Id = id, Type = historyRequest.WorkflowObject.Type, Template = findTemplateByActCode(code, templatesByCode), When = actEntryRecord.AsDateTime("entry_time"), Who = _employeeAssembler.Assemble(actEntryRecord, _contactAssembler), ImpersonatedBy = _employeeAssembler.Assemble(actEntryRecord), AdditionalInfo = actEntryRecord.AsString("addnl_info"), ActEntryRecord = actEntryRecord }); }).Where(_ => !_.Template.IsCancelled).ToList(); return(actEntryDTOS .Select(dto => createActivityDTOFromMapper(dto, templateRelatedGenerics)) .Where(i => !i.IsCancelled) .Where(_ => historyRequest.ShowAllActivities || !_.IsVerbose) .ToList()); }
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."); }
public IEnumerable<HistoryItem> Assemble(ClarifyGeneric actEntryGeneric, IDictionary<int, ActEntryTemplate> templatesByCode, HistoryRequest historyRequest) { actEntryGeneric.DataFields.AddRange("act_code", "entry_time", "addnl_info"); if (!historyRequest.ShowAllActivities) { var activeCodes = templatesByCode.Values.Where(t => !t.IsVerbose).Select(d => d.Code).ToArray(); actEntryGeneric.Filter(f => f.IsIn("act_code", activeCodes)); } //adding related generics expected by any fancy act entry templates var templateRelatedGenerics = traverseRelatedGenerics(actEntryGeneric, templatesByCode); _employeeAssembler.TraverseEmployee(actEntryGeneric); _contactAssembler.TraverseContact(actEntryGeneric); if (historyRequest.HistoryItemLimit.HasValue) { actEntryGeneric.MaximumRows = historyRequest.HistoryItemLimit.Value; } actEntryGeneric.Query(); var actEntryDTOS = actEntryGeneric.DataRows().Select(actEntryRecord => { var id = historyRequest.WorkflowObject.Id; if (historyRequest.WorkflowObject.IsChild) { //child objects are loaded in bulk so historyRequest.WorkflowObject.Id is not the correct id //find the act_entry's parent generic id field value var info = WorkflowObjectInfo.GetObjectInfo(actEntryGeneric.ParentRelation.TargetName); var parentId = actEntryRecord.AsInt(actEntryGeneric.ParentRelation.Name); var parentRow = actEntryGeneric.ParentGeneric.DataRows().First(r => r.DatabaseIdentifier() == parentId); id = (info.HasIDFieldName) ? parentRow[info.IDFieldName].ToString() : Convert.ToString(parentRow.DatabaseIdentifier()); } var code = actEntryRecord.AsInt("act_code"); return new ActEntry { Id = id, Type = historyRequest.WorkflowObject.Type, Template = findTemplateByActCode(code, templatesByCode), When = actEntryRecord.AsDateTime("entry_time"), Who = _employeeAssembler.Assemble(actEntryRecord, _contactAssembler), AdditionalInfo = actEntryRecord.AsString("addnl_info"), ActEntryRecord = actEntryRecord }; }).ToList(); return actEntryDTOS .Select(dto => createActivityDTOFromMapper(dto, templateRelatedGenerics)) .Where(i=>!i.IsCancelled) .Where(_ => historyRequest.ShowAllActivities || !_.IsVerbose) .ToList(); }
protected void DoesContactExist(object source, ServerValidateEventArgs args) { ClarifyGeneric contactGeneric = dataSet.CreateGeneric("contact"); contactGeneric.AppendFilter("first_name", StringOps.Equals, firstName.Text); contactGeneric.AppendFilter("last_name", StringOps.Equals, lastName.Text); contactGeneric.AppendFilter("phone", StringOps.Equals, phone.Text); contactGeneric.Query(); args.IsValid = contactGeneric.Rows.Count > 0; }
private ClarifyGeneric[] GetRootGenericsToQuery(QueryProtocol[] queryItems) { ClarifyGeneric[] generics = new ClarifyGeneric[queryItems.Length]; for (int i = 0; i < generics.Length; i++) { generics[i] = queryItems[i].ClarifyGeneric; } return(generics); }
private ITimeZone findTimezone(ClarifyGeneric timeZoneGeneric, string username) { if (timeZoneGeneric.Count < 1) { _logger.LogWarn("Could not find default timezone for user {0} using server default.", username); return(_localeCache.ServerTimeZone); } var timezoneName = timeZoneGeneric.Rows[0].AsString("name"); return(_localeCache.TimeZones[timezoneName, false]); }
public static ClarifyGeneric TraverseWithFields(this ClarifyGeneric generic, string relationName, params string[] fields) { if (fields == null || fields.Length < 1) { fields = new[] { "objid" } } ; var childGeneric = generic.Traverse(relationName); childGeneric.DataFields.AddRange(fields); return(childGeneric); }
private IEnumerable<ActEntry> assembleActEntryDTOs(ClarifyGeneric actEntryGeneric, IDictionary<int, ActEntryTemplate> actEntryTemplatesByCode, Func<ClarifyDataRow, HistoryItemEmployee> employeeAssembler) { return actEntryGeneric.DataRows().Select(actEntryRecord => { var code = actEntryRecord.AsInt("act_code"); var template = actEntryTemplatesByCode[code]; var when = actEntryRecord.AsDateTime("entry_time"); var detail = actEntryRecord.AsString("addnl_info"); var who = employeeAssembler(actEntryRecord); return new ActEntry { Template = template, When = when, Who = who, AdditionalInfo = detail, ActEntryRecord = actEntryRecord, Type = _workflowObject.Type }; }).ToArray(); }
public HistoryModelMapVisitor(IMappingTransformRegistry registry, IServiceLocator services, IMappingVariableExpander expander, ClarifyGeneric rootGeneric, ClarifyDataSet dataSet, WorkflowObject workflowObject, HistorySettings settings) { _registry = registry; _services = services; _expander = expander; _rootGeneric = rootGeneric; _workflowObject = workflowObject; _settings = settings; DataSet = dataSet; }
public IEnumerable <HistoryItem> Assemble(ClarifyGeneric actEntryGeneric) { var codes = _templatesByCode.Values.Select(d => d.Code).ToArray(); actEntryGeneric.DataFields.AddRange("act_code", "entry_time", "addnl_info"); actEntryGeneric.Filter(f => f.IsIn("act_code", codes)); var actEntryUserGeneric = actEntryGeneric.TraverseWithFields("act_entry2user", "objid", "login_name"); var actEntryEmployeeGeneric = actEntryUserGeneric.TraverseWithFields("user2employee", "first_name", "last_name"); //adding related generics expected by any fancy act entry templates var templateRelatedGenerics = traverseRelatedGenerics(actEntryGeneric); actEntryGeneric.Query(); Func <ClarifyDataRow, HistoryItemEmployee> employeeAssembler = actEntryRecord => { var userRows = actEntryRecord.RelatedRows(actEntryUserGeneric); if (userRows.Length == 0) { return(new HistoryItemEmployee()); } var userRecord = userRows[0]; var login = userRecord.AsString("login_name"); var employeeRows = userRecord.RelatedRows(actEntryEmployeeGeneric); if (employeeRows.Length == 0) { return new HistoryItemEmployee { Login = login } } ; var employeeRecord = employeeRows[0]; var name = "{0} {1}".ToFormat(employeeRecord.AsString("first_name"), employeeRecord.AsString("last_name")); var id = employeeRecord.DatabaseIdentifier(); return(new HistoryItemEmployee { Name = name, Id = id, Login = login }); }; var actEntryDTOS = assembleActEntryDTOs(actEntryGeneric, _templatesByCode, employeeAssembler); return(actEntryDTOS.Select(dto => createActivityDTOFromMapper(dto, templateRelatedGenerics)).ToArray()); }
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); } }
private IEnumerable <ActEntry> assembleActEntryDTOs(ClarifyGeneric actEntryGeneric, IDictionary <int, ActEntryTemplate> actEntryTemplatesByCode, Func <ClarifyDataRow, HistoryItemEmployee> employeeAssembler) { return(actEntryGeneric.DataRows().Select(actEntryRecord => { var code = actEntryRecord.AsInt("act_code"); var template = actEntryTemplatesByCode[code]; var serverWhen = actEntryRecord.AsDateTime("entry_time"); var utcWhen = ConvertToUTC(serverWhen); var detail = actEntryRecord.AsString("addnl_info"); var who = employeeAssembler(actEntryRecord); return new ActEntry { Template = template, When = utcWhen, Who = who, AdditionalInfo = detail, ActEntryRecord = actEntryRecord, Type = _workflowObject.Type }; }).ToArray()); }
public IEnumerable<HistoryItem> Assemble(ClarifyGeneric actEntryGeneric) { var codes = _templatesByCode.Values.Select(d => d.Code).ToArray(); actEntryGeneric.DataFields.AddRange("act_code", "entry_time", "addnl_info"); actEntryGeneric.Filter(f => f.IsIn("act_code", codes)); var actEntryUserGeneric = actEntryGeneric.TraverseWithFields("act_entry2user", "objid", "login_name"); var actEntryEmployeeGeneric = actEntryUserGeneric.TraverseWithFields("user2employee", "first_name", "last_name", "e_mail"); //adding related generics expected by any fancy act entry templates var templateRelatedGenerics = traverseRelatedGenerics(actEntryGeneric); actEntryGeneric.Query(); Func<ClarifyDataRow, HistoryItemEmployee> employeeAssembler = actEntryRecord => { var userRows = actEntryRecord.RelatedRows(actEntryUserGeneric); if (userRows.Length == 0) return new HistoryItemEmployee(); var userRecord = userRows[0]; var login = userRecord.AsString("login_name"); var employeeRows = userRecord.RelatedRows(actEntryEmployeeGeneric); if (employeeRows.Length == 0) return new HistoryItemEmployee {Login = login}; var employeeRecord = employeeRows[0]; var name = "{0} {1}".ToFormat(employeeRecord.AsString("first_name"), employeeRecord.AsString("last_name")); var email = employeeRecord.AsString("e_mail"); var id = employeeRecord.DatabaseIdentifier(); return new HistoryItemEmployee {Name = name, Id = id, Login = login, Email = email}; }; var actEntryDTOS = assembleActEntryDTOs(actEntryGeneric, _templatesByCode, employeeAssembler); return actEntryDTOS.Select(dto => createActivityDTOFromMapper(dto, templateRelatedGenerics)).ToArray(); }
private ITimeZone findTimezone(ClarifyGeneric timeZoneGeneric, string username) { if (timeZoneGeneric.Count < 1) { _logger.LogWarn("Could not find default timezone for user {0} using server default.", username); return _localeCache.ServerTimeZone; } var timezoneName = timeZoneGeneric.Rows[0].AsString("name"); return _localeCache.TimeZones[timezoneName, false]; }
private static IEnumerable<SDKUserQueue> findQueues(ClarifyGeneric queueGeneric) { var queues = queueGeneric.DataRows().Select(row => new SDKUserQueue { DatabaseIdentifier = Convert.ToInt32(row.UniqueID), Name = row["title"].ToString() }); return queues; }
public static IEnumerable <ClarifyDataRow> DataRows(this ClarifyGeneric generic) { return(generic.Rows.Cast <ClarifyDataRow>()); }
private IDictionary<ActEntryTemplate, ClarifyGeneric> traverseRelatedGenerics(ClarifyGeneric actEntryGeneric) { var relatedGenericByTemplate = new Dictionary<ActEntryTemplate, ClarifyGeneric>(); foreach (var actEntryTemplate in _templatesByCode.Values.Where(t => t.RelatedGenericRelationName.IsNotEmpty())) { var relatedGeneric = actEntryGeneric.TraverseWithFields(actEntryTemplate.RelatedGenericRelationName, actEntryTemplate.RelatedGenericFields); relatedGenericByTemplate.Add(actEntryTemplate, relatedGeneric); } return relatedGenericByTemplate; }
private IDictionary<ActEntryTemplate, ClarifyGeneric> traverseRelatedGenerics(ClarifyGeneric actEntryGeneric, IDictionary<int, ActEntryTemplate> templatesByCode) { var relatedGenericByTemplate = new Dictionary<ActEntryTemplate, ClarifyGeneric>(); var genericsByRelation = new Dictionary<string, ClarifyGeneric>(); foreach (var template in templatesByCode.Values.Where(t => t.RelatedGenericRelationName.IsNotEmpty())) { //avoid traversing the same relation (from actentry) twice. ClarifyGeneric relatedGeneric; if (genericsByRelation.ContainsKey(template.RelatedGenericRelationName)) { relatedGeneric = genericsByRelation[template.RelatedGenericRelationName]; } else { relatedGeneric = actEntryGeneric.TraverseWithFields(template.RelatedGenericRelationName); if (template.RelatedGenericAction != null) { template.RelatedGenericAction(relatedGeneric); } genericsByRelation.Add(template.RelatedGenericRelationName, relatedGeneric); } relatedGeneric.DataFields.AddRange(template.RelatedGenericFields); relatedGenericByTemplate.Add(template, relatedGeneric); } return relatedGenericByTemplate; }
private IDictionary <ActEntryTemplate, ClarifyGeneric> traverseRelatedGenerics(ClarifyGeneric actEntryGeneric, IDictionary <int, ActEntryTemplate> templatesByCode) { var relatedGenericByTemplate = new Dictionary <ActEntryTemplate, ClarifyGeneric>(); var genericsByRelation = new Dictionary <string, ClarifyGeneric>(); foreach (var template in templatesByCode.Values.Where(t => t.RelatedGenericRelationName.IsNotEmpty())) { //avoid traversing the same relation (from actentry) twice. ClarifyGeneric relatedGeneric; if (genericsByRelation.ContainsKey(template.RelatedGenericRelationName)) { relatedGeneric = genericsByRelation[template.RelatedGenericRelationName]; } else { relatedGeneric = actEntryGeneric.TraverseWithFields(template.RelatedGenericRelationName); if (template.RelatedGenericAction != null) { template.RelatedGenericAction(relatedGeneric); } genericsByRelation.Add(template.RelatedGenericRelationName, relatedGeneric); } relatedGeneric.DataFields.AddRange(template.RelatedGenericFields); relatedGenericByTemplate.Add(template, relatedGeneric); } return(relatedGenericByTemplate); }
private ClarifyGeneric[] GetRootGenericsToQuery(QueryProtocol[] queryItems) { ClarifyGeneric[] generics = new ClarifyGeneric[queryItems.Length]; for (int i = 0; i < generics.Length; i++) generics[i] = queryItems[i].ClarifyGeneric; return generics; }
private static void InsertRecords(XmlDocument doc, ClarifyGeneric generic) { IClarifyApplication FCApp = ClarifyApplication.Instance; bool isValid = true; int i = 0; // Loop for each address record in the xml file foreach (XmlNode address in doc.SelectNodes("//addresses/address")) { i++; // Get values of attributes string address1 = GetAttributeValue(address, "address1", i); string address2 = GetAttributeValue(address, "address2", i); string city = GetAttributeValue(address, "city", i); string state = GetAttributeValue(address, "state", i); string zip = GetAttributeValue(address, "zip", i); string country = GetAttributeValue(address, "country", i); string timezone = GetAttributeValue(address, "timezone", i); // Check to see if the country, timezone, and state are valid isValid = isValid & IsValid(country, timezone, state, i); // Only add new rows if all previous rows are valid if (isValid) { // Add a new address row to the address generic GenericDataRow row = generic.AddNew(); // Set the field values of the new address row row["address"] = address1; row["address_2"] = address2; row["city"] = city; row["state"] = state; row["zipcode"] = zip; row["update_stamp"] = DateTime.Now; // Relate this new row to existing records by relation and objid row.RelateByID(FCApp.LocaleCache.GetCountryObjID(country), "address2country"); row.RelateByID(FCApp.LocaleCache.GetStateObjID(country, state), "address2state_prov"); row.RelateByID(FCApp.LocaleCache.GetTimeZoneObjID(timezone), "address2time_zone"); } } try { // If all the records are valid then commit new rows to the database if (isValid) { // Commit all the new rows to the database generic.UpdateAll(); Console.WriteLine("Finished. Added {0} address records.", i); } else { Console.WriteLine("No records were added due to invalid data."); } } catch (Exception ex) { // Error inserting rows Console.WriteLine("Error adding new addresses.\n{0}", ex.Message); } }
private ClarifyDataRow findRelatedSubRecord(ClarifyDataRow parentRecord, string parentKeyField, ClarifyGeneric subRootGeneric, string rootKeyField) { if (_schemaCache.IsIntegerField(parentRecord.ParentGeneric.TableName, parentKeyField)) { var parentKeyValue = Convert.ToInt32(parentRecord[parentKeyField]); return(subRootGeneric.Rows.Cast <ClarifyDataRow>().First(row => Convert.ToInt32(row[rootKeyField]) == parentKeyValue)); } var parentKeyString = parentRecord[parentKeyField].ToString(); return(subRootGeneric.Rows.Cast <ClarifyDataRow>().First(row => row[rootKeyField].ToString() == parentKeyString)); }
public ClarifyGeneric TraverseContact(ClarifyGeneric actEntryGeneric) { _contactGeneric = actEntryGeneric.TraverseWithFields("act_entry2contact", "first_name", "last_name", "e_mail"); return _contactGeneric; }
private IDictionary <ActEntryTemplate, ClarifyGeneric> traverseRelatedGenerics(ClarifyGeneric actEntryGeneric) { var relatedGenericByTemplate = new Dictionary <ActEntryTemplate, ClarifyGeneric>(); foreach (var actEntryTemplate in _templatesByCode.Values.Where(t => t.RelatedGenericRelationName.IsNotEmpty())) { var relatedGeneric = actEntryGeneric.TraverseWithFields(actEntryTemplate.RelatedGenericRelationName, actEntryTemplate.RelatedGenericFields); relatedGenericByTemplate.Add(actEntryTemplate, relatedGeneric); } return(relatedGenericByTemplate); }
private static void InsertRecords(XmlDocument doc, ClarifyGeneric generic) { IClarifyApplication FCApp = ClarifyApplication.Instance; bool isValid = true; int i = 0; // Loop for each address record in the xml file foreach(XmlNode address in doc.SelectNodes("//addresses/address") ) { i++; // Get values of attributes string address1 = GetAttributeValue(address, "address1", i); string address2 = GetAttributeValue(address, "address2", i); string city = GetAttributeValue(address, "city", i); string state = GetAttributeValue(address, "state", i); string zip = GetAttributeValue(address, "zip", i); string country = GetAttributeValue(address, "country", i); string timezone = GetAttributeValue(address, "timezone", i); // Check to see if the country, timezone, and state are valid isValid = isValid & IsValid(country, timezone, state, i); // Only add new rows if all previous rows are valid if( isValid ) { // Add a new address row to the address generic GenericDataRow row = generic.AddNew(); // Set the field values of the new address row row["address"] = address1; row["address_2"] = address2; row["city"] = city; row["state"] = state; row["zipcode"] = zip; row["update_stamp"] = DateTime.Now; // Relate this new row to existing records by relation and objid row.RelateByID( FCApp.LocaleCache.GetCountryObjID( country ), "address2country" ); row.RelateByID( FCApp.LocaleCache.GetStateObjID( country, state ), "address2state_prov" ); row.RelateByID( FCApp.LocaleCache.GetTimeZoneObjID( timezone ), "address2time_zone" ); } } try { // If all the records are valid then commit new rows to the database if( isValid ) { // Commit all the new rows to the database generic.UpdateAll(); Console.WriteLine("Finished. Added {0} address records.", i); } else { Console.WriteLine("No records were added due to invalid data."); } } catch(Exception ex) { // Error inserting rows Console.WriteLine("Error adding new addresses.\n{0}", ex.Message); } }
public ClarifyGeneric TraverseContact(ClarifyGeneric actEntryGeneric) { _contactGeneric = actEntryGeneric.TraverseWithFields("act_entry2contact", "first_name", "last_name", "e_mail"); return(_contactGeneric); }