private async void Timer1_Tick(object sender, EventArgs e) { string[] objects = ConfigurationManager.AppSettings["objects"].Split(';'); string[] objectsNames = ConfigurationManager.AppSettings["objectsNames"].Split(';'); string[] objectsModDateTime = ConfigurationManager.AppSettings["objectsModDateTime"].Split(';'); int index = 0; foreach (string objectLink in objects) { if (String.IsNullOrEmpty(objectLink)) { continue; } try { var result = await client.Propfind(objectLink); if (result.IsSuccessful) { string modifiedby; string dateModify; foreach (var res in result.Resources) { dateModify = res.LastModifiedDate.ToString(); modifiedby = res.Properties.ToList().Find(a => a.ToString().Contains("modifiedby")).Value; if (dateModify != objectsModDateTime[index]) { #region Сохранение даты изменения objectsModDateTime[index] = dateModify; string objectsModDateTimeString = ""; foreach (var item in objectsModDateTime) { objectsModDateTimeString += $"{item};"; } Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); KeyValueConfigurationCollection confCollection = config.AppSettings.Settings; confCollection["objectsModDateTime"].Value = objectsModDateTimeString; config.Save(ConfigurationSaveMode.Modified); ConfigurationManager.RefreshSection(config.AppSettings.SectionInformation.Name); #endregion var fAlert = new FormAlert(objectsNames[index], dateModify, modifiedby, objectLink); fAlert.Show(); } } } } catch (Exception) { } index++; } }
public Form1() { InitializeComponent(); udpClient.Client.Bind(new IPEndPoint(IPAddress.Any, PORT)); var from = new IPEndPoint(0, 0); Task.Run(() => { while (true) { var recvBuffer = udpClient.Receive(ref from); string message = Encoding.UTF8.GetString(recvBuffer); string[] items = message.Split(';'); string userName = ""; string mashineName = ""; if (items.Length == 2) { userName = items[0]; mashineName = items[1]; } if (userName != Environment.UserName && mashineName != Environment.MachineName) { if (!String.IsNullOrEmpty(userName) && !String.IsNullOrEmpty(mashineName)) { //var fAlert = new FormAlert(userName, mashineName, DateTime.Now.ToLongTimeString()); var fAlert = new FormAlert(userName, mashineName, $"{DateTime.Now.ToLongDateString()} {DateTime.Now.ToLongTimeString()}"); fAlert.StartPosition = FormStartPosition.CenterParent; //fAlert.TopMost = true; fAlert.ShowDialog(this); } } } }); }