Exemplo n.º 1
0
        protected virtual void FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
        {
            EPEmployee employee = PXSelect <EPEmployee, Where <EPEmployee.acctCD, Equal <Required <EPEmployee.acctCD> > > >
                                  .SelectWindowed(sender.Graph, 0, 1, e.NewValue);

            if (employee != null)
            {
                e.NewValue = employee.BAccountID;
                e.Cancel   = true;
            }
            else
            {
                PXFieldUpdating fu = this.GetAttribute <PXDimensionAttribute>().FieldUpdating;
                fu(sender, e);
                e.Cancel = false;

                fu = this.GetAttribute <PXSelectorAttribute>().SubstituteKeyFieldUpdating;
                fu(sender, e);
            }
        }
Exemplo n.º 2
0
        public override void Persist()
        {
            foreach (Users user in UserList.Cache.Deleted)
            {
                Contact cnt = (Contact)contact.View.SelectSingleBound(new object[] { user });
                if (cnt != null)
                {
                    cnt.UserID = null;
                    contact.Update(cnt);

                    EPEmployee emp = Employee.Select(cnt.ContactID);
                    if (emp != null)
                    {
                        emp = PXCache <EPEmployee> .CreateCopy(emp);

                        emp.UserID = null;
                        Employee.Update(emp);
                    }
                }
            }

            if (UserList.Current != null && UserList.Current.OverrideADRoles != true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                //notice that this select returns nothing if called on AccessUsers. AccessUsers::roleList() returns empty list;
                foreach (UsersInRoles userrole in RoleList.Select())
                {
                    RoleList.Delete(userrole);
                }
            }

            //if no local roles selected - disable override.
            if (UserList.Current != null && UserList.Current.OverrideADRoles == true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                if (RolesByUser.SelectSingle() == null)
                {
                    UserListCurrent.Current.OverrideADRoles = false;
                }
            }

            base.Persist();
        }
Exemplo n.º 3
0
        protected virtual void CSCalendar_RowDeleting(PXCache sender, PXRowDeletingEventArgs e)
        {
            CSCalendar row = e.Row as CSCalendar;

            if (row != null)
            {
                EPEmployeeClass refEmpClass = PXSelect <EPEmployeeClass, Where <EPEmployeeClass.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refEmpClass != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByEmployeeClass, refEmpClass.VendorClassID);
                }

                Carrier refCarrier = PXSelect <Carrier, Where <Carrier.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refCarrier != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByCarrier, refCarrier.CarrierID);
                }

                Contract refContract = PXSelect <Contract, Where <Contract.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refContract != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByContract, refContract.ContractID);
                }

                EPEmployee refEmployee = PXSelect <EPEmployee, Where <EPEmployee.calendarID, Equal <Current <CSCalendar.calendarID> > > > .SelectWindowed(this, 0, 1);

                if (refEmployee != null)
                {
                    e.Cancel = true;
                    throw new PXException(Messages.ReferencedByEmployee, refEmployee.ClassID);
                }
            }
        }
Exemplo n.º 4
0
        protected virtual IEnumerable members(
            [PXInt]
            int?WorkGroupID)
        {
            this.Members.Cache.AllowInsert = (WorkGroupID != null);
            CurrentSelected.WorkGroupID    = WorkGroupID;
            foreach (PXResult <EPCompanyTreeMember, EPEmployee, Users> res in PXSelectJoin <EPCompanyTreeMember,
                                                                                            LeftJoin <EPEmployee, On <EPEmployee.userID, Equal <EPCompanyTreeMember.userID> >,
                                                                                                      LeftJoin <Users, On <Users.pKID, Equal <EPCompanyTreeMember.userID> > > >,
                                                                                            Where <EPCompanyTreeMember.workGroupID, Equal <Required <EPCompanyTreeMember.workGroupID> > > > .Select(this, WorkGroupID))
            {
                EPCompanyTreeMember member = res;
                EPEmployee          emp    = res;
                Users user = res;

                if (string.IsNullOrEmpty(emp.AcctCD))
                {
                    Members.Cache.RaiseExceptionHandling <EPCompanyTreeMember.userID>(member, null, new PXSetPropertyException(PX.Objects.EP.Messages.UserWithoutEmployee, PXErrorLevel.RowWarning, user.Username));
                }
                yield return(new PXResult <EPCompanyTreeMember, EPEmployee>(member, emp));
            }
        }
