Example #1
0
        protected virtual void InsertARTran(ARInvoiceEntry arGraph, EPExpenseClaimDetails row, bool copyNotes, bool copyFiles)
        {
            ARTran tran = (ARTran)arGraph.Transactions.Cache.CreateInstance();

            tran.InventoryID = row.InventoryID;
            tran.TranDesc    = row.TranDesc;
            tran.TranCost    = row.ExtCost;
            tran.Qty         = row.Qty;
            tran.UOM         = row.UOM;
            tran.CuryTranAmt = row.CuryTranAmt;
            tran.AccountID   = row.SalesAccountID;
            tran.SubID       = row.SalesSubID;
            tran.Date        = row.ExpenseDate;
            tran             = arGraph.Transactions.Insert(tran);

            if (copyNotes)
            {
                string note = PXNoteAttribute.GetNote(Caches[typeof(EPExpenseClaimDetails)], row);
                if (note != null)
                {
                    PXNoteAttribute.SetNote(arGraph.Transactions.Cache, tran, note);
                }
            }
            if (copyFiles)
            {
                Guid[] files = PXNoteAttribute.GetFileNotes(Caches[typeof(EPExpenseClaimDetails)], row);
                if (files != null && files.Length > 0)
                {
                    PXNoteAttribute.SetFileNotes(arGraph.Transactions.Cache, tran, files);
                }
            }
        }
    protected void exportAttachmnts()
    {
        var order = Base.Document.Current;

        PXLongOperation.StartOperation(Base, () =>
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (PX.Common.ZipArchive archive = PX.Common.ZipArchive.CreateFrom(stream, false))
                {
                    UploadFileMaintenance upload = PXGraph.CreateInstance <UploadFileMaintenance>();
                    Guid[] uids = PXNoteAttribute.GetFileNotes(Base.Document.Cache, order);
                    foreach (Guid uid in uids)
                    {
                        PX.SM.FileInfo fileInfo = upload.GetFile(uid);
                        archive.AddFile(fileInfo.Name, fileInfo.BinData);
                    }
                }
                PX.SM.FileInfo info = new PX.SM.FileInfo(
                    string.Format("{0}-{1}-Attachmets.zip", order.OrderType, order.OrderNbr),
                    null, stream.ToArray());
                throw new PXRedirectToFileException(info, true);
            }
        });
    }
Example #3
0
        protected virtual void InsertARTran(ARInvoiceEntry arGraph, EPExpenseClaimDetails row, decimal signOperation)
        {
            CurrencyInfo curyInfo = PXSelect <CurrencyInfo> .Search <CurrencyInfo.curyInfoID>(arGraph, row.CuryInfoID);

            decimal curyamount;

            if (arGraph.currencyinfo.Current != null && curyInfo != null && arGraph.currencyinfo.Current.CuryID == curyInfo.CuryID)
            {
                curyamount = row.CuryTranAmt.GetValueOrDefault(0);
            }
            else
            {
                CM.PXCurrencyAttribute.CuryConvCury(arGraph.Document.Cache, arGraph.currencyinfo, row.TranAmt.GetValueOrDefault(), out curyamount);
            }

            ARTran tran = arGraph.Transactions.Insert();

            tran.InventoryID   = row.InventoryID;
            tran.TranDesc      = row.TranDesc;
            tran.Qty           = row.Qty * signOperation;
            tran.UOM           = row.UOM;
            tran.AccountID     = row.SalesAccountID;
            tran.SubID         = row.SalesSubID;
            tran.Date          = row.ExpenseDate;
            tran.CuryTranAmt   = curyamount * signOperation;
            tran.CuryUnitPrice = (curyamount / (row.Qty.GetValueOrDefault(1m) != 0m ? row.Qty.GetValueOrDefault(1m) : 1m)) * signOperation;
            tran.CuryExtPrice  = curyamount * signOperation;
            tran = arGraph.Transactions.Update(tran);

            PXNoteAttribute.CopyNoteAndFiles(Caches[typeof(EPExpenseClaimDetails)], row, arGraph.Transactions.Cache, tran, Setup.Current.GetCopyNoteSettings <PXModule.ar>());
        }
Example #4
0
        private PXAction AddAction(PXGraph graph, Survey survey, string fieldName)
        {
            PXButtonDelegate handler = (PXAdapter adapter) => {
                string str1        = (string.IsNullOrEmpty(adapter.CommandArguments) ? graph.PrimaryView : adapter.CommandArguments);
                string primaryView = graph.PrimaryView;
                var    surveyID    = survey.SurveyID;
                var    caches      = Base.Caches;
                var    cache       = caches[typeof(EDoc)];
                var    doc         = cache?.Current;
                var    entityType  = cache?.GetItemType();
                var    noteID      = PXNoteAttribute.GetNoteIDIfExists(cache, doc);
                fieldName = Clean(fieldName);
                var contactID   = (int?)cache?.GetValue(doc, fieldName);
                var surveyGraph = PXGraph.CreateInstance <SurveyMaint>();
                if (survey != null && contactID.HasValue && noteID.HasValue)
                {
                    surveyGraph.Survey.Current = survey;
                    var user      = surveyGraph.InsertOrFindUser(survey, contactID, false);
                    var collector = surveyGraph.DoUpsertCollector(survey, user, noteID, true, false);
                }
                return(adapter.Get());
            };
            var actionName  = ACTION_PREFIX + survey.SurveyID;
            var displayName = survey.Title; // TODO Add " -> Ship-To Contact"

            return(AddAction(actionName, displayName, handler));
        }
