public object GetDefaultValue(string defaultValue) { object val = null; switch (defaultValue.ToLower()) { case "forcenull": val = System.DBNull.Value; break; case "currentofficerid": val = AtMng.OfficerLoggedOn.OfficerId; break; case "workingasid": val = AtMng.WorkingAsOfficer.OfficerId; break; case "workingasofficeid": val = AtMng.WorkingAsOfficer.OfficeRow.OfficeId; break; case "utcnow": val = DateTime.UtcNow; break; case "now": val = DateTime.Now; break; case "today": val = DateTime.Today; break; default: if (defaultValue.ToLower().StartsWith("today")) { val = ActivityBE.AtriumDateAdd(DateTime.Today, defaultValue.ToLower().Replace("today", "")); } else { val = defaultValue; } break; } return(val); }
public void MaintainBFDate(int linkId, string linkTable, string field, DateTime relDate) { //find all liked activities //how to find the activity if the link table info is not there //or if the ac is linked to the file //related field config data determines this //**** acbf.bfdate is of this form objectalias,fieldname AllowEdit = true; //find all acbf records that match ActivityConfig.ACBFRow[] acbfrs = (ActivityConfig.ACBFRow[])myA.AtMng.acMng.DB.ACBF.Select("BFDate like '" + linkTable + "%' and BFDate like '%" + field + "%'"); foreach (ActivityConfig.ACBFRow acbfr in acbfrs) { atriumDB.ActivityBFRow[] abfrs = (atriumDB.ActivityBFRow[])myA.DB.ActivityBF.Select("Completed=false and ACBFId=" + acbfr.ACBFId.ToString()); DateTime newBf; if (acbfr.BFDate.Contains(",")) { string[] args = acbfr.BFDate.Split(','); newBf = ActivityBE.AtriumDateAdd(relDate, args[2]); } else { newBf = ActivityBE.CalculateBFDate(field, relDate, acbfr.BFDate); } if (newBf < DateTime.Today) { newBf = DateTime.Today; } foreach (atriumDB.ActivityBFRow abfr in abfrs) { atriumDB.ActivityRow ar = abfr.ActivityRow; bool inContext = false; foreach (atriumDB.ProcessContextRow pcr in ar.ProcessRow.GetProcessContextRows()) { if (pcr.LinkTable == linkTable & pcr.LinkId == linkId) { inContext = true; } } if (!ar.IsLinkTableNull() && ar.LinkTable == linkTable && ar.LinkID == linkId) //best match { abfr.BFDate = newBf; abfr.InitialBFDate = abfr.BFDate; } else if (inContext) //check for process context match { abfr.BFDate = newBf; abfr.InitialBFDate = abfr.BFDate; } else if (ar.IsLinkTableNull()) //should this be allowed { abfr.BFDate = newBf; abfr.InitialBFDate = abfr.BFDate; } } } AllowEdit = false; }