Beispiel #1
0
 private static async Task SaveXcuda_Item(xcuda_Item cAsycudaItm)
 {
     using (var ctx = new xcuda_ItemService())
     {
         await ctx.Updatexcuda_Item(cAsycudaItm).ConfigureAwait(false);
     }
 }
Beispiel #2
0
 //Search Entities
 public async Task <IEnumerable <xcuda_Item> > Searchxcuda_Item(List <string> lst, List <string> includeLst = null)
 {
     using (var ctx = new xcuda_ItemService())
     {
         return(await ctx.Getxcuda_ItemByExpressionLst(lst, includeLst).ConfigureAwait(false));
     }
 }
Beispiel #3
0
 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 async Task ReorderDocumentItems(int ASYCUDA_Id)
        {
            List <xcuda_Item> rlst;

            using (var ctx = new xcuda_ItemService())
            {
                rlst =
                    (await ctx.Getxcuda_ItemByExpression(string.Format("ASYCUDA_Id == {0}", ASYCUDA_Id),
                                                         new List <string>()
                {
                    "xcuda_PreviousItem"
                })
                     .ConfigureAwait(false))
                    .OrderBy(x => x.LineNumber)
                    .ToList();
            }

            //if (!rlst.Where(x => x.xcuda_PreviousItem != null).Select(x => x.xcuda_PreviousItem).Any()) return;

            for (int i = 0; i < rlst.Count(); i++)
            {
                rlst.ElementAt(i).LineNumber = i + 1;
                if (rlst.ElementAt(i).xcuda_PreviousItem != null)
                {
                    rlst.ElementAt(i).xcuda_PreviousItem.StartTracking();
                    rlst.ElementAt(i).xcuda_PreviousItem.Current_item_number = (i + 1).ToString();
                }
            }

            using (var ctx = new xcuda_PreviousItemService())
            {
                foreach (var p in rlst.Select(x => x.xcuda_PreviousItem))
                {
                    if (p == null)
                    {
                        continue;
                    }
                    p.xcuda_Item = null;
                    await ctx.Updatexcuda_PreviousItem(p).ConfigureAwait(false);
                }
            }

            using (var ctx = new DocumentItemDSContext())
            {
                foreach (var i in rlst)
                {
                    ctx.Database.ExecuteSqlCommand("update xcuda_Item" +
                                                   $" set linenumber = {i.LineNumber}" +
                                                   $" where Item_Id = {i.Item_Id}");
                }
            }
        }
Beispiel #5
0
 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;
     }
 }
        public void multiple_where()
        {
            var s   = new xcuda_ItemService();
            var exp = new List <string>()
            {
                string.Format("EX.Precision_4.ToUpper() == \"{0}\"", "test")
            };

            var lst = s.Getxcuda_ItemByExpressionLst(exp, new List <string>()
            {
                "EX"
            });

            Assert.AreEqual(1, lst.Result.Count());
        }
        public async Task SaveDocumentCT(AsycudaDocument entity)
        {
            var ct = new DocumentCT();

            ct.Document = await WaterNut.DataSpace.BaseDataModel.Instance.GetDocument(entity.ASYCUDA_Id, new List <string>()
            {
                "xcuda_ASYCUDA_ExtendedProperties",
                "xcuda_Identification",
                "xcuda_Valuation.xcuda_Gs_Invoice",
                "xcuda_Declarant",
                "xcuda_General_information.xcuda_Country",
                "xcuda_Property"
            }).ConfigureAwait(false);

            using (var ctx = new xcuda_ItemService())
            {
                var res = (await ctx.Getxcuda_ItemByASYCUDA_Id(entity.ASYCUDA_Id.ToString(), new List <string>()
                {
                    "xcuda_Previous_doc"
                }).ConfigureAwait(false));
                if (res != null)
                {
                    ct.DocumentItems = res.ToList();
                }
            }
            // bl
            foreach (var itm in ct.DocumentItems.Where(x => x.xcuda_Previous_doc.Summary_declaration != entity.BLNumber))
            {
                itm.xcuda_Previous_doc.StartTracking();
                itm.xcuda_Previous_doc.Summary_declaration = entity.BLNumber;
            }
            ct.Document.xcuda_Identification.StartTracking();
            ct.Document.xcuda_Identification.Manifest_reference_number = entity.Manifest_reference_number;
            ct.Document.xcuda_Valuation.xcuda_Gs_Invoice.StartTracking();
            ct.Document.xcuda_Valuation.xcuda_Gs_Invoice.Currency_code = entity.Currency_code;
            ct.Document.xcuda_Valuation.xcuda_Gs_Invoice.Currency_rate = entity.Currency_rate.GetValueOrDefault();
            ct.Document.xcuda_ASYCUDA_ExtendedProperties.StartTracking();
            ct.Document.xcuda_ASYCUDA_ExtendedProperties.Description         = entity.Description;
            ct.Document.xcuda_ASYCUDA_ExtendedProperties.Document_TypeId     = entity.Document_TypeId;
            ct.Document.xcuda_ASYCUDA_ExtendedProperties.Customs_ProcedureId = entity.Customs_ProcedureId;
            ct.Document.xcuda_Declarant.StartTracking();
            ct.Document.xcuda_Declarant.Number = string.Format("{0}-F{1}", entity.ReferenceNumber, ct.Document.xcuda_ASYCUDA_ExtendedProperties.FileNumber);
            ct.Document.xcuda_General_information.xcuda_Country.StartTracking();
            ct.Document.xcuda_General_information.xcuda_Country.Country_first_destination =
                entity.Country_first_destination;

            await WaterNut.DataSpace.BaseDataModel.Instance.SaveDocumentCT(ct).ConfigureAwait(false);
        }
