Example #1
0
        public IEnumerable CaseHandler()
        {
            var @case = (SimpleCase)PXSelect <SimpleCase,
                                              Where <SimpleCase.caseID, Equal <Optional <SimpleCase.caseID> > > > .
                        Select(this, PXView.Parameters);

            var userId = PXAccess.GetUserID();

            if (@case != null && @case.CreatedByID != userId)
            {
                var currentContact = (Contact)PXSelect <Contact,
                                                        Where <Contact.userID, Equal <Required <Contact.userID> > > > .
                                     Select(this, userId);

                if (currentContact == null ||
                    (@case.ContactID != currentContact.ContactID && @case.CustomerID != currentContact.BAccountID))
                {
                    @case = null;
                }
            }
            if (@case == null)
            {
                throw new PXException(Messages.CaseNotFound);
            }
            yield return(@case);
        }
Example #2
0
        private void UpdateAcitivtyRemindInfo(object id, UpdateRemindInfo handler)
        {
            CRReminder remindInfo = RemindInfo.Select(id);

            if (remindInfo == null && id is Guid)
            {
                remindInfo              = (CRReminder)RemindInfo.Cache.Insert();
                remindInfo.RefNoteID    = (Guid)id;
                remindInfo.Owner        = PXAccess.GetUserID();
                remindInfo.ReminderDate = PXTimeZoneInfo.Now;
                RemindInfo.Cache.Normalize();
            }
            handler(remindInfo);
            RemindInfo.Update(remindInfo);
            using (var ts = new PXTransactionScope())
            {
                RemindInfo.Cache.Persist(PXDBOperation.Insert);
                RemindInfo.Cache.Persist(PXDBOperation.Update);
                ts.Complete(this);
            }
            RemindInfo.Cache.Persisted(false);
            ActivityList.Cache.Clear();
            ActivityList.View.Clear();
            ActivityCount.Cache.Clear();
            ActivityCount.View.Clear();
            ReminderList.Cache.Clear();
            ReminderList.View.Clear();
            ReminderListCurrent.View.Clear();
        }
