Пример #1
0
        public List <ForecastDateMethod> GetSavedForecastDateCollection(SqlString companyCode, SqlString customerNumber, long rowCount)
        {
            const string RDBConnectionKey = "PWCConnectionString";
            var          pf         = PersistenceFacade.GetInstance();
            var          connection = pf.GetDbConnection(RDBConnectionKey);
            var          command    = connection.CreateCommand();

            command.CommandText = "savedForecastDateCollection_sel";
            command.CommandType = CommandType.StoredProcedure;
            pf.AddCommandParameter(RDBConnectionKey, command, "company_code", companyCode);
            pf.AddCommandParameter(RDBConnectionKey, command, "customer_number", customerNumber);
            pf.AddCommandParameter(RDBConnectionKey, command, "row_count", rowCount);
            var savedForecastDateCollection = new List <ForecastDateMethod>
            {
                new ForecastDateMethod(string.Empty, string.Empty)
            };

            using (var dr = command.ExecuteReader(CommandBehavior.CloseConnection))
            {
                while (dr.Read())
                {
                    savedForecastDateCollection.Add(new ForecastDateMethod(string.Format("{0:MM/dd/yyyy}", dr["POSSalesEndDate"]), dr["ForecastMethod"].ToString()));
                }
            }
            return(savedForecastDateCollection);
        }
        //public void CreateSculpture()
        //{
        //    Sculpture sculpture = new Sculpture();
        //    new PersistenceFacade().SaveSculpture(sculpture);
        //    var sculptures = new PersistenceFacade().GetSculptures();
        //    SculptureViewModel.SculptureCatalogSingleton.Sculptures.Clear();
        //    foreach (var sculpture1 in sculptures)
        //    {
        //        SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture1);
        //    }
        //}
        public void CreateSculpture()
        {
            Sculpture sculpture = new Sculpture();

            sculpture.Sculpture_Id        = SculptureViewModel.NewSculpture.Sculpture_Id;
            sculpture.Sculpture_Name      = SculptureViewModel.NewSculpture.Sculpture_Name;
            sculpture.Sculpture_Adress    = SculptureViewModel.NewSculpture.Sculpture_Adress;
            sculpture.Sculpture_Placement = SculptureViewModel.NewSculpture.Sculpture_Placement;
            sculpture.TypeLoc             = SculptureViewModel.NewSculpture.TypeLoc;
            sculpture.Material            = SculptureViewModel.NewSculpture.Material;
            //sculpture.Damages = SculptureViewModel.NewSculpture.Damages;
            //sculpture.Notes = SculptureViewModel.NewSculpture.Notes;
            //sculpture.Treatments = SculptureViewModel.NewSculpture.Treatments;
            new PersistenceFacade().SaveSculpture(sculpture);

            //  SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture);
            var sculptures = new PersistenceFacade().GetSculptures();

            SculptureViewModel.SculptureCatalogSingleton.Sculptures.Clear();
            foreach (var sculpture1 in sculptures)
            {
                SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture1);
            }
            SculptureViewModel.NewSculpture.Sculpture_Id        = 0;
            SculptureViewModel.NewSculpture.Sculpture_Name      = "";
            SculptureViewModel.NewSculpture.Sculpture_Adress    = "";
            SculptureViewModel.NewSculpture.Sculpture_Placement = "";
            SculptureViewModel.NewSculpture.Material            = "";
            SculptureViewModel.NewSculpture.TypeLoc             = "";
            // SculptureViewModel.NewSculpture.Damages = new Damage[];
            // SculptureViewModel.NewSculpture.Notes = new Note[];
            //  SculptureViewModel.NewSculpture.Treatments = new Treatment[];
        }
        public virtual void Setup()
        {
            Session = MockRepository.GenerateStub<ISession>();
            Container = MockRepository.GenerateStub<IContainer>();

            PersistenceFacade = new PersistenceFacade(Container);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            var exportService = new ExportService(new ExportService.Config
            {
                ReadyDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                              ApplicationRomingFolderName,
                                              "exportReady"),
                WorkingDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
                                                ApplicationRomingFolderName,
                                                "exportPrepare"),
            });

            var persistenceFacade = new PersistenceFacade(persistenceConfig);
            var dbTemplateService = new DBTemplateService(persistenceFacade);

            services.AddRazorPages();
            services.AddServerSideBlazor();
            services.AddMvc().SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0);
            services.AddSingleton <DBTemplateService>(dbTemplateService);
            services.AddSingleton <ExportService>(exportService);
            services.AddSingleton <ExportController>(new ExportController(dbTemplateService, exportService));
            services.AddSingleton <PersistenceFacade>(persistenceFacade);
            services.AddSingleton <DatabaseModelImportService>(new DatabaseModelImportService(new ImporterProxy(), persistenceFacade));
            services.AddLogging();
        }
