public UC_ITEM_AccueilNewDoc(Int64 id)
 {
     InitializeComponent();
     Document myDoc = new Document((uint)id, "loc");
     UIElement myExpendItem = new UIElement();
     this.TextBlock_heure.Text = myDoc.dateTimeEditionBDD.ToString("dd/MM/yyyy");
     this.TextBlock_logoSection.Text = Logos.DisplayLogo(myDoc.section);
     if (myDoc.typeDocument == "DocNormales")
     {
         this.TextBlock_logoTypeDocument.Text = Logos.DisplayLogo("DOCUMENTS_TECHNIQUES");
         this.TextBlock_titre.Text = ((Document.DocNormales)myDoc.document).titreDocument;
         myExpendItem = new UC_ITEM_Document(id);
     }
     if (myDoc.typeDocument == "Consignes")
     {
         this.TextBlock_logoTypeDocument.Text = Logos.DisplayLogo("CONSIGNES");
         this.TextBlock_titre.Text = ((Document.Consignes)myDoc.document).objetConsigne;
         myExpendItem = new UC_ITEM_Consigne(id);
     }
     if (myDoc.typeDocument == "TachesJournalieres")
     {
         this.TextBlock_logoTypeDocument.Text = Logos.DisplayLogo("TACHES_JOURNALIERES");
         this.TextBlock_titre.Text = ((Document.TachesJournalieres)myDoc.document).titreAction;
         myExpendItem = new UC_ITEM_TacheJournaliere(id);
     }
     if (myDoc.typeDocument == "Verifications")
     {
         this.TextBlock_logoTypeDocument.Text = Logos.DisplayLogo("VERIFICATIONS");
         this.TextBlock_titre.Text = ((Document.Verifications)myDoc.document).titreAction;
         myExpendItem = new UC_ITEM_Verification(id);
     }
     this.myGridAdditionalContent.Children.Add(myExpendItem);
 }
        public UC_ITEM_SearchItem(Document _myDoc, float score)
        {
            InitializeComponent();
            this._myDoc = _myDoc;
            if (_myDoc.typeDocument == "DocNormales")
            {
                this.textBlock_titreDocument.Text = ((Document.DocNormales)_myDoc.document).titreDocument;
                this.titreDocument = ((Document.DocNormales)_myDoc.document).titreDocument;
                this.textBlock_typeDoc.Text = "Document : " + ((Document.DocNormales)_myDoc.document).categorieDocument;
            }
            if (_myDoc.typeDocument == "Consignes")
            {
                this.textBlock_titreDocument.Text = ((Document.Consignes)_myDoc.document).referenceConsigne;
                this.titreDocument = ((Document.Consignes)_myDoc.document).referenceConsigne;
                this.textBlock_typeDoc.Text = "Consigne";
            }
            if (_myDoc.typeDocument == "TachesJournalieres")
            {
                this.textBlock_titreDocument.Text = ((Document.TachesJournalieres)_myDoc.document).titreAction;
                this.titreDocument = ((Document.TachesJournalieres)_myDoc.document).titreAction;
                this.textBlock_typeDoc.Text = "Tâche Journalière";
            }
            if (_myDoc.typeDocument == "Verifications")
            {
                this.textBlock_titreDocument.Text = ((Document.Verifications)_myDoc.document).titreAction;
                this.titreDocument = ((Document.Verifications)_myDoc.document).titreAction;
                this.textBlock_typeDoc.Text = "Verification";
            }
            this.systeme = _myDoc.systeme;
            if (_myDoc.typeContenu != "WITHOUT_CONTENT")
            {
                this.pathToFolder = ((Document.Contenus)_myDoc.contenu).pathToFolder;
                this.fileName = ((Document.Contenus)_myDoc.contenu).fileName;
                this.textBlock_nomSysteme.Text = _myDoc.systeme;
                this.MouseLeftButtonDown += UC_DocumentItem_MouseLeftButtonDown;
                //Ouverture de la photo dans un stream (on ne garde pas ouvert le fichier)
                try
                {
                    FileStream photoStream = new FileStream(this.pathToFolder + '\\' + this.fileName + "_preview.png", FileMode.Open);
                    var bitmap = new BitmapImage();
                    bitmap.BeginInit();
                    bitmap.StreamSource = photoStream;
                    bitmap.CacheOption = BitmapCacheOption.OnLoad;
                    bitmap.EndInit();
                    bitmap.Freeze();
                    photoStream.Close();
                    image_previewDocument.Source = bitmap;
                }
                catch(System.IO.IOException e)
                {
                    Notifier.ShowMessage(e.Message, "Erreur de chargement d'un image", "error", 5);
                }

                //this.image_previewDocument.Source = new BitmapImage(new Uri(this.pathToFolder + '\\' + this.fileName + "_preview.png", UriKind.Absolute));
            }
            this.textBlock_logoSection.Text = Logos.DisplayLogo(_myDoc.section.ToUpper());
            this.textBlock_nomSection.Text = _myDoc.section;
            this.textBlock_scoreDocument.Text = score.ToString();
        }
        public void SetInformations(uint id)
        {
            Document myDoc = new Document(id, "Local");

            try
            {
                FileStream photoStream = new FileStream(myDoc.contenu.pathToFolder + '\\' + myDoc.contenu.fileName + "_preview.png", FileMode.Open);
                var bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.StreamSource = photoStream;
                bitmap.CacheOption = BitmapCacheOption.OnLoad;
                bitmap.EndInit();
                bitmap.Freeze();
                photoStream.Close();
                this.imagePreview.Source = bitmap;
            }
            catch (System.IO.IOException e)
            {
                Notifier.ShowMessage(e.Message, "Erreur de chargement d'une image", "erreur",5);
            }

            //this.imagePreview.Source = new BitmapImage(new Uri(myDoc.contenu.pathToFolder + '\\' + myDoc.contenu.fileName + "_preview.png", UriKind.Absolute));
            this.txtLogoSub.Text = Logos.DisplayLogo(myDoc.subdivision);
            this.txtLogoSection.Text = Logos.DisplayLogo(myDoc.section);
            this.txtSection.Text = myDoc.section;
            this.txtSub.Text = myDoc.subdivision;
            this.txtTypeDocument.Text = myDoc.typeDocument;
            this.txtDateAjoutBDD.Text = "Date d'ajout à la BDD : " + myDoc.dateTimeEditionBDD.ToString("dd-MM-yyyy");
            this.txtTypeContenu.Text = "Type de contenu : "+myDoc.typeContenu;
            switch (myDoc.typeDocument)
            {
                case "DocNormales":
                    this.txtTitre.Text = ((Document.DocNormales)myDoc.document).titreDocument;
                    this.txtRedacteur.Text = "Rédacteur : "+((Document.DocNormales)myDoc.document).auteurDocument;
                    this.txtDateRedaction.Text = "Date rédaction : "+((Document.DocNormales)myDoc.document).dateDocument.ToString("dd-MM-yyyy");
                    this.txtVersion.Text = "Version du document : "+((Document.DocNormales)myDoc.document).versionDocument;
                    break;
                case "Consignes":
                    this.txtTitre.Text = ((Document.Consignes)myDoc.document).referenceConsigne;
                    this.txtRedacteur.Text = "Rédacteur : " + ((Document.Consignes)myDoc.document).redigePar;
                    this.txtDateRedaction.Text = "Responsable de l'opération : " + ((Document.Consignes)myDoc.document).responsableOperation;
                    this.txtVersion.Text = "Objet : " + ((Document.Consignes)myDoc.document).objetConsigne;
                    break;
                case "Verifications":
                    this.txtTitre.Text = ((Document.Verifications)myDoc.document).titreAction;
                    this.txtRedacteur.Text = "Lieu de l'action : " + ((Document.Verifications)myDoc.document).lieu;
                    this.txtDateRedaction.Text = "Vacation cible : " + ((Document.Verifications)myDoc.document).vacationCible;
                    this.txtVersion.Text = "Dernère vérification : " + ((Document.Verifications)myDoc.document).derniereVerification.ToString("dd-MM-yyyy");
                    break;
                case "TachesJournalieres":
                    this.txtTitre.Text = ((Document.TachesJournalieres)myDoc.document).titreAction;
                    this.txtRedacteur.Text = "Version de la tâche : " + ((Document.TachesJournalieres)myDoc.document).versionAction;
                    this.txtDateRedaction.Text = "Jour d'application : " + ((Document.TachesJournalieres)myDoc.document).jourApplication;
                    this.txtVersion.Text = "Date d'expiration : " + ((Document.TachesJournalieres)myDoc.document).dateExpiration;
                    break;
            }
        }
 public UC_ITEM_AccueilVerifications(Int64 id)
 {
     InitializeComponent();
     Document myDoc = new Document((UInt32)id, "loc");
     UIElement myExpendItem = new UIElement();
     this.TextBlock_systeme.Text = myDoc.systeme;
     this.TextBlock_logoSection.Text = Logos.DisplayLogo(myDoc.section);
     this.TextBlock_logoLieu.Text = Logos.DisplayLogo(((Document.Verifications)myDoc.document).lieu);
     this.TextBlock_titre.Text = ((Document.Verifications)myDoc.document).titreAction;
     this.myGridAdditionalContent.Children.Add(myExpendItem);
 }
        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();
            }
        }
 public UC_ITEM_Verification(Document myDoc)
 {
     InitializeComponent();
     _myDoc = myDoc;
     InitControl();
 }
 public UC_ITEM_Document(Document myDoc)
 {
     InitializeComponent();
     _myDoc = myDoc;
     InitControl();
 }
 //Pour l'accueil
 public UC_ITEM_Document(Int64 id)
 {
     InitializeComponent();
     _myDoc = new Document((uint)id, "loc");
     InitControl();
 }
 void UC_DocumentItem_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     e.Handled = true;
     if (_myDoc == null)
     {
         _myDoc = new Document(_id, "loc");
     }
     App._myDocumentViewerWindow.DisplayDocument(_myDoc);
 }
 private void BW_WORK_GetConsignes(object sender, DoWorkEventArgs e)
 {
     BackgroundWorker worker = sender as BackgroundWorker;
     SqlDataReader Reader = ConnectorSqlServer.ExecCommandSql(
                                 @"SELECT Documents.idDocument as id
                                 FROM Documents
                                 JOIN Consignes
                                 ON Documents.idDocument = Consignes.idDocument" +
                                 SelecteurSQLWhere() +
                                 SelecteurSQLTri());
     if (Reader != null)
     {
         while (Reader.Read() && !worker.CancellationPending)
         {
             Document retour = new Document((uint)Reader.GetInt64(Reader.GetOrdinal("id")), "local");
             //Mise en pause du thread pendant 1ms pour la mise à jour des autres threads
             System.Threading.Thread.Sleep(0);
             worker.ReportProgress(0, retour);
         }
         ConnectorSqlServer.Close(Reader);
     }
     if (worker.CancellationPending)
     {
         this._BW_Display_Canceled = true;
     }
 }
 private void AddConsigneToDocPanel(Document myDoc)
 {
     UC_ITEM_Consigne consigneToAdd = new UC_ITEM_Consigne(myDoc);
     this.myDocPanel.Children.Add(consigneToAdd);
 }
 public UC_ITEM_TacheJournaliere(Document myDoc)
 {
     InitializeComponent();
     _myDoc = myDoc;
     InitControl();
 }
        private void AddItemsInListPanel(string section, string systeme = null, string categorieDocument = null)
        {
            string tmpCmd = @"SELECT Documents.idDocument as id
                                FROM Documents
                                JOIN DocNormales
                                ON Documents.idDocument = DocNormales.idDocument
                                JOIN Contenus
                                ON Documents.idDocument = Contenus.idDocument
                                WHERE Documents.subdivision = 'Service' ";
            if (section != null)
            {
                tmpCmd += "AND Documents.section = '" + section + "' ";
            }
            if (systeme != null)
            {
                tmpCmd += "AND Documents.systeme = '" + systeme + "' ";
            }
            if (categorieDocument != null)
            {
                tmpCmd += "AND DocNormales.categorieDocument = '" + categorieDocument + "' ";
            }
            tmpCmd += "ORDER BY section ASC, titreDocument ASC";

            SqlDataReader Reader = ConnectorSqlServer.ExecCommandSql(tmpCmd);

            ClearListPanel();
            while (Reader.Read())
            {
                Document myDoc = new Document((uint)Reader.GetInt64(Reader.GetOrdinal("id")), "local");
                UC_ITEM_Document myNewItem = new UC_ITEM_Document(myDoc);
                myNewItem.Margin = new Thickness(10);
                myDocPanel.Children.Add(myNewItem);
            }
            ConnectorSqlServer.Close(Reader);
        }
 private void BW_WORK_DisplayDocuments(object sender, DoWorkEventArgs e)
 {
     BackgroundWorker worker = sender as BackgroundWorker;
     Tuple<string, int> args = e.Argument as Tuple<string, int>;
     SqlDataReader Reader = ConnectorSqlServer.ExecCommandSql(args.Item1);
     if (Reader != null)
     {
         _parent.setVisibilityProgressBar(Visibility.Visible);
         int numDoc = 0;
         while (Reader.Read() && !worker.CancellationPending)
         {
             Document myDoc = new Document((uint)TablesBdd.GetDBBigInt("id", Reader), "local");
             worker.ReportProgress(((++numDoc * 100) / args.Item2), myDoc);
             //Mise en pause du thread pendant 1ms pour la mise à jour des autres threads
             System.Threading.Thread.Sleep(1);
         }
         ConnectorSqlServer.Close(Reader);
     }
     if (worker.CancellationPending)
     {
         this._BW_Display_Canceled = true;
     }
 }
 public UC_ITEM_Verification(Int64 id)
 {
     InitializeComponent();
     _myDoc = new Document((uint)id, "local");
     InitControl();
 }
 public UC_ITEM_TacheJournaliere(Int64 id)
 {
     InitializeComponent();
     _myDoc = new Document((uint)id, "");
     InitControl();
 }
 public UC_ITEM_Consigne(Int64 id)
 {
     InitializeComponent();
     _myConsigne = new Document((uint)id, "");
     InitControl();
 }
 public UC_ITEM_Consigne(Document myConsigne)
 {
     InitializeComponent();
     _myConsigne = myConsigne;
     InitControl();
 }
 protected void AddItemToDisplayArea(Document myDoc)
 {
     UC_ITEM_Document docRetour = new UC_ITEM_Document(myDoc);
     docRetour.Margin = new Thickness(10, 10, 0, 0);
     this.myDocPanel.Children.Add(docRetour);
 }
 private void BW_WORK_GetVerifications(object sender, DoWorkEventArgs e)
 {
     BackgroundWorker worker = sender as BackgroundWorker;
     SqlDataReader Reader = ConnectorSqlServer.ExecCommandSql(
                                 @"SELECT Documents.idDocument as id
                                 FROM Documents
                                 JOIN Verifications
                                 ON Documents.idDocument = Verifications.idDocument " +
                                 SelecteurSQLVacationApplication() +
                               @"ORDER BY CASE WHEN vacationCible = 'Jour' THEN 1
                                               WHEN vacationCible = 'Nuit' THEN 2
                                               ELSE 3 END,
                                          section ASC, systeme ASC");
     if (Reader != null)
     {
         while (Reader.Read() && !worker.CancellationPending)
         {
             Document myDoc = new Document((uint)Reader.GetInt64(Reader.GetOrdinal("id")), "local");
             //Mise en pause du thread pendant 1ms pour la mise à jour des autres threads
             System.Threading.Thread.Sleep(0);
             worker.ReportProgress(0, myDoc);
         }
         ConnectorSqlServer.Close(Reader);
     }
     if (worker.CancellationPending)
     {
         this._BW_Display_Canceled = true;
     }
 }
 private void BW_WORK_GetTachesJournalieres(object sender, DoWorkEventArgs e)
 {
     BackgroundWorker worker = sender as BackgroundWorker;
     //A ajouter au modèle BDD : heureApplication
     SqlDataReader Reader = ConnectorSqlServer.ExecCommandSql(
                                 @"SELECT Documents.idDocument as id
                                 FROM Documents
                                 JOIN TachesJournalieres
                                 ON Documents.idDocument = TachesJournalieres.idDocument " +
                                 SelecteurSQL() +
                               @"ORDER BY CASE WHEN jourApplication = 'Lundi' THEN 1
                                               WHEN jourApplication = 'Mardi' THEN 2
                                               WHEN jourApplication = 'Mercredi' THEN 3
                                               WHEN jourApplication = 'Jeudi' THEN 4
                                               WHEN jourApplication = 'Vendredi' THEN 5
                                               WHEN jourApplication = 'Samedi' THEN 6
                                               WHEN jourApplication = 'Dimanche' THEN 7
                                               ELSE 8 END,
                                          section ASC, systeme ASC");
     if (Reader != null)
     {
         while (Reader.Read() && !worker.CancellationPending)
         {
             //Mise en pause du thread pendant 1ms pour la mise à jour des autres threads
             System.Threading.Thread.Sleep(0);
             Document myDoc = new Document((uint)Reader.GetInt64(Reader.GetOrdinal("id")), "local");
             //On reporte le progress avezc un objet custom
             worker.ReportProgress(0, myDoc);
         }
         ConnectorSqlServer.Close(Reader);
     }
 }
        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();
        }