Example #3
0
        protected virtual IEnumerable customer()
        {
            var userId         = PXAccess.GetUserID();
            var currentContact = (Contact)PXSelect <Contact,
                                                    Where <Contact.userID, Equal <Required <Contact.userID> > > > .
                                 Select(this, userId);

            foreach (BAccount row in this.QuickSelect(Customer.View.BqlSelect))
            {
                if (currentContact == null ||
                    row.BAccountID != currentContact.BAccountID)
                {
                    throw new PXException(Messages.AccountNotFound);
                }

                var  isOpenStr = PXView.Parameters[1].With(p => p.ToString());
                bool isOpen;
                if (bool.TryParse(isOpenStr, out isOpen))
                {
                    row.CasesCount = CalcAccountCases(row.BAccountID, isOpen);
                }
                else
                {
                    row.CasesCount = 0;
                }
                yield return(row);
            }
        }
        public virtual IEnumerable languageSearchSettings()
        {
            var cache         = LanguageSearchSettings.Cache;
            var oldDirtyValue = cache.IsDirty;

            foreach (PXResult <SMLanguageSearchSettings, WikiPageLanguage> record in
                     PXSelectJoinGroupBy <SMLanguageSearchSettings,
                                          RightJoin <WikiPageLanguage, On <WikiPageLanguage.language, Equal <SMLanguageSearchSettings.name> > >,
                                          Where <SMLanguageSearchSettings.userID, IsNull,
                                                 Or <SMLanguageSearchSettings.userID, Equal <Current <AccessInfo.userID> > > >,
                                          Aggregate <GroupBy <WikiPageLanguage.language,
                                                              GroupBy <SMLanguageSearchSettings.userID,
                                                                       GroupBy <SMLanguageSearchSettings.active> > > > > .
                     Select(this))
            {
                var langSettings = (SMLanguageSearchSettings)record;
                var pageLanguage = (WikiPageLanguage)record;
                if (langSettings.UserID == null)
                {
                    var fieldValues = new OrderedDictionary
                    {
                        { cache.GetField(typeof(SMLanguageSearchSettings.name)), pageLanguage.Language },
                        { cache.GetField(typeof(SMLanguageSearchSettings.userID)), PXAccess.GetUserID() },
                        { cache.GetField(typeof(SMLanguageSearchSettings.active)), false }
                    };
                    cache.Insert(fieldValues);
                    langSettings = (SMLanguageSearchSettings)cache.Current;
                }
                yield return(langSettings);
            }
            cache.IsDirty = oldDirtyValue;
        }
    /// <summary>
    /// The tlbPath callback event handler.
    /// </summary>
    protected void tlbPath_CallBack(object sender, PXCallBackEventArgs e)
    {
        if (e.Command.Name == "AddFav" && PXSiteMap.CurrentNode != null)
        {
            var currentNode   = PXSiteMap.CurrentNode;
            var entryScreenId = GetEntryNodeId(currentNode.ScreenID);

            if (!IsInFavoritesLegacy(entryScreenId))
            {
                screenRepository.SetFavoriteForScreen(entryScreenId, true);
            }
            else
            {
                screenRepository.SetFavoriteForScreen(entryScreenId, false);
            }
            PXContext.Session.FavoritesExists["FavoritesExists"] = null;
            PXSiteMap.FavoritesProvider.Clear();

            // check if favorites exists
            using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                       new PXDataField("UserID"), new PXDataFieldValue("UserID", PXAccess.GetUserID())))
            {
                e.Result = (exist == null) ? "0" : "1";
            }
        }
    }
    /// <summary>
    /// The tlbPath callback event handler.
    /// </summary>
    protected void tlbPath_CallBack(object sender, PXCallBackEventArgs e)
    {
        if (e.Command.Name == "AddFav" && PXSiteMap.CurrentNode != null)
        {
            Guid nodeID = PXSiteMap.CurrentNode.NodeID;
            if (!IsInFavorites(nodeID))
            {
                AddFavorite(screenTitle, nodeID);
            }
            else
            {
                PXDatabase.Delete <Favorite>(
                    new PXDataFieldRestrict("UserID", PXAccess.GetUserID()),
                    new PXDataFieldRestrict("SiteMapID", nodeID)
                    );
            }
            PXContext.Session.FavoritesExists["FavoritesExists"] = null;
            PXSiteMap.FavoritesProvider.Clear();

            // check if favorites exists
            using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                       new PXDataField("UserID"), new PXDataFieldValue("UserID", PXAccess.GetUserID())))
            {
                e.Result = (exist == null) ? "0" : "1";
            }
        }
    }
Example #7
0
        private void UpdateAcitivtyRemindInfo(object id, UpdateRemindInfo handler)
        {
            EPReminder remindInfo = RemindInfo.Select(id);

            if (remindInfo == null)
            {
                remindInfo = (EPReminder)RemindInfo.Cache.Insert();
                EPActivity activity = PXSelect <EPActivity, Where <EPActivity.taskID, Equal <Required <EPActivity.taskID> > > > .
                                      Select(this, id);

                remindInfo.NoteID = PXNoteAttribute.GetNoteID(Caches[typeof(EPActivity)], activity,
                                                              EntityHelper.GetNoteField(typeof(EPActivity)));
                remindInfo.UserID = PXAccess.GetUserID();
                remindInfo.Date   = PXTimeZoneInfo.Now;
                RemindInfo.Cache.Normalize();
            }
            handler(remindInfo);
            RemindInfo.Update(remindInfo);
            using (var ts = new PXTransactionScope())
            {
                RemindInfo.Cache.Persist(PXDBOperation.Insert);
                RemindInfo.Cache.Persist(PXDBOperation.Update);
                ts.Complete(this);
            }
            RemindInfo.Cache.Persisted(false);
            ActivityList.Cache.Clear();
            ActivityList.View.Clear();
            ActivityCount.Cache.Clear();
            ActivityCount.View.Clear();
            ReminderList.Cache.Clear();
            ReminderList.View.Clear();
            ReminderListCurrent.View.Clear();
        }