Exemplo n.º 5
0
        protected virtual void Users_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            Contact c = (Contact)contact.View.SelectSingleBound(new object[] { e.Row });

            if (c != null)
            {
                c.UserID = null;
                contact.Update(c);

                EPEmployee emp = Employee.Select(c.ContactID);
                if (emp != null)
                {
                    emp = PXCache <EPEmployee> .CreateCopy(emp);

                    emp.UserID = null;
                    Employee.Update(emp);
                }
            }
            foreach (EPCompanyTreeMember member in Members.View.SelectMultiBound(new[] { e.Row }))
            {
                Members.Delete(member);
            }
        }
Exemplo n.º 6
0
        protected virtual void Users_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
        {
            Users   user = (Users)e.Row;
            Contact c    = (Contact)contact.View.SelectSingleBound(new object[] { user });

            if (user == null || c == null || user.PKID == c.UserID)
            {
                return;
            }

            c        = (Contact)contact.Cache.CreateCopy(c);
            c.UserID = user.PKID;
            contact.Update(c);

            EPEmployee emp = Employee.Select(c.ContactID);

            if (emp != null)
            {
                emp = PXCache <EPEmployee> .CreateCopy(emp);

                emp.UserID = user.PKID;
                Employee.Update(emp);
            }
        }
Exemplo n.º 7
0
        protected virtual void _(Events.FieldDefaulting <PMLaborCostRate, PMLaborCostRate.inventoryID> e)
        {
            if (Filter.Current != null && Filter.Current.InventoryID != null)
            {
                e.NewValue = Filter.Current.InventoryID;
            }
            else if (e.Row.EmployeeID != null)
            {
                EPEmployee employee = PXSelect <EPEmployee, Where <EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > > .Select(this, e.Row.EmployeeID);

                if (employee != null)
                {
                    PMLaborCostRate existing = PXSelect <PMLaborCostRate, Where <PMLaborCostRate.employeeID, Equal <Required <PMLaborCostRate.employeeID> >,
                                                                                 And <PMLaborCostRate.inventoryID, Equal <Required <PMLaborCostRate.inventoryID> >,
                                                                                      And <PMLaborCostRate.type, Equal <Required <PMLaborCostRate.type> >,
                                                                                           And <PMLaborCostRate.recordID, NotEqual <Required <PMLaborCostRate.recordID> > > > > > > .Select(this, e.Row.EmployeeID, employee.LabourItemID, e.Row.Type, e.Row.RecordID);

                    if (existing == null)
                    {
                        e.NewValue = employee.LabourItemID;
                    }
                }
            }
        }
Exemplo n.º 8
0
        public virtual IEnumerable tGTasks()
        {
            List <TGTimecardTask> tasks = new List <TGTimecardTask>();

            EPEmployee employee = Base.Employee.Current;

            if (employee != null)
            {
                DateTime startDate = PXWeekSelector2Attribute.GetWeekStartDate(Base.Document.Current.WeekID.Value);
                DateTime endDate   = PXWeekSelector2Attribute.GetWeekEndDate(this.Base, Base.Document.Current.WeekID.Value);

                TGEPEmployeeExtension employeeExt = PXCache <EPEmployee> .GetExtension <TGEPEmployeeExtension>(employee);

                using (TogglClient client = new TogglClient(employeeExt.UsrTGToken))
                {
                    foreach (TogglMap result in client.TGTimecardTaskList(startDate, endDate))
                    {
                        tasks.Add(TogglMapper.MapFromToggl(this.Base, result));
                    }
                }
            }

            return(tasks);
        }
