Bonjour,

Je développe une appli MVC et j'ai mis en place un calendar.
Ce calendar permet d'avoir une vue sur des tâches à effectuer / action à prendre.

J'ai mis en place des fréquences : mensuelle, trimestrielle, bi-annuelle, annuelle.
Lorsqu'une action à prendre sur une fréquence mensuelle n'est pas faite, je fais ressortir le mois en statut "Late".
Je bloque sur un point :
- j'aimerais que lorsque j'ai une fréquence "mensuelle" et que j'ai un statut "Late", il m'affiche le mois en cours comme "Late". Actuellement, il me met un statut sur le mois en cours comme "action à prendre".

Voici la partie du code qui définit les fréquences et statuts:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//LOOP FOR CURRENT AND UPCOMING STATUSES
            //Set statuses from the month of the current control to the end month
            bool isControlMonthFound = false;
            int frequencyCounter = 0;
            int lateIncr = 0;

            DateTime computedStartDate = DateTimeHelper.Now > calendarStartDate ? DateTimeHelper.Now : calendarStartDate;

            for (int year = computedStartDate.Year; year <= calendarEndDate.Year; year++)
            {
                //Setting start and end months based on year
                int startMonth = 1, endMonth = 12;
                if (year == computedStartDate.Year)
                    startMonth = computedStartDate.Month;
                if (year == calendarEndDate.Year)
                    endMonth = calendarEndDate.Month;

                //Looping through months - store current status, current action and upcoming statuses
                for (int month = startMonth; month <= endMonth; month++)
                {
                    //init vars
                    int upcomingStatus = -1;
                    int upcomingAction = -1;
                    bool isCurrentControl = false;
                    bool isTicked = false;
                    string key = year + "-" + month;
                    bool isMissingDeadLine = false;

                    DateTime cursorDate = new DateTime(year, month, DateTime.DaysInMonth(year, month));
                    isCurrentControl = controlData.RegularEndDate.Value == cursorDate;

                    if (isCurrentControl)
                    {


                        //If current control is in current month  and status is good
                        if (controlData.RegularEndDate.Value.Year == DateTimeHelper.Now.Year
                            && controlData.RegularEndDate.Value.Month == DateTimeHelper.Now.Month
                            && controlData.StatusRef == (int)Statuses.Good)
                        {
                            upcomingStatus = controlData.StatusRef;
                            if (controlData.ControlStateRef == (int)ControlStates.Validated)
                            {
                                isTicked = true;
                            }
                        }
                        else
                        {
                            //If current control is in current month  and status is LATE
                            if (controlData.RegularEndDate.Value.Year == DateTimeHelper.Now.Year
                            && controlData.RegularEndDate.Value.Month == DateTimeHelper.Now.Month
                              &&  controlData.StatusRef == (int) Statuses.Late)
                                isMissingDeadLine = true;

                            upcomingStatus = 0;
                        }
                       
                        upcomingAction = controlData.ControlActionRef;
                        isControlMonthFound = true;
                        frequencyCounter = 0;
                    }

                    if (frequencyCounter % frequencyMonthsCount == 0)
                    {//Set next controls based on the control frequency
                        frequencyCounter = 0;
                    }

                    if (frequencyCounter == 0 && cursorDate > controlData.EndDate.Value)
                    {
                        upcomingStatus = 0;
                    }

                    if (controlData.StatusRef != (int)Statuses.Good && lateIncr <= lateCount)
                    {
                        upcomingStatus = controlData.StatusRef;
                        upcomingAction = controlData.ControlActionRef;
                        lateIncr++;
                    }

                    if (controlData.StatusRef == (int)Statuses.Late   //si précédent status en "Late"
                        && controlData.FrequencyRef == 1) //et une fréquence "Monthly"
                    {
                        upcomingStatus = (int)Statuses.Late;                 
                    }

                    //if (controlData.StatusRef == (int)Statuses.Good && lastMonthIsGAP)
                    //{//Check if previous status is bad and if current month is empty (means it's a month of GAP resolution)
                    //    upcomingStatus = controlData.StatusRef;
                    //    if (controlData.ControlStateRef == (int)ControlStates.Validated)
                    //    {
                    //        isTicked = true;
                    //    }

                    //    lastMonthIsGAP = false;
                    //}

                    //Fill in the planning dictionnary
                    var spl = new StatusPlanning()
                    {
                        StatusRef = upcomingStatus,
                        ActionRef = upcomingAction,
                        IsCurrent = isCurrentControl,
                        IsMissingDeadline = isMissingDeadLine,
                        IsTicked = isTicked
                    };
                    if (statusPlanning.ContainsKey(key))
                    {
                        if (statusPlanning[key].StatusRef != (int)Statuses.Good)
                            statusPlanning[key] = spl;
                    }
                    else
                        statusPlanning.Add(key, spl);

                    frequencyCounter++;
                }
            }
La partie du code qui cause problème :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
                    if (controlData.StatusRef == (int)Statuses.Late   //si précédent status en "Late"
                        && controlData.FrequencyRef == 1) //et une fréquence "Monthly"
                    {
                        upcomingStatus = (int)Statuses.Late;                 
                    }
controlData.FrequencyRef == 1 : correspond à une fréquence mensuelle,
controlData.StatusRef == (int)Statuses.Late : correspond à un controle étant en état "Late"
upcomingStatus : correspond au statut à venir.

Cependant, quelque chose doit m'échapper car cela ne change rien... Je n'arrive pas à mettre le controle du mois en cours en statut "Late".

Si jamais vous avez une idée d'ou peut provenir mon erreur.

Merci.