public IDisposable Subscribe(IObserver <T> observer)
        {
            try
            {
                AbstractResponse response = this.connect();

                CancellationDisposable cd = new CancellationDisposable();

                IDisposable cancel = this.scheduler.Schedule(() =>
                {
                    try
                    {
                        XmlNode next = response.NextNode();
                        while (next != null && !cd.IsDisposed)
                        {
                            observer.OnNext((T)XmlReadWrite.CreateFromXml(typeof(T), next));
                            next = response.NextNode();
                        }
                        observer.OnCompleted();
                    }
                    catch (Exception e)
                    {
                        Log.LogException(e);
                        observer.OnError(e);
                    }
                });
                return(new CompositeDisposable(cd, cancel, response));
            }
            catch (Exception e)
            {
                Log.LogException(e);
                observer.OnError(e);
            }
            return(Disposable.Empty);
        }
Esempio n. 2
0
 protected override AbstractResponse DoCommunication(XmlNode request)
 {
     try
     {
         HttpWebRequest httpReq = this.authentication.GetHttpRequest(this.uri, request != null);
         if (request != null)
         {
             Stream reqStream = httpReq.GetRequestStream();
             XmlReadWrite.WriteToStream(true, request, reqStream);
             HttpWebResponse httpResp = (HttpWebResponse)httpReq.GetResponse();
             if (httpResp.StatusCode < HttpStatusCode.BadRequest)
             {
                 return(new HttpResponse(httpResp));
             }
             else
             {
                 throw new AdvanceIOException(string.Format("Response with {0} ({1}) Http status code", httpResp.StatusCode.ToString(), (int)httpResp.StatusCode));
             }
         }
         else
         {
             throw new AdvanceIOException("Request generation failed");
         }
     }
     catch (Exception e)
     {
         throw new AdvanceIOException(this.uri + " communication failed", e);
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Updates notification groups
        /// </summary>
        /// <remarks>
        /// Note that this update is considered complete, e.g., the existing group
        /// settings will be deleted and replaced by the contents of the map.
        /// </remarks>
        /// <param name="groups">notification group names with set of notification address by notification group types</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if  username or password is incorrect</exception>
        public void UpdateNotificationGroups(Dictionary <AdvanceNotificationGroupType, Dictionary <string, ICollection <string> > > groups)
        {
            XmlDocument req = XmlReadWrite.CreateFunctionRequest("update-notification-groups");

            AdvanceNotificationGroup.FillXmlElementFromDict(req.DocumentElement, groups);
            this.communicator.Send(req);
        }
Esempio n. 4
0
        /// <summary>
        /// Update flow descriptor in the given realm.
        /// </summary>
        /// <param name="realm">target realm</param>
        /// <param name="flow">flow descriptor XML</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if  username or password is incorrect</exception>
        public void UpdateFlow(string realm, XmlNode flow)
        {
            XmlDocument req = XmlReadWrite.CreateFunctionRequest("update-flow", "realm", realm);

            req.DocumentElement.AppendChild(req.ImportNode(flow, true));
            this.communicator.Send(req);
        }
Esempio n. 5
0
        /// <summary>
        /// Creates new realm.
        /// </summary>
        /// <param name="realm">realm name</param>
        /// <param name="byUser">user who creates the object</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if  username or password is incorrect</exception>
        public void CreateRealm(string realm, string byUser)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("realm", realm);
            attrs.Add("by-user", byUser);
            this.communicator.Send(XmlReadWrite.CreateFunctionRequest("update-realm", null, attrs));
        }
Esempio n. 6
0
    public XmlParsedInformation readDataStorageXml(string fileName)
    {
        //get the xml-file from the xmlreadWrite class.
        XmlDocument          doc      = XmlReadWrite.getInstance( ).readXmlDocument(fileName);
        XmlParsedInformation rootNode = XmlReadWrite.getInstance( ).parseXmlDocument(doc);

        return(rootNode);
    }
Esempio n. 7
0
        /// <summary>
        /// Delete a key entry from a keystore.
        /// </summary>
        /// <param name="keyStore">key store name</param>
        /// <param name="keyAlias">key alias</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if user is not allowed to delete key.</exception>
        public void DeleteKeyEntry(string keyStore, string keyAlias)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("keystore", keyStore);
            parameters.Add("keyalias", keyAlias);
            this.communicator.Send(XmlReadWrite.CreateFunctionRequest("delete-key-entry", null, parameters));
        }