Exemplo n.º 9
0
        string createProjectEstimate(SOOrder sOOrder)
        {
            string transID = "";
            string result  = "";

            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);

                EPEmployee ePEmployee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(Base, sOOrder.OwnerID);

                string estimatorId = ePEmployee != null ? ePEmployee.AcctCD : "ADMIN";

                ProjectEstimateService projectEstimateService = new ProjectEstimateService()
                {
                    Timeout = transactionService.Timeout,
                    Url     = $"{urlPrefix(dbName)}ProjectEstimateService"
                };

                PLNSC.ProjectEstimateRef.OperationContext projectEstimateOperationContext = new PLNSC.ProjectEstimateRef.OperationContext()
                {
                    district     = transContext.district,
                    position     = transContext.position,
                    maxInstances = transContext.maxInstances
                };

                //ProjectEstimateDTO[] projectEstimateDTOs = new ProjectEstimateDTO[1];
                ProjectEstimateDTO projectEstimateDTO = new ProjectEstimateDTO()
                {
                    districtCode                       = transContext.district,
                    projectNo                          = sOOrder.OrderNbr.Trim(),
                    estimateBuildMethod                = "T",
                    estimatorId                        = estimatorId,
                    directEstimateCost                 = Math.Round(sOOrder.OrderTotal ?? 0, 2),
                    directEstimateCostSpecified        = true,
                    directUnallocFinPeriodEst          = Math.Round(sOOrder.OrderTotal ?? 0, 2),
                    directUnallocFinPeriodEstSpecified = true,
                    estimateSpreadCode                 = "A",
                    budgetCode                         = "RAB"
                };
                ProjectEstimateServiceResult projectEstimateServiceResult = projectEstimateService.update(projectEstimateOperationContext, projectEstimateDTO);
                //ProjectEstimateServiceResult[] projectEstimateServiceResults = projectEstimateService.multipleUpdate(projectEstimateOperationContext, projectEstimateDTOs);

                //ProjectEstimateServiceResult projectEstimateServiceResult = projectEstimateServiceResults[0];

                Error[] errors = projectEstimateServiceResult.errors;

                if (errors.Length > 0)
                {
                    result = errors[0].messageText.Trim();
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
                else
                {
                    result = "OK";
                    transContext.transaction = transID;
                    transactionService.commit(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Exemplo n.º 10
0
        protected virtual void Users_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            Users oldRow = e.Row as Users;
            Users row    = e.NewRow as Users;

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

            if (oldRow.ContactID != row.ContactID)
            {
                foreach (PXResult <Contact, EPEmployee> set in PXSelectJoin <Contact,
                                                                             LeftJoin <EPEmployee, On <Contact.contactID, Equal <EPEmployee.defContactID>,
                                                                                                       And <Contact.bAccountID, Equal <EPEmployee.parentBAccountID> > > >,
                                                                             Where <Contact.userID, Equal <Current <Users.pKID> > > > .SelectMultiBound(this, new object[] { oldRow }))
                {
                    var(cont, emp) = set;
                    cont.UserID    = null;
                    contact.Update(cont);

                    if (emp != null)
                    {
                        emp.UserID = null;
                        Employee.Update(emp);
                    }
                }

                Contact newContact = PXSelect <Contact, Where <Contact.contactID, Equal <Current <Users.contactID> > > > .SelectSingleBound(this, new object[] { row });

                if (newContact != null)
                {
                    newContact.UserID = row.PKID;
                    contact.Update(newContact);

                    EPEmployee emp = PXSelectJoin <EPEmployee,
                                                   InnerJoin <Contact, On <Contact.contactID, Equal <EPEmployee.defContactID>,
                                                                           And <Contact.bAccountID, Equal <EPEmployee.parentBAccountID> > > >,
                                                   Where <Contact.contactID, Equal <Required <Contact.contactID> > > > .Select(this, newContact.ContactID);

                    if (emp != null)
                    {
                        emp = PXCache <EPEmployee> .CreateCopy(emp);

                        emp.UserID = row.PKID;
                        Employee.Update(emp);
                    }
                }
            }

            if (row.Guest == true && oldRow.Guest != true)
            {
                if (contact.View.Ask(
                        MyMessages.EmployeeContactWouldBeCleared,
                        MessageButtons.YesNo) != WebDialogResult.Yes)
                {
                    e.Cancel = true;
                }
            }
            else if (row.Guest != true && oldRow.Guest == true)
            {
                if (contact.View.Ask(
                        MyMessages.ExternalUserContactWouldBeCleared,
                        MessageButtons.YesNo) != WebDialogResult.Yes)
                {
                    e.Cancel = true;
                }
            }
        }
Exemplo n.º 11
0
        private AccountSubaccountPair GetDeferralAccountSubaccount(
            DRDeferredCode deferralCode,
            InventoryItem item,
            DRProcess.DRScheduleParameters scheduleParameters)
        {
            int?accountID = deferralCode.AccountID;

            string subaccountCD = null;
            int?   subaccountID = null;

            if (deferralCode.AccountSource == DeferralAccountSource.Item)
            {
                accountID = item != null ? item.DeferralAcctID : subaccountID;
                // this is fishy. subID is always null at this point.
            }

            if (deferralCode.CopySubFromSourceTran == true)
            {
                subaccountID = scheduleParameters.SubID;
            }
            else if (scheduleParameters.Module == BatchModule.AP)
            {
                int?itemSubID = item?.DeferralSubID;

                Location location = _businessAccountProvider
                                    .GetLocation(scheduleParameters.BAccountID, scheduleParameters.BAccountLocID);

                int?locationSubID = location?.VExpenseSubID;

                EPEmployee employee = _businessAccountProvider
                                      .GetEmployee(scheduleParameters.EmployeeID);

                int?employeeSubaccountID = employee?.ExpenseSubID;

                subaccountCD = _subaccountProvider.MakeSubaccount <DRScheduleDetail.subID>(
                    deferralCode.DeferralSubMaskAP,
                    new object[] { locationSubID, itemSubID, employeeSubaccountID, deferralCode.SubID },
                    new []
                {
                    typeof(Location.vExpenseSubID),
                    typeof(InventoryItem.deferralSubID),
                    typeof(EPEmployee.expenseSubID),
                    typeof(DRDeferredCode.subID)
                });
            }
            else if (scheduleParameters.Module == BatchModule.AR)
            {
                int?itemSubID = item?.DeferralSubID;

                Location location = _businessAccountProvider
                                    .GetLocation(scheduleParameters.BAccountID, scheduleParameters.BAccountLocID);

                int?locationSubaccountID = location?.CSalesSubID;

                EPEmployee employee = _businessAccountProvider
                                      .GetEmployee(scheduleParameters.EmployeeID);

                int?employeeSubaccountID = employee?.SalesSubID;

                SalesPerson salesPerson = _businessAccountProvider
                                          .GetSalesPerson(scheduleParameters.SalesPersonID);

                int?salesPersonSubaccountID = salesPerson?.SalesSubID;

                subaccountCD = _subaccountProvider.MakeSubaccount <DRScheduleDetail.subID>(
                    deferralCode.DeferralSubMaskAR,
                    new object[] { locationSubaccountID, itemSubID, employeeSubaccountID, deferralCode.SubID, salesPersonSubaccountID },
                    new []
                {
                    typeof(Location.cSalesSubID),
                    typeof(InventoryItem.deferralSubID),
                    typeof(EPEmployee.salesSubID),
                    typeof(DRDeferredCode.subID),
                    typeof(SalesPerson.salesSubID)
                });
            }

            if (subaccountCD != null)
            {
                subaccountID = _subaccountProvider.GetSubaccountID(subaccountCD);
            }

            return(new AccountSubaccountPair(accountID, subaccountID));
        }
Exemplo n.º 12
0
        public override void Persist()
        {
            Contact    cnt             = contact.SelectSingle();
            EPEmployee currentEmployee = (cnt != null) ? Employee.Select(cnt.ContactID) : null;

            cnt = (Contact)contact.Cache.CreateCopy(cnt);
            if (UserList.Current != null)
            {
                UserList.Current.IsAssigned = cnt != null;

                foreach (Contact existing in PXSelect <Contact, Where <Contact.userID, Equal <Current <Users.pKID> > > > .Select(this))
                {
                    existing.UserID = null;
                    contact.Update(existing);

                    EPEmployee emp = Employee.Select(existing.ContactID);
                    if (emp != null)
                    {
                        emp = PXCache <EPEmployee> .CreateCopy(emp);

                        emp.UserID = null;
                        Employee.Update(emp);
                    }
                }

                if (cnt != null)
                {
                    cnt.UserID = UserList.Current.PKID;
                    contact.Update(cnt);

                    if (currentEmployee != null)
                    {
                        currentEmployee = PXCache <EPEmployee> .CreateCopy(currentEmployee);

                        currentEmployee.UserID = UserList.Current.PKID;
                        Employee.Update(currentEmployee);
                    }
                }
            }

            foreach (Users user in UserList.Cache.Deleted)
            {
                cnt = (Contact)contact.View.SelectSingleBound(new object[] { user });
                if (cnt != null)
                {
                    cnt.UserID = null;
                    contact.Update(cnt);

                    EPEmployee emp = Employee.Select(cnt.ContactID);
                    if (emp != null)
                    {
                        emp = PXCache <EPEmployee> .CreateCopy(emp);

                        emp.UserID = null;
                        Employee.Update(emp);
                    }
                }
            }

            if (UserList.Current != null && UserList.Current.OverrideADRoles != true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                //notice that this select returns nothing if called on AccessUsers. AccessUsers::roleList() returns empty list;
                foreach (UsersInRoles userrole in RoleList.Select())
                {
                    RoleList.Delete(userrole);
                }
            }

            //if no local roles selected - disable override.
            if (UserList.Current != null && UserList.Current.OverrideADRoles == true && UserList.Current.Source == PXUsersSourceListAttribute.ActiveDirectory)
            {
                if (RolesByUser.SelectSingle() == null)
                {
                    UserListCurrent.Current.OverrideADRoles = false;
                }
            }

            base.Persist();
        }
Exemplo n.º 13
0
        string modifyProject(SOOrder sOOrder)
        {
            int?customerSalesAcctId;
            int?customerSalesSubId;
            int?cogsAcctId;
            int?cogsSubId;
            int?invtAcctId;
            int?invtSubId;
            int?cARAccountID;

            string cogsAcctCd      = "";
            string cogsSubCd       = "";
            string invtAcctCd      = "";
            string invtSubCd       = "";
            string custSalesAcctCD = "";
            string custSalesSubCD  = "";
            string cARAccountCD    = string.Empty;
            string custCD          = "";
            string transID         = "";

            string result = "";

            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);

                BAccount2 customer = PXSelect <BAccount2,
                                               Where <BAccount2.bAccountID, Equal <Required <BAccount2.bAccountID> >,
                                                      And <BAccount2.defLocationID, Equal <Required <BAccount2.defLocationID> >,
                                                           And <BAccount.type, Equal <Required <BAccount.type> > > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID, "CU");

                Location custLocation = PXSelect <Location,
                                                  Where <Location.bAccountID, Equal <Required <Location.bAccountID> >,
                                                         And <Location.locationID, Equal <Required <Location.locationID> > > > > .Select(Base, sOOrder.CustomerID, sOOrder.CustomerLocationID);

                customerSalesAcctId = custLocation.CSalesAcctID;
                customerSalesSubId  = custLocation.CSalesSubID;
                cARAccountID        = custLocation.CARAccountID;

                Account custSalesAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, customerSalesAcctId);

                Account custARAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, cARAccountID);

                Sub custSalesSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, customerSalesSubId);

                custSalesAcctCD = custSalesAccount.AccountCD;
                custSalesSubCD  = custSalesSub.SubCD;
                cARAccountCD    = custARAccount.AccountCD;
                custCD          = customer.AcctCD.Trim();

                foreach (SOLine soLine in Base.Transactions.Select(sOOrder.OrderNbr))
                {
                    InventoryItem inventoryItem = PXSelect <InventoryItem,
                                                            Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(Base, soLine.InventoryID);

                    cogsAcctId = inventoryItem.COGSAcctID;
                    cogsSubId  = inventoryItem.COGSSubID;
                    invtAcctId = inventoryItem.InvtAcctID;
                    invtSubId  = inventoryItem.InvtSubID;

                    if (cogsAcctId == null && cogsSubId == null)
                    {
                        throw new PXException(CustomMessage.COGSAccountEmpty);
                    }

                    Account itemInvtAcct = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, invtAcctId);

                    Sub itemInvtSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, invtSubId);

                    Account invtCogsAccount = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(Base, cogsAcctId);

                    Sub invtCogsSub = PXSelect <Sub, Where <Sub.subID, Equal <Required <Sub.subID> > > > .Select(Base, cogsSubId);

                    cogsAcctCd = invtCogsAccount.AccountCD;
                    cogsSubCd  = invtCogsSub.SubCD;
                    invtAcctCd = itemInvtAcct.AccountCD;
                    invtSubCd  = itemInvtSub.SubCD;

                    if (cogsAcctId != null && cogsSubId != null)
                    {
                        break;
                    }
                }

                EPEmployee ePEmployee = PXSelect <EPEmployee, Where <EPEmployee.userID, Equal <Required <EPEmployee.userID> > > > .Select(Base, sOOrder.OwnerID);

                string   originatorId         = ePEmployee != null ? ePEmployee.AcctCD : "ADMIN";
                string   stockItemAccount     = custSalesSubCD.Substring(0, 11).Trim() + cogsSubCd.Substring(11, 4).Trim(); // + cogsAcctCd.Trim();
                string   nonStockItemAccount  = cogsSubCd.Trim();                                                           // + cogsAcctCd.Trim();
                string   itemInventoryAccount = invtSubCd.Trim() + invtAcctCd.Trim();
                DateTime actStartDate         = sOOrder.OrderDate ?? DateTime.Now;
                string   raisedDate           = actStartDate.ToString("yyyyMMdd");
                string   planFinishDate       = (sOOrder.RequestDate ?? actStartDate.AddDays(60)).ToString("yyyyMMdd");

                try
                {
                    //ClientConversation.authenticate(userName, password);
                    PLNSC.ProjectService.OperationContext projectOperationContext = new PLNSC.ProjectService.OperationContext()
                    {
                        district     = districtCode,
                        position     = positionID,
                        maxInstances = maxInstance,
                        transaction  = transID
                    };

                    ProjectService projectService = new ProjectService()
                    {
                        Timeout = sessionTimeout,
                        Url     = $"{urlPrefix(dbName)}ProjectService"
                    };

                    ProjectServiceModifyRequestDTO projectRequest = new ProjectServiceModifyRequestDTO()
                    {
                        districtCode       = "SC01",
                        projectNo          = sOOrder.OrderNbr,
                        projDesc           = sOOrder.OrderDesc,
                        originatorId       = originatorId,
                        raisedDate         = raisedDate,
                        planFinDate        = planFinishDate,
                        accountCode        = cARAccountCD,
                        accountCodeEnabled = true
                    };

                    ProjectServiceModifyReplyDTO             projectReply       = projectService.modify(projectOperationContext, projectRequest);
                    PLNSC.ProjectService.WarningMessageDTO[] warningMessageDTOs = projectReply.warningsAndInformation;

                    if (warningMessageDTOs.Length > 0)
                    {
                        result = warningMessageDTOs[0].message;
                        transContext.transaction = transID;
                        transactionService.rollback(transContext);
                    }
                    else
                    {
                        result = "OK";
                        transContext.transaction = transID;
                        transactionService.commit(transContext);
                    }
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                    transContext.transaction = transID;
                    transactionService.rollback(transContext);
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }

            return(result);
        }