Example #8
0
        private void RefreshActivityReminder()
        {
            ActivityReminder.Expire();
            string key = _REMINDERLIST_SLOT_KEY_PREFIX + PXAccess.GetUserID();

            PXContext.SetSlot <EPActivityReminder>(key, null);
        }
        public string RefreshSmartsheetToken()
        {
            Guid loggedUser = PXAccess.GetUserID();

            Users usersRow = PXSelect <Users,
                                       Where <Users.pKID, Equal <Required <Users.pKID> > > >
                             .Select(this.Base, loggedUser);

            UsersSSExt usersSSExtRow = PXCache <Users> .GetExtension <UsersSSExt>(usersRow);

            PMSetup setupRow = PXSelect <PMSetup> .Select(this.Base);

            PMSetupSSExt setupSSExtRow = PXCache <PMSetup> .GetExtension <PMSetupSSExt>(setupRow);

            if (usersSSExtRow != null && usersSSExtRow.UsrSmartsheetRefreshToken != null)
            {
                List <string> ssToken = refreshToken(setupSSExtRow.UsrSmartsheetClientID, setupSSExtRow.UsrSmartsheetAppSecret, usersSSExtRow.UsrSmartsheetRefreshToken);

                if (ssToken.Count == 2)
                {
                    usersSSExtRow.UsrSmartsheetToken        = ssToken[0];
                    usersSSExtRow.UsrSmartsheetRefreshToken = ssToken[1];
                    this.Base.UserProfile.Update(usersRow);
                    this.Base.Actions.PressSave();

                    return(usersSSExtRow.UsrSmartsheetToken);
                }
            }

            return("");
        }
        private void insertApprovedVendLists(AVLTable curAVLTableCache, AVLLine curAVLLineCache)
        {
            if (curAVLTableCache == null || curAVLLineCache == null)
            {
                return;
            }

            var maint = PXGraph.CreateInstance <AVLCreateVendorListEntry>();

            maint.ProviderInsert <ApprovedVendLists>(
                new PXDataFieldAssign("AVLNbr", curAVLTableCache.Avlnbr),
                new PXDataFieldAssign("LineNbr", curAVLLineCache.LineNbr),
                new PXDataFieldAssign("AVLStatus", curAVLTableCache.AVLStatus), //Approved
                new PXDataFieldAssign("AVLDate", curAVLTableCache.Avldate),
                new PXDataFieldAssign("Descripton", curAVLTableCache.Descripton),
                new PXDataFieldAssign("VendorID", curAVLLineCache.VendorID),
                new PXDataFieldAssign("VendorName", curAVLLineCache.VendorName),
                new PXDataFieldAssign("InventoryID", curAVLLineCache.InventoryID),
                new PXDataFieldAssign("InventoryDesc", curAVLLineCache.InventoryDesc),
                new PXDataFieldAssign("Remark", curAVLLineCache.Remark),
                new PXDataFieldAssign("ApprovedByID", PXAccess.GetUserID()),
                new PXDataFieldAssign("ApprovedDateTime", DateTime.Now),
                new PXDataFieldAssign("CreatedByID", curAVLTableCache.CreatedByID),
                new PXDataFieldAssign("CreatedByScreenID", PXSiteMap.CurrentScreenID),
                new PXDataFieldAssign("CreatedDateTime", curAVLTableCache.CreatedDateTime),
                new PXDataFieldAssign("LastModifiedByID", curAVLTableCache.LastModifiedByID),
                new PXDataFieldAssign("LastModifiedByScreenID", PXSiteMap.CurrentScreenID),
                new PXDataFieldAssign("LastModifiedDateTime", curAVLTableCache.LastModifiedDateTime)
                );
        }
 public override void ProcessRequest(SubscribeRequest requestData)
 {
     if (requestData == null)
     {
         //Unsubscribe this user from *all* push notification
         PXDatabase.Delete <VXUserPushNotification>(
             new PXDataFieldRestrict <VXUserPushNotification.userID>(PXAccess.GetUserID())
             );
     }
     else
     {
         //Register endpoint. The page will always refresh its subscription on load.
         try
         {
             PXDatabase.Insert <VXUserPushNotification>(
                 new PXDataFieldAssign <VXUserPushNotification.userID>(PXAccess.GetUserID()),
                 new PXDataFieldAssign <VXUserPushNotification.endpoint>(requestData.Endpoint),
                 new PXDataFieldAssign <VXUserPushNotification.authKey>(requestData.Keys["auth"]),
                 new PXDataFieldAssign <VXUserPushNotification.receiverKey>(requestData.Keys["p256dh"]));
         }
         catch (PXDatabaseException e)
         {
             if (e.ErrorCode == PXDbExceptions.PrimaryKeyConstraintViolation)
             {
                 PXDatabase.Update <VXUserPushNotification>(
                     new PXDataFieldAssign <VXUserPushNotification.authKey>(requestData.Keys["auth"]),
                     new PXDataFieldAssign <VXUserPushNotification.receiverKey>(requestData.Keys["p256dh"]),
                     new PXDataFieldRestrict <VXUserPushNotification.userID>(PXAccess.GetUserID()),
                     new PXDataFieldRestrict <VXUserPushNotification.endpoint>(requestData.Endpoint));
             }
         }
     }
 }
        private IEnumerable getTemplates <TTemplate>(PXSelectBase <TTemplate> select)
            where TTemplate : CRFilterTemplate, new()
        {
            Hashtable hashTable = new Hashtable();

            foreach (TTemplate item in select.Cache.Updated)
            {
                hashTable.Add(item.FilterTemplateID, item);
                yield return(item);
            }
            foreach (TTemplate item in select.Cache.Inserted)
            {
                hashTable.Add(item.FilterTemplateID, item);
                yield return(item);
            }
            PXView view = new PXView(this, true, select.View.BqlSelect);

            foreach (TTemplate item in view.SelectMulti(graphTypeName, PXAccess.GetUserID()))
            {
                if (!hashTable.Contains(item.FilterTemplateID))
                {
                    yield return(item);
                }
            }
            if (hashTable.Count < 1)
            {
                select.Cache.IsDirty = false;
            }
        }
