private void SaveSupplementaryUnit(xcuda_Item item, ASYCUDAItem ai) { for (var i = 0; i < item.xcuda_Tarification.xcuda_Supplementary_unit.Count; i++) { var supp = item.xcuda_Tarification.xcuda_Supplementary_unit.ElementAt(i); if (supp.Suppplementary_unit_quantity != null) { var asupp = new ASYCUDAItemTarificationSupplementary_unit(); if (supp.Suppplementary_unit_code != null) { asupp.Suppplementary_unit_code.Text.Add(supp.Suppplementary_unit_code); } if (supp.Suppplementary_unit_name != null) { asupp.Suppplementary_unit_name.Text.Add(supp.Suppplementary_unit_name); } if (supp.Suppplementary_unit_quantity != null) { asupp.Suppplementary_unit_quantity = supp.Suppplementary_unit_quantity.GetValueOrDefault().ToString(); } ai.Tarification.Supplementary_unit.Insert(i, asupp); } } }
private void SaveAttachedDocuments(xcuda_Item item, ASYCUDAItem ai) { var i = 0; foreach (var doc in item.xcuda_Attached_documents) { var adoc = ai.Attached_documents[i]; // new ASYCUDAItemAttached_documents(); if (doc.Attached_document_code != null) { adoc.Attached_document_code.Text.Add(doc.Attached_document_code); } if (doc.Attached_document_date != null) { adoc.Attached_document_date = doc.Attached_document_date; } if (doc.Attached_document_reference != null) { adoc.Attached_document_reference.Text.Add(doc.Attached_document_reference); } if (doc.Attached_document_from_rule != null) { adoc.Attached_document_from_rule.Text.Add(doc.Attached_document_from_rule.ToString()); } if (doc.Attached_document_name != null) { adoc.Attached_document_name.Text.Add(doc.Attached_document_name); } // ai.Attached_documents.Add(adoc); i += 1; } }
public async Task Savexcuda_Item(xcuda_Item i) { if (i == null) { return; } using (var ctx = new xcuda_ItemService()) { await ctx.Updatexcuda_Item(i).ConfigureAwait(false); } }
public static int AddFreeText(int itmcnt, xcuda_Item itm, string entryDataId) { if (BaseDataModel.Instance.CurrentApplicationSettings.GroupEX9 != true) { if (itmcnt < 5) { if (itm.Free_text_1 == null) { itm.Free_text_1 = ""; //"Inv.#" } itm.Free_text_1 = itm.Free_text_1 + "|" + string.Format("{0}", entryDataId); //CleanText(allo.EntryDataDetails.EntryDataId)); } else { if (itm.Free_text_2 == null) { itm.Free_text_2 = ""; //"Inv.#" } itm.Free_text_2 = itm.Free_text_2 + "|" + string.Format("{0}", entryDataId); // CleanText(allo.EntryDataDetails.EntryDataId)); } itmcnt += 1; } if (itm.Free_text_1 != null && itm.Free_text_1.Length > 1) { if (itm.Free_text_1.Length < 31) { itm.Free_text_1 = itm.Free_text_1.Substring(1); } else { itm.Free_text_1 = itm.Free_text_1.Substring(1, 30); } } if (itm.Free_text_2 != null && itm.Free_text_2.Length > 1) { if (itm.Free_text_2.Length < 21) { itm.Free_text_2 = itm.Free_text_2.Substring(1); } else { itm.Free_text_2 = itm.Free_text_2.Substring(1, 20); } } return(itmcnt); }
private async Task SaveXcuda_Item(xcuda_Item xitm) { try { using (var ctx = new xcuda_ItemService()) { await ctx.Updatexcuda_Item(xitm).ConfigureAwait(false); } } catch (Exception) { throw; } }
private void SaveHSCode(xcuda_Item item, ASYCUDAItem ai) { if (item.xcuda_Tarification.xcuda_HScode != null) { if (item.xcuda_Tarification.xcuda_HScode.Commodity_code != null) { ai.Tarification.HScode.Commodity_code = item.xcuda_Tarification.xcuda_HScode.Commodity_code; // item.xcuda_Tarification.xcuda_HScode.Commodity_code; } // ai.Tarification.HScode.Precision_1 = item.xcuda_Tarification.xcuda_HScode.Precision_1; if (item.xcuda_Tarification.xcuda_HScode.Precision_4 != null) { ai.Tarification.HScode.Precision_4.Text.Add(item.xcuda_Tarification.xcuda_HScode.Precision_4); } } }
private void SaveGoodsDescription(xcuda_Item item, ASYCUDAItem ai) { if (item.xcuda_Goods_description != null && item.xcuda_Goods_description.Country_of_origin_code != null) { if (item.xcuda_Goods_description.Commercial_Description != null) { ai.Goods_description.Commercial_Description = item.xcuda_Goods_description.Commercial_Description; } if (item.xcuda_Goods_description.Country_of_origin_code != null) { ai.Goods_description.Country_of_origin_code = item.xcuda_Goods_description.Country_of_origin_code; } if (item.xcuda_Goods_description.Description_of_goods != null) { ai.Goods_description.Description_of_goods.Text.Add(item.xcuda_Goods_description.Description_of_goods); } } }
private static void UpdateSubItem(SubItems s, SubItemData itm, xcuda_Item xitm) { if (s.ItemDescription != itm.ItemDescription) { s.ItemDescription = itm.ItemDescription; } if (s.Item_Id != xitm.Item_Id) { s.Item_Id = xitm.Item_Id; } if (s.QtyAllocated != itm.QtyAllocated) { s.QtyAllocated = itm.QtyAllocated; } if (s.Quantity != itm.Quantity) { s.Quantity = itm.Quantity; } }
private void SaveTarification(xcuda_Item item, ASYCUDAItem ai) { if (item.xcuda_Tarification != null) { if (item.xcuda_Tarification.Extended_customs_procedure != null) { ai.Tarification.Extended_customs_procedure = item.xcuda_Tarification.Extended_customs_procedure; } if (item.xcuda_Tarification.National_customs_procedure != null) { ai.Tarification.National_customs_procedure = item.xcuda_Tarification.National_customs_procedure; } if (item.xcuda_Tarification.Item_price != 0) { ai.Tarification.Item_price = Math.Round(item.xcuda_Tarification.Item_price, 2).ToString(); } SaveHSCode(item, ai); SaveSupplementaryUnit(item, ai); } }
private void SavePreviousDoc(xcuda_Item item, ASYCUDAItem ai) { if (item.xcuda_Previous_doc != null) { if (item.xcuda_Previous_doc.Summary_declaration != null) { ai.Previous_doc.Summary_declaration.Text.Add(item.xcuda_Previous_doc.Summary_declaration); } } else { if (item.xcuda_ASYCUDA.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet.BLNumber != null) { if (item.xcuda_ASYCUDA.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet.BLNumber != null) { ai.Previous_doc.Summary_declaration.Text.Add(item.xcuda_ASYCUDA.xcuda_ASYCUDA_ExtendedProperties.AsycudaDocumentSet.BLNumber); } } } }
private static SubItems GetSubItem(xcuda_Item xitm, SubItemData subItemData) { SubItems s = null; //if (xitm.SubItems.Any()) //{ s = xitm.SubItems.FirstOrDefault(x => x.ItemNumber == subItemData.ItemNumber); // } if (s == null) { s = new SubItems() { ItemNumber = subItemData.ItemNumber, Item_Id = xitm.Item_Id, // xcuda_Item = xitm, TrackingState = TrackingState.Added }; xitm.SubItems.Add(s); } return(s); }
private void SaveValuationItem(xcuda_Item item, ASYCUDAItem ai) { if (item.xcuda_Valuation_item != null && item.Statistical_value != 0) { ai.Valuation_item.Statistical_value = item.Statistical_value.ToString(); if (item.xcuda_Valuation_item.Total_CIF_itm != 0) { ai.Valuation_item.Total_CIF_itm = item.xcuda_Valuation_item.Total_CIF_itm.ToString(); } if (item.xcuda_Valuation_item.Total_cost_itm != 0) { ai.Valuation_item.Total_cost_itm = item.xcuda_Valuation_item.Total_cost_itm.ToString(); } if (item.xcuda_Valuation_item.xcuda_Item_Invoice != null && item.xcuda_Valuation_item.xcuda_Item_Invoice.Amount_foreign_currency != 0) { var ivc = item.xcuda_Valuation_item.xcuda_Item_Invoice; var av = new ASYCUDAItemValuation_itemItem_Invoice(); av.Amount_foreign_currency = Math.Round(ivc.Amount_foreign_currency, 2).ToString();//Convert.ToDecimal(ivc.Amount_foreign_currency); if (ivc.Amount_national_currency != 0) { av.Amount_national_currency = ivc.Amount_national_currency.ToString(); } if (ivc.Currency_code != null) { av.Currency_code = ivc.Currency_code; } if (ivc.Currency_rate != 0) { av.Currency_rate = ivc.Currency_rate.ToString(); } ai.Valuation_item.Item_Invoice = av; } if (item.xcuda_Valuation_item.xcuda_item_external_freight != null && item.xcuda_Valuation_item.xcuda_item_external_freight.Amount_foreign_currency != 0) { var ief = item.xcuda_Valuation_item.xcuda_item_external_freight; var af = new ASYCUDAItemValuation_itemItem_external_freight(); if (ief.Amount_foreign_currency != 0) { af.Amount_foreign_currency = ief.Amount_foreign_currency.ToString(); } if (ief.Amount_national_currency != 0) { af.Amount_national_currency = ief.Amount_national_currency.ToString(); } if (ief.Currency_code != null) { af.Currency_code.Text.Add(ief.Currency_code); } if (ief.Currency_rate != 0) { af.Currency_rate = ief.Currency_rate.ToString(); } ai.Valuation_item.item_external_freight = af; } if (item.xcuda_Valuation_item.xcuda_Weight_itm != null && item.xcuda_Valuation_item.xcuda_Weight_itm.Gross_weight_itm != 0) { var wi = new ASYCUDAItemValuation_itemWeight_itm(); if (item.xcuda_Valuation_item.xcuda_Weight_itm.Gross_weight_itm != 0) { wi.Gross_weight_itm = item.xcuda_Valuation_item.xcuda_Weight_itm.Gross_weight_itm.ToString(); } if (item.xcuda_Valuation_item.xcuda_Weight_itm.Net_weight_itm != 0) { wi.Net_weight_itm = item.xcuda_Valuation_item.xcuda_Weight_itm.Net_weight_itm.ToString(); } ai.Valuation_item.Weight_itm = wi; } } }
private void UpdateEntity(xcuda_Item entity) { using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew, new TransactionOptions() { IsolationLevel = IsolationLevel.ReadUncommitted })) { using (var dbContext = new DocumentItemDSContext()) { try { dbContext.ApplyChanges(entity); dbContext.SaveChanges(); //entity.AcceptChanges(); scope.Complete(); } catch (DbUpdateConcurrencyException dce) { // Get failed entry foreach (var itm in dce.Entries) { itm.OriginalValues.SetValues(itm.GetDatabaseValues()); } } catch (OptimisticConcurrencyException oce) { var context = ((IObjectContextAdapter)dbContext).ObjectContext; foreach (var entry in oce.StateEntries) { context.Refresh(System.Data.Entity.Core.Objects.RefreshMode.StoreWins, entry.Entity); } } catch (DbUpdateException e) { // Debugger.Break(); SqlException s = e.InnerException.InnerException as SqlException; if (s != null && s.Number == 2627) { } else { Debugger.Break(); throw; } } catch (Exception updateEx) { System.Diagnostics.Debugger.Break(); //throw new FaultException(updateEx.Message); var fault = new ValidationFault { Result = false, Message = updateEx.Message, Description = updateEx.StackTrace }; throw new FaultException <ValidationFault>(fault); } } } }