コード例 #1
0
        /// ////////////////////////////////////////
        ///Retourne la prochaine date correspondant à la planification suivant
        ///la date de référence
        ///Peut retourner null, si aucune occurence ne suit la date demandée
        public virtual CDateTimeEx GetNextOccurence(DateTime dtDateExecutionPrecedente, bool bPremiereExecution)
        {
            if (DateDebut != null && dtDateExecutionPrecedente < DateDebut.DateTimeValue)
            {
                dtDateExecutionPrecedente = DateDebut.DateTimeValue;
            }
            if (DateFin != null && dtDateExecutionPrecedente > DateFin.DateTimeValue)
            {
                return(null);
            }
            double dHeure = dtDateExecutionPrecedente.Hour + (double)dtDateExecutionPrecedente.Minute / 100;

            if (dHeure > m_dHeure)
            {
                dtDateExecutionPrecedente = dtDateExecutionPrecedente.AddDays(1);
            }


            CDateTimeEx dt = GetMyNextOccurence(dtDateExecutionPrecedente, bPremiereExecution);

            if (dt == null)
            {
                return(null);
            }
            if (DateFin != null && dt.DateTimeValue > DateFin.DateTimeValue)
            {
                return(null);
            }

            return(dt);
        }
コード例 #2
0
        /// ////////////////////////////////////////
        public virtual CResultAErreur Serialize(C2iSerializer serializer)
        {
            int            nVersion = GetNumVersion();
            CResultAErreur result   = serializer.TraiteVersion(ref nVersion);

            if (!result)
            {
                return(result);
            }

            serializer.TraiteDouble(ref m_dHeure);
            if (nVersion < 1)
            {
                int    nHeure = (int)m_dHeure;
                double fMin   = m_dHeure - nHeure;
                fMin     = fMin * 100.0 / 60.0;
                m_dHeure = nHeure + fMin;
            }

            I2iSerializable objet = m_dateDebut;

            serializer.TraiteObject(ref objet);
            m_dateDebut = (CDateTimeEx)objet;

            objet = m_dateFin;
            serializer.TraiteObject(ref objet);
            m_dateFin = (CDateTimeEx)objet;

            return(result);
        }
コード例 #3
0
        /// //////////////////////////////////////////////////////////
        public CDateTimeEx GetNextOccurence(DateTime dtDateReference, bool bPremiereExecution)
        {
            CDateTimeEx dtMin = null;

            foreach (CPlanificationTache planif in Planifications)
            {
                CDateTimeEx dt = planif.GetNextOccurence(dtDateReference, bPremiereExecution);
                if (dt != null &&
                    (dtMin == null || dt.DateTimeValue < dtMin.DateTimeValue))
                {
                    dtMin = dt;
                }
            }
            return(dtMin);
        }
コード例 #4
0
        /// ////////////////////////////////////////
        ///Retourne la prochaine date correspondant à la planification suivant
        ///la date de référence
        ///Peut retourner null, si aucune occurence ne suit la date demandée
        public override CDateTimeEx GetNextOccurence(DateTime dtDateExecutionPrecedente, bool bPremiereExecution)
        {
            if (DateDebut != null && dtDateExecutionPrecedente < DateDebut.DateTimeValue)
            {
                dtDateExecutionPrecedente = DateDebut.DateTimeValue;
            }
            if (DateFin != null && dtDateExecutionPrecedente > DateFin.DateTimeValue)
            {
                return(null);
            }
            CDateTimeEx dt = GetMyNextOccurence(dtDateExecutionPrecedente, bPremiereExecution);

            if (dt == null)
            {
                return(null);
            }
            if (DateFin != null && dt.DateTimeValue > DateFin.DateTimeValue)
            {
                return(null);
            }

            return(dt);
        }
