Пример #1
0
        public static void parseCVReport(String path, Campaign campaign)
        {

            TextFieldParser parser = new TextFieldParser(path, Encoding.GetEncoding("shift_jis"));
            parser.TextFieldType = FieldType.Delimited;
            parser.SetDelimiters(new String[] { ",", "\t" });

            Boolean google = false;
            Boolean ready = false;
            int row = 0;

            if (path.Contains("Yahoo"))
            {
                google = false;
            }
            else {
                google = true;
            }
           
            while (!parser.EndOfData)
            {
                //Process row
                int column = 0;
                Boolean branding = false;
                Boolean document = false;
                string[] fields = parser.ReadFields();

                

                foreach (string field in fields)
                {
                    if (!ready)
                    {
                        if (field.Equals(YCV_CAMPAIGN_NAME) || field.Equals(GCV_CAMPAIGN_NAME))
                        {
                            cvrColumnCampaign = column;
                        }
                        if (field.Equals(YCV_CVs) || field.Equals(GCV_CVs))
                        {
                            cvrColumnCV = column;
                        }
                        if (field.Equals(YCV_CV_NAME) || field.Equals(GCV_CV_NAME))
                        {
                            cvrColumnConverstionType = column;
                        }

                        if (row > 5 || (google && row>2))
                        {
                            ready = true;
                        }
                    }

                    if (ready)
                    {

                        if (column == cvrColumnConverstionType && field.Contains("資料"))
                        {
                                document = true;
                        }

                        if (column == cvrColumnCampaign)
                        {
                            if (field.Contains("社名"))
                            {
                                branding = true;
                            }
                            if (field.Contains("--"))
                            {
                                return;
                            }
                        }

                        if (column == cvrColumnCV)
                        {
                            if (branding)
                            {
                                if (document)
                                {
                                    if (google)
                                    {
                                        campaign.googleBranding.conversionBrochure += Convert.ToDouble(field);
                                    }
                                    else {
                                        campaign.yahooBranding.conversionBrochure += Convert.ToDouble(field);
                                    }
                                }
                                else
                                {
                                    if (google)
                                    {
                                        campaign.googleBranding.conversionBooking += Convert.ToDouble(field);
                                    }
                                    else {
                                        campaign.yahooBranding.conversionBooking += Convert.ToDouble(field);
                                    }
                                }
                            }
                            else
                            {
                                if (document)
                                {
                                    if (google)
                                    {
                                        campaign.googleGeneral.conversionBrochure += Convert.ToDouble(field);
                                    }
                                    else {
                                        campaign.yahooGeneral.conversionBrochure += Convert.ToDouble(field);
                                    }
                                }
                                else
                                {
                                    if (google)
                                    {
                                        campaign.googleGeneral.conversionBooking += Convert.ToDouble(field);
                                    }
                                    else {
                                        campaign.yahooGeneral.conversionBooking += Convert.ToDouble(field);
                                    }
                                }
                            }
                        }

                    }
                    //TODO: Process field
                    column++;
                }
                row++;
            }
            parser.Close();

            return;
        }
