Esempio n. 1
0
        public SqlTransaction AcknowledgePickupNotice(PUNAcknowledgementInformation acknowledgement)
        {
            if (!acknowledgement.PickupNoticeAgentVerified)
            {
                throw new Exception("Please confirm pickup notice agent has been verified.");
            }
            if (acknowledgement.ClientId == Guid.Empty)
            {
                throw new Exception("This pickup notice is issued to unknown client and couldnot be processed.");
            }
            if (acknowledgement.CommodityGradeId == Guid.Empty)
            {
                throw new Exception("The commodity grade in this pickup notice is unknown.");
            }
            acknowledgement.PledgedWeight  = acknowledgement.Weight;
            PickupNoticeInformation.Status = (int)PUNStatusType.BeingIssued;
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]));
            try
            {
                return(PersistenceTransactionFactory.CreatePersistenceTransaction().Persist(
                           new Queue <object>(new object[] { PickupNoticeInformation, acknowledgement }), contextParameters));
            }
            catch (Exception ex)
            {
                throw new Exception("Your acknowledgement couldn't be saved to the database");
            }
        }
Esempio n. 2
0
        public void AddStackPhysicalCount(PhysicalCountInfo physicalCount, StackPhysicalCountInfo stackPhysicalCount)
        {
            if (physicalCount.Stacks.Any(s => (s.StackId == stackPhysicalCount.StackId)))
            {
                throw new Exception("Invalid Stack Count : Stack count shall not be duplicated");
            }
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("StackId", stackPhysicalCount.StackId);
            contextParameters.Add("PhysicalCountId", stackPhysicalCount.PhysicalCountId);
            try
            {
                XmlSerializer s        = new XmlSerializer(typeof(StackInventoryStatusInfo));
                XmlDocument   document = PersistenceTransactionFactory.CreatePersistenceTransaction().Open(
                    "spGetStackInventoryStatus", contextParameters);
                StringBuilder sb     = new StringBuilder();
                TextWriter    writer = new StringWriter(sb);
                document.Save(writer);

                StackInventoryStatusInfo sis = (StackInventoryStatusInfo)s.Deserialize(new StringReader(sb.ToString()));
                stackPhysicalCount.CummulatedShortage = sis.CummulatedShortage;
                stackPhysicalCount.CumulatedOverage   = sis.CumulatedOverage;
                stackPhysicalCount.ExpectedBalance    = sis.ExpectedBalance;
            }
            catch (Exception ex)
            {
                throw new Exception("The database failed to load a required Stack Inventory Status ", ex);
            }
            physicalCount.Stacks.Add(stackPhysicalCount);
        }
Esempio n. 3
0
        public void SavePhysicalCount(PhysicalCountInfo physicalCount)
        {
            PhysicalCountInfo originalPhysicalCount = OpenPhysicalCount(physicalCount.Id);
            AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.InvCount,
                                                          new object[][] { new object[] { originalPhysicalCount, physicalCount, AuditTrailWrapper.ExistingRecord } }, "Inventory Control");

            foreach (PhysicalCountInspectorInfo inspector in physicalCount.Inspectors)
            {
                PhysicalCountInspectorInfo originalInspector = originalPhysicalCount.Inspectors.Find(oi => oi.Id == inspector.Id);
                if (originalInspector == null)
                {
                    atw.AddChange(null, inspector, AuditTrailWrapper.NewRecord);
                }
                else
                {
                    atw.AddChange(originalInspector, inspector, AuditTrailWrapper.ExistingRecord);
                }
            }
            foreach (StackPhysicalCountInfo stack in originalPhysicalCount.Stacks)
            {
                StackPhysicalCountInfo originalStack = physicalCount.Stacks.Find(os => os.Id == stack.Id);
                if (originalStack == null)
                {
                    atw.AddChange(null, stack, AuditTrailWrapper.NewRecord);
                }
                else
                {
                    atw.AddChange(originalStack, stack, AuditTrailWrapper.ExistingRecord);
                }
            }

            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]));
            Queue <object> queue = new Queue <object>(new object[] { physicalCount });

            foreach (PhysicalCountInspectorInfo inspector in physicalCount.Inspectors)
            {
                queue.Enqueue(inspector);
            }
            foreach (StackPhysicalCountInfo stack in physicalCount.Stacks)
            {
                queue.Enqueue(stack);
            }
            try
            {
                SqlTransaction transaction = PersistenceTransactionFactory.CreatePersistenceTransaction().Persist(
                    queue, contextParameters);
                if (!atw.Save())
                {
                    transaction.Rollback();
                    throw new Exception("Failed to save audit trail!");
                }
                transaction.Commit();
            }
            catch (Exception ex)
            {
                throw new Exception("Physical Count couldn't be saved to the database", ex);
            }
        }
