private static void ValidateCADailySummary(CATranEntryLight graph, CashAccount cashAccount, IFinPeriod period)
        {
            using (new PXConnectionScope())
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    graph.dailycache.Clear();
                    ts.Complete(graph);
                }
            }

            PXDatabase.Delete <CADailySummary>(
                new PXDataFieldRestrict(nameof(CADailySummary.CashAccountID), PXDbType.Int, 4, cashAccount.CashAccountID, PXComp.EQ),
                new PXDataFieldRestrict(nameof(CADailySummary.TranDate), PXDbType.DateTime, 8, period.StartDate, PXComp.GE));

            foreach (CATran tran in PXSelect <CATran,
                                              Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> >,
                                                     And <CATran.tranDate, GreaterEqual <Required <CATran.tranDate> > > > > .Select(graph, cashAccount.CashAccountID, period.StartDate))
            {
                CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(graph.catrancache, tran);
            }

            graph.dailycache.Persist(PXDBOperation.Insert);
            graph.dailycache.Persist(PXDBOperation.Update);

            graph.dailycache.Persisted(false);
        }
Ejemplo n.º 2
0
    /// <summary>
    /// The tlbPath callback event handler.
    /// </summary>
    protected void tlbPath_CallBack(object sender, PXCallBackEventArgs e)
    {
        if (e.Command.Name == "AddFav" && PXSiteMap.CurrentNode != null)
        {
            Guid nodeID = PXSiteMap.CurrentNode.NodeID;
            if (!IsInFavorites(nodeID))
            {
                AddFavorite(screenTitle, nodeID);
            }
            else
            {
                PXDatabase.Delete <Favorite>(
                    new PXDataFieldRestrict("UserID", PXAccess.GetUserID()),
                    new PXDataFieldRestrict("SiteMapID", nodeID)
                    );
            }
            PXContext.Session.FavoritesExists["FavoritesExists"] = null;
            PXSiteMap.FavoritesProvider.Clear();

            // check if favorites exists
            using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                       new PXDataField("UserID"), new PXDataFieldValue("UserID", PXAccess.GetUserID())))
            {
                e.Result = (exist == null) ? "0" : "1";
            }
        }
    }
Ejemplo n.º 3
0
        private void ErasePseudonymizedData(PXGraph processingGraph, Type childTable, IEnumerable <object> childs)
        {
            foreach (object child in childs)
            {
                List <PXDataFieldParam> assignsDB = new List <PXDataFieldParam>();

                assignsDB.Add(new PXDataFieldAssign(nameof(IPseudonymizable.PseudonymizationStatus), SetPseudonymizationStatus));

                List <PXDataFieldParam> restricts = new List <PXDataFieldParam>();

                foreach (string key in processingGraph.Caches[childTable].Keys)
                {
                    restricts.Add(new PXDataFieldRestrict(key, processingGraph.Caches[childTable].GetValue(child, key)));
                }

                PXDatabase.Update(
                    childTable,
                    assignsDB
                    .Union(restricts)
                    .ToArray()
                    );

                var entityNoteID = processingGraph.Caches[childTable].GetValue(child, nameof(INotable.NoteID)) as Guid?;

                PXDatabase.Delete <SMPersonalData>(
                    new PXDataFieldRestrict <SMPersonalData.table>(childTable.FullName),
                    new PXDataFieldRestrict <SMPersonalData.entityID>(entityNoteID));
            }
        }