Пример #5
0
        public void DeleteSculpture()
        {
            //int deletesculptureId = SculptureViewModel.SelectedSculpture.Sculpture_Id;
            //  int deletesculptureId = SculptureViewModel.NewSculpture.Sculpture_Id;
            //new PersistenceFacade().DeleteSculpture(deletesculptureId);
            new PersistenceFacade().DeleteSculpture(SculptureViewModel.SelectedSculpture);
            //Updated the Listview
            // SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture);
            var sculptures = new PersistenceFacade().GetSculptures();

            SculptureViewModel.SculptureCatalogSingleton.Sculptures.Clear();
            foreach (var sculpture1 in sculptures)
            {
                SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture1);
            }
            SculptureViewModel.NewSculpture.Sculpture_Id        = 0;
            SculptureViewModel.NewSculpture.Sculpture_Name      = "";
            SculptureViewModel.NewSculpture.Sculpture_Adress    = "";
            SculptureViewModel.NewSculpture.Sculpture_Placement = "";
            SculptureViewModel.NewSculpture.Material            = "";
            SculptureViewModel.NewSculpture.TypeLoc             = "";
            //     SculptureViewModel.NewSculpture.Damages = new Damage[];
            // SculptureViewModel.NewSculpture.Notes = new Note[];
            //  SculptureViewModel.NewSculpture.Treatments = new Treatment[];
        }
Пример #6
0
        public void AddDamage()
        {
            int    Sculpture_Id = SculptureViewModel.SelectedSculpture.Sculpture_Id;
            int    damageId     = SculptureViewModel.NewDamage.Damage_Id;
            string damageName   = SculptureViewModel.NewDamage.Damage_Name;
            string damageCare   = SculptureViewModel.NewDamage.Damage_Care;

            Damage d = new Damage(); //new instance of sculptures damage

            d.Sculpture_Id = Sculpture_Id;
            d.Damage_Id    = damageId;
            d.Damage_Name  = damageName;
            d.Damage_Care  = damageCare;

            new PersistenceFacade().SaveDamage(d);
            var sculptures = new PersistenceFacade().GetSculptures();

            SculptureViewModel.SculptureCatalogSingleton.Sculptures.Clear();
            foreach (var sculpture1 in sculptures)
            {
                SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture1);
            }
            SculptureViewModel.NewSculpture.Sculpture_Id     = 0;
            SculptureViewModel.NewSculpture.Sculpture_Name   = "";
            SculptureViewModel.NewSculpture.Sculpture_Adress = "";
        }
Пример #7
0
 public DBTemplateService(PersistenceFacade persistenceFacade)
 {
     if (persistenceFacade == null)
     {
         throw new ArgumentNullException(nameof(persistenceFacade));
     }
     this.persistenceFacade = persistenceFacade;
 }
Пример #8
0
        public string GetDefaultSqlServerName()
        {
            var connection = PersistenceFacade.GetInstance().GetDbConnection("PWCConnectionString");

            using (connection)
            {
                return(connection.DataSource);
            }
        }
Пример #9
0
        public async void LoadHotels()
        {
            PersistenceFacade facade = new PersistenceFacade();
            List <Hotel>      hotels = await facade.GetAllHotelsAsync();

            foreach (Hotel hotel in hotels)
            {
                Hotels.Add(hotel);
            }
        }