Пример #2
0
        public static void parseCampaignReport(String path, Campaign campaign)
        {

            TextFieldParser parser = new TextFieldParser(path, Encoding.GetEncoding("shift_jis"));
            parser.TextFieldType = FieldType.Delimited;
            parser.SetDelimiters(new String[] { ",", "\t" });
       
            Boolean ready = false;
            int row = 0;
            Boolean google = false;

            if (path.Contains("Yahoo"))
            {
                google = false;
            }
            else {
                google = true;
            }

            while (!parser.EndOfData)
            {
                //Process row
                int column = 0;
                Boolean branding = false;
                Double impression = 0.0;
                Double averageRank = 0.0;
                string[] fields = parser.ReadFields();
                foreach (string field in fields)
                {
                  
                    if (field.Equals(YCR_AVG_RANK) || field.Equals(GCR_AVG_RANK))
                    {
                        cprColumnAvgRank = column;
                    }
                    if (field.Equals(YCR_CAMPAIGN_NAME) || field.Equals(GCR_CAMPAIGN_NAME))
                    {
                        cprColumnCampaign = column;
                    }
                    if (field.Equals(YCR_CLICKS) || field.Equals(GCR_CLICKS))
                    {
                        cprColumnClicks = column;
                    }
                    if (field.Equals(YCR_COST) || field.Equals(GCR_COST))
                    {
                        cprColumnCost = column;
                    }
                    if (field.Equals(YCR_IMPRESSIONS) || field.Equals(GCR_IMPRESSIONS))
                    {
                        cprColumnImpressions = column;
                    }
                    if (field.Equals(YCR_UNIQUE_CV) || field.Equals(GCR_UNIQUE_CVs))
                    {
                        cprColumnUniqueCV = column;
                    }

                    if (field.Equals("ユニークコンバージョン率") || field.Equals("すべてのコンバージョン"))
                    {
                        ready = true;
                    }

                    if (ready)
                    {
                        if (column == cprColumnAvgRank)
                        {
                            averageRank = Convert.ToDouble(field);
                        }

                        if (column == cprColumnImpressions)
                        {
                            impression = Convert.ToDouble(field);
                        }

                        if (column == cprColumnCampaign)
                        {
                            if (field.Contains("社名"))
                            {
                                branding = true;
                            }
                            if (field.Contains("--"))
                            {
                                return;
                            }
                        }
                        if (column == cprColumnClicks)
                        {
                            if (branding)
                            {
                                if (google)
                                {
                                    campaign.googleBranding.clickThroughs += Convert.ToDouble(field);
                                }
                                else {
                                    campaign.yahooBranding.clickThroughs += Convert.ToDouble(field);
                                }

                                
                            }
                            else
                            {
                                if (google)
                                {
                                    campaign.googleGeneral.clickThroughs += Convert.ToDouble(field);
                                }
                                else {
                                    campaign.yahooGeneral.clickThroughs += Convert.ToDouble(field);
                                }
                            }
                        }

                        if (column == cprColumnCost)
                        {
                            if (branding)
                            {
                                if (google)
                                {
                                    campaign.googleBranding.cost += Convert.ToDouble(field);
                                }
                                else {
                                    campaign.yahooBranding.cost += Convert.ToDouble(field);
                                }
                            }
                            else
                            {
                                if (google)
                                {
                                    campaign.googleGeneral.cost += Convert.ToDouble(field);
                                }
                                else {
                                    campaign.yahooGeneral.cost += Convert.ToDouble(field);
                                }
                            }
                        }

                        if (column == cprColumnUniqueCV)
                        {
                            if (branding)
                            {
                                if (google)
                                {
                                    campaign.googleBranding.conversionUnique += Convert.ToDouble(field);
                                }
                                else {
                                    campaign.yahooBranding.conversionUnique += Convert.ToDouble(field);
                                }
                            }
                            else
                            {
                                if (google)
                                {
                                    campaign.googleGeneral.conversionUnique += Convert.ToDouble(field);
                                }
                                else {
                                    campaign.yahooGeneral.conversionUnique += Convert.ToDouble(field);
                                }
                            }
                        }

                     
                    }
                    //TODO: Process field
                    column++;
                }
                Double weightedRank = averageRank * impression;
                if (branding)
                {
                    if (google)
                    {
                        campaign.googleBranding.weightedRank += weightedRank;
                    }
                    else {
                        campaign.yahooBranding.weightedRank+= weightedRank;
                    }
                }
                else
                {
                    if (google)
                    {
                        campaign.googleGeneral.weightedRank += weightedRank;
                    }
                    else {
                        campaign.yahooGeneral.weightedRank += weightedRank;
                    }
                }


                row++;

            }
            parser.Close();

            return;
        }