public XmlRpcStruct NodeRetrieve(int nid)
        {
            this.InitRequest();
            XmlRpcStruct res = null;

            try {
                res = drupalServiceSystem.NodeRetrieve(nid);
            } catch (Exception ex) {
                this.HandleException(ex, "NodeRetrieve");
            }
            return(res);
        }
        public XmlRpcStruct NodeCreate(object node)
        {
            this.InitRequest();
            XmlRpcStruct res = null;

            try {
                res = drupalServiceSystem.NodeCreate(ConvertAs(node));
            } catch (Exception ex) {
                this.HandleException(ex, "NodeCreate");
            }
            return(res);
        }
        /// <summary>
        /// Retrieves an entity of type File.
        /// </summary>
        /// <param name="file_id">The file id.</param>
        /// <param name="fields">A comma separated list of fields to get.</param>
        /// <param name="revision">The specific revision to retrieve.</param>
        /// <returns>An entity of type File.</returns>
        public XmlRpcStruct EntityFileRetrieve(int file_id, string fields, int revision)
        {
            this.InitRequest();
            XmlRpcStruct res = null;

            try {
                res = drupalServiceSystem.EntityFileRetrieve("retrieve", "file", file_id, fields, revision);
            } catch (Exception ex) {
                this.HandleException(ex, "EntityFileRetrieve");
            }
            return(res);
        }
        public XmlRpcStruct GeocoderIndex()
        {
            this.InitRequest();
            XmlRpcStruct res = null;

            try {
                res = drupalServiceSystem.GeocoderIndex();
            } catch (Exception ex) {
                this.HandleException(ex, "GeocoderIndex");
            }
            return(res);
        }
Esempio n. 5
0
        private Product GetProductById(string productId)
        {
            var filterParameters = new XmlRpcStruct();
            var filterOperator   = new XmlRpcStruct {
                { "eq", productId }
            };

            filterParameters.Add("product_id", filterOperator);
            var products = Product.List(MagentoConnection.Instance.Url, MagentoConnection.Instance.SessionId, new object[] { filterParameters });

            return(products[0]);
        }
        public XmlRpcStruct CommentRetrieve(int cid)
        {
            this.InitRequest();
            XmlRpcStruct res = null;

            try {
                res = drupalServiceSystem.CommentRetrieve(cid) as XmlRpcStruct;
            } catch (Exception ex) {
                this.HandleException(ex, "CommentRetrieve");
            }
            return(res);
        }
        /// <summary>
        /// 将rpc信息转换为种子链接信息
        /// </summary>
        /// <param name="rpcStruct">rpc信息</param>
        public Aria2cPeers(XmlRpcStruct rpcStruct)
        {
            List <string> keyList   = rpcStruct.Keys as List <string>;
            List <object> valueList = rpcStruct.Values as List <object>;

            for (int i = 0; i < rpcStruct.Count; i++)
            {
                string key   = keyList[i];
                object value = valueList[i];

                if (key == "peerId")
                {
                    this.PeerId = Convert.ToInt64(value as string);
                }
                else if (key == "ip")
                {
                    this.IP = value as string;
                }
                else if (key == "port")
                {
                    this.Port = Convert.ToInt64(value as string);
                }
                else if (key == "bitfield")
                {
                    this.Bitfield = value as string;
                }
                else if (key == "amChoking")
                {
                    this.AmChoking = (value as string) == "true" ? true : false;
                }
                else if (key == "peerChoking")
                {
                    this.PeerChoking = (value as string) == "true" ? true : false;
                }
                else if (key == "downloadSpeed")
                {
                    this.downloadSpeed = Convert.ToInt64(value as string);
                }
                else if (key == "uploadSpeed")
                {
                    this.uploadSpeed = Convert.ToInt64(value as string);
                }
                else if (key == "seeder")
                {
                    this.seeder = (value as string) == "true" ? true : false;
                }
                else
                {
                    //throw new Exception("无法将属性转换到Aria2cPeers中");
                    Console.WriteLine("无法将属性转换到Aria2cPeers中");
                }
            }
        }
        public XmlRpcStruct ViewsRetrieve(string view_name, string display_id, XmlRpcStruct args, int offset, int limit, object return_type, XmlRpcStruct filters)
        {
            this.InitRequest();
            XmlRpcStruct res = null;

            try {
                res = drupalServiceSystem.ViewsRetrieve(view_name, display_id, args, offset, limit, return_type, filters);
            } catch (Exception ex) {
                this.HandleException(ex, "ViewsRetrieve");
            }
            return(res);
        }