Пример #10
0
        public async void LoadRatingsAsync()
        {
            ObservableCollection <Rating> ratings = await PersistenceFacade.LoadRatingsFromXmlAsync();

            mainViewModel.Ratings.Clear();
            foreach (var rating in ratings)
            {
                mainViewModel.Ratings.Add(rating);
            }
        }
Пример #11
0
        public void DeleteRoom()
        {
            new PersistenceFacade().DeleteRoom(HotelViewModel.SelectedRoom);
            var rooms = new PersistenceFacade().GetRooms();

            HotelViewModel.HotelCatalogSingleton.Rooms.Clear();
            foreach (var r in rooms)
            {
                HotelViewModel.HotelCatalogSingleton.Rooms.Add(r);
            }
        }
Пример #12
0
 private void dgvProductCategory_DataError(object sender, DataGridViewDataErrorEventArgs e)
 {
     if (e.Exception != null)
     {
         var additionalData = new StringBuilder("Context: ");
         additionalData.Append(e.Context.ToString()).Append("\n");
         additionalData.Append("RowIndex: ").Append(e.RowIndex.ToString()).Append("\n");
         additionalData.Append("ColumnIndex: ").Append(e.ColumnIndex.ToString());
         PersistenceFacade.GetInstance().LogException(e.Exception, Environment.MachineName, additionalData.ToString());
         e.ThrowException = true;
     }
 }
Пример #13
0
 public override void Load()
 {
     if (ParameterCollection != null)
     {
         PersistenceFacade.GetInstance().Get(this, Parent.ObjectKey, ParameterCollection);
     }
     else
     {
         PersistenceFacade.GetInstance().Get(this, Parent.ObjectKey);
     }
     LoadSetVersion();
 }
Пример #14
0
        public void DeleteHotel()
        {
            //HotelViewModel.HotelCatalogSingleton.Remove(HotelViewModel.SelectedHotel);

            new PersistenceFacade().DeleteHotel(HotelViewModel.SelectedHotel);
            var hotels = new PersistenceFacade().GetHotels();

            HotelViewModel.HotelCatalogSingleton.Hotels.Clear();
            foreach (var h in hotels)
            {
                HotelViewModel.HotelCatalogSingleton.Hotels.Add(h);
            }
        }
        public async void LoadPersonsAsync()
        {
            var persons = await PersistenceFacade.LoadPersonsFromJsonAsync();

            personsViewModel.Persons.Clear();
            if (persons != null)
            {
                foreach (var person in persons)
                {
                    personsViewModel.Persons.Add(person);
                }
            }
        }
Пример #16
0
        private void dgvBrand_DataError(object sender, DataGridViewDataErrorEventArgs e)
        {
            if (e.Exception == null)
            {
                return;
            }
            var additionalData = new StringBuilder("Context: ");

            additionalData.Append(e.Context.ToString()).Append("\n");
            additionalData.Append("RowIndex: ").Append(e.RowIndex.ToString(CultureInfo.InvariantCulture)).Append("\n");
            additionalData.Append("ColumnIndex: ").Append(e.ColumnIndex.ToString(CultureInfo.InvariantCulture));
            PersistenceFacade.GetInstance().LogException(e.Exception, Environment.MachineName, additionalData.ToString());
            e.ThrowException = true;
        }
        public DatabaseModelImportService(ImporterProxy importerProxy, PersistenceFacade persistenceFacade)
        {
            if (importerProxy == null)
            {
                throw new ArgumentNullException(nameof(importerProxy));
            }
            if (persistenceFacade == null)
            {
                throw new ArgumentNullException(nameof(persistenceFacade));
            }

            this.importerProxy     = importerProxy;
            this.persistenceFacade = persistenceFacade;
        }
