Esempio n. 1
0
            public static List <Global.User> LoadUsersFromXML()
            {
                List <Global.User> list      = new List <Global.User>();
                XmlNodeList        userNodes = xmldoc.GetElementsByTagName("User");

                foreach (XmlNode xmlnode in userNodes)
                {
                    XmlAttributeCollection xmlAttrs = xmlnode.Attributes;
                    list.Add(new Global.User
                    {
                        username    = xmlAttrs.GetNamedItem("username").InnerText,
                        password    = xmlAttrs.GetNamedItem("password").InnerText,
                        banned      = Boolean.Parse(xmlAttrs.GetNamedItem("banned").InnerText),
                        banReason   = xmlAttrs.GetNamedItem("banReason").InnerText,
                        bannedUntil = xmlAttrs.GetNamedItem("bannedUntil").InnerText
                    });
                }
                return(list);
            }
Esempio n. 2
0
        private void parseNcx(string ncxPath)
        {
            //Presentation presentation = DTBooktoXukConversion.m_Project.GetPresentation(0);
            Presentation presentation = m_Project.GetPresentation(0);
            //XmlDocument ncxXmlDoc = DTBooktoXukConversion.readXmlDocument(ncxPath);
            XmlDocument ncxXmlDoc = readXmlDocument(ncxPath);


            XmlNodeList listOfHeadRootNodes = ncxXmlDoc.GetElementsByTagName("head");

            if (listOfHeadRootNodes != null)
            {
                foreach (XmlNode headNodeRoot in listOfHeadRootNodes)
                {
                    XmlNodeList listOfMetaNodes = headNodeRoot.ChildNodes;
                    if (listOfMetaNodes != null)
                    {
                        foreach (XmlNode metaNode in listOfMetaNodes)
                        {
                            if (metaNode.NodeType == XmlNodeType.Element &&
                                metaNode.Name == "meta")
                            {
                                XmlAttributeCollection attributeCol = metaNode.Attributes;

                                if (attributeCol != null)
                                {
                                    XmlNode attrName    = attributeCol.GetNamedItem("name");
                                    XmlNode attrContent = attributeCol.GetNamedItem("content");
                                    if (attrName != null && attrContent != null && !String.IsNullOrEmpty(attrName.Value) &&
                                        !String.IsNullOrEmpty(attrContent.Value))
                                    {
                                        Metadata md = presentation.MetadataFactory.CreateMetadata();
                                        md.Name    = attrName.Value;
                                        md.Content = attrContent.Value;
                                        presentation.AddMetadata(md);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        private static void SaveToDB(XmlDocument xml, string SignalId)
        {
            MOE.Common.Data.MOE.Controller_Event_LogDataTable elTable = new MOE.Common.Data.MOE.Controller_Event_LogDataTable();
            UniqueConstraint custUnique =
                new UniqueConstraint(new DataColumn[] { elTable.Columns["SignalID"],
                                                        elTable.Columns["Timestamp"],
                                                        elTable.Columns["EventCode"],
                                                        elTable.Columns["EventParam"] });

            elTable.Constraints.Add(custUnique);

            XmlNodeList list = xml.SelectNodes("/EventResponses/EventResponse/Event");

            foreach (XmlNode node in list)
            {
                XmlAttributeCollection attrColl = node.Attributes;

                DateTime EventTime  = Convert.ToDateTime(attrColl.GetNamedItem("TimeStamp").Value);
                int      EventCode  = Convert.ToInt32(attrColl.GetNamedItem("EventTypeID").Value);
                int      EventParam = Convert.ToInt32(attrColl.GetNamedItem("Parameter").Value);

                try
                {
                    MOE.Common.Data.MOE.Controller_Event_LogRow eventrow = elTable.NewController_Event_LogRow();


                    eventrow.Timestamp  = EventTime;
                    eventrow.SignalID   = SignalId;
                    eventrow.EventCode  = EventCode;
                    eventrow.EventParam = EventParam;

                    elTable.AddController_Event_LogRow(eventrow);
                }
                catch
                {
                }
            }
            MOE.Common.Business.BulkCopyOptions Options = new MOE.Common.Business.BulkCopyOptions(Properties.Settings.Default.SPM, Properties.Settings.Default.DestinationTableName,
                                                                                                  Properties.Settings.Default.WriteToConsole, Properties.Settings.Default.forceNonParallel, Properties.Settings.Default.MaxThreads, false,
                                                                                                  Properties.Settings.Default.EarliestAcceptableDate, Properties.Settings.Default.BulkCopyBatchSize, Properties.Settings.Default.BulkCopyTimeOut);

            MOE.Common.Business.SignalFtp.BulktoDb(elTable, Options);
        }
Esempio n. 4
0
        private ISubCommand createAddLabelToMergeRequestCommand(XmlAttributeCollection attributes)
        {
            XmlNode label = attributes.GetNamedItem("Label");

            if (label == null)
            {
                return(null);
            }
            return(new AddLabelToMergeRequestCommand(_callback, label.Value));
        }
Esempio n. 5
0
        private ISubCommand createEndPointPOSTCommand(XmlAttributeCollection attributes)
        {
            XmlNode endpoint = attributes.GetNamedItem("EndPoint");

            if (endpoint == null)
            {
                return(null);
            }
            return(new MergeRequestEndPointPOSTCommand(_callback, endpoint.Value));
        }
Esempio n. 6
0
        private ISubCommand createSendNoteCommand(XmlAttributeCollection attributes)
        {
            XmlNode body = attributes.GetNamedItem("Body");

            if (body == null)
            {
                return(null);
            }
            return(new SendNoteCommand(_callback, body.Value));
        }
        public static IApiResponse GetResponse(XmlNode node)
        {
            if (node == null || node.Attributes.Count < 0)
            {
                throw new ArgumentException("node");
            }

            XmlNode typeNode = node.Attributes.GetNamedItem("type");

            if (typeNode != null)
            {
                string type = typeNode.Value;

                switch (type)
                {
                case "list":
                    return(new ApiResponseList(node));

                case "set":
                    return(new ApiResponseSet(node));

                case "exception":
                    XmlAttributeCollection attributes = node.Attributes;
                    string code = attributes.GetNamedItem("code") != null
                            ?
                                  attributes.GetNamedItem("code").Value : "0";

                    string detail = attributes.GetNamedItem("detail") != null
                            ?
                                    attributes.GetNamedItem("detail").Value : string.Empty;

                    throw new Exception(node.Value
                                        + Environment.NewLine + code
                                        + Environment.NewLine + detail);

                default:
                    break;
                }
            }

            return(new ApiResponseElement(node));
        }
        /// -------------------------------------------------------------------------------------
        /// <summary>
        /// Get the ws value (hvo) from the writing system identifier contained in the given
        /// attributes
        /// </summary>
        /// <param name="attribs">Collection of attributes that better have a "wsId"
        /// attribute</param>
        /// <returns></returns>
        /// -------------------------------------------------------------------------------------
        private int GetWs(XmlAttributeCollection attribs)
        {
            string wsId = attribs.GetNamedItem("wsId").Value;

            if (string.IsNullOrEmpty(wsId))
            {
                return(0);
            }

            return(m_scr.Services.WritingSystemManager.GetWsFromStr(wsId));
        }
Esempio n. 9
0
        public static string GetNamedItemValueOrEmpty(this XmlAttributeCollection iAttibutes, string iName)
        {
            string  lResult    = "";
            XmlNode lAttribute = iAttibutes.GetNamedItem(iName);

            if (lAttribute != null)
            {
                lResult = lAttribute.Value;
            }
            return(lResult);
        }
Esempio n. 10
0
        public static Genre[] getGenres()
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();
            XmlNode list = get("genre", "primary", null);

            if (list != null)
            {
                Genre[] genres = new Genre[list.ChildNodes.Count];
                for (int i = 0; i < list.ChildNodes.Count; ++i)
                {
                    XmlAttributeCollection attributes = list.ChildNodes[i].Attributes;
                    genres[i] = new Genre(
                        attributes.GetNamedItem("name").InnerText,
                        attributes.GetNamedItem("id").InnerText
                        );
                }
                return(genres);
            }
            return(new Genre[] { });
        }
    public void RemoveXmlNode(string InherentNumber, string Bool)
    {
        Characteristics = new List <XMLCharInfoCharacteristicData>();
        XmlDocument Document = new XmlDocument();

        Document.Load(filePath);
        XmlNode node = Document.SelectSingleNode("/descendant::CharacteristicList/Characteristic");
        XmlAttributeCollection acxNode = node.Attributes;

        if (acxNode.GetNamedItem("InherentNumber" + InherentNumber).Value != null)
        {
            Debug.Log("아아");
            acxNode.GetNamedItem("Bool").Value = "1";
        }
        else
        {
            return;
        }
        Document.Save(filePath);
    }
Esempio n. 12
0
 public Component(string aParameter, XmlAttributeCollection aAttributes, PageDefinitions.Constant[] aConstants)
 {
     if (aAttributes != null && aAttributes.Count > 0)
     {
         XmlNode state = aAttributes.GetNamedItem("id");
         if (state != null)
         {
             Set(state.Value, aParameter, aAttributes, aConstants);
         }
     }
 }
Esempio n. 13
0
        public string GetAttribute(string attribute)
        {
            XmlNode attribnode = attributes.GetNamedItem(attribute);

            if (attribnode == null)
            {
                return(null);
            }

            return(attribnode.Value);
        }
Esempio n. 14
0
        public string ExtractAttribute(XmlDocument doc, string name)
        {
            XmlAttributeCollection attrs = doc.DocumentElement.Attributes;
            XmlAttribute           attr  = (XmlAttribute)attrs.GetNamedItem(name);

            if (null == attr)
            {
                return(null);
            }
            return(attr.Value);
        }
    private IEnumerator waitForSuitPurchase(WWW www, int suitToBuy)
    {
        yield return(www);

        if (www.error == null)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(www.text);
            XmlNode node = xmlDoc.FirstChild;
            if (node == null)
            {
                Debug.Log("Purchase Authentication was NULL");
                yield break;
            }
            XmlAttributeCollection data   = node.Attributes;
            XmlAttribute           status = (XmlAttribute)data.GetNamedItem("status");
            string msg = string.Empty;
            if (data.GetNamedItem("message") != null)
            {
                msg = data.GetNamedItem("message").Value;
            }
            switch (status.Value)
            {
            case "success":
                GameData.AddOwnedSuit(suitToBuy);
                GameData.MyTotalCredits -= GameData.getExosuit(suitToBuy).mCost;
                MessageBox.AddMessage("Suit Purchase Success!", "Your Suit was successfully Purchased.", null, true, MessageBox.MessageType.MB_OK, null);
                MessageBox.AddMessage("Equip New Suit?", "Would you like to equip your new suit?", null, false, MessageBox.MessageType.MB_YESNO, tabshowcase.EquipSelected);
                break;

            case "fail":
                MessageBox.AddMessage("Operation Error | Game DB Says You Cannot Purchase", msg, null, true, MessageBox.MessageType.MB_OK, null);
                break;
            }
        }
        else
        {
            MessageBox.AddMessage("ERROR PURCHASING SUIT!", "You Cannot Purchase this suit at this time.", null, true, MessageBox.MessageType.MB_OK, null);
            Debug.Log("@Error Purchasing Suit:" + www.error.ToString());
        }
    }
Esempio n. 16
0
        private static XmlNodeList SelectAttributes(XmlNode parentNode, string path)
        {
            Debug.Assert(path[0] == '@');

            int pos = 1;
            XmlAttributeCollection attributes = parentNode.Attributes;
            XmlPatchNodeList       nodeList   = null;

            for (;;)
            {
                string name = ReadAttrName(path, ref pos);

                if (nodeList == null)
                {
                    if (pos == path.Length)
                    {
                        nodeList = new SingleNodeList();
                    }
                    else
                    {
                        nodeList = new MultiNodeList();
                    }
                }

                XmlNode attr = attributes.GetNamedItem(name);
                if (attr == null)
                {
                    OnNoMatchingNode(path);
                }

                nodeList.AddNode(attr);

                if (pos == path.Length)
                {
                    break;
                }
                else if (path[pos] == '|')
                {
                    pos++;
                    if (path[pos] != '@')
                    {
                        OnInvalidExpression(path);
                    }
                    pos++;
                }
                else
                {
                    OnInvalidExpression(path);
                }
            }

            return(nodeList);
        }
Esempio n. 17
0
 /// <summary>
 /// Retrieves the value for the specified attribute name from the
 /// collection of attributes.
 /// </summary>
 /// <param name="attrs">the attributes to process</param>
 /// <param name="attrName">the name of the attribute desired</param>
 /// <returns>
 /// the parsed value if the attribute is found; otherwise null is returned.
 /// </returns>
 public static string GetAttributeValue(XmlAttributeCollection attrs, string attrName)
 {
     if (attrs != null)
     {
         XmlNode attrNode = attrs.GetNamedItem(attrName);
         if (attrNode != null)
         {
             return(attrNode.Value);
         }
     }
     return(null);
 }
        public QuicbooksResponse(string response, string queryNodeResult)
        {
            // Generate the target XML document
            outputXMLDoc = new XmlDocument();

            //en esta parte hay que revisar  los xml por donde pasen
            outputXMLDoc.LoadXml(response);

            qbXMLMsgsRsNodeList = outputXMLDoc.GetElementsByTagName(queryNodeResult);
            // Obtain response status
            System.Text.StringBuilder popupMessage = new System.Text.StringBuilder();
            XmlAttributeCollection    rsAttributes = qbXMLMsgsRsNodeList.Item(0).Attributes;
            //get the status Code, info and Severity
            string retStatusCode     = rsAttributes.GetNamedItem("statusCode").Value;
            string retStatusSeverity = rsAttributes.GetNamedItem("statusSeverity").Value;
            string retStatusMessage  = rsAttributes.GetNamedItem("statusMessage").Value;

            popupMessage.AppendFormat("statusCode = {0}, statusSeverity = {1}, statusMessage = {2}", retStatusCode, retStatusSeverity, retStatusMessage);
            lastMessage = retStatusMessage;
            success     = retStatusCode == "0";
        }
        private void LoadCommands(CommandViewModel model)
        {
            doc = new XmlDocument();
            try { doc.Load(fileCommandsXMLPath); }
            catch (XmlException e)
            {
                System.Diagnostics.Debug.WriteLine("Error loading commands: " + e.Message);
                return;
            }
            catch (FileNotFoundException e)
            {
                System.Diagnostics.Debug.WriteLine("Error loading commands: " + e.Message);
                return;
            }

            IEnumerator docChildNodes = doc.ChildNodes.GetEnumerator();

            while (docChildNodes.MoveNext())
            {
                XmlNode currentNode = (docChildNodes.Current as XmlNode);
                if (currentNode.Name == "commands")
                {
                    IEnumerator docNodes = currentNode.ChildNodes.GetEnumerator();

                    while (docNodes.MoveNext())
                    {
                        XmlNode currentSubNode = (docNodes.Current as XmlNode);
                        XmlAttributeCollection currentAttrib = currentSubNode.Attributes;
                        model.Commands.Add(new CustomCommand()
                        {
                            Name         = currentAttrib.GetNamedItem("name").Value,
                            Example      = currentAttrib.GetNamedItem("example").Value,
                            ListenFor    = currentAttrib.GetNamedItem("listenfor").Value,
                            Feedback     = currentAttrib.GetNamedItem("feedback").Value,
                            BatchCommand = currentAttrib.GetNamedItem("batchcommand").Value
                        });
                    }
                }
            }
        }
Esempio n. 20
0
        }//parseOpfDcMetaData

        private void parseOpfMetaData(XmlDocument opfXmlDoc)
        {
            //Presentation presentation = DTBooktoXukConversion.m_Project.GetPresentation(0);
            Presentation presentation = m_Project.GetPresentation(0);

            XmlNodeList listOfMetaDataRootNodes = opfXmlDoc.GetElementsByTagName("x-metadata");

            if (listOfMetaDataRootNodes != null)
            {
                foreach (XmlNode mdNodeRoot in listOfMetaDataRootNodes)
                {
                    XmlNodeList listOfMetaDataNodes = mdNodeRoot.ChildNodes;
                    if (listOfMetaDataNodes != null)
                    {
                        foreach (XmlNode mdNode in listOfMetaDataNodes)
                        {
                            if (mdNode.NodeType == XmlNodeType.Element && mdNode.Name == "meta")
                            {
                                XmlAttributeCollection mdAttributes = mdNode.Attributes;

                                if (mdAttributes != null)
                                {
                                    XmlNode attrName    = mdAttributes.GetNamedItem("name");
                                    XmlNode attrContent = mdAttributes.GetNamedItem("content");

                                    if (attrName != null && attrContent != null && !String.IsNullOrEmpty(attrName.Value) &&
                                        !String.IsNullOrEmpty(attrContent.Value))
                                    {
                                        Metadata md = presentation.MetadataFactory.CreateMetadata();
                                        md.Name    = attrName.Value;
                                        md.Content = attrContent.Value;
                                        presentation.AddMetadata(md);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }//parseOpfMetaData
        public List <DatabaseTrackInfo> ParseQuery(XmlDocument xml_response)
        {
            Log.Debug("[Shoutcast] <ParseQuery> Start");

            List <DatabaseTrackInfo> station_list;
            XmlNodeList XML_station_nodes = xml_response.GetElementsByTagName("station");

            station_list = new List <DatabaseTrackInfo> (XML_station_nodes.Count);

            PrimarySource source = GetInternetRadioSource();  // If not found, throws exception caught in upper level.

            foreach (XmlNode node in XML_station_nodes)
            {
                XmlAttributeCollection xml_attributes = node.Attributes;

                try {
                    string name        = xml_attributes.GetNamedItem("name").InnerText;
                    string media_type  = xml_attributes.GetNamedItem("mt").InnerText;
                    string id          = xml_attributes.GetNamedItem("id").InnerText;
                    string genre       = xml_attributes.GetNamedItem("genre").InnerText;
                    string now_playing = xml_attributes.GetNamedItem("ct").InnerText;
                    string bitrate     = xml_attributes.GetNamedItem("br").InnerText;
                    int    id_int;
                    int    bitrate_int;

                    if (!Int32.TryParse(id.Trim(), out id_int))
                    {
                        continue; //Something wrong with id, skip this
                    }

                    DatabaseTrackInfo new_station = new DatabaseTrackInfo();

                    new_station.Uri           = new SafeUri("http://207.200.98.1/sbin/tunein-station.pls?id=" + id);
                    new_station.ArtistName    = "www.shoutcast.com";
                    new_station.Genre         = genre;
                    new_station.TrackTitle    = name;
                    new_station.Comment       = now_playing;
                    new_station.AlbumTitle    = now_playing;
                    new_station.MimeType      = media_type;
                    new_station.ExternalId    = id_int;
                    new_station.PrimarySource = source;
                    new_station.IsLive        = true;
                    Int32.TryParse(bitrate.Trim(), out bitrate_int);
                    new_station.BitRate = bitrate_int;
                    new_station.IsLive  = true;

                    Log.DebugFormat("[Shoutcast] <ParseQuery> Station found! Name: {0} URL: {1}",
                                    name, new_station.Uri.ToString());

                    station_list.Add(new_station);
                }
                catch (Exception e) {
                    Log.Warning("[Shoutcast] <ParseQuery> ERROR: ", e);
                    continue;
                }
            }

            Log.Debug("[Shoutcast] <ParseQuery> End");
            return(station_list);
        }
    private IEnumerator waitForProgUpdate(WWW www)
    {
        while (!www.isDone)
        {
            Debug.Log(www.progress);
            yield return(new WaitForEndOfFrame());
        }
        Debug.Log("Mission Progress update\n" + www.text);
        if (www.error == null)
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(www.text);
            XmlNode node = xmlDoc.FirstChild;
            if (node == null)
            {
                Debug.Log("Mission Progress was NULL");
                yield break;
            }
            Debug.Log("Mission Progress update\n" + www.text);
            XmlAttributeCollection data   = node.Attributes;
            XmlAttribute           status = (XmlAttribute)data.GetNamedItem("status");
            switch (status.Value)
            {
            case "success":
            {
                GameData.LatestMissionsInProgress.Clear();
                XmlNodeList missionsProg = xmlDoc.GetElementsByTagName("mission");
                for (int i = 0; i < missionsProg.Count; i++)
                {
                    XmlNode     prog     = missionsProg.Item(i);
                    XmlNodeList pData    = prog.ChildNodes;
                    Hashtable   progData = new Hashtable();
                    for (int s = 0; s < pData.Count; s++)
                    {
                        XmlNode Node = pData.Item(s);
                        progData.Add(value: Node.Attributes.GetNamedItem("value").Value, key: Node.Name);
                    }
                    GameData.addMissionInProgress(progData);
                }
                break;
            }

            case "fail":
                Logger.trace("No Mission Progress update");
                break;
            }
        }
        else
        {
            Logger.trace("No Mission Progress update");
        }
    }
        private void parseOpf(XmlDocument opfXmlDoc)
        {
            XmlNode packageNode = getFirstChildElementsWithName(opfXmlDoc, true, "package", null);

            if (packageNode != null)
            {
                XmlAttributeCollection packageNodeAttrs = packageNode.Attributes;
                if (packageNodeAttrs != null && packageNodeAttrs.Count > 0)
                {
                    m_PackageUniqueIdAttr = packageNodeAttrs.GetNamedItem("unique-identifier");
                }
            }

            parseMetadata(opfXmlDoc);

            List <string> spine;
            string        spineMimeType;
            string        dtbookPath;
            string        ncxPath;

            parseOpfManifest(opfXmlDoc, out spine, out spineMimeType, out dtbookPath, out ncxPath);

            if (dtbookPath != null)
            {
                string      fullDtbookPath = Path.Combine(Path.GetDirectoryName(m_Book_FilePath), dtbookPath);
                XmlDocument dtbookXmlDoc   = readXmlDocument(fullDtbookPath);
                parseMetadata(dtbookXmlDoc);
                parseContentDocument(dtbookXmlDoc, null, fullDtbookPath);
            }

            if (false && ncxPath != null) //we skip NCX metadata parsing (we get publication metadata only from OPF and DTBOOK/XHTMLs)
            {
                string      fullNcxPath = Path.Combine(Path.GetDirectoryName(m_Book_FilePath), ncxPath);
                XmlDocument ncxXmlDoc   = readXmlDocument(fullNcxPath);
                parseMetadata(ncxXmlDoc);
            }

            switch (spineMimeType)
            {
            case "application/smil":
            {
                parseSmiles(spine);
                break;
            }

            case "application/xhtml+xml":
            {
                parseContentDocuments(spine);
                break;
            }
            }
        }
        private string getAttribute(XmlAttributeCollection theAttributes, string strName)
        {
            XmlNode anAttribute = theAttributes.GetNamedItem(strName);

            if (anAttribute != null)
            {
                return(anAttribute.Value);
            }
            else
            {
                return("");
            }
        }
Esempio n. 25
0
        private static void WalkCustomerAddRs(string response)
        {
            if (response == null)
            {
                return;
            }

            //Parse the response XML string into an XmlDocument
            XmlDocument responseXmlDoc = new XmlDocument();

            responseXmlDoc.LoadXml(response);

            //Get the response for our request
            XmlNodeList CustomerAddRsList = responseXmlDoc.GetElementsByTagName("CustomerAddRs");

            if (CustomerAddRsList.Count == 1) //Should always be true since we only did one request in this sample
            {
                XmlNode responseNode = CustomerAddRsList.Item(0);
                //Check the status code, info, and severity
                XmlAttributeCollection rsAttributes = responseNode.Attributes;
                string statusCode     = rsAttributes.GetNamedItem("statusCode").Value;
                string statusSeverity = rsAttributes.GetNamedItem("statusSeverity").Value;
                string statusMessage  = rsAttributes.GetNamedItem("statusMessage").Value;

                // Check status and log any errors
                QBUtils.CheckStatus(statusCode, statusSeverity, statusMessage);

                //status code = 0 all OK, > 0 is warning
                if (Convert.ToInt32(statusCode) >= 0)
                {
                    XmlNodeList CustomerRetList = responseNode.SelectNodes("//CustomerRet");//XPath Query
                    for (int i = 0; i < CustomerRetList.Count; i++)
                    {
                        XmlNode CustomerRet = CustomerRetList.Item(i);
                        WalkCustomerRetForAdd(CustomerRet);
                    }
                }
            }
        }
Esempio n. 26
0
        //Unsubscribes this application from listening to add/modify/delete custmor event
        private static void UnsubscribeForEvents(QBSubscriptionType strType, bool bSilent)
        {
            RequestProcessor2 qbRequestProcessor;

            try
            {
                // Get an instance of the qbXMLRP Request Processor and
                // call OpenConnection if that has not been done already.
                qbRequestProcessor = new RequestProcessor2();
                qbRequestProcessor.OpenConnection("", strAppName);

                StringBuilder strRequest  = new StringBuilder(GetSubscriptionDeleteXML(strType));
                string        strResponse = qbRequestProcessor.ProcessSubscription(strRequest.ToString());

                //Parse the XML response to check the status
                XmlDocument outputXMLDoc = new XmlDocument();
                outputXMLDoc.LoadXml(strResponse);
                XmlNodeList qbXMLMsgsRsNodeList = outputXMLDoc.GetElementsByTagName("SubscriptionDelRs");

                XmlAttributeCollection rsAttributes = qbXMLMsgsRsNodeList.Item(0).Attributes;
                //get the status Code, info and Severity
                string retStatusCode     = rsAttributes.GetNamedItem("statusCode").Value;
                string retStatusSeverity = rsAttributes.GetNamedItem("statusSeverity").Value;
                string retStatusMessage  = rsAttributes.GetNamedItem("statusMessage").Value;

                if ((retStatusCode != "0") && (!bSilent))
                {
                    Console.WriteLine("Error while unsubscribing from events\n\terror Code - {0},\n\tSeverity - {1},\n\tError Message - {2}\n", retStatusCode, retStatusSeverity, retStatusMessage);
                    return;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while unsubscribing from QB events - " + ex.Message);
                qbRequestProcessor = null;
                return;
            }
            return;
        }
Esempio n. 27
0
        /// <summary>
        /// 获取指定配置项
        /// Item.All :      返回根节点的子节点列表 List<XmlNode>
        /// Item.Functions :返回可用功能列表 List<Config.Functions>
        /// Item.BlackList :返回黑名单列表  List<BlackListInfo>
        /// </summary>
        /// <param name="item">要获取的配置</param>
        /// <returns>返回值类型根据参数item不同而不同</returns>
        public static object Get(Item item)
        {
            if (!loaded_)
            {
                Load();
            }

            switch (item)
            {
            case Item.All:
                return(ConvertToList(xmlRoot_.SelectSingleNode("config").GetEnumerator(),
                                     (XmlNode node, out XmlNode ret) => {
                    ret = node;
                    return true;
                }));

            case Item.Functions:
                return(ConvertToList(xmlRoot_.SelectSingleNode("function").GetEnumerator(),
                                     (XmlNode node, out Functions ret) => {
                    ret = (Config.Functions)Enum.Parse(typeof(Config.Functions), node.Name);
                    return Get(node, "enabled", "false") == "true";
                }));

            case Item.BlackList:
                return(ConvertToList(xmlRoot_.SelectSingleNode("list/balck").GetEnumerator(),
                                     (XmlNode node, out BlackListItem ret) => {
                    XmlAttributeCollection attrs = node.Attributes;
                    ret = new BlackListItem {
                        type = attrs.GetNamedItem("type").InnerText,
                        id = attrs.GetNamedItem("id").InnerText,
                        reason = attrs.GetNamedItem("reason").InnerText,
                    };
                    return true;
                }));

            default:
                throw new ConfigParseException("Try to get an unkown Item");
            }
        }
Esempio n. 28
0
        private XmlNode CreateAttribute(XmlDocument doc, XmlNode currentNode, String axisName)
        {
            String attributeName = axisName.Substring(1);
            XmlAttributeCollection attributesMap = currentNode.Attributes;
            XmlNode attribute = attributesMap.GetNamedItem(attributeName);

            if (attribute == null)
            {
                attribute = doc.CreateAttribute(attributeName);
                attributesMap.SetNamedItem(attribute);
            }
            return(attribute);
        }
Esempio n. 29
0
        private void ProcessPdfFile(XmlNode fileNode, XmlNode pdfFileNode, string customerCode, string siteCode)
        {
            XmlAttributeCollection Attr = pdfFileNode.Attributes;
            string fileSize             = Attr.GetNamedItem("size").Value;
            string formId = Attr.GetNamedItem("formId").Value;

            string pdfFullName = GetDownloadFileName(customerCode, siteCode, formId, "pdf");

            if (!m_Utils.FileUpToDate(pdfFullName, fileSize))
            {
                DownloadPdf(customerCode, siteCode, formId, pdfFullName);
            }

            string destfileName = formId;

            //Copy pdf to print folder watcher pdf folder (later).
            AddPdfToDownloadedFileTable(pdfFullName, destfileName, fileSize);

            //Also dump a copy of this file node to print folder watcher folder manifest folder (later)
            //so that it can be aware of what printer or duplex to use.
            AddManifestToDownloadedFileTable(fileNode, destfileName);
        }
Esempio n. 30
0
        private static void CompareAttributes(XmlAttributeCollection attribs1, XmlAttributeCollection attribs2,
                                              string attribute)
        {
            var attr1 = attribs1.GetNamedItem(attribute);
            var attr2 = attribs2.GetNamedItem(attribute);

            Assert.IsFalse(attr1 == null && attr2 != null);
            Assert.IsFalse(attr1 != null && attr2 == null);
            if (attr1 != null)
            {
                Assert.AreEqual(attr1.Value, attr2.Value);
            }
        }