Example #13
0
    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();
                    }
                }
            }
        }
    }
Example #14
0
        private void RefreshActivityReminder()
        {
            ActivityReminder.Expire();
            string key = _REMINDERLIST_SLOT_KEY_PREFIX + PXAccess.GetUserID();

            PXContext.SetSlot <EPActivityReminder>(key, null);
            PXDatabase.ResetSlot <EPActivityReminder>(key, typeof(CRActivity), typeof(EPView), typeof(EPAttendee), typeof(CRReminder), typeof(UserPreferences));
        }
 /// <summary>
 /// Check if current node in Favorites.
 /// </summary>
 private bool IsInFavoritesLegacy(Guid nodeId)
 {
     using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                new PXDataField("SiteMapID"), new PXDataFieldValue("SiteMapID", nodeId),
                new PXDataFieldValue("UserID", PXAccess.GetUserID())))
     {
         return(exist != null);
     }
 }
        protected override void ReverseDocumentUpdate(OpportunityMaint graph, CROpportunity entity)
        {
            var doc = Documents.Current;

            Documents.Cache.SetValue <Document.description>(doc, entity.Subject);
            Documents.Cache.SetValue <Document.qualificationDate>(doc, PXTimeZoneInfo.Now);
            Documents.Cache.SetValue <Document.convertedBy>(doc, PXAccess.GetUserID());
            graph.Caches <TMain>().Update(GetMain(doc));
        }
Example #17
0
    /// <summary>
    /// Check if current node in Favorites.
    /// </summary>
    private bool IsInFavorites(Guid?siteId)
    {
        Guid nodeID = siteId.HasValue ? siteId.Value : PXSiteMap.CurrentNode.NodeID;

        using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                   new PXDataField("SiteMapID"), new PXDataFieldValue("SiteMapID", nodeID),
                   new PXDataFieldValue("UserID", PXAccess.GetUserID())))
        {
            return(exist != null);
        }
    }
Example #18
0
        /// <summary> RowSelected CROpportunity </summary>
        public void _(Events.RowSelected <CROpportunity> e, PXRowSelected baseMethod)
        {
            baseMethod?.Invoke(e.Cache, e.Args);
            var wgID = (e.Row as CROpportunity).WorkgroupID;
            var role = new PublicFunc().CheckAcessRoleByWP(PXAccess.GetUserID(), wgID);

            if (!role && wgID.HasValue)
            {
                throw new PXException("You don't have right to read this data.");
            }
        }
