public IMessage GetContactsforForwardMail(string searchText, int maxresults, out bool isIndex, string[] contactIDs = null) { IMessage response = null; try { var stringlist = new string[] { "EmailAddress", "FirstName", "LastName", "PhoneNumber" }; if (ContactDataContext.GetInstance().IsContactIndexFound) { isIndex = true; string query = "TenantId:" + ConfigContainer.Instance().TenantDbId; //Add EmailAddress, FirstName, LastName and PhoneNumber for searching string subQuery = ""; foreach (string key in stringlist) { if (!Settings.ContactDataContext.GetInstance().ContactValidAttribute.ContainsKey(key)) { continue; } subQuery += (!string.IsNullOrEmpty(subQuery) ? " OR " : "") + key + ":" + searchText + "*"; } if (!string.IsNullOrEmpty(subQuery)) { query += " AND (" + subQuery + ")"; } //Add ContactIDs for searching subQuery = string.Empty; if (contactIDs != null && contactIDs.Length > 0) { //System.Threading.Tasks.Parallel.ForEach(contactIDs, contactID => //{ // subQuery += (!string.IsNullOrEmpty(subQuery) ? " OR " : "") + "Id" + ":" + contactID; //}); for (int i = 0; i < contactIDs.Length; i++) { subQuery += (!string.IsNullOrEmpty(subQuery) ? " OR " : "") + "Id" + ":" + contactIDs[i]; } if (!string.IsNullOrEmpty(subQuery)) { query += " AND (" + subQuery + ")"; } maxresults = contactIDs.Length; } response = SearchContact(query, maxresults); } else { isIndex = false; if (contactIDs != null && contactIDs.Length > 0) { return(response); } //Assign Search Criteria Collection for searching SearchCriteriaCollection searchCriteriaCollection = new SearchCriteriaCollection(); //Assign Complex Search Criteria for searching var csub1 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; // Add cChildOr1 in csub1 var csub2 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; // Add cChildOr2 in csub2 //Add EmailAddress, FirstName, LastName and PhoneNumber for searching StringList attributeList = new StringList(); string attributeValue = "*".Equals(searchText) ? "" : searchText; csub1.Criterias = new SearchCriteriaCollection(); for (int index = 0; index < stringlist.Length; index++) { attributeList.Add(stringlist[index]); var cChildOr1 = new ComplexSearchCriteria() { Prefix = Prefixes.Or }; cChildOr1.Criterias = new SearchCriteriaCollection(); SimpleSearchCriteria simpleSearchCriteria = new SimpleSearchCriteria() { AttrName = stringlist[index], AttrValue = attributeValue + "*", Operator = new NullableOperators(Operators.Like) }; cChildOr1.Criterias.Add(simpleSearchCriteria); if (contactIDs != null && contactIDs.Length > 0) { csub1.Criterias.Add(cChildOr1); } else { searchCriteriaCollection.Add(cChildOr1); } } //if (contactIDs != null && contactIDs.Length > 0) //{ //Add ContactIDs for searching //csub2.Criterias = new SearchCriteriaCollection(); //for (int i = 0; i < contactIDs.Length; i++) //{ // var cChildOr2 = new ComplexSearchCriteria() { Prefix = Prefixes.Or }; // cChildOr2.Criterias = new SearchCriteriaCollection(); // SimpleSearchCriteria simpleSearchCriteria = new SimpleSearchCriteria() { AttrName = Genesyslab.Platform.Contacts.Protocols.ContactSearchCriteriaConstants.ContactId, AttrValue = contactIDs[i], Operator = new NullableOperators(Operators.Equal) }; // cChildOr2.Criterias.Add(simpleSearchCriteria); // // Add cChildOr2 in csub2 // csub2.Criterias.Add(cChildOr2); //} //Finally add sub1 and sub2 in searchCriteriaCollection //searchCriteriaCollection.Add(csub1); //searchCriteriaCollection.Add(csub2); //} attributeList.Add("MergeId"); response = GetContactList(ConfigContainer.Instance().TenantDbId, attributeList, searchCriteriaCollection, maxresults); } } catch (Exception generalException) { isIndex = false; logger.Error("Error occurred as : " + generalException.ToString()); } return(response); }
/// <summary> /// Gets the interaction count. /// </summary> /// <param name="universalContactServerProtocol">The universal contact server protocol.</param> /// <param name="mediaType">Type of the media.</param> /// <param name="contactID">The contact unique identifier.</param> /// <returns></returns> public static OutputValues GetTotalInteractionCount(string contactID, string interactionId) { Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID"); OutputValues output = OutputValues.GetInstance(); try { RequestCountInteractions requestCountInteractions = RequestCountInteractions.Create(); requestCountInteractions.TenantId = Settings.tenantDBID; SimpleSearchCriteria sSC1 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.MediaTypeId, AttrValue = "voice", Operator = new NullableOperators(Operators.NotEqual) }; SimpleSearchCriteria sSC2 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.Status, AttrValue = ((int)Statuses.InProcess).ToString(), Operator = new NullableOperators(Operators.Equal) }; SimpleSearchCriteria sSC3 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.Id, AttrValue = null, Operator = new NullableOperators(Operators.NotEqual) }; SimpleSearchCriteria sSC4 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.ContactId, AttrValue = contactID, Operator = new NullableOperators(Operators.Equal) }; ComplexSearchCriteria cmpSC = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC.Criterias = new SearchCriteriaCollection(); cmpSC.Criterias.Add(sSC1); ComplexSearchCriteria cmpSC2 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC2.Criterias = new SearchCriteriaCollection(); cmpSC2.Criterias.Add(sSC2); ComplexSearchCriteria cmpSC3 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC3.Criterias = new SearchCriteriaCollection(); cmpSC3.Criterias.Add(sSC3); ComplexSearchCriteria cmpSC4 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC4.Criterias = new SearchCriteriaCollection(); cmpSC4.Criterias.Add(sSC4); SearchCriteriaCollection srchCrit = new SearchCriteriaCollection(); srchCrit.Add(cmpSC); srchCrit.Add(cmpSC2); srchCrit.Add(cmpSC3); srchCrit.Add(cmpSC4); requestCountInteractions.SearchCriteria = new SearchCriteriaCollection(); requestCountInteractions.SearchCriteria = srchCrit; if (Settings.UCSProtocol != null && Settings.UCSProtocol.State == ChannelState.Opened) { logger.Info("------------RequestCountInteractions-------------"); logger.Info("Interaction ID :" + interactionId); logger.Info("Contact ID :" + contactID); logger.Info("-------------------------------------------------"); IMessage response = Settings.UCSProtocol.Request(requestCountInteractions); if (response != null) { logger.Trace(response.ToString()); output.IContactMessage = response; output.MessageCode = "200"; output.Message = "Received Total InProcess Interaction count Successfully"; } else { output.IContactMessage = null; output.MessageCode = "2001"; output.Message = "Don't Received Total InProcess Interaction count Successfully"; } } else { output.IContactMessage = null; output.MessageCode = "2001"; output.Message = "Universal Contact Server protocol is Null or Closed"; logger.Warn("GetInteractionCount() : Universal Contact Server Protocol is Null"); } } catch (Exception error) { logger.Error("GetInteractionCount(): Error occurred while retrieving total in-process interaction count :" + error.ToString()); output.IContactMessage = null; output.MessageCode = "2001"; output.Message = error.Message; } return(output); }
/// <summary> /// Gets the recent interaction list. /// </summary> /// <param name="universalContactServerProtocol">The universal contact server protocol.</param> /// <param name="mediaType">Type of the media.</param> /// <returns></returns> public static OutputValues GetRecentInteractionList(string mediaType, string contactID) { Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID"); OutputValues output = OutputValues.GetInstance(); try { RequestInteractionListGet requestInteractionListGet = RequestInteractionListGet.Create(); requestInteractionListGet.DataSource = new NullableDataSourceType(DataSourceType.Main); requestInteractionListGet.SortCriteria = new SortCriteriaCollection(); SortCriteriaCollection sortCC = new SortCriteriaCollection(); SortCriteria sortc = new SortCriteria() { AttrName = InteractionSearchCriteriaConstants.StartDate, SortOperator = new NullableSortMode(SortMode.Descending), SortIndex = 0 }; sortCC.Add(sortc); requestInteractionListGet.SortCriteria = sortCC; SimpleSearchCriteria sSC1 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.MediaTypeId, AttrValue = mediaType.ToLower(), Operator = new NullableOperators(Operators.Equal) }; SimpleSearchCriteria sSC2 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.StartDate, AttrValue = DateTime.Now.ToString("yyyy") + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day).ToString() + "T00:00:00.000Z", Operator = new NullableOperators(Operators.GreaterOrEqual) }; SimpleSearchCriteria sSC3 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.Status, AttrValue = ((int)Statuses.Stopped).ToString(), Operator = new NullableOperators(Operators.Equal) }; SimpleSearchCriteria sSC4 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.ContactId, AttrValue = contactID, Operator = new NullableOperators(Operators.Equal) }; ComplexSearchCriteria cmpSC = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC.Criterias = new SearchCriteriaCollection(); cmpSC.Criterias.Add(sSC1); ComplexSearchCriteria cmpSC2 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC2.Criterias = new SearchCriteriaCollection(); cmpSC2.Criterias.Add(sSC2); ComplexSearchCriteria cmpSC3 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC3.Criterias = new SearchCriteriaCollection(); cmpSC3.Criterias.Add(sSC3); ComplexSearchCriteria cmpSC4 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC4.Criterias = new SearchCriteriaCollection(); cmpSC4.Criterias.Add(sSC4); SearchCriteriaCollection srchCrit = new SearchCriteriaCollection(); srchCrit.Add(cmpSC); srchCrit.Add(cmpSC2); srchCrit.Add(cmpSC3); srchCrit.Add(cmpSC4); requestInteractionListGet.SearchCriteria = new SearchCriteriaCollection(); requestInteractionListGet.SearchCriteria = srchCrit; StringList stringList = new StringList(); stringList.Add("StartDate"); stringList.Add("Subject"); requestInteractionListGet.AttributeList = stringList; requestInteractionListGet.TenantId = Settings.tenantDBID; if (Settings.UCSProtocol != null && Settings.UCSProtocol.State == ChannelState.Opened) { logger.Info("------------RequestGetRecentInteractionList-------------"); logger.Info("Media Type :" + mediaType); logger.Info("Contact ID :" + contactID); logger.Info("----------------------------------------------"); IMessage response = Settings.UCSProtocol.Request(requestInteractionListGet); if (response != null) { logger.Trace(response.ToString()); output.IContactMessage = response; output.MessageCode = "200"; output.Message = "Received Recent Interaction List Successfully"; } else { output.IContactMessage = null; output.MessageCode = "200"; output.Message = "Doesn't Received Recent Interaction List Successfully"; } } else { output.IContactMessage = null; output.MessageCode = "2001"; output.Message = "Universal Contact Server protocol is Null or Closed"; logger.Warn("GetRecentInteractionList() : Contact Server protocol is Null.."); } } catch (Exception generalException) { logger.Error("Error occurred while Request Get Recent Interaction List " + generalException.ToString()); output.IContactMessage = null; output.MessageCode = "2001"; output.Message = generalException.Message; } return(output); }
/// <summary> /// Gets the recent interaction list. /// </summary> /// <param name="mediaType">Type of the media.</param> /// <param name="contactID">The contact unique identifier.</param> /// <param name="tenantId">The tenant unique identifier.</param> /// <param name="attributesNames">The attributes names.</param> /// <returns></returns> public static OutputValues GetRecentInteractionList(string contactID, int tenantId, string interactionID, List <string> attributesNames) { Pointel.Logger.Core.ILog logger = Pointel.Logger.Core.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "AID"); OutputValues output = OutputValues.GetInstance(); try { RequestInteractionListGet requestInteractionListGet = RequestInteractionListGet.Create(); requestInteractionListGet.DataSource = new NullableDataSourceType(DataSourceType.Main); requestInteractionListGet.SortCriteria = new SortCriteriaCollection(); SortCriteriaCollection sortCC = new SortCriteriaCollection(); SortCriteria sortc = new SortCriteria() { AttrName = InteractionSearchCriteriaConstants.StartDate, SortOperator = new NullableSortMode(SortMode.Descending), SortIndex = 0 }; sortCC.Add(sortc); requestInteractionListGet.SortCriteria = sortCC; SimpleSearchCriteria sSC1 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.MediaTypeId, AttrValue = "voice", Operator = new NullableOperators(Operators.NotEqual) }; SimpleSearchCriteria sSC2 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.StartDate, AttrValue = DateTime.Now.ToString("yyyy") + "-" + DateTime.Now.Month.ToString() + "-" + (DateTime.Now.Day).ToString() + "T00:00:00.000Z", Operator = new NullableOperators(Operators.GreaterOrEqual) }; SimpleSearchCriteria sSC3 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.Id, AttrValue = interactionID, Operator = new NullableOperators(Operators.NotEqual) }; SimpleSearchCriteria sSC4 = new SimpleSearchCriteria() { AttrName = InteractionSearchCriteriaConstants.ContactId, AttrValue = contactID, Operator = new NullableOperators(Operators.Equal) }; ComplexSearchCriteria cmpSC = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC.Criterias = new SearchCriteriaCollection(); cmpSC.Criterias.Add(sSC1); ComplexSearchCriteria cmpSC2 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC2.Criterias = new SearchCriteriaCollection(); cmpSC2.Criterias.Add(sSC2); ComplexSearchCriteria cmpSC3 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC3.Criterias = new SearchCriteriaCollection(); cmpSC3.Criterias.Add(sSC3); ComplexSearchCriteria cmpSC4 = new ComplexSearchCriteria() { Prefix = Prefixes.And }; cmpSC4.Criterias = new SearchCriteriaCollection(); cmpSC4.Criterias.Add(sSC4); SearchCriteriaCollection srchCrit = new SearchCriteriaCollection(); srchCrit.Add(cmpSC); srchCrit.Add(cmpSC2); srchCrit.Add(cmpSC3); srchCrit.Add(cmpSC4); requestInteractionListGet.SearchCriteria = new SearchCriteriaCollection(); requestInteractionListGet.SearchCriteria = srchCrit; StringList stringList = new StringList(); if (attributesNames.Count > 0) { foreach (string attribute in attributesNames) { stringList.Add(attribute); } } //stringList.Add("StartDate"); //stringList.Add("Subject"); requestInteractionListGet.AttributeList = stringList; requestInteractionListGet.TenantId = tenantId; if (Settings.UCSProtocol != null && Settings.UCSProtocol.State == ChannelState.Opened) { IMessage response = Settings.UCSProtocol.Request(requestInteractionListGet); if (response != null && response.Id == EventInteractionListGet.MessageId) { //EventInteractionListGet eventInteractionListGet = (EventInteractionListGet)response; //if (eventInteractionListGet != null && eventInteractionListGet.InteractionData != null) //{ // interactionDataList = eventInteractionListGet.InteractionData; // logger.Info("------------RequestGetRecentInteractionList-------------"); // logger.Info("Media Type :" + mediaType); // logger.Info("Contact ID :" + contactID); // logger.Info("----------------------------------------------"); // logger.Trace(eventInteractionListGet.ToString()); // output.MessageCode = "200"; // output.Message = "Received Recent Interaction List Successfully"; // output.GetInteractionDataList = interactionDataList; //} output.MessageCode = "200"; output.Message = "Get Recent Interaction List Successful"; output.IContactMessage = response; } else { output.MessageCode = "2001"; output.Message = "Get Recent Interaction List Failed"; output.IContactMessage = response; } } else { logger.Warn("GetRecentInteractionList() : Contact Server protocol is Null.."); } } catch (Exception generalException) { logger.Error("Error occurred while Request Get Recent Interaction List " + generalException.ToString()); output.MessageCode = "2001"; output.Message = generalException.Message; output.IContactMessage = null; } return(output); }