Example #5
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();
        }
        public void CopyPOLineFields(POFixedDemand demand, POLine line)
        {
            PXResult <FSSODetSplit, FSSODet> fsSODetSplitDetRow =
                (PXResult <FSSODetSplit, FSSODet>) PXSelectJoin <FSSODetSplit,
                                                                 InnerJoin <FSSODet,
                                                                            On <FSSODet.lineNbr, Equal <FSSODetSplit.lineNbr>,
                                                                                And <FSSODet.srvOrdType, Equal <FSSODetSplit.srvOrdType>,
                                                                                     And <FSSODet.refNbr, Equal <FSSODetSplit.refNbr> > > > >,
                                                                 Where <FSSODetSplit.planID, Equal <Required <FSSODetSplit.planID> > > >
                .Select(Base, demand.PlanID);

            if (fsSODetSplitDetRow != null)
            {
                FSSODet fsSODetRow = (FSSODet)fsSODetSplitDetRow;

                if (POSetupRecord.Current != null)
                {
                    if (POSetupRecord.Current.CopyLineNotesFromServiceOrder == true ||
                        POSetupRecord.Current.CopyLineAttachmentsFromServiceOrder == true)
                    {
                        var fsSODetCache = new PXCache <FSSODet>(Base);
                        fsSODetCache.Update(fsSODetRow);

                        PXNoteAttribute.CopyNoteAndFiles(fsSODetCache,
                                                         fsSODetRow,
                                                         Base.Transactions.Cache,
                                                         line,
                                                         POSetupRecord.Current.CopyLineNotesFromServiceOrder == true,
                                                         POSetupRecord.Current.CopyLineAttachmentsFromServiceOrder == true);
                    }
                }

                line.TranDesc = fsSODetRow.TranDesc;
            }
        }
        private static void UpdateTrackingNumberDetails(SOGetFBATrackingNumberProcess graph, List <SOProcessOrder> list, SOAmazonSetup objSOAmazonSetupDetails, SOOrderEntry orderEntry, SOPartialMaint objPartialMaint, InvokeReporstServicesCallResponse liShipmentResponse)
        {
            string trackingNumber = string.Empty;
            string carrier        = string.Empty;

            foreach (SOProcessOrder currentRecord in list)
            {
                try
                {
                    if (liShipmentResponse != null && liShipmentResponse.objShipmentResponse != null && liShipmentResponse.objShipmentResponse.Count > 0)
                    {
                        trackingNumber = SOHelper.GetTrackingForFBAOrders(currentRecord.AmazonOrderID, liShipmentResponse.objShipmentResponse, out carrier);
                        currentRecord.AmazonTrackingNumber = !string.IsNullOrEmpty(trackingNumber) ? trackingNumber : null;
                        currentRecord.Carrier = !string.IsNullOrEmpty(carrier) ? carrier : null;
                        graph.TrackingNumberOrdersList.Cache.Update(currentRecord);
                        SOOrder objSOOrder = objPartialMaint.SOOrderView.Select(objSOAmazonSetupDetails.OrderType, currentRecord.AmazonOrderID);
                        if (objSOOrder != null)
                        {
                            PXNoteAttribute.SetNote(orderEntry.Document.Cache, objSOOrder, trackingNumber);
                            orderEntry.Document.Cache.Update(objSOOrder);
                            orderEntry.Actions.PressSave();
                        }
                    }
                }
                catch (Exception ex)
                {
                    throw new PXException(ex.Message);
                }
            }
        }
Example #8
0
        private void SendCopyMessageToInside(PXGraph graph, EMailAccount account, EPActivity message, IEnumerable <Mailbox> email)
        {
            var cache = graph.Caches[message.GetType()];
            var copy  = (EPActivity)cache.CreateCopy(message);

            copy.TaskID       = null;
            copy.IsIncome     = false;
            copy.ParentTaskID = message.TaskID;
            copy.MailTo       = ConcatAddresses(email);       //TODO: need add address description
            copy.MailCc       = null;
            copy.MailBcc      = null;
            copy.MPStatus     = MailStatusListAttribute.PreProcess;
            copy.ClassID      = CRActivityClass.EmailRouting;
            new AddInfoEmailProcessor().Process(new EmailProcessEventArgs(graph, account, copy));
            copy.RefNoteID       = null;
            copy.ParentRefNoteID = null;
            var imcUid = Guid.NewGuid();

            copy.ImcUID    = imcUid;
            copy.MessageId = GetType().Name + "_" + imcUid.ToString().Replace("-", string.Empty);
            copy.Owner     = message.Owner;
            copy.IsPrivate = message.IsPrivate;
            cache.Insert(copy);
            var noteFiles = PXNoteAttribute.GetFileNotes(cache, message);

            if (noteFiles != null)
            {
                PXNoteAttribute.SetFileNotes(cache, copy, noteFiles);
            }
        }
Example #9
0
        protected virtual void SaveFile(FileInfo file)
        {
            const string FilesField = "NoteFiles";

            var person = Persons.Current;

            if (person?.Id != null)
            {
                try
                {
                    PXBlobStorage.SaveContext = new PXBlobStorageContext
                    {
                        NoteID   = person.Id,
                        ViewName = Persons.View.Name,
                        DataRow  = person,
                        Graph    = this
                    };

                    if (this.FileGraph.SaveFile(file, FileExistsAction.CreateVersion))
                    {
                        PXNoteAttribute.ForcePassThrow(Persons.Cache, null);

                        Persons.Cache.SetValueExt(person, FilesField, new Guid[] { file.UID.Value });
                    }
                }
                finally
                {
                    PXBlobStorage.SaveContext = null;
                }
            }
        }
