public void CreateNotification(string description, UrgencyLevel urgencyLevel, bool destroyExisting, bool saveToNotifications = true, List <string> buttonTitles = null, List <Action> buttonActions = null)
    {
        // Remove older occurances of the same notification
        if (destroyExisting)
        {
            CloseNotification(FindNotificationGO(description));
        }

        if (saveToNotifications)
        {
            GameObject notificationGO = CreateNotificationGO(notificationParent.transform, false, description, urgencyLevel, destroyExisting, buttonTitles, buttonActions);
            notifications.Add(notificationGO);
        }
        // Add to event feed if notifications panel not already open
        if (!notificationParent.activeInHierarchy && !ObjectiveController.Instance.objectiveUIParent.activeInHierarchy)
        {
            GameObject eventFeedGO = CreateNotificationGO(eventFeedParent.transform, true, description, urgencyLevel, destroyExisting, buttonTitles, buttonActions);
            Canvas.ForceUpdateCanvases();
            eventFeedGO.transform.parent.GetComponent <ContentSizeFitter>().enabled = false;
            eventFeedGO.transform.parent.GetComponent <ContentSizeFitter>().enabled = true;
            eventFeedGO.GetComponent <Notification>().Destroy(5f);
            if (saveToNotifications)
            {
                StartBlinking();
            }
        }
    }
        public async Task <TicketsResult> CreateTicket(string description, UrgencyLevel urgency)
        {
            try
            {
                var request = CreateRequest(getUserIdResource);
                var userId  = await client.GetAsync <GetUserIdResponse>(request);

                request = CreateRequest(TicketResource);
                var body = new CreateTicketRequest()
                {
                    caller_id         = userId.result,
                    short_description = description,
                    urgency           = UrgencyToString[urgency]
                };
                request.AddJsonBody(body);
                var result = await client.PostAsync <SingleTicketResponse>(request);

                return(new TicketsResult()
                {
                    Success = true,
                    Tickets = new Ticket[] { ConvertTicket(result.result) }
                });
            }
            catch (Exception ex)
            {
                return(new TicketsResult()
                {
                    Success = false,
                    ErrorMessage = ex.Message
                });
            }
        }
Example #3
0
        public void Log(UrgencyLevel level, string content, object counterToken = null)
        {
            string logFileLocation = System.IO.Path.Combine(LogFileFolder, System.DateTime.Now.ToString("MMMM dd, yyyy") + ".txt");

            System.IO.File.AppendAllText(logFileLocation, string.Format("[{0}][{1}] {2}\n", SystemHelper.CurrentTimeFileNameFriendly, level, content));

            if (counterToken == CounterToken)
            {
                Count++;
            }
            else
            {
                CounterToken = counterToken; Count = 1;
            }
        }
Example #4
0
 public ServiceRequest(string requestSubject, string serviceCategory, string requestDetails,
                       UrgencyLevel urgent, RequestStatus status, int leaseId, int requestorId, int workOrderId, string notes,
                       DateTime created, DateTime updated)
 {
     RequestSubject  = requestSubject;
     ServiceCategory = serviceCategory;
     RequestDetails  = requestDetails;
     Urgent          = urgent;
     Status          = status;
     LeaseId         = leaseId;
     RequestorId     = requestorId;
     WorkOrderId     = workOrderId;
     Notes           = notes;
     Created         = created;
     Modified        = updated;
 }
        public async Task <TicketsResult> UpdateTicket(string id, string title = null, string description = null, UrgencyLevel urgency = UrgencyLevel.None)
        {
            var request = CreateRequest($"{TicketResource}/{id}?sysparm_exclude_ref_link=true");
            var body    = new CreateTicketRequest()
            {
                short_description = title,
                description       = description,
                urgency           = urgency == UrgencyLevel.None ? null : UrgencyToString[urgency]
            };

            request.JsonSerializer = new JsonNoNull();
            request.AddJsonBody(body);
            try
            {
                var result = await client.PatchAsync <SingleTicketResponse>(request);

                return(new TicketsResult()
                {
                    Success = true,
                    Tickets = new Ticket[] { ConvertTicket(result.result) }
                });
            }
            catch (Exception ex)
            {
                return(new TicketsResult()
                {
                    Success = false,
                    ErrorMessage = ex.Message
                });
            }
        }
Example #6
0
        public async Task <TicketsResult> CreateTicket(string title, string description, UrgencyLevel urgency)
        {
            try
            {
                var request = CreateRequest(TicketResource);
                var body    = new CreateTicketRequest()
                {
                    caller_id         = userId,
                    short_description = title,
                    description       = description,
                    urgency           = ServiceNowHelper.UrgencyToString[urgency]
                };
                request.AddJsonBody(body);
                var response = await client.ExecuteTaskAsync(request, CancellationToken.None, Method.POST);

                // Return Response
                return(response.ProcessCreateUpdateCloseTicketIRestResponse());
            }
            catch (Exception ex)
            {
                return(new TicketsResult()
                {
                    Success = false,
                    ErrorMessage = ex.Message
                });
            }
        }
