private void LoadTermine(IProgress <ProgressMessage> progress = null)
 {
     RaidOrgaPlusTermine = new List <RaidSimple>();
     if (!Settings.RaidOrgaPlusAccoutSet)
     {
         RaidOrgaPlusTermine.Add(RaidSimple.GetNoAccount());
         Logger.Message("[LogUploaderLogic.LoadTermine] No RO+ Account");
         progress?.Report(new ProgressMessage(1, "No Account"));
         return;
     }
     progress?.Report(new ProgressMessage(0, "Login"));
     RaidOrgaPlusConnector = new Helper.RaidOrgaPlus.RaidOrgaPlusConnector(Settings);
     RaidOrgaPlusSession   = RaidOrgaPlusConnector.Connect(Settings);
     if (RaidOrgaPlusSession == null)
     {
         RaidOrgaPlusTermine.Add(RaidSimple.GetLogInFaild());
         Logger.Error("[LogUploaderLogic.LoadTermine] RO+ Login Faild");
         progress?.Report(new ProgressMessage(1, "Log in Failed"));
         return;
     }
     progress?.Report(new ProgressMessage(0.5, "Raids"));
     RaidOrgaPlusTermine = RaidOrgaPlusConnector.GetRaids(RaidOrgaPlusSession, new Progress <double>(p => progress?.Report(new ProgressMessage((0.4 * p) + 0.5, "Raids"))));
     if (RaidOrgaPlusTermine.Count == 0)
     {
         RaidOrgaPlusTermine.Add(RaidSimple.GetNoTermine());
         Logger.Message("[LogUploaderLogic.LoadTermine] No Raid appointments");
     }
     progress?.Report(new ProgressMessage(1, "Done"));
 }
        internal void UpdateRaidOrga(RaidSimple data, List <int> list, CancellationToken ct, Action <Delegate> invoker, IProgress <ProgressMessage> progress = null)
        {
            progress?.Report(new ProgressMessage(0, "Check RO+ Login"));
            if (data is RaidSimpleTemplate t)
            {
                //TODO localize error
                Action a = () => MessageBox.Show(t.DisplayName, "Invalid raid", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                invoker(a);
                return;
            }

            if (!CheckRaidOrgaSession(invoker, progress))
            {
                return;
            }

            progress?.Report(new ProgressMessage(0.05, "Gathering RO+ data"));
            Raid raid = RaidOrgaPlusConnector.GetRaid(RaidOrgaPlusSession, data.TerminID, data.RaidID, ct, new Progress <ProgressMessage>((p) => progress?.Report(new ProgressMessage((p.Percent * 0.35) + 0.05, "Gathering RO+ data - " + p.Message))));

            if (ct.IsCancellationRequested)
            {
                return;
            }
            progress?.Report(new ProgressMessage(0.35, "Gathering local data"));
            var PercentPerLog     = 0.4 / list.Count;
            List <CachedLog> logs = new List <CachedLog>();

            foreach ((var i, var id) in list.Enumerate())
            {
                var tmp = ProcessLog(PercentPerLog, i, id, progress, ct);
                if (ct.IsCancellationRequested)
                {
                    return;
                }
                if (tmp != null)
                {
                    logs.Add(tmp);
                }
            }
            ;
            raid = Helper.RaidOrgaPlus.RaidOrgaPlusDataWorker.UpdateRaid(raid, logs, invoker, new Progress <ProgressMessage>((p) => progress?.Report(new ProgressMessage((p.Percent * 0.1) + 0.8, "Processing data - " + p.Message))));

            if (ct.IsCancellationRequested)
            {
                return;
            }
            progress?.Report(new ProgressMessage(0.95, "Updating RO+"));
            try
            {
                RaidOrgaPlusConnector.SetRaid(RaidOrgaPlusSession, raid);
            }
            catch (Exception e)
            {
                Logger.Error("Exeption in LogUploaderLogic.UpdateRaidOrga when setting raid");
                Logger.LogException(e);
            }
            progress?.Report(new ProgressMessage(0.99, "Done"));
        }