Ejemplo n.º 4
0
        void sender_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
        {
            if (!IsSearchable(sender, e.Row))
            {
                return;
            }

            Guid?noteID = (Guid?)sender.GetValue(e.Row, _FieldOrdinal);

            Note note = PXSelect <Note, Where <Note.noteID, Equal <Required <Note.noteID> > > > .Select(sender.Graph, noteID);

            SearchIndex si = BuildSearchIndex(sender, e.Row, null, note != null ? note.NoteText : null);

            if (e.TranStatus == PXTranStatus.Completed)
            {
                if (noteID == null)
                {
                    throw new PXException(MsgNotLocalizable.SearchIndexCannotBeSaved);
                }

                if (e.Operation == PXDBOperation.Delete)
                {
                    PXDatabase.Delete(typeof(SearchIndex),
                                      new PXDataFieldRestrict(typeof(SearchIndex.noteID).Name, PXDbType.UniqueIdentifier, si.NoteID));
                }
                else
                {
                    if (!Update(si))
                    {
                        Insert(si);
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public IEnumerable aMBomCostSummary(RollupSettings _setting, IQueryable <AMBomItem> _bomItem)
        {
            // Delete All Data By User
            PXDatabase.Delete <AMBomCost>(new PXDataFieldRestrict <AMBomCost.userID>(Accessinfo.UserID));

            // Get All BOM Data
            int    count    = 0;
            string errorMsg = string.Empty;

            Settings.Current = _setting.DeepClone();
            List <object> result = new List <object>();

            foreach (var _bom in _bomItem)
            {
                try
                {
                    result.Add(DoingCostRoll(_bom));
                }
                catch (Exception ex)
                {
                    errorMsg += $"Error:{ex.Message} BOMID:{_bom.BOMID} Revision:{_bom.RevisionID}\n";
                }
            }
            // write Error Msg
            if (string.IsNullOrEmpty(errorMsg))
            {
                PXProcessing.SetWarning(errorMsg);
            }

            BomCostRecs.Cache.Clear();
            result.ForEach(x => { BomCostRecs.Cache.Insert(x); });
            Actions.PressSave();
            return(null);
        }
 public override void ProcessRequest(SubscribeRequest requestData)
 {
     if (requestData == null)
     {
         //Unsubscribe this user from *all* push notification
         PXDatabase.Delete <VXUserPushNotification>(
             new PXDataFieldRestrict <VXUserPushNotification.userID>(PXAccess.GetUserID())
             );
     }
     else
     {
         //Register endpoint. The page will always refresh its subscription on load.
         try
         {
             PXDatabase.Insert <VXUserPushNotification>(
                 new PXDataFieldAssign <VXUserPushNotification.userID>(PXAccess.GetUserID()),
                 new PXDataFieldAssign <VXUserPushNotification.endpoint>(requestData.Endpoint),
                 new PXDataFieldAssign <VXUserPushNotification.authKey>(requestData.Keys["auth"]),
                 new PXDataFieldAssign <VXUserPushNotification.receiverKey>(requestData.Keys["p256dh"]));
         }
         catch (PXDatabaseException e)
         {
             if (e.ErrorCode == PXDbExceptions.PrimaryKeyConstraintViolation)
             {
                 PXDatabase.Update <VXUserPushNotification>(
                     new PXDataFieldAssign <VXUserPushNotification.authKey>(requestData.Keys["auth"]),
                     new PXDataFieldAssign <VXUserPushNotification.receiverKey>(requestData.Keys["p256dh"]),
                     new PXDataFieldRestrict <VXUserPushNotification.userID>(PXAccess.GetUserID()),
                     new PXDataFieldRestrict <VXUserPushNotification.endpoint>(requestData.Endpoint));
             }
         }
     }
 }
        protected void WipeAudit(PXGraph processingGraph, Type childTable, IEnumerable <PXPersonalDataFieldAttribute> fields, IEnumerable <object> childs)
        {
            foreach (object child in childs)
            {
                string restrict = null;
                foreach (string key in processingGraph.Caches[childTable].Keys)
                {
                    restrict += processingGraph.Caches[childTable].GetValue(child, key).ToString() + PXAuditHelper.SEPARATOR;
                }

                restrict = restrict.TrimEnd(PXAuditHelper.SEPARATOR);

                List <Tuple <long, long> > modifications = new List <Tuple <long, long> >();

                foreach (PXDataRecord record in PXDatabase.SelectMulti <AuditHistory>(
                             new PXDataField <AuditHistory.batchID>(),
                             new PXDataField <AuditHistory.changeID>(),
                             new PXDataField <AuditHistory.modifiedFields>(),
                             new PXDataFieldValue <AuditHistory.combinedKey>(restrict))
                         .Where(_ => fields.Any(field => _.GetString(2).Contains(field.FieldName))))
                {
                    modifications.Add(new Tuple <long, long>(record.GetInt64(0).Value, record.GetInt64(1).Value));
                }

                foreach (var modification in modifications)
                {
                    PXDatabase.Delete <AuditHistory>(
                        new PXDataFieldRestrict <AuditHistory.batchID>(modification.Item1),
                        new PXDataFieldRestrict <AuditHistory.changeID>(modification.Item2)
                        );
                }
            }
        }
Ejemplo n.º 8
0
        public virtual void DeletePostingBatch(FSContractPostBatch fsPostBatchRow)
        {
            if (fsPostBatchRow.ContractPostBatchID < 0)
            {
                return;
            }

            PostBatchRecords.Current = PostBatchRecords.Search <FSContractPostBatch.contractPostBatchID>(fsPostBatchRow.ContractPostBatchID);

            if (PostBatchRecords.Current == null || PostBatchRecords.Current.ContractPostBatchID != fsPostBatchRow.ContractPostBatchID)
            {
                return;
            }

            using (var ts = new PXTransactionScope())
            {
                PXDatabase.Delete <FSCreatedDoc>(
                    new PXDataFieldRestrict <FSCreatedDoc.batchID>(fsPostBatchRow.ContractPostBatchID));

                PostBatchRecords.Delete(fsPostBatchRow);
                Save.Press();

                ts.Complete();
            }
        }
Ejemplo n.º 9
0
        public virtual IEnumerable ClearAllIndexes(PXAdapter adapter)
        {
            PXLongOperation.StartOperation(this, delegate()
            {
                PXDatabase.Delete(typeof(SearchIndex));
            });

            return(adapter.Get());
        }
Ejemplo n.º 10
0
        private void RestoreObfuscatedEntries(PXGraph processingGraph, Type childTable, IEnumerable <PXPersonalDataFieldAttribute> fields, IEnumerable <object> childs)
        {
            foreach (object child in childs)
            {
                var entityNoteID = processingGraph.Caches[childTable].GetValue(child, nameof(INotable.NoteID)) as Guid?;

                List <PXDataFieldParam> assignsDB = new List <PXDataFieldParam>();

                foreach (PXDataRecord record in PXDatabase.SelectMulti <SMPersonalData>(
                             new PXDataField <SMPersonalData.field>(),
                             new PXDataField <SMPersonalData.value>(),
                             new PXDataFieldValue <SMPersonalData.table>(childTable.FullName),
                             new PXDataFieldValue <SMPersonalData.entityID>(entityNoteID)))
                {
                    assignsDB.Add(new PXDataFieldAssign(record.GetString(0), record.GetString(1)));
                }

                List <PXDataFieldParam> assignsEntity = new List <PXDataFieldParam>();

                foreach (var field in fields)
                {
                    var defaultAttr = processingGraph.Caches[childTable]
                                      .GetAttributesOfType <PXDefaultAttribute>(null, field.FieldName)
                                      ?.FirstOrDefault();

                    var defaultValue = field.DefaultValue ?? defaultAttr?.Constant;

                    assignsEntity.Add(new PXDataFieldAssign(field.FieldName, defaultValue));
                }

                assignsDB.Add(new PXDataFieldAssign(nameof(IPseudonymizable.PseudonymizationStatus), SetPseudonymizationStatus));

                List <PXDataFieldParam> restricts = new List <PXDataFieldParam>();

                foreach (string key in processingGraph.Caches[childTable].Keys)
                {
                    restricts.Add(new PXDataFieldRestrict(key, processingGraph.Caches[childTable].GetValue(child, key)));
                }

                var isSuccess = PXDatabase.Update(
                    childTable,
                    InterruptRestorationHandler(processingGraph.Caches[childTable], restricts)
                    .Union(assignsDB)
                    .Union(assignsEntity)
                    .Distinct(_ => _.Column.Name.ToLower())
                    .Union(restricts)
                    .ToArray()
                    );

                if (isSuccess)
                {
                    PXDatabase.Delete <SMPersonalData>(
                        new PXDataFieldRestrict <SMPersonalData.table>(childTable.FullName),
                        new PXDataFieldRestrict <SMPersonalData.entityID>(entityNoteID));
                }
            }
        }
Ejemplo n.º 11
0
        protected virtual IEnumerable ClearData(PXAdapter adapter)
        {
            PXLongOperation.StartOperation(this, () =>
            {
                PXDatabase.Delete <LUMWarehouseImportProcess>(
                    new PXDataFieldRestrict <LUMWarehouseImportProcess.createdByID>(Accessinfo.UserID));
                this.ImportShipmentList.Cache.Clear();
            });

            return(adapter.Get());
        }
Ejemplo n.º 12
0
        protected virtual IEnumerable GenerateAdjustment(PXAdapter adapter)
        {
            var graph = PXGraph.CreateInstance <INAdjustmentEntry>();

            try
            {
                var filter   = this.Filter.Current;
                var impDatas = this.ImportPACList.Select().RowCast <LUMPacAdjCost>().ToList();

                if (string.IsNullOrEmpty(filter.FinPeriod))
                {
                    throw new PXException("Period can not be empty!!");
                }

                if (!impDatas.Any())
                {
                    throw new PXException("No Data Found!!");
                }

                // Create Adjustment
                decimal sum = 0;

                var doc = graph.adjustment.Insert((INRegister)graph.adjustment.Cache.CreateInstance());
                doc.FinPeriodID = filter.FinPeriod;
                doc.TranDesc    = "PAC COGS Adujstment";

                foreach (var row in impDatas)
                {
                    if (Math.Round((row.Cogsadj ?? 0), 0) == 0)
                    {
                        continue;
                    }
                    var line = graph.transactions.Insert((INTran)graph.transactions.Cache.CreateInstance());
                    graph.transactions.SetValueExt <INTran.inventoryID>(line, row.InventoryID);
                    graph.transactions.SetValueExt <INTran.siteID>(line, row.Siteid);
                    graph.transactions.SetValueExt <INTran.tranCost>(line, row.Cogsadj);
                    graph.transactions.SetValueExt <INTran.reasonCode>(line, "PACADJ");
                    graph.transactions.SetValueExt <INTran.lotSerialNbr>(line, string.Empty);
                    sum += (row.Cogsadj ?? 0);
                }
                doc.TotalCost = sum;
                graph.Save.Press();
                // Delete temp table data
                PXDatabase.Delete <LUMPacAdjCost>();
                this.ImportPACList.Cache.Clear();
            }
            catch (Exception ex)
            {
                throw new PXException(ex.Message);
            }
            throw new PXRedirectRequiredException(graph, "");
        }
Ejemplo n.º 13
0
        protected virtual IEnumerable PrepareImport(PXAdapter adapter)
        {
            PXLongOperation.StartOperation(this, () =>
            {
                try
                {
                    var result = DCLHelper.CallDCLToGetSOByFilter(this.DCLSetup.Select().RowCast <LUMVendCntrlSetup>().FirstOrDefault(), this.DocFilter.Current);
                    if (result.StatusCode == HttpStatusCode.OK)
                    {
                        // Delete temp table data
                        PXDatabase.Delete <LUMVendCntrlProcessOrder>(
                            new PXDataFieldRestrict <LUMVendCntrlProcessOrder.customerID>("AMZ"));
                        this.ImportOrderList.Cache.Clear();

                        int count      = 1;
                        var _dclOrders = JsonConvert.DeserializeObject <OrderResponse>(result.ContentResult);
                        // insert data to temp table
                        foreach (var orders in _dclOrders.orders)
                        {
                            if (this.ImportLog.Select().RowCast <LUMVendCntrlProcessLog>().Any(x => x.OrderID == orders.order_number && !string.IsNullOrEmpty(x.AcumaticaOrderID) && x.ImportStatus == true))
                            {
                                continue;
                            }
                            var _soOrder = this.ImportOrderList.Insert(
                                (LUMVendCntrlProcessOrder)this.ImportOrderList.Cache.CreateInstance());
                            _soOrder.LineNumber    = count++;
                            _soOrder.OrderID       = orders.order_number;
                            _soOrder.CustomerID    = orders.customer_number;
                            _soOrder.OrderDate     = DateTime.Parse(orders.ordered_date);
                            _soOrder.OrderStatusID = orders.order_stage.ToString();
                            _soOrder.OrderQty      = orders.order_lines.Sum(x => x.quantity);
                            _soOrder.OrderAmount   = orders.order_subtotal;
                            _soOrder.PoNumber      = orders.po_number;
                            _soOrder.LastUpdated   = DateTime.Parse(orders.modified_at);
                            _soOrder.Processed     = false;
                        }

                        this.Actions.PressSave();
                        return;
                    }
                    else
                    {
                        throw new Exception($"StatusCode:{result.StatusCode} Content: {result.ContentResult}");
                    }
                }
                catch (Exception e)
                {
                    throw new PXOperationCompletedWithErrorException(e.Message, e);
                }
            });
            return(adapter.Get());
        }
        void sender_RowPersisted(PXCache sender, PXRowPersistedEventArgs e)
        {
            if (!IsSearchable(sender, e.Row))
            {
                return;
            }

            Guid?noteID = (Guid?)sender.GetValue(e.Row, _FieldOrdinal);

            Dictionary <Guid, SearchIndex> dict = PX.Common.PXContext.GetSlot <Dictionary <Guid, SearchIndex> >("SearchIndexSlot");

            if (dict == null)
            {
                dict = new Dictionary <Guid, SearchIndex>();
                PX.Common.PXContext.SetSlot("SearchIndexSlot", dict);
            }
            SearchIndex si = null;

            if (noteID.HasValue)
            {
                dict.TryGetValue(noteID.Value, out si);

                if (si == null)
                {
                    Note note = PXSelect <Note, Where <Note.noteID, Equal <Required <Note.noteID> > > > .SelectSingleBound(sender.Graph, null, noteID);

                    si = BuildSearchIndex(sender, e.Row, null, note != null ? note.NoteText : null);
                    dict[noteID.Value] = si;
                }
            }

            if (e.TranStatus == PXTranStatus.Completed)
            {
                if (noteID == null)
                {
                    throw new PXException(MsgNotLocalizable.SearchIndexCannotBeSaved);
                }

                if (e.Operation == PXDBOperation.Delete)
                {
                    PXDatabase.Delete(typeof(SearchIndex),
                                      new PXDataFieldRestrict(typeof(SearchIndex.noteID).Name, PXDbType.UniqueIdentifier, si.NoteID));
                }
                else
                {
                    if (!Update(si))
                    {
                        Insert(si);
                    }
                }
            }
        }
Ejemplo n.º 15
0
        protected virtual void TXImportZipFileData_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            TXImportZipFileData row = e.Row as TXImportZipFileData;

            if (row != null)
            {
                if (_importing && !_cleared)
                {
                    PXDatabase.Delete <TXImportZipFileData>();
                    _cleared = true;
                }
            }
        }
Ejemplo n.º 16
0
            public bool PersistGrams(Contact contact, bool requireRecreate = false)
            {
                try
                {
                    if (track == null)
                    {
                        track = DateTime.Now;
                    }
                    if (graph.Caches[contact.GetType()].GetStatus(contact) == PXEntryStatus.Deleted)
                    {
                        PXDatabase.Delete <CRGrams>(new PXDataFieldRestrict("EntityID", PXDbType.Int, 4, contact.ContactID, PXComp.EQ));
                        return(false);
                    }

                    if (!requireRecreate && GrammSourceUpdated(contact))
                    {
                        return(false);
                    }

                    PXDatabase.Delete <CRGrams>(new PXDataFieldRestrict("EntityID", PXDbType.Int, 4, contact.ContactID, PXComp.EQ));
                    foreach (CRGrams gram in DoCreateGramms(contact))
                    {
                        PXDatabase.Insert <CRGrams>(
                            new PXDataFieldAssign(typeof(CRGrams.entityID).Name, PXDbType.Int, 4, contact.ContactID),
                            new PXDataFieldAssign(typeof(CRGrams.fieldName).Name, PXDbType.NVarChar, 60, gram.FieldName),
                            new PXDataFieldAssign(typeof(CRGrams.fieldValue).Name, PXDbType.NVarChar, 60, gram.FieldValue),
                            new PXDataFieldAssign(typeof(CRGrams.score).Name, PXDbType.Decimal, 8, gram.Score),
                            new PXDataFieldAssign(typeof(CRGrams.validationType).Name, PXDbType.NVarChar, 2, gram.ValidationType)
                            );
                        //CRGrams row = (CRGrams)graph.Caches[typeof(CRGrams)].Insert(gram);
                        //graph.Caches[typeof(CRGrams)].PersistInserted(row);
                    }
                    contact.GrammValidationDateTime = PXTimeZoneInfo.Now;
                    PXDatabase.Update <Contact>
                    (
                        new PXDataFieldAssign(typeof(Contact.grammValidationDateTime).Name, PXTimeZoneInfo.ConvertTimeToUtc(contact.GrammValidationDateTime.Value, LocaleInfo.GetTimeZone())),
                        new PXDataFieldRestrict(typeof(Contact.contactID).Name, contact.ContactID)
                    );
                    processedItems += 1;
                    return(true);
                }
                finally
                {
                    if (processedItems % 100 == 0)
                    {
                        TimeSpan taken = DateTime.Now - (DateTime)track;
                        System.Diagnostics.Debug.WriteLine("Items count:{0}, increment taken {1}", processedItems, taken);
                        track = DateTime.Now;
                    }
                }
            }
Ejemplo n.º 17
0
        private void CleanNonRestored(IEnumerable <IBqlTable> entities)
        {
            var processingGraph = PXGraph.CreateInstance <GDPRPersonalDataProcessBase>();

            foreach (IBqlTable entity in entities)
            {
                processingGraph.EnsureCachePersistence(entity.GetType());

                var entityCache = processingGraph.Caches[entity.GetType()];

                PXDatabase.Delete <SMPersonalData>(
                    new PXDataFieldRestrict <SMPersonalData.topParentNoteID>(entityCache.GetValue(entity, nameof(INotable.NoteID))));
            }
        }
Ejemplo n.º 18
0
        public virtual IEnumerable deleteGeneratedPeriods(PXAdapter adapter)
        {
            FABookYearSetup year = FiscalYearSetup.Current;

            PXLongOperation.StartOperation(this, delegate
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    PXDatabase.Delete <FABookYear>(new PXDataFieldRestrict("BookID", PXDbType.Int, 4, year.BookID, PXComp.EQ));
                    PXDatabase.Delete <FABookPeriod>(new PXDataFieldRestrict("BookID", PXDbType.Int, 4, year.BookID, PXComp.EQ));
                    ts.Complete();
                }
            });
            return(adapter.Get());
        }
Ejemplo n.º 19
0
 protected void Logout(object sender, EventArgs e)
 {
     try
     {
         PXLogin.LogoutUser(PXAccess.GetUserName(), Session.SessionID);
         PXContext.Session.SetString("UserLogin", string.Empty);
         Session.Abandon();
         PX.Data.Auth.ExternalAuthHelper.SignOut(Context, "~/Frames/Outlook/FirstRun.html");
         PXDatabase.Delete <PX.SM.UserIdentity>(
             new PXDataFieldRestrict <PX.SM.UserIdentity.providerName>(PXDbType.VarChar, "ExchangeIdentityToken"),
             new PXDataFieldRestrict <PX.SM.UserIdentity.userID>(PXDbType.UniqueIdentifier, PXAccess.GetUserID())
             );
     }
     finally
     {
         PX.Data.Redirector.Redirect(System.Web.HttpContext.Current, "~/Frames/Outlook/FirstRun.html");
     }
 }
Ejemplo n.º 20
0
        protected virtual void InventoryItem_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            InventoryItem row = e.Row as InventoryItem;

            if (row.IsSplitted == true)
            {
                if (string.IsNullOrEmpty(row.DeferredCode))
                {
                    if (sender.RaiseExceptionHandling <InventoryItem.deferredCode>(e.Row, row.DeferredCode, new PXSetPropertyException(Data.ErrorMessages.FieldIsEmpty, typeof(InventoryItem.deferredCode).Name)))
                    {
                        throw new PXRowPersistingException(typeof(InventoryItem.deferredCode).Name, row.DeferredCode, Data.ErrorMessages.FieldIsEmpty, typeof(InventoryItem.deferredCode).Name);
                    }
                }

                var components = Components.Select().RowCast <INComponent>().ToList();

                VerifyComponentPercentages(sender, row, components);
                VerifyOnlyOneResidualComponent(sender, row, components);
                CheckSameTermOnAllComponents(Components.Cache, components);
            }

            if (!PXAccess.FeatureInstalled <FeaturesSet.distributionModule>() || !PXAccess.FeatureInstalled <FeaturesSet.inventory>())
            {
                row.NonStockReceipt = false;
                row.NonStockShip    = false;
            }

            if (row.NonStockReceipt == true)
            {
                if (string.IsNullOrEmpty(row.PostClassID))
                {
                    throw new PXRowPersistingException(typeof(InventoryItem.postClassID).Name, row.PostClassID, Data.ErrorMessages.FieldIsEmpty, typeof(InventoryItem.postClassID).Name);
                }
            }

            if (e.Operation == PXDBOperation.Delete)
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    PXDatabase.Delete <CSAnswers>(new PXDataFieldRestrict("RefNoteID", PXDbType.UniqueIdentifier, ((InventoryItem)e.Row).NoteID));
                    ts.Complete(this);
                }
            }
        }
        protected IEnumerable clearLog(PXAdapter adapter)
        {
            EMailAccountSyncFilter filter  = Filter.Current;
            EMailSyncAccount       account = SelectedItems.Current;

            if (filter == null || account == null)
            {
                return(adapter.Get());
            }


            PXDatabase.Delete <EMailSyncLog>(
                new PXDataFieldRestrict <EMailSyncLog.address>(account.Address),
                new PXDataFieldRestrict <EMailSyncLog.serverID>(account.ServerID));

            OperationLog.View.RequestRefresh();
            OperationLog.View.Clear();

            return(adapter.Get());
        }
    /// <summary>
    /// The tlbPath callback event handler.
    /// </summary>
    protected void tlbPath_CallBack(object sender, PXCallBackEventArgs e)
    {
        if (e.Command.Name == "AddFav" && PXSiteMap.CurrentNode != null)
        {
            Guid nodeID = PXSiteMap.CurrentNode.NodeID;
            if (!IsInFavorites(nodeID))
            {
                AddFavorite(screenTitle, nodeID);
            }
            else
            {
                PXDatabase.Delete <Favorite>(
                    new PXDataFieldRestrict("UserID", PXAccess.GetUserID()),
                    new PXDataFieldRestrict("SiteMapID", nodeID)
                    );
            }
            PXContext.Session.FavoritesExists["FavoritesExists"] = null;
            PXSiteMap.FavoritesProvider.Clear();

            // check if favorites exists
            using (PXDataRecord exist = PXDatabase.SelectSingle <Favorite>(
                       new PXDataField("UserID"), new PXDataFieldValue("UserID", PXAccess.GetUserID())))
            {
                e.Result = (exist == null) ? "0" : "1";
            }
        }
        else if (e.Command.Name == "ClearFilter")
        {
            var ds = PXPage.GetDefaultDataSource(this.Page);
            if (ds != null)
            {
                var action = ds.DataGraph.Actions[clearFilterCommand];
                if (action != null)
                {
                    action.Press();
                }
            }
            PXCallbackManager.RegisterJavaScript(
                "if (window['__px_alls'] && __px_alls(this) && __px_alls(this)['tlbPath'])__px_alls(this)['tlbPath'].items['clearFilter'].setVisible(false);");
        }
    }
        public override void Persist()
        {
            using (var ts = new PXTransactionScope())
            {
                foreach (INSite record in site.Cache.Deleted)
                {
                    PXDatabase.Delete <INSiteStatus>(
                        new PXDataFieldRestrict <INSiteStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ),
                        new PXDataFieldRestrict <INSiteStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ),
                        new PXDataFieldRestrict <INSiteStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ));

                    PXDatabase.Delete <INLocationStatus>(
                        new PXDataFieldRestrict <INLocationStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ),
                        new PXDataFieldRestrict <INLocationStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ),
                        new PXDataFieldRestrict <INLocationStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ));

                    PXDatabase.Delete <INLotSerialStatus>(
                        new PXDataFieldRestrict <INLotSerialStatus.siteID>(PXDbType.Int, 4, record.SiteID, PXComp.EQ),
                        new PXDataFieldRestrict <INLotSerialStatus.qtyOnHand>(PXDbType.Decimal, 8, 0m, PXComp.EQ),
                        new PXDataFieldRestrict <INLotSerialStatus.qtyAvail>(PXDbType.Decimal, 8, 0m, PXComp.EQ));

                    InventoryItem item =
                        PXSelectJoin <InventoryItem,
                                      InnerJoin <INSiteStatus, On <INSiteStatus.inventoryID, Equal <InventoryItem.inventoryID> > >,
                                      Where <INSiteStatus.siteID, Equal <Required <INSiteStatus.siteID> > > >
                        .SelectWindowed(this, 0, 1, record.SiteID);

                    if (item?.InventoryCD != null)
                    {
                        throw new PXRowPersistingException(typeof(INSite.siteCD).Name, record, Messages.SiteUsageDeleted, item.InventoryCD.TrimEnd());
                    }
                }

                ts.Complete();
            }

            base.Persist();
            location.Cache.Clear();
        }
