Exemple #1
0
        private static void _runThread()
        {
            try
            {
                while (!_stop)
                {
                    string line = "";

                    try
                    {
                        line = _port.ReadLine();

                        _workLine(line);
                    }
                    catch (TimeoutException)
                    {
                        _thread.Join(500);
                    }
                    catch (Exception ex)
                    {
                        StatusInfo.WriteLine("Telefonüberwachnung: Fehler: {0} - Zeile: {1}", ex.Message, line);
                    }
                }
            }
            finally
            {
                _thread = null;
                _port.Close();

                StatusInfo.SetCallWatcher();
            }
        }
Exemple #2
0
        public static void RunRead()
        {
            try
            {
                var knr  = Settings.GetSetting <int>("dirs21.knr");
                var pwd  = Settings.GetSetting <string>("dirs21.pwd");
                var flag = Settings.GetSetting <bool>("dirs21.flag");

                StatusInfo.StatusRunning  = true;
                StatusInfo.StatusGroup    = "Daten werden abgerufen...";
                StatusInfo.StatusLabel    = "Bitte warten...";
                StatusInfo.StatusProgress = -1;

                var stream = _prepairFile();
                var dirs21 = new dirs21.DIRS21PMSInterface();
                var table  = dirs21.ReadBookingsPMSValue(knr, pwd, 0).Tables[0];

                foreach (DataRow row in table.Rows)
                {
                    int id = (int)row[0];

                    stream.WriteLine(
                        String.Join(";", _createRow(row))
                        );

                    Booking.SaveOne(
                        new Booking(
                            row,
                            dirs21.ReadBookingdetails(knr, pwd, id).Tables[0],
                            dirs21.ReadBookingAddOns(knr, pwd, id).Tables[0]
                            )
                        );

                    if (flag)
                    {
                        dirs21.WriteBookingFlag(knr, pwd, (int)row[0], 1);
                    }
                }

                stream.Close();

                StatusInfo.StatusRunning = false;

                if (table.Rows.Count > 0)
                {
                    StatusInfo.WriteLine(table.Rows.Count + " Buchungen eingelsen.");
                    StatusInfo.StatusBalloon = table.Rows.Count.ToString();
                }

                table.Dispose();
                dirs21.Dispose();
            }
            finally
            {
                _thread = null;
            }
        }
Exemple #3
0
        private static void _workLine(string line)
        {
            Call call = _createObject(line);

            var calls = Call.ReadAll();

            calls.Add(call);

            Call.SaveAll(calls);

            GastwareInterface.BookCall(call);

            Program.Form.Invoke(
                new Action(Program.Form.RefreshCallList)
                );
            StatusInfo.WriteLine("Telefonat: {0} -> {1}", call.ExtensionLine, call.CallNumber);
        }
Exemple #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();
            }
        }
Exemple #5
0
        public static void RunWrite()
        {
            try
            {
                StatusInfo.StatusRunning = true;

                DateTime lastUpdate = DateTime.Parse((string)Program.AddIn.Query("SELECT MAX(updated_on) FROM b_buchungen").Rows[0][0]);

                if (lastUpdate == _lastUpdate)
                {
                    _thread = null;
                    StatusInfo.StatusRunning = false;
                    StatusInfo.WriteLine("Verfügbarkeiten senden: Keine veränderten Buchungen");

                    return;
                }
                _lastUpdate = lastUpdate;

                Dictionary <string, DayAva> avaNew    = DayAva.ReadAllDefault();
                Dictionary <string, DayAva> avaOnline = DayAva.ReadAll();

                DataTable table = _query();

                StatusInfo.StatusGroup = "Errechnen der neuen Verfügbarkeiten...";

                int c = 0, p = 0, a = table.Rows.Count;
                foreach (DataRow row in table.Rows)
                {
                    int      dirsId   = Int16.Parse(row["dirsid"].ToString());
                    DateTime arrival  = DateTime.Parse(row["arrival"].ToString());
                    DateTime depature = DateTime.Parse(row["depature"].ToString());

                    for (DateTime date = arrival; date < depature; date = date.AddDays(1))
                    {
                        string id = DayAva.GetID(date, dirsId);

                        if (!avaNew.ContainsKey(id))
                        {
                            var day = new DayAva(dirsId, date, RoomCount.GetCount(dirsId));

                            avaNew.Add(
                                day.Id,
                                day
                                );
                        }

                        avaNew[id].Value -= 1;
                    }

                    p = (int)((100.0f / a) * c);

                    StatusInfo.StatusLabel    = String.Format("Buchung: {0} von {1}", c, a);
                    StatusInfo.StatusProgress = p;

                    c++;
                }

                StatusInfo.StatusGroup = "Differenzen senden...";

                var dirs21 = new dirs21.DIRS21PMSInterface();
                var knr    = Settings.GetSetting <int>("dirs21.knr");
                var pwd    = Settings.GetSetting <string>("dirs21.pwd");

                int send = 0;
                c = 0;
                a = avaNew.Count;
                foreach (var id in avaNew.Keys.ToArray())
                {
                    if (!avaOnline.ContainsKey(id) || avaNew[id].Value != avaOnline[id].Value)
                    {
                        var ava = avaNew[id];

                        try
                        {
                            dirs21.WriteAvailabilities(
                                knr,
                                pwd,
                                ava.DirsID,
                                ava.Date.ToString("dd.MM.yyyy"),
                                ava.Date.ToString("dd.MM.yyyy"),
                                ava.Value
                                );

                            send++;
                        }
                        catch
                        {
                            MessageBox.Show(
                                String.Format(
                                    "Datensatz konnte nicht an Dirs21 gesendet werden. Bitte tragen Sie die Werte manuell ein.\n\nDirsID: {0}\nDatum: {1}\nWert: {2}",
                                    ava.DirsID,
                                    ava.Date.ToString("dd.MM.yyyy"),
                                    ava.Value
                                    ),
                                "Fehler",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error
                                );
                        }
                    }

                    p = (int)((100.0f / a) * c);

                    StatusInfo.StatusLabel    = String.Format("Datensatz: {0} von {1}", c, a);
                    StatusInfo.StatusProgress = p;

                    c++;
                }
                dirs21.Dispose();

                StatusInfo.StatusGroup    = "Speichern der Daten...";
                StatusInfo.StatusLabel    = "Bitte Warten";
                StatusInfo.StatusProgress = -1;

                DayAva.SaveAll(avaNew);

                StatusInfo.StatusRunning = false;
                StatusInfo.WriteLine("Verfügbarkeiten senden: " + send + " Veränderungen gesendet.");
            }
            finally
            {
                _thread = null;
            }
        }