Exemplo n.º 1
0
        public static void InsertImportPriceList(ImportPriceList newValue)
        {
            CanonDataContext db = Cdb.Instance;

            db.ImportPriceLists.InsertOnSubmit(newValue);
            db.SubmitChanges();
        }
Exemplo n.º 2
0
        public bool ExportToDb()
        {
            ErrorMessages.Clear();
            try
            {
                bool     IsSucceeded = false;
                List <T> list        = this.ImportFile(ref IsSucceeded);
                if (IsSucceeded == false)
                {
                    return(false);
                }

                CanonDataContext db = Cdb.Instance;

                // Create ImportPriceList
                ImportPriceList priceList = new ImportPriceList();
                priceList.IDUser       = WebVariables.LoggedUserId;
                priceList.FileName     = _OriginalFilename;
                priceList.DateImported = DateTime.Now;
                priceList.ErrorMessage = string.Empty;
                priceList.Succeeded    = true;

                CanonImportPriceList.InsertImportPriceList(priceList);

                // import products
                foreach (T productPrice in list)
                {
                    try
                    {
                        productPrice.ImportPriceList = priceList;
                        productPrice.InsertImportPriceListRecord(db);
                    }
                    catch (Exception ex)
                    {
                        //add message about error
                        ErrorMessages.Add(new ImportErrorMessage("GeneralRecordImportError",
                                                                 new string[] { "Produkt", productPrice.ProductName }));
                        //into log
                        WebVariables.Logger.Error(string.Format("File {0}, general import error", _filename), ex);
                    }
                }
            }
            catch (Exception ex)
            {
                ErrorMessages.Add(new ImportErrorMessage("GeneralFileImportError"));
                //into log
                WebVariables.Logger.Error(string.Format("File {0} ", _filename), ex);
                return(false);
            }

            return(true);
        }
Exemplo n.º 3
0
 public static void InsertImportPriceList(ImportPriceList newValue)
 {
     CanonDataContext db = Cdb.Instance;
     db.ImportPriceLists.InsertOnSubmit(newValue);
     db.SubmitChanges();
 }