Beispiel #8
0
        private static List <xcuda_Item> GetAsycudaEntries(string attrib, string salesDescrip)
        {
            var alst = new List <xcuda_Item>();


            // alst.AddRange(db.xcuda_Item.Where(x => x.PreviousDocumentItem.SubItems.Any(y => y.ItemNumber == salesDetails.InventoryItems.ItemNumber)));
            //match by attribute
            //alst = db.xcuda_Item.AsEnumerable().Where(x => salesDetails.ItemDescription.ToUpper().Split('|')[2] == x.ItemNumber.ToUpper()).ToList();
            using (var ctx = new xcuda_ItemService())
            {
                if (attrib != null)
                {
                    alst =
                        (ctx.Getxcuda_ItemByExpressionLst(
                             new List <string>()
                    {
                        "DoNotAllocate == null || DoNotAllocate != true",
                        "AsycudaDocument.DocumentType == \"IM7\"",
                        "SubItems.Count == 0",
                        "AttributeOnlyAllocation == true",
                        string.Format("EX.Precision_4.ToUpper() == \"{0}\"", attrib)
                    },
                             new List <string>()
                    {
                        "SubItems", "AsycudaDocument", "EX"
                    }).Result)
                        .ToList();
                    //.Where(x => x.SubItems.Any() == false && (x.AttributeOnlyAllocation == true) && string.IsNullOrEmpty(salesDetails.ItemDescription.ToUpper().Split('|')[2]) == false && salesDetails.ItemDescription.ToUpper().Split('|')[2].ToUpper().Replace(" ", "") == x.ItemNumber.ToUpper().Replace(" ", "")).ToList();
                }
                alst.AddRange((ctx.Getxcuda_ItemByExpressionLst(new List <string>()
                {
                    "DoNotAllocate == null || DoNotAllocate != true",
                    "AsycudaDocument.DocumentType == \"IM7\"",
                    "SubItems.Count == 0",
                    "AttributeOnlyAllocation == null || AttributeOnlyAllocation != true",
                    string.Format("\"{0}\".Contains(EX.Precision_4.ToUpper())", salesDescrip)
                },
                                                                new List <string>()
                {
                    "SubItems", "AsycudaDocument", "EX"
                })).Result);
                //.Where(x => x.SubItems.Any() == false
                //            && (x.AttributeOnlyAllocation == null || x.AttributeOnlyAllocation != true)
                //            && salesDetails.ItemDescription.ToUpper().Replace(" ", "").Contains(x.ItemNumber.ToUpper().Replace(" ", ""))));
            }
            return(alst);
        }
Beispiel #9
0
        private static async Task <IEnumerable <ItemEntries> > GetAsycudaEntries()
        {
            StatusModel.Timer("Getting Data - Asycuda Entries...");
            //string itmnumber = "MMM/08657";
            IEnumerable <ItemEntries> asycudaEntries = null;

            using (var ctx = new xcuda_ItemService())
            {
                var lst = await ctx.Getxcuda_ItemByExpressionNav(
                    "All",
                    //"EX.Precision_4 == \"PE10833\"",
                    new Dictionary <string, string>() { { "AsycudaDocument", "CNumber != null && DocumentType == \"IM7\"" } }
                    , new List <string>() { "AsycudaDocument", "EX" }).ConfigureAwait(false);


                asycudaEntries = from s in lst
                                 //.Where(x => x.ItemNumber == itmnumber)
                                 //       .Where(x => x.AsycudaDocument.CNumber != null).AsEnumerable()
                                 group s by s.ItemNumber
                                 into g
                                 select
                                 new ItemEntries
                {
                    ItemNumber  = g.Key,
                    EntriesList =
                        g.AsEnumerable()
                        .OrderBy(
                            x =>
                            x.AsycudaDocument.EffectiveRegistrationDate == null
                                                ? Convert.ToDateTime(x.AsycudaDocument.RegistrationDate)
                                                : x.AsycudaDocument.EffectiveRegistrationDate)
                        .ToList()
                };
            }
            return(asycudaEntries);
        }