コード例 #5
0
        private void m_lnkReplanifier_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e)
        {
            CDateTimeEx dt = null;

            if (!m_gestionnaireModeEdition.ModeEdition)
            {
                dt = TachePlanifiee.ParametrePlanification.GetNextOccurence(DateTime.Now, true);
            }
            else
            {
                m_panelPlanification.ValideDonnees();
                dt = m_panelPlanification.ParametrePlanification.GetNextOccurence(DateTime.Now, true);
            }
            if (dt != null)
            {
                if (CFormAlerte.Afficher(I.T("Plan execution on |30235") + dt.DateTimeValue.ToString("g"),
                                         EFormAlerteType.Question) == DialogResult.Yes)
                {
                    if (!m_gestionnaireModeEdition.ModeEdition)
                    {
                        TachePlanifiee.BeginEdit();
                    }
                    TachePlanifiee.DateProchaineExecution = dt;
                    if (!m_gestionnaireModeEdition.ModeEdition)
                    {
                        CResultAErreur result = TachePlanifiee.CommitEdit();
                        if (!result)
                        {
                            CFormAlerte.Afficher(result.Erreur);
                            return;
                        }
                    }
                }
                UpdateDateProchaineExecution();
            }
        }
コード例 #6
0
ファイル: CWndForWndChampSnmp.cs プロジェクト: ykebaili/Timos
        //-------------------------------------
        protected override void  MyUpdateValeursCalculees()
        {
            if (m_controleSnmp == null)
            {
                return;
            }
            CEntiteSnmp entiteSnmp = EditedElement as CEntiteSnmp;

            if (entiteSnmp == null)
            {
                return;
            }

            CRelationEntiteSnmp_ChampCustom rel = CUtilElementAChamps.GetRelationToChamp(entiteSnmp, ((CChampCustom)WndSnmp.FieldZone.Variable).Id) as CRelationEntiteSnmp_ChampCustom;

            if (m_createur != null && m_controleSnmp != null)
            {
                m_createur.SetTooltip(m_controleSnmp, "");
            }
            if (rel == null)
            {
                m_controleSnmp.Visible = false;
                m_imageWarning.Visible = false;
            }
            else
            {
                CDateTimeEx dt = rel.DateSynchroSnmp;
                if (dt != null)
                {
                    if (m_createur != null && m_controleSnmp != null)
                    {
                        m_createur.SetTooltip(m_controleSnmp, I.T("Last updated : @1 @2|20317",
                                                                  dt.DateTimeValue.ToShortDateString(),
                                                                  dt.DateTimeValue.ToLongTimeString()));
                    }
                }
                m_controleSnmp.Visible = true;
                object val = rel.LastSnmpValue;
                if (val == null)
                {
                    m_controleSnmp.Text = "";
                }
                else
                {
                    if (WndSnmp.ChampCustom.IsChoixParmis())
                    {
                        m_controleSnmp.Text = WndSnmp.ChampCustom.DisplayFromValue(val);
                    }
                    else if (m_controleSnmp is CheckBox)
                    {
                        ((CheckBox)m_controleSnmp).Checked = (val is bool) ? (bool)val : false;
                    }
                    else
                    {
                        m_controleSnmp.Text = val.ToString();
                    }
                }
                string strVal1 = m_wndChamp.Value != null?m_wndChamp.Value.ToString() : "";

                string strVal2 = val != null?val.ToString() : "";

                if (strVal1 != strVal2 && rel.DateSynchroSnmp != null)
                {
                    m_imageWarning.Visible = true;
                    m_controleSnmp.Width   = m_wndChamp.Control.Width - 16;
                }
                else
                {
                    m_imageWarning.Visible = false;
                    m_controleSnmp.Width   = m_wndChamp.Control.Width;
                }
            }
        }