Example #19
0
        protected virtual string GenerateMailBody()
        {
            string res       = null;
            var    signature = ((UserPreferences)PXSelect <UserPreferences> .
                                Search <UserPreferences.userID>(this, PXAccess.GetUserID())).
                               With(pref => pref.MailSignature);

            if (signature != null && (signature = signature.Trim()) != string.Empty)
            {
                res += "<br />" + signature;
            }
            return(res);
        }
        protected static string GenerateMailBody(PXGraph graph)
        {
            string res       = null;
            var    signature = ((UserPreferences)PXSelect <UserPreferences> .
                                Search <UserPreferences.userID>(graph, PXAccess.GetUserID())).
                               With(pref => pref.MailSignature);

            if (signature != null && (signature = signature.Trim()) != string.Empty)
            {
                res += "<br />" + signature;
            }
            return(PX.Web.UI.PXRichTextConverter.NormalizeHtml(res));
        }
Example #21
0
            public static ActivityStatistics GetFromSlot(Source source)
            {
                Type[] tables = source.Tables ??
                                new Type[] { typeof(CRActivity), typeof(EPAttendee), typeof(EPView), typeof(UserPreferences) };
                string key = _ACTIVITY_SLOT_KEY_PREFIX + source.SrceenID + PXAccess.GetUserID();

                var slot = PXDatabase.GetSlot <ActivityStatistics, Source>(key, source, tables);

                if (slot != null && slot.Day != DateTime.Today)
                {
                    PXDatabase.ResetSlot <ActivityStatistics>(key, tables);
                    slot = PXDatabase.GetSlot <ActivityStatistics, Source>(key, source, tables);
                }
                return(slot);
            }
Example #22
0
        protected virtual IEnumerable cases()
        {
            var userId         = PXAccess.GetUserID();
            var currentContact = (Contact)PXSelect <Contact,
                                                    Where <Contact.userID, Equal <Required <Contact.userID> > > > .
                                 Select(this, userId);

            foreach (CaseInfo row in this.QuickSelect(Cases.View.BqlSelect))
            {
                if (row.CreatedByID != userId &&
                    (currentContact == null ||
                     (row.ContactID != currentContact.ContactID && row.CustomerID != currentContact.BAccountID)))
                {
                    continue;
                }
                yield return(row);
            }
        }
    /// <summary>
    /// The tlbPath callback event handler.
    /// </summary>
    protected void tlbPath_CallBack(object sender, PXCallBackEventArgs e)
    {
        if (e.Command.Name == "AddFav" && PXSiteMap.CurrentNode != null)
        {
            Guid nodeID = PXSiteMap.CurrentNode.NodeID;
            if (!IsInFavorites(nodeID))
            {
                AddFavorite(screenTitle, nodeID);
            }
            else
            {
                PXDatabase.Delete <Favorite>(
                    new PXDataFieldRestrict("UserID", PXAccess.GetUserID()),
                    new PXDataFieldRestrict("SiteMapID", nodeID)
                    );
            }
            PXContext.Session.FavoritesExists["FavoritesExists"] = null;
            PXSiteMap.FavoritesProvider.Clear();

            // check if favorites exists
            using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                       new PXDataField("UserID"), new PXDataFieldValue("UserID", PXAccess.GetUserID())))
            {
                e.Result = (exist == null) ? "0" : "1";
            }
        }
        else if (e.Command.Name == "ClearFilter")
        {
            var ds = PXPage.GetDefaultDataSource(this.Page);
            if (ds != null)
            {
                var action = ds.DataGraph.Actions[clearFilterCommand];
                if (action != null)
                {
                    action.Press();
                }
            }
            PXCallbackManager.RegisterJavaScript(
                "if (window['__px_alls'] && __px_alls(this) && __px_alls(this)['tlbPath'])__px_alls(this)['tlbPath'].items['clearFilter'].setVisible(false);");
        }
    }