Example #10
0
        protected virtual void Batch_RowInserted(PXCache sender, PXRowInsertedEventArgs e, PXRowInserted bs)
        {
            if (bs != null)
            {
                bs(sender, e);
            }

            if (Base.IsWithinContext)
            {
                string vb   = Base.GetContextValue <GLVoucherBatch.voucherBatchNbr>();
                string wbID = Base.GetContextValue <GLVoucherBatch.workBookID>();
                this.VoucherBatch.Current = this.VoucherBatch.Select(wbID, vb);
                GLWorkBook wb = PXSelect <GLWorkBook,
                                          Where <GLWorkBook.workBookID, Equal <Required <GLVoucherBatch.workBookID> > > > .Select(this.Base, Base.GetContextValue <GLVoucherBatch.workBookID>());

                if (!String.IsNullOrEmpty(vb))
                {
                    Guid?noteID = PXNoteAttribute.GetNoteID <Batch.noteID>(sender, e.Row);
                    this.Voucher.Insert(new GLVoucher());
                    this.Voucher.Cache.IsDirty        = false;
                    Base.Caches[typeof(Note)].IsDirty = false;
                }
                if (wb.DefaultDescription != null && (e.Row as Batch)?.Description == null)
                {
                    sender.SetValueExt <Batch.description>(e.Row, wb.DefaultDescription);
                }
            }
        }
Example #11
0
        public virtual IEnumerable createAP(PXAdapter adapter)
        {
            UploadFileRevision file = PXSelectJoin <UploadFileRevision,
                                                    InnerJoin <UploadFile,
                                                               On <UploadFileRevision.fileID, Equal <UploadFile.fileID>,
                                                                   And <UploadFileRevision.fileRevisionID, Equal <UploadFile.lastRevisionID> > >,
                                                               InnerJoin <NoteDoc,
                                                                          On <NoteDoc.fileID, Equal <UploadFile.fileID> > > >,
                                                    Where <NoteDoc.noteID, Equal <Required <CRSMEmail.noteID> >,
                                                           And <UploadFile.name, Like <pdfExtension> > >,
                                                    OrderBy <Desc <UploadFileRevision.createdDateTime> > > .Select(Base, Base.Emails.Current.NoteID);

            string url = null;

            if (file != null)
            {
                string rooturl;

                if (HttpContext.Current == null)
                {
                    rooturl = string.Empty;
                }

                var applicationpath = string.IsNullOrEmpty(HttpContext.Current.Request.ApplicationPath)
                                        ? string.Empty
                                        : HttpContext.Current.Request.ApplicationPath + "/";
                rooturl = HttpContext.Current.Request.Url.GetLeftPart(UriPartial.Authority) + applicationpath;

                url = string.Concat(rooturl != null ? rooturl : string.Empty, HandlerURL, file.FileID.GetValueOrDefault(Guid.Empty).ToString("D"));

                CRSMEmail email = Base.Emails.Current;

                APInvoiceEntryPXInhExt graph = PXGraph.CreateInstance <APInvoiceEntryPXInhExt>();
                graph.Clear();
                APInvoice doc = (APInvoice)graph.Document.Cache.CreateInstance();
                doc.GetExtension <APInvoiceExt>().UsrFileURL = url;
                doc.LineCntr = 0;
                TryFillValuesFromPDF(graph.Document.Cache, doc, Base.Emails.Cache, email);
                doc = graph.Document.Insert(doc);

                (email).Selected = false;
                CRSMEmail copy = PXCache <CRSMEmail> .CreateCopy(email);

                CRActivity newActivity = (CRActivity)graph.Caches[typeof(CRActivity)].Insert();

                copy.BAccountID = newActivity.BAccountID;
                copy.ContactID  = newActivity.ContactID;
                copy.RefNoteID  = newActivity.RefNoteID;
                copy.MPStatus   = MailStatusListAttribute.Processed;
                copy.Exception  = null;
                PXRefNoteSelectorAttribute.EnsureNotePersistence(Base, Base.entityFilter.Current.Type, Base.entityFilter.Current.RefNoteID);
                copy = Base.Emails.Update(copy);
                Base.Save.Press();

                PXNoteAttribute.CopyNoteAndFiles(Base.Emails.Cache, Base.Emails.Current, graph.Document.Cache, doc);
                PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
            }
            return(adapter.Get());
        }
        protected virtual PMTran InsertPMTran(RegisterEntry pmGraph, PXResult <EPExpenseClaimDetails, Contract, Account> res)
        {
            EPExpenseClaimDetails detail = res;
            Contract contract            = res;
            Account  account             = res;

            if (account.AccountGroupID == null && contract.BaseType == CTPRType.Project)
            {
                throw new PXException(Messages.AccountGroupIsNotAssignedForAccount, account.AccountCD);
            }

            bool released = contract.BaseType == CTPRType.Contract;             //contract trans are created as released

            PMTran tran = (PMTran)pmGraph.Transactions.Cache.Insert();

            tran.AccountGroupID   = account.AccountGroupID;
            tran.BAccountID       = detail.CustomerID;
            tran.LocationID       = detail.CustomerLocationID;
            tran.ProjectID        = detail.ContractID;
            tran.TaskID           = detail.TaskID;
            tran.CostCodeID       = detail.CostCodeID;
            tran.InventoryID      = detail.InventoryID;
            tran.Qty              = detail.Qty;
            tran.Billable         = true;
            tran.BillableQty      = detail.Qty;
            tran.UOM              = detail.UOM;
            tran.TranCuryID       = detail.CuryID;
            tran.BaseCuryInfoID   = detail.CuryInfoID;
            tran.TranCuryAmount   = detail.ClaimCuryTranAmt;
            tran.Amount           = detail.ClaimTranAmt;
            tran.TranCuryUnitRate = detail.CuryUnitCost;
            tran.UnitRate         = detail.UnitCost;

            //TODO: Review the following code (exists only to support MA302 case when UnitCost is not entered):
            if (detail.CuryUnitCost == 0m && detail.Qty != 0)
            {
                tran.TranCuryUnitRate = detail.ClaimCuryTranAmt / detail.Qty;
                tran.UnitRate         = detail.ClaimTranAmt / detail.Qty;
            }
            tran.AccountID  = detail.ExpenseAccountID;
            tran.SubID      = detail.ExpenseSubID;
            tran.StartDate  = detail.ExpenseDate;
            tran.EndDate    = detail.ExpenseDate;
            tran.Date       = detail.ExpenseDate;
            tran.ResourceID = detail.EmployeeID;
            tran.Released   = released;

            tran = pmGraph.Transactions.Update(tran);

            pmGraph.Document.Current.Released = released;
            if (released)
            {
                pmGraph.Document.Current.Status = PMRegister.status.Released;
            }

            PXNoteAttribute.CopyNoteAndFiles(Caches[typeof(EPExpenseClaimDetails)], detail, pmGraph.Transactions.Cache, tran, Setup.Current.GetCopyNoteSettings <PXModule.pm>());

            return(tran);
        }
        protected virtual CRSMEmail CreateMessage()
        {
            var activityCache = Graph.Caches[typeof(CRSMEmail)];
            var act           = (CRSMEmail)activityCache.Insert();

            //CRActivity
            act.ClassID      = CRActivityClass.Email;
            act.Type         = null;
            act.OwnerID      = Owner;
            act.StartDate    = PXTimeZoneInfo.Now;
            act.BAccountID   = BAccountID;
            act.RefNoteID    = RefNoteID;
            act.ParentNoteID = ParentNoteID;

            //SMEmail
            var accountId = MailAccountId ?? MailAccountManager.DefaultMailAccountID;

            act.MailAccountID = accountId;

            act.MailFrom = accountId.
                           With(_ => (EMailAccount)PXSelect <EMailAccount,
                                                             Where <EMailAccount.emailAccountID, Equal <Required <EMailAccount.emailAccountID> > > > .
                                Select(_graph, _.Value)).
                           With(_ => _.Address);

            act.MailTo    = MergeAddressList(act, To, act.MailTo);
            act.MailCc    = MergeAddressList(act, Cc, act.MailCc);
            act.MailBcc   = MergeAddressList(act, Bcc, act.MailBcc);
            act.MailReply = string.IsNullOrEmpty(Reply) ? act.MailFrom : Reply;
            act.IsIncome  = false;
            act.MPStatus  = MailStatusListAttribute.PreProcess;
            act.Format    = BodyFormat ?? EmailFormatListAttribute.Html;

            act.Subject = Subject;
            act.Body    = BodyFormat == null || BodyFormat == EmailFormatListAttribute.Html
                ? CreateHtmlBody(Body)
                : CreateTextBody(Body);

            if (AttachmentsID != null)
            {
                foreach (NoteDoc doc in
                         PXSelect <NoteDoc, Where <NoteDoc.noteID, Equal <Required <NoteDoc.noteID> > > > .Select(Graph, AttachmentsID))
                {
                    if (doc.FileID != null && !_attachments.Contains(doc.FileID.Value))
                    {
                        _attachments.Add(doc.FileID.Value);
                    }
                }
            }

            if (_attachments.Count > 0)
            {
                PXNoteAttribute.SetFileNotes(activityCache, act, _attachments.ToArray());
            }

            act = (CRSMEmail)activityCache.Update(act);

            return(act);
        }