Esempio n. 8
0
 /// <summary>
 /// gets a singleton instance of this class.
 /// </summary>
 /// <returns></returns>
 public static XmlReadWrite getInstance( )
 {
     if (_instance == null)
     {
         _instance = new XmlReadWrite( );
     }
     return(_instance);
 }
Esempio n. 9
0
        /// <summary>
        /// Import a private key into a designated key store.
        /// </summary>
        /// <param name="request">represents the key store and key alias to import</param>
        /// <param name="data">ckey in textual PEM format.</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if user is not allowed to export.</exception>
        public void ImportPrivateKey(AdvanceKeyStoreExport request, string keyData, string certData)
        {
            XmlDocument req = XmlReadWrite.CreateFunctionRequest("import-private-key", request);

            XmlReadWrite.AddTextNode(req.DocumentElement, "private-key", keyData);
            XmlReadWrite.AddTextNode(req.DocumentElement, "certificate", certData);
            this.communicator.Send(req);
        }
Esempio n. 10
0
        /// <summary>
        /// Ask for the observable sequence of block diagnostic messages for the given block
        /// within the given realm.
        /// </summary>
        /// <param name="realm">realm</param>
        /// <param name="blockId">block unique identifier (as in the flow)</param>
        /// <returns>observable for the diagnostic messages</returns>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if user is not allowed to update a flow.</exception>
        public IObservable <BlockDiagnostic> DebugBlock(string realm, string blockId)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("realm", realm);
            attrs.Add("port-id", blockId);
            return(this.communicator.Receive <BlockDiagnostic>(XmlReadWrite.CreateFunctionRequest("debug-block", null, attrs), new NewThreadScheduler()));
        }
Esempio n. 11
0
        /// <summary>
        /// Start a realm's execution.
        /// </summary>
        /// <param name="name">realm's name</param>
        /// <param name="byUser">user who is starting the realm</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if user is not allowed to start the realm or other problems arise.</exception>
        public void StartRealm(string name, string byUser)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("name", name);
            parameters.Add("by-user", byUser);
            this.communicator.Send(XmlReadWrite.CreateFunctionRequest("start-realm", null, parameters));
        }
Esempio n. 12
0
        /// <summary>
        /// Query block state.
        /// </summary>
        /// <param name="realm">realm name</param>
        /// <param name="blockId"> block identifier</param>
        /// <returns>Flow descriptor xml element</returns>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if  username or password is incorrect</exception>
        public XmlNode QueryBlockState(string realm, string blockId)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("realm", realm);
            attrs.Add("block-id", blockId);
            return(this.communicator.Query(XmlReadWrite.CreateFunctionRequest("query-block-state", null, attrs)));
        }
 public XmlNode NextNode()
 {
     if (this.xmlReader == null)
     {
         this.xmlReader = XmlReader.Create(this.GetResponseStream());
     }
     return(XmlReadWrite.ReadFregment(this.xmlReader));
 }
Esempio n. 14
0
        /// <summary>
        /// Enable/disable a user.
        /// </summary>
        /// <param name="userName">User's identifier</param>
        /// <param name="enabled">if true enable otherwise disable</param>
        /// <param name="byUser">user who is changes it</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if  username or password is incorrect</exception>
        public void EnableUser(string userName, bool enabled, string byUser)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("user-name", userName);
            attrs.Add("enabled", enabled);
            attrs.Add("by-user", byUser);
            this.communicator.Send(XmlReadWrite.CreateFunctionRequest("enable-user", null, attrs));
        }