Пример #18
0
        public void OneTimeSetUp()
        {
            PersistenceFacadeConfiguration persistanceFacadeConfiguration =
                new PersistenceFacadeConfiguration()
            {
                DatabaseModelsFolderPath = Path.Combine(AssemblyDirectory, "CSharp", "DatabaseModels"),
                TemplatesFolderPath      = Path.Combine(AssemblyDirectory, "CSharp", "Templates"),
                TypeMappingFolderPath    = Path.Combine(AssemblyDirectory, "CSharp", "TypeMappings"),
                TypeSetFolderPath        = Path.Combine(AssemblyDirectory, "CSharp", "TypeSets")
            };

            persistanceFacade = new PersistenceFacade(persistanceFacadeConfiguration);
            _tested           = new InputModelHandler();
        }
Пример #19
0
        public void HandleException(Form form, Exception ex, EventArgs e)
        {
            string additionalData        = null;
            var    errorPhrase           = "Unexpected error occured.";
            var    isConcurrencyConflict = false;

            if (ex is SqlException)
            {
                isConcurrencyConflict = ex.Message == "Timestamp mismatched";

                additionalData = string.Format("Class: {0}, LineNumber: {1}, Number: {2}, Procedure: {3}, State: {4}", ((SqlException)ex).Class, ((SqlException)ex).LineNumber, ((SqlException)ex).Number, ((SqlException)ex).Procedure, ((SqlException)ex).State);
                errorPhrase    = "SQL operation error occured.";
            }
            if (isConcurrencyConflict)
            {
                MessageBox.Show("Your changes cannot be saved since your original data has been changed by another user.\n\n1. Please review the refreshed data\n2. Apply your changes\n3. Save again.", "PWC Forecast", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                PersistenceFacade.GetInstance().LogException(ex, Environment.MachineName, additionalData);
                MessageBox.Show(
                    string.Format(
                        "{0}\nThe error has been logged into database.\nPlease notify System Administrator.\n\n{1}",
                        errorPhrase, ex.Message), "PWC Forecast", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            form.Cursor = Cursors.Arrow;

            //if (e is DataGridViewCellCancelEventArgs)
            //    ((DataGridViewCellCancelEventArgs)e).Cancel = true;
            //else if (e is DataGridViewRowCancelEventArgs)
            //    ((DataGridViewRowCancelEventArgs)e).Cancel = true;
            //else if (e is DataGridViewCellValidatingEventArgs)
            //    ((DataGridViewCellValidatingEventArgs)e).Cancel = true;

            // all of the types above are derived from CancelEventArgs, so no need to check individually
            if (e is CancelEventArgs)
            {
                ((CancelEventArgs)e).Cancel = true;
            }
            else if (e is DataGridViewCellParsingEventArgs)
            {
                ((DataGridViewCellParsingEventArgs)e).ParsingApplied = false;
            }
            else if (e is DataGridViewCellFormattingEventArgs)
            {
                ((DataGridViewCellFormattingEventArgs)e).FormattingApplied = false;
            }
        }
Пример #20
0
        public bool DoesForecastSalesRateExist(SqlString companyCode, SqlString customerNumber, SqlDateTime posWeekEndDateEnd)
        {
            const string RDBConnectionKey = "PWCConnectionString";
            var          pf         = PersistenceFacade.GetInstance();
            var          connection = pf.GetDbConnection(RDBConnectionKey);

            using (connection)
            {
                var command = connection.CreateCommand();
                command.CommandText = "doesForecastSalesRateExist_sel";
                command.CommandType = CommandType.StoredProcedure;
                pf.AddCommandParameter(RDBConnectionKey, command, "company_code", companyCode);
                pf.AddCommandParameter(RDBConnectionKey, command, "customer_number", customerNumber);
                pf.AddCommandParameter(RDBConnectionKey, command, "pos_sales_end_date", posWeekEndDateEnd);
                return((int)command.ExecuteScalar() == 1);
            }
        }
Пример #21
0
        public async void DeleteHotel()
        {
            int hotelNr = HotelViewModel.NewHotel.HotelNr;
            PersistenceFacade facade = new PersistenceFacade();
            bool ok = await facade.DeleteHotelAsync(hotelNr);

            if (!ok)
            {
                MessageDialogHelper.Show("Der skete en fejl!", "Hotel blev ikke slettet");
            }
            else
            {
                MessageDialogHelper.Show("Alt gik godt!", $"Hotellet {hotelNr} blev slettet");
                HotelViewModel.HotelCatalogSingleton.Hotels.Clear();
                HotelViewModel.HotelCatalogSingleton.LoadHotels();
            }
        }
Пример #22
0
        public async void UpdateHotel()
        {
            int hotelNo = HotelViewModel.NewHotel.Id;
            PersistenceFacade facade = new PersistenceFacade();
            bool ok = await facade.PutHotelAsync(hotelNo, HotelViewModel.NewHotel);

            if (!ok)
            {
                MessageDialogHelper.Show("Der skete en fejl", "Hotel blev ikke opdateret");
            }

            else
            {
                MessageDialogHelper.Show("Alt gik godt", $"Hotellet {hotelNo} blev Updateret");
                HotelViewModel.HotelCatalogSingleton.Hotels.Clear();
                HotelViewModel.HotelCatalogSingleton.LoadHotels();
            }
        }
Пример #23
0
        public void CreateRoom()
        {
            Room room = new Room(HotelViewModel.NewRoom.Room_No, HotelViewModel.NewRoom.Hotel_No,
                                 HotelViewModel.NewRoom.Room_Type, HotelViewModel.NewRoom.Room_Price);

            new PersistenceFacade().SaveRoom(room);

            var rooms = new PersistenceFacade().GetRooms();

            HotelViewModel.HotelCatalogSingleton.Rooms.Clear();
            foreach (var r in rooms)
            {
                HotelViewModel.HotelCatalogSingleton.Rooms.Add(r);
            }

            HotelViewModel.NewRoom.Room_No    = 0;
            HotelViewModel.NewRoom.Hotel_No   = 0;
            HotelViewModel.NewRoom.Room_Type  = "";
            HotelViewModel.NewRoom.Room_Price = "";
        }
Пример #24
0
        public async void UpdateHotel()
        {
            int               hotelNr      = HotelViewModel.NewHotel.HotelNr;
            string            hotelName    = HotelViewModel.NewHotel.Name;
            string            hotelAddress = HotelViewModel.NewHotel.Address;
            Hotel             aHotel       = new Hotel(hotelNr, hotelName, hotelAddress);
            PersistenceFacade facade       = new PersistenceFacade();
            bool              ok           = await facade.PutHotelAsync(hotelNr, aHotel);

            if (!ok)
            {
                MessageDialogHelper.Show("Der skete en fejl!", "Hotel blev ikke updateret");
            }
            else
            {
                MessageDialogHelper.Show("Alt gik godt!", $"Hotellet {hotelNr} blev updateret");
                HotelViewModel.HotelCatalogSingleton.Hotels.Clear();
                HotelViewModel.HotelCatalogSingleton.LoadHotels();
            }
        }
Пример #25
0
        public async void CreateHotel()
        {
            int               hotelNo     = HotelViewModel.NewHotel.Id;
            string            hotelName   = HotelViewModel.NewHotel.Name;
            string            hotelAdress = HotelViewModel.NewHotel.Address;
            Hotel             aHotel      = new Hotel(hotelNo, hotelName, hotelAdress);
            PersistenceFacade facade      = new PersistenceFacade();
            bool              ok          = await facade.PostHotelAsync(aHotel);

            if (!ok)
            {
                MessageDialogHelper.Show("Der skete en fejl", "Hotel blev ikke oprettet");
            }

            else
            {
                MessageDialogHelper.Show("Alt gik godt", $"Hotellet {aHotel.Name} blev oprettet");
                HotelViewModel.HotelCatalogSingleton.Hotels.Clear();
                HotelViewModel.HotelCatalogSingleton.LoadHotels();
            }
        }
Пример #26
0
        public void CreateHotel()
        {
            Hotel hotel = new Hotel(HotelViewModel.NewHotel.Hotel_No,
                                    HotelViewModel.NewHotel.Hotel_Name,
                                    HotelViewModel.NewHotel.Hotel_Address);

            new PersistenceFacade().SaveHotel(hotel);

            //HotelViewModel.Hotels.Hotels.Add(hotel);
            var hotels = new PersistenceFacade().GetHotels();

            HotelViewModel.HotelCatalogSingleton.Hotels.Clear();
            foreach (var h in hotels)
            {
                HotelViewModel.HotelCatalogSingleton.Hotels.Add(h);
            }

            HotelViewModel.NewHotel.Hotel_No      = 0;
            HotelViewModel.NewHotel.Hotel_Name    = "";
            HotelViewModel.NewHotel.Hotel_Address = "";
        }
Пример #27
0
        public void UpdateSculpture()
        {
            Sculpture sculptureToUpdate = new Sculpture()
            {
                Sculpture_Id        = SculptureViewModel.NewSculpture.Sculpture_Id,
                Sculpture_Name      = SculptureViewModel.NewSculpture.Sculpture_Name,
                Sculpture_Adress    = SculptureViewModel.NewSculpture.Sculpture_Adress,
                Sculpture_Placement = SculptureViewModel.NewSculpture.Sculpture_Placement,
                Material            = SculptureViewModel.NewSculpture.Material,
                TypeLoc             = SculptureViewModel.NewSculpture.TypeLoc
            };

            new PersistenceFacade().UpdateSculpture(sculptureToUpdate);
            //Updated the ListView
            // SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture);
            var sculptures = new PersistenceFacade().GetSculptures();

            SculptureViewModel.SculptureCatalogSingleton.Sculptures.Clear();
            foreach (var sculpture1 in sculptures)
            {
                SculptureViewModel.SculptureCatalogSingleton.Sculptures.Add(sculpture1);
            }
            SculptureViewModel.NewSculpture = new Sculpture();
        }
Пример #28
0
 public override void Commit(APersistenceObject persistenceObject)
 {
     PersistenceFacade.GetInstance().Insert(persistenceObject);
     persistenceObject.PreviousState = this;
     persistenceObject.State         = OldCleanState.GetInstance();
 }
Пример #29
0
        public void Commit()
        {
            if (_transactionObjectCollection.Count == 0)
            {
                return;
            }

            if (IsDistributedTransaction)
            {
                using (var ts = new TransactionScope(TransactionScopeOption.Required))
                {
                    try
                    {
                        _transactionObjectCollection.Sort(new ComparerExecutionSequence());
                        foreach (var obj in _transactionObjectCollection)
                        {
                            obj.IsDelayedCommit = false;
                            obj.Commit();
                        }
                        ts.Complete();
                        _isCommitted = true;
                    }
                    catch (Exception)
                    {
                        foreach (var obj in _transactionObjectCollection)
                        {
                            obj.IsDelayedCommit = false;
                            obj.Refresh();
                        }
                        throw;
                    }
                    finally
                    {
                        ClearEnlistedObjects();
                    }
                }
            }
            else
            {
                try
                {
                    var pf = PersistenceFacade.GetInstance();
                    _localDbTransaction = pf.BeginLocalDbTransaction(_localRdbConnectionKey);
                    _transactionObjectCollection.Sort(new ComparerExecutionSequence());
                    foreach (var obj in _transactionObjectCollection)
                    {
                        obj.IsDelayedCommit = false;
                        obj.Commit();
                    }
                    pf.CommitLocalDbTransacstion(_localRdbConnectionKey);
                    _isCommitted = true;
                }
                catch (Exception)
                {
                    if (_localDbTransaction != null)
                    {
                        _localDbTransaction.Rollback();
                    }
                    foreach (var obj in _transactionObjectCollection)
                    {
                        obj.Refresh();
                    }
                    throw;
                }
                finally
                {
                    ClearEnlistedObjects();
                }
            }
        }
Пример #30
0
 public async void SaveRatingsAsync()
 {
     PersistenceFacade.SaveRatingsAsXmlAsync(mainViewModel.Ratings);
 }
Пример #31
0
 public override void Commit(APersistenceObject persistenceObject)
 {
     PersistenceFacade.GetInstance().Delete(persistenceObject);
     persistenceObject.PreviousState = this;
     persistenceObject.State         = DeletedState.GetInstance();
 }