Example #14
0
        protected void SendCopyMessageToInside(PXGraph graph, EMailAccount account, CRSMEmail message, IEnumerable <MailAddress> addresses)
        {
            var cache = graph.Caches[message.GetType()];
            var copy  = (CRSMEmail)cache.CreateCopy(message);

            copy.NoteID       = null;
            copy.EmailNoteID  = null;
            copy.IsIncome     = false;
            copy.ParentNoteID = message.NoteID;
            MailAddress address = null;

            copy.MailFrom = EmailParser.TryParse(message.MailFrom, out address)
                                ? new MailAddress(account.Address, address.DisplayName).ToString()
                                : account.Address;
            copy.MailTo    = PXDBEmailAttribute.ToString(addresses);          //TODO: need add address description
            copy.MailCc    = null;
            copy.MailBcc   = null;
            copy.MailReply = copy.MailFrom;
            copy.MPStatus  = MailStatusListAttribute.PreProcess;
            copy.ClassID   = CRActivityClass.EmailRouting;
            new AddInfoEmailProcessor().Process(new EmailProcessEventArgs(graph, account, copy));
            copy.RefNoteID  = null;
            copy.BAccountID = null;
            copy.ContactID  = null;
            copy.Pop3UID    = null;
            copy.ImapUID    = null;
            var imcUid = Guid.NewGuid();

            copy.ImcUID      = imcUid;
            copy.MessageId   = this.GetType().Name + "_" + imcUid.ToString().Replace("-", string.Empty);
            copy.OwnerID     = null;
            copy.WorkgroupID = null;

            copy = (CRSMEmail)cache.CreateCopy(cache.Insert(copy));

            //Update owner and reset owner if employee not found
            copy.OwnerID = message.OwnerID;
            try
            {
                cache.Update(copy);
            }
            catch (PXSetPropertyException)
            {
                copy.OwnerID = null;
                copy         = (CRSMEmail)cache.CreateCopy(cache.Update(copy));
            }

            copy.IsPrivate   = message.IsPrivate;
            copy.WorkgroupID = message.WorkgroupID;

            var noteFiles = PXNoteAttribute.GetFileNotes(cache, message);

            if (noteFiles != null)
            {
                PXNoteAttribute.SetFileNotes(cache, copy, noteFiles);
            }
        }
Example #15
0
        public BatchRelease()
        {
            GLSetup setup = GLSetup.Current;

            BatchList.SetProcessDelegate <PostGraph>(ReleaseBatch);
            BatchList.SetProcessCaption(Messages.ProcRelease);
            BatchList.SetProcessAllCaption(Messages.ProcReleaseAll);
            PXNoteAttribute.ForcePassThrow <Batch.noteID>(BatchList.Cache);
        }
        protected virtual void INItemPlan_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            INItemPlan plan = (INItemPlan)e.Row;

            if (plan != null)
            {
                PXCache parent = this.Document.Cache;
                plan.RefNoteID = PXNoteAttribute.GetNoteID <INReplenishmentOrder.noteID>(parent, parent.Current);
            }
        }
