Beispiel #1
0
        protected void FillPropertyValue()
        {
            PXCache cache = Base.Caches[typeof(FieldValue)];

            cache.Clear();

            PXCache <MergeParams> pcache = Base.Caches <MergeParams>();

            List <FieldValue> values     = new List <FieldValue>();
            HashSet <string>  fieldNames = new HashSet <string>();

            GetAllProperties(values, fieldNames);

            TMain targetEntity = GetTargetEntity(((MergeParams)pcache.Current).TargetEntityID ?? 0);

            Contact targetContact = GetTargetContact(targetEntity);
            Address targetAddress = GetTargetAddress(targetEntity);

            Dictionary <Type, object> targets = new Dictionary <Type, object>();

            targets[typeof(TMain)]   = targetEntity;
            targets[typeof(Contact)] = targetContact;
            targets[typeof(Address)] = targetAddress;

            foreach (FieldValue fieldValue in values)
            {
                InsertPropertyValue(fieldValue, targets);
            }
            cache.IsDirty = false;
        }
        protected virtual void ARInvoiceAlias_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            ARInvoiceAlias row      = e.Row as ARInvoiceAlias;
            CRCampaign     campaign = Campaign.Current;

            if (row == null || campaign == null)
            {
                return;
            }

            if (e.Operation == PXDBOperation.Insert)
            {
                PXDatabase.Update <ARInvoice>(
                    new PXDataFieldAssign <ARInvoice.campaignID>(campaign.CampaignID),
                    new PXDataFieldRestrict <ARInvoice.docType>(row.DocType),
                    new PXDataFieldRestrict <ARInvoice.refNbr>(row.RefNbr)
                    );
            }
            else if (e.Operation == PXDBOperation.Delete)
            {
                PXDatabase.Update <ARInvoice>(
                    new PXDataFieldAssign <ARInvoice.campaignID>(null),
                    new PXDataFieldRestrict <ARInvoice.docType>(row.DocType),
                    new PXDataFieldRestrict <ARInvoice.refNbr>(row.RefNbr)
                    );
            }

            sender.Clear();

            e.Cancel = true;
        }
            public virtual void OnPersist(IEnumerable <Organization> organizations)
            {
                OrganizationMaint organizationMaint = CreateInstance <OrganizationMaint>();

                PXCache organizationCache = organizationMaint.OrganizationView.Cache;

                PXDBTimestampAttribute timestampAttribute = organizationCache
                                                            .GetAttributesOfType <PXDBTimestampAttribute>(null, nameof(Organization.tstamp))
                                                            .First();

                timestampAttribute.RecordComesFirst = true;

                foreach (Organization organization in organizations)
                {
                    organizationMaint.Clear();

                    organizationMaint.BAccount.Current = organizationMaint.BAccount.Search <OrganizationBAccount.bAccountID>(organization.BAccountID);

                    organizationCache.Clear();
                    organizationCache.ClearQueryCache();

                    if (organization.ActualLedgerID < 0)
                    {
                        organization.ActualLedgerID = LedgerIDMap[organization.ActualLedgerID].LedgerID;
                    }

                    organizationCache.Current = organization;
                    organizationCache.SetStatus(organizationMaint.OrganizationView.Current, PXEntryStatus.Updated);

                    organizationMaint.Actions.PressSave();
                }
            }
    protected void Filltables()
    {
        Guid currentwikipage = new Guid(pageid);

        PXGraph article = PXGraph.CreateInstance(typeof(KBArticleMaint));

        PXCache response        = article.Caches[typeof(KBResponse)];
        PXCache responsesummary = article.Caches[typeof(KBResponseSummary)];

        PXResult <WikiPage, WikiPageLanguage> result = (PXResult <WikiPage, WikiPageLanguage>) PXSelectJoin <WikiPage,
                                                                                                             InnerJoin <WikiPageLanguage, On <WikiPageLanguage.pageID, Equal <WikiPage.pageID> > >,
                                                                                                             Where <WikiPage.pageID, Equal <Required <WikiPage.pageID> > >,
                                                                                                             OrderBy <Desc <WikiRevision.pageRevisionID> > >
                                                       .SelectWindowed(new PXGraph(), 0, 1, currentwikipage);

        Guid userId = PXAccess.GetUserID();
        PXResult <KBResponseSummary> resultsummary = (PXResult <KBResponseSummary>) PXSelect <KBResponseSummary, Where <KBResponseSummary.pageID, Equal <Required <KBResponseSummary.pageID> > > > .
                                                     SelectWindowed(article, 0, 1, currentwikipage);

        PXResult <KBResponse> resnonse = (PXResult <KBResponse>) PXSelect <KBResponse,
                                                                           Where <KBResponse.userID, Equal <Required <KBResponse.userID> >,
                                                                                  And <KBResponse.pageID, Equal <Required <KBResponse.pageID> > > > > .
                                         SelectWindowed(article, 0, 1, userId, currentwikipage);

        if (result != null)
        {
            WikiPage         wp  = result[typeof(WikiPage)] as WikiPage;
            WikiPageLanguage wpl = result[typeof(WikiPageLanguage)] as WikiPageLanguage;

            KBResponse newresnonse = response.CreateInstance() as KBResponse;

            if (resnonse != null)
            {
                newresnonse = resnonse[typeof(KBResponse)] as KBResponse;
                if (wp != null && wpl != null)
                {
                    Int16 res;
                    if (Int16.TryParse(Rate.Value.ToString(), out res))
                    {
                        newresnonse.PageID                 = currentwikipage;
                        newresnonse.RevisionID             = 1;
                        newresnonse.NewMark                = res;
                        newresnonse.Date                   = PXTimeZoneInfo.Now;
                        newresnonse.Summary                = "";
                        newresnonse.CreatedByID            = wp.CreatedByID;
                        newresnonse.CreatedByScreenID      = "WP00000";
                        newresnonse.CreatedDateTime        = wp.CreatedDateTime;
                        newresnonse.LastModifiedByID       = wp.LastModifiedByID;
                        newresnonse.LastModifiedByScreenID = "WP00000";
                        newresnonse.LastModifiedDateTime   = wp.LastModifiedDateTime;

                        response.Update(newresnonse);
                        response.PersistUpdated(newresnonse);
                        response.Clear();
                    }
                }
            }
        }
    }