Ejemplo n.º 24
0
        protected virtual IEnumerable PrepareImport(PXAdapter adapter)
        {
            PXLongOperation.StartOperation(this, () =>
            {
                try
                {
                    // Clear Data
                    PXDatabase.Delete <LUMP3PLImportProcess>(
                        new PXDataFieldRestrict <LUMP3PLImportProcess.createdByID>(Accessinfo.UserID));
                    this.ImportDataList.Cache.Clear();

                    // Load FTP File
                    FTP_Config config   = GetConfig();
                    FTPHelper helper    = new FTPHelper(config);
                    var ftpFileContents = helper.LoadFileStringFromFTP();
                    foreach (var item in ftpFileContents)
                    {
                        var line               = item.Value.Split(';');
                        var model              = this.ImportDataList.Insert((LUMP3PLImportProcess)this.ImportDataList.Cache.CreateInstance());
                        model.WarehouseOrder   = line[0];
                        model.CustomerOrderRef = line[1];
                        model.OrderStatus      = line[2];
                        model.UnitsSent        = int.Parse(string.IsNullOrEmpty(line[3]) ? "0" : line[3]);
                        model.Carrier          = line[4];
                        model.TrackingNumber   = line[5];
                        model.FreightCost      = decimal.Parse(string.IsNullOrEmpty(line[6]) ? "0" : line[6]);
                        model.FreightCurrency  = line[7];
                        model.FtpFileName      = item.Key;
                    }
                    this.Actions.PressSave();
                }
                catch (Exception e)
                {
                    throw new PXOperationCompletedWithErrorException(e.Message, e);
                }
            });
            return(adapter.Get());
        }
