public int[] SeparateYearAndMonthFromDateMethod(AnalysisDataModel u)
        {
            char separator = '.';

            string[] strlist = u.Date.Split(separator);
            return(strlist.Select(int.Parse).ToArray());
        }
Пример #2
0
        public List <AnalysisDataModel> CreateNewListWithDataModelMethod(List <object> ReadOutList)
        {
            foreach (object[] element in ReadOutList)
            {
                if (element[0] != null)
                {
                    DateTime          convertedDate = shamsiDate.DateConvertor(element);
                    AnalysisDataModel analysisData  = new AnalysisDataModel();

                    tempTime1 = ctt.CreateTime(convertedDate);

                    if (tempTime1 == temptime2 && lastReadOutDate == convertedDate)
                    {
                        element[0]   = convertedDate;
                        analysisData = new AnalysisDataModel((DateTime)element[0],
                                                             element[1].ToString(),
                                                             element[2].ToString(),
                                                             element[3].ToString(),
                                                             element[4].ToString(),
                                                             "");
                        FinalReadOutList.Add(analysisData);
                    }

                    if (temptime2 != tempTime1)
                    {
                        temptime2    = tempTime1;
                        element[0]   = convertedDate;
                        analysisData = new AnalysisDataModel((DateTime)element[0],
                                                             element[1].ToString(),
                                                             element[2].ToString(),
                                                             element[3].ToString(),
                                                             element[4].ToString(),
                                                             "");
                        FinalReadOutList.Add(analysisData);
                        lastReadOutDate = convertedDate;
                    }
                }
            }
            return(FinalReadOutList);
        }
        public List <AnalysisDataModel> AddModifiedDateColumnToReadOutListMethod(List <AnalysisDataModel> FinalReadOutList)
        {
            int m = 0;

            DateTime cmdate = new DateTime();

            AnalysisDataModel asb = FinalReadOutList.FirstOrDefault();
            AnalysisDataModel lastItemInThisList = new AnalysisDataModel(new DateTime(), "", "", "", "", "");

            cmdate = asb.ReadOutDate;

            int tm = cmdate.Month;
            int ym = cmdate.Year;
            int dm = cmdate.Day;

            foreach (AnalysisDataModel element in FinalReadOutList)
            {
                if (cmdate != element.ReadOutDate)
                {
                    DateTime d = element.ReadOutDate;

                    tm     = d.Month;
                    ym     = d.Year;
                    dm     = d.Day;
                    cmdate = element.ReadOutDate;
                    m      = 0;
                }

                if (element.Obis != null && element.Obis.Contains("802010000") && element.Obis != ("0802010000FF"))
                {
                    if (dm >= 20 && dm <= 31)
                    {
                        if (tm < 1)
                        {
                            tm           = 12;
                            ym           = ym - 1;
                            element.Date = ym.ToString() + "." + tm.ToString();
                            tm           = tm - 1;
                        }
                        else
                        {
                            element.Date = ym.ToString() + "." + tm.ToString();
                            tm           = tm - 1;
                        }
                    }

                    else
                    {
                        tm = tm - 1;
                        if (tm < 1)
                        {
                            tm           = 12;
                            ym           = ym - 1;
                            element.Date = ym.ToString() + "." + (tm).ToString();
                        }
                        else
                        {
                            element.Date = ym.ToString() + "." + (tm).ToString();
                        }
                    }

                    m++;
                    if (lastItemInThisList.ObisFarciDesc != element.ObisFarciDesc)
                    {
                        FinalOrderedReadOutList.Add(element);
                        lastItemInThisList = FinalOrderedReadOutList.LastOrDefault();
                    }
                    else
                    {
                        tm = tm + 1;
                    }
                }

                //if (element[2] != null && element[2].ToString().Contains("802606202"))
                //{
                //    FinalOrderedReadOutList.Add(element);
                //}
            }
            return(FinalOrderedReadOutList);
        }
Пример #4
0
        public List <AnalysisDataModel> CreateFinalListMethod(List <AnalysisDataModel> FinalOrderedReadOutList)
        {
            AnalysisDataModel OldSampleData = FinalOrderedReadOutList.FirstOrDefault();

            foreach (AnalysisDataModel item in FinalOrderedReadOutList)
            {
                if (item.ReadOutDate != OldSampleData.ReadOutDate)
                {
                    if (item.Date == OldSampleData.Date)
                    {
                        if (item.Value == OldSampleData.Value)
                        {
                            foreach (AnalysisDataModel itemm in FinalOrderedReadOutList)
                            {
                                if (item.ReadOutDate == itemm.ReadOutDate)
                                {
                                    if (index == 1)
                                    {
                                        OldSampleData  = itemm;
                                        index          = 0;
                                        ReadOutListOld = ReadOutListNew.ToList();
                                        ReadOutListNew.Clear();
                                    }
                                    ReadOutListNew.Add(itemm);
                                }
                            }

                            ReadOutListNew.Reverse();
                            lastitem1 = ReadOutListNew.FirstOrDefault();
                            ReadOutListOld.Reverse();
                            SeparateYearAndMonthFromDate separateYearAndMonthFromDate = new SeparateYearAndMonthFromDate();
                            int[] LastItemYearMonthArray = separateYearAndMonthFromDate.SeparateYearAndMonthFromDateMethod(lastitem1);

                            foreach (AnalysisDataModel u in ReadOutListOld)
                            {
                                int[] UYearMotnhArrayList = separateYearAndMonthFromDate.SeparateYearAndMonthFromDateMethod(u);

                                if (UYearMotnhArrayList[0] == LastItemYearMonthArray[0] && UYearMotnhArrayList[1] > LastItemYearMonthArray[1])
                                {
                                    break;
                                }

                                if (lastitem1.Date == u.Date)
                                {
                                    break;
                                }


                                if (lastitem1.Date != u.Date)
                                {
                                    SampleLastItem.Add(u);
                                }
                            }

                            ReadOutListNew = SampleLastItem.Concat(ReadOutListNew).ToList();
                            SampleLastItem.Clear();
                            ReadOutListNew.Reverse();
                            index = 1;
                        }
                    }
                }
            }
            return(ReadOutListNew);
        }