Beispiel #10
0
        private async Task <List <xcuda_Item> > GetAllAsycudaEntries()
        {
            var alst = new List <xcuda_Item>();

            using (var ctx = new xcuda_ItemService())
            {
                alst.AddRange(ctx.Getxcuda_ItemByExpressionLst(
                                  new List <string>()
                {
                    "DoNotAllocate == null || DoNotAllocate != true",
                    "AsycudaDocument.DocumentType == \"IM7\"",
                    //"SubItems.Count > 0",
                    // "AttributeOnlyAllocation == true"
                    //string.Format("EX.Precision_4.ToUpper() == \"{0}\"", attrib)
                },
                                  new List <string>()
                {
                    "SubItems", "AsycudaDocument", "EX"
                }).Result.Distinct());
            }

            //using (var ctx = new SubItemsService())
            //{
            //    alst.AddRange(
            //        ctx.GetSubItemsByExpressionLst(
            //            new List<string>()
            //            {
            //                "All"
            //                //string.Format("ItemNumber == \"{0}\"", salesDetails.ItemNumber)
            //            }
            //            , new List<string>() { "xcuda_Item", "xcuda_Item.EX", "xcuda_Item.AsycudaDocument" }).Result
            //        //.Where(y => y.ItemNumber == salesDetails.ItemNumber)
            //            .Select(x => x.xcuda_Item).ToList());
            //}
            return(alst);
        }
Beispiel #11
0
        private async Task <xcuda_Item> GetXcudaItems(dynamic itm)
        {
            try
            {
                using (var itmctx = new AsycudaDocumentItemService())
                {
                    var xitm =
                        await itmctx.GetAsycudaDocumentItemsByExpressionLst(new List <string>()
                    {
                        string.Format("ItemNumber == \"{0}\"", itm.Precision_4),
                        string.Format("AsycudaDocument.CNumber == \"{0}\"", itm.CNumber),
                        string.Format("AsycudaDocument.RegistrationDate == \"{0}\"",
                                      itm.RegistrationDate.ToShortDateString())
                    },
                                                                            new List <string>()
                    {
                        "SubItems"
                    }
                                                                            ).ConfigureAwait(false);

                    if (xitm.FirstOrDefault() != null)
                    {
                        using (var dctx = new xcuda_ItemService())
                        {
                            return
                                (await dctx.Getxcuda_ItemByKey(xitm.FirstOrDefault().Item_Id.ToString(), new List <string>() { "SubItems" }).ConfigureAwait(false));
                        }
                    }
                    return(null);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
        internal async Task MapInventoryToAsycuda()
        {
            try
            {
                var ilst = new List <InventoryItem>();
                using (var ctx = new InventoryItemService()
                {
                    StartTracking = true
                })
                {
                    ilst.AddRange(await ctx.GetInventoryItems(new List <string>()
                    {
                        "InventoryAsycudaMappings"
                    }).ConfigureAwait(false));
                }

                var alst = new List <xcuda_Item>();
                using (var ctx = new xcuda_ItemService())
                {
                    alst.AddRange(ctx.Getxcuda_ItemByExpressionLst(
                                      new List <string>()
                    {
                        "AsycudaDocument.DocumentType == \"IM7\" && AsycudaDocument.CNumber != null"
                    },
                                      new List <string>()
                    {
                        "SubItems",
                        "AsycudaDocument",
                        "xcuda_Tarification.xcuda_HScode",
                        "xcuda_Tarification.xcuda_Supplementary_unit"
                    }).Result.Distinct());         //, "EX"
                }

                if (BaseDataModel.Instance.CurrentApplicationSettings.ItemDescriptionContainsAsycudaAttribute == true)
                {
                    // get inventory
                    foreach (var itm in ilst)
                    {
                        var invDescrip = itm.Description;

                        string attrib = invDescrip.Split('|').Length > 2
                                ? invDescrip.Split('|')[2].ToUpper().Replace(" ", "")
                                : null;
                        var res = AllocationsBaseModel.Instance.GetAsycudaEntriesWithItemNumber(alst, attrib, invDescrip,
                                                                                                new List <string>()
                        {
                            itm.ItemNumber
                        }).ToList();
                        foreach (var ae in res)
                        {
                            if (!itm.InventoryAsycudaMappings.Any(x => x.Item_Id == ae.Item_Id))
                            {
                                itm.InventoryAsycudaMappings.Add(new InventoryAsycudaMapping(true)
                                {
                                    ItemNumber    = itm.ItemNumber,
                                    Item_Id       = ae.Item_Id,
                                    TrackingState = TrackingState.Added
                                });
                            }
                        }
                    }


                    ilst.AsParallel(new ParallelLinqOptions()
                    {
                        MaxDegreeOfParallelism = Environment.ProcessorCount
                    }).ForAll(x =>
                    {
                        using (var ctx = new InventoryDSContext())
                        {
                            ctx.ApplyChanges(x);
                            ctx.SaveChanges();
                        }
                    });

                    //await MapWhereItemDescriptionContainsAsycudaAttribute().ConfigureAwait(false);
                }
                else
                {
                    //await MapByMatchingSalestoAsycudaEntriesOnItemNumber().ConfigureAwait(false);
                }
            }
            catch (Exception)
            {
                throw;
            }
        }