Beispiel #5
0
        protected virtual void _(Events.FieldUpdated <Document, Document.allowOverrideShippingContactAddress> e)
        {
            var row = e.Row as Document;

            if (row == null)
            {
                return;
            }

            PXCache cacheShippingContact = GetShippingContactCache();

            if (cacheShippingContact != null)
            {
                PXCache cacheContact = GetContactCache();
                if (cacheContact.Current == null)
                {
                    cacheContact.Current = GetCurrentContact();
                }

                if (cacheShippingContact.Current == null)
                {
                    cacheShippingContact.Current = GetCurrentShippingContact();
                }
                IPersonalContact crShippingContact = cacheShippingContact.Current as IPersonalContact;
                if (crShippingContact != null)
                {
                    cacheShippingContact.SetValueExt <CRShippingContact.overrideContact>(crShippingContact, row.AllowOverrideShippingContactAddress);
                    if (cacheShippingContact.Current == null)
                    {
                        cacheShippingContact.Clear();
                        cacheShippingContact.Current = GetCurrentShippingContact();
                    }
                }
            }

            PXCache cacheShippingAddress = GetShippingAddressCache();

            if (cacheShippingAddress != null)
            {
                PXCache cacheAddress = GetAddressCache();
                if (cacheAddress.Current == null)
                {
                    cacheAddress.Current = GetCurrentAddress();
                }

                IAddress crShippingAddress = GetCurrentShippingAddress();
                if (crShippingAddress != null)
                {
                    cacheShippingAddress.SetValueExt <CRShippingAddress.overrideAddress>(crShippingAddress, row.AllowOverrideShippingContactAddress);
                    if (cacheShippingAddress.Current == null)
                    {
                        cacheShippingAddress.Clear();
                        cacheShippingAddress.Current = GetCurrentShippingAddress();
                    }
                }
            }
        }
Beispiel #6
0
        protected void FillPropertyValue(PXGraph graph, string viewName)
        {
            PXCache cache = Caches[typeof(FieldValue)];

            cache.Clear();
            foreach (FieldValue field in ProcessingProperties)
            {
                cache.Insert(field);
            }
            cache.IsDirty = false;
        }