Esempio n. 4
0
        public SqlTransaction Aborted()
        {
            PickupNoticeInformation.Status = (int)PUNStatusType.Aborted;
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]));
            try
            {
                return(PersistenceTransactionFactory.CreatePersistenceTransaction().Persist(
                           new Queue <object>(new object[] { PickupNoticeInformation }), contextParameters));
            }
            catch (Exception)
            {
                throw new Exception("The PUN abortion couldn't be saved to the database");
            }
        }
Esempio n. 5
0
        public SqlTransaction LoadFromStack(Guid stackId, int bags, float weight, SqlTransaction transction)
        {
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]));
            Queue <object> queue = new Queue <object>(new object[] { new StackLoadInfo(stackId, bags, weight) });

            try
            {
                return(PersistenceTransactionFactory.CreatePersistenceTransaction().Persist(
                           queue, contextParameters, transction));
            }
            catch (Exception ex)
            {
                throw new Exception("Unable to save stack unloading to the database", ex);
            }
        }
Esempio n. 6
0
        public PhysicalCountInfo OpenPhysicalCount(Guid id)
        {
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("Id", id);
            try
            {
                XmlSerializer s        = new XmlSerializer(typeof(PhysicalCountInfo));
                XmlDocument   document = PersistenceTransactionFactory.CreatePersistenceTransaction().Open(
                    "spOpenPhysicalInventory", contextParameters);
                StringBuilder sb     = new StringBuilder();
                TextWriter    writer = new StringWriter(sb);
                document.Save(writer);

                return((PhysicalCountInfo)s.Deserialize(new StringReader(sb.ToString())));
            }
            catch (Exception ex)
            {
                throw new Exception("The database failed to load the requested Physical Count ", ex);
            }
        }
Esempio n. 7
0
        public PickupNoticeBLL(Guid pickupNoticeId)
        {
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("PickupNoticeId", pickupNoticeId);
            try
            {
                XmlSerializer s        = new XmlSerializer(typeof(PickupNoticeInformation));
                XmlDocument   document = PersistenceTransactionFactory.CreatePersistenceTransaction().Open(
                    "spOpenPickupNotice", contextParameters);
                StringBuilder sb     = new StringBuilder();
                TextWriter    writer = new StringWriter(sb);
                document.Save(writer);

                punInformation = (PickupNoticeInformation)s.Deserialize(new StringReader(sb.ToString()));
            }
            catch (Exception ex)
            {
                throw new Exception("The database failed to load the requested Pickup Notice ", ex);
            }
            lookupSource = new PickupNoticeLookupSource(punInformation);
        }
Esempio n. 8
0
        public void CreatePhysicalCount(PhysicalCountInfo physicalCount)
        {
            AuditTrailWrapper atw = new AuditTrailWrapper(AuditTrailWrapper.InvCount,
                                                          new object[][] { new object[] { null, physicalCount, AuditTrailWrapper.NewRecord } }, "Inventory Control");
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]));
            try
            {
                SqlTransaction transaction = PersistenceTransactionFactory.CreatePersistenceTransaction().Persist(
                    new Queue <object>(new object[] { physicalCount }), contextParameters);
                transaction.Commit();
                if (!atw.Save())
                {
                    transaction.Rollback();
                    throw new Exception("Failed to save audit trail!");
                }
            }
            catch (Exception ex)
            {
                throw new Exception("Physical Count couldn't be saved to the database", ex);
            }
        }
Esempio n. 9
0
        public void GINIssued(SqlTransaction transaction)
        {
            PickupNoticeInformation.Status = (int)PUNStatusType.Closed;
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]));
            try
            {
                PersistenceTransactionFactory.CreatePersistenceTransaction().Persist(
                    new Queue <object>(new object[] { PickupNoticeInformation }), contextParameters, transaction);
            }
            catch (Exception)
            {
                try
                {
                    transaction.Rollback();
                }
                catch (Exception)
                {
                }
                throw new Exception("The completion of the PUN issuance couldn't be saved to the database");
            }
        }
