예제 #1
0
        public static void Refresh()
        {
            _rooms = new Dictionary <int, int>();
            Dictionary <string, int> roomsLodgit = new Dictionary <string, int>();

            foreach (RoomType type in RoomType.ReadAll())
            {
                roomsLodgit[type.RoomTypeId] = type.DirsId;
            }

            DataTable table = _query();

            foreach (DataRow row in table.Rows)
            {
                string code = (string)row["code"];

                if (roomsLodgit.ContainsKey(code))
                {
                    int dirsId = roomsLodgit[code];

                    if (!_rooms.ContainsKey(dirsId))
                    {
                        _rooms[dirsId] = 0;
                    }

                    _rooms[dirsId] += 1;
                }
            }
        }
예제 #2
0
        public formConfigRooms()
        {
            InitializeComponent();

            _rooms = RoomType.ReadAll();

            _createList();
        }
예제 #3
0
        private static DataTable _query()
        {
            string        allTypes = "";
            StringBuilder str      = new StringBuilder();

            str.AppendLine("SELECT");
            str.AppendLine("    date(booking.BU_DATUM_VON) as arrival,");
            str.AppendLine("    date(booking.BU_DATUM_BIS) as depature,");
            str.AppendLine("    (CASE");

            foreach (RoomType type in RoomType.ReadAll())
            {
                str.AppendFormat("        WHEN roomtype.ZT_KURZ = '{0}' THEN {1}\n", type.RoomTypeId, type.DirsId);

                allTypes += String.Format(
                    "{1}'{0}'",
                    type.RoomTypeId,
                    (allTypes == "" ? "" : ", ")
                    );
            }

            str.AppendLine("    END) as dirsid");
            str.AppendLine("FROM");
            str.AppendLine("    b_buchungen as booking,");
            str.AppendLine("    o_mieteinheit as room,");
            str.AppendLine("    o_objekt as hotel,");
            str.AppendLine("    o_zimmertyp as roomtype");
            str.AppendLine("WHERE");
            str.AppendLine("room.rowid = booking.BU_ZIMMER AND");
            str.AppendLine("hotel.rowid = room.ME_OBJEKT AND");
            str.AppendLine("roomtype.rowid = room.ME_ZIMMERTYP AND");
            str.AppendFormat("roomtype.ZT_KURZ IN ({0})", allTypes);

            string setting = Settings.GetSetting <string>("dirs21.hotels");

            if (!String.IsNullOrEmpty(setting))
            {
                str.AppendLine("    AND hotel.rowid IN (" + setting + ")");
            }

            return(Program.AddIn.Query(str.ToString()));
        }
예제 #4
0
        public static void RunReset()
        {
            try
            {
                StatusInfo.StatusRunning  = true;
                StatusInfo.StatusGroup    = "Daten zurücksetzen...";
                StatusInfo.StatusLabel    = "Datenbank leeren.";
                StatusInfo.StatusProgress = -1;

                DayAva.SaveAll(
                    new Dictionary <string, DayAva>()
                    );
                OnlineBooking.LastUpdate = DateTime.MinValue;

                DataTable table = Program.AddIn.Query(
                    String.Format(@"
                                SELECT
                                    price.KP_PREIS as price,
                                    price.KP_FROM as date_from,
                                    price.KP_TO as date_to,
                                    roomtype.ZT_KURZ as roomtype_id,
                                    roomtype.ZT_BEZ as roomtype_name
                                FROM
                                    o_zimmertyp as roomtype,
                                    o_katgoriepreis as price
                                WHERE
                                    roomtype.rowid = KP_ZIMMERTYP AND
                                    (CASE
                                        {0}
                                    END)",
                                  String.Join(
                                      "\n",
                                      RoomType.ReadAll().Select(
                                          t => String.Format(
                                              "WHEN roomtype.ZT_KURZ = '{0}' THEN price.KP_PERSON_FROM = {1}",
                                              t.RoomTypeId,
                                              t.DefaultPersons
                                              )
                                          ).ToArray()
                                      )
                                  )
                    );

                int    i      = 0;
                int    c      = table.Rows.Count;
                int    knr    = Settings.GetSetting <int>("dirs21.knr");
                string pwd    = Settings.GetSetting <string>("dirs21.pwd");
                var    dirs21 = new HotelAddInApp.dirs21.DIRS21PMSInterface();

                foreach (DataRow row in table.Rows)
                {
                    StatusInfo.StatusLabel    = row["roomtype_name"].ToString() + " wird zurückgesetzt.";
                    StatusInfo.StatusProgress = (int)((100.0f / c) * i);

                    try
                    {
                        RoomType type  = RoomType.ReadAll().First(t => t.RoomTypeId == (string)row["roomtype_id"]);
                        double   price = ((double)row["price"] + Settings.GetSetting <double>("dirs21.breakfast")) * type.DefaultPersons;

                        dirs21.WriteAvailabilitiesPricesMinstay(
                            knr,
                            pwd,
                            type.DirsIdPrice,
                            ((DateTime)row["date_from"]).ToString("dd.MM.yyyy"),
                            ((DateTime)row["date_to"]).ToString("dd.MM.yyyy"),
                            RoomCount.GetCount(type.DirsId),
                            (float)price,
                            1
                            );
                    }
                    catch (Exception ex)
                    {
                        StatusInfo.WriteLine("Zimmertype konnte nicht zurückgesetzt werden.\n\nFehler: " + ex.Message);
                    }

                    i++;
                }

                dirs21.Dispose();

                StatusInfo.StatusRunning = false;
                StatusInfo.WriteLine("Daten zurückgesetzt");
            }
            finally
            {
                _thread = null;

                RunThreadWriteAsk();
            }
        }