Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
                    }
                }
            }
        }
Пример #3
0
        public virtual IEnumerable counters()
        {
            ActivityStatistics.Source[] sources = new[]
            {
                new ActivityStatistics.Source("EP404000", null, Sprite.Main.Task),
                new ActivityStatistics.Source("EP404100", "Events", Sprite.Main.Event),
                new ActivityStatistics.Source("CO409000", null, Sprite.Main.MailReceive),
                new ActivityStatistics.Source("EP503010", null, Sprite.Main.Roles, new[] { typeof(EPApproval), typeof(UserPreferences) }),
            };
            var result = new List <PX.Data.EP.ActivityService.Total>();

            foreach (var source in sources)
            {
                ActivityStatistics statistics = ActivityStatistics.GetFromSlot(source);
                if (statistics != null && statistics.Count > 0)
                {
                    var node = PXSiteMap.Provider.FindSiteMapNodeByScreenID(source.SrceenID);
                    if (node == null || PXAccess.VerifyRights(node.ScreenID) != true)
                    {
                        continue;
                    }

                    var rec = new PX.Data.EP.ActivityService.Total();
                    rec.ScreenID = source.SrceenID;
                    rec.ImageKey = source.ImageKey;
                    rec.ImageSet = source.ImageSet;
                    rec.Url      = node.Url;
                    rec.Title    = node.Title;
                    rec.Count    = statistics.Count;
                    rec.NewCount = statistics.UnreadCount;
                    yield return(rec);
                }
            }
        }
Пример #4
0
    protected void Page_Init(object sender, EventArgs e)
    {
        this.usrCaption.CustomizationAvailable = false;
        this.ds.ReportCode = this.Request.QueryString["ID"];
        if (!String.IsNullOrEmpty(this.ds.ReportCode) && this.ds.ReportCode.Contains(".rpx"))
        {
            this.ds.ReportCode = this.ds.ReportCode.Replace(".rpx", "");
        }
        string screenID = null;
        object date     = PX.Common.PXContext.GetBusinessDate();

        PX.Common.PXContext.SetBusinessDate((DateTime?)date);
        if (PXSiteMap.CurrentNode != null)
        {
            this.Title = PXSiteMap.CurrentNode.Title;
            screenID   = PXSiteMap.CurrentNode.ScreenID;
        }
        else
        {
            string        url  = (Request.ApplicationPath != "/" ? Request.Path.Replace(Request.ApplicationPath, "~") : "~" + Request.Path) + "?id=" + this.ds.ReportCode + ".rpx";
            PXSiteMapNode node = SiteMap.Provider.FindSiteMapNode(url) as PXSiteMapNode;
            if (node != null)
            {
                this.Title = node.Title;
                this.usrCaption.ScreenTitle = node.Title;
                this.usrCaption.ScreenID    = PX.Common.Mask.Format("CC.CC.CC.CC", node.ScreenID);
                screenID = node.ScreenID;
            }
            else
            {
                using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>(
                           new PXDataField("ScreenID"),
                           new PXDataFieldValue("Url", PXDbType.VarChar, 512, url)
                           ))
                {
                    if (record != null)
                    {
                        screenID = record.GetString(0);
                        if (!String.IsNullOrEmpty(screenID) && !PXAccess.VerifyRights(screenID))
                        {
                            throw new PXSetPropertyException(ErrorMessages.NotEnoughRights, this.ds.ReportCode);
                        }
                    }
                }
            }
        }
        if (String.IsNullOrEmpty(PX.Common.PXContext.GetScreenID()) && !String.IsNullOrEmpty(screenID))
        {
            PX.Common.PXContext.SetScreenID(PX.Common.Mask.Format(">CC.CC.CC.CC", screenID));
        }
        if (_canSendEmail)
        {
            viewer.EmailSend += new PXReportViewer.EmailSendHandler(viewer_EmailSend);
        }
        else
        {
            viewer.AllowSendEmails = false;
        }
    }
Пример #5
0
        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 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);
        }
    protected void Page_Init(object sender, EventArgs e)
    {
        // remove unum parameter
        PropertyInfo isreadonly = typeof(System.Collections.Specialized.NameValueCollection).GetProperty("IsReadOnly", BindingFlags.Instance | BindingFlags.NonPublic);

        // make collection editable
        isreadonly.SetValue(this.Request.QueryString, false, null);
        this.Request.QueryString.Remove(PXUrl.UNum);
        isreadonly.SetValue(this.Request.QueryString, true, null);

        this.usrCaption.CustomizationAvailable = false;

        var date = PXContext.GetBusinessDate();

        PX.Common.PXContext.SetBusinessDate((DateTime?)date);

        if ((this.viewer.SchemaUrl = this.Request.QueryString["ID"]) == null)
        {
            this.viewer.SchemaUrl = ReportID;
        }

        if (SiteMap.CurrentNode != null)
        {
            this.Title = PXSiteMap.CurrentNode.Title;
            _screenID  = PXSiteMap.CurrentNode.ScreenID;
        }
        else
        {
            string url;
            if (Request.ApplicationPath != "/")
            {
                url = Request.Path.Replace(Request.ApplicationPath, "~") + "?ID=" + this.viewer.SchemaUrl;
            }
            else if (Request.Path.StartsWith("/"))
            {
                url = "~" + Request.Path;
            }
            else
            {
                url = Request.Path;
            }
            PXSiteMapNode node = SiteMap.Provider.FindSiteMapNode(url) as PXSiteMapNode;
            if (node != null)
            {
                this.Title = node.Title;
                this.usrCaption.ScreenTitle = node.Title;
                this.usrCaption.ScreenID    = PX.Common.Mask.Format(">CC.CC.CC.CC", node.ScreenID);
                _screenID = node.ScreenID;
            }
            else
            {
                using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>(
                           new PXDataField("ScreenID"),
                           new PXDataFieldValue("Url", PXDbType.VarChar, 512, url)
                           ))
                {
                    if (record != null)
                    {
                        _screenID = record.GetString(0);
                        if (!String.IsNullOrEmpty(_screenID) && !PXAccess.VerifyRights(_screenID))
                        {
                            throw new PXSetPropertyException(ErrorMessages.NotEnoughRights, this.viewer.SchemaUrl);
                        }
                    }
                }
            }
        }
        if (String.IsNullOrEmpty(PX.Common.PXContext.GetScreenID()))
        {
            if (String.IsNullOrEmpty(_screenID) && !String.IsNullOrEmpty(this.viewer.SchemaUrl))
            {
                string schema = this.viewer.SchemaUrl;
                if (schema.EndsWith(".rpx", StringComparison.OrdinalIgnoreCase))
                {
                    schema = schema.Substring(0, schema.Length - 4);
                }
                if (schema.Length == 8)
                {
                    _screenID = schema;
                }
            }
            if (!String.IsNullOrEmpty(_screenID))
            {
                PX.Common.PXContext.SetScreenID(PX.Common.Mask.Format(">CC.CC.CC.CC", _screenID));
            }
        }
        if (_canSendEmail)
        {
            viewer.EmailSend += new PXReportViewer.EmailSendHandler(viewer_EmailSend);
        }
        else
        {
            viewer.AllowSendEmails = false;
        }
    }