示例#1
0
        public void Get_carriers_by_QuoteID(string QuoteID, out List <AES_API_info> quote_carriers)
        {
            quote_carriers = new List <AES_API_info>();
            try
            {
                using (SqlConnection conn = new SqlConnection(AppCodeConstants.connStringRater2009))
                {
                    #region SQL

                    string sql = string.Concat("SELECT CarrierDisplayName, TotalPrice ",

                                               "FROM SQL_STATS_GCM_LTL_QUOTES ",

                                               "WHERE ID=", QuoteID, " ",
                                               "ORDER BY TotalPrice");

                    #endregion

                    //DB.LogGenera("Get_carriers_by_QuoteID", "sql", sql);

                    using (SqlCommand command = new SqlCommand())
                    {
                        command.Connection  = conn;
                        command.CommandText = sql;
                        conn.Open();
                        using (SqlDataReader reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                AES_API_info api_info = new AES_API_info();

                                if (reader["CarrierDisplayName"] != DBNull.Value)
                                {
                                    api_info.CarrierDisplayName = reader["CarrierDisplayName"].ToString();
                                }
                                if (reader["TotalPrice"] != DBNull.Value)
                                {
                                    api_info.Rate = string.Format("{0:0.00}", (double)reader["TotalPrice"]);
                                }

                                quote_carriers.Add(api_info);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                DB.LogGenera("get from sql_ltl_quotes", "Get_booking_info_by_booking_key", e.ToString());
            }
        }
示例#2
0
        public string Build_booking_response(string code, string message, ref string PNW, ref AES_API_info api_info)
        {
            string freight_class = "";

            if (api_info.m_lPiece != null && api_info.m_lPiece.Length > 0)
            {
                freight_class = api_info.m_lPiece[0].FreightClass;
                DB.LogGenera("Build_booking_response", "freight_class", freight_class);
            }
            else
            {
                // Do nothing
                DB.LogGenera("Build_booking_response", "freight_class", "api_info.m_lPiece was null or empty");
            }

            //

            int sub_nmfc;
            var repo = new gcmAPI.Models.Public.LTL.Repository();

            repo.Get_sub_nmfc_by_density(ref api_info, out sub_nmfc);
            DB.LogGenera("Build_booking_response", "sub_nmfc", sub_nmfc.ToString());

            StringBuilder json = new StringBuilder();

            try
            {
                json.Append("{ \"Notification\":{");
                //json.Append("\"RateServiceNotification\":{");
                //json.Append("\"Code\":0,");
                json.Append(string.Concat("\"Code\":", code, ","));
                json.Append(string.Concat("\"Message\":\"", message, "\"},"));

                //json.Append("\"BOLURL\":{},");
                //json.Append("\"ICURL\":{},");
                //json.Append("\"ShipmentId\":{}");
                json.Append(string.Concat("\"PNW\":\"", PNW, "\","));
                json.Append(string.Concat("\"NMFC\":\"18260.", sub_nmfc, "\","));
                json.Append(string.Concat("\"Freight Class\":\"", freight_class, "\""));

                json.Append(" }");
                return(json.ToString());
            }
            catch (Exception e)
            {
                DB.LogGenera(iam, "Build_error_response", e.ToString());
                return("error");
            }
        }