Example #17
0
        public virtual IEnumerable trainFaceRecongnition(PXAdapter adapter)
        {
            Save.Press();

            PXLongOperation.StartOperation(this, delegate()
            {
                IFaceClient client = Trainer.Authenticate(MasterView.Current.FaceApiEndpoint, MasterView.Current.FaceApiSubscriptionKey);
                var trainer        = new Trainer(client, MasterView.Current.FaceApiGroupID);
                bool uploaded      = false;
                foreach (EPEmployee emp in PXSelect <EPEmployee> .Select(this))
                {
                    bool deleted  = false;
                    Person person = null;
                    Guid[] files  = PXNoteAttribute.GetFileNotes(this.Caches[typeof(EPEmployee)], emp);

                    foreach (Guid fileID in files)
                    {
                        var fm            = new PX.SM.UploadFileMaintenance();
                        PX.SM.FileInfo fi = fm.GetFile(fileID);
                        string ext        = System.IO.Path.GetExtension(fi.Name).ToLower();
                        PXTrace.WriteWarning(emp.AcctCD.TrimEnd() + " " + ext);
                        if (ext.IsIn(".png", ".jpg", ".bmp"))
                        {
                            if (!deleted)
                            {
                                var utilities = new Utilities(client, MasterView.Current.FaceApiGroupID);
                                utilities.DeleteEmployee(emp.AcctCD.TrimEnd());
                                deleted = true;
                            }

                            if (person == null)
                            {
                                person = trainer.GetEmployee_CreateIfNonExistent(emp.AcctCD.TrimEnd());
                            }


                            using (var stream = new System.IO.MemoryStream(fi.BinData))
                            {
                                PXTrace.WriteWarning(emp.AcctCD.TrimEnd() + " " + fi.Name + " " + stream.Length);
                                trainer.UploadTrainingImageStream(person, stream);
                                Thread.Sleep(1000);
                                uploaded = true;
                            }
                        }
                    }
                }
                if (uploaded)
                {
                    trainer.InvokeTraining();
                }
            });


            return(adapter.Get());
        }
        protected override bool Process(Package package)
        {
            var account = package.Account;

            if (account.IncomingProcessing != true ||
                account.CreateLead != true)
            {
                return(false);
            }

            var message = package.Message;

            if (!string.IsNullOrEmpty(message.Exception) ||
                message.IsIncome != true ||
                message.RefNoteID != null ||
                message.ClassID == CRActivityClass.EmailRouting)
            {
                return(false);
            }

            var copy = package.Graph.Caches[typeof(CRSMEmail)].CreateCopy(message);

            try
            {
                LeadMaint graph     = PXGraph.CreateInstance <LeadMaint>();
                var       leadCache = graph.Lead.Cache;
                var       lead      = (Contact)leadCache.Insert();
                lead = PXCache <Contact> .CreateCopy(graph.Lead.Search <Contact.contactID>(lead.ContactID));

                lead.EMail    = package.Address;
                lead.LastName = package.Description;

                CREmailActivityMaint.EmailAddress address = CREmailActivityMaint.ParseNames(message.MailFrom);

                lead.FirstName = address.FirstName;
                lead.LastName  = address.LastName;
                if (account.CreateLeadClassID != null)
                {
                    lead.ClassID = account.CreateLeadClassID;
                }

                lead = (Contact)leadCache.Update(lead);

                message.RefNoteID = PXNoteAttribute.GetNoteID <Contact.noteID>(leadCache, lead);
                graph.Actions.PressSave();
                message.ContactID = message.ContactID ?? lead.ContactID;
            }
            catch (Exception e)
            {
                package.Graph.Caches[typeof(CRSMEmail)].RestoreCopy(message, copy);
                throw new PXException(Messages.CreateLeadException, e is PXOuterException ? ("\r\n" + String.Join("\r\n", ((PXOuterException)e).InnerMessages)) : e.Message);
            }

            return(true);
        }