Example #24
0
        /// <summary> RowSelected Engineering  </summary>
        public void _(Events.RowSelected <ENGineering> e)
        {
            var row     = e.Row as ENGineering;
            var prjType = SelectFrom <ENGProjectType> .View.Select(this).RowCast <ENGProjectType>();

            // Valid Work Group Access right
            var wgID = (e.Row as ENGineering).SalesRegion;

            int?ToNullableInt(string val)
            => int.TryParse(val, out var i) ? (int?)i : null;

            var role = new PublicFunc().CheckAcessRoleByWP(PXAccess.GetUserID(), ToNullableInt(wgID));

            if (!role && !string.IsNullOrEmpty(wgID))
            {
                throw new PXException("You don't have right to read this data.");
            }

            // Init prjtype ddl
            if (e.Row != null)
            {
                PXStringListAttribute.SetList <ENGineering.prjtype>(
                    e.Cache,
                    e.Row,
                    prjType.Select(x => x.Prjtype).ToArray(),
                    prjType.Select(x => x.Description).ToArray());
            }

            // Gerber Info Visible
            if (row != null && row.Prjtype?.ToLower() == "gerber")
            {
                PXUIFieldAttribute.SetVisible <ENGLine.geberFile>(this.CurrentLine.Cache, null, true);
                PXUIFieldAttribute.SetVisible <ENGLine.file3D>(this.CurrentLine.Cache, null, true);
                PXUIFieldAttribute.SetVisible <ENGLine.stackUpFile>(this.CurrentLine.Cache, null, true);
                PXUIFieldAttribute.SetVisible <ENGLine.deviceTopology>(this.CurrentLine.Cache, null, true);
                PXUIFieldAttribute.SetVisible <ENGLine.pCBATopology>(this.CurrentLine.Cache, null, true);
            }
        }
Example #25
0
    /// <summary>
    /// Append node with specified tutle to favorites.
    /// </summary>
    private void AddFavorite(string title, Guid?siteId)
    {
        if (String.IsNullOrEmpty(title) && siteId == null)
        {
            return;
        }

        Guid   folderID = PXSiteMap.RootNode.NodeID;
        string neutralTitle;

        using (PXDataRecord record = PXDatabase.SelectSingle <PX.SM.SiteMap>(new PXDataField("Title"),
                                                                             new PXDataFieldValue("NodeID", siteId)))
        {
            neutralTitle = record.GetString(0);
        }

        if (!string.IsNullOrEmpty(neutralTitle))
        {
            using (PXDataRecord rec_id = PXDatabase.SelectSingle <Favorite>(
                       new PXDataField("Max(Position)+1"),
                       new PXDataFieldValue("UserID", PXAccess.GetUserID())))
            {
                int pos = 1;
                if (rec_id != null)
                {
                    pos = rec_id.GetInt32(0) ?? 1;
                }
                PXDatabase.Insert <Favorite>(
                    new PXDataFieldAssign("UserID", PXAccess.GetUserID()),
                    new PXDataFieldAssign("NodeID", Guid.NewGuid()),
                    new PXDataFieldAssign("Title", neutralTitle),
                    new PXDataFieldAssign("ParentID", folderID),
                    new PXDataFieldAssign("Position", pos),
                    new PXDataFieldAssign("SiteMapID", siteId));
            }
        }
    }
Example #26
0
 protected void Logout(object sender, EventArgs e)
 {
     try
     {
         PXLogin.LogoutUser(PXAccess.GetUserName(), Session.SessionID);
         PXContext.Session.SetString("UserLogin", string.Empty);
         Session.Abandon();
         PX.Data.Auth.ExternalAuthHelper.SignOut(Context, "~/Frames/Outlook/FirstRun.html");
         PXDatabase.Delete <PX.SM.UserIdentity>(
             new PXDataFieldRestrict <PX.SM.UserIdentity.providerName>(PXDbType.VarChar, "ExchangeIdentityToken"),
             new PXDataFieldRestrict <PX.SM.UserIdentity.userID>(PXDbType.UniqueIdentifier, PXAccess.GetUserID())
             );
     }
     finally
     {
         PX.Data.Redirector.Redirect(System.Web.HttpContext.Current, "~/Frames/Outlook/FirstRun.html");
     }
 }
