コード例 #1
0
        public DataTable TrackVehicle(vehicledetails l)
        {
            // int Status = 1;
            LogTraceWriter traceWriter  = new LogTraceWriter();
            SqlConnection  conn         = new SqlConnection();
            DataTable      currTripList = new DataTable();
            StringBuilder  str          = new StringBuilder();

            try
            {
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "TrackVehicle....");

                str.Append("Mobilenumber:" + l.PMobNo + ",");
                str.Append("Latitude:" + l.latitude + ",");
                str.Append("Longitude:" + l.longitude + ",");


                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Input sent...." + str.ToString());
                conn.ConnectionString = ConfigurationManager.ConnectionStrings["btposdb"].ToString();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "PSTrackVehicleHistory";

                cmd.Connection = conn;


                SqlParameter MobileNumber = new SqlParameter("@Mobilenumber", SqlDbType.VarChar, 50);
                MobileNumber.Value = l.PMobNo;
                cmd.Parameters.Add(MobileNumber);

                SqlParameter Lat = new SqlParameter("@Latitude", SqlDbType.Float);
                Lat.Value = l.latitude;
                cmd.Parameters.Add(Lat);

                SqlParameter Lng = new SqlParameter("@Longitude", SqlDbType.Float);
                Lng.Value = l.longitude;
                cmd.Parameters.Add(Lng);

                SqlDataAdapter db = new SqlDataAdapter(cmd);
                db.Fill(currTripList);
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "TrackVehicle successful....");


                if (currTripList.Rows.Count > 0)
                {
                    traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "TrackVehicle Output...." + currTripList.Rows[0]["BNo"].ToString());
                }
                else
                {
                    traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "TrackVehicle Output....No bookings found");
                }
            }
            catch (Exception ex)
            {
                traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "TrackVehicle...." + ex.Message.ToString());
                //throw ex;
                //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
                currTripList.Columns.Add("Code");
                currTripList.Columns.Add("description");
                DataRow dr = currTripList.NewRow();
                dr[0] = "ERR001";
                dr[1] = ex.Message;
                currTripList.Rows.Add(dr);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }

            return(currTripList);
        }
コード例 #2
0
        public DataTable VehicleCreation(vehicledetails v)
        {
            LogTraceWriter traceWriter = new LogTraceWriter();
            SqlConnection  conn        = new SqlConnection();
            StringBuilder  str         = new StringBuilder();
            DataTable      dt          = new DataTable();

            try
            {
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Vehicles....");

                str.Append("RegistrationNo:" + v.RegistrationNo + ",");
                str.Append("VehicleGroupId:" + v.VehicleGroupId + ",");
                str.Append("Country:" + v.CountryId + ",");
                str.Append("FleetOwnerId:" + v.FleetOwnerCode + ",");
                str.Append("VehicleType:" + v.VehicleTypeId + ",");
                str.Append("VehicleCode:" + v.VehicleCode + ",");

                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Input sent...." + str.ToString());

                conn.ConnectionString = ConfigurationManager.ConnectionStrings["btposdb"].ToString();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.CommandText = "HVInsUpdVehicles";
                cmd.Connection  = conn;


                SqlParameter se = new SqlParameter("@flag", SqlDbType.VarChar);
                se.Value = v.flag;
                cmd.Parameters.Add(se);

                SqlParameter s = new SqlParameter("@Id", SqlDbType.Int);
                s.Value = v.Id;
                cmd.Parameters.Add(s);

                SqlParameter i = new SqlParameter("@VID", SqlDbType.Int);
                i.Value = v.VID;
                cmd.Parameters.Add(i);

                SqlParameter cd = new SqlParameter("@CompanyId", SqlDbType.Int);
                cd.Value = v.CompanyId;
                cmd.Parameters.Add(cd);

                SqlParameter n = new SqlParameter("@RegistrationNo", SqlDbType.VarChar, 50);
                n.Value = v.RegistrationNo;
                cmd.Parameters.Add(n);

                SqlParameter cn = new SqlParameter("@ChasisNo", SqlDbType.VarChar, 50);
                cn.Value = v.ChasisNo;
                cmd.Parameters.Add(cn);

                SqlParameter en = new SqlParameter("@Engineno", SqlDbType.VarChar, 50);
                en.Value = v.Engineno;
                cmd.Parameters.Add(en);

                SqlParameter oid = new SqlParameter("@FleetOwnerId", SqlDbType.Int);
                oid.Value = v.FleetOwnerCode;
                cmd.Parameters.Add(oid);

                SqlParameter vt = new SqlParameter("@VehicleType", SqlDbType.VarChar, 50);
                vt.Value = v.VehicleTypeId;
                cmd.Parameters.Add(vt);

                SqlParameter vv = new SqlParameter("@VehicleModelId", SqlDbType.Int);
                vv.Value = v.VehicleModelId;
                cmd.Parameters.Add(vv);

                SqlParameter vg = new SqlParameter("@VehicleGroupId", SqlDbType.VarChar, 50);
                vg.Value = v.VehicleGroupId;
                cmd.Parameters.Add(vg);

                SqlParameter wg = new SqlParameter("@ModelYear", SqlDbType.VarChar, 5);
                wg.Value = v.ModelYear;
                cmd.Parameters.Add(wg);

                SqlParameter ac = new SqlParameter("@HasAC", SqlDbType.Int);
                ac.Value = v.HasAC;
                cmd.Parameters.Add(ac);

                SqlParameter sid = new SqlParameter("@StatusId", SqlDbType.Int);
                sid.Value = v.StatusId;
                cmd.Parameters.Add(sid);

                SqlParameter isv = new SqlParameter("@IsVerified", SqlDbType.Int);
                isv.Value = v.IsVerified;
                cmd.Parameters.Add(isv);

                SqlParameter isDriverOwned = new SqlParameter("@isDriverOwned", SqlDbType.Int);
                isDriverOwned.Value = v.isDriverOwned;
                cmd.Parameters.Add(isDriverOwned);


                SqlParameter vcode = new SqlParameter("@VehicleCode ", SqlDbType.VarChar, 10);
                vcode.Value = v.VehicleCode;
                cmd.Parameters.Add(vcode);

                SqlParameter ctr = new SqlParameter("@Country", SqlDbType.VarChar, 50);
                ctr.Value = v.CountryId;
                cmd.Parameters.Add(ctr);

                BusinessAppUserController obj = new BusinessAppUserController();
                obj.SendNotificationToAdmin(v.RegistrationNo, v.change, v.type);



                SqlDataAdapter da = new SqlDataAdapter(cmd);
                da.Fill(dt);
                traceWriter.Trace(Request, "0", TraceLevel.Info, "{0}", "Vehicles successful....");
            }
            catch (Exception ex)
            {
                traceWriter.Trace(Request, "0", TraceLevel.Error, "{0}", "Vehicles...." + ex.Message.ToString());
                //throw ex;
                //throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message));
                dt.Columns.Add("Code");
                dt.Columns.Add("description");
                DataRow dr = dt.NewRow();
                dr[0] = "ERR001";
                dr[1] = ex.Message;
                dt.Rows.Add(dr);
            }
            finally
            {
                conn.Close();
                conn.Dispose();
                SqlConnection.ClearPool(conn);
            }
            return(dt);
        }