Exemplo n.º 14
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;
        }
Exemplo n.º 15
0
        /// <summary>
        /// Add the Employee(s) info as a recipient(s) in the Email template generated by Appointment.
        /// </summary>
        private static void AddEmployeeStaffRecipient(
            AppointmentEntry graphAppointmentEntry,
            int?bAccountID,
            string type,
            NotificationRecipient recSetup,
            RecipientList recipients)
        {
            NotificationRecipient recipient = null;
            bool?   appNotification         = false;
            Contact contactRow = null;

            if (type == BAccountType.EmployeeType)
            {
                EPEmployee epEmployeeRow = PXSelect <EPEmployee,
                                                     Where <
                                                         EPEmployee.bAccountID, Equal <Required <EPEmployee.bAccountID> > > >
                                           .Select(graphAppointmentEntry, bAccountID);

                FSxEPEmployee fsxEpEmployeeRow = PXCache <EPEmployee> .GetExtension <FSxEPEmployee>(epEmployeeRow);

                appNotification = fsxEpEmployeeRow.SendAppNotification;

                contactRow = PXSelectJoin <Contact,
                                           InnerJoin <BAccount,
                                                      On <BAccount.parentBAccountID, Equal <Contact.bAccountID>,
                                                          And <BAccount.defContactID, Equal <Contact.contactID> > > >,
                                           Where <
                                               BAccount.bAccountID, Equal <Required <BAccount.bAccountID> >,
                                               And <BAccount.type, Equal <Required <BAccount.type> > > > >
                             .Select(graphAppointmentEntry, bAccountID, type);
            }
            else if (type == BAccountType.VendorType)
            {
                Vendor vendorRow = PXSelect <Vendor,
                                             Where <
                                                 Vendor.bAccountID, Equal <Required <Vendor.bAccountID> > > >
                                   .Select(graphAppointmentEntry, bAccountID);

                FSxVendor fsxVendorRow = PXCache <Vendor> .GetExtension <FSxVendor>(vendorRow);

                appNotification = fsxVendorRow.SendAppNotification;

                contactRow = PXSelectJoin <Contact,
                                           InnerJoin <BAccount,
                                                      On <Contact.contactID, Equal <BAccount.defContactID> > >,
                                           Where <
                                               BAccount.bAccountID, Equal <Required <BAccount.bAccountID> >,
                                               And <BAccount.type, Equal <Required <BAccount.type> > > > >
                             .Select(graphAppointmentEntry, bAccountID, type);
            }

            if (appNotification == true)
            {
                if (contactRow != null && contactRow.EMail != null)
                {
                    recipient = new NotificationRecipient()
                    {
                        Active = true,
                        Email  = contactRow.EMail,
                        Hidden = recSetup.Hidden,
                        Format = recSetup.Format
                    };
                    if (recipient != null)
                    {
                        recipients.Add(recipient);
                    }
                }
            }
        }
