我有下一个问题: 当我以编程方式发送与ews的会议时, 我在数据库中插入日历,电子邮件和其他信息的ID 我在服务器上跟踪Job每小时响应的参与者 下一个代码:
namespace TrackForMeeting
{
class TrackForMeeting
{
//string ResponseType;
//string IdItem;
//string meetingInsert;
static ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
// static string Tracking()
{
try
{
service.Credentials = new WebCredentials("info@somemail.ru", "somepass");
service.AutodiscoverUrl("info@somemail.ru", RedirectionUrlValidationCallback);
var timeZoneInfo = TimeZoneInfo.CreateCustomTimeZone("UTC+3",
TimeZoneInfo.Local.BaseUtcOffset, "UTC+3", "UTC+3");
string sql = "SELECT IdItem,StartDate,ResponseType,UpdStatus FROM dbo.RespForMeetings WHERE IsExpir = 0";
string connectionString = @"Data Source=someserv;Initial Catalog=somedb;Integrated Security=True";
string ResponseType;
using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
// Создаем объект DataAdapter
SqlDataAdapter adapter = new SqlDataAdapter(sql, connection);
// Создаем объект DataTable
DataTable dt = new DataTable();
// Заполняем Datatable
adapter.Fill(dt);
for (int i = 0; i < dt.Rows.Count; i++)
{
Appointment meeting = Appointment.Bind(service, new ItemId(dt.Rows[i][0].ToString()));
ResponseType = meeting.RequiredAttendees[0].ResponseType.Value.ToString();
if (ResponseType != dt.Rows[i][2].ToString())
{
ExecCommand($"Update dbo.RespForMeetings SET ResponseType = '{ResponseType}',UpdStatus = 1 WHERE IdItem = '{dt.Rows[i][0].ToString()}'", connectionString);
}
if (DateTime.Now > DateTime.Parse(dt.Rows[i][1].ToString()))
{
ExecCommand($"Update dbo.RespForMeetings SET IsExpir = 1 WHERE IdItem ='{dt.Rows[i][0].ToString()}'", connectionString);
meeting.Delete(DeleteMode.MoveToDeletedItems, SendCancellationsMode.SendToNone);
}
}
}
}
catch (Exception e) { return e.Message; }
return "";
}
public static bool RedirectionUrlValidationCallback(string redirectionUrl)
{
// The default for the validation callback is to reject the URL.
bool result = false;
Uri redirectionUri = new Uri(redirectionUrl);
// Validate the contents of the redirection URL. In this simple validation
// callback, the redirection URL is considered valid if it is using HTTPS
// to encrypt the authentication credentials.
if (redirectionUri.Scheme == "https")
{
result = true;
}
return result;
}
static string ExecCommand(string queryString, string conn)
{
using (SqlConnection connection = new SqlConnection(conn))
{
SqlCommand command = new SqlCommand(queryString, connection);
command.Connection.Open();
try
{
command.ExecuteNonQuery();
return "";
}
catch (Exception ex)
{ return ex.ToString(); }
}
}
static void Main(string[] args)
{
Tracking();
}
当有苹果移动设备的人的回复收入我有这个字符串的麻烦时:
ResponseType = meeting.RequiredAttendees[0].ResponseType.Value.ToString();
if (ResponseType != dt.Rows[i][2].ToString())
{
ExecCommand($"Update dbo.RespForMeetings SET ResponseType = '{ResponseType}',UpdStatus = 1 WHERE IdItem = '{dt.Rows[i][0].ToString()}'", connectionString);
}
并且传入的响应发生了变化,但是这个脚本不会检查这个。可以有人帮忙吗?