Esempio n. 1
0
        /// <summary>
        /// 총리슽를 토대로 분석데이터를 뽑는 함수이다.
        /// </summary>
        public void AnalysisData()
        {
            int count   = 0;
            int count2  = 0;
            int decide  = 0; //item 넘버로 찾을지 아님 가격으로 위치 찾을지 결정하는 변수
            int decide2 = 0; //up down 리스트를 구별하는 함수
            int count3  = 0; //같은몰
            int count4  = 0; //같은몰중에서도 가격 높은거

            CPTotalList = new List <string[]>();
            CPupList    = new List <string[]>(); //가격이 높은거
            CPdownList  = new List <string[]>(); //가격이 낮은거
            CPTotalList.AddRange(CPinfoNaverList);
            CPTotalList.AddRange(CPinfoDanawaList);

            try
            {
                CPTotalList.Sort(delegate(String[] x, String[] y)
                {
                    String tmpx = "";
                    foreach (var VARIABLE in x.ElementAt(3).Split(','))
                    {
                        tmpx += VARIABLE;
                    }
                    String tmpy = "";
                    foreach (var VARIABLE2 in y.ElementAt(3).Split(','))
                    {
                        tmpy += VARIABLE2;
                    }
                    return(int.Parse(tmpx).CompareTo(int.Parse(tmpy)));
                });

                foreach (var VARIABLE3 in CPTotalList)
                {
                    count++;
                    CPdownList.Add(VARIABLE3);
                    if (VARIABLE3.ElementAt(1) == mall)
                    {
                        count3++;
                        count4++;
                    }
                    if (VARIABLE3.ElementAt(2) == itemNum)
                    {
                        decide = 1;
                        break;
                    }
                }
                if (decide == 1)
                {
                    int tmp = count;

                    for (var i = tmp + 1; tmp < CPTotalList.Count; tmp++)
                    {
                        if (CPTotalList.ElementAt(tmp).ElementAt(1) == mall)
                        {
                            count3++;
                        }
                        CPupList.Add(CPTotalList.ElementAt(tmp));
                    }
                }
                Console.WriteLine("현재 상품은 이위치에 있습니다item넘버로찾은위치" + count);
                grade = count;
                if (decide == 0)
                {
                    foreach (var VARIABLE4 in CPTotalList)
                    {
                        count2++;
                        CPdownList.Add(VARIABLE4);
                        if (VARIABLE4.ElementAt(1) == mall)
                        {
                            count3++;
                            count4++;
                        }
                        if (VARIABLE4.ElementAt(2) == itemNum)
                        {
                            decide = 1; break;
                        }
                    }
                    if (decide == 1)
                    {
                        int tmp = count2;
                        for (var i = tmp + 1; tmp < CPTotalList.Count; tmp++)
                        {
                            if (CPTotalList.ElementAt(tmp).ElementAt(1) == mall)
                            {
                                count3++;
                            }
                            CPupList.Add(CPTotalList.ElementAt(tmp));
                        }
                    }
                    Console.WriteLine("현재 상품은 이위치에 있습니다가격으로찾은위치" + count);
                }
                //////////////////////////////////////////////////////////////////////////////////////////
                //////////////////////////
                String tmph = "";
                foreach (var VARIABLE in CPTotalList.Last().ElementAt(3).Split(','))
                {
                    tmph += VARIABLE;
                }
                highprice = int.Parse(tmph);
                /////////////////////////
                String tmpd = "";
                foreach (var VARIABLE in CPTotalList.First().ElementAt(3).Split(','))
                {
                    tmpd += VARIABLE;
                }
                rowprice = int.Parse(tmpd);
                ////////////////////////
                Totallistcount = CPTotalList.Count;
                ////////////////////////
                avg = (int)((highprice + rowprice) / 2);
                //////////////
                float tmp3 = rowprice;
                float tmp2 = highprice;
                avgper = ((tmp3 / tmp2) * 100);
                Math.Round(avgper, 1);
                /////////////////////
                samemallcount = count3;
                ////////////////////
                samemallgrade = count4;
                //////////////////////

                highcompare = new List <int>();
                highcompare = new List <int>();

                try
                {
                    foreach (var VARIABLE in CPTotalList)
                    {
                        String tmp = "";
                        foreach (var VARIABLE2 in VARIABLE.ElementAt(3).Split(','))
                        {
                            tmp += VARIABLE2;
                        }
                        highcompare.Add(highprice - int.Parse(tmp));

                        lowcompare.Add(int.Parse(tmp) - rowprice);
                    }
                }
                catch (FormatException)
                {
                }
                catch (NullReferenceException)
                {
                }
            }
            catch (InvalidOperationException)
            {
                Console.WriteLine("totallist를 뽑는 과정에서 익셉션 발생 ");
            }
        }