Exemplo n.º 1
0
        public List <LinkIDAttribute> getAttributes(String userId, String attributeName)
        {
            setTargetIdentity(userId);

            QueryType     query     = new QueryType();
            QueryItemType queryItem = new QueryItemType();

            queryItem.objectType = DataServiceConstants.ATTRIBUTE_OBJECT_TYPE;
            query.QueryItem      = new QueryItemType[] { queryItem };

            SelectType select = new SelectType();

            select.Value     = attributeName;
            queryItem.Select = select;

            QueryResponseType response = this.client.Query(query);

            validateStatus(response.Status);

            // parse attributes
            List <LinkIDAttribute> attributes = new List <LinkIDAttribute>();

            if (null != response.Data)
            {
                foreach (DataType data in response.Data)
                {
                    attributes.Add(getAttribute(data.Attribute));
                }
            }
            return(attributes);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 序列化
        /// </summary>
        /// <param name="data"></param>
        /// <param name="ty"></param>
        static void SerializeResultToDisk(QueryResponseType data, QueryableTypes ty)
        {
            if (data.Status.code == StatusTypeCode.OK)
            {
                #region 输出成功

                foreach (var s in data.Status.Status)
                {
                    #region 访问所有的状态
                    if (s.code == StatusTypeCode.OK)
                    {
                        // use LINQ to match successful status result with matching dataset
                        DataType d = data.Data.Where(q => q.itemIDRef == s.@ref).FirstOrDefault();
                        if (d != null)
                        {
                            XmlSerializer     sr       = new XmlSerializer(typeof(DataType));
                            XmlWriterSettings settings = new XmlWriterSettings()
                            {
                                Indent          = true,
                                NewLineHandling = NewLineHandling.Entitize
                            };

                            // Simply dump dataset to xml file on disk...
                            using (XmlWriter wr = XmlWriter.Create(ty + "-" + d.itemIDRef.ToString() + ".xml", settings))
                            {
                                sr.Serialize(wr, d);
                            }
                        }
                    }
                    else
                    {
                        JLog.Instance.AppInfo(string.Format("code: {0}, comment: {1}", s.code, s.comment));
                    }
                    #endregion
                }
                #endregion
            }
            else
            {
                foreach (var stat in data.Status.Status)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("code: {0}, comment: {1}", stat.code, stat.comment));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Dumps EDS response data to the console (example)
        /// </summary>
        /// <param name="data"></param>
        private void HandleData(QueryResponseType data)
        {
            // if outer result a success...
            if (data.Status.code == StatusTypeCode.OK)
            {
                // visit each individual response using the status ref as a lookup
                foreach (var s in data.Status.Status)
                {
                    if (s.code == StatusTypeCode.OK)
                    {
                        // use LINQ to match successful status result with matching dataset
                        DataType d = data.Data.Where(q => q.itemIDRef == s.@ref).FirstOrDefault();
                        if (d != null)
                        {
                            XmlSerializer     sr       = new XmlSerializer(typeof(DataType));
                            XmlWriterSettings settings = new XmlWriterSettings()
                            {
                                Indent          = true,
                                NewLineHandling = NewLineHandling.Entitize
                            };

                            // Simply dump dataset to xml file to console...
                            using (XmlWriter wr = XmlWriter.Create(Console.Out, settings))
                            {
                                sr.Serialize(wr, d);
                            }
                        }
                    }
                    else
                    {
                        // Primitive error handling...
                        System.Diagnostics.Debug.WriteLine(string.Format("code: {0}, comment: {1}", s.code, s.comment));
                    }
                }
            }
            else
            {
                // Simply dump errors to diagnostic console.
                foreach (var stat in data.Status.Status)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("code: {0}, comment: {1}", stat.code, stat.comment));
                }
            }
        }
Exemplo n.º 4
0
        private bool ValidateResponse(QueryResponseType EDSResponse, string sEDSQuery, QueryableTypes type, QueryItemType[] queryItemType, out string sError)
        {
            if (EDSResponse == null || EDSResponse.Status == null || EDSResponse.Status.Status == null)
            {
                sError = "Either response, response.Status, or response.Status.Status was null";
                return(true);
            }

            bool          error = false;
            StringBuilder str   = new StringBuilder();

            ValidateStatus(new StatusType[] { EDSResponse.Status }, str, ref error, queryItemType);

            if (error == true)
            {
                Log.Error(str.ToString(), LogSource);
            }

            sError = str.ToString();

            return(error);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Builds an EDS query and dumps the result to disk if successful...
        /// </summary>
        /// <param name="notificationData"></param>
        internal void RequestData(NotificationData notificationData)
        {
            // EDS Query's require an outer request structure with a unique (guid) id and one request item per task
            QueryRequestType qry = new QueryRequestType()
            {
                itemID     = Guid.NewGuid(), // Outer request id
                QueryItems = new QueryItemType[]
                {
                    new QueryItemType()
                    {
                        itemID = Guid.NewGuid(),    // Inner request id for an item
                        // data type to query against
                        objectType = (QueryableTypes)Enum.Parse(typeof(QueryableTypes), notificationData.ObjectTypeString),
                        // build a freeform text query
                        Select = new QrySelectType()
                        {
                            Item = new QrySimpleTextType()
                            {
                                // Place our query expression here...
                                Query = string.Format("iid = \"{0}\" and bvid = \"{1}\"", notificationData.ObjectID, notificationData.Project)
                            }
                        }
                    }
                }
            };

            // sends query
            QueryResponseType data = _client.Query(qry);

            // if outer result a success...
            if (data.Status.code == StatusTypeCode.OK)
            {
                // visit each individual response using the status ref as a lookup
                foreach (var s in data.Status.Status)
                {
                    if (s.code == StatusTypeCode.OK)
                    {
                        // use LINQ to match successful status result with matching dataset
                        DataType d = data.Data.Where(q => q.itemIDRef == s.@ref).FirstOrDefault();
                        if (d != null)
                        {
                            XmlSerializer     sr       = new XmlSerializer(typeof(DataType));
                            XmlWriterSettings settings = new XmlWriterSettings()
                            {
                                Indent          = true,
                                NewLineHandling = NewLineHandling.Entitize
                            };

                            // Simply dump dataset to xml file on disk...
                            using (XmlWriter wr = XmlWriter.Create(notificationData.ObjectTypeString + "-" + d.itemIDRef.ToString() + ".xml", settings))
                            {
                                sr.Serialize(wr, d);
                            }
                        }
                    }
                    else
                    {
                        // Primitive error handling...
                        System.Diagnostics.Debug.WriteLine(string.Format("code: {0}, comment: {1}", s.code, s.comment));
                    }
                }
            }
            else
            {
                // Simply dump errors to diagnostic console.
                foreach (var stat in data.Status.Status)
                {
                    System.Diagnostics.Debug.WriteLine(string.Format("code: {0}, comment: {1}", stat.code, stat.comment));
                }
            }
        }