Esempio n. 1
0
        public BussinessDistrictReport AnalysisBussinessDistricReport(string sessionId, double log, double lat)
        {
            UserInformation user = SessionHelpers.Validate(sessionId);

            if (user == null)
            {
                return(null);
            }
            BussinessDistrictReport report = new BussinessDistrictReport();

            report.userId               = user.userId;
            report.longitude            = log;
            report.latitude             = lat;
            report.reportId             = 1;
            report.trafficAccessibility = OracleHelpers.TrafficAccessibilityPointQuery(log, lat, 1000) * 5 + OracleHelpers.TrafficAccessibilityPointQuery(log, lat, 2000);
            report.competitiveness      = OracleHelpers.CompetitivenessPointQuery(log, lat);
            report.date = DateTime.Now;
            return(report);
        }
Esempio n. 2
0
        public BussinessDistrictReport GetBussinessDistricReportByReportID(string sessionId, int reportId)
        {
            UserInformation user = GetSession(sessionId).userInformation;

            if (user == null)
            {
                return(null);
            }
            BussinessDistrictReport report = new BussinessDistrictReport();
            string           oracleSpatialAdminUsername = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_ADMIN_DB_USERNAME"];
            string           oracleSpatialAdminPassword = earthfusion_backend.Globals.config["EARTH_FUSION_SPATIAL_ADMIN_DB_PASSWORD"];
            OracleConnection conn        = OracleHelpers.GetOracleConnection(oracleSpatialAdminUsername, oracleSpatialAdminPassword, false);
            string           QueryString = ("select * from nemo.BussinessDistricReport where user_id=" + user.userId).ToString();

            Logging.Info("GetBussinessDistricReportByReportID", "Constructed query: " + QueryString);

            // constructs command from string
            OracleCommand command = new OracleCommand(QueryString, conn);

            // open db connection
            conn.Open();

            // then, executes the data reader
            OracleDataReader reader = command.ExecuteReader();

            if (reader.RowSize == 0)
            {
                return(null);
            }
            try
            {
                /*
                 *
                 *  CREATE  TABLE nemo.BussinessDistricReport
                 *  (
                 *      user_id int,
                 *      bd_report_id int,
                 *      bd_report_log float,
                 *      bd_report_lat float,
                 *      bd_report_time date,
                 *      bd_competitiveness int,
                 *      bd_traffic_accessibility  int,
                 *      PRIMARY KEY(bd_report_id)
                 *
                 *  )
                 */
                while (reader.Read())
                {
                    report.userId               = reader.GetInt32(0);
                    report.reportId             = reader.GetInt32(1);
                    report.longitude            = reader.GetFloat(2);
                    report.latitude             = reader.GetFloat(3);
                    report.date                 = reader.GetDateTime(4);
                    report.competitiveness      = reader.GetInt32(5);
                    report.trafficAccessibility = reader.GetInt32(6);
                }
            }
            finally
            {
                // always call Close when done reading.
                reader.Close();
            }
            conn.Close();
            return(report);
        }