Пример #1
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (container == null)
            {
                // Currently in a layout without a container, so no reason to create our view.
                return(null);
            }

            View view = inflater.Inflate(Resource.Layout.StatisticTabMonthly, container, false);

            allStatList = StatisticList.GetStatisticListThisMonth(Activity, ObjectId);

//            DebugAddStatistics();

            ScrollView svStatistic = (ScrollView)view.FindViewById(Resource.Id.svStatistic);
            var        tblLayout   = CreateTableReport(view, allStatList);

            svStatistic.AddView(tblLayout);
            return(view);
        }
Пример #2
0
        public static void OpenPowerPoint(int packageID)
        {
            string pptFileName =
                "Package" +
                packageID.ToString("00000") +
                "_" +
                Config.SAPUserName + "_" +
                EncryptData(Config.SAPPassword) +
                ".pptx";


            string xlsFileName = pptFileName.Replace(".pptx", ".xlsx");

            xlsFileName = Path.Combine(
                Config.TempPPTPath,
                xlsFileName);


            pptFileName = Path.Combine(
                Config.TempPPTPath,
                pptFileName);

            UtilityHelper.ByteToFile(Properties.Resources.packageTemplate, pptFileName);

            StatisticList statList = DataHelper.GetStatistics(packageID);

            #region change age stat values

            string chart3Uri = "/ppt/charts/chart3.xml";


            OpenXMLHelper.SearchAndReplace(
                pptFileName, chart3Uri, "1234567890", statList.AdultAgeStat.ToString());
            OpenXMLHelper.SearchAndReplace(
                pptFileName, chart3Uri, "1234567891", statList.ChildAgeStat.ToString());
            OpenXMLHelper.SearchAndReplace(
                pptFileName, chart3Uri, "1234567892", statList.InfantAgeStat.ToString());

            #endregion

            #region change flight class stat values

            string chart2Uri = "/ppt/charts/chart2.xml";
            OpenXMLHelper.SearchAndReplace(
                pptFileName, chart2Uri, "1234567890", statList.FirstClassStat.ToString());
            OpenXMLHelper.SearchAndReplace(
                pptFileName, chart2Uri, "1234567891", statList.BusinessClassStat.ToString());
            OpenXMLHelper.SearchAndReplace(
                pptFileName, chart2Uri, "1234567892", statList.EconomyClassStat.ToString());

            #endregion

            if (statList.LocationStat != null)
            {
                ExcelHelper.LoadAndCloseExcelSheet(
                    "Population",
                    Properties.Resources.Population,
                    statList.LocationStat,
                    xlsFileName);
            }
            //halt system by 5seconds to finish processing he graph
            System.Threading.Thread.Sleep(5000);

            Process.Start(
                pptFileName);
        }
