public bool Rabbit_Send(string message, string queue, string hostname, out string error)
        {
            error = string.Empty;
            try
            {
                string strRabbitMQUrl           = "";
                string strRabbitMQRequestQueue  = "";
                string strRabbitMQResponseQueue = "";
                // Get HostName //
                Get_Data_Utility        objGet    = new Get_Data_Utility();
                List <tbl_config_value> lstConfig = objGet.Get_Cofig_Details("RABITMQWipro");
                foreach (var ob in lstConfig)
                {
                    strRabbitMQUrl           = ob.configstring;
                    strRabbitMQRequestQueue  = ob.RequestQueue;
                    strRabbitMQResponseQueue = ob.ResponseQueue;
                }
                if (!string.IsNullOrEmpty(strRabbitMQUrl))
                {
                    //queue = queue.ToLower() == "response" ? strRabbitMQResponseQueue : strRabbitMQRequestQueue;
                    queue    = strRabbitMQRequestQueue;// strRabbitMQRequestQueue;
                    hostname = strRabbitMQUrl;
                    var factory = new ConnectionFactory()
                    {
                        HostName = hostname
                    };
                    string UserName = ConfigurationManager.AppSettings["r_username"];
                    string Password = ConfigurationManager.AppSettings["r_password"];
                    factory.UserName = UserName;
                    factory.Password = Password;

                    using (var connection = factory.CreateConnection())

                        using (var channel = connection.CreateModel())
                        {
                            channel.QueueDeclare(queue: queue, durable: true, exclusive: false, autoDelete: false, arguments: null);
                            var body = Encoding.UTF8.GetBytes(message);
                            channel.BasicPublish(exchange: "", routingKey: queue, basicProperties: null, body: body);
                        }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message.ToString();
                //return false;
                throw ex;
            }
        }
 public bool Receive1(string queue, out string data, out string error)
 {
     error = string.Empty;
     data  = string.Empty;
     try
     {
         string strRabbitMQUrl           = "";
         string strRabbitMQRequestQueue  = "";
         string strRabbitMQResponseQueue = "";
         // Get HostName //
         Get_Data_Utility        objGet    = new Get_Data_Utility();
         List <tbl_config_value> lstConfig = objGet.Get_Cofig_Details("RABITMQ");
         foreach (var ob in lstConfig)
         {
             strRabbitMQUrl           = ob.configstring;
             strRabbitMQRequestQueue  = ob.RequestQueue;
             strRabbitMQResponseQueue = ob.ResponseQueue;
         }
         if (!string.IsNullOrEmpty(strRabbitMQUrl))
         {
             queue = strRabbitMQResponseQueue;
             using (IConnection connection = new ConnectionFactory().CreateConnection())
             {
                 using (IModel channel = connection.CreateModel())
                 {
                     channel.QueueDeclare(queue, true, false, false, null);
                     var            consumer = new EventingBasicConsumer(channel);
                     BasicGetResult result   = channel.BasicGet(queue, true);
                     if (result != null)
                     {
                         data =
                             Encoding.UTF8.GetString(result.Body);
                         Console.WriteLine(data);
                     }
                 }
             }
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         error = ex.Message.ToString();
         throw ex;
         //return false;
     }
 }
        public int Execute_Excel_InitialTracker()
        {
            int         Value  = 0;
            DML_Utility objDML = new DML_Utility();

            try
            {
                string strFilePath = "";
                string strFileName = "";
                // Get HostName //
                Get_Data_Utility        objGet    = new Get_Data_Utility();
                List <tbl_config_value> lstConfig = objGet.Get_Cofig_Details("MISDATA");
                foreach (var ob in lstConfig)
                {
                    strFilePath = ob.configstring;
                    strFileName = ob.FileName;
                }

                string path = strFilePath + strFileName; //
                //FilePath_Container.FilePath + FilePath_Container.FileName_InitationTracker;
                if (File.Exists(path))
                {
                    DataTable dt = Read_Excel("Sheet1", path);
                    if (dt.Rows.Count > 0)
                    {
                        // Add Rows Count into table //
                        long rowcount = dt.Rows.Count;
                        objDML.Add_Rows_Count_Data(path, rowcount);
                        Value = addData(dt);
                    }
                    else
                    {
                        Value = 9; // No data exist
                    }
                }
            }
            catch (Exception ex)
            {
                Value = -1;
                ////// Exception Log ///
                int iException = objDML.Add_Exception_Log(ex.Message, "");
            }
            return(Value);
        }
        public bool Receive(string queue, out string data, out string error)
        {
            error = string.Empty;
            try
            {
                string strRabbitMQUrl           = "";
                string strRabbitMQRequestQueue  = "";
                string strRabbitMQResponseQueue = "";
                data = string.Empty;
                // Get HostName //
                Get_Data_Utility objGet = new Get_Data_Utility();
                DML_Utility      objDML = new DML_Utility();

                List <tbl_config_value> lstConfig = objGet.Get_Cofig_Details("RABITMQWipro");
                foreach (var ob in lstConfig)
                {
                    strRabbitMQUrl           = ob.configstring;
                    strRabbitMQRequestQueue  = ob.RequestQueue;
                    strRabbitMQResponseQueue = ob.ResponseQueue;
                }
                if (!string.IsNullOrEmpty(strRabbitMQUrl))
                {
                    //queue = queue.ToLower() == "response" ? strRabbitMQResponseQueue : strRabbitMQRequestQueue;
                    queue = strRabbitMQResponseQueue;// strRabbitMQRequestQueue;
                    //hostname = strRabbitMQUrl;
                    var factory = new ConnectionFactory()
                    {
                        HostName = strRabbitMQUrl
                    };
                    string UserName = ConfigurationManager.AppSettings["r_username"];
                    string Password = ConfigurationManager.AppSettings["r_password"];
                    factory.UserName = UserName;
                    factory.Password = Password;
                    //objDML.Add_Exception_Log(strRabbitMQUrl, "");

                    using (var connection = factory.CreateConnection())

                        using (var channel = connection.CreateModel())
                        {
                            //channel.QueueDeclare(queue: queue, durable: true, exclusive: false, autoDelete: false, arguments: null);
                            //var body = Encoding.UTF8.GetBytes(message);
                            //channel.BasicPublish(exchange: "", routingKey: queue, basicProperties: null, body: body);
                            // objDML.Add_Exception_Log(queue, "");
                            channel.QueueDeclare(queue, true, false, false, null);
                            var            consumer = new EventingBasicConsumer(channel);
                            BasicGetResult result   = channel.BasicGet(queue, true);
                            // objDML.Add_Exception_Log(result.Body.ToString(), "");

                            if (result != null)
                            {
                                data =
                                    Encoding.UTF8.GetString(result.Body);
                                //Console.WriteLine(data);
                            }
                        }
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                error = ex.Message.ToString();
                //return false;
                throw ex;
            }
        }
        public string Write_JSON_TO_Download()
        {
            bool             ret    = false;
            string           output = "";
            string           error  = "";
            DML_Utility      objDML = new DML_Utility();
            Get_Data_Utility objGet = new Get_Data_Utility();

            try
            {
                //objDML.Add_Exception_Log(ts.TotalMinutes.ToString(), "");
                // Check Last Request //
                int Flag = 1;
                List <tbl_request_details> lstObj = new List <tbl_request_details>();
                lstObj = objGet.Get_Last_Request();

                if (lstObj.Count > 0)
                {
                    double   timeMinutes = 0;
                    DateTime dtReq       = (DateTime)lstObj[0].createdOn;
                    //DateTime dt = System.DateTime.Now;
                    DateTime dt = System.DateTime.Now.AddMinutes(0);
                    TimeSpan ts = dt - dtReq;
                    List <tbl_config_value> lstConfig = objGet.Get_Cofig_Details("DOWNLOADREQUEST");
                    foreach (var ob in lstConfig)
                    {
                        double.TryParse(ob.configstring, out timeMinutes);
                    }
                    timeMinutes = timeMinutes <= 0 ? 59 : timeMinutes;
                    //int iException1 = objDML.Add_Exception_Log(ts.TotalMinutes.ToString(), dt.ToString());
                    if (ts.TotalMinutes > timeMinutes)
                    {
                        Flag = 1;
                    }
                    else
                    {
                        Flag = 0;
                    }
                }

                if (Flag > 0)
                {
                    string MessageId = Guid.NewGuid().ToString();
                    string ServiceId = FilePath_Container.ServiceId_Download.ToString();// "DOWNLOAD";// Guid.NewGuid().ToString();
                    ///////////////////////// Add Json request into database //////////////
                    JsonCreater JsonCreater = new Read_File_Processor.JsonCreater();
                    string      json        = JsonCreater.getDownload(MessageId, ServiceId);
                    int         iDML        = objDML.Add_Request_Json_Detail(MessageId, ServiceId, json); // Add_Request_Json(MessageId, "DOWNLOAD", json);
                    ///////////////////////// Add Json request into Rabbit MQ //////////////
                    if (iDML == 1)
                    {
                        ret    = Write_JSON_TO_RABBIT_MQ(json);
                        output = ret ? "Success" : "Failed";
                    }
                }
                else
                {
                    // READ RESPONSE QUEUE //
                    Read_Response();
                }
            }
            catch (Exception ex)
            {
                output = "exception : " + ex.Message.ToString();
                ////// Exception Log ///
                //DML_Utility objDML = new DML_Utility();
                //int iException = objDML.Add_Exception_Log(ex.Message, "Write_JSON_TO_Download");
            }
            return(output);
        }