Esempio n. 9
0
        /// <summary>
        /// Gets the categories.
        /// </summary>
        /// <param name="blogid">The blogid.</param>
        /// <param name="username">The username.</param>
        /// <param name="password">The password.</param>
        /// <returns>System.Object[].</returns>
        /// <exception cref="BlogSystemException">error getting categories</exception>
        object[] IMetaWeblog.GetCategories(string blogid, string username, string password)
        {
            ValidateUser(username, password);
            try
            {
                TraceUtility.LogInformation("Get categories");
                ////Get All Blog Search Keys
                var activeTable = this.metaweblogTable.CustomOperation();
                //// Create a projected query to get all categories.
                var partitionKeyQuery = TableQuery.GenerateFilterCondition(
                    KnownTypes.PartitionKey,
                    QueryComparisons.Equal,
                    ApplicationConstants.BlogKey);
                var query  = new TableQuery().Where(partitionKeyQuery);
                var result = activeTable.ExecuteQuery(
                    query.Select(new[] { "CategoriesCsv" }),
                    this.metaweblogTable.TableRequestOptions);
                var resultList = result as IList <DynamicTableEntity> ?? result.ToList();
                if (!resultList.Any())
                {
                    return(null);
                }

                ////Combine all categories.
                var dynamicTableEntities = result as IList <DynamicTableEntity> ?? resultList.ToList();
                var allCategories        =
                    string.Join(
                        KnownTypes.CsvSeparator.ToInvariantCultureString(),
                        dynamicTableEntities.Select(element => element["CategoriesCsv"].StringValue)).ToCollection();
                var categories = allCategories as IList <string> ?? allCategories.ToList();
                var posts      = new XmlRpcStruct[categories.Count()];
                var counter    = 0;
                foreach (var category in categories)
                {
                    var rpcstruct = new XmlRpcStruct
                    {
                        { "categoryid", counter.ToInvariantCultureString() },
                        { "title", category },
                        { "description", category }
                    };

                    posts[counter++] = rpcstruct;
                }

                return(posts);
            }
            catch (Exception exception)
            {
                TraceUtility.LogError(exception);
                throw new BlogSystemException("error getting categories");
            }
        }
        /// <summary>
        /// 将rpc信息转换为种子信息名称
        /// </summary>
        /// <param name="rpcStruct"></param>
        /// <returns></returns>
        public static string ConvertToBittorrentInfoName(XmlRpcStruct rpcStruct)
        {
            List <string> keyList   = rpcStruct.Keys as List <string>;
            List <object> valueList = rpcStruct.Values as List <object>;

            if (rpcStruct.ContainsKey("name"))
            {
                string value = valueList[0] as string;
                return(value);
            }

            return(string.Empty);
        }
Esempio n. 11
0
        /// <summary>
        /// 将rpc信息转换为设置信息
        /// </summary>
        /// <param name="rpcStruct"></param>
        /// <returns></returns>
        public Aria2cOption(XmlRpcStruct rpcStruct)
        {
            List <string> keyList   = rpcStruct.Keys as List <string>;
            List <object> valueList = rpcStruct.Values as List <object>;

            for (int i = 0; i < rpcStruct.Count; i++)
            {
                string key   = keyList[i];
                string value = valueList[i] as string;

                this.SetOption(key, value);
            }
        }
Esempio n. 12
0
 // utility that uncovers the keys and values of the xml-rpc struct for figuring out and creating your own structs/classes
 public static void StructDiscovery(object[] bar)
 {
     //used to discover the items returned
     foreach (object foo in bar)
     {
         XmlRpcStruct duh = (XmlRpcStruct)foo;
         foreach (string ugh in duh.Keys)
         {
             // writes the key value pairs
             Console.WriteLine(ugh + "=" + duh[ugh]);
         }
     }
 }
        /**
        ** Misc Private Helper Methods
        **/
        private XmlRpcStruct mergeArrayToStruct(MCMergeVar[] merges)
        {
            XmlRpcStruct mv = new XmlRpcStruct();

            foreach (MCMergeVar var in merges)
            {
                if (var.tag != null)
                {
                    mv.Add(var.tag, var.val);
                }
            }
            return(mv);
        }