Beispiel #7
0
        protected virtual void userSetupDialog()
        {
            EnsureUserSetup();
            PXCache setupCache = Base.Caches[typeof(TSetup)];

            if (UserSetupView.AskExt() == WebDialogResult.OK)
            {
                using (var tr = new PXTransactionScope())
                {
                    setupCache.Persist(PXDBOperation.Insert);
                    setupCache.Persist(PXDBOperation.Update);
                    tr.Complete();
                }
                Base.Clear();
            }
            else
            {
                setupCache.Clear();
                setupCache.ClearQueryCacheObsolete();
            }
        }
    protected void ViewCount()
    {
        if (pageid != null)
        {
            Guid currentwikipage = new Guid(pageid);

            PXGraph article         = PXGraph.CreateInstance(typeof(KBArticleMaint));
            PXCache responsesummary = article.Caches[typeof(KBResponseSummary)];
            PXCache responses       = article.Caches[typeof(KBResponse)];

            PXResult <WikiPage, WikiPageLanguage, WikiRevision> result = (PXResult <WikiPage, WikiPageLanguage, WikiRevision>) PXSelectJoin <WikiPage,
                                                                                                                                             InnerJoin <WikiPageLanguage, On <WikiPageLanguage.pageID, Equal <WikiPage.pageID> >,
                                                                                                                                                        InnerJoin <WikiRevision, On <WikiRevision.pageID, Equal <WikiPage.pageID> > > >,
                                                                                                                                             Where <WikiPage.pageID, Equal <Required <WikiPage.pageID> > > >
                                                                         .SelectWindowed(new PXGraph(), 0, 1, currentwikipage);

            Guid userId = PXAccess.GetUserID();
            PXResult <KBResponseSummary> resultsummary = (PXResult <KBResponseSummary>) PXSelect <KBResponseSummary, Where <KBResponseSummary.pageID, Equal <Required <KBResponseSummary.pageID> > > >
                                                         .SelectWindowed(article, 0, 1, currentwikipage);

            PXResult <KBResponse> resnonse = (PXResult <KBResponse>) PXSelect <KBResponse,
                                                                               Where <KBResponse.userID, Equal <Required <KBResponse.userID> >,
                                                                                      And <KBResponse.pageID, Equal <Required <KBResponse.pageID> > > > >
                                             .SelectWindowed(article, 0, 1, userId, currentwikipage);

            if (result != null)
            {
                WikiPage         wp  = result[typeof(WikiPage)] as WikiPage;
                WikiPageLanguage wpl = result[typeof(WikiPageLanguage)] as WikiPageLanguage;

                KBResponseSummary kbrs        = responsesummary.CreateInstance() as KBResponseSummary;
                KBResponse        newresnonse = responses.CreateInstance() as KBResponse;

                if (resultsummary != null)
                {
                    kbrs = resultsummary[typeof(KBResponseSummary)] as KBResponseSummary;
                }

                if (resnonse != null)
                {
                    newresnonse = resnonse[typeof(KBResponse)] as KBResponse;
                }

                if (wp != null && wpl != null)
                {
                    if (kbrs == null || kbrs.PageID == null)
                    {
                        kbrs.PageID                 = currentwikipage;
                        kbrs.Views                  = 1;
                        kbrs.Markcount              = 0;
                        kbrs.Marksummary            = 0;
                        kbrs.CreatedByID            = wp.CreatedByID;
                        kbrs.CreatedByScreenID      = "WP00000";
                        kbrs.CreatedDateTime        = wp.CreatedDateTime;
                        kbrs.LastModifiedByID       = wp.LastModifiedByID;
                        kbrs.LastModifiedByScreenID = "WP00000";
                        kbrs.LastModifiedDateTime   = wp.LastModifiedDateTime;
                        kbrs.tstamp                 = wp.tstamp;
                        responsesummary.Insert(kbrs);
                        responsesummary.PersistInserted(kbrs);
                        responsesummary.Clear();
                    }
                    else
                    {
                        kbrs.Views++;
                        responsesummary.Update(kbrs);
                        responsesummary.PersistUpdated(kbrs);
                        responsesummary.Clear();
                    }

                    if (newresnonse == null || newresnonse.PageID == null)
                    {
                        newresnonse.PageID                 = currentwikipage;
                        newresnonse.RevisionID             = 1;
                        newresnonse.OldMark                = 0;
                        newresnonse.NewMark                = 0;
                        newresnonse.Date                   = PXTimeZoneInfo.Now;
                        newresnonse.UserID                 = userId;
                        newresnonse.Summary                = "";
                        newresnonse.CreatedByID            = wp.CreatedByID;
                        newresnonse.CreatedByScreenID      = "WP00000";
                        newresnonse.CreatedDateTime        = wp.CreatedDateTime;
                        newresnonse.LastModifiedByID       = wp.LastModifiedByID;
                        newresnonse.LastModifiedByScreenID = "WP00000";
                        newresnonse.LastModifiedDateTime   = wp.LastModifiedDateTime;
                        newresnonse.tstamp                 = wp.tstamp;
                        responses.Insert(newresnonse);
                        responses.PersistInserted(newresnonse);
                        responses.Clear();
                    }
                }
            }
        }
    }
    protected void Rate_PageRate(object sender, EventArgs e)
    {
        Filltables();
        Guid currentwikipage = new Guid(pageid);

        PXGraph article = PXGraph.CreateInstance(typeof(KBArticleMaint));

        PXCache response        = article.Caches[typeof(KBResponse)];
        PXCache responsesummary = article.Caches[typeof(KBResponseSummary)];

        PXResult <WikiPage, WikiPageLanguage, WikiRevision> result = (PXResult <WikiPage, WikiPageLanguage, WikiRevision>) PXSelectJoin
                                                                     <WikiPage,
                                                                      InnerJoin <WikiPageLanguage, On <WikiPageLanguage.pageID, Equal <WikiPage.pageID> >,
                                                                                 InnerJoin <WikiRevision, On <WikiRevision.pageID, Equal <WikiPage.pageID> > > >,
                                                                      Where <WikiPage.pageID, Equal <Required <WikiPage.pageID> > >,
                                                                      OrderBy <Desc <WikiRevision.pageRevisionID> > > .SelectWindowed(new PXGraph(), 0, 1, currentwikipage);

        Guid userId = PXAccess.GetUserID();
        PXResult <KBResponseSummary> resultsummary = (PXResult <KBResponseSummary>) PXSelect <KBResponseSummary, Where <KBResponseSummary.pageID, Equal <Required <KBResponseSummary.pageID> > > >
                                                     .SelectWindowed(article, 0, 1, currentwikipage);

        PXResult <KBResponse> resnonse = (PXResult <KBResponse>) PXSelect <KBResponse,
                                                                           Where <KBResponse.userID, Equal <Required <KBResponse.userID> >,
                                                                                  And <KBResponse.pageID, Equal <Required <KBResponse.pageID> > > > > .SelectWindowed(article, 0, 1, userId, currentwikipage);

        if (result != null)
        {
            WikiPage         wp  = result[typeof(WikiPage)] as WikiPage;
            WikiPageLanguage wpl = result[typeof(WikiPageLanguage)] as WikiPageLanguage;

            KBResponseSummary kbrs        = responsesummary.CreateInstance() as KBResponseSummary;
            KBResponse        newresnonse = response.CreateInstance() as KBResponse;

            if (resultsummary != null)
            {
                kbrs = resultsummary[typeof(KBResponseSummary)] as KBResponseSummary;
            }

            if (resnonse != null)
            {
                newresnonse = resnonse[typeof(KBResponse)] as KBResponse;
                if (wp != null && wpl != null && newresnonse.NewMark != null)
                {
                    if (newresnonse.OldMark != 0)
                    {
                        kbrs.Marksummary = kbrs.Marksummary - newresnonse.OldMark;
                        kbrs.Marksummary = kbrs.Marksummary + newresnonse.NewMark;
                    }
                    else
                    {
                        kbrs.Markcount   = kbrs.Markcount + 1;
                        kbrs.Marksummary = kbrs.Marksummary + newresnonse.NewMark;
                    }

                    int    AvRate      = (int)((int)kbrs.Marksummary / (int)kbrs.Markcount);
                    Int32  Marksummary = (int)kbrs.Marksummary;
                    Int32  Markcount   = (int)kbrs.Markcount;
                    double dAvRate     = (double)Marksummary / (double)Markcount;
                    kbrs.AvRate = dAvRate;

                    responsesummary.Update(kbrs);
                    responsesummary.PersistUpdated(kbrs);
                    responsesummary.Clear();


                    newresnonse.PageID                 = currentwikipage;
                    newresnonse.RevisionID             = 1;
                    newresnonse.OldMark                = newresnonse.NewMark;
                    newresnonse.Date                   = PXTimeZoneInfo.Now;
                    newresnonse.Summary                = "";
                    newresnonse.CreatedByID            = wp.CreatedByID;
                    newresnonse.CreatedByScreenID      = "WP00000";
                    newresnonse.CreatedDateTime        = wp.CreatedDateTime;
                    newresnonse.LastModifiedByID       = wp.LastModifiedByID;
                    newresnonse.LastModifiedByScreenID = "WP00000";
                    newresnonse.LastModifiedDateTime   = wp.LastModifiedDateTime;

                    response.Update(newresnonse);
                    response.PersistUpdated(newresnonse);
                    response.Clear();
                }
            }

            else
            {
                if (wp != null && wpl != null && newresnonse.NewMark != null)
                {
                    newresnonse.PageID                 = currentwikipage;
                    newresnonse.RevisionID             = 1;
                    newresnonse.OldMark                = newresnonse.NewMark;
                    newresnonse.Date                   = PXTimeZoneInfo.Now;
                    newresnonse.UserID                 = userId;
                    newresnonse.Summary                = "";
                    newresnonse.CreatedByID            = wp.CreatedByID;
                    newresnonse.CreatedByScreenID      = "WP00000";
                    newresnonse.CreatedDateTime        = wp.CreatedDateTime;
                    newresnonse.LastModifiedByID       = wp.LastModifiedByID;
                    newresnonse.LastModifiedByScreenID = "WP00000";
                    newresnonse.LastModifiedDateTime   = wp.LastModifiedDateTime;

                    if (kbrs == null || kbrs.PageID == null)
                    {
                        kbrs.PageID                 = currentwikipage;
                        kbrs.CreatedByID            = wp.CreatedByID;
                        kbrs.CreatedByScreenID      = "WP00000";
                        kbrs.CreatedDateTime        = wp.CreatedDateTime;
                        kbrs.LastModifiedByID       = wp.LastModifiedByID;
                        kbrs.LastModifiedByScreenID = "WP00000";
                        kbrs.LastModifiedDateTime   = wp.LastModifiedDateTime;
                        kbrs.Markcount              = 1;
                        kbrs.Marksummary            = newresnonse.NewMark;

                        int    AvRate      = (int)((int)kbrs.Marksummary / (int)kbrs.Markcount);
                        Int32  Marksummary = (int)kbrs.Marksummary;
                        Int32  Markcount   = (int)kbrs.Markcount;
                        double dAvRate     = (double)Marksummary / (double)Markcount;
                        kbrs.AvRate = dAvRate;

                        responsesummary.Insert(kbrs);
                        responsesummary.PersistInserted(kbrs);
                        responsesummary.Clear();
                    }
                    else
                    {
                        kbrs.Markcount   = kbrs.Markcount + 1;
                        kbrs.Marksummary = kbrs.Marksummary + newresnonse.NewMark;
                        responsesummary.Update(kbrs);
                        responsesummary.PersistUpdated(kbrs);
                        responsesummary.Clear();
                    }
                    response.Insert(newresnonse);
                    response.PersistInserted(newresnonse);
                    response.Clear();
                }
            }

            string path = PXUrl.SiteUrlWithPath();
            path += path.EndsWith("/") ? "" : "/";
            var url = string.Format("{0}Wiki/{1}?pageid={2}",
                                    path, this.ResolveClientUrl("~/Wiki/ShowWiki.aspx"), pageid);
            url = url + "&rateid=" + Rate.Value;
            throw new Exception("Redirect0:" + url);
        }
    }