public static bool CheckCampainLogByCampaingIdAndMobile(int CampaignId, string Mobile)
        {
            bool IsMessageSent = false;
            List <CampaignLogDTO> CampaignLogDTOList = new List <CampaignLogDTO>();

            CampaignLogDTOList = CampaignLogService.GetCampaignLogListByCampaignIdAndMobile(CampaignId, Mobile);
            if (CampaignLogDTOList.Count() > 0)
            {
                IsMessageSent = true;
            }
            else
            {
                IsMessageSent = false;
            }

            //if (CampaignLogDTOList != null)
            //        {
            //            foreach (var item in CampaignLogDTOList)
            //            {

            //            }
            //        }


            return(IsMessageSent);
        }
        public static String SplitMobile(string Mobile, CampaignDTO CampaignDTO)
        {
            string result = "";

            try
            {
                string finalstring = "";

                // Input string contain separators.
                string value1 = Mobile;

                char[] delimiter1 = new char[] { ',', ';' };   // <-- Split on these
                // ... Use StringSplitOptions.RemoveEmptyEntries.
                string[] array2 = value1.Split(delimiter1,
                                               StringSplitOptions.RemoveEmptyEntries);

                //Console.WriteLine();
                foreach (string mobile in array2)
                {
                    Console.WriteLine(mobile);
                    bool isMessageSent = CheckCampainLogByCampaingIdAndMobile(CampaignDTO.Id, Mobile);

                    ClientDTO ClientDTO = new ClientDTO();
                    ClientDTO = ClientService.GetById(CampaignDTO.ClientId);

                    //SMSGatewayDTO SMSGatewayDTO = new SMSGatewayDTO();
                    //SMSGatewayDTO = SMSGatewayService.GetById(ClientDTO.SMSGatewayId);

                    if (isMessageSent == false)
                    {
                        Console.Write("Send SMS");
                        // Check the Message required credits and actual client credits
                        string message = "";
                        CampaignDTO.Message = CampaignService.GetById(CampaignDTO.Id).Message;
                        //// macros

                        List <Macros> MacrosList = Enum.GetValues(typeof(Macros)).Cast <Macros>().ToList();
                        ContactDTO    ContactDTO = new ContactDTO();
                        ContactDTO = ContactService.GetContactByMobileNumberAndClientId(mobile, CampaignDTO.ClientId);

                        if (MacrosList.Count() > 0)
                        {
                            foreach (var item in MacrosList)
                            {
                                if (item.ToString() == "FirstName")
                                {
                                    string FirstName = "";
                                    FirstName           = CommonService.GetFirstname(ContactDTO.Name);
                                    CampaignDTO.Message = CampaignDTO.Message.Replace("[" + item.ToString() + "]", FirstName);
                                }

                                if (item.ToString() == "LastName")
                                {
                                    string LastName = "";
                                    LastName = CommonService.GetLastname(ContactDTO.Name);

                                    CampaignDTO.Message = CampaignDTO.Message.Replace("[" + item.ToString() + "]", LastName);
                                }
                            }

                            message = CampaignDTO.Message;

                            CampaignDTO.Message = ReformatMsg(message);
                            int SMSMsgCount = GetMessageCount(message);


                            if (ClientDTO.SMSCredit >= SMSMsgCount)
                            {
                                if (CampaignLogService.GetCampaignLogListByCampaignIdAndMobile(CampaignDTO.Id, mobile).Count != 0)
                                {
                                    continue;
                                }

                                //CampaignDTO.Message
                                string sender = "";
                                if (ClientDTO.SenderCode != null && ClientDTO.SenderCode != "")
                                {
                                    sender = ClientDTO.SenderCode;
                                }
                                else
                                {
                                    sender = "022751";
                                }

                                ActualSmsSend(mobile, CampaignDTO.Message, sender, CampaignDTO, ClientDTO);
                            }
                            else
                            {
                                goto nextprocess;
                            }
                        }

                        //CampaignDTO.Message = ReformatMsg(message);
                        //int SMSMsgCount = GetMessageCount(message);

                        //if (ClientDTO.SMSCredit >= SMSMsgCount)
                        //{
                        //     //CampaignDTO.Message
                        //    ActualSmsSend(mobile, CampaignDTO.Message, SMSGatewayDTO.Name, CampaignDTO, ClientDTO);

                        //}
                        //else
                        //{
                        //    goto nextprocess;
                        //}
                    }
                    else
                    {
                    }
                }

                // Modify Campaign IsSent status
                CampaignDTO.IsSent  = true;
                CampaignDTO.Message = CampaignService.GetById(CampaignDTO.Id).Message;
                CampaignService.EditCampaignFromBackend(CampaignDTO);

nextprocess:
                result = finalstring;
            }

            catch (Exception ex)
            {
                result = "";

                using (FileStream file = new FileStream(Directory.GetCurrentDirectory() + "\\msgBlasterBackendService_Log.txt", FileMode.Append, FileAccess.Write))
                {
                    StreamWriter streamWriter = new StreamWriter(file);
                    streamWriter.WriteLine(System.DateTime.Now + " - " + "  SplitMobile()" + " - " + ex.Message);
                    streamWriter.Close();
                }
            }
            return(result);
        }