Exemplo n.º 16
0
    protected void Page_Load(object sender, EventArgs e)
    {
        applicationName = Request.ApplicationPath.TrimEnd('/');
        pageUrl         = SharedFunctions.GetWebMethodPath(Request.Path);

        DateTime?startDateBridge;
        var      date = PXContext.GetBusinessDate();

        startDateBridge = (date != null) ? date : PXTimeZoneInfo.Now;

        // Filter By RefNbr
        RefNbr = Request.QueryString["RefNbr"];

        // External CustomerID
        CustomerID = Request.QueryString["CustomerID"];

        // Employee
        ExternalEmployee = Request.QueryString["EmployeeID"];

        // External SMEquipmentID
        SMEquipmentID = Request.QueryString["SMEquipmentID"];

        // Focus unassigned Appointment Tab
        AppSource = Request.QueryString["AppSource"];

        // Date
        try
        {
            if (!String.IsNullOrEmpty(Request.QueryString["Date"]))
            {
                startDateBridge = Convert.ToDateTime(Request.QueryString["Date"]);
            }
        }
        catch (Exception)
        {
        }

        var graphExternalControls = PXGraph.CreateInstance <ExternalControls>();
        var results = graphExternalControls.EmployeeSelected.Select();

        startDate = ((DateTime)startDateBridge).ToString("MM/dd/yyyy h:mm:ss tt", new CultureInfo("en-US"));

        PXResult <EPEmployee, Contact> result = (PXResult <EPEmployee, Contact>)results;

        EPEmployee epEmployeeRow = result;

        if (epEmployeeRow != null)
        {
            DefaultEmployee = epEmployeeRow.BAccountID.ToString();
        }

        if (string.IsNullOrEmpty(ExternalEmployee) && epEmployeeRow != null)
        {
            ExternalEmployee = DefaultEmployee;
        }

        // Load Appointment's Body to be used in index.aspx
        StreamReader streamReader = new StreamReader(Server.MapPath("../../Shared/templates/EventTemplate.html"));

        appointmentBodyTemplate = streamReader.ReadToEnd();
        streamReader.Close();

        // Load Service Order's ToolTip to be used in index.aspx
        streamReader = new StreamReader(Server.MapPath("../../Shared/templates/TooltipServiceOrder.html"));
        toolTipTemplateServiceOrder = streamReader.ReadToEnd();
        streamReader.Close();

        // Load Appointment's ToolTip to be used in index.aspx
        streamReader = new StreamReader(Server.MapPath("../../Shared/templates/TooltipAppointment.html"));
        toolTipTemplateAppointment = streamReader.ReadToEnd();
        streamReader.Close();
    }