Esempio n. 15
0
        /// <summary>
        /// Ask for the observable sequence of port messages of the given port/block/realm.
        /// </summary>
        /// <param name="realm">realm</param>
        /// <param name="blockId">block unique identifier (as in the flow)</param>
        /// <param name="port">port name</param>
        /// <returns>observable of parameter messages</returns>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if user is not allowed to debug in the realm or referenced parameter is missing.</exception>
        public IObservable <PortDiagnostic> DebugParameter(string realm, string blockId, string port)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("realm", realm);
            attrs.Add("block-id", realm);
            attrs.Add("port", port);
            return(this.communicator.Receive <PortDiagnostic>(XmlReadWrite.CreateFunctionRequest("debug-parameter", null, attrs), new NewThreadScheduler()));
        }
Esempio n. 16
0
        /// <summary>
        /// Observe the output of the specified port in the given realm.
        /// </summary>
        /// <param name="realm">target realm</param>
        /// <param name="portId">port identifier of an input port returned by the queryPorts() method.</param>
        /// <returns>observable which will send out the values</returns>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if user is not has no right to access the realm/ports</exception>
        public IObservable <XmlNode> ReceivePort(string realm, string portId)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("realm", realm);
            attrs.Add("port-id", portId);

            return(this.communicator.Receive <XmlNode>(XmlReadWrite.CreateFunctionRequest("receve-port", null, attrs), new NewThreadScheduler()));
        }
Esempio n. 17
0
        /// <summary>
        /// Check if the user has the expected right
        /// </summary>
        /// <param name="userName">user's name</param>
        /// <param name="expected">expected right</param>
        /// <returns>true if has the expected right</returns>
        public bool HasUserRight(string userName, AdvanceUserRights expected)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("user-name", userName);
            attrs.Add("expected", expected);
            XmlNode resp = this.communicator.Query(XmlReadWrite.CreateFunctionRequest("has-user-right", null, attrs));

            return(XmlReadWrite.GetBoolContent(resp, false));
        }
Esempio n. 18
0
        public void Checklang()
        {
            Launcher     obj = new Launcher();
            XmlReadWrite xml = new XmlReadWrite();

            if (xml.ReadXML())
            {
                obj.Checklang(false);
            }
            obj.Checklang(true);
        }
Esempio n. 19
0
        /// <summary>
        /// Query notification group
        /// </summary>
        /// <param name="type">group type</param>
        /// <param name="name">group name</param>
        /// <returns>set of contact information</returns>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if  username or password is incorrect</exception>
        public List <string> QueryNotificationGroup(AdvanceNotificationGroupType type, string name)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("type", type);
            attrs.Add("name", name);
            XmlNode resp = this.communicator.Query(XmlReadWrite.CreateFunctionRequest("query-notification-group", null, attrs));
            AdvanceNotificationGroup ng = XmlReadWrite.CreateFromXml <AdvanceNotificationGroup>(resp);

            return(ng.Contacts);
        }
        /// <summary>
        /// Fill object data from xml node
        /// </summary>
        /// <param name="source">Source Xml</param>
        protected override void LoadFromXmlNode(XmlNode source)
        {
            this.Type = GetEnumAttribute <AdvanceNotificationGroupType>(source, "type", AdvanceNotificationGroupType.EMAIL);
            this.Name = GetAttribute(source, "name", null);
            HashSet <string> ret = new HashSet <string>();

            foreach (XmlNode node in XmlReadWrite.GetChildren(source, "contact"))
            {
                ret.Add(XmlReadWrite.GetAttribute(node, "value"));
            }
        }
        /// <summary>
        /// Načítanie vstupu aplikácie z XML
        /// </summary>
        public void LoadDataXml()
        {
            Pouzivatelia = new HashSet <Pouzivatel>();
            Skupiny      = new HashSet <Skupina>();
            XmlReadWrite RW = new XmlReadWrite();

            //RW.LoadPouzivatelia("..\\..\\..\\DATA\\test_pouzivatelia.xml", t_Uziv);
            //RW.LoadSkupiny("..\\..\\..\\DATA\\test_skupiny.xml", t_Skupiny);
            RW.LoadPouzivatelia(_nastavenia.Get("cestaXML_Pouzivatelia"), Pouzivatelia);
            RW.LoadSkupiny(_nastavenia.Get("cestaXML_Skupiny"), Skupiny);
        }
