예제 #1
0
        private static Boolean ProcessBatches(delivery deliveryDocument, List<batch> batches)
        {
            DALPortalDataContext dc = new DALPortalDataContext();
            Boolean returnValue = true;

            // Remove all batches attached to this document
            BatchClass.RemoveBatchesDocument(deliveryDocument.docId, deliveryDocument.docType, dc);

            foreach (batch batchLine in batches)
            {
                try
                {
                    batch batch = BatchClass.GetBatch(batchLine.batchNumber, batchLine.heatNumber, batchLine.itemId, deliveryDocument.companyCode, dc);

                    Boolean newBatch = false;
                    if (batch == null)
                    {
                        batch = new batch();
                        newBatch = true;
                    }

                    if (newBatch)
                    {
                        batch.batchNumber = batchLine.batchNumber;
                        batch.companyCode = deliveryDocument.companyCode;
                    }

                    batch.itemId = batchLine.itemId;
                    batch.certificateIndexNumber = batchLine.certificateIndexNumber;
                    batch.heatNumber = batchLine.heatNumber;
                    batch.ixosArchiveId = batchLine.ixosArchiveId;

                    if (newBatch)
                    {
                        // Check if certificate is already on the server
                        String fileName = "CERT_" + batchLine.ixosArchiveId + ".pdf";
                        String filePath = Path.Combine(Parameters_DataProcessor.CompanyFilesRoot, "Certificates", fileName);
                        String dbPath = Path.Combine(@"~\Files\Certificates", fileName);

                        if (File.Exists(filePath))
                            batch.certificateLink = dbPath;
                    }

                    foreach (batchDocument batchDocLine in batchLine.batchDocuments)
                    {
                        // Check if Batch relates to document
                        batchDocument batchDoc = batch.batchDocuments.Where(c => c.baseDocId.Equals(deliveryDocument.docId) && c.baseLineNum.Equals(batchDocLine.baseLineNum) && c.baseDocType.Equals("DL")).FirstOrDefault();
                        Boolean newBatchDoc = false;
                        if (batchDoc == null)
                        {
                            newBatchDoc = true;
                            batchDoc = new batchDocument();
                            batchDoc.baseDocId = deliveryDocument.docId;
                            batchDoc.baseLineNum = batchDocLine.baseLineNum;
                            batchDoc.baseDocType = "DL";
                        }

                        batchDoc.quantity = batchDocLine.quantity;

                        if (newBatchDoc)
                            batch.batchDocuments.Add(batchDoc);
                    }

                    if (newBatch)
                        dc.batches.InsertOnSubmit(batch);

                    dc.SubmitChanges();
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(String.Format("Error Processing Batches for Delivery {0} for company {1}. Error: {2}", deliveryDocument.documentNumber, deliveryDocument.companyCode, ex.Message), "ProcessBatches");
                    returnValue = false;
                }
            }

            return returnValue;
        }
예제 #2
0
		private void detach_batchDocuments(batchDocument entity)
		{
			this.SendPropertyChanging();
			entity.document = null;
		}
예제 #3
0
		private void attach_batchDocuments(batchDocument entity)
		{
			this.SendPropertyChanging();
			entity.document = this;
		}
예제 #4
0
 partial void DeletebatchDocument(batchDocument instance);
예제 #5
0
 partial void UpdatebatchDocument(batchDocument instance);
예제 #6
0
 partial void InsertbatchDocument(batchDocument instance);