Example #19
0
        protected virtual void InsertPMTran(RegisterEntry pmGraph, EPExpenseClaimDetails row, EPExpenseClaim doc, bool copyNotes, bool copyFiles)
        {
            PMProject project = PXSelect <PMProject, Where <PMProject.contractID, Equal <Required <PMProject.contractID> > > > .Select(pmGraph, row.ContractID);

            Account account = PXSelect <Account, Where <Account.accountID, Equal <Required <Account.accountID> > > > .Select(this, row.ExpenseAccountID);

            if (account.AccountGroupID == null && project.BaseType == PMProject.ProjectBaseType.Project)
            {
                throw new PXException(Messages.AccountGroupIsNotAssignedForAccount, account.AccountCD);
            }

            PMTran tran = (PMTran)pmGraph.Transactions.Cache.Insert();

            tran.AccountGroupID = account.AccountGroupID;
            tran.BAccountID     = row.CustomerID;
            tran.LocationID     = row.CustomerLocationID;
            tran.ProjectID      = row.ContractID;
            tran.TaskID         = row.TaskID;
            tran.InventoryID    = row.InventoryID;
            tran.Qty            = row.Qty;
            tran.Billable       = true;
            tran.BillableQty    = row.Qty;
            tran.UOM            = row.UOM;
            tran.UnitRate       = row.UnitCost;
            tran.Amount         = row.TranAmt;
            tran.AccountID      = row.ExpenseAccountID;
            tran.SubID          = row.ExpenseSubID;
            tran.StartDate      = row.ExpenseDate;
            tran.EndDate        = row.ExpenseDate;
            tran.Date           = row.ExpenseDate;
            tran.ResourceID     = doc.EmployeeID;
            tran.Released       = project.BaseType == PMProject.ContractBaseType.Contract;      //contract trans are created as released

            pmGraph.Transactions.Update(tran);

            pmGraph.Document.Current.Released = project.BaseType == PMProject.ContractBaseType.Contract;

            if (copyNotes)
            {
                string note = PXNoteAttribute.GetNote(Caches[typeof(EPExpenseClaimDetails)], row);
                if (note != null)
                {
                    PXNoteAttribute.SetNote(pmGraph.Transactions.Cache, tran, note);
                }
            }
            if (copyFiles)
            {
                Guid[] files = PXNoteAttribute.GetFileNotes(Caches[typeof(EPExpenseClaimDetails)], row);
                if (files != null && files.Length > 0)
                {
                    PXNoteAttribute.SetFileNotes(pmGraph.Transactions.Cache, tran, files);
                }
            }
        }
        private void CheckForMissingNoteRecord(PXBlobStorageContext saveContext)
        {
            EntityHelper entityHelper = new EntityHelper(this);
            Note         note         = entityHelper.SelectNote(saveContext.NoteID);

            if (note == null)
            {
                PXNoteAttribute.InsertNoteRecord(saveContext.Graph.Views[saveContext.ViewName].Cache, saveContext.NoteID.Value);
                this.Caches[typeof(Note)].ClearQueryCache();
            }
        }
        public static SOOrder GetSOOrder(SOOrderEntry orderGraph, KCAPIOrder order, SOOrder acumaticaOrder, int?branchID, bool FBA)
        {
            KCSiteMasterMaint graph = PXGraph.CreateInstance <KCSiteMasterMaint>();
            var customer            = KCGeneralDataHelper.GetCustomerByCAOrder(graph, order);
            var paymentmethod       = KCGeneralDataHelper.GetPaymenthMethodId(graph, order);
            var mapper          = new KCDynamicOrderMapper(KCMappingEntitiesConstants.Order);
            var conversionGraph = PXGraph.CreateInstance <KCOrderConversionDataMaint>();

            mapper.Mapping.MappingValues = conversionGraph.GetEntity();
            mapper.MapOrder(acumaticaOrder, order);
            if (paymentmethod == null)
            {
                KCPaymentMethodsMappingMaint paymentMethodMappingGraph = PXGraph.CreateInstance <KCPaymentMethodsMappingMaint>();
                CustomerPaymentMethodMaint   paymentMethodGraph        = PXGraph.CreateInstance <CustomerPaymentMethodMaint>();
                try
                {
                    KCGeneralDataHelper.CreatePaymentMethod(paymentMethodGraph, paymentMethodMappingGraph, customer.BAccountID, order);
                    paymentmethod = KCGeneralDataHelper.GetPaymenthMethodId(graph, order);
                }
                catch { }
            }
            acumaticaOrder.CustomerID       = customer.BAccountID;
            acumaticaOrder.PMInstanceID     = paymentmethod?.PMInstanceID;
            acumaticaOrder.Status           = SOOrderStatus.Open;
            acumaticaOrder.CreatePMInstance = true;
            KCSOOrderEntryExt orderext  = orderGraph.GetExtension <KCSOOrderEntryExt>();
            string            orderType = new KCMarketplaceHelper().GetOrderType(order, orderGraph);

            acumaticaOrder.OrderType = orderType ?? acumaticaOrder.OrderType;

            if (order.EstimatedShipDateUtc == null)
            {
                acumaticaOrder.RequestDate = acumaticaOrder.OrderDate;
            }
            orderGraph.CurrentDocument.Current = acumaticaOrder;

            PXNoteAttribute.SetNote(orderGraph.CurrentDocument.Cache, orderGraph.CurrentDocument.Current, order.PrivateNotes);
            string       firstName      = orderext.AccountCD.SelectSingle(acumaticaOrder.CustomerID).AcctName;
            bool         isFBAFirstName = firstName.Contains("FBA");
            KCSOOrderExt orderExt       = acumaticaOrder.GetExtension <KCSOOrderExt>();

            orderExt = mapper.MapOrderCaExt(orderExt, order);
            orderExt.UsrKCSyncDate  = DateTime.Now;
            orderExt.UsrKCSiteName += FBA ? "/FBA" : "/Non-FBA";
            if ((FBA && orderExt.UsrKCSiteName.Contains("Amazon")) || isFBAFirstName)
            {
                acumaticaOrder.Status = KCCheckoutStatus.CCompleted;
            }

            return(acumaticaOrder);
        }
        private void SendCopyMessage(PXGraph graph, EMailAccount account, CRSMEmail message, string email)
        {
            var cache = graph.Caches[message.GetType()];
            var copy  = (CRSMEmail)cache.CreateCopy(message);

            copy.NoteID       = null;
            copy.EmailNoteID  = null;
            copy.IsIncome     = false;
            copy.ParentNoteID = message.NoteID;
            copy.MailTo       = email;       //TODO: need add address description
            copy.MailCc       = null;
            copy.MailBcc      = null;
            copy.MPStatus     = MailStatusListAttribute.PreProcess;
            copy.ClassID      = CRActivityClass.EmailRouting;
            new AddInfoEmailProcessor().Process(new EmailProcessEventArgs(graph, account, copy));
            copy.RefNoteID  = null;
            copy.BAccountID = null;
            copy.ContactID  = null;
            copy.Pop3UID    = null;
            copy.ImapUID    = null;
            var imcUid = Guid.NewGuid();

            copy.ImcUID      = imcUid;
            copy.MessageId   = this.GetType().Name + "_" + imcUid.ToString().Replace("-", string.Empty);
            copy.OwnerID     = null;
            copy.WorkgroupID = null;

            copy = (CRSMEmail)cache.CreateCopy(cache.Insert(copy));

            //Update owner and reset owner if employee not found
            copy.OwnerID = message.OwnerID;
            try
            {
                cache.Update(copy);
            }
            catch (PXSetPropertyException)
            {
                copy.OwnerID = null;
                copy         = (CRSMEmail)cache.CreateCopy(cache.Update(copy));
            }

            copy.WorkgroupID = message.WorkgroupID;

            var noteFiles = PXNoteAttribute.GetFileNotes(cache, message);

            if (noteFiles != null)
            {
                PXNoteAttribute.SetFileNotes(cache, copy, noteFiles);
            }
            graph.EnsureCachePersistence(copy.GetType());
        }