Example #7
0
        public async Task <TicketsResult> UpdateTicket(string id, string title = null, string description = null, UrgencyLevel urgency = UrgencyLevel.None)
        {
            var request = CreateRequest($"{TicketResource}/{id}?sysparm_exclude_ref_link=true");
            var body    = new CreateTicketRequest()
            {
                short_description = title,
                description       = description,
                urgency           = urgency == UrgencyLevel.None ? null : ServiceNowHelper.UrgencyToString[urgency]
            };

            request.JsonSerializer = new JsonNoNull();
            request.AddJsonBody(body);
            try
            {
                var response = await client.ExecuteTaskAsync(request, CancellationToken.None, Method.PATCH);

                // Process and Return Correct Response
                return(response.ProcessCreateUpdateCloseTicketIRestResponse());
            }
            catch (Exception ex)
            {
                return(new TicketsResult()
                {
                    Success = false,
                    ErrorMessage = ex.Message
                });
            }
        }
Example #8
0
 internal void Log(UrgencyLevel level, string content, object counter = null)
 {
     LogHelper.Log(level, content, counter);
 }
    private GameObject CreateNotificationGO(Transform parent, bool destroyOnClick, string description, UrgencyLevel urgencyLevel, bool destroyExisting, List <string> buttonTitles, List <Action> buttonActions)
    {
        GameObject notificationGO = Instantiate(notificationPrefab);

        notificationGO.transform.SetParent(parent);
        notificationGO.transform.SetSiblingIndex(0);
        notificationGO.transform.localScale = Vector3.one;
        Notification notification = notificationGO.GetComponent <Notification>();

        notification.descriptionGO.text = description;
        if (buttonActions != null)
        {
            if (buttonActions.Count != buttonTitles.Count)
            {
                Debug.LogError("Unmatched number of button titles to actions!");
            }
            foreach (Action action in buttonActions)
            {
                GameObject buttonGO = Instantiate(buttonPrefab);
                buttonGO.transform.SetParent(notification.buttonParent.transform);
                buttonGO.transform.localScale = Vector3.one;
                if (destroyOnClick)
                {
                    buttonGO.GetComponent <Button>().onClick.AddListener(() => action.Invoke());
                    buttonGO.GetComponent <Button>().onClick.AddListener(() => Destroy(notificationGO));
                }
                else
                {
                    buttonGO.GetComponent <Button>().onClick.AddListener(() => action.Invoke());
                }

                // Button texts
                buttonGO.GetComponentInChildren <TextMeshProUGUI>().text = buttonTitles[buttonActions.IndexOf(action)];
            }
        }

        // Colour based on urgency
        if (urgencyLevel == UrgencyLevel.High)
        {
            notificationGO.GetComponent <Image>().color = new Color(1, 0.5679187f, 0.06666666f);
            notification.descriptionGO.color            = Color.white;
        }
        else if (urgencyLevel == UrgencyLevel.Medium)
        {
            notificationGO.GetComponent <Image>().color = new Color(1, 0.8666667f, 0.06666667f);
            notification.descriptionGO.color            = Color.black;
        }
        else if (urgencyLevel == UrgencyLevel.Low)
        {
            notificationGO.GetComponent <Image>().color = new Color(0.2313726f, 0.1529412f, 0.7294118f);
            notification.descriptionGO.color            = Color.white;
        }

        notification.buttonClose.onClick.AddListener(delegate() { CloseNotification(notificationGO); });

        return(notificationGO);
    }
Example #10
0
    IEnumerator SendID(int id, UrgencyLevel level)
    {
        float time  = Time.time;
        float rTime = Time.realtimeSinceStartup;

        Debug.Log(rTime);

        string n = "0", m = "0", h = "0";

        switch (level)
        {
        case UrgencyLevel.None: n = "1"; break;

        case UrgencyLevel.Med:  m = "1"; break;

        case UrgencyLevel.High: h = "1"; break;
        }

        string connectionString = webServiceUrl +
                                  "?ssid=" + spreadsheetId +
                                  "&sheet=" + urgencyWorksheet +
                                  "&pass="******"&val1=" + id +
                                  "&val2=" + level.ToString();

        for (int i = 3; i < 20; i++)
        {
            connectionString += "&val" + i + "=" + "";
        }

        connectionString += "&action=SetData";

        if (debugMode)
        {
            Debug.Log("Connection String: " + connectionString);
        }
        WWW   www               = new WWW(connectionString);
        float elapsedTime       = 0.0f;

        while (!www.isDone)
        {
            elapsedTime += Time.deltaTime;
            if (elapsedTime >= maxWaitTime)
            {
                // Error handling here.
                break;
            }

            yield return(null);
        }

        if (!www.isDone || !string.IsNullOrEmpty(www.error))
        {
            // Error handling here.

            if (debugMode)
            {
                Debug.Log("error " + www.error);
            }
            yield break;
        }

        string response = www.text;

        if (response.Contains("Incorrect Password"))
        {
            // Error handling here.

            if (debugMode)
            {
                Debug.Log("incorrect password");
            }
            yield break;
        }

        if (response.Contains("RCVD OK"))
        {
            // Data correctly sent!

            if (debugMode)
            {
                Debug.Log("correctly sent");
            }
            yield break;
        }
    }
Example #11
0
 public void SaveID(int id, UrgencyLevel level)
 {
     StartCoroutine(SendID(id, level));
 }
Example #12
0
 /// <summary>
 /// Represent a debug message.
 /// </summary>
 /// <param name="_msg">Message to store.</param>
 /// <param name="_ulvl">Urgency level.</param>
 public WarningString(string _msg, UrgencyLevel _ulvl)
 {
     message      = _msg;
     urgencyLevel = _ulvl;
 }