public static MsCrmResultObject GetSendSmsList(Guid portalId, SqlDataAccess sda) { MsCrmResultObject returnValue = new MsCrmResultObject(); List <SendSmsRecord> lstSendList = new List <SendSmsRecord>(); try { #region | SQL QUERY | string sqlQuery = @"DECLARE @now DATETIME SET @now=GETUTCDATE() SELECT s.new_sentsmsId AS Id FROM new_sentsms AS s (NOLOCK) WHERE s.new_prefferedsenddate<=@now AND s.statuscode=1 --İşlem Bekliyor AND s.new_portalId='{0}' AND s.statecode=0" ; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, portalId)); if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { MsCrmResultObject result = SMSHelper.GetSendSsmsRecordInfo((Guid)dt.Rows[i]["Id"], sda); if (result.Success) { lstSendList.Add((SendSmsRecord)result.ReturnObject); } } returnValue.ReturnObject = lstSendList; returnValue.Success = true; returnValue.Result = "Gönderim Listesi çekilidi."; } else { returnValue.Result = "Gönderim listesi boş."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }
public static MsCrmResultObject GetSendSsmsRecordInfo(Guid sendSmsId, SqlDataAccess sda) { MsCrmResultObject returnValue = new MsCrmResultObject(); try { #region | SQL QUERY | string sqlQuery = @"DECLARE @now DATETIME SET @now=GETUTCDATE() SELECT s.new_sentsmsId AS Id ,s.new_name AS Name ,s.statuscode AS StatusCode ,s.new_contactId AS ContactId ,s.new_contactIdName AS ContactIdName ,s.new_content AS Content ,s.new_errortext AS ErrorText ,s.new_issent AS IsSent ,s.new_MesajId AS MessageId ,s.new_phonenumber AS PhoneNumber ,s.new_prefferedsenddate AS PrefferedSendDate ,s.new_resultcode AS ResultCode ,s.new_smsconfigurationId AS SmsConfigurationId ,s.new_smsconfigurationIdName AS SmsConfigurationIdName FROM new_sentsms AS s (NOLOCK) WHERE s.new_sentsmsId='{0}'" ; #endregion DataTable dt = sda.getDataTable(string.Format(sqlQuery, sendSmsId)); if (dt.Rows.Count > 0) { SendSmsRecord sendRec = new SendSmsRecord(); sendRec.Id = (Guid)dt.Rows[0]["Id"]; sendRec.Name = dt.Rows[0]["Name"].ToString(); sendRec.StatusCode = (int)dt.Rows[0]["StatusCode"]; if (dt.Rows[0]["ContactId"] != DBNull.Value) { EntityReference er = new EntityReference() { Id = (Guid)dt.Rows[0]["ContactId"], Name = dt.Rows[0]["ContactIdName"].ToString(), LogicalName = "contact" }; sendRec.Contact = er; } sendRec.Content = dt.Rows[0]["Content"].ToString(); sendRec.IsSent = (bool)dt.Rows[0]["IsSent"]; sendRec.PhoneNumber = dt.Rows[0]["PhoneNumber"].ToString(); sendRec.PrefferedSendDate = (DateTime)dt.Rows[0]["PrefferedSendDate"]; sendRec.ResultCode = dt.Rows[0]["ResultCode"].ToString(); if (dt.Rows[0]["SmsConfigurationId"] != DBNull.Value) { //EntityReference er = new EntityReference() //{ // Id = (Guid)dt.Rows[0]["SmsConfigurationId"], // Name = dt.Rows[0]["SmsConfigurationId"].ToString(), // LogicalName = "new_smsconfiguration" //}; //sendRec.SmsConfiguration = er; MsCrmResultObject resultConf = SMSHelper.GetSmsConfigurationInfo((Guid)dt.Rows[0]["SmsConfigurationId"], sda); if (resultConf.Success) { sendRec.SmsConfiguration = (SmsConfiguration)resultConf.ReturnObject; } } returnValue.ReturnObject = sendRec; returnValue.Success = true; returnValue.Result = "Sms gönderme kaydı bilgisi çekildi."; } else { returnValue.Result = "Sms Gönderim kaydı bilgisi çekilemedi."; } } catch (Exception ex) { returnValue.Result = ex.Message; } return(returnValue); }