public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_CustomerProfile1 s, Action <p_CustomerProfile1> bespoke = null) { var _ = new ChangedFields(ManageFlags.CustomerProfileChanged); bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } var list = add ? null : await GetListAsync(una, s.organization_codeKey).ConfigureAwait(false); if (list?.Count > 1) { return(_.Changed(), $"list > 1"); } var key = list?.Single().Key; var(r, last) = await una.SubmitSubManageAsync("C", add?HttpMethod.Post : HttpMethod.Put, "organizations/customer_org", $"key={key}", $"orgKey={s.organization_codeKey}", "legalEntityOrg=-1&paymentTerm=1&active=true", (z, f) => { //if (add || cf.Contains("oc")) f.FromSelect("xxx", _._(s.organization_code, nameof(s.organization_code))); if (add || cf.Contains("lec")) { f.FromSelect("legalEntityOrg", _._(s.legal_entity_code, nameof(s.legal_entity_code)) ?? f.Selects["legalEntityOrg"].FirstOrDefault().Value); } if (add || cf.Contains("a")) { f.Checked["active"] = _._(s.active, nameof(s.active)) == "Y"; } if (add || cf.Contains("pt")) { f.FromSelect("paymentTerm", _._(s.payment_terms, nameof(s.payment_terms))); } // //if (add || cf.Contains("u1")) f.Values["udf_0"] = _._(s.user01, nameof(s.user01)); //if (add || cf.Contains("u2")) f.Values["udf_1"] = _._(s.user02, nameof(s.user02)); //if (add || cf.Contains("u3")) f.Values["udf_2"] = _._(s.user03, nameof(s.user03)); //if (add || cf.Contains("u4")) f.Values["udf_3"] = _._(s.user04, nameof(s.user04)); //if (add || cf.Contains("u5")) f.Values["udf_4"] = _._(s.user05, nameof(s.user05)); //if (add || cf.Contains("u6")) f.Values["udf_5"] = _._(s.user06, nameof(s.user06)); //if (add || cf.Contains("u7")) f.Values["udf_6"] = _._(s.user07, nameof(s.user07)); //if (add || cf.Contains("u8")) f.Values("udf_7", _._(s.user08, nameof(s.user08))); //if (add || cf.Contains("u9")) f.Values["udf_8"] = _._(s.user09, nameof(s.user09)); //if (add || cf.Contains("u10")) f.Values["udf_9"] = _._(s.user10, nameof(s.user10)); //if (add || cf.Contains("u11")) f.Values["udf_10"] = _._(s.user11, nameof(s.user11)); //if (add || cf.Contains("u12")) f.Values["udf_11"] = _._(s.user12, nameof(s.user12)); //if (add || cf.Contains("u13")) f.Values["udf_12"] = _._(s.user13, nameof(s.user13)); //if (add || cf.Contains("u14")) f.Values["udf_13"] = _._(s.user14, nameof(s.user14)); //if (add || cf.Contains("u15")) f.Values["udf_14"] = _._(s.user15, nameof(s.user15)); //if (add || cf.Contains("u16")) f.Values["udf_15"] = _._(s.user16, nameof(s.user16)); //if (add || cf.Contains("u17")) f.Values["udf_16"] = _._(s.user17, nameof(s.user17)); //if (add || cf.Contains("u18")) f.Values["udf_17"] = _._(s.user18, nameof(s.user18)); //if (add || cf.Contains("u19")) f.Values["udf_18"] = _._(s.user19, nameof(s.user19)); //if (add || cf.Contains("u20")) f.Values["udf_19"] = _._(s.user20, nameof(s.user20)); return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_Alternate1 s, Action <p_Alternate1> bespoke = null) { var _ = new ChangedFields(ManageFlags.AlternateChanged); bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2, canDelete: true)) { return(_.Changed(), last2); } var method = !cf.Contains("delete") ? add ? HttpMethod.Post : HttpMethod.Put : HttpMethod.Delete; var(r, last) = await una.SubmitSubManageAsync("D", HttpMethod.Get, $"people/alternates", null, $"personkey={s.alternate_usernameKey}", null, (z, f) => { var roleKey = f.Selects["attributes"].FirstOrDefault(x => x.Value.Replace(" ", "").ToLowerInvariant() == s.role.ToLowerInvariant()).Key; if (roleKey == null) { return(null); } f.Values[method == HttpMethod.Delete ? "unassign" : "assign"] = $"{s.usernameKey};{roleKey}"; f.Add("button_save", "action", null); return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_PersonAccess1 s, Action <p_PersonAccess1> bespoke = null) { var _ = new ChangedFields(ManageFlags.PersonAccessChanged); bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } if (add) { return(_, "key field missing, please check export critieria"); } var(r, last) = await una.SubmitSubManageAsync("0", HttpMethod.Get, "people/orgaccess/edit", null, $"personkey={s.usernameKey}&oapkey={s.key}", null, (z, f) => { // cache template if (DateTime.Now > FormExpires || FormOptions == null || FormOrgTreesByName == null) { f.Values["personkey"] = f.Values["oapkey"] = null; FormExpires = DateTime.Now.AddHours(3); FormOptions = new HtmlFormOptions { FormTemplate = new HtmlFormTemplate(f) }; FormOrgTreesByName = BuildOrgTreesByName(z); } if (!cf.Contains("oa")) { throw new ArgumentOutOfRangeException(nameof(cf)); } // f.Values["personkey"] = s.usernameKey; f.Values["oapkey"] = s.key; var org_access = _._(s.org_access, nameof(s.org_access)); switch (org_access) { case "!ALL!": f.FromSelectByKey("orgaccess", "all"); break; case "!NONE!": f.FromSelectByKey("orgaccess", "none"); break; default: f.FromSelectByKey("orgaccess", "org"); var orgTreeKeys = org_access.Split(',').Select(x => FormOrgTreesByName[x.Trim()]).ToArray(); f.FromMultiCheckbox("orgTree_selected", orgTreeKeys); break; } return(f.ToString()); }, formOptions : FormOptions).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_ProjectAdministrator1 s, Action <p_ProjectAdministrator1> bespoke = null) { var _ = new ChangedFields(ManageFlags.ProjectAdministratorChanged); bespoke?.Invoke(s); var canDelete = s.role != "projectManager"; if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2, canDelete: canDelete)) { return(_.Changed(), last2); } var method = !cf.Contains("delete") ? add ? HttpMethod.Post : HttpMethod.Put : HttpMethod.Delete; if (canDelete && string.IsNullOrEmpty(s.username)) { method = HttpMethod.Delete; } var(r, last) = await una.SubmitSubManageAsync("D", HttpMethod.Get, $"projects/controllers/{s.role}", null, //: POST $"projectkey={s.project_codeKey}", null, (z, f) => { if (s.role == "projectApprover") { f.Checked["approverApproveFirst"] = s.pm_approves_before_mgr == "Y"; if (method != HttpMethod.Delete) { f.Values["primaryAssigned"] = $"*{s.usernameKey};2"; } else if (method == HttpMethod.Delete) { f.Values["primaryNotAssigned"] = "-1"; } } else { if (method != HttpMethod.Delete) { f.Values["primary"] = s.usernameKey; } else if (method == HttpMethod.Delete) { f.Values["primary"] = "-1"; } } return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_Project1 s, Action <p_Project1> bespoke = null) { var _ = new ChangedFields(ManageFlags.ProjectChanged); bespoke?.Invoke(s); if (ManageRecordBase(s.key, s.XCF, 0, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } var organizations = Unanet.Lookups.CostCenters.Value; var(r, last) = await una.SubmitManageAsync(add?HttpMethod.Post : HttpMethod.Put, "projects", $"projectkey={s.key}", (z, f) => { if (add || cf.Contains("poc")) { f.Values["projectOrg"] = s.project_org_codeKey; } if (add || cf.Contains("pc")) { f.Values["pjtCode"] = _._(s.project_code, nameof(s.project_code)); } if (add || cf.Contains("pt")) { f.FromSelect("pjtType", _._(s.project_type, nameof(s.project_type))); } if (add || cf.Contains("ps")) { f.FromSelect("pjtStatus", $"{_._(s.project_status, nameof(s.project_status))} ({s.project_status})"); } //if (add || cf.Contains("pm")) f.Values["xxxx"] = _._(s.project_manager, nameof(s.project_manager)); //if (add || cf.Contains("oe")) f.Values["xxxx"] = _._(s.open_edit, nameof(s.open_edit)); //?? // if (add || cf.Contains("ss")) { f.Checked["selfSign"] = _._(s.self_signup, nameof(s.self_signup)) == "Y"; } if (add || cf.Contains("sp")) { f.FromSelectByKey("selfPlan", _._(s.self_plan, nameof(s.self_plan))); } if (add || cf.Contains("sap")) { f.Checked["assignSelfPlans"] = _._(s.self_assign_plans, nameof(s.self_assign_plans)) == "Y"; } if (add || cf.Contains("aft")) { f.Checked["future_charge"] = _._(s.allows_future_time, nameof(s.allows_future_time)) == "Y"; } //if (add || cf.Contains("at")) f.Checked["xxxx"] = _._(s.approve_time, nameof(s.approve_time)) == "Y"; //if (add || cf.Contains("ae")) f.Checked["xxxx"] = _._(s.approve_expense, nameof(s.approve_expense)) == "Y"; if (add || cf.Contains("trt")) { f.Checked["ts_task_required"] = _._(s.time_requires_task, nameof(s.time_requires_task)) == "Y"; } if (add || cf.Contains("ert")) { f.Checked["er_task_required"] = _._(s.expense_requires_task, nameof(s.expense_requires_task)) == "Y"; } if (add || cf.Contains("ae2")) { f.Checked["expenseCharge"] = _._(s.allows_expenses, nameof(s.allows_expenses)) == "Y"; } // if (add || cf.Contains("osd")) { f.Values["origStartDate"] = _._(s.original_start_date, nameof(s.original_start_date)).FromDateTime(); } if (add || cf.Contains("oed")) { f.Values["origEndDate"] = _._(s.original_end_date, nameof(s.original_end_date)).FromDateTime(); } if (add || cf.Contains("rsd")) { f.Values["revStartDate"] = _._(s.revised_start_date, nameof(s.revised_start_date)).FromDateTime("BOT"); } if (add || cf.Contains("red")) { f.Values["revEndDate"] = _._(s.revised_end_date, nameof(s.revised_end_date)).FromDateTime("EOT"); } if (add || cf.Contains("cd")) { f.Values["completedDate"] = _._(s.completed_date, nameof(s.completed_date)).FromDateTime(); } // if (add || cf.Contains("bh")) { f.Values["bgtHrs"] = _._(s.budget_hours, nameof(s.budget_hours)).ToString(); } if (add || cf.Contains("bldb")) { f.Values["bgtLaborAmtBill"] = _._(s.budget_labor_dollars_bill, nameof(s.budget_labor_dollars_bill)); } if (add || cf.Contains("bedb")) { f.Values["bgtExpenseAmtBill"] = _._(s.budget_expense_dollars_bill, nameof(s.budget_expense_dollars_bill)); } // if (add || cf.Contains("eh")) { f.Values["etcHrs"] = _._(s.etc_hours, nameof(s.etc_hours)).ToString(); } if (add || cf.Contains("eldb")) { f.Values["etcLaborAmtBill"] = _._(s.etc_labor_dollars_bill, nameof(s.etc_labor_dollars_bill)); } if (add || cf.Contains("eedb")) { f.Values["etcExpenseAmtBill"] = _._(s.etc_expense_dollars_bill, nameof(s.etc_expense_dollars_bill)); } if (add || cf.Contains("eth")) { f.Values["estTotalHrs"] = _._(s.est_tot_hours, nameof(s.est_tot_hours)); } if (add || cf.Contains("etldb")) { f.Values["estTotalLaborAmtBill"] = _._(s.est_tot_labor_dollars_bill, nameof(s.est_tot_labor_dollars_bill)); } if (add || cf.Contains("etedb")) { f.Values["estTotalExpenseAmtBill"] = _._(s.est_tot_expense_dollars_bill, nameof(s.est_tot_expense_dollars_bill)); } // if (add || cf.Contains("esc") || cf.Contains("bind")) { f.Values["externalSystemCode"] = _._(s.external_system_code, nameof(s.external_system_code)); } if (add || cf.Contains("t")) { f.Values["pjtTitle"] = _._(s.title, nameof(s.title)); } if (add || cf.Contains("c")) { f.Values["purpose"] = _._(s.comments, nameof(s.comments)); } //if (add || cf.Contains("apo")) f.Values["xxxx"] = _._(s.assigned_person_orgs, nameof(s.assigned_person_orgs)); // Multi // //if (add || cf.Contains("pcl")) f.FromSelect("xxxx", _._(s.pay_code_list, nameof(s.pay_code_list))); if (add || cf.Contains("dpc")) { if (s.default_pay_code != null) { f.FromSelect("default_paycode", _._(s.default_pay_code, nameof(s.default_pay_code))); } else { f.FromSelectByPredicate("default_paycode", _._(s.default_pay_code, nameof(s.default_pay_code)), (x, v) => true); } } if (add || cf.Contains("tla")) { f.Checked["taskLevelAssignment"] = _._(s.task_level_assignment, nameof(s.task_level_assignment)) == "Y"; } if (add || cf.Contains("pp")) { f.Values["probability"] = _._(s.probability_percent, nameof(s.probability_percent)); } // if (add || cf.Contains("pc2")) { f.Values["percentComplete"] = _._(s.percent_complete, nameof(s.percent_complete)); } if (add || cf.Contains("tr")) { f.FromSelectByKey("titoRequired", _._(s.tito_required, nameof(s.tito_required))); } if (add || cf.Contains("brs")) { f.FromSelectByKey("billRateSource", _._(s.bill_rate_source, nameof(s.bill_rate_source))); } if (add || cf.Contains("crs")) { f.FromSelectByKey("costRateSource", _._(s.cost_rate_source, nameof(s.cost_rate_source))); } if (add || cf.Contains("ulc")) { f.FromSelectByKey("useLaborCategory", _._(s.use_labor_category, nameof(s.use_labor_category))); } if (add || cf.Contains("ewd")) { f.Checked["enforceWBSDates"] = _._(s.enforce_wbs_dates, nameof(s.enforce_wbs_dates)) == "Y"; } if (add || cf.Contains("li")) { f.Checked["leaveBalance"] = _._(s.leave_ind, nameof(s.leave_ind)) == "Y"; } // if (add || cf.Contains("u1")) { f.FromSelect("udf_0", _._(s.user01, nameof(s.user01))); } if (add || cf.Contains("u2")) { f.FromSelect("udf_1", _._(s.user02, nameof(s.user02))); } if (add || cf.Contains("u3")) { f.FromSelect("udf_2", _._(s.user03, nameof(s.user03))); } if (add || cf.Contains("u4")) { f.FromSelect("udf_3", _._(s.user04, nameof(s.user04))); } if (add || cf.Contains("u5")) { f.FromSelect("udf_4", _._(s.user05, nameof(s.user05))); } if (add || cf.Contains("u6")) { f.FromSelect("udf_5", _._(s.user06, nameof(s.user06))); } if (add || cf.Contains("u7")) { f.FromSelect("udf_6", _._(s.user07, nameof(s.user07))); } if (add || cf.Contains("u8")) { f.FromSelect("udf_7", _._(s.user08, nameof(s.user08))); } if (add || cf.Contains("u9")) { f.FromSelect("udf_8", _._(s.user09, nameof(s.user09))); } if (add || cf.Contains("u10")) { f.FromSelect("udf_9", _._(s.user10, nameof(s.user10))); } // if (add || cf.Contains("bldc")) { f.Values["bgtLaborAmtCost"] = _._(s.budget_labor_dollars_cost, nameof(s.budget_labor_dollars_cost)); } if (add || cf.Contains("bedc")) { f.Values["bgtExpenseAmtCost"] = _._(s.budget_expense_dollars_cost, nameof(s.budget_expense_dollars_cost)); } if (add || cf.Contains("eldc")) { f.Values["etcLaborAmtCost"] = _._(s.etc_labor_dollars_cost, nameof(s.etc_labor_dollars_cost)); } if (add || cf.Contains("eedc")) { f.Values["etcExpenseAmtCost"] = _._(s.etc_expense_dollars_cost, nameof(s.etc_expense_dollars_cost)); } if (add || cf.Contains("etldc")) { f.Values["estTotalLaborAmtCost"] = _._(s.est_tot_labor_dollars_cost, nameof(s.est_tot_labor_dollars_cost)); } if (add || cf.Contains("etedc")) { f.Values["estTotalExpenseAmtCost"] = _._(s.est_tot_expense_dollars_cost, nameof(s.est_tot_expense_dollars_cost)); } // if (add || cf.Contains("pcr")) { f.FromSelectByKey("pctComplRule", _._(s.pct_complete_rule, nameof(s.pct_complete_rule))); } if (add || cf.Contains("pc3")) { f.FromSelectByKey("projectColor", _._(s.project_color, nameof(s.project_color))); } if (add || cf.Contains("papm")) { f.Checked["pmOpen"] = _._(s.proj_access_proj_manager, nameof(s.proj_access_proj_manager)) == "Y"; } if (add || cf.Contains("papv")) { f.Checked["viewerOpen"] = _._(s.proj_access_proj_viewer, nameof(s.proj_access_proj_viewer)) == "Y"; } //if (add || cf.Contains("parm")) f.Values["xxxx"] = _._(s.proj_access_resource_manager, nameof(s.proj_access_resource_manager)); if (add || cf.Contains("at2")) { f.Checked["timeCharge"] = _._(s.allows_time, nameof(s.allows_time)) == "Y"; } // if (add || cf.Contains("oo")) { f.Values["owningCustomer"] = _._(s.owning_organization, nameof(s.owning_organization)) != null && organizations.TryGetValue(s.owning_organization, out var organizationKey) ? organizationKey : "-1"; // LOOKUP } if (add || cf.Contains("bt")) { f.FromSelect("billingType", _._(s.billing_type, nameof(s.billing_type))); } if (add || cf.Contains("cs")) { f.FromSelect("costStructure", _._(s.cost_structure, nameof(s.cost_structure))); } //if (add || cf.Contains("ff")) f.Values["feeFactor_0"] = _._(s.fee_factor, nameof(s.fee_factor)); //if (add || cf.Contains("fcm")) f.FromSelect("feeMethod_0", _._(s.fee_calculation_method, nameof(s.fee_calculation_method))); if (add || cf.Contains("tv")) { f.Values["totalValue"] = _._(s.total_value, nameof(s.total_value)); } if (add || cf.Contains("fv")) { f.Values["fundedValue"] = _._(s.funded_value, nameof(s.funded_value)); } if (add || cf.Contains("bldcb")) { f.Values["burdenLaborAmtCost"] = _._(s.budget_labor_dollars_cost_burdened, nameof(s.budget_labor_dollars_cost_burdened)); } if (add || cf.Contains("bedcb")) { f.Values["burdenExpAmtCost"] = _._(s.budget_expense_dollars_cost_burdened, nameof(s.budget_expense_dollars_cost_burdened)); } // if (add || cf.Contains("rtc")) { f.Checked["require_comments"] = _._(s.require_time_comments, nameof(s.require_time_comments)) == "Y"; } if (add || cf.Contains("parp")) { f.Checked["rmOpen"] = _._(s.proj_access_resource_planner, nameof(s.proj_access_resource_planner)) == "Y"; } if (add || cf.Contains("para")) { f.Checked["raOpen"] = _._(s.proj_access_resource_assigner, nameof(s.proj_access_resource_assigner)) == "Y"; } if (add || cf.Contains("parr")) { f.Checked["rrOpen"] = _._(s.proj_access_resource_requestor, nameof(s.proj_access_resource_requestor)) == "Y"; } if (add || cf.Contains("dl")) { f.FromSelect("location", _._(s.default_location, nameof(s.default_location))); } if (add || cf.Contains("lr")) { f.Checked["location_required"] = _._(s.location_required, nameof(s.location_required)) == "Y"; } //if (add || cf.Contains("fft")) f.FromSelect("feeFactorType_0", _._(s.fee_factor_type, nameof(s.fee_factor_type))); if (add || cf.Contains("pacbm")) { f.Checked["bmOpen"] = _._(s.proj_access_billing_manager, nameof(s.proj_access_billing_manager)) == "Y"; } if (add || cf.Contains("pabv")) { f.Checked["bvOpen"] = _._(s.proj_access_billing_viewer, nameof(s.proj_access_billing_viewer)) == "Y"; } if (add || cf.Contains("lbtf")) { f.Checked["limitBillToFunded"] = _._(s.limit_bill_to_funded, nameof(s.limit_bill_to_funded)) == "Y"; } if (add || cf.Contains("lrtf")) { f.Checked["limitRevToFunded"] = _._(s.limit_rev_to_funded, nameof(s.limit_rev_to_funded)) == "Y"; } if (add || cf.Contains("pg")) { f.FromSelectStartsWith("postingGroup", _._(s.posting_group, nameof(s.posting_group))); } // //if (add || cf.Contains("tnepr")) f.Values["xxx"] = _._(s.ts_non_emp_po_required, nameof(s.ts_non_emp_po_required)); //if (add || cf.Contains("enepr")) f.Values["xxx"] = _._(s.exp_non_emp_po_required, nameof(s.exp_non_emp_po_required)); //if (add || cf.Contains("ai")) f.Checked["xxx"] = _._(s.allows_item, nameof(s.allows_item)) == "Y"; //if (add || cf.Contains("irt")) f.Checked["xxx"] = _._(s.item_requires_task, nameof(s.item_requires_task)) == "Y"; // if (add || cf.Contains("u11")) { f.FromSelect("udf_10", _._(s.user11, nameof(s.user11))); } //if (add || cf.Contains("u12")) f.Values["udf_11"] = _._(s.user12, nameof(s.user12)); if (add || cf.Contains("u13")) { f.Values["udf_12"] = _._(s.user13, nameof(s.user13)); } //if (add || cf.Contains("u14")) f.Values["udf_13"] = _._(s.user14, nameof(s.user14)); //if (add || cf.Contains("u15")) f.Values["udf_14"] = _._(s.user15, nameof(s.user15)); //if (add || cf.Contains("u16")) f.Values["udf_15"] = _._(s.user16, nameof(s.user16)); //if (add || cf.Contains("u17")) f.Values["udf_16"] = _._(s.user17, nameof(s.user17)); //if (add || cf.Contains("u18")) f.Values["udf_17"] = _._(s.user18, nameof(s.user18)); if (add || cf.Contains("u19")) { f.Values["udf_18"] = _._(s.user19, nameof(s.user19)); } if (add || cf.Contains("u20")) { f.FromSelect("udf_19", _._(s.user20, nameof(s.user20))); } // //if (add || cf.Contains("papdv")) f.Values["xxx"] = _tset(s.proj_access_proj_doc_viewer, nameof(s.proj_access_proj_doc_viewer)); //if (add || cf.Contains("papv")) f.Values["xxx"] = _._(s.proj_access_po_viewer, nameof(s.proj_access_po_viewer)); //if (add || cf.Contains("papv2")) f.Values["xxx"] = _._(s.proj_access_pr_viewer, nameof(s.proj_access_pr_viewer)); //f.Values["lastUseLaborCategoryIndex"] = "2"; f.Remove("email_alert", "time_elapsed_alert_pct", "funding_expended_alert_pct", "hour_alert_pct", "hour_alert_denom", "total_cost_alert_pct", "total_cost_alert_denom", "labor_cost_alert_pct", "labor_cost_alert_denom", "expense_cost_alert_pct", "expense_cost_alert_denom", "total_bill_alert_pct", "total_bill_alert_denom"); f.Add("button_save", "action", null); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_FixedPrice1 s, Action <string> lockFunc, Action <p_FixedPrice1> bespoke = null) { throw new NotSupportedException("FixedPrice Not Supported"); var _ = new ChangedFields(ManageFlags.FixedPriceChanged); bespoke?.Invoke(s); if (s.revenue_recognition_method == null) { throw new InvalidOperationException($"{s.project_code} not categorized"); } if (ManageRecordBase(s.key, s.XCF, 0, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } //throw new NotSupportedException(); var method = add ? HttpMethod.Post : HttpMethod.Put; // !cf.Contains("tainted") ? add ? HttpMethod.Post : HttpMethod.Put : HttpMethod.Delete; var(r, last) = await una.SubmitSubManageAsync("A", method, "projects/accounting/fixed_price_item", $"key={s.key}", $"projectkey={s.project_codeKey}", null, (z, f) => { if (f.Types["description"] == "disabled") { lockFunc(s.key); return(null); } //if (add || cf.Contains("poc")) f.Values["xxxx"] = _._(s.project_org_code, nameof(s.project_org_code)); //if (add || cf.Contains("pc")) f.Values["xxxx"] = _._(s.project_code, nameof(s.project_code)); if (add || cf.Contains("tn")) { f.FromSelectByPredicate("task", _._(s.task_name, nameof(s.task_name)), x => x.Value.StartsWith(s.task_name)); } var description = _._(s.description, nameof(s.description)); var description2 = !string.IsNullOrEmpty(_._(s.external_system_code, nameof(s.external_system_code))) ? $"{description},{s.external_system_code}" : description; if (add || cf.Contains("esc") || cf.Contains("d") || cf.Contains("bind")) { f.Values["description"] = description; } // if (add || cf.Contains("bd")) { f.Values["billDate"] = _._(s.bill_date, nameof(s.bill_date)).FromDateTime(); } if (add || cf.Contains("boc")) { f.Checked["useWbsEndDate"] = _._(s.bill_on_completion, nameof(s.bill_on_completion)) == "Y"; } if (add || cf.Contains("ba")) { f.Values["amount"] = _._(s.bill_amount, nameof(s.bill_amount)); } var recMethod = s.revenue_recognition_method == "WHEN_BILLED" ? "1" : s.revenue_recognition_method == "PERCENT_COMPLETE" ? "2" : s.revenue_recognition_method == "CUSTOM_SCHEDULE" ? "3" : throw new ArgumentOutOfRangeException(nameof(s.revenue_recognition_method), s.revenue_recognition_method); if (add || cf.Contains("rrm")) { f.FromSelectByKey("revRecMethod", recMethod); } f.Add("button_save", "action", null); return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_ProjectLaborCategory1 s, Action <p_ProjectLaborCategory1> bespoke = null) { var _ = new ChangedFields(ManageFlags.ProjectLaborCategoryChanged); bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } var laborCategories = Unanet.Lookups.LaborCategories.Value; var(r, last) = await una.SubmitSubManageAsync(add? "E" : "C", HttpMethod.Put, $"projects/labor_category", $"key={s.key}", $"projectkey={s.project_codeKey}", "blindInsert=false&list=true&reload=true&canEditBill=true&canEditCost=true&canViewBill=true&canViewCost=true&labor_category_dbValue=&labor_category_filterInactiveLabCat=false&showLaborCategory=false", (z, f) => { if (add) { f.Values["assign"] = laborCategories[_._(s.labor_category, nameof(s.labor_category))]; // LOOKUP } if (!add && cf.Contains("dtmr")) { f.FromSelectByKey("master", _._(s.default_to_master_rate, nameof(s.default_to_master_rate)) == "Y" ? "true" : "false"); } // edit rate row for effective_date|exempt_status|costStructLabor|bill_rate|cost_rate if (!add && (cf.Contains("ed") || cf.Contains("br") || cf.Contains("cr"))) { //throw new InvalidOperationException("MANUAL: found multiple rate rows"); if (f.Values["rateSize"] != "1") { f.Values["rateSize"] = "1"; f.Remove(f.Values.Keys.Where(x => (x.StartsWith("dbrate_") && x != "dbrate_0") || (x.StartsWith("bDate_") && x != "bDate_0") || (x.StartsWith("billRate_") && x != "billRate_0") || (x.StartsWith("costRate_") && x != "costRate_0")).ToArray()); } if (cf.Contains("ed") && _._(s.effective_date, nameof(s.effective_date)) != UnanetClient.BOT) { throw new InvalidOperationException($"MANUAL: {nameof(s.effective_date)} not BOT"); } if (cf.Contains("br")) { f.Values["billRate_0"] = _._(s.bill_rate, nameof(s.bill_rate)).ToString(); } if (cf.Contains("cr")) { f.Values["costRate_0"] = _._(s.cost_rate, nameof(s.cost_rate)).ToString(); } } if (add) { f.Add("button_save", "action", null); } else { f.Action = f.Action.Replace("/list", "/save"); } return(f.ToString()); }, formOptions : new HtmlFormOptions { Marker = add ? null : "<form name=\"simpleList\"" }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_Task1 s, Action <p_Task1> bespoke = null) { var _ = new ChangedFields(ManageFlags.TaskChanged); bespoke?.Invoke(s); if (ManageRecordBase(s.key, s.XCF, 0, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } var organizations = Unanet.Lookups.CostCenters.Value; var method = add ? HttpMethod.Post : HttpMethod.Put; var(r, last) = await una.SubmitSubManageAsync("B", method, "task", add? "key=0&insertPos=1" : $"key={s.key}&insertPos=0", $"projectkey={s.project_codeKey}", null, (z, f) => { //if (add || cf.Contains("poc")) f.Values["xxxx"] = _._(s.project_org_code, nameof(s.project_org_code)); //if (add || cf.Contains("pc")) f.Values["xxxx"] = _._(s.project_code, nameof(s.project_code)); if (add || cf.Contains("tn")) { f.Values["taskName"] = _._(s.task_name, nameof(s.task_name)); } if (add || cf.Contains("a")) { f.Checked["active"] = _._(s.active, nameof(s.active)) == "Y"; } // if (add || cf.Contains("osd")) { f.Values["orig_start_date"] = _._(s.original_start_date, nameof(s.original_start_date)).FromDateTime(); } if (add || cf.Contains("oed")) { f.Values["orig_end_date"] = _._(s.original_end_date, nameof(s.original_end_date)).FromDateTime(); } if (add || cf.Contains("rsd")) { f.Values["rev_start_date"] = _._(s.revised_start_date, nameof(s.revised_start_date)).FromDateTime("BOT"); } if (add || cf.Contains("red")) { f.Values["rev_end_date"] = _._(s.revised_end_date, nameof(s.revised_end_date)).FromDateTime("EOT"); } if (add || cf.Contains("cd")) { f.Values["completed"] = _._(s.completed_date, nameof(s.completed_date)).FromDateTime(); } // if (add || cf.Contains("pc2")) { f.Values["percentComplete"] = _._(s.percent_complete, nameof(s.percent_complete)); } if (add || cf.Contains("s")) { f.Values["status"] = _._(s.status, nameof(s.status)); } if (add || cf.Contains("o")) { f.Values["output"] = _._(s.output, nameof(s.output)); } if (add || cf.Contains("esc") || cf.Contains("bind")) { f.Values["externalSystemCode"] = _._(s.external_system_code, nameof(s.external_system_code)); } if (add || cf.Contains("bh")) { f.Values["hours_budget"] = _._(s.budget_hours, nameof(s.budget_hours)); } if (add || cf.Contains("eh")) { f.Values["hours_etc"] = _._(s.etc_hours, nameof(s.etc_hours)); } if (add || cf.Contains("eth")) { f.Values["hours_tot"] = _._(s.est_tot_hours, nameof(s.est_tot_hours)); } // if (add || cf.Contains("bldb")) { f.Values["labor_budget_bill"] = _._(s.budget_labor_dollars_bill, nameof(s.budget_labor_dollars_bill)); } if (add || cf.Contains("eldb")) { f.Values["labor_etc_bill"] = _._(s.etc_labor_dollars_bill, nameof(s.etc_labor_dollars_bill)); } if (add || cf.Contains("etldb")) { f.Values["labor_tot_bill"] = _._(s.est_tot_labor_dollars_bill, nameof(s.est_tot_labor_dollars_bill)); } if (add || cf.Contains("bedb")) { f.Values["expense_budget_bill"] = _._(s.budget_expense_dollars_bill, nameof(s.budget_expense_dollars_bill)); } if (add || cf.Contains("eedb")) { f.Values["expense_etc_bill"] = _._(s.etc_expense_dollars_bill, nameof(s.etc_expense_dollars_bill)); } if (add || cf.Contains("etedb")) { f.Values["expense_tot_bill"] = _._(s.est_tot_expense_dollars_bill, nameof(s.est_tot_expense_dollars_bill)); } // //if (add || cf.Contains("u1")) f.Values["udf_0"] = _._(s.user01, nameof(s.user01)); //if (add || cf.Contains("u2")) f.Values["udf_1"] = _._(s.user02, nameof(s.user02)); //if (add || cf.Contains("u3")) f.Values["udf_2"] = _._(s.user03, nameof(s.user03)); //if (add || cf.Contains("u4")) f.Values["udf_3"] = _._(s.user04, nameof(s.user04)); //if (add || cf.Contains("u5")) f.Values["udf_4"] = _._(s.user05, nameof(s.user05)); //if (add || cf.Contains("u6")) f.Values["udf_5"] = _._(s.user06, nameof(s.user06)); //if (add || cf.Contains("u7")) f.Values["udf_6"] = _._(s.user07, nameof(s.user07)); if (add || cf.Contains("u8")) { f.FromSelect("udf_7", _._(s.user08, nameof(s.user08))); } //if (add || cf.Contains("u9")) f.Values["udf_8"] = _._(s.user09, nameof(s.user09)); //if (add || cf.Contains("u10")) f.Values["udf_9"] = _._(s.user10, nameof(s.user10)); // if (add || cf.Contains("bldc")) { f.Values["labor_budget_cost"] = _._(s.budget_labor_dollars_cost, nameof(s.budget_labor_dollars_cost)); } if (add || cf.Contains("eldc")) { f.Values["labor_etc_cost"] = _._(s.etc_labor_dollars_cost, nameof(s.etc_labor_dollars_cost)); } if (add || cf.Contains("etldc")) { f.Values["labor_tot_cost"] = _._(s.est_tot_labor_dollars_cost, nameof(s.est_tot_labor_dollars_cost)); } if (add || cf.Contains("bedc")) { f.Values["expense_budget_cost"] = _._(s.budget_expense_dollars_cost, nameof(s.budget_expense_dollars_cost)); } if (add || cf.Contains("eedc")) { f.Values["expense_etc_cost"] = _._(s.etc_expense_dollars_cost, nameof(s.etc_expense_dollars_cost)); } if (add || cf.Contains("etedc")) { f.Values["expense_tot_cost"] = _._(s.est_tot_expense_dollars_cost, nameof(s.est_tot_expense_dollars_cost)); } // if (add || cf.Contains("pt")) { f.FromSelect("pjtType", _._(s.project_type, nameof(s.project_type))); } if (add || cf.Contains("d")) { f.Values["duration"] = _._(s.duration, nameof(s.duration)); } if (add || cf.Contains("ea")) { f.Checked["alertable"] = _._(s.enable_alerts, nameof(s.enable_alerts)) == "Y"; } if (add || cf.Contains("bt")) { f.FromSelect("billType", _._(s.billing_type, nameof(s.billing_type))); } // if (add || cf.Contains("bldcb")) { f.Values["labor_burden_cost"] = _._(s.budget_labor_dollars_cost_burdened, nameof(s.budget_labor_dollars_cost_burdened)); } if (add || cf.Contains("bedcb")) { f.Values["expense_burden_cost"] = _._(s.budget_expense_dollars_cost_burdened, nameof(s.budget_expense_dollars_cost_burdened)); } if (add || cf.Contains("fv")) { f.Values["funded_value"] = _._(s.funded_value, nameof(s.funded_value)); } //if (add || cf.Contains("lbtf")) f.Checked["limitBillToFunded"] = _._(s.limit_bill_to_funded, nameof(s.limit_bill_to_funded)) == "Y"; //if (add || cf.Contains("lrtf")) f.Checked["limitRevToFunded"] = _._(s.limit_rev_to_funded, nameof(s.limit_rev_to_funded)) == "Y"; if (add || cf.Contains("oo")) { f.Values["tOOMenu"] = GetLookupValue(organizations, _._(s.owning_organization, nameof(s.owning_organization))); } // if (add || cf.Contains("at")) { f.Values["time_assignment_flag"] = _._(s.allows_time, nameof(s.allows_time)); } if (add || cf.Contains("tnepr")) { f.Values["ts_sub_po_required"] = _._(s.ts_non_emp_po_required, nameof(s.ts_non_emp_po_required)); } if (add || cf.Contains("ae")) { f.Values["expense_assignment_flag"] = _._(s.allows_expense, nameof(s.allows_expense)); } if (add || cf.Contains("enepr")) { f.Values["exp_sub_po_required"] = _._(s.exp_non_emp_po_required, nameof(s.exp_non_emp_po_required)); } if (add || cf.Contains("ai")) { f.Values["item_assignment_flag"] = _._(s.allows_item, nameof(s.allows_item)); } // //if (add || cf.Contains("u11")) f.Values["udf_10"] = _._(s.user11, nameof(s.user11)); //if (add || cf.Contains("u12")) f.Values["udf_11"] = _._(s.user12, nameof(s.user12)); //if (add || cf.Contains("u13")) f.Values["udf_12"] = _._(s.user13, nameof(s.user13)); //if (add || cf.Contains("u14")) f.Values["udf_13"] = _._(s.user14, nameof(s.user14)); //if (add || cf.Contains("u15")) f.Values["udf_14"] = _._(s.user15, nameof(s.user15)); //if (add || cf.Contains("u16")) f.Values["udf_15"] = _._(s.user16, nameof(s.user16)); //if (add || cf.Contains("u17")) f.Values["udf_16"] = _._(s.user17, nameof(s.user17)); //if (add || cf.Contains("u18")) f.Values["udf_17"] = _._(s.user18, nameof(s.user18)); //if (add || cf.Contains("u19")) f.Values["udf_18"] = _._(s.user19, nameof(s.user19)); //if (add || cf.Contains("u20")) f.Values["udf_19"] = _._(s.user20, nameof(s.user20)); return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_ProjectInvoiceSetup1 s, Action <p_ProjectInvoiceSetup1> bespoke = null) { var _ = new ChangedFields(ManageFlags.ProjectInvoiceSetupChanged); bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } var(r, last) = await una.SubmitSubManageAsync("D", HttpMethod.Get, $"projects/accounting/invoice/edit", null, $"projectkey={s.project_codeKey}", null, (z, f) => { if (add || cf.Contains("gi")) { f.Checked["generateInvoice"] = _._(s.generate_invoice, nameof(s.generate_invoice)) == "Y"; } if (add || cf.Contains("io")) { f.Values["proj_invoice"] = _._(s.invoicing_option, nameof(s.invoicing_option)); f.Values["invoice_option"] = s.invoicing_option; } if (s.invoicing_option != "C") { f.Values["lead_projects_mod"] = "true"; f.Types["lead_projects"] = "disabled"; } else { //if (add || cf.Contains("lpoc")) f.Values["xxxx"] = _._(s.lead_project_org_code, nameof(s.lead_project_org_code)); //if (add || cf.Contains("lpc")) f.Values["xxxx"] = _._(s.lead_project_code, nameof(s.lead_project_code)); f.Types["contributorsnotAssigned_orgCode_fltr"] = "disabled"; f.Types["contributorsnotAssigned_projCode_fltr"] = "disabled"; f.Values["lead_projects_mod"] = "false"; f.Values["lead_projects"] = _._(s.lead_project_codeKey, nameof(s.lead_project_codeKey)); } // if (s.invoicing_option != "C") { if (add || cf.Contains("pif")) { f.FromSelect("invoiceFormat", _._(s.primary_invoice_format, nameof(s.primary_invoice_format))); } //if (add || cf.Contains("aif")) f.FromSelect("xxxx", _._(s.additional_invoice_formats, nameof(s.additional_invoice_formats))); if (add || cf.Contains("inf")) { f.FromSelectStartsWith("invoiceNumber", _._(s.invoice_number_format, nameof(s.invoice_number_format))); } if (add || cf.Contains("pt")) { f.FromSelect("paymentTerm", _._(s.payment_terms, nameof(s.payment_terms))); } } else { f.Types["invoiceFormat"] = "disabled"; //f.Types["xxxx"] = "disabled"; f.Types["invoiceNumber"] = "disabled"; f.Types["paymentTerm"] = "disabled"; } // if (s.invoicing_option != "C") { if (add || cf.Contains("btc")) { f.FromSelectStartsWith("bill_to_contact", _._(s.bill_to_contact, nameof(s.bill_to_contact))); } if (add || cf.Contains("bta")) { f.FromSelect("bill_to_address", !string.IsNullOrEmpty(_._(s.bill_to_address, nameof(s.bill_to_address))) ? s.bill_to_address : f.Selects["bill_to_address"].First().Value); } if (add || cf.Contains("stc")) { f.FromSelectStartsWith("ship_to_contact", _._(s.ship_to_contact, nameof(s.ship_to_contact))); } if (add || cf.Contains("sta")) { f.FromSelect("ship_to_address", _._(s.ship_to_address, nameof(s.ship_to_address))); } if (add || cf.Contains("rtc")) { f.FromSelectStartsWith("remit_to_contact", _._(s.remit_to_contact, nameof(s.remit_to_contact))); } if (add || cf.Contains("rta")) { f.FromSelect("remit_to_address", !string.IsNullOrEmpty(_._(s.remit_to_address, nameof(s.remit_to_address))) ? s.remit_to_address : f.Selects["remit_to_address"].First().Value); } if (add || cf.Contains("idm")) { f.FromSelectByKey("invoice_delivery_opt", _._(s.invoice_delivery_method, nameof(s.invoice_delivery_method))); } if (add || cf.Contains("emt")) { f.FromSelect("emailTemplate", _._(s.email_message_template, nameof(s.email_message_template))); } if (add || cf.Contains("tel")) { f.Values["toEmail"] = _._(s.to_email_list, nameof(s.to_email_list)); } if (add || cf.Contains("cel")) { f.Values["ccEmail"] = _._(s.cc_email_list, nameof(s.cc_email_list)); } if (add || cf.Contains("bel")) { f.Values["bccEmail"] = _._(s.bcc_email_list, nameof(s.bcc_email_list)); } if (add || cf.Contains("rdr")) { f.Checked["delivery_req"] = _._(s.req_delivery_receipt, nameof(s.req_delivery_receipt)) == "Y"; } if (add || cf.Contains("rrr")) { f.Checked["read_req"] = _._(s.req_read_receipt, nameof(s.req_read_receipt)) == "Y"; } } else { f.Types["bill_to_contact"] = "disabled"; f.Types["bill_to_address"] = "disabled"; f.Types["ship_to_contact"] = "disabled"; f.Types["ship_to_address"] = "disabled"; f.Types["remit_to_contact"] = "disabled"; f.Types["remit_to_address"] = "disabled"; f.Types["invoice_delivery_opt"] = "disabled"; f.Types["emailTemplate"] = "disabled"; f.Types["toEmail"] = "disabled"; f.Types["ccEmail"] = "disabled"; f.Types["bccEmail"] = "disabled"; f.Types["delivery_req"] = "disabled"; f.Types["read_req"] = "disabled"; } // if (s.invoicing_option != "C") { if (add || cf.Contains("spoc")) { f.Checked["showProjectOrgCode"] = _._(s.show_project_org_code, nameof(s.show_project_org_code)) == "Y"; } if (add || cf.Contains("spc")) { f.Checked["showProjectCode"] = _._(s.show_project_code, nameof(s.show_project_code)) == "Y"; } if (add || cf.Contains("spt")) { f.Checked["showProjectTitle"] = _._(s.show_project_title, nameof(s.show_project_title)) == "Y"; } if (add || cf.Contains("spfv")) { f.Checked["showProjectFundedValue"] = _._(s.show_project_funded_value, nameof(s.show_project_funded_value)) == "Y"; } if (add || cf.Contains("scl")) { f.Checked["showCompanyLogo"] = _._(s.show_company_logo, nameof(s.show_company_logo)) == "Y"; } if (add || cf.Contains("cl")) { f.FromSelect("companyLogo", _._(s.company_logo, nameof(s.company_logo))); } f.Types["companyLogo"] = f.Checked["showCompanyLogo"] ? "text" : "disabled"; if (add || cf.Contains("scn")) { f.Checked["showContractNumber"] = _._(s.show_contract_number, nameof(s.show_contract_number)) == "Y"; } if (add || cf.Contains("cn")) { f.Values["contractNumber"] = _._(s.contract_number, nameof(s.contract_number)); } f.Types["contractNumber"] = f.Checked["showContractNumber"] ? "text" : "disabled"; if (add || cf.Contains("son")) { f.Checked["showOrderNumber"] = _._(s.show_order_number, nameof(s.show_order_number)) == "Y"; } f.Types["orderNumber"] = f.Checked["showOrderNumber"] ? "text" : "disabled"; } else { f.Types["showProjectOrgCode"] = "disabled"; f.Types["showProjectCode"] = "disabled"; f.Types["showProjectTitle"] = "disabled"; f.Types["showProjectFundedValue"] = "disabled"; f.Types["showCompanyLogo"] = "disabled"; f.Types["companyLogo"] = "disabled"; f.Types["showContractNumber"] = "disabled"; f.Types["contractNumber"] = "disabled"; f.Types["showOrderNumber"] = "disabled"; f.Types["orderNumber"] = "text"; } // if (add || cf.Contains("on")) { f.Values["orderNumber"] = _._(s.order_number, nameof(s.order_number)); } if (add || cf.Contains("d")) { f.Values["description"] = _._(s.description, nameof(s.description)); } /*if (add || cf.Contains("im"))*/ f.Values["memo"] = _._(s.invoice_memo, nameof(s.invoice_memo)); f.Add("button_save", "action", null); return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_OrganizationContact1 s, Action <p_OrganizationContact1> bespoke = null) { var _ = new ChangedFields(ManageFlags.OrganizationContactChanged); bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } var list = add ? null : await GetListAsync(una, s.organization_codeKey).ConfigureAwait(false); //var key0 = list?.Where(x => string.Equals(x.Value[3].Item1, $"DEG, {s.last_name}", StringComparison.OrdinalIgnoreCase)).SingleOrDefault().Key; var key1 = list?.Where(x => string.Equals(x.Value[3].Item1, $"{s.last_name}, {s.first_name}", StringComparison.OrdinalIgnoreCase)).SingleOrDefault().Key; var key = key1; if (!add && key == null) { throw new Exception("unable to find record"); } var(r, last) = await una.SubmitSubManageAsync("A", add?HttpMethod.Post : HttpMethod.Put, "organizations/contacts", $"contactKey={key}&orgKey={s.organization_codeKey}", $"orgKey={s.organization_codeKey}", null, (z, f) => { //if (add || cf.Contains("oc")) f.Values["xxx"] = _._(s.organization_code, nameof(s.organization_code))s.; if (add || cf.Contains("s")) { f.Values["salutation"] = _._(s.salutation, nameof(s.salutation)); } if (add || cf.Contains("fn")) { f.Values["first_name"] = _._(s.first_name, nameof(s.first_name)); } if (add || cf.Contains("mi")) { f.Values["middleInitial"] = _._(s.middle_initial, nameof(s.middle_initial)); } if (add || cf.Contains("ln")) { f.Values["last_name"] = _._(s.last_name, nameof(s.last_name)); } if (add || cf.Contains("s2")) { f.Values["suffix"] = _._(s.suffix, nameof(s.suffix)); } if (add || cf.Contains("t")) { f.Values["title"] = _._(s.title, nameof(s.title)); } if (add || cf.Contains("c") || cf.Contains("bind")) { f.Values["comments"] = _._(s.comment, nameof(s.comment)); } // if (add || cf.Contains("a")) { f.Checked["active"] = _._(s.active, nameof(s.active)) == "Y"; } if (add || cf.Contains("dbt")) { f.Checked["default_bill_to"] = _._(s.default_bill_to, nameof(s.default_bill_to)) == "Y"; } if (add || cf.Contains("dst")) { f.Checked["default_ship_to"] = _._(s.default_ship_to, nameof(s.default_ship_to)) == "Y"; } if (add || cf.Contains("drt")) { f.Checked["default_remit_to"] = _._(s.default_remit_to, nameof(s.default_remit_to)) == "Y"; } //if (add || cf.Contains("cc")) f.Values["xxxx"] = _._(s.contact_category, nameof(s.contact_category)); //: no field // if (add || cf.Contains("u1")) { f.Values["udf_0"] = _._(s.user01, nameof(s.user01)); } //if (add || cf.Contains("u2")) f.Values["udf_1"] = _._(s.user02, nameof(s.user02)); //if (add || cf.Contains("u3")) f.Values["udf_2"] = _._(s.user03, nameof(s.user03)); //if (add || cf.Contains("u4")) f.Values["udf_3"] = _._(s.user04, nameof(s.user04)); //if (add || cf.Contains("u5")) f.Values["udf_4"] = _._(s.user05, nameof(s.user05)); //if (add || cf.Contains("u6")) f.Values["udf_5"] = _._(s.user06, nameof(s.user06)); //if (add || cf.Contains("u7")) f.Values["udf_6"] = _._(s.user07, nameof(s.user07)); //if (add || cf.Contains("u8")) f.Values["udf_7"] = _._(s.user08, nameof(s.user08)); //if (add || cf.Contains("u9")) f.Values["udf_8"] = _._(s.user09, nameof(s.user09)); //if (add || cf.Contains("u10")) f.Values["udf_9"] = _._(s.user10, nameof(s.user10)); // //if (add || cf.Contains("xa")) AddressModel.ManageRecord(f, s.addresses); //if (add || cf.Contains("xe")) EmailModel.ManageRecord(f, s.emails); //if (add || cf.Contains("xn")) PhoneModel.ManageRecord(f, s.phones); return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_OrganizationAddress1 s, Action <p_OrganizationAddress1> bespoke = null) { var _ = new ChangedFields(ManageFlags.OrganizationAddressChanged); string ToStreetAddress() { var b = new StringBuilder(); if (!string.IsNullOrEmpty(_._(s.street_address1, nameof(s.street_address1)))) { b.AppendLine(s.street_address1); } if (!string.IsNullOrEmpty(_._(s.street_address2, nameof(s.street_address2)))) { b.AppendLine(s.street_address2); } if (!string.IsNullOrEmpty(_._(s.street_address3, nameof(s.street_address3)))) { b.AppendLine(s.street_address3); } return(b.ToString()); } bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2)) { return(_.Changed(), last2); } var list = add ? null : await GetListAsync(una, s.organization_codeKey).ConfigureAwait(false); //if (list?.Count == 2 && Enumerable.SequenceEqual(list.ElementAt(0).Value, list.ElementAt(1).Value)) //{ // ctx.SubmitSubList("organizations/addresses", list.ElementAt(1).Key, $"orgKey={s.organization_codeKey}", "&streetAddress=&city=&state=&postalCode=&country=", true, out last); // return ManageFlags.OrganizationAddressChanged; //} if (list?.Count > 1) { return(_.Changed(), $"list > 1"); } var key = list?.Single().Key; var(r, last) = await una.SubmitSubManageAsync("C", add?HttpMethod.Post : HttpMethod.Put, "organizations/addresses", $"key={key}", $"orgKey={s.organization_codeKey}", "&streetAddress=&city=&state=&postalCode=&country=", (z, f) => { //if (add || cf.Contains("oc")) f.Values["xxx"] = _._(s.organization_code, nameof(s.organization_code))s.; if (add || cf.Contains("sa1") || cf.Contains("sa2") || cf.Contains("sa3")) { f.Values["streetAddress"] = ToStreetAddress(); } if (add || cf.Contains("c")) { f.Values["city"] = _._(s.city, nameof(s.city)); } if (add || cf.Contains("sp")) { f.Values["state"] = _._(s.state_province, nameof(s.state_province)); } if (add || cf.Contains("pc")) { f.Values["postalCode"] = _._(s.postal_code, nameof(s.postal_code)); } if (add || cf.Contains("c2")) { f.Values["country"] = _._(s.country, nameof(s.country)); } // if (add || cf.Contains("dbt")) { f.Checked["billTo"] = _._(s.default_bill_to, nameof(s.default_bill_to)) == "Y"; } if (add || cf.Contains("dst")) { f.Checked["shipTo"] = _._(s.default_ship_to, nameof(s.default_ship_to)) == "Y"; } if (add || cf.Contains("drt")) { f.Checked["remitTo"] = _._(s.default_remit_to, nameof(s.default_remit_to)) == "Y"; } return(f.ToString()); }).ConfigureAwait(false); return(_.Changed(r), last); }
public static async Task <(ChangedFields changed, string last)> ManageRecordAsync(UnanetClient una, p_Assignment1 s, Action <p_Assignment1> bespoke = null) { var _ = new ChangedFields(ManageFlags.AssignmentChanged); bespoke?.Invoke(s); if (ManageRecordBase(null, s.XCF, 1, out var cf, out var add, out var last2, canDelete: true)) { return(_.Changed(), last2); } var method = !cf.Contains("delete") ? add ? HttpMethod.Post : HttpMethod.Put : HttpMethod.Delete; switch (s.assignment_type) { case "1": { if (!Unanet.Lookups.TryGetCostCentersAndDefault(s.assign, out var assignKey)) { throw new InvalidOperationException($"unable to find org {s.assign}"); } var(r, last) = await una.SubmitSubManageAsync("E", method, $"projects/orgs", $"key={assignKey}&nextKey=0", $"projectkey={s.project_codeKey}", null, (z, f) => { if (add) { f.Values["assign"] = assignKey ?? throw new ArgumentOutOfRangeException(nameof(s.assign), s.assign); // LOOKUP f.Add("button_save", "action", null); } return(f.ToString()); }, formOptions : new HtmlFormOptions { ParseOptions = false }).ConfigureAwait(false); return(_.Changed(r), last); } case "2": { var(r, last) = await una.SubmitSubManageAsync(add? "E" : "F", method, $"projects/assignment", null, $"projectkey={s.project_codeKey}", "savedCriteria=&person_mod=false&personClass=com.unanet.page.projects.ScheduledPeopleMenu%24ScheduleListPeopleMenu&person_dbValue=&person_personOrgCode_fltr=&person_lastname_fltr=&person_outputActive=true&location_mod=false&locationClass=com.unanet.page.criteria.FilteredLocationMenu&location_dbValue=&location_location_fltr=&dateRange_bDate=BOT&dateRange_eDate=EOT&dateRange=bot_eot&unit=HOUR&showEstimates=true&savedListName=&criteriaClass=com.unanet.page.projects.AssignmentListCriteria&loadValues=true&restore=false&list=true", (z, f) => { if (add) { f.Values["assign"] = s.usernameKey ?? throw new ArgumentNullException(nameof(s.usernameKey)); f.Values["costStructLabor"] = "-1"; f.Values["beginDate"] = "BOT"; f.Types["beginDate"] = "text"; f.Values["endDate"] = "EOT"; f.Types["endDate"] = "text"; f.Checked["useWbsDates"] = false; f.Add("button_save", "action", null); return(f.ToString()); } else if (cf.Contains("delete")) { var doc = z.ToHtmlDocument(); var rows = doc.DocumentNode.Descendants("tr") .Where(x => x.Attributes["id"] != null && x.Attributes["id"].Value.StartsWith("r")) .ToDictionary( x => x.Attributes["id"].Value.Substring(1).Trim(), x => x.Descendants("td").ToArray()); var row = rows.SingleOrDefault(x => x.Value[3].InnerText.Contains($"({s.assign.ToLowerInvariant()})")); var key = row.Key ?? throw new ArgumentNullException(nameof(row.Key)); var keysListed = string.Join(",", rows.Keys); return($"projectkey={s.project_codeKey}&restore=true&key={key}&keysListed={keysListed}"); } return(null); }).ConfigureAwait(false); return(_.Changed(r), last); } default: throw new ArgumentOutOfRangeException(nameof(s.assignment_type), s.assignment_type); } }