예제 #1
0
    // Recieve a message from an action being completed for feedback
    public void RecieveMessage(string message, WarningStatus status)
    {
        actionMessage = message;
        actionStatus  = status;
        timer         = 0;

        if (status == WarningStatus.Error)
        {
            settings.meshInfo = new GeneratedMeshInfo();
        }

        Debug.Log(status.ToString() + " - " + message);
    }
예제 #2
0
    // Recieve a message from an action being completed for feedback
    public void RecieveMessage(string message, WarningStatus status)
    {
        actionMessage = message;
        actionStatus  = status;
        timer         = 0;

        if (status == WarningStatus.Error)
        {
            settings.nodeInfo       = new GeneratedNodeSystem();
            settings.renderRealtime = false; // Stop realtime render when an error occured
        }

        Debug.Log(status.ToString() + " - " + message);
    }
예제 #3
0
    public void DrawSmallError(Rect rect, WarningStatus error = WarningStatus.Error)
    {
        if (rect.size != Vector2.zero)
        {
            GUILayout.BeginArea(rect);
        }

        GUILayout.Label(error == WarningStatus.Error ? errorSymbol : warningSymbol, smallErrorImage);

        if (rect.size != Vector2.zero)
        {
            GUILayout.EndArea();
        }
    }
예제 #4
0
    // Send a request for a message in the layout
    private void SendMessageRequest(string message, WarningStatus status)
    {
        if (status == WarningStatus.Warning)
        {
            style.DrawWarning(message);
        }
        else if (status == WarningStatus.Error)
        {
            style.DrawError(message);
        }
        else
        {
            style.DrawInfo(message);
        }

        if (status != WarningStatus.None)
        {
            settings.currentTabStatus = status;
        }
    }
예제 #5
0
    // Send a request for a message in the layout
    private void SendMessageRequest(string message, int index, WarningStatus status)
    {
        if (status == WarningStatus.Warning)
        {
            style.DrawWarning(message);
        }
        else if (status == WarningStatus.Error)
        {
            style.DrawError(message);
        }
        else
        {
            style.DrawInfo(message);
        }

        if (index != -1)
        {
            settings.tabStatus[index] = status;
        }
    }
예제 #6
0
        private void EnqueueToUser(ContactType userType, WarningStatus statusOfFailedOrEnqueue,
                                   WarningStatus statusOfSendSuccess)
        {
            List <WarningInfo> alarms;

            //
            if (userType == ContactType.Support)
            {
                alarms = DataAccess.GetWarningInfo(_config.Top, (int)WarningStatus.WaitToSendToSupport,
                                                   (int)DealFlag.UnConfiremBySupport, _structureId);
            }
            else
            {
                alarms = DataAccess.GetWarningInfo(_config.Top, (int)WarningStatus.WaitToSendToClient,
                                                   (int)DealFlag.UnConfiremByClient, _structureId);
            }
            //
            if (alarms.Count == 0)
            {
                //logger.Info(string.Format("No alarm to send to {0}.", userType));
                return;
            }
            EnqueueAlarmsToUser(alarms, userType, statusOfFailedOrEnqueue, statusOfSendSuccess);
        }
예제 #7
0
        /// <summary>
        ///     入队列
        /// </summary>
        /// <param name="alarms"></param>
        /// <param name="userType"></param>
        /// <param name="statusOfFailedOrEnqueue"></param>
        /// <param name="statusOfSendSuccess"></param>
        private void EnqueueAlarmsToUser(List <WarningInfo> alarms, ContactType userType,
                                         WarningStatus statusOfFailedOrEnqueue,
                                         WarningStatus statusOfSendSuccess)
        {
            var enqueuedAlarms = new List <int>();

            foreach (WarningInfo alarm in alarms)
            {
                if (alarm.WarningLevel != string.Empty)
                {
                    try
                    {
                        if (_stuctToRoleContacts.ContainsKey(Convert.ToInt32(alarm.StructId)) &&
                            _stuctToRoleContacts[Convert.ToInt32(alarm.StructId)].ContainsKey((int)userType))
                        {
                            List <ContactsInfo> receivers =
                                _stuctToRoleContacts[Convert.ToInt32(alarm.StructId)][(int)userType].Where(
                                    m => m.FilterLevel >= Convert.ToInt32(alarm.WarningLevel)).ToList();
                            if (receivers.Count == 0)
                            {
                                enqueuedAlarms.Add(alarm.Id);
                                continue;
                            }
                            string sms = CreateSMS(alarm, userType);
                            foreach (ContactsInfo contact in receivers)
                            {
                                var smsData = new SMSData();
                                smsData.Phone = contact.ReceiverPhone;
                                smsData.Name  = contact.ReceiverName;
                                smsData.Sms   = sms;
                                smsData.Id    = alarm.Id;
                                _smsQueue.Enqueue(smsData);
                                if (_smsQueue.Count >= _config.MaxCapacity)
                                {
                                    logger.Error("Queue reach it's capacity.");
                                    return;
                                }
                                enqueuedAlarms.Add(alarm.Id);
                                logger.Debug(string.Format("Enqueue sms to {0}-{1}-{2} ; msg:{3}", userType,
                                                           contact.ReceiverName, contact.ReceiverPhone, sms));
                            }
                        }
                        else
                        {
                            enqueuedAlarms.Add(alarm.Id);
                        }
                    }
                    catch (CreateSMSException e)
                    {
                        logger.Error(e);
                        enqueuedAlarms.Add(alarm.Id);
                    }
                }
                else
                {
                    enqueuedAlarms.Add(alarm.Id);
                }
            }
            //
            if (enqueuedAlarms.Count != 0)
            {
                DataAccess.UpdateStatusById(enqueuedAlarms, (int)statusOfFailedOrEnqueue);
            }
        }