Exemplo n.º 17
0
        public virtual void StartStaffAction(IEnumerable <FSStaffLogActionDetail> createLogItems = null)
        {
            IEnumerable <FSStaffLogActionDetail> createLogItemsLocal = null;

            if (createLogItems == null)
            {
                if (LogActionFilter.Current.Me == true)
                {
                    EPEmployee employeeByUserID = PXSelect <EPEmployee,
                                                            Where <
                                                                EPEmployee.userID, Equal <Current <AccessInfo.userID> > > >
                                                  .Select(this);

                    if (employeeByUserID != null)
                    {
                        bool isEmployeeInGrid = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                .Where(x => x.EmployeeID == employeeByUserID.BAccountID)
                                                .Count() > 0;

                        bool isTherePrimaryDriver = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.PrimaryDriver == true)
                                                    .Count() > 0;

                        if (isEmployeeInGrid == false)
                        {
                            FSAppointmentEmployee fsAppointmentEmployeeRow = new FSAppointmentEmployee()
                            {
                                EmployeeID = employeeByUserID.BAccountID
                            };

                            if (isTherePrimaryDriver == false)
                            {
                                fsAppointmentEmployeeRow.PrimaryDriver = true;
                            }

                            AppointmentServiceEmployees.Cache.Insert(fsAppointmentEmployeeRow);

                            FSAppointmentLog fsAppointmentLogRow = new FSAppointmentLog()
                            {
                                Type          = ID.Type_Log.STAFF_ASSIGMENT,
                                BAccountID    = employeeByUserID.BAccountID,
                                DetLineRef    = null,
                                DateTimeBegin = LogActionFilter.Current.LogTime
                            };

                            LogRecords.Cache.Insert(fsAppointmentLogRow);
                        }
                        else
                        {
                            createLogItemsLocal = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>()
                                                  .Where(x => x.Selected == true);
                        }
                    }
                }
                else
                {
                    createLogItemsLocal = LogStaffActionDetails.Select().RowCast <FSStaffLogActionDetail>()
                                          .Where(x => x.Selected == true);
                }
            }
            else
            {
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSStaffLogActionDetail fsStaffLogActionDetailRow in createLogItemsLocal)
                {
                    int?timeDuration = fsStaffLogActionDetailRow != null && fsStaffLogActionDetailRow.EstimatedDuration != null ? fsStaffLogActionDetailRow.EstimatedDuration : 0;

                    FSAppointmentLog fsAppointmentLogRow = new FSAppointmentLog()
                    {
                        Type          = ID.Type_Log.STAFF_ASSIGMENT,
                        BAccountID    = fsStaffLogActionDetailRow.BAccountID,
                        DetLineRef    = fsStaffLogActionDetailRow.DetLineRef,
                        DateTimeBegin = LogActionFilter.Current.LogTime,
                        TimeDuration  = timeDuration
                    };

                    LogRecords.Cache.Insert(fsAppointmentLogRow);
                }
            }
        }