Ejemplo n.º 25
0
        public bool PersistGrams(DuplicateDocument document, bool requireRecreate = false)
        {
            if (graph.Caches[document.GetType()].GetStatus(document) == PXEntryStatus.Deleted)
            {
                PXDatabase.Delete <CRGrams>(new PXDataFieldRestrict <CRGrams.entityID>(PXDbType.Int, 4, document.ContactID, PXComp.EQ));

                return(false);
            }

            if (!requireRecreate && GrammSourceUpdated(document))
            {
                return(false);
            }

            PXDatabase.Delete <CRGrams>(new PXDataFieldRestrict <CRGrams.entityID>(PXDbType.Int, 4, document.ContactID, PXComp.EQ));

            foreach (CRGrams gram in DoCreateGramms(document))
            {
                PXDatabase.Insert <CRGrams>(
                    new PXDataFieldAssign(typeof(CRGrams.entityID).Name, PXDbType.Int, 4, document.ContactID),
                    new PXDataFieldAssign(typeof(CRGrams.fieldName).Name, PXDbType.NVarChar, 60, gram.FieldName),
                    new PXDataFieldAssign(typeof(CRGrams.fieldValue).Name, PXDbType.NVarChar, 60, gram.FieldValue),
                    new PXDataFieldAssign(typeof(CRGrams.score).Name, PXDbType.Decimal, 8, gram.Score),
                    new PXDataFieldAssign(typeof(CRGrams.validationType).Name, PXDbType.NVarChar, 2, gram.ValidationType)
                    );
            }

            document.DuplicateStatus         = DuplicateStatusAttribute.NotValidated;
            document.GrammValidationDateTime = PXTimeZoneInfo.Now;

            PXDatabase.Update <Contact>(
                new PXDataFieldAssign <Contact.duplicateStatus>(PXDbType.NVarChar, document.DuplicateStatus),
                new PXDataFieldAssign <Contact.grammValidationDateTime>(PXDbType.DateTime, PXTimeZoneInfo.ConvertTimeToUtc(document.GrammValidationDateTime.Value, LocaleInfo.GetTimeZone())),
                new PXDataFieldRestrict <Contact.contactID>(PXDbType.Int, document.ContactID)
                );

            return(true);
        }
