//Delete group contact by group id and contact id
        public static bool DeleteByGroupId(int GroupId, int ContactId)
        {
            try
            {

                GroupContactDTO GroupContactDTO = new GroupContactDTO();
                UnitOfWork uow = new UnitOfWork();
                IEnumerable<GroupContact> GroupContact = uow.GroupContactRepo.GetAll().Where(e => e.GroupId == GroupId && e.ContactId == ContactId);
                if (GroupContact != null)
                {
                    foreach (var item in GroupContact)
                    {
                        //GroupContactDTO = GetById(item.Id);
                        uow.GroupContactRepo.Delete(item.Id);
                        uow.SaveChanges();
                    }
                }
                return true;
            }
            catch
            {

                throw;
            }
        }
 public void EditGroupContact(GroupContactDTO GroupContactDTO)
 {
     try
     {
         GroupService.EditGroupContact(GroupContactDTO);
     }
     catch (Exception)
     {
         throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError)
         {
             Content = new StringContent("An error occurred, please try again or contact the administrator."),
             ReasonPhrase = "Critical Exception"
         });
     }
 }
Ejemplo n.º 3
0
        //Add contact to group contact by contact id and group id
        public static void AddContactToGroup(int ContactId, int GroupId)
        {
            try
            {
                //UnitOfWork uow = new UnitOfWork();
                //uow.GroupRepo.AddContact(GroupId, ContactId );
                //uow.SaveChanges();

                GroupContactDTO GroupContactDTO = new GroupContactDTO();
                GroupContactDTO.ContactId = ContactId;
                GroupContactDTO.GroupId = GroupId;
                GroupContactService.Create(GroupContactDTO);

            }
            catch
            {
                throw;
            }
        }
        //Create group contact
        public static GroupContactDTO Create(GroupContactDTO GroupContactDTO)
        {
            try
            {
                var GroupContact = new GroupContact();

                UnitOfWork uow = new UnitOfWork();
                GroupContact = Transform.GroupContactNewToDomain(GroupContactDTO);
                uow.GroupContactRepo.Insert(GroupContact);

                uow.SaveChanges();
                GroupContact.Id = GroupContact.Id;
                return Transform.GroupContactNewToDTO(GroupContact);

            }

            catch (Exception)
            {
                throw;
            }
        }
        public static void AddGroupToContact(int ContactId, int GroupId)
        {
            try
            {
                //UnitOfWork uow = new UnitOfWork();
                //uow.ContactRepo.AddGroup(ContactId, GroupId);
                //uow.SaveChanges();
                GroupContactDTO GroupContactDTO = new GroupContactDTO();
                GroupContactDTO.ContactId = ContactId;
                GroupContactDTO.GroupId = GroupId;

                GlobalSettings.LoggedInClientId = ContactService.GetById(ContactId).ClientId;// ContactDTO.ClientId;
                int PartnerId = ClientService.GetById(Convert.ToInt32(GlobalSettings.LoggedInClientId)).PartnerId;
                GlobalSettings.LoggedInPartnerId = PartnerId;

                GroupContactService.Create(GroupContactDTO);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 6
0
        //Delete contact from group using contact id and group id
        public static void RemoveContactFromGroup(int ContactId, int GroupId)
        {
            try
            {
                //UnitOfWork uow = new UnitOfWork();
                //uow.GroupRepo.RemoveContact(GroupId, ContactId);
                //uow.SaveChanges();

                GroupContactDTO GroupContactDTO = new GroupContactDTO();
                GroupContactDTO.ContactId = ContactId;
                GroupContactDTO.GroupId = GroupId;
                GroupContactService.DeleteByContactId(GroupContactDTO.ContactId, GroupContactDTO.GroupId);
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 7
0
        // Returns group list which have clients
        public static List<GroupContactDTO> GetGroupListWithContactPresentByClientId(int ClientId)
        {
            List<GroupContactDTO> GroupDTOList = new List<GroupContactDTO>();

            try
            {

                using (var uow = new UnitOfWork())
                {
                    IEnumerable<Group> Group = uow.GroupRepo.GetAll().Where(e => e.ClientID == ClientId).OrderBy(e => e.Name).ToList();
                    if (Group != null)
                    {
                        foreach (var item in Group)
                        {
                            GroupDTO GroupDTO = new GroupDTO();
                            GroupDTO = GetById(item.Id);
                            GroupContactDTO GroupContactDTO = new GroupContactDTO();
                            //GroupContactDTO = GetGroupContactById(GroupDTO.Id);
                            List<ContactDTO> ContactDTOList = new List<ContactDTO>();
                            ContactDTOList = GroupContactService.GetGroupIdWiseContacts(GroupDTO.Id);// GroupDTOTemp.Id

                            GroupContactDTO.ContactCount = ContactDTOList.Count();// GroupContactDTO.Contacts.Count();
                            if (ContactDTOList.Count() > 0) // GroupContactDTO.Contacts.Count
                            {
                                GroupDTOList.Add(GroupContactDTO);// (Transform.GroupContactToDTO(item));
                            }
                        }
                    }
                }

                return GroupDTOList;
            }
            //catch (LoggedInUserException)
            //{
            //    throw new System.TimeoutException();
            //}
            catch (Exception)
            {

                throw;
            }
        }
Ejemplo n.º 8
0
        //Edit Group Contact
        public static void EditGroupContact(GroupContactDTO GroupContactDTO)
        {
            try
            {
                bool IsDeleted;
                GroupContactDTO GroupDTORemoveContact = new GroupContactDTO();
                //GroupDTORemoveContact = GetGroupContactById(GroupContactDTO.Id);

                if (GroupContactDTO.UnwantedContacts != null)
                {

                    foreach (var item in GroupContactDTO.UnwantedContacts)
                    {
                        try
                        {
                            IsDeleted = GroupContactService.DeleteByGroupId(GroupContactDTO.Id, item.Id);
                            //RemoveContactFromGroup(item.Id, GroupContactDTO.Id);
                        }
                        catch
                        {
                            continue;
                        }
                    }

                }

                //if (GroupDTORemoveContact.Contacts.Count() > 0)
                //{
                //    foreach (var item in GroupDTORemoveContact.Contacts)
                //    {

                //        RemoveContactFromGroup(item.Id, GroupContactDTO.Id);
                //    }
                //}

                if (GroupContactDTO.Contacts != null)
                {
                    foreach (var item in GroupContactDTO.Contacts)
                    {
                          int contactCount = 0;

                        if (item.Groups.Count != 0)
                        {
                            foreach (var grp in item.Groups)
                            {
                                if(grp.Id == GroupContactDTO.GroupId){

                                    contactCount++;
                                }
                            }

                        }

                        if (contactCount == 0)
                        {
                            GroupContactDTO GroupContactDTOCreate = new GroupContactDTO();
                            GroupContactDTOCreate.GroupId = GroupContactDTO.Id;
                            GroupContactDTOCreate.ContactId = item.Id;
                            GroupContactService.Create(GroupContactDTOCreate);

                        }
                    }

              }

                //uow.SaveChanges();
            }
            catch
            {
                throw;
            }
        }
        //Returns Campaign paged list as per client and search with pagingInfo obect
        public static PageData<CampaignDTO> GetCampaignPagedListbyClientId(PagingInfo pagingInfo, int ClientId)
        {
            List<CampaignDTO> CampaignDTOList = new List<CampaignDTO>();
            PageData<CampaignDTO> pageList = new PageData<CampaignDTO>();

            if (pagingInfo == null)
            {
                PagingInfo PagingInfoCreated = new PagingInfo();
                PagingInfoCreated.Page = 1;
                PagingInfoCreated.Reverse = false;
                PagingInfoCreated.ItemsPerPage = 1;
                PagingInfoCreated.Search = "";
                PagingInfoCreated.TotalItem = 0;

                pagingInfo = PagingInfoCreated;
            }
            if (pagingInfo.SortBy == "")
            {
                pagingInfo.SortBy = "CreatedDate";
            }

            CampaignDTOList = GetCampaignsbyClientId(ClientId, pagingInfo.Search, pagingInfo);
            IQueryable<CampaignDTO> CampaignDTOPagedList = CampaignDTOList.AsQueryable();
            UnitOfWork uow = new UnitOfWork();
            int count = 0;

            if (pagingInfo.Search != "" && pagingInfo.Search != null)
            {
                bool IsDate = CommonService.IsDate(pagingInfo.Search);
                if (IsDate != true)
                {
                    count = 0;
                    count = uow.CampaignRepo.GetAll().Where(e => e.Name.ToLower().Contains(pagingInfo.Search.ToLower()) || e.RecipientsNumber.Contains(pagingInfo.Search) || e.RequiredCredits.ToString() == (pagingInfo.Search) || (e.ScheduledDate.ToString() != null ? (Convert.ToDateTime(e.ScheduledDate).ToString("dd-MMM-yyyy").ToLower().Contains(pagingInfo.Search.ToLower())) : false)).OrderByDescending(e => e.CreatedDate).Count();
                }
                else
                {
                    DateTime date = Convert.ToDateTime(pagingInfo.Search);
                    count = 0;
                    count = uow.CampaignRepo.GetAll().Where(e => e.CreatedDate >= date && e.CreatedDate < date.AddDays(1) || e.ScheduledDate >= date && e.ScheduledDate < date.AddDays(1)).OrderByDescending(e => e.CreatedDate).Count();

                }

            }
            else
            {
                count = uow.CampaignRepo.GetAll().Where(e => e.ClientId == ClientId).Count();
            }

            ////Sorting
            //CampaignDTOPagedList = PagingService.Sorting<CampaignDTO>(CampaignDTOPagedList, pagingInfo.SortBy, pagingInfo.Reverse);

            // paging
            if (CampaignDTOPagedList.Count() > 0)
            {
                //var ContacDTOPerPage = PagingService.Paging<CampaignDTO>(CampaignDTOPagedList, pagingInfo.ItemsPerPage, pagingInfo.Page);
                pageList.Count = count;// CampaignDTOPagedList.Count();

                List<CampaignDTO> pagedCampaignDTOList = new List<CampaignDTO>();
                foreach (var item in CampaignDTOPagedList)
                {
                    if (item.Status == "Unsend" && item.GroupId != null)//item.IsSent == false
                    {
                        GroupContactDTO GroupDTO = new GroupContactDTO();
                        GroupDTO GroupDTOTemp = new GroupDTO();
                        GroupDTOTemp = GroupService.GetById(Convert.ToInt32(item.GroupId));
                        //GroupDTO = GroupService.GetGroupContactById(GroupDTOTemp.Id);

                        //List<ContactDTO> ContactDTOList = new List<ContactDTO>();
                        //ContactDTOList = GroupContactService.GetGroupIdWiseContacts(GroupDTOTemp.Id);

                        int CotactCount = GroupContactService.GetGroupIdWiseContactsCount(GroupDTOTemp.Id, "");

                        item.GroupName = GroupDTOTemp.Name;// GroupDTO.Name;
                        item.GroupContactCount = item.RecipientsCount;

                        if (item.RecipientsCount != CotactCount) // GroupDTO.Contacts.Count()
                        {
                            item.RecipientsCount = CotactCount;// GroupDTO.Contacts.Count();
                            item.GroupContactCount = item.RecipientsCount;
                            item.RequiredCredits = item.RecipientsCount * item.MessageCount;
                            CampaignService.Edit(item);
                        }

                        if (CotactCount == 1) //GroupDTO.Contacts.Count()
                        {
                            item.GroupContactCount = null;
                            List<ContactDTO> ContactDTOList = GroupContactService.GetGroupIdWiseContacts(GroupDTOTemp.Id).ToList();
                            item.RecipientsNumber = ContactDTOList[0].MobileNumber;// GroupDTO.Contacts[0].MobileNumber;
                            item.RecipientsCount = 1;
                        }
                    }
                    else if (item.Status == "Unsend" && item.ForAllContact == true)//item.IsSent == false
                    {
                        int CotactCount = uow.ContactRepo.GetAll().Where(e => e.ClientId == item.ClientId).Count();
                        item.GroupContactCount = CotactCount;
                        if (item.RecipientsCount != CotactCount) // GroupDTO.Contacts.Count()
                        {
                            item.GroupContactCount = CotactCount;
                            item.RecipientsCount = CotactCount;
                            item.RequiredCredits = item.RecipientsCount * item.MessageCount;
                            CampaignService.Edit(item);
                        }

                        if (CotactCount == 1) //GroupDTO.Contacts.Count()
                        {
                            item.GroupContactCount = null;
                            List<ContactDTO> ContactDTOList = ContactService.GetListByClientId(item.ClientId).ToList();
                            item.RecipientsNumber = ContactDTOList[0].MobileNumber;// GroupDTO.Contacts[0].MobileNumber;
                            item.RecipientsCount = 1;
                        }

                    }

                    pagedCampaignDTOList.Add(item);
                }
                pageList.Data = pagedCampaignDTOList;
            }
            else
            {
                pageList.Data = null;
            }

            return pageList;
        }
        public static void CreatePacket()
        {
            StringBuilder recipientnumberslist = new StringBuilder();

            try
            {
                bool ismailmarge = false;
                int requiredCreditTosendmsg = 0;
                //DataTable dtContact = new DataTable();
                int MOBILENUMBERLEN = 0;
                string xmlpacket = null;
                List<CampaignDTO> CampaignDTOList = CampaignService.GetCampaignNotSentList();
                if (CampaignDTOList.Count != 0)
                {

                    foreach (var item in CampaignDTOList)
                    {
                        DateTime Time;
                        if (item.ScheduledTime != "")
                        {
                            Time = Convert.ToDateTime(item.ScheduledTime);
                        }
                        else Time = Convert.ToDateTime("12:00 AM");

                        item.ScheduledDate = Convert.ToDateTime(item.ScheduledDate.Date.Date.ToString("MM/dd/yyyy") + " " + Time.TimeOfDay);
                        //CampaignService.EditCampaignFromBackend(item);

                        ismailmarge = false;
                        // create xml packet
                        DataTable dtContact = new DataTable();

                        xmlpacket = "<?xml version=" + "\"1.0\"?>";
                        xmlpacket += "<packet>";
                        xmlpacket += "<mbversion>MessageBlaster_Web</mbversion>";
                        xmlpacket += "<messagesource>MSGBLASTER</messagesource>";
                        //DataTable regInfoDT = oCompanyInfo.LoadAll();
                        ClientDTO ClientDTO = new ClientDTO();
                        ClientDTO = ClientService.GetById(item.ClientId);

                        SettingDTO SettingDTO = new SettingDTO();
                        SettingDTO = SettingService.GetById(1);
                        MOBILENUMBERLEN = SettingDTO.MobileNumberLength;

                        ArrayList recipientsnumbers = new ArrayList();
                        MessageLogDTO oMessageLog = new MessageLogDTO();
                        string[] recipients;
                        if (item.GroupId == null && item.ForAllContact == false) // To check wheather the user sending Group message
                        {
                            recipients = item.RecipientsNumber.ToString().Split(',');
                        }
                        else
                        {
                            string RecipientsNumberList = null;
                            if (item.GroupId > 0)
                            {

                                GroupContactDTO GroupContactDTO = new GroupContactDTO();
                                GroupDTO GroupDTO = new GroupDTO();
                                GroupDTO = GroupService.GetById(Convert.ToInt32(item.GroupId));
                                List<ContactDTO> ContactDTOList = new List<ContactDTO>();
                                ContactDTOList = GroupContactService.GetGroupIdWiseContacts(Convert.ToInt32(item.GroupId));
                                //GroupContactDTO = GroupService.GetGroupContactById(Convert.ToInt32(GroupDTO.Id));
                                foreach (var Contactitem in ContactDTOList) //GroupContactDTO.Contacts
                                {
                                    RecipientsNumberList = Contactitem.MobileNumber + "," + RecipientsNumberList;
                                }

                            }
                            else if(item.ForAllContact == true)
                            {
                                RecipientsNumberList = null;
                                RecipientsNumberList = ContactService.GetAllReceipentNumberByClientId(item.ClientId);
                                RecipientsNumberList = RecipientsNumberList + ",";

                            }
                                item.RecipientsNumber = RecipientsNumberList.Remove(RecipientsNumberList.LastIndexOf(','));
                                item.RecipientsCount = CommonService.GetRecipientsCount(item.RecipientsNumber);
                                CampaignService.EditCampaignFromBackend(item);
                                recipients = item.RecipientsNumber.ToString().Split(',');

                        }
                        if (recipients.Length == 0)
                        {
                            //oUcButtonControl.showMessage(frmButtonControl.Messageflag.warningMessage, "Select recipients first.");
                            return;
                        }
                        for (int i = 0; i < recipients.Length; i++) // Loop through each recipient number & remove duplicate numbers
                        {
                            if (!string.IsNullOrEmpty(recipients[i].ToString())) // Don`t allow empty number
                            {
                                string mobileNumber = GetValidMobileNumber(recipients[i].ToString().Trim()); // Get only digits from Mobile number
                                if (mobileNumber.Length >= MOBILENUMBERLEN) // Check for valid mobile number
                                {
                                    mobileNumber = mobileNumber.Substring(mobileNumber.Length - MOBILENUMBERLEN);
                                    if (!recipientsnumbers.Contains(mobileNumber)) // Check for number duplication.
                                    {
                                        recipientsnumbers.Add(mobileNumber);
                                        recipientnumberslist.Append(mobileNumber).Append(',');
                                    }
                                }
                            }
                        }
                        if (recipientnumberslist.Length != 0)
                        {
                            oMessageLog.Recipients = recipientnumberslist.ToString().Substring(0, recipientnumberslist.Length - 1);
                        }

                        MsgInformationDTO _oMsginfo = new MsgInformationDTO();

                        _oMsginfo.CampaignId = item.Id;// regInfoDT.Rows[0]["SerialKey"].ToString();
                        //xmlpacket += "<cdkey>" + regInfoDT.Rows[0]["SerialKey"].ToString() + "</cdkey>";
                        xmlpacket += "<campaignId>" + _oMsginfo.CampaignId + "</campaignId>";
                        _oMsginfo.ClientId = item.ClientId;// MachineID.Value();
                        //xmlpacket += "<machineid>" + _oMsginfo.MachineID + "</machineid>";
                        xmlpacket += "<clientId>" + _oMsginfo.ClientId + "</clientId>";

                        if (!string.IsNullOrEmpty(item.Name)) // check for TemplateName
                        {
                            //xmlpacket += "<campaignname>" + MsgCorrect(lkupTemplate.Text) + "</campaignname>";
                            xmlpacket += "<campaignname>" + MsgCorrect(item.Name.ToString()) + "</campaignname>";
                            oMessageLog.MessageTemplateID = _oMsginfo.CampaignId;
                        }
                        else
                        {
                            xmlpacket += "<campaignname>Direct_Message</campaignname>";
                            oMessageLog.MessageTemplateID = _oMsginfo.CampaignId;
                        }

                        if (!string.IsNullOrEmpty(item.GroupId.ToString())) //nameOfGroupForMsgSending
                        {
                            GroupDTO GroupDTO = new GroupDTO();
                            GroupDTO = GroupService.GetById(Convert.ToInt32(item.GroupId));
                            xmlpacket += "<groupname>" + MsgCorrect(GroupDTO.Name) + "</groupname>"; // nameOfGroupForMsgSending
                            oMessageLog.RecipientType = GroupDTO.Name;
                        }
                        else if (!string.IsNullOrEmpty(item.Name))  //nameOfImportedFile // Check for is direct message to imported contact
                        {
                            oMessageLog.RecipientType = item.Name;//  nameOfImportedFile ;
                        }
                        else
                        {
                            oMessageLog.RecipientType = "Direct";
                        }

                        oMessageLog.MessageDateTime = Convert.ToString(System.DateTime.Now);
                        xmlpacket += "<senddate>" + System.DateTime.Now.ToString("MM/dd/yyyy") + "</senddate>";

                        if (!string.IsNullOrEmpty(item.ScheduledDate.ToString())) //scheduledDate.Text // check for sheduled Date
                        {

                            if (item.ScheduledDate >= System.DateTime.Now)
                            {

                                continue;
                            }

                            DateTime ScheduledDateTime = DateTime.Parse(item.ScheduledDate.ToString());
                            if (item.ScheduledTime == null || item.ScheduledTime == "")
                            {
                                item.ScheduledTime = "12:00 AM";
                            }
                            DateTime ScheduledTime = Convert.ToDateTime(item.ScheduledTime);
                            ScheduledDateTime = ScheduledDateTime.AddHours(ScheduledTime.TimeOfDay.Hours);
                            ScheduledDateTime = ScheduledDateTime.AddMinutes(ScheduledTime.TimeOfDay.Minutes);
                           // DateTime ActualScheduleDatetime = Convert.ToDateTime(item.ScheduledDate.ToString("MM/dd/yyyy") + " " + ScheduledDateTime.TimeOfDay);
                            DateTime ActualScheduleDatetime = Convert.ToDateTime(item.ScheduledDate);
                            xmlpacket += "<scheduleddate>" + ActualScheduleDatetime.ToString("MM/dd/yyyy HH:mm tt") + "</scheduleddate>";
                            //oMessageLog.MessageScheduledDateTime = Convert.ToString(ScheduledDateTime);
                            oMessageLog.MessageScheduledDateTime = Convert.ToString(ActualScheduleDatetime);
                        }

                        oMessageLog.MessageText = item.Message.ToString().Replace("'", "''"); //memoMessagetxt.Text.Replace("'", "''");

                        if (FormatMessageText(item.Message)) //memoMessagetxt.Text
                        {
                            ismailmarge = true;
                            xmlpacket += "<messagetype>MAILMERGE</messagetype>";
                            oMessageLog.MessageTemplateType = "MAILMERGE";
                            // Get information of numbers which are in Contact list to foramte mail-marge-message
                            string nameOfGroupForMsgSending = null;

                            if (nameOfGroupForMsgSending == null)
                                dtContact = CommonService.SelectContatsInNumber(recipientnumberslist.ToString().Substring(0, recipientnumberslist.Length - 1), item.ClientId);
                            else
                                dtContact = CommonService.SelectContatsInNumber(recipientnumberslist.ToString().Substring(0, recipientnumberslist.Length - 1), item.ClientId);
                        }
                        else
                        {

                            xmlpacket += "<messagetype>NORMAL</messagetype>";
                            oMessageLog.MessageTemplateType = "NORMAL";
                        }

                        oMessageLog.Count = recipientsnumbers.Count;
                        xmlpacket += "<messagecount>" + recipientsnumbers.Count.ToString() + "</messagecount>";

                        //oMessageLog.SenderNumber = lookUpSender.Text;
                        List<UserDTO> UserDTOList = new List<UserDTO>();
                        UserDTOList = UserService.GetUsersbyClientId(ClientDTO.Id, "");
                        if (UserDTOList.Count != 0)
                        {
                            foreach (var itemuser in UserDTOList)
                            {
                                if (itemuser.UserType == "Admin")
                                {
                                    oMessageLog.SenderNumber = itemuser.Mobile;
                                    xmlpacket += "<sender>" + MsgCorrect(oMessageLog.SenderNumber) + "</sender>";
                                }

                            }
                        }

                        xmlpacket += "<numbers>";

                        CampaignDTO CampaignDTO = new CampaignDTO();
                        CampaignDTO = item;

                        if (ismailmarge)
                            requiredCreditTosendmsg = AddMsgRecipToXmlpacketMailMerge(item.Message, recipientsnumbers, dtContact.DefaultView, xmlpacket, _oMsginfo, recipientsnumbers.Count, CampaignDTO);
                        else

                            requiredCreditTosendmsg = AddMsgRecipToXmlpacket(item.Message, recipientsnumbers, xmlpacket, _oMsginfo, recipientsnumbers.Count, CampaignDTO) * recipientsnumbers.Count;

                        //xmlpacket += "</numbers>";
                        //xmlpacket += "</packet>";
                        //_oMsginfo.xmlpacket = xmlpacket;
                        //_oMsginfo.RequiredCredits = requiredCreditTosendmsg;
                        //Byte[] array = Serializeobject(_oMsginfo);
                        //Byte[] checksum = new MD5CryptoServiceProvider().ComputeHash(array); // calculate checksum for validation

                        //if (requiredCreditTosendmsg > recipientsnumbers.Count)
                        //{
                        //    //DialogResult dlg = XtraMessageBox.Show("You will be charged " + requiredCreditTosendmsg + " credits to send this message." + "\r\n" + "Do you want to send ?", "Conformation", MessageBoxButtons.YesNo);
                        //    //if (dlg == DialogResult.Yes)
                        //    //{

                        //    string responsefromService = SendMessage(array, checksum);
                        //    Response(responsefromService);

                        //    //}
                        //    //else
                        //    //{
                        //    //oUcButtonControl.ShowSend = true;
                        //    //oUcButtonControl.showMessage(frmButtonControl.Messageflag.none, "");
                        //    //oUcButtonControl.ButtonView();
                        //    //this.Update();
                        //    //}
                        //}
                        //else
                        //{
                        //    string responsefromService = SendMessage(array, checksum);
                        //    Response(responsefromService);
                        //}
                    }
                }

            }
            catch (Exception ex)
            {
                //oUcButtonControl.showMessage(frmButtonControl.Messageflag.errorMessage, Global.DisplayConnectionError(ex));
                throw;
            }
        }
        public static void ReadEcouponEcouponCampaign()
        {
            List<EcouponCampaignDTO> EcouponCampaignDTOList = new List<EcouponCampaignDTO>();
            EcouponCampaignDTOList = EcouponCampaignService.GetEcouponCampaignNotSentList();
            if (EcouponCampaignDTOList != null)
            {
                foreach (var item in EcouponCampaignDTOList)
                {
                    try
                    {
                        EcouponCampaignDTO EcouponCampaignDTO = new EcouponCampaignDTO();
                        EcouponCampaignDTO = item;
                        DateTime ScheduledDate = EcouponCampaignDTO.SendOn.Date;
                        DateTime Time;
                        if (EcouponCampaignDTO.ScheduleTime != "")
                        {
                            Time = Convert.ToDateTime(EcouponCampaignDTO.ScheduleTime);
                        }
                        else Time = Convert.ToDateTime("12:00 AM");

                        ScheduledDate = Convert.ToDateTime(ScheduledDate.Date.ToString("MM/dd/yyyy") + " " + Time.TimeOfDay);

                        Console.WriteLine("Scheduled Time = " + ScheduledDate);

                        if (ScheduledDate <= System.DateTime.Now)
                        {
                            //SplitMobile(item.ReceipentNumber, EcouponCampaignDTO);
                            if (item.GroupId == null && item.ForAllContact == false)
                            {
                                SplitMobile(item.ReceipentNumber, EcouponCampaignDTO);
                            }
                            else
                            {

                                string RecipientsNumberList = null;
                                if (item.GroupId > 0)
                                {
                                    GroupContactDTO GroupContactDTO = new GroupContactDTO();
                                    GroupDTO GroupDTO = new GroupDTO();
                                    GroupDTO = GroupService.GetById(Convert.ToInt32(item.GroupId));
                                    //GroupContactDTO = GroupService.GetGroupContactById(Convert.ToInt32(GroupDTO.Id));

                                    List<ContactDTO> ContactDTO = new List<ContactDTO>();
                                    ContactDTO = GroupContactService.GetGroupIdWiseContacts(GroupDTO.Id);

                                    foreach (var Contactitem in ContactDTO) //GroupContactDTO.Contacts
                                    {
                                        RecipientsNumberList = Contactitem.MobileNumber + "," + RecipientsNumberList;
                                    }
                                }
                                else if(item.ForAllContact == true)
                                {
                                    RecipientsNumberList = null;
                                    RecipientsNumberList = ContactService.GetAllReceipentNumberByClientId(item.ClientId);
                                    RecipientsNumberList = RecipientsNumberList + ",";
                                }

                                item.ReceipentNumber = RecipientsNumberList.Remove(RecipientsNumberList.LastIndexOf(','));
                                item.RecipientsCount = CommonService.GetRecipientsCount(item.ReceipentNumber);
                                EcouponCampaignService.EditEcouponCampaignFromBackend(item);

                                EcouponCampaignDTO EcouponCampaignGrpDTO = new EcouponCampaignDTO();
                                EcouponCampaignGrpDTO = item;
                                SplitMobile(item.ReceipentNumber, EcouponCampaignGrpDTO);
                            }

                        }
                        else { }

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

                        continue;
                    }

                }
            }

            //Check Client Balance

            //Modify Client Balance
        }
Ejemplo n.º 12
0
 public static GroupContact GroupContactNewToDomain(GroupContactDTO GroupContactDTO)
 {
     if (GroupContactDTO == null) return null;
      Mapper.CreateMap<GroupContactDTO, GroupContact>();
      GroupContact GroupContact = Mapper.Map<GroupContact>(GroupContactDTO);
      return GroupContact;
 }