Esempio n. 1
0
        public void SendReport <T>(REPORT_TYPE _type, T _obj, Model.Header _header, string _eqpID)
        {
            try
            {
                switch (_type)
                {
                case REPORT_TYPE.EqpStatuChangeReport:
                    // Step 1: Check Validation of the object
                    //
                    if (!(_obj is Report.StatuChangeReport))
                    {
                        throw new ObjectValidationException();
                    }

                    // Step 2: Convert into JSON
                    //
                    string msg = SemiJSONHelper.GetString(_obj, _header, Model.MESSAGE_TYPE.REQUEST, _eqpID);

                    // step 3: Send to Server
                    //
                    if (!string.IsNullOrEmpty(msg))
                    {
                        SendAsyn(msg, true);
                    }

                    break;

                case REPORT_TYPE.EqpAlarmReport:
                    if (!(_obj is Report.AlarmReport))
                    {
                        throw new ObjectValidationException();
                    }

                    // TO-DO

                    break;

                case REPORT_TYPE.EqpEdcReport:
                    if (!(_obj is Report.EdcReport))
                    {
                        throw new ObjectValidationException();
                    }

                    // TO-DO

                    break;

                default:
                    throw new ObjectValidationException("Object type invalid");
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.ToString());
            }
        }
Esempio n. 2
0
        private void requestObject(object _obj, Model.Header _header)
        {
            try
            {
                if (_obj is Report.StatuChangeReport)
                {
                    string msg = SemiJSONHelper.GetString(_obj, _header, Model.MESSAGE_TYPE.RESPONSE, "A");

                    if (SemiManager.Instance != null)
                    {
                        SemiManager.Instance.SendAsyn(msg, false);
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(E_CODE.JSON_REQ_OBJECT_FAILED.ToString() + ":" + ex.Message);
            }
        }