Ejemplo n.º 26
0
        protected virtual IEnumerable LoadData(PXAdapter adapter)
        {
            var filter     = this.Filter.Current;
            var sourceData = SelectFrom <vPACAdjCost> .Where <vPACAdjCost.finPeriodID.IsEqual <P.AsString> > .View.Select(this, filter.FinPeriod).RowCast <vPACAdjCost>().ToList().Where(x => x.FinPeriodID == filter.FinPeriod);

            // Delete temp table data
            PXDatabase.Delete <LUMPacAdjCost>();
            this.ImportPACList.Cache.Clear();

            foreach (var item in sourceData)
            {
                var data = this.ImportPACList.Insert((LUMPacAdjCost)this.ImportPACList.Cache.CreateInstance());
                data.FinPeriodID    = item.FinPeriodID;
                data.Finptdcogs     = item.Finptdcogs;
                data.FinPtdQtySales = item.FinPtdQtySales;
                data.PACUnitCost    = item.PACUnitCost;
                data.InventoryID    = item.InventoryID;
                data.Paccogs        = item.Paccogs;
                data.Siteid         = item.Siteid;
                data.Cogsadj        = item.Cogsadj;
            }
            this.Actions.PressSave();
            return(adapter.Get());
        }
Ejemplo n.º 27
0
        public override void UpdateDatabase()
        {
            ProjectList graph = PXGraph.CreateInstance <ProjectList>();

            try
            {
                SOThrottleConstants records = PXSelectReadonly <SOThrottleConstants> .Select(graph);

                if (records != null)
                {
                    PXDatabase.Delete <SOThrottleConstants>();
                }
                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiListOrders),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("30000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID)
                    );

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiListOrdersByNextToken),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("30000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiGetOrder),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("30000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiGetListOrderItems),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("10000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiSubmitFeed),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("20000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiGetFeedSubmissionResult),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("20000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiRequestReport),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("10000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiGetRequestReportList),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("30000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.getGeneratedReportID),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("30000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiGetReport),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("20000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));

                PXDatabase.Insert <SOThrottleConstants>(
                    new PXDataFieldAssign <SOThrottleConstants.apiname>(SOConstants.apiFeedResultWaiting),
                    new PXDataFieldAssign <SOThrottleConstants.delayTime>("20000"),
                    new PXDataFieldAssign <SOThrottleConstants.createdDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedDateTime>(PXTimeZoneInfo.Now),
                    new PXDataFieldAssign <SOThrottleConstants.createdByID>(graph.Accessinfo.UserID),
                    new PXDataFieldAssign <SOThrottleConstants.lastModifiedByID>(graph.Accessinfo.UserID));
            }
            catch (Exception ex)
            {
                PXTrace.WriteInformation(ex.Message);
            }
        }
