Esempio n. 1
0
        internal void HandleCallException(C8oExceptionListener c8oExceptionListener, IDictionary <string, object> requestParameters, Exception exception)
        {
            c8oLogger._Warn("Handle a call exception", exception);

            if (c8oExceptionListener != null)
            {
                c8oExceptionListener.OnException(exception, requestParameters);
            }
        }
Esempio n. 2
0
        public void Call(IDictionary <string, object> parameters = null, C8oResponseListener c8oResponseListener = null, C8oExceptionListener c8oExceptionListener = null)
        {
            // IMPORTANT : all c8o calls have to end here !
            try
            {
                c8oLogger.LogMethodCall("Call", parameters);

                // Checks parameters validity
                if (parameters == null)
                {
                    parameters = new Dictionary <string, object>();
                }
                else
                {
                    // Clones parameters in order to modify them
                    parameters = new Dictionary <string, object>(parameters);
                }

                // Creates a async task running on another thread
                // Exceptions have to be handled by the C8oExceptionListener
                var task = new C8oCallTask(this, parameters, c8oResponseListener, c8oExceptionListener);
                task.Execute();
            }
            catch (Exception e)
            {
                HandleCallException(c8oExceptionListener, parameters, e);
            }
        }
Esempio n. 3
0
        //*** C8o calls ***//
        public void Call(string requestable, IDictionary <string, object> parameters = null, C8oResponseListener c8oResponseListener = null, C8oExceptionListener c8oExceptionListener = null)
        {
            try
            {
                if (requestable == null)
                {
                    throw new System.ArgumentNullException(C8oExceptionMessage.InvalidArgumentNullParameter("requestable"));
                }

                // Checks parameters validity
                if (parameters == null)
                {
                    parameters = new Dictionary <string, object>();
                }
                else
                {
                    // Clone parameters in order to modify them
                    parameters = new Dictionary <string, object>(parameters);
                }

                // Use the requestable string to add parameters corresponding to the c8o project, sequence, connector and transaction (<project>.<sequence> or <project>.<connector>.<transaction>)
                var matches = RE_REQUESTABLE.Match(requestable);
                if (!matches.Success)
                {
                    // The requestable is not correct so the default transaction of the default connector will be called
                    throw new System.ArgumentException(C8oExceptionMessage.InvalidRequestable(requestable));
                }

                // If the project name is specified
                if (matches.Groups[1].Value != "")
                {
                    parameters[ENGINE_PARAMETER_PROJECT] = matches.Groups[1].Value;
                }
                // If the C8o call use a sequence
                if (matches.Groups[2].Value != "")
                {
                    parameters[ENGINE_PARAMETER_SEQUENCE] = matches.Groups[2].Value;
                }
                else
                {
                    parameters[ENGINE_PARAMETER_CONNECTOR]   = matches.Groups[3].Value;
                    parameters[ENGINE_PARAMETER_TRANSACTION] = matches.Groups[4].Value;
                }

                Call(parameters, c8oResponseListener, c8oExceptionListener);
            }
            catch (Exception e)
            {
                HandleCallException(c8oExceptionListener, parameters, e);
            }
        }