} // public DataTable GetDeliveries()

        // Deletes a delivery item from db.deliveries
        public void UpdateDelivery(DeliveryModels.UpdateDelivery Delivery)
        {
            try
            {
                using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["DeliverySystem"].ToString()))
                {
                    cnn.Open();

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cnn;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "dbo.editdelivery";

                        cmd.Parameters.Add("@deliveriesId", SqlDbType.Int, -1).Value  = Delivery.deliveriesId;
                        cmd.Parameters.Add("@from", SqlDbType.VarChar, 50).Value      = Delivery.from;
                        cmd.Parameters.Add("@to", SqlDbType.VarChar, 50).Value        = Delivery.to;
                        cmd.Parameters.Add("@message", SqlDbType.VarChar, 8000).Value = Delivery.message;
                        cmd.Parameters.Add("active", SqlDbType.Bit, -1).Value         = Delivery.active;

                        cmd.ExecuteNonQuery();
                    } // using (SqlCommand cmd = new SqlCommand())
                }     // using(SqlConnection cnn = new SqlConnection
            }         // try
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
            catch (Exception ex)
            {
                throw ex;
            }
        } // public void insertDelivery(Models.DeliveryModels.Delivery delivery)
示例#2
0
        public ActionResult Index()
        {
            DeliveryModels.UpdateDelivery ud = new DeliveryModels.UpdateDelivery();
            string Msg = string.Empty;

            if (!string.IsNullOrEmpty(Request.QueryString["ActiveDeliveries"]))
            {
                ud  = UIDeliveryHelper.GetDelivery(Convert.ToInt32(Request.QueryString["ActiveDeliveries"]));
                Msg = UIDeliveryHelper.Message;
            }

            DeliveryModels model = new DeliveryModels
            {
                Deliveries   = UIDeliveryHelper.GetDelTypes(),
                Message      = Msg,
                deliveriesId = ud.deliveriesId,
                deliveryId   = ud.deliveryId,
                from         = ud.from,
                to           = ud.to,
                message      = ud.message,
                active       = ud.active,
                TableHeader  = string.IsNullOrEmpty(Request.Form["ActiveDeliveries"]) ? Settings.CreateDelivery : Settings.UpdateDelivery
            };

            return(View(model));
        }
示例#3
0
 public void UpdateDelivery(DeliveryModels.UpdateDelivery Delivery)
 {
     using (DeliveryHelper UpdateDel = new DeliveryHelper())
     {
         // If the from field is empty then we need to de-activate the delivery.
         if (string.IsNullOrEmpty(Delivery.from))
         {
             UpdateDel.DeleteDelivery(Delivery.deliveriesId);
         }
         else
         {
             UpdateDel.UpdateDelivery(Delivery);
         }
     }
 }
        public DeliveryModels.UpdateDelivery GetDelivery(int DeliveriesId)
        {
            DeliveryModels.UpdateDelivery Delivery = new DeliveryModels.UpdateDelivery();
            //DeliveryModels.GetDeliveries DelItems = null;

            try
            {
                using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["DeliverySystem"].ToString()))
                {
                    cnn.Open();

                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.Connection  = cnn;
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.CommandText = "dbo.getdelivery";

                        cmd.Parameters.Add("@deliveriesId", SqlDbType.Int, -1).Value = DeliveriesId;

                        using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                        {
                            while (rdr.Read())
                            {
                                Delivery = new DeliveryModels.UpdateDelivery();

                                Delivery.deliveriesId = Convert.ToInt32(rdr["deliveriesid"]);
                                Delivery.deliveryId   = Convert.ToInt32(rdr["deliveryid"]);
                                Delivery.from         = rdr["from"].ToString();
                                Delivery.to           = rdr["to"].ToString();
                                Delivery.message      = rdr["message"].ToString();
                                Delivery.active       = Convert.ToBoolean(rdr["active"]);
                            }
                        } // using (IDataReader rdr = cmd.ExecuteReader(CommandBehavior.CloseConnection))
                    }     // using(SqlCommand cmd = new SqlCommand())
                }         // using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["DeliverySystem"].ToString()))
            }
            catch (SqlException sqlex)
            {
                throw sqlex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Delivery);
        }
