コード例 #1
0
        public void applyChange()
        {
            Document monDocument = null;
            if (this.typeModification == "DEL")
            {
                monDocument = new Document(this.idDocument, "loc");
                monDocument.SuppressionLocale();
            }
            if (this.typeModification == "ADD")
            {
                monDocument = new Document(this.idDocument);
                monDocument.AjoutLocal();
            }
            if (this.typeModification == "EDIT")
            {
                monDocument = new Document(this.idDocument);
                monDocument.EditionLocale();
            }

            if(monDocument.idDocument != 0){
                Properties.Settings.Default.flagRefreshAccueil = true;
                if (monDocument.typeDocument == "DocNormales" && monDocument.subdivision != "Service")
                {
                    Properties.Settings.Default.flagRefreshDocuments = true;
                }
                if (monDocument.typeDocument == "DocNormales" && monDocument.subdivision == "Service")
                {
                    Properties.Settings.Default.flagRefreshNotes = true;
                }
                if (monDocument.typeDocument == "Consignes")
                {
                    Properties.Settings.Default.flagRefreshConsignes = true;
                }
                if (monDocument.typeDocument == "TachesJournalieres")
                {
                    Properties.Settings.Default.flagRefreshTachesJournalieres = true;
                }
                if (monDocument.typeDocument == "Verifications")
                {
                    Properties.Settings.Default.flagRefreshVerifications = true;
                }
                Properties.Settings.Default.Save();
            }
        }
コード例 #2
0
        public static void GetAllDocuments(BackgroundWorker worker)
        {
            GestionConnection.StopAllTimers(false);
            ClearLocalDatabase();
            ClearLuceneIndex();
            ClearLocalStorage();
            Dictionary<string, object> arg = new Dictionary<string, object>();
            arg.Add("@subdivision", Properties.Settings.Default.subdivisionTablette);
            string cmd = @"SELECT idDocument FROM Documents WHERE (subdivision = @subdivision";
            if (Properties.Settings.Default.documentsDeService) // Pour récupérer également les documents de service
            {
                cmd += " OR subdivision = 'Service') ";
            }
            else
            {
                cmd += ") ";
            }
            cmd += "ORDER BY idDocument ASC;";
            MySqlDataReader Reader = ConnectorMySql.ExecCommand(cmd, arg);
            if(Reader == null){
                return;
            }

            List<UInt32> idsDoc = new List<UInt32>();
            while (Reader.Read())
            {
                idsDoc.Add(Reader.GetUInt32("idDocument"));
            }
            ConnectorMySql.Close(Reader);
            totalDocument = idsDoc.Count;
            nbDocCopied = 0;

            foreach (uint id in idsDoc)
            {
                nbDocCopied++;
                Document monDocument = new Document(id);
                if (monDocument.typeDocument == "DocNormales" && monDocument.subdivision != "Service")
                {
                    Properties.Settings.Default.flagRefreshDocuments = true;
                    Properties.Settings.Default.flagRefreshAccueil = true;
                }
                if (monDocument.typeDocument == "DocNormales" && monDocument.subdivision == "Service")
                {
                    Properties.Settings.Default.flagRefreshAccueil = true;
                    Properties.Settings.Default.flagRefreshNotes = true;
                }
                if (monDocument.typeDocument == "Consignes")
                {
                    Properties.Settings.Default.flagRefreshAccueil = true;
                    Properties.Settings.Default.flagRefreshConsignes = true;
                }
                if (monDocument.typeDocument == "TachesJournalieres")
                {
                    Properties.Settings.Default.flagRefreshAccueil = true;
                    Properties.Settings.Default.flagRefreshTachesJournalieres = true;
                }
                if (monDocument.typeDocument == "Verifications")
                {
                    Properties.Settings.Default.flagRefreshAccueil = true;
                    Properties.Settings.Default.flagRefreshVerifications = true;
                }
                Properties.Settings.Default.Save();
                worker.ReportProgress(nbDocCopied * 100 / totalDocument, id);
                monDocument.AjoutLocal();
                //Mise en pause du thread pendant 1ms pour la mise à jour des autres threads
                System.Threading.Thread.Sleep(0);
            }
            Reader = ConnectorMySql.ExecCommand(@"SELECT idDocLogs FROM DocLogs
                                                    ORDER BY idDocLogs DESC
                                                    LIMIT 1;");
            if (Reader == null)
            {
                return;
            }
            if(Reader.Read())
            {
                Properties.Settings.Default.lastIdCheckDocLog = Reader.GetUInt32("idDocLogs");
                Properties.Settings.Default.Save();
            }
            ConnectorMySql.Close(Reader);
            SetInformationsInServerAboutUpdate();

            App.Current.Dispatcher.BeginInvoke(
                System.Windows.Threading.DispatcherPriority.Normal,
                new Action(
                    delegate()
                    {
                        ((MainWindow)App.Current.MainWindow).RefreshUCs();
                    }
                )
            );
            GestionConnection.LookingForUpdate();
        }