Beispiel #1
0
        private void AddItems(Dictionary<string, VersionInfo> RetuDic, List<string> Criteria, Dictionary<string, List<VersionInfo>> Diction, FromTypes fromtypr, Status stat, string statusStr)
        {
            if (Criteria == null)
            {
                return;
            }
            int cn;
            string CstatusStr = "";
            Stopwatch st = new Stopwatch();
            st.Start();
            foreach (string item in Criteria)
            {
                cn = 0;
                if (Diction.ContainsKey(item) == true && Diction[item] != null)
                {
                    foreach (VersionInfo vers in Diction[item])
                    {
                        cn++;

                        RetuDic[vers.versionName] = vers;
                        if (st.ElapsedMilliseconds > 250)
                        {
                            CstatusStr = CreateString(cn, fromtypr, item);
                            CstatusStr += " so far";
                            stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                            st.Reset();
                            st.Start();
                        }
                    }
                }
                statusStr += '\n'+CreateString(cn, fromtypr, item);
            }
        }
Beispiel #2
0
        public List<VersionInfo> VersionInfoFromCriteria(VersionInfoSearchCriteria crit,Status stat)
        {
            string statusStr="";
            string CstatusStr = "";
            int cn=0;
            Stopwatch stopw = new Stopwatch();
            List<VersionInfo> ReturnListI = new List<VersionInfo>();
            List<VersionInfo> ReturnList = new List<VersionInfo>();
            List<VersionInfo> util;
            Dictionary<string, VersionInfo> RetuDic = new Dictionary<string, VersionInfo>();

            stopw.Reset();
            stopw.Start();
            foreach (DayOfWeek dayofweek in crit.DaysOfWeek)
            {
                cn = 0;

                if (VersionInfoFromDayOfWeek.TryGetValue(dayofweek, out util))
                {
                    foreach (VersionInfo vers in util)
                    {

                            cn++;

                        RetuDic[vers.versionName] = vers;
                        if (stopw.ElapsedMilliseconds > 250)
                        {
                            CstatusStr = "Added "+cn+" versions created on " + dayofweek+ " so far";
                            stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                            stopw.Reset();
                            stopw.Start();
                        }
                    }
                }
                statusStr += '\n'+"Added " + cn + " versions created on " + dayofweek;
            }

            stopw.Reset();
            stopw.Start();
            foreach (ChangeType changetype in crit.ChangeTypes)
            {
                cn = 0;

                if (VersionInfoFromChangeType.TryGetValue(changetype, out util))
                {
                    foreach (VersionInfo vers in util)
                    {
                        cn++;

                        RetuDic[vers.versionName] = vers;
                        if (stopw.ElapsedMilliseconds > 250)
                        {
                            CstatusStr = "Added " + cn + " versions created because of a " + changetype + " so far";
                            stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                            stopw.Reset();
                            stopw.Start();
                        }
                    }
                }
                statusStr += '\n'+"Added " + cn + " versions created because of a " + changetype;
            }

            stopw.Reset();
            stopw.Start();
            foreach (string changefile in crit.ChangeFile)
            {
                cn = 0;
                if (VersionInfoFromChangeFile[changefile] != null)
                {
                    foreach (VersionInfo vers in VersionInfoFromChangeFile[changefile])
                    {
                        cn++;

                        RetuDic[vers.versionName] = vers;
                        if (stopw.ElapsedMilliseconds > 250)
                        {
                            CstatusStr = "Added " + cn + " versions because of " + changefile + " so far";
                            stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                            stopw.Reset();
                            stopw.Start();
                        }
                    }
                }
                statusStr += '\n'+"Added " + cn + " versions because of " + changefile;
            }

            VersionInfo outVerIn;
            stopw.Reset();
            stopw.Start();
            foreach (string versionName in crit.VersionName)
            {
                cn = 0;
                if (versionName.Contains("*") == false)
                {
                    if (VersionInfoFromVersionName.TryGetValue(versionName,out outVerIn))
                    {
                        cn++;

                        RetuDic[outVerIn.versionName] = outVerIn;
                        if (stopw.ElapsedMilliseconds > 250)
                        {
                            CstatusStr = "Added " + cn + " versions because of version name" + versionName + " so far";
                            stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                            stopw.Reset();
                            stopw.Start();
                        }
                    }
                }
                else
                {
                    foreach (KeyValuePair<string, VersionInfo> k in VersionInfoFromVersionName)
                    {
                        if (Matches(versionName, k.Key))
                        {
                            cn++;

                            RetuDic[k.Value.versionName] = k.Value;
                            if (stopw.ElapsedMilliseconds > 250)
                            {
                                CstatusStr = "Added " + cn + " versions because of version name" + versionName + " so far";
                                stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                                stopw.Reset();
                                stopw.Start();
                            }
                        }
                    }

                }
                statusStr += '\n'+ "Added " + cn + " versions because of version name" + versionName;
            }

            stopw.Reset();
            stopw.Start();
            foreach (string discrip in crit.Notes)
            {
                cn = 0;
                foreach (KeyValuePair<string, List<VersionInfo>> k in VersionInfoFromNotes)
                {
                    if (k.Key.Contains(discrip) == true)
                    {
                        foreach (VersionInfo ve in k.Value)
                        {
                            cn++;

                            RetuDic[ve.versionName] = ve;
                            if (stopw.ElapsedMilliseconds > 250)
                            {
                                CstatusStr = "Added " + cn + " versions because notes contain\"" + discrip + "\" so far";
                                stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                                stopw.Reset();
                                stopw.Start();
                            }
                        }
                    }
                }
                statusStr += '\n'+ "Added " + cn + " versions because notes contain\"" + discrip + "\"";
            }

            AddItems(RetuDic, crit.DaysOfMonth, VersionInfoFromDayOfMonth, FromTypes.DayOfMonth,stat,statusStr);
            AddItems(RetuDic, crit.Hours, VersionInfoFromHour, FromTypes.Hour, stat, statusStr);
            AddItems(RetuDic, crit.Minutes, VersionInfoFromMinute, FromTypes.Minute, stat, statusStr);
            AddItems(RetuDic, crit.Months, VersionInfoFromMonth, FromTypes.Month, stat, statusStr);
            AddItems(RetuDic, crit.Years, VersionInfoFromYear, FromTypes.Year, stat, statusStr);
            AddItems(RetuDic, crit.UserVersions, VersionInfoFromUserVersion, FromTypes.UserVersion, stat, statusStr);

            if (crit.IncludeAllUserVersions == true)
            {
                stopw.Reset();
                stopw.Start();
                cn = 0;
                foreach (KeyValuePair<string, List<VersionInfo>> k in VersionInfoFromUserVersion)
                {

                    //If list has a key that has a user version
                    if (k.Key.Equals(String.Empty) == false)
                    {
                        foreach (VersionInfo ve in k.Value)
                        {
                            cn++;

                            RetuDic[ve.versionName] = ve;
                            if (stopw.ElapsedMilliseconds > 250)
                            {
                                CstatusStr = "Added " + cn + " versions so far because they have user versions";
                                stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                                stopw.Reset();
                                stopw.Start();
                            }
                        }

                    }
                    statusStr += '\n'+"Added " + cn + " versions because they have user versions";
                }

            }

            if (crit.IncludeNoUserVersions == true)
            {
                List<VersionInfo> NoUserVersion;
                stopw.Reset();
                stopw.Start();
                cn = 0;
                if (VersionInfoFromUserVersion.TryGetValue(String.Empty, out NoUserVersion))
                {
                    foreach (VersionInfo ve in NoUserVersion)
                    {
                        cn++;

                        RetuDic[ve.versionName] = ve;
                        if (stopw.ElapsedMilliseconds > 250)
                        {
                            CstatusStr = "Added " + cn + " versions so far because they do not have user versions";
                            stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                            stopw.Reset();
                            stopw.Start();
                        }
                    }
                    statusStr += '\n' + "Added " + cn + " versions because they do not have user versions";
                }
            }

            if (crit.IncludeDiscription == true)
            {
                stopw.Reset();
                stopw.Start();
                cn = 0;
                foreach (KeyValuePair<string, List<VersionInfo>> k in VersionInfoFromNotes)
                {
                    //If list has a key that has a user version
                    if (k.Key.Equals(String.Empty) == false)
                    {
                        foreach (VersionInfo ve in k.Value)
                        {
                            cn++;

                            RetuDic[ve.versionName] = ve;
                            if (stopw.ElapsedMilliseconds > 250)
                            {
                                CstatusStr = "Added " + cn + " versions so far because they have a description";
                                stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                                stopw.Reset();
                                stopw.Start();
                            }
                        }

                    }
                    statusStr += '\n'+"Added " + cn + " versions because they have a description";
                 }
                }

            if (crit.IncludeNoDiscription == true)
            {
                List<VersionInfo> NoDiscription;
                cn = 0;
                stopw.Reset();
                stopw.Start();
                if (VersionInfoFromUserVersion.TryGetValue(String.Empty, out NoDiscription))
                {
                    foreach (VersionInfo ve in NoDiscription)
                    {
                        cn++;

                        RetuDic[ve.versionName] = ve;
                        if (stopw.ElapsedMilliseconds > 250)
                        {
                            CstatusStr = "Added " + cn + " versions so far because they do not have a description";
                            stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                            stopw.Reset();
                            stopw.Start();
                        }
                    }
                    statusStr += '\n' + "Added " + cn + " versions because they do not have a description";
                }
            }

            ReturnListI.AddRange(RetuDic.Values);
            //used to get out of for each loops
            bool breakAndContinue;
            stopw.Reset();
            stopw.Start();
            cn = 0;
            foreach (VersionInfo vers in ReturnListI)
            {
                if (stopw.ElapsedMilliseconds > 250)
                {
                    CstatusStr = "Removed " + cn + " versions so far because they were exlcuded";
                    stat.ReceiveStatus(CstatusStr + '\n' + statusStr,false);
                    stopw.Reset();
                    stopw.Start();
                }

                if (crit.DaysOfWeekR != null && crit.DaysOfWeekR.Contains(vers.date.DayOfWeek) == true)
                {
                    cn++;
                    continue;
                }

                if (crit.DaysOfMonthR != null && crit.DaysOfMonthR.Contains(vers.date.Day) == true)
                {
                    cn++;
                    continue;
                }

                if (crit.HoursR != null && crit.HoursR.Contains(vers.date.Hour) == true)
                {
                    cn++;
                    continue;
                }

                if (crit.MonthsR != null && crit.MonthsR.Contains(vers.date.Month) == true)
                {
                    cn++;
                    continue;
                }

                if (crit.YearsR != null && crit.YearsR.Contains(vers.date.Year) == true)
                {
                    cn++;
                    continue;
                }

                if (crit.MinutesR != null && crit.MinutesR.Contains(vers.date.Minute) == true)
                {
                    cn++;
                    continue;
                }

                if (vers.Removed == true && crit.includeRemove == false)
                {
                    cn++;
                    continue;
                }

                breakAndContinue = false;
                if (crit.VersionNameR != null)
                {
                    foreach (string versionName in crit.VersionNameR)
                    {
                        if (versionName.Contains("*") == false)
                        {
                            if (crit.VersionNameR.Contains(vers.versionName) == true)
                            {
                                breakAndContinue = true;
                                break;
                            }
                        }
                        else
                        {

                            if (Matches(versionName, vers.versionName))
                            {
                                    breakAndContinue = true;
                                    break;
                            }
                        }
                    }
                    if (breakAndContinue == true)
                    {
                        cn++;
                        continue;
                    }
                }

                breakAndContinue = false;
                if (crit.UserVersionsR != null)
                {
                    foreach (string userVersions in crit.UserVersionsR)
                    {
                        if (ContainsVersion(vers.UserVersionsThatContain,userVersions))
                        {
                            breakAndContinue = true;
                            break;
                        }
                    }
                    if (breakAndContinue == true)
                    {
                        cn++;
                        continue;
                    }

                }

                breakAndContinue = false;
                if (crit.ChangeTypesR!= null)
                {
                    foreach (ChangeType changetype in crit.ChangeTypesR)
                    {
                        foreach (ChangeInstruction changeinstructions in vers.changesInVersion)
                        {
                            if (changeinstructions.change == changetype)
                            {
                                breakAndContinue = true;
                                break;
                            }
                        }
                        if (breakAndContinue == true)
                        {
                            break;
                        }
                    }
                    if (breakAndContinue == true)
                    {
                        cn++;
                        continue;
                    }

                }

                breakAndContinue = false;
                if (crit.ChangeFileR != null)
                {
                    foreach (string changefile in crit.ChangeFileR)
                    {
                        foreach (ChangeInstruction changeinstructions in vers.changesInVersion)
                        {
                            if (changeinstructions.externalLocation.Equals(changefile))
                            {
                                breakAndContinue = true;
                                break;
                            }
                        }
                        if (breakAndContinue == true)
                        {
                            break;
                        }
                    }
                    if (breakAndContinue == true)
                    {
                        cn++;
                        continue;
                    }

                }

                if (RejectExclude(vers.date, crit) != null)
                {
                    cn++;
                    continue;
                }

                ReturnList.Add(vers);

            }
            statusStr += '\n' + "Removed " + cn + " versions because they were exlcuded";
            stat.ReceiveStatus(statusStr, true);
            return ReturnList;
        }