Esempio n. 22
0
        /// <summary>
        /// ends a sequence of values to the same or multiple ports in a batch.
        /// </summary>
        /// <param name="realm">target realm</param>
        /// <param name="portValues">equence of port id and value XML pairs</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if user is not has no right to access the realm/ports</exception>
        public void SendPort(string realm, Dictionary <string, XmlNode> portValues)
        {
            XmlDocument req = XmlReadWrite.CreateFunctionRequest("send-port", "realm", realm);

            foreach (KeyValuePair <string, XmlNode> pv in portValues)
            {
                XmlElement node = XmlReadWrite.AddAttributeNode(req.DocumentElement, "entry", "port", pv.Key);
                node.AppendChild(req.ImportNode(pv.Value, true));
            }
            this.communicator.Send(req);
        }
Esempio n. 23
0
        /// <summary>
        /// Saves block state
        /// </summary>
        /// <param name="realm">target realm</param>
        /// <param name="blockId">arget block identifier</param>
        /// <param name="state">state Xml element or null</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceXMLException">On Xml parsing error</exception>
        /// <exception cref="AdvanceControlException">if  username or password is incorrect</exception>
        public void UpdateBlockState(string realm, string blockId, XmlNode state)
        {
            XmlDocument req = XmlReadWrite.CreateFunctionRequest("update-block-state");

            XmlReadWrite.AddAttribute(req.DocumentElement, "realm", realm);
            XmlReadWrite.AddAttribute(req.DocumentElement, "block-id", blockId);
            if (state != null)
            {
                req.DocumentElement.AppendChild(req.ImportNode(state, true));
            }
            this.communicator.Send(req);
        }
Esempio n. 24
0
        /// <summary>
        /// Inject a value into the given  realm/block/input port.
        /// </summary>
        /// <param name="realm">realm</param>
        /// <param name="blockId">block unique identifier (as in the flow)</param>
        /// <param name="port">port name</param>
        /// <param name="value">as XNElement to inject</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if user is not allowed to debug in the realm or referenced parameter is missing.</exception>
        public void InjectValue(string realm, string blockId, string port, XmlElement value)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("realm", realm);
            attrs.Add("block-id", blockId);
            attrs.Add("port", port);
            XmlDocument req = XmlReadWrite.CreateFunctionRequest("inject-value", null, attrs);

            req.DocumentElement.AppendChild(req.ImportNode(value, true));
            this.communicator.Send(req);
        }
Esempio n. 25
0
        /// <summary>
        /// Update a flow in a the given realm.
        /// </summary>
        /// <param name="realm">target realm</param>
        /// <param name="block">Flow content to upload</param>
        /// <param name="byUser">user who modifies the realm</param>
        /// <exception cref="AdvanceIOException">if network connection failed</exception>
        /// <exception cref="AdvanceControlException">if user is not allowed to update a flow.</exception>
        public void UpdateFlow(string realm, AdvanceCompositeBlock block, string byUser)
        {
            Dictionary <string, object> attrs = new Dictionary <string, object>();

            attrs.Add("realm", realm);
            attrs.Add("by-user", byUser);
            List <XmlReadWrite> pars = new List <XmlReadWrite>();

            pars.Add(new AdvanceFlow(block));
            XmlDocument req = XmlReadWrite.CreateFunctionRequest("update-flow", pars, attrs);

            this.communicator.Send(req);
        }