Ejemplo n.º 28
0
        private static void Validate(CATranEntryLight te, CashAccount tlist)
        {
            using (new PXConnectionScope())
            {
                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    Account account = PXSelect <Account, Where <Account.isCashAccount, Equal <False>,
                                                                And <Account.accountID, Equal <Required <Account.accountID> > > > > .Select(te, tlist.AccountID);

                    if (account != null)
                    {
                        account.IsCashAccount = true;
                        te.account.Update(account);
                        te.account.Cache.Persist(PXDBOperation.Update);
                        te.account.Cache.Persisted(false);
                    }
                    ts.Complete(te);
                }
            }
            te.Clear();

            if (tlist.Reconcile != true)
            {
                te.Clear();
                using (new PXConnectionScope())
                {
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        PXCache adjcache = te.Caches[typeof(CATran)];
                        foreach (CATran catran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID))
                        {
                            if (tlist.Reconcile != true && (catran.Cleared != true || catran.TranDate == null))
                            {
                                catran.Cleared   = true;
                                catran.ClearDate = catran.TranDate;
                            }
                            te.catrancache.Update(catran);
                        }
                        te.catrancache.Persist(PXDBOperation.Update);
                        ts.Complete(te);
                    }
                    te.catrancache.Persisted(false);
                }
            }

            te.Clear();

            using (new PXConnectionScope())
            {
                PXCache adjcache = te.Caches[typeof(CAAdj)];

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <CAAdj, CATran> res in PXSelectJoin <CAAdj, LeftJoin <CATran, On <CATran.tranID, Equal <CAAdj.tranID> >,
                                                                                            LeftJoin <GLTranDoc, On <GLTranDoc.refNbr, Equal <CAAdj.adjRefNbr>, And <GLTranDoc.tranType, Equal <CAAdj.adjTranType>, And <GLTranDoc.tranModule, Equal <BatchModule.moduleCA> > > > > >,
                                                                           Where <CAAdj.cashAccountID, Equal <Required <CAAdj.cashAccountID> >, And <CATran.tranID, IsNull, And <GLTranDoc.refNbr, IsNull> > > > .Select(te, tlist.CashAccountID))
                    {
                        CAAdj caadj = (CAAdj)res;

                        GLTran gltran = PXSelectJoin <GLTran, InnerJoin <CashAccount,
                                                                         On <CashAccount.accountID, Equal <GLTran.accountID>,
                                                                             And <CashAccount.subID, Equal <GLTran.subID>,
                                                                                  And <CashAccount.branchID, Equal <GLTran.branchID> > > > >,
                                                      Where <GLTran.cATranID, Equal <Required <CAAdj.tranID> >,
                                                             And <CashAccount.cashAccountID, Equal <Required <CAAdj.cashAccountID> > > > > .Select(te, caadj.TranID, caadj.CashAccountID);

                        adjcache.SetValue <CAAdj.tranID>(caadj, null);
                        adjcache.SetValue <CAAdj.cleared>(caadj, false);

                        CATran catran = AdjCashTranIDAttribute.DefaultValues <CAAdj.tranID>(adjcache, caadj);
                        catran.BatchNbr = gltran?.BatchNbr;

                        long?id = null;

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            te.SelectTimeStamp();

                            adjcache.SetValue <CAAdj.tranID>(caadj, id);
                            adjcache.Update(caadj);
                        }

                        if (id.HasValue && gltran?.TranID != null)
                        {
                            gltran.CATranID = id;
                            te.gltrancache.Update(gltran);
                            te.gltrancache.Persist(PXDBOperation.Update);
                        }
                    }

                    adjcache.Persist(PXDBOperation.Update);

                    ts.Complete(te);
                }

                adjcache.Persisted(false);
                te.catrancache.Persisted(false);
                te.gltrancache.Persisted(false);
            }

            te.Clear();

            using (new PXConnectionScope())
            {
                PXCache transfercache = te.Caches[typeof(CATransfer)];

                using (PXTransactionScope ts = new PXTransactionScope())
                {
                    foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDIn> > >, Where <CATransfer.inAccountID, Equal <Required <CATransfer.inAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID))
                    {
                        CATransfer catransfer = (CATransfer)res;

                        transfercache.SetValue <CATransfer.tranIDIn>(catransfer, null);
                        transfercache.SetValue <CATransfer.clearedIn>(catransfer, false);
                        if (transfercache.GetValue <CATransfer.clearedOut>(catransfer) == null)
                        {
                            transfercache.SetValue <CATransfer.clearedOut>(catransfer, false);
                        }

                        CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDIn>(transfercache, catransfer);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            transfercache.SetValue <CATransfer.tranIDIn>(catransfer, id);
                            transfercache.Update(catransfer);
                        }
                    }

                    foreach (PXResult <CATransfer, CATran> res in PXSelectJoin <CATransfer, LeftJoin <CATran, On <CATran.tranID, Equal <CATransfer.tranIDOut> > >, Where <CATransfer.outAccountID, Equal <Required <CATransfer.outAccountID> >, And <CATran.tranID, IsNull> > > .Select(te, tlist.CashAccountID))
                    {
                        CATransfer catransfer = (CATransfer)res;

                        transfercache.SetValue <CATransfer.tranIDOut>(catransfer, null);
                        transfercache.SetValue <CATransfer.clearedOut>(catransfer, false);
                        if (transfercache.GetValue <CATransfer.clearedIn>(catransfer) == null)
                        {
                            transfercache.SetValue <CATransfer.clearedIn>(catransfer, false);
                        }

                        CATran catran = TransferCashTranIDAttribute.DefaultValues <CATransfer.tranIDOut>(transfercache, catransfer);

                        if (catran != null)
                        {
                            catran = (CATran)te.catrancache.Insert(catran);
                            te.catrancache.PersistInserted(catran);
                            long id = Convert.ToInt64(PXDatabase.SelectIdentity());

                            transfercache.SetValue <CATransfer.tranIDOut>(catransfer, id);
                            transfercache.Update(catransfer);
                        }
                    }

                    transfercache.Persist(PXDBOperation.Update);

                    ts.Complete(te);
                }

                transfercache.Persisted(false);
                te.catrancache.Persisted(false);
            }

            te.Clear();

            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.module>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.batchNbr>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.ledgerID>(te.Caches[typeof(GLTran)], null, false);
            PXDBDefaultAttribute.SetDefaultForUpdate <GLTran.finPeriodID>(te.Caches[typeof(GLTran)], null, false);

            using (new PXConnectionScope())
            {
                const int rowsPerCycle = 10000;
                bool      noMoreTran   = false;
                int?      lastGLTranIDOnPreviousStep = null;
                int       previousCountRows          = 0;

                while (!noMoreTran)
                {
                    noMoreTran = true;
                    int countRows    = 0;
                    int?lastGLTranID = null;
                    using (PXTransactionScope ts = new PXTransactionScope())
                    {
                        foreach (PXResult <GLTran, Ledger, Batch> res in PXSelectJoin <GLTran, InnerJoin <Ledger, On <Ledger.ledgerID, Equal <GLTran.ledgerID> >,
                                                                                                          InnerJoin <Batch, On <Batch.module, Equal <GLTran.module>, And <Batch.batchNbr, Equal <GLTran.batchNbr>,
                                                                                                                                                                          And <Batch.scheduled, Equal <False>, And <Batch.voided, NotEqual <True> > > > > > >,
                                                                                       Where <GLTran.accountID, Equal <Required <GLTran.accountID> >,
                                                                                              And <GLTran.subID, Equal <Required <GLTran.subID> >,
                                                                                                   And <GLTran.branchID, Equal <Required <GLTran.branchID> >,
                                                                                                        And <Ledger.balanceType, Equal <LedgerBalanceType.actual>,
                                                                                                             //ignoring CM because DefaultValues always return null for CM
                                                                                                             And <GLTran.module, NotEqual <BatchModule.moduleCM>,
                                                                                                                  And <GLTran.cATranID, IsNull> > > > > >, OrderBy <Asc <GLTran.tranID> > > .SelectWindowed(te, 0, rowsPerCycle, tlist.AccountID, tlist.SubID, tlist.BranchID))
                        {
                            GLTran gltran = (GLTran)res;
                            lastGLTranID = gltran.TranID;
                            noMoreTran   = false;
                            countRows++;
                            CATran catran = GLCashTranIDAttribute.DefaultValues <GLTran.cATranID>(te.gltrancache, gltran);
                            if (catran != null)
                            {
                                long id;
                                bool newCATRan = false;
                                if (te.catrancache.Locate(catran) == null)
                                {
                                    catran    = (CATran)te.catrancache.Insert(catran);
                                    newCATRan = true;
                                    te.catrancache.PersistInserted(catran);
                                    id = Convert.ToInt64(PXDatabase.SelectIdentity());
                                }
                                else
                                {
                                    catran = (CATran)te.catrancache.Update(catran);
                                    te.catrancache.PersistUpdated(catran);
                                    id = catran.TranID.Value;
                                }

                                gltran.CATranID = id;
                                te.gltrancache.Update(gltran);

                                if (catran.OrigModule != GLTranType.GLEntry)
                                {
                                    switch (catran.OrigModule)
                                    {
                                    case BatchModule.AR:
                                        ARPayment arPayment = PXSelect <ARPayment, Where <ARPayment.docType, Equal <Required <ARPayment.docType> >,
                                                                                          And <ARPayment.refNbr, Equal <Required <ARPayment.refNbr> > > > > .Select(te, catran.OrigTranType, catran.OrigRefNbr);

                                        if (arPayment != null && (arPayment.CATranID == null || newCATRan))
                                        {
                                            arPayment.CATranID = id;
                                            arPayment          = (ARPayment)te.Caches[typeof(ARPayment)].Update(arPayment);
                                            te.Caches[typeof(ARPayment)].PersistUpdated(arPayment);
                                        }
                                        break;

                                    case BatchModule.AP:
                                        APPayment apPayment = PXSelect <APPayment, Where <APPayment.docType, Equal <Required <APPayment.docType> >,
                                                                                          And <APPayment.refNbr, Equal <Required <APPayment.refNbr> > > > > .Select(te, catran.OrigTranType, catran.OrigRefNbr);

                                        if (apPayment != null && (apPayment.CATranID == null || newCATRan))
                                        {
                                            apPayment.CATranID = id;
                                            apPayment          = (APPayment)te.Caches[typeof(APPayment)].Update(apPayment);
                                            te.Caches[typeof(APPayment)].PersistUpdated(apPayment);
                                        }
                                        break;
                                    }
                                }
                            }
                        }

                        if (!noMoreTran && countRows == previousCountRows && lastGLTranID == lastGLTranIDOnPreviousStep)
                        {
                            throw new PXException(Messages.ProcessCannotBeCompleted);
                        }

                        previousCountRows          = countRows;
                        lastGLTranIDOnPreviousStep = lastGLTranID;

                        te.gltrancache.ClearQueryCache();
                        te.gltrancache.Persist(PXDBOperation.Update);
                        te.gltrancache.Clear();
                        te.catrancache.Clear();
                        te.catrancache.ClearQueryCache();
                        te.dailycache.Clear();
                        te.Caches[typeof(APPayment)].Clear();
                        te.Caches[typeof(ARPayment)].Clear();
                        ts.Complete(te);
                    }
                }

                PXDatabase.Delete <CADailySummary>(
                    new PXDataFieldRestrict("CashAccountID", PXDbType.Int, 4, tlist.CashAccountID, PXComp.EQ));

                foreach (CATran tran in PXSelect <CATran, Where <CATran.cashAccountID, Equal <Required <CATran.cashAccountID> > > > .Select(te, tlist.CashAccountID))
                {
                    CADailyAccumulatorAttribute.RowInserted <CATran.tranDate>(te.catrancache, tran);
                }

                te.dailycache.Persist(PXDBOperation.Insert);
                te.dailycache.Persist(PXDBOperation.Update);


                te.gltrancache.Persisted(false);
                te.catrancache.Persisted(false);
                te.dailycache.Persisted(false);
            }
        }
Ejemplo n.º 29
0
 public static bool Delete(SearchIndex record)
 {
     return(PXDatabase.Delete(typeof(SearchIndex),
                              new PXDataFieldRestrict(typeof(SearchIndex.noteID).Name, PXDbType.UniqueIdentifier, record.NoteID)));
 }
Ejemplo n.º 30
0
 /// <summary>
 /// Delete specify table record by Processed is not true.
 /// </summary>
 protected static void DeleteWrkTableRecs()
 {
     PXDatabase.Delete <LUM3DCartProcessOrder>(new PXDataFieldRestrict <LUM3DCartProcessOrder.processed>(PXDbType.Bit, false));
 }