示例#5
0
        public static DeliveryModels.UpdateDelivery GetDelivery(int DeliveriesId)
        {
            themessage = string.Empty;

            DeliveryModels.UpdateDelivery retVal = null;

            HttpWebRequest webRequest    = null;
            int            intStatusCode = 0;
            string         strStatus     = string.Empty;

            webRequest = (HttpWebRequest)WebRequest.Create("http://localhost:50628/api/Delivery/GetDelivery/?DeliveriesId=" + DeliveriesId.ToString());

            webRequest.Method = "get";

            bool blnRetVal = false;

            Stream os = null;

            try
            {
                blnRetVal = true;

                if (os != null)
                {
                    os.Flush();
                    os.Close();
                    os = null;
                }

                // if blnRetVal is true then sending was successful.
                string Result = string.Empty;

                if (blnRetVal == true)
                {
                    //WebResponse webResponse = webRequest.GetResponse();
                    try
                    {
                        using (HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse())
                        {
                            if (webResponse == null)
                            {
                                themessage = Settings.APIGenericErrorMessage;

                                Exception exInner = new Exception("Unable to get a response back for a posting " + 0.ToString() + "\r\nFeedID " + 0.ToString() + "\r\nThe webResponse object is null");
                                throw new Exception(string.Empty, exInner);
                            }

                            intStatusCode = (int)webResponse.StatusCode;
                            strStatus     = webResponse.StatusDescription;

                            using (StreamReader sr = new StreamReader(webResponse.GetResponseStream()))
                            {
                                retVal = Json.Decode <DeliveryModels.UpdateDelivery>(sr.ReadToEnd());
                            }
                        }
                    }
                    catch (WebException wex)
                    {
                        HttpWebResponse strGetErrorResponse = ((HttpWebResponse)wex.Response);
                        Stream          stream = null;

                        int    intCode        = 0;
                        string result         = string.Empty;
                        string strDescription = string.Empty;

                        try
                        {
                            stream = strGetErrorResponse.GetResponseStream();

                            Encoding encoding = System.Text.Encoding.Default; // System.Text.Encoding.GetEncoding("utf-8");

                            StreamReader streamReader = new StreamReader(stream, encoding);

                            result = streamReader.ReadToEnd();

                            themessage = Settings.APIGenericErrorMessage;

                            intCode        = (int)strGetErrorResponse.StatusCode;
                            strDescription = strGetErrorResponse.StatusDescription;

                            // TODO: Log error.
                            //string strErrorMessage = "|ORIGINAL_SOURCE" + wex.Source + " --> Error occurred in " + CLASS_NAME + "." + PROCEDURE_NAME + "|ERRORINFOError reported from: " + CLASS_NAME + "." + PROCEDURE_NAME + "|CLASSNAME" + CLASS_NAME + "|REQEMEDIAID0" + "|REQUISITIONID0|FEEDID" + p_intAutoFeedID.ToString() + "|EMEDIAID" + p_strEmediaID + "|ERRORLEVEL2|WRITESTOPLIGHT1|FILENAME" + p_strFileName + "|PARAMUSED" + p_strParamUsed + "|PARAMTYPE16|PROCESSGUID" + p_strGuid;
                            //ClassErrors clsErr = new ClassErrors(wex.Message + strErrorMessage, wex, wex.Source);

                            /*try
                             * {
                             *  clsData.ReportError(clsErr.ErrorInfo, clsErr.Source, clsErr.Message, clsErr.LineNumber, clsErr.AfErrorNumber, clsErr.ErrorNumber, clsErr.ConnectionString, clsErr.Filename, clsErr.AutoFeedID, clsErr.EmediaID, clsErr.ReqEmediaID.ToString(), clsErr.DeliveryType, clsErr.EmailAddress, clsErr.FTPAddress, clsErr.URLAddress, clsErr.LocalCopyAdddress, clsErr.ParamUsed, clsErr.RequisitionID, clsErr.ReqEmediaID, ClassStaticData.MachineName, clsErr.StoredProcedure, clsErr.ParamType, clsErr.ErrorLevel, clsErr.WriteStopLight, string.Empty, clsErr.UsesSubID, clsErr.SubID, clsErr.ProcessGuid, clsErr.GetStackTrace, clsErr.GetStackFrames, clsErr.InnerExceptionMessage, clsErr.ExceptionType, clsErr.ColumnNumber);
                             * }
                             * catch (Exception ex2)
                             * {
                             *  ClassStaticData.EmailMessage(ClassStaticData.GetFromEmail, ClassStaticData.GetDevEmail, string.Empty, ClassStaticData.Msg_UnexpectedError, "Original error follows:\r\n\r\nFrom: " + System.Reflection.Assembly.GetExecutingAssembly().ToString() + "\r\nConnectionString: " + ClassStaticData.MASTER_SOURCE + "\r\n\r\n" + "Error Message: " + wex.Message + "\r\n\r\n" + wex.Source + "\r\n\r\nNew error follows:\r\n" + ex2.Message + "\r\n" + ex2.Source + "\r\nNew error inner exception: " + ex2.InnerException + "\r\n" + "\r\n\r\nAdditional information follows:\r\nAutoFeedID: " + clsErr.AutoFeedID.ToString() + "\r\n\r\nEmediaID: " + clsErr.EmediaID + "\r\n\r\nCIDList: " + clsErr.CIDList + "\r\n\r\nErrorTime: " + System.DateTime.Now.ToLongTimeString());
                             * }*/
                        }
                        catch (Exception ex2)
                        {
                            themessage = Settings.APIGenericErrorMessage;

                            // TODO: Log error.
                            // throw ex2;
                        }
                    }
                }

                webRequest = null;

                if (intStatusCode > 204)
                {
                    themessage = Settings.APIGenericErrorMessage;

                    // TODO: Log error.

                    /*Exception exInner = new Exception("Unable to post job " + p_intReqEmediaID.ToString() + "\r\nStatusCode " + intStatusCode.ToString() + "\r\nStatus " + strStatus + "\r\nFeedID " + p_intAutoFeedID.ToString() + "\r\nThe site has returned this error " + Result);
                     * throw new Exception(string.Empty, exInner);*/
                }

                /*Store result value here*/
            }
            finally
            {
                if (os != null)
                {
                    os.Flush();
                    os.Close();
                    os = null;
                }

                /*if (clsData != null)
                 * {
                 *  clsData.Dispose();
                 * }
                 *
                 * clsData = null;*/
            }

            webRequest = null;

            return(retVal);
        }