Esempio n. 26
0
        private void btnInvoke_Click(object sender, EventArgs e)
        {
            InterfaceDescription selectedInterface = this.cmbInterfaces.SelectedItem as InterfaceDescription;
            string method = this.cmbMethods.SelectedItem as string;

            object[] ps = GetActualParameters(selectedInterface.GetMethodParameters(method));
            try
            {
                this.rtxtResults.Clear();
                this.AddMessageLine("Invoke '" + method + "' from '" + selectedInterface);
                object response = selectedInterface.InvokeMethod(method, ps);
                if (response != null)
                {
                    Type respType = response.GetType();
                    if (respType.IsPrimitive || respType.Equals(typeof(string)))
                    {
                        this.AddMessageLine(response.ToString());
                    }
                    else
                    {
                        string fn = (this.outputDir == "") ? null : Utils.GetFilenameForCreate(this.outputDir, method, "xml");
                        if (fn != null)
                        {
                            this.AddMessageLine("Output in file: " + fn);
                        }
                        if (response is IObservable <XmlNode> )
                        {
                            this.StartObservable <XmlNode>(response as IObservable <XmlNode>, fn);
                        }
                        else if (response is IObservable <XmlNode> )
                        {
                            this.StartObservable <XmlReadWrite>(response as IObservable <XmlReadWrite>, fn);
                        }
                        else
                        {
                            if (fn != null)
                            {
                                XmlReadWrite.WriteToFile(fn, response);
                            }
                            XmlReadWrite xmlObj = (response is XmlReadWrite) ? (response as XmlReadWrite) : new XmlObjectSerializer(response);
                            this.AddMessageLine(xmlObj.ToString());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.AddErrMessage("Error", ex);
            }
        }
Esempio n. 27
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         _configuration = XmlReadWrite.Read("/XML/", _configuration, "set.config") as WeiXinConfiguration;
         if (_configuration != null)
         {
             txt_appid.Text           = _configuration.Appid;
             txt_secret.Text          = _configuration.AppSecret;
             txt_token.Text           = _configuration.Token;
             txt_encodingaeskey.Value = _configuration.EncodingAESKey;
         }
     }
 }
        public HttpResponseMessage Register(Register data)
        {
            var user = ParseAuthorizationHeader(this.Request);

            var result = XmlReadWrite.Register(user[0], user[1]);

            if (result)
            {
                return(Request.CreateResponse(HttpStatusCode.OK, ""));
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, "username taken"));
            }
        }
        /// <summary>
        /// Načítanie vstupu aplikácie z jednotlivého XML
        /// </summary>
        /// <param name="paCesta">Cesta k súboru</param>
        /// <param name="paNacitanie">Typ načítania True -> načíta skupiny, False -> načíta používateľov</param>
        public void LoadDataXmlImport(string paCesta, bool paNacitanie)
        {
            XmlReadWrite RW = new XmlReadWrite();

            if (paNacitanie)
            {
                Skupiny = new HashSet <Skupina>();
                RW.LoadSkupiny(paCesta, Skupiny);
            }
            else
            {
                Pouzivatelia = new HashSet <Pouzivatel>();
                RW.LoadPouzivatelia(paCesta, Pouzivatelia);
            }
        }
Esempio n. 30
0
 private object GetActualParameter(Type parType, object value)
 {
     if (parType.Equals(typeof(String)))
     {
         return(value);
     }
     else if (parType.IsPrimitive)
     {
         return(Convert.ChangeType(value, parType));
     }
     else
     {
         XmlNode node = XmlReadWrite.ReadFromStream(File.OpenRead((string)value));
         return(XmlReadWrite.CreateFromXml(parType, node));
     }
 }