public virtual IEnumerable CancelRow(PXAdapter adapter) { var activity = ReadActivity(ExtractActivityID(adapter)); var graphType = activity.With(_ => _.ClassID).With(_ => CRActivityPrimaryGraphAttribute.GetGraphType(_.Value)); if (graphType != null) { var graph = Activator.CreateInstance(graphType) as IActivityMaint; graph.CancelRow(activity); } adapter.Parameters = new object[0]; return(adapter.Get()); }
public virtual void Complete(string keys) { var act = SearchItem(keys) as CRActivity; if (act == null) { return; } var graphType = act.With(_ => _.ClassID).With(_ => CRActivityPrimaryGraphAttribute.GetGraphType(_.Value)); if (graphType != null) { var graph = Activator.CreateInstance(graphType) as IActivityMaint; if (graph != null) { graph.CompleteRow(act); } } }
public void CreateEmailActivity(object refNoteID, int EmailAccountID, Action <object> initializeHandler) { var graphType = CRActivityPrimaryGraphAttribute.GetGraphType(CRActivityClass.Email); if (!PXAccess.VerifyRights(graphType)) { throw new AccessViolationException(CR.Messages.FormNoAccessRightsMessage(graphType)); } var cache = CreateInstanceCache <CRSMEmail>(graphType); if (cache != null) { var graph = cache.Graph; var newEmail = (CRSMEmail)cache.CreateInstance(); newEmail.Type = null; newEmail.IsIncome = false; if (EmailAccountID != 0) { FillMailAccount(newEmail, EmailAccountID); } else { FillMailAccount(newEmail); } FillMailCC(graph, newEmail, (Guid?)refNoteID); newEmail.RefNoteID = (Guid?)refNoteID; newEmail.Body = GenerateMailBody(graph); if (initializeHandler != null) { initializeHandler(newEmail); } cache.Insert(newEmail); PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow); } }
private void CreateActivity(int classId, Guid?refNoteID, string typeCode, Guid?owner, PXRedirectHelper.WindowMode windowMode = PXRedirectHelper.WindowMode.NewWindow) { var graphType = CRActivityPrimaryGraphAttribute.GetGraphType(classId); if (!PXAccess.VerifyRights(graphType)) { throw new AccessViolationException(CR.Messages.FormNoAccessRightsMessage(graphType)); } CRActivity activity = null; var cache = CreateInstanceCache <CRActivity>(graphType); if (cache == null) { return; } if (owner == null) { owner = EmployeeMaint.GetCurrentEmployeeID(cache.Graph); } Action <object> initializeHandler = delegate(object act1) { var act = act1 as CRActivity; if (act == null) { return; } act.ClassID = classId; act.RefNoteID = refNoteID; if (!string.IsNullOrEmpty(typeCode)) { act.Type = typeCode; } act.OwnerID = owner; }; EntityHelper helper = new EntityHelper(cache.Graph); var type = helper.GetEntityRowType(refNoteID); var entity = helper.GetEntityRow(type, refNoteID); Type entityGraphType = null; if (type != null) { PXPrimaryGraphAttribute.FindPrimaryGraph(cache.Graph.Caches[type], ref entity, out entityGraphType); } if (entityGraphType != null) { PXGraph entry = PXGraph.CreateInstance(entityGraphType); PXCache <CRActivity> activityCache = entry.Caches[typeof(CRActivity)] as PXCache <CRActivity>; if (activityCache != null) { entry.Views[entry.PrimaryView].Cache.Current = entity; activity = (CRActivity)activityCache.CreateInstance(); if (initializeHandler != null) { initializeHandler(activity); } activity = activityCache.InitNewRow(activity); } } if (activity == null) { activity = (CRActivity)cache.CreateInstance(); initializeHandler(activity); activity = ((PXCache <CRActivity>)cache).InitNewRow(activity); } cache.Update(activity); PXRedirectHelper.TryRedirect(cache.Graph, windowMode); }