2 Replies Latest reply on Aug 17, 2016 5:57 AM by Maksim

    c# notification isn't working

    Maksim

      Hello, every day at 10:00 is program starts. Program create statistics per night in bmp file,save in folder, upload AFnotification and SetValue in AF, but when start in 10:00 notification sends old file instead created. If you look in AF attribute you will see that in attribute is new picture(bmp). Notification is activated be attribute  LastTimeUpdated

      Where me find a trouble ?

      AF SDK : v4.0.30319

       

      Code:

      myAFDB = AFserver.Databases[myAFDBstr]
      ...
      AFFile file = new AFFile();
      Bitmap bmp = GRAPHICS.CreateGraphics_15hours(AFserver, ObjectName, Hlogger.HostServicelogger);
      string NotificationFileName = Application.StartupPath + "\\Images\\FlowStatistics.png";
      bmp.Save(NotificationFileName, System.Drawing.Imaging.ImageFormat.Png);
      string filename = Application.StartupPath + "\\Images\\FlowStatistics\\Stats_" + part_of_filename + ".png";
      bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
      file.Upload(filename);
      
      AFNamedCollectionList<AFNotification> notification = AFNotification.FindNotifications(myAFDB, "StatisticsNotification", AFSearchField.Name, AFSortField.Name, AFSortOrder.Ascending, 10);
      AFNotification afN = notification.Where(x => x.Name.Equals("StatisticsNotification")).First();
      if (afN.Contents.Contains("NightTimeFlowStatistics.png")) {
           AFNotificationContent content = afN.Contents["FlowStatistics.png"];
           AFFile img_file = new AFFile(content.Attribute);
           img_file.Upload(filename); 
           content.Attribute.SetValue(img_file, null);
           afN.ApplyChanges(); }
      myAFDB.Elements["Root"].Elements[ObjectName].Elements["Statistics"].Elements["Time"].Attributes["Image"].SetValue(file, null);
      myAFDB.Elements["Root"].Elements[ObjectName].Elements["Statistics"].Elements["Time"].Attributes["LastTimeUpdated"].SetValue(DateTime.Now, null);
      myAFDB.ApplyChanges();
      bmp.Dispose();