コード例 #7
0
        private static void OnTachePlanifiee(object state)
        {
            //14/12/2010 : si un traitement est en cours depuis plus de 24H, lance d'autres traitements
            TimeSpan sp = DateTime.Now - m_lastDateDebutTraitement;

            if (m_bTraitementEnCours && sp.TotalHours < 24)
            {
                return;
            }
            m_bTraitementEnCours      = true;
            m_lastDateDebutTraitement = DateTime.Now;
            try
            {
                System.Threading.Thread.CurrentThread.Priority = System.Threading.ThreadPriority.Lowest;
                CResultAErreur result;
                if (m_sessionRecherche == null || !m_sessionRecherche.IsConnected)
                {
                    m_sessionRecherche = CSessionClient.CreateInstance();
                    result             = m_sessionRecherche.OpenSession(new CAuthentificationSessionServer(),
                                                                        I.T("Search of planned tasks|332"),
                                                                        ETypeApplicationCliente.Service);
                    if (!result)
                    {
                        C2iEventLog.WriteErreur(I.T("Session Opening error for planned tasks|333"));
                        return;
                    }
                }
                try
                {
                    CFiltreData filtre = new CFiltreData(CTachePlanifiee.c_champProchaineExecution + " < @1 and " +
                                                         CTachePlanifiee.c_champBloquer + "=@2",
                                                         DateTime.Now,
                                                         false
                                                         );
                    if (new CTachePlanifieeServeur(m_sessionRecherche.IdSession).CountRecords(
                            CTachePlanifiee.c_nomTable, filtre) > 0)
                    {
                        CSessionClient sessionTravail = new CSessionProcessServeurSuivi();
                        result = sessionTravail.OpenSession(new CAuthentificationSessionProcess(),
                                                            I.T("Planned Tasks execution|334"),
                                                            ETypeApplicationCliente.Service);
                        if (!result)
                        {
                            C2iEventLog.WriteErreur(I.T("Working session openning error for Planned Tasks|335"));
                            return;
                        }
                        try
                        {
                            using (CContexteDonnee contexteTravail = new CContexteDonnee(sessionTravail.IdSession, true, false))
                            {
                                CTachePlanifieeServeur serveur = new CTachePlanifieeServeur(sessionTravail.IdSession);
                                CListeObjetsDonnees    liste   = new CListeObjetsDonnees(contexteTravail, typeof(CTachePlanifiee));
                                liste.Filtre = filtre;

                                foreach (CTachePlanifiee tache in liste)
                                {
                                    CInfoDeclencheurProcess infoDeclencheur = new CInfoDeclencheurProcess(TypeEvenement.Date);
                                    try
                                    {
                                        serveur.ExecuteTache(tache.Id, null);
                                    }
                                    catch (Exception e)
                                    {
                                        string strLibelle = I.T("Error planned task @1|336", tache.Libelle) + Environment.NewLine;
                                        strLibelle += e.ToString();
                                        C2iEventLog.WriteErreur(strLibelle);
                                    }
                                    tache.BeginEdit();
                                    CDateTimeEx dt = tache.ParametrePlanification.GetNextOccurence(tache.DateProchaineExecution, false);
                                    while (dt != null && (DateTime)dt < DateTime.Now)
                                    {
                                        dt = tache.ParametrePlanification.GetNextOccurence(dt, false);
                                    }
                                    tache.DateProchaineExecution = dt;
                                    tache.CommitEdit();
                                    //Ouvre une session pour chaque tâche. Comme ça s'il y a une erreur sur une tâche,
                                    //les autres ne peuvent pas être impactées
                                    sessionTravail.CloseSession();
                                    result = sessionTravail.OpenSession(new CAuthentificationSessionProcess(),
                                                                        I.T("Planned Tasks execution|334"),
                                                                        ETypeApplicationCliente.Service);
                                    if (!result)
                                    {
                                        throw new CExceptionErreur(result.Erreur);
                                    }
                                }
                            }
                        }
                        catch (Exception e)
                        {
                            C2iEventLog.WriteErreur(I.T("Error in planned tasks : @1|337", e.ToString()));
                        }
                        finally
                        {
                            try
                            {
                                sessionTravail.CloseSession();
                            }
                            catch { }
                        }
                    }
                }
                catch (Exception e)
                {
                    C2iEventLog.WriteErreur(I.T("Error in planned tasks : @1|337", e.ToString()));
                }
            }
            catch (Exception e)
            {
                {
                    C2iEventLog.WriteErreur(I.T("Error in planned tasks : @1|337", e.ToString()));
                }
            }
            finally
            {
                m_bTraitementEnCours = false;
            }
        }