Example #23
0
 public static byte[] GetFirstFile(PXCache cache, object row)
 {
     Guid[] guids = PXNoteAttribute.GetFileNotes(cache, row);
     if (guids.Length > 0)
     {
         var            fm = new PX.SM.UploadFileMaintenance();
         PX.SM.FileInfo fi = fm.GetFile(guids[0]);
         return(fi.BinData);
     }
     else
     {
         return(null);
     }
 }
Example #24
0
        private void SendCopyMessageToOutside(PXGraph graph, EMailAccount account, CRSMEmail message, IEnumerable <Mailbox> email)
        {
            var cache = graph.Caches[message.GetType()];
            var copy  = (CRSMEmail)cache.CreateCopy(message);

            copy.NoteID       = null;
            copy.EmailNoteID  = null;
            copy.IsIncome     = false;
            copy.ParentNoteID = message.NoteID;
            Mailbox mailFrom;

            copy.MailFrom = Mailbox.TryParse(message.MailFrom, out mailFrom)
                ? new Mailbox(mailFrom.DisplayName, account.Address).ToString()
                : account.Address;
            copy.MailTo   = ConcatAddresses(email); //TODO: need add address description
            copy.MailCc   = null;
            copy.MailBcc  = null;
            copy.MPStatus = MailStatusListAttribute.PreProcess;
            copy.ClassID  = CRActivityClass.Email;
            var imcUid = Guid.NewGuid();

            copy.ImcUID       = imcUid;
            copy.MessageId    = GetType().Name + "_" + imcUid.ToString().Replace("-", string.Empty);
            copy.IsPrivate    = message.IsPrivate;
            copy.OwnerID      = null;
            copy.ParentNoteID = null;

            copy = (CRSMEmail)cache.CreateCopy(cache.Insert(copy));

            //Update owner and reset owner if employee not found
            copy.OwnerID = message.OwnerID;
            try
            {
                copy = (CRSMEmail)cache.Update(copy);
            }
            catch (PXSetPropertyException)
            {
                copy.OwnerID = null;
                copy         = (CRSMEmail)cache.Update(copy);
            }

            copy.ParentNoteID = message.NoteID;

            var noteFiles = PXNoteAttribute.GetFileNotes(cache, message);

            if (noteFiles != null)
            {
                PXNoteAttribute.SetFileNotes(cache, copy, noteFiles);
            }
        }
Example #25
0
        protected virtual void INItemPlan_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                return;
            }
            INItemPlan plan = (INItemPlan)e.Row;

            if (plan != null)
            {
                PXCache parent = this.Document.Cache;
                plan.RefNoteID = PXNoteAttribute.GetNoteID <INReplenishmentOrder.noteID>(parent, parent.Current);
            }
        }
Example #26
0
        protected virtual PMTran InsertPMTran(RegisterEntry pmGraph, PXResult <EPExpenseClaimDetails, Contract, Account> res)
        {
            EPExpenseClaimDetails detail = res;
            Contract contract            = res;
            Account  account             = res;

            if (account.AccountGroupID == null && contract.BaseType == PMProject.ProjectBaseType.Project)
            {
                throw new PXException(Messages.AccountGroupIsNotAssignedForAccount, account.AccountCD);
            }

            bool released = contract.BaseType == Contract.ContractBaseType.Contract;             //contract trans are created as released

            PMTran tran = (PMTran)pmGraph.Transactions.Cache.Insert();

            tran.AccountGroupID = account.AccountGroupID;
            tran.BAccountID     = detail.CustomerID;
            tran.LocationID     = detail.CustomerLocationID;
            tran.ProjectID      = detail.ContractID;
            tran.TaskID         = detail.TaskID;
            tran.InventoryID    = detail.InventoryID;
            tran.Qty            = detail.Qty;
            tran.Billable       = true;
            tran.BillableQty    = detail.Qty;
            tran.UOM            = detail.UOM;
            if (detail.CuryInfoID == detail.ClaimCuryInfoID && detail.EmployeePart == 0m)
            {
                tran.UnitRate = detail.UnitCost;
            }
            else
            {
                tran.UnitRate = detail.ClaimTranAmt / detail.Qty;
            }
            tran.Amount     = detail.ClaimTranAmt;
            tran.AccountID  = detail.ExpenseAccountID;
            tran.SubID      = detail.ExpenseSubID;
            tran.StartDate  = detail.ExpenseDate;
            tran.EndDate    = detail.ExpenseDate;
            tran.Date       = detail.ExpenseDate;
            tran.ResourceID = detail.EmployeeID;
            tran.Released   = released;

            tran = pmGraph.Transactions.Update(tran);

            pmGraph.Document.Current.Released = released;

            PXNoteAttribute.CopyNoteAndFiles(Caches[typeof(EPExpenseClaimDetails)], detail, pmGraph.Transactions.Cache, tran, Setup.Current.GetCopyNoteSettings <PXModule.pm>());

            return(tran);
        }
        private void PrepareCertificationData(CarrierPlugin cp)
        {
            ICarrierService plugin = CreateCarrierService(this, cp);

            if (plugin != null)
            {
                UploadFileMaintenance upload = PXGraph.CreateInstance <UploadFileMaintenance>();
                CarrierResult <IList <CarrierCertificationData> > result = plugin.GetCertificationData();

                if (result != null)
                {
                    StringBuilder sb = new StringBuilder();
                    foreach (Message message in result.Messages)
                    {
                        sb.AppendFormat("{0}:{1} ", message.Code, message.Description);
                    }

                    if (result.IsSuccess)
                    {
                        CarrierPlugin copy = (CarrierPlugin)Plugin.Cache.CreateCopy(cp);

                        using (System.IO.MemoryStream ms = new System.IO.MemoryStream())
                        {
                            ZipArchive zip = new ZipArchive(ms, false);

                            foreach (CarrierCertificationData d in result.Result)
                            {
                                using (System.IO.Stream zipStream = zip.OpenWrite(string.Format("{0}.{1}", d.Description, d.Format)))
                                {
                                    zipStream.Write(d.File, 0, d.File.Length);
                                }
                            }

                            FileInfo file = new FileInfo("CertificationData.zip", null, ms.ToArray());
                            upload.SaveFile(file, FileExistsAction.CreateVersion);
                            PXNoteAttribute.SetFileNotes(Plugin.Cache, copy, file.UID.Value);
                        }

                        Plugin.Update(copy);

                        this.Save.Press();
                    }
                    else
                    {
                        throw new PXException(SO.Messages.CarrierServiceError, sb.ToString());
                    }
                }
            }
        }
        public BatchPost()
        {
            GLSetup setup = GLSetup.Current;

            BatchList.SetProcessDelegate <PostGraph>(
                delegate(PostGraph pg, Batch batch)
            {
                pg.Clear();
                pg.PostBatchProc(batch);
            }
                );
            BatchList.SetProcessCaption(Messages.ProcPost);
            BatchList.SetProcessAllCaption(Messages.ProcPostAll);
            PXNoteAttribute.ForcePassThrow <Batch.noteID>(BatchList.Cache);
        }
