private void CreateActivity(int classId, long?refNoteID, string typeCode, Action <object> initializeHandler) { var graphType = EPActivityPrimaryGraphAttribute.GetGraphType(classId); if (!PXAccess.VerifyRights(graphType)) { throw new AccessViolationException(CR.Messages.FormNoAccessRightsMessage(graphType)); } var cache = CreateInstanceCache <EPActivity>(graphType); if (cache != null) { var owner = EmployeeMaint.GetCurrentEmployeeID(cache.Graph); var activity = (EPActivity)cache.CreateCopy(cache.Insert()); activity.ClassID = classId; activity.RefNoteID = refNoteID; if (!string.IsNullOrEmpty(typeCode)) { activity.Type = typeCode; } activity.Owner = owner; if (initializeHandler != null) { initializeHandler(activity); } cache.Update(activity); PXRedirectHelper.TryRedirect(cache.Graph, PXRedirectHelper.WindowMode.NewWindow); } }
public virtual void NavigateToItem(EPActivity current) { if (current != null) { var graphType = EPActivityPrimaryGraphAttribute.GetGraphType(current); if (!PXAccess.VerifyRights(graphType)) { ReminderList.Ask(CR.Messages.AccessDenied, CR.Messages.FormNoAccessRightsMessage(graphType), MessageButtons.OK, MessageIcon.Error); } else { var graph = (PXGraph)PXGraph.CreateInstance(graphType); var cache = graph.Caches[current.GetType()]; var searchView = new PXView( graph, false, BqlCommand.CreateInstance(typeof(Select <>), cache.GetItemType())); var startRow = 0; var totalRows = 0; var acts = searchView. Select(null, null, new object[] { current.TaskID }, new string[] { typeof(EPActivity.taskID).Name }, null, null, ref startRow, 1, ref totalRows); if (acts != null && acts.Count > 0) { var act = acts[0]; cache.Current = act; PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow); } } } }
public virtual IEnumerable CancelRow(PXAdapter adapter) { var activity = ReadActivity(ExtractActivityID(adapter)); var graphType = activity.With(_ => _.ClassID).With(_ => EPActivityPrimaryGraphAttribute.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 IEnumerable messageDetails(PXAdapter a) { if (History.Current != null) { PXRedirectHelper.TryOpenPopup(History.Cache, History.Current, string.Empty); var activity = History.Current; var graphType = EPActivityPrimaryGraphAttribute.GetGraphType(activity); if (!PXAccess.VerifyRights(graphType)) { MassMails.Ask(Messages.AccessDenied, Messages.FormNoAccessRightsMessage(graphType), MessageButtons.OK, MessageIcon.Error); } else { var graph = PXGraph.CreateInstance(graphType); PXCache cache = graph.Caches[typeof(EPActivity)]; var searchView = new PXView( cache.Graph, false, BqlCommand.CreateInstance(typeof(Select <>), cache.GetItemType())); var startRow = 0; var totalRows = 0; var acts = searchView. Select(null, null, new object[] { activity.TaskID }, new string[] { typeof(EPActivity.taskID).Name }, null, null, ref startRow, 1, ref totalRows); if (acts != null && acts.Count > 0) { var act = acts[0]; cache.Current = act; throw new PXPopupRedirectException(cache.Graph, graphType.Name, true) { Mode = PXBaseRedirectException.WindowMode.NewWindow }; } } } yield return(MassMails.Current); }
public virtual void Cancel(string keys) { var act = SearchItem(keys) as EPActivity; if (act == null) { return; } var graphType = act.With(_ => _.ClassID).With(_ => EPActivityPrimaryGraphAttribute.GetGraphType(_.Value)); if (graphType != null) { var graph = Activator.CreateInstance(graphType) as IActivityMaint; if (graph != null) { graph.CancelRow(act); } } }
public void CreateEmailActivity(object refNoteID, int EmailAccountID, Action <object> initializeHandler) { var graphType = EPActivityPrimaryGraphAttribute.GetGraphType(CRActivityClass.Email); if (!PXAccess.VerifyRights(graphType)) { throw new AccessViolationException(CR.Messages.FormNoAccessRightsMessage(graphType)); } var cache = CreateInstanceCache <EPActivity>(graphType); if (cache != null) { var graph = cache.Graph; var newEmail = (EPActivity)cache.CreateInstance(); newEmail.Type = null; newEmail.IsIncome = false; if (EmailAccountID != 0) { FillMailAccount(newEmail, EmailAccountID); } else { FillMailAccount(newEmail); } FillMailCC(graph, newEmail, (long?)refNoteID); newEmail.RefNoteID = (long?)refNoteID; newEmail.Body = GenerateMailBody(graph); if (initializeHandler != null) { initializeHandler(newEmail); } cache.Insert(newEmail); PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow); } }