Example #27
0
        string receiptPOGoods(POReceipt pOReceipt, string pONbr, List<POReceiptLine> receiptLines)
        {
            string result = "";
            string transID = "";

            bool isOverSupply = false;

            try
            {
                ClientConversation.authenticate(userName, password);

                TransactionService transactionService = new TransactionService()
                {
                    Timeout = sessionTimeout,
                    Url = $"{urlPrefix(dbName)}TransactionService"
                };

                PLNSC.TransactionRef.OperationContext transContext = new PLNSC.TransactionRef.OperationContext()
                {
                    district = districtCode,
                    position = positionID,
                    maxInstances = maxInstance
                };

                transID = transactionService.begin(transContext);

                ReceiptDocumentService receipt = new ReceiptDocumentService()
                {
                    Timeout = sessionTimeout,
                    Url = $"{urlPrefix(dbName)}ReceiptDocumentService"
                };

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemService receiptPurchaseOrderItemService = new PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemService()
                {
                    Timeout = sessionTimeout,
                    Url = $"{urlPrefix(dbName)}ReceiptPurchaseOrderItemService"
                };

                PLNSC.ReceiptPurchaseOrderItemRef.OperationContext receiptPOItemContext = new PLNSC.ReceiptPurchaseOrderItemRef.OperationContext()
                {
                    district = transContext.district,
                    position = transContext.position,
                    maxInstances = transContext.maxInstances,
                    returnWarnings = transContext.returnWarnings,
                    trace = transContext.trace,
                    transaction = transID
                };

                PLNSC.ReceiptDocumentService.OperationContext receiptContext = new PLNSC.ReceiptDocumentService.OperationContext()
                {
                    district = transContext.district,
                    position = transContext.position,
                    maxInstances = transContext.maxInstances,
                    returnWarnings = transContext.returnWarnings,
                    trace = transContext.trace,
                    transaction = transID
                };

                var userID = PXAccess.GetUserID();
                EPEmployee ePEmployee = PXSelect<EPEmployee, Where<EPEmployee.userID, Equal<Required<EPEmployee.userID>>>>.Select(Base, PXAccess.GetUserID());
                string receivedByUser = ePEmployee.AcctCD.Trim() ?? "ADMIN";

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemSearchParam receiptPurchaseOrderItemSearchParam = new PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemSearchParam()
                {
                    documentDistrictCode = "SC01",
                    documentNumber = pONbr,
                    documentTypeDescription = "POP",
                    isReceiveAll = false
                };

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemDTO restartParam = new PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemDTO()
                {
                    documentNumber = "",
                    documentDistrictCode = "",
                    documentItem = "",
                    documentTypeDescription = "",
                    receiptDocumentType = ""
                };

                PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemServiceResult[] searchResult = receiptPurchaseOrderItemService.search(receiptPOItemContext, receiptPurchaseOrderItemSearchParam, restartParam);

                if (searchResult.Length > 0)
                {
                    PLNSC.ReceiptPurchaseOrderItemRef.Error[] searchErrors = searchResult[0].errors;
                    PLNSC.ReceiptPurchaseOrderItemRef.Message[] searchMsg = searchResult[0].informationalMessages;
                    if (searchErrors.Length > 0)
                    {
                        result = searchErrors[0].messageText;
                        transContext.transaction = transID;
                        transactionService.rollback(transContext);
                        return result;
                    }
                    
                    ReceiptPurchaseOrderItemDTO[] requestItem = new ReceiptPurchaseOrderItemDTO[searchResult.Length];
                    int arrIndex = 0;
                    foreach (PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemServiceResult receiptPurchaseOrderItemServiceResult in searchResult)
                    {
                        PLNSC.ReceiptPurchaseOrderItemRef.ReceiptPurchaseOrderItemDTO lineReceipt = receiptPurchaseOrderItemServiceResult.receiptPurchaseOrderItemDTO;

                        string testPOReceiptLine = Right("000" + lineReceipt.documentItem.Trim(), 3);
                        string receiptLine = lineReceipt.documentNumber != null ? testPOReceiptLine : "001";
                        decimal receiptQty = 0;
                        pONbr = lineReceipt.documentNumber != null ? lineReceipt.documentNumber.Trim() : " ";

                        foreach (POReceiptLine pOReceiptLine in receiptLines)
                        {
                            string poNbr = pOReceiptLine.PONbr.Trim();
                            string poLine = Right("000" + pOReceiptLine.POLineNbr.ToString(), 3);
                            if (poNbr == pONbr && poLine == receiptLine)
                            {
                                receiptQty = pOReceiptLine.ReceiptQty ?? 0;
                                decimal origOrderQty = pOReceiptLine.OrigOrderQty ?? 0;
                                decimal openOrderQty = pOReceiptLine.OpenOrderQty ?? 0;
                                decimal outstandingQty = openOrderQty != 0 ? openOrderQty : origOrderQty;
                                if (receiptQty > outstandingQty)
                                {
                                    isOverSupply = true;
                                }
                                else
                                {
                                    isOverSupply = false;
                                }
                            }
                        }

                        requestItem[arrIndex] = new ReceiptPurchaseOrderItemDTO()
                        {
                            documentNumber = lineReceipt.documentNumber.Trim() ?? " ",
                            custodianId = lineReceipt.custodianId.Trim() ?? " ",
                            documentItem = receiptLine,
                            receiptQuantity = receiptQty,
                            receiptQuantitySpecified = true,
                            documentTypeDescription = lineReceipt.documentTypeDescription.Trim() ?? " ",
                            documentType = lineReceipt.documentType.Trim() ?? " ",
                            deliveryLocation = lineReceipt.deliveryLocation.Trim() ?? " ",
                            isReceive = true,
                            isReceiveSpecified = true,
                            isCompleteItem = false,
                            isCompleteItemSpecified = true,
                            isOverSupplyItem = isOverSupply,
                            isOverSupplyItemSpecified = true,
                            isBinCodeDisabled = lineReceipt.isBinCodeDisabled,
                            isBinCodeDisabledSpecified = true,
                            isCategoryCodeDisabled = lineReceipt.isCategoryCodeDisabled,
                            isCategoryCodeDisabledSpecified = true,
                            receiptDocumentType = lineReceipt.receiptDocumentType.Trim() ?? " ",
                            receivingDistrictCode = lineReceipt.receivingDistrictCode.Trim() ?? " ",
                            receivingWarehouseId = lineReceipt.receivingWarehouseId.Trim() ?? " ",
                            requestedByEmployeeId = receivedByUser,
                            purchaseRequisition = lineReceipt.purchaseRequisition.Trim() ?? " ",
                            unitOfPurchase = lineReceipt.unitOfPurchase.Trim() ?? " ",
                            unitOfIssueOutstanding = lineReceipt.unitOfIssueOutstanding,
                            unitOfIssueOutstandingSpecified = true,
                            unitOfMeasure = lineReceipt.unitOfMeasure.Trim() ?? " ",
                            unitOfPurchaseOutstanding = lineReceipt.unitOfPurchaseOutstanding,
                            unitOfPurchaseOutstandingSpecified = true
                        };
                        arrIndex += 1;
                    }

                    ReceiptDocumentDTO request = new ReceiptDocumentDTO()
                    {
                        documentNumber = pONbr,
                        receiptReference = "G-" + pOReceipt.ReceiptNbr.Trim() + "RC",
                        receiptPurchaseOrderItemDTOs = requestItem,
                        receiptDate = DateTime.Now,
                        receiptDateSpecified = true,
                        isReceiveAll = false,
                        isReceiveAllSpecified = true,
                        receivedBy = receivedByUser,
                        receivedByPosition = "INTPO",
                        receivingDistrictCode = "SC01",
                        documentDistrictCode = "SC01",
                        documentTypeDescription = "POP"
                    };

                    ReceiptDocumentServiceResult receiptDocumentServiceResult = receipt.update(receiptContext, request);
                    PLNSC.ReceiptDocumentService.Error[] updErrors = receiptDocumentServiceResult.errors;
                    PLNSC.ReceiptDocumentService.Message[] updMessages = receiptDocumentServiceResult.informationalMessages;

                    if (updErrors.Length > 0)
                    {
                        result = updErrors[0].messageText;
                        transContext.transaction = transID;
                        transactionService.rollback(transContext);
                    }
                    else
                    {
                        result = "OK";
                        transContext.transaction = transID;
                        transactionService.commit(transContext);
                    }
                }
                else
                {
                    return "No Item To receive or All Item has already been received";
                }
                //ReceiptPurchaseOrderItemDTO[] requestItem = new ReceiptPurchaseOrderItemDTO[receiptLines.Count];
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return result;
        }
Example #28
0
    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();
                    }
                }
            }
        }
    }
Example #29
0
    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);
        }
    }