Example #29
0
        protected virtual IEnumerable LumGenerate3PLUKFile(PXAdapter adapter)
        {
            try
            {
                SOShipment soShipment = adapter.Get <SOShipment>()?.FirstOrDefault();
                // Get Csv String Builder
                var result = CombineCSV(soShipment, "P3PL");
                // Upload Graph
                UploadFileMaintenance upload = PXGraph.CreateInstance <UploadFileMaintenance>();
                // Create SM.FileInfo
                var      fileName = $"{result.OrderNbr}.csv";
                var      data     = new UTF8Encoding(true).GetBytes(result.csvText.ToString());
                FileInfo fi       = new FileInfo(fileName, null, data);
                // Upload file to FTP
                #region 3PL UK FTP
                var configYusen = SelectFrom <LUM3PLUKSetup> .View.Select(Base).RowCast <LUM3PLUKSetup>().FirstOrDefault();

                FTP_Config config = new FTP_Config()
                {
                    FtpHost = configYusen.FtpHost,
                    FtpUser = configYusen.FtpUser,
                    FtpPass = configYusen.FtpPass,
                    FtpPort = configYusen.FtpPort,
                    FtpPath = configYusen.FtpPath
                };

                var ftpResult = UploadFileByFTP(config, fileName, data);
                //var ftpResult = true;
                if (!ftpResult)
                {
                    throw new Exception("Ftp Upload Fail!!");
                }
                #endregion

                // Upload file to Attachment
                upload.SaveFile(fi);
                PXNoteAttribute.SetFileNotes(Base.Document.Cache, Base.Document.Current, fi.UID.Value);
                Base.Document.Current.GetExtension <SOShipmentExt>().UsrSendToWareHouse = true;
                Base.Document.UpdateCurrent();
                Base.Save.Press();
            }
            catch (Exception ex)
            {
                PXProcessing.SetError(ex.Message);
            }

            return(adapter.Get());
        }
        private void CloneServices(AppointmentEntry sourceAppointmentGraph, AppointmentEntry newAppointmentGraph, FSAppointment newAppointmentRow)
        {
            foreach (FSAppointmentDetService sourceRow in sourceAppointmentGraph.AppointmentDetServices.Select())
            {
                FSSODet fsSODetRow = ServiceOrderCore.GetSODetFromAppointmentDet(sourceAppointmentGraph, sourceRow);

                if (fsSODetRow != null &&
                    (fsSODetRow.Status == ID.Status_AppointmentDet.CANCELED ||
                     fsSODetRow.Status == ID.Status_AppointmentDet.COMPLETED))
                {
                    continue;
                }

                FSAppointmentDetService newRow = PXCache <FSAppointmentDetService> .CreateCopy(sourceRow);

                newRow.ActualDuration      = 0;
                newRow.ActualDateTimeBegin = null;
                newRow.ActualDateTimeEnd   = null;
                newRow.Qty = 0;

                newRow = AppointmentEntry.InsertServicePartLine <FSAppointmentDetService, FSAppointmentDetService>(
                    newAppointmentGraph.AppointmentDetServices.Cache,
                    newRow,
                    sourceAppointmentGraph.AppointmentDetServices.Cache,
                    sourceRow,
                    null,
                    sourceRow.SODetID,
                    copyTranDate: false,
                    tranDate: sourceRow.TranDate,
                    SetValuesAfterAssigningSODetID: true,
                    copyingFromQuote: false);

                PXNoteAttribute.CopyNoteAndFiles(
                    sourceAppointmentGraph.AppointmentDetServices.Cache,
                    sourceRow,
                    newAppointmentGraph.AppointmentDetServices.Cache,
                    newRow,
                    copyNotes: true,
                    copyFiles: false);


                newAppointmentGraph.AppointmentDetServices.SetValueExt <FSAppointmentDetService.acctID>(newRow, sourceRow.AcctID);
                newAppointmentGraph.AppointmentDetServices.SetValueExt <FSAppointmentDetService.subID>(newRow, sourceRow.SubID);

                AppointmentCore.UpdateAppointmentsInfoInServiceOrder(newAppointmentGraph.AppointmentDetServices.Cache, newRow, ServiceOrderRelated);
            }
        }