Esempio n. 14
0
        private string MapIdToName(XmlRpcStruct issue, XmlRpcStruct[] items, string idField)
        {
            string id = (string)issue [idField];

            foreach (XmlRpcStruct item in items)
            {
                if ((string)item["id"] == id)
                {
                    return((string)item ["name"]);
                }
            }
            return("?");
        }
Esempio n. 15
0
        public static int processSmugmugPhotoGalleryImage(ProcessFile imageFileProcessor, string gpxName, string imageName,
                                                          XmlRpcStruct imageUrls, XmlRpcStruct imageExif)
        {
            int ret = 0;

            PhotoDescr photoDescr = PhotoDescr.FromSmugmugPhotoGallery(imageName, imageUrls, imageExif);

            string thumbUrl = photoDescr.imageThumbSource;

            ret = imageFileProcessor(null, null, gpxName, thumbUrl);                    // do the rest of the work

            return(ret);
        }
Esempio n. 16
0
 /// <summary>
 ///  robust convert a date string
 /// </summary>
 /// <param name="data">key value dictionary</param>
 /// <param name="name">name of field to use</param>
 /// <returns></returns>
 internal DateTime toDate(XmlRpcStruct data, string name)
 {
     if (data.ContainsKey(name))
     {
         DateTime n;
         bool     good = DateTime.TryParse((string)data[name], out n);
         if (good)
         {
             return(n);
         }
     }
     return(DateTime.MinValue);
 }
Esempio n. 17
0
 public static TestPlan ToTestPlan(XmlRpcStruct data)
 {
     return(new TestPlan
     {
         active = ToInt(data, "active") == 1,
         id = ToInt(data, "id"),
         name = (string)data["name"],
         notes = (string)data["notes"],
         testproject_id = ToInt(data, "testproject_id"),
         open = ToInt(data, "is_open") == 1,
         is_public = ToInt(data, "is_public") == 1
     });
 }
Esempio n. 18
0
        internal static Build ToBuild(XmlRpcStruct data)
        {
            var item = new Build();

            item.id          = ToInt(data, "id");
            item.active      = ToInt(data, "active") == 1;
            item.name        = (string)data["name"];
            item.notes       = (string)data["notes"];
            item.testplan_id = ToInt(data, "testplan_id");
            item.is_open     = ToInt(data, "is_open") == 1;

            return(item);
        }
Esempio n. 19
0
        /// <summary>
        ///  constructor used by the XML Rpc return
        /// </summary>
        /// <param name="data"></param>
        internal static TestStep ToTestStep(XmlRpcStruct data)
        {
            var item = new TestStep();

            item.id               = ToInt(data, "id");
            item.step_number      = ToInt(data, "step_number");
            item.actions          = (string)data["actions"];
            item.expected_results = (string)data["expected_results"];
            item.active           = ToInt(data, "active") == 1;
            item.execution_type   = ToInt(data, "execution_type");

            return(item);
        }
Esempio n. 20
0
        public void EditPost_InvalidUser()
        {
            // Edit the entry
            var updatedContent = new XmlRpcStruct();

            updatedContent.Add("description", "updated");

            var entry11 = m_blog1.Axes.GetDescendant("Entry11");

            var result = m_api.editPost(entry11.ID.ToString(), "sitecore\\a", "a", updatedContent, false);

            Assert.IsFalse(result);
        }
Esempio n. 21
0
 /// <summary>
 /// Not implimented.
 /// </summary>
 public XmlRpcStruct GetImageExif(int imageId)
 {
     try
     {
         XmlRpcStruct imageExif = proxy.GetImageEXIF(this.credentials.SessionID, imageId);
         return(imageExif);
     }
     catch (Exception ex)
     {
         //throw new SmugMugException("Could not get image EXIF", ex.InnerException);
         return(new XmlRpcStruct());
     }
 }
Esempio n. 22
0
        /// <summary>
        ///  constructor used by XMLRPC interface on decoding the function return
        /// </summary>
        /// <param name="data">data returned by Testlink</param>
        internal static AdditionalInfo ToAdditionalInfo(XmlRpcStruct data)
        {
            var item = new AdditionalInfo();

            item.new_name       = (string)data["new_name"];
            item.status_ok      = ToInt(data, "status_ok") == 1;
            item.msg            = (string)data["msg"];
            item.id             = ToInt(data, "id");
            item.external_id    = ToInt(data, "external_id");
            item.version_number = ToInt(data, "version_number");
            item.has_duplicate  = ToBool(data, "has_duplicate");

            return(item);
        }
