示例#1
0
        public static bool ShowAnnouncementResponse(string resp, string vmName)
        {
            if (resp == null)
            {
                Logger.Error("Failed to get announcement data.");
                return(false);
            }
            Logger.Info("Announcement get resp: " + resp);
            JObject o    = JObject.Parse(resp);
            string  strA = o["success"].ToString().Trim();
            string  str  = o["reason"].ToString().Trim();

            if (string.Compare(strA, "false", true) == 0)
            {
                Logger.Info("Could not get announcement msg: " + str);
                return(false);
            }
            CloudAnnouncement.sMsgId = Convert.ToInt32(o["msgId"].ToString().Trim());
            string imagePath = CloudAnnouncement.DownloadDisplayImage(o["imageUrl"].ToString().Trim());

            try
            {
                CloudAnnouncement.sOemForSilentLogCollect = o["oem"].ToString().Trim();
            }
            catch
            {
                Logger.Warning("OEM not passed in announcement");
            }
            try
            {
                CloudAnnouncement.sIsSilentLogCollectForAllOems = bool.Parse(o["all_oem"].ToString().Trim());
            }
            catch
            {
                Logger.Warning("All_Oem parameter not passed in announcement");
            }
            AnnouncementMessage m = new AnnouncementMessage(imagePath, CloudAnnouncement.sMsgId, o);

            if (m.FileName.Length < 3)
            {
                m.FileName = "downloadedFile.exe";
            }
            try
            {
                CloudAnnouncement.sUploadStats = true;
                CloudAnnouncement.ShowFetchedMsg(m, vmName);
            }
            catch (Exception ex)
            {
                Logger.Error("Failed to fetch announcement message. error: " + ex.ToString());
                return(false);
            }
            return(true);
        }
示例#2
0
        public static void ShowNotification(
            string action,
            string title,
            string message,
            string actionURL,
            string fileName,
            string imageURL,
            string vmName)
        {
            string imagePath = string.Empty;

            if (imageURL != null)
            {
                imagePath = CloudAnnouncement.DownloadDisplayImage(imageURL);
            }
            AnnouncementMessage m = new AnnouncementMessage(imagePath, -1, title, message, action, "", actionURL, fileName);

            CloudAnnouncement.sUploadStats = false;
            string vmName1 = vmName;

            CloudAnnouncement.ShowFetchedMsg(m, vmName1);
        }