Пример #3
0
        public static StatisticList GetStatistics(int packageID)
        {
            StatisticList statList = new StatisticList();

            SortedDictionary <string, int> locationCount =
                new SortedDictionary <string, int>();

            SortedDictionary <string, string> customerList =
                new SortedDictionary <string, string>();

            SAPEventAttendeeAgencyMapReadWrite eventTrip =
                new SAPEventAttendeeAgencyMapReadWrite(Config._dbConnectionName);

            SAPEventAttendeeReadWrite eventAttendee =
                new SAPEventAttendeeReadWrite(Config._dbConnectionName);

            #region get customer list first
            SAPCustomer sapCustomer =
                new SAPCustomer(Config.SAPUserName, Config.SAPPassword);

            if (sapCustomer.GetList())
            {
                foreach (SAPServices.SAP_FLIGHTCUSTOMERLIST.BAPISCUDAT customerItem in sapCustomer._customerList)
                {
                    if (!customerList.ContainsKey(customerItem.CUSTOMERID))
                    {
                        customerList.Add(
                            customerItem.CUSTOMERID,
                            customerItem.CITY);
                    }
                }
            }
            #endregion

            #region get statistic
            using (SAPDataReaderEventAttendeeAgencyMap rdrTrip =
                       eventTrip.ReaderSelectByPackageID(packageID))
            {
                if (rdrTrip.DataReader != null &&
                    rdrTrip.DataReader.HasRows)
                {
                    SAPFlightTrip flightTrip =
                        new SAPFlightTrip(Config.SAPUserName, Config.SAPPassword);
                    while (rdrTrip.DataReader.Read())
                    {
                        if (flightTrip.GetList(
                                rdrTrip.CustomerNumber.Trim(),
                                rdrTrip.AgencyNumber.Trim()))
                        {
                            SAPServices.SAP_FLIGHTTRIPLIST.BAPISTRDAT[] _bapiFlightTripList =
                                flightTrip._bapiFlightTripList;

                            foreach (SAPServices.SAP_FLIGHTTRIPLIST.BAPISTRDAT _bapiFlightTrip in _bapiFlightTripList)
                            {
                                if (_bapiFlightTrip.TRIPNUMBER != rdrTrip.TripNumber.Trim())
                                {
                                    continue;
                                }
                                statList.AdultAgeStat  += _bapiFlightTrip.NUMADULT;
                                statList.ChildAgeStat  += _bapiFlightTrip.NUMCHILD;
                                statList.InfantAgeStat += _bapiFlightTrip.NUMINFANT;
                                switch (_bapiFlightTrip.CLASS)
                                {
                                case "Y":
                                    statList.FirstClassStat++;
                                    break;

                                case "C":
                                    statList.BusinessClassStat++;
                                    break;

                                case "F":
                                    statList.EconomyClassStat++;
                                    break;
                                }
                            }
                        }
                    } //while (rdrTrip.DataReader.Read());
                }
            }
            #endregion

            using (SAPDataReaderEventAttendee rdrEventAttendee =
                       eventAttendee.ReaderSelectByPackageID(packageID))
            {
                if (rdrEventAttendee.DataReader != null &&
                    rdrEventAttendee.DataReader.HasRows)
                {
                    while (rdrEventAttendee.DataReader.Read())
                    {
                        //location demographics
                        if (customerList.ContainsKey(rdrEventAttendee.CustomerNumber.Trim()))
                        {
                            string location = customerList[rdrEventAttendee.CustomerNumber.Trim()].ToUpper();

                            if (locationCount.ContainsKey(location))
                            {
                                locationCount[location]++;
                            }
                            else
                            {
                                locationCount.Add(location, 1);
                            }
                        }
                    } //while (rdrEventAttendee.DataReader.Read());
                }
            }

            Population populate = null;

            if (locationCount.Count > 0)
            {
                populate = new Population();

                Population.PopulationTableDataTable dt =
                    populate.PopulationTable;

                foreach (KeyValuePair <string, int> kvp in locationCount)
                {
                    dt.AddPopulationTableRow(
                        kvp.Key,
                        kvp.Value);
                }
            }

            statList.LocationStat = populate;

            return(statList);
        }
Пример #4
0
        static TableLayout CreateTableReport(View view, StatisticList statList)
        {
            TableLayout.LayoutParams fillParams = new TableLayout.LayoutParams(ViewGroup.LayoutParams.FillParent, ViewGroup.LayoutParams.FillParent, 1.0f);
            TableLayout tblLayout = new TableLayout(view.Context);

            tblLayout.LayoutParameters  = fillParams;
            tblLayout.StretchAllColumns = true;

            TableRow rowHeader = new TableRow(view.Context);

            rowHeader.SetBackgroundResource(Resource.Drawable.actionbar_background);

            TextView tvItemKategH = new TextView(view.Context);

            tvItemKategH.Text = view.Resources.GetText(Resource.String.tvHeaderItemKategory);
            SetHeaderCellStyle(tvItemKategH);
            rowHeader.AddView(tvItemKategH);

            TextView tvAmountCurrH = new TextView(view.Context);

            tvAmountCurrH.Text    = DateTime.Now.ToString("MMM yyyy");
            tvAmountCurrH.Gravity = GravityFlags.Right;
            SetHeaderCellStyle(tvAmountCurrH);
            rowHeader.AddView(tvAmountCurrH);

            TextView tvAmountPrevH = new TextView(view.Context);

            tvAmountPrevH.Text    = DateTime.Now.AddYears(-1).ToString("MMM yyyy");
            tvAmountPrevH.Gravity = GravityFlags.Right;
            SetHeaderCellStyle(tvAmountPrevH);
            rowHeader.AddView(tvAmountPrevH);

            tblLayout.AddView(rowHeader);

            foreach (Statistic st in statList)
            {
                TableRow row = new TableRow(view.Context);
                row.SetBackgroundResource(Resource.Drawable.button_selector);

                TextView tvItemKateg = new TextView(view.Context);
                tvItemKateg.Text = st.ItemKategDesc;
                StatisticTabMonthly.SetCellStyle(tvItemKateg);
                row.AddView(tvItemKateg);

                TextView tvAmountCurr = new TextView(view.Context);
                tvAmountCurr.Gravity = GravityFlags.Right;
                tvAmountCurr.Text    = st.AmountCurrText;
                StatisticTabMonthly.SetCellStyle(tvAmountCurr);
                row.AddView(tvAmountCurr);

                TextView tvAmountPrev = new TextView(view.Context);
                tvAmountPrev.Gravity = GravityFlags.Right;
                tvAmountPrev.Text    = st.AmountPrevText;
                StatisticTabMonthly.SetCellStyle(tvAmountPrev);
                row.AddView(tvAmountPrev);

                tblLayout.AddView(row);
            }

            return(tblLayout);
        }