Esempio n. 10
0
        public static void CachePickupNotices()
        {
            List <Guid> cachedPunIds = new List <Guid>();

            ECXCD.WR wr = new WarehouseApplication.ECXCD.WR();
            List <ECXCD.CPickUpNotice> importedPuns = new List <WarehouseApplication.ECXCD.CPickUpNotice>(wr.GetPun());
            int importedPunsCount = importedPuns.Count;

            if (importedPunsCount == 0)
            {
                return;
            }
            List <PickupNoticeInformation> cachedPuns = new List <PickupNoticeInformation>(
                from ipun in importedPuns
                where ipun.WarehouseId == new Guid(StaticLookupSource.GetLookup("CurrentWarehouse")["Id"])
                select new PickupNoticeInformation()
            {
                ClientId           = ipun.ClientId,
                MemberId           = ipun.MemberId,
                RepId              = ipun.RepId,
                CommodityGradeId   = ipun.CommodityGradeId,
                ProductionYear     = ipun.ProductionYear,
                ExpectedPickupDate = ipun.ExpectedPickupDate,
                ExpirationDate     = ipun.ExpirationDate,
                PickupNoticeId     = ipun.PickupNoticeId,
                WarehouseId        = ipun.WarehouseId,
                Quantity           = ipun.Quantity,
                Weight             = ipun.Weight,
                Status             = 0
            });
            int cachedPunsCount = cachedPuns.Count;
            Dictionary <string, object> contextParameters = new Dictionary <string, object>();

            contextParameters.Add("CurrentUser", new Guid(SystemLookup.LookupSource.GetLookup("CurrentUser")["Id"]));
            cachedPuns.ForEach(
                delegate(PickupNoticeInformation pun)
            {
                pun.PickupNoticeAgents.AddRange(
                    from ipun in importedPuns
                    where ipun.PickupNoticeId == pun.PickupNoticeId
                    from ipuna in ipun.PickupNoticeAgents
                    select new PickupNoticeInformation.PickupNoticeAgentInformation()
                {
                    AgentName      = ipuna.AgentName,
                    AgentTel       = ipuna.AgentTel,
                    Id             = Guid.NewGuid(),
                    NIDNumber      = ipuna.NIDNumber,
                    NIDType        = ipuna.NIDType,
                    PickupNoticeId = ipuna.PickupNoticeId,
                    Status         = ipuna.Status
                });
                pun.WarehouseReceipts.AddRange(
                    from ipun in importedPuns
                    where ipun.PickupNoticeId == pun.PickupNoticeId
                    from iwr in ipun.WarehouseReciepts
                    select new PickupNoticeInformation.WarehouseReceiptInformation()
                {
                    Bags               = iwr.Bags,
                    BagType            = iwr.BagType,
                    GRNID              = iwr.GRNID,
                    GRNNo              = iwr.GRNNo,
                    Id                 = iwr.Id,
                    PickupNoticeId     = iwr.PickupNoticeId,
                    Quantity           = Convert.ToDecimal(iwr.Quantity),
                    ShedId             = iwr.ShedId,
                    WarehouseReceiptId = iwr.WarehouseRecieptId,
                    Weight             = Convert.ToDecimal(iwr.Weight)
                });

                Queue <object[]> queue = new Queue <object[]>();
                queue.Enqueue(new object[] { pun, "spImportPUN" });

                pun.PickupNoticeAgents.ForEach(puna => queue.Enqueue(new object[] { puna, "spImportPUNAgent" }));
                pun.WarehouseReceipts.ForEach(wrct => queue.Enqueue(new object[] { wrct, "spImportWarehouseReceipt" }));

                SqlTransaction transaction = null;
                try
                {
                    transaction = PersistenceTransactionFactory.CreatePersistenceTransaction().Persist(queue, contextParameters);
                    transaction.Commit();
                    cachedPunIds.Add(pun.PickupNoticeId);
                }
                catch (Exception ex)
                {
                    try
                    {
                        if (transaction != null)
                        {
                            transaction.Rollback();
                        }
                    }
                    catch (Exception)
                    {
                    }
                }
            });
            wr.AcknowledgePuns(cachedPunIds.ToArray());
        }