Esempio n. 23
0
        /// <summary>
        ///  constructor used by XMLRPC interface on decoding the function return
        /// </summary>
        /// <param name="data">data returned by Testlink</param>
        internal static AttachmentRequestResponse ToAttachmentRequestResponse(XmlRpcStruct data)
        {
            var item = new AttachmentRequestResponse();

            item.foreignKeyId    = ToInt(data, "fk_id");
            item.linkedTableName = (string)data["fk_table"];
            item.title           = (string)data["title"];
            item.description     = (string)data["description"];
            item.file_name       = (string)data["file_name"];
            item.file_type       = (string)data["file_type"];
            item.size            = ToInt(data, "file_size");

            return(item);
        }
Esempio n. 24
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="file">Full path to movie file with allowed extension enumerated in config entry allowedExtensions</param>
        /// <param name="languages"></param>
        /// <returns></returns>
        public IEnumerable <SearchResult> SearchSubtitles(string file, string[] languages)
        {
            KeepAlive();
            if (!IsValidFile(file))
            {
                throw new OpensubtitlesConnectorException("Provided file not valid.");
            }

            CheckLogin();
            var          searchParams = CreateSearchParams(file, languages);
            XmlRpcStruct response     = _proxy.SearchSubtitles(_token, new[] { searchParams });

            return(ParseResponse(response).ToList());
        }
Esempio n. 25
0
        public void OrderingKeys2()
        {
            var xps = new XmlRpcStruct();

            xps.Add("member_1", "a");
            xps.Add("member_4", "c");

            IEnumerator enumerator = xps.Keys.GetEnumerator();

            enumerator.MoveNext();
            Assert.AreEqual("member_1", enumerator.Current);
            enumerator.MoveNext();
            Assert.AreEqual("member_4", enumerator.Current);
        }
Esempio n. 26
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="output">The output from the server request.</param>
        protected Output(XmlRpcStruct output)
        {
            if (output.ContainsKey("status"))
            {
                this.StatusString = ( string )output["status"];
            }
            else
            {
                this.StatusString = "200 OK";
            }

            this.Status  = ConvertStatusToStatusCode(StatusString);
            this.Seconds = ( double )output["seconds"];
        }
Esempio n. 27
0
        public Dictionary <string, Option_Get> SetOptions(IEnumerable <Option> options)
        {
            XmlRpcStruct xmlRpcOption = new XmlRpcStruct();

            foreach (var option in options)
            {
                xmlRpcOption.Add(option.Name, option.Value);
            }

            var retOptions = WordPressService.SetOptios(WordPressSiteConfig.BlogId, WordPressSiteConfig.Username,
                                                        WordPressSiteConfig.Password, xmlRpcOption);

            return(ConvertOptionReturnValue(retOptions));
        }
Esempio n. 28
0
 /// <summary>
 /// Load a node
 /// </summary>
 private void button_load_Click(object sender, EventArgs e)
 {
     // Node to load
     if (_serviceCon != null)
     {
         _node = _serviceCon.NodeGet(Convert.ToInt32(textBox_nodeID.Text));
         if (_node != null)
         {
             XmlRpcStruct body = _node["body"] as XmlRpcStruct;
             //body["und"] as XmlRpcStruct
             richTextBox1.Text = _node["body"].ToString();
         }
     }
 }
Esempio n. 29
0
        public string ParseField(string fieldName, XmlRpcStruct nodeStruct)
        {
            try
            {
                return(nodeStruct[fieldName].ToString());
            }
            catch (Exception ex)
            {
                //errorMessage(ex.Message);
                handleExeption(ex, "ParseField");

                return("");
            }
        }
 void OnTaxonomyVocabularyRetrieveCompleted(IAsyncResult asyncResult)
 {
     if (this.TaxonomyVocabularyRetrieveCompleted != null)
     {
         var          clientResult = (XmlRpcAsyncResult)asyncResult;
         XmlRpcStruct result       = null;
         try {
             result = ((IServiceSystem)clientResult.ClientProtocol).EndTaxonomyVocabularyRetrieve(asyncResult);
             this.TaxonomyVocabularyRetrieveCompleted(this, new DrupalAsyncCompletedEventArgs <XmlRpcStruct>(result, null, asyncResult.AsyncState));
         } catch (Exception ex) {
             this.TaxonomyVocabularyRetrieveCompleted(this, new DrupalAsyncCompletedEventArgs <XmlRpcStruct>(result, ex, asyncResult.AsyncState));
         }
     }
 }