Exemplo n.º 18
0
        public virtual void StartServiceAction(IEnumerable <FSAppointmentEmployeeFSLogStart> createLogItems = null)
        {
            IEnumerable <FSAppointmentEmployeeFSLogStart> createLogItemsLocal = null;
            FSAppointmentLog fsAppointmentLogRow;
            FSAppointmentDet fsAppointmentDetRow = null;
            string           detLineRef          = null;
            DateTime?        dateTimeBegin       = null;
            int timeDuration = 0;

            if (LogActionFilter.Current?.DetLineRef == null)
            {
                return;
            }

            if (createLogItems == null)
            {
                detLineRef    = LogActionFilter.Current?.DetLineRef;
                dateTimeBegin = LogActionFilter.Current?.LogTime;

                if (LogActionFilter.Current.DetLineRef != null)
                {
                    fsAppointmentDetRow = PXSelect <FSAppointmentDet,
                                                    Where <
                                                        FSAppointmentDet.appointmentID, Equal <Required <FSAppointmentDet.appointmentID> >,
                                                        And <FSAppointmentDet.lineRef, Equal <Required <FSAppointmentDet.lineRef> > > > >
                                          .Select(this, AppointmentRecords.Current.AppointmentID, LogActionFilter.Current.DetLineRef);

                    if (fsAppointmentDetRow != null)
                    {
                        timeDuration = fsAppointmentDetRow.EstimatedDuration ?? 0;
                    }
                }

                if (LogActionFilter.Current.Me == true)
                {
                    EPEmployee employeeByUserID = PXSelect <EPEmployee,
                                                            Where <
                                                                EPEmployee.userID, Equal <Current <AccessInfo.userID> > > >
                                                  .Select(this);

                    if (employeeByUserID != null)
                    {
                        bool isEmployeeInGrid = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                .Where(x => x.EmployeeID == employeeByUserID.BAccountID)
                                                .Count() > 0;

                        bool isTherePrimaryDriver = AppointmentServiceEmployees.Select().RowCast <FSAppointmentEmployee>()
                                                    .Where(x => x.PrimaryDriver == true)
                                                    .Count() > 0;

                        if (isEmployeeInGrid == false)
                        {
                            FSAppointmentEmployee fsAppointmentEmployeeRow = new FSAppointmentEmployee()
                            {
                                EmployeeID = employeeByUserID.BAccountID,
                            };

                            if (isTherePrimaryDriver == false)
                            {
                                fsAppointmentEmployeeRow.PrimaryDriver = true;
                            }

                            AppointmentServiceEmployees.Cache.Insert(fsAppointmentEmployeeRow);
                        }

                        fsAppointmentLogRow = new FSAppointmentLog()
                        {
                            Type          = ID.Type_Log.SERVICE,
                            BAccountID    = employeeByUserID.BAccountID,
                            DetLineRef    = detLineRef,
                            DateTimeBegin = dateTimeBegin,
                            TimeDuration  = timeDuration
                        };

                        LogRecords.Cache.Insert(fsAppointmentLogRow);
                    }
                }
                else
                {
                    createLogItemsLocal = StaffMemberLogStartAction.Select().RowCast <FSAppointmentEmployeeFSLogStart>()
                                          .Where(x => x.Selected == true);
                }
            }
            else
            {
                detLineRef          = null;
                dateTimeBegin       = PXDBDateAndTimeAttribute.CombineDateTime(AppointmentRecords.Current.ExecutionDate, PXTimeZoneInfo.Now);
                createLogItemsLocal = createLogItems;
            }

            if (createLogItemsLocal != null)
            {
                foreach (FSAppointmentEmployeeFSLogStart row in createLogItemsLocal)
                {
                    fsAppointmentLogRow = new FSAppointmentLog()
                    {
                        Type          = ID.Type_Log.SERVICE,
                        BAccountID    = row.BAccountID,
                        DetLineRef    = detLineRef,
                        DateTimeBegin = dateTimeBegin,
                        TimeDuration  = timeDuration
                    };

                    LogRecords.Cache.Insert(fsAppointmentLogRow);
                }
            }
        }