Beispiel #1
0
        void Sorting(RevisionCl rowL, int newEtap, int oldEtap)
        {
            try
            {
                if (revL != null)
                {
                    if (revL.All(r => r.Etap != newEtap))   // чтобы не было дублирующих этапов
                    {
                        var removeRows = revL.Where(r => r.Etap == oldEtap).OrderByDescending(r => r).ToList();

                        int removeRowsCount = removeRows.Count();
                        if (removeRows != null)
                        {
                            foreach (var rem in removeRows)
                            {
                                revL.Remove(rem);
                            }

                            List <int> ind = new List <int>();
                            var        devidedByRevicion = revL.GroupBy(g => g.Revision);

                            if (devidedByRevicion != null && devidedByRevicion.Count() > 0)
                            {
                                foreach (var devR in devidedByRevicion)
                                {
                                    var lastEt = devR.LastOrDefault(r => r.Etap <= newEtap);
                                    if (lastEt == null)
                                    {
                                        lastEt = devR.Last();
                                    }
                                    ind.Add(revL.IndexOf(lastEt));
                                }
                            }
                            else
                            {
                                ind = Enumerable.Repeat(-1, removeRowsCount).ToList();
                            }

                            if (ind != null && ind.Count == removeRowsCount)
                            {
                                int chet = ind.Count - 1;

                                foreach (var rem in removeRows)
                                {
                                    var rev = (rem as RevisionCl).Copy();
                                    rev.Etap = newEtap;
                                    revL.Insert(ind[chet] + 1, new RevisionClWithEvent(rev));
                                    chet -= 1;
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
                throw;
            }
        }
Beispiel #2
0
 public RevisionClWithEvent(RevisionCl rev)
     : base(rev)
 {
 }
Beispiel #3
0
        public void InsterRow(TypeOfAddRows rezhim, int ind)
        {
            try
            {
                if (revL != null)
                {
                    if (rezhim == TypeOfAddRows.AddRevision)
                    {
                        int maxRev  = revL.Max(r => r.Revision) + 1;
                        var lastRev = revL.Where(r => r.Revision == maxRev - 1).Select(r =>
                        {
                            var rCopy      = r.Copy();
                            rCopy.Revision = maxRev;
                            return(rCopy);
                        }).ToList();

                        foreach (var rev in lastRev)
                        {
                            revL.Add(rev);
                        }
                    }
                    else if (rezhim == TypeOfAddRows.AddEtap)
                    {
                        RevisionCl rCopy = (revL[ind] as RevisionCl).Copy();
                        rCopy.Etap += 1;

                        var gr = revL.GroupBy(r => r.Revision);

                        if (gr != null)
                        {
                            if (gr.First().Any(r => r.Etap == rCopy.Etap) == true)
                            {
                                rCopy.Etap  = gr.First().Max(r => r.Etap);
                                rCopy.Etap += 1;
                            }

                            List <int> index = new List <int>();
                            foreach (var g in gr)
                            {
                                index.Add(0);
                                if (g != null)
                                {
                                    var findf = g.LastOrDefault(gig => gig.Etap <= rCopy.Etap);
                                    if (findf != null)
                                    {
                                        index[index.Count - 1] = revL.IndexOf(findf) + 1;
                                    }
                                }
                            }

                            if (index != null)
                            {
                                for (int i = index.Count - 1; i >= 0; i--)
                                {
                                    RevisionClWithEvent newrow = new RevisionClWithEvent(rCopy);
                                    newrow.Revision = i + 1;
                                    revL.Insert(index[i], newrow);
                                }
                            }
                        }
                    }
                    //  RevisionCl.EtapChange += new Action<RevisionCl, int>(Sorting);
                    //  AllowdToSort = true;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                MessageBox.Show(ex.StackTrace);
            }
        }