Example #1
0
        /// <summary>
        /// 竞赛状态更新
        /// </summary>
        /// <returns></returns>
        private bool updateTestStatus()
        {
            string mediaUrl = txtFile.Text;
            string usern    = txtUserName.Text;
            string pass     = txtPassword.Text;

            YYTestApi            yyTestApi      = (YYTestApi)XmlRpcProxyGen.Create(typeof(YYTestApi));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)yyTestApi;

            clientProtocol.Url = mediaUrl;
            Test[] tests = yyTestApi.getTestStatus(usern, pass);
            if (tests.Length > 0 && tests[0].isActive == 1)
            {
                setActiveTest(tests[0].id, true);
                cmbTest.Enabled = false;
            }
            else
            {
                setActiveTest(0, false);
                cmbTest.Enabled = true;
            }
            lblProgressInfor.Text = "竞赛状态更新成功!";
            //MessageBox.Show("竞赛状态更新成功!");
            return(false);
        }
Example #2
0
        public XmlBlasterClient()
        {
            // Client

            xmlBlasterClientProxy    = (IXmlBlasterClient)XmlRpcProxyGen.Create(typeof(IXmlBlasterClient));
            xmlBlasterClientProtocol = (XmlRpcClientProtocol)xmlBlasterClientProxy;

            // Server for Callback

            //RemotingConfiguration.Configure("xmlrpc.exe.config");

            HttpChannel channel = null;

            try
            {
                //int port = FindFreeHttpPort( 9090 ) ;
                //Debug.WriteLine( "FindFreeHttpPort() found port "+port );
                int port = 0;

                ListDictionary channelProperties = new ListDictionary();
                channelProperties.Add("port", port);

                channel = new HttpChannel(
                    channelProperties,
                    new CookComputing.XmlRpc.XmlRpcClientFormatterSinkProvider(),
                    new CookComputing.XmlRpc.XmlRpcServerFormatterSinkProvider(null, null)
                    //new SoapClientFormatterSinkProvider(),
                    //new SoapServerFormatterSinkProvider()
                    );
            }
            catch (Exception ex)
            {
                // Listener config failed : Une seule utilisation de chaque adresse de socket (protocole/adresse réseau/port) est habituellement autorisée

                Debug.WriteLine("Listener config failed : " + ex.Message);

                XmlBlasterException.HandleException(new Exception("Listener config failed.", ex));
            }

            ChannelServices.RegisterChannel(channel);

            RemotingConfiguration.RegisterWellKnownServiceType(
                typeof(XmlBlasterCallback),
                "XmlBlasterCallback",
                WellKnownObjectMode.Singleton
                );

            // Print out the urls for HelloServer.
            string[] urls = channel.GetUrlsForUri("XmlBlasterCallback");
            foreach (string url in urls)
            {
                System.Console.WriteLine("url: {0}", url);
            }
            //url: http://127.0.0.1:1038/XmlBlasterCallback
            if (urls.Length != 1)
            {
                XmlBlasterException.HandleException(new Exception("XmlBlasterCallback server, failed to retreive url."));
            }
            this.callbackServerUri = new Uri(urls[0]);
        }
Example #3
0
        /// <summary>
        /// Retrieves all posts from the blog.
        /// </summary>
        /// <param name="serviceUrl">The service URL to connect to.</param>
        /// <param name="blogId">The blog Id to login with.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>List collection of posts.</returns>
        /// <history>
        /// Sean Patterson    11/3/2010   [Created]
        /// </history>
        public List <Post> GetAllPosts(string serviceUrl, string blogId,
                                       string username, string password)
        {
            List <Post> Results = new List <Post>();

            Post[] TestPosts;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPosts = proxy.getRecentPosts(blogId, username, password, 9999999);

                if (TestPosts.Length > 0)
                {
                    Results = new List <Post>(TestPosts);
                }
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(Results);
        }
Example #4
0
        /// <summary>
        /// Verifies that the destination server can be connected to by
        /// retrieving a single post.
        /// </summary>
        /// <param name="service">The service to connect to.</param>
        /// <param name="blogId">The blog Id to login with.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>String with result message.</returns>
        /// <remarks>
        /// No exception handling is performed in the method since the only
        /// thing it could do is bubble it up one step further. Calling method
        ///// must be resposible for checking for an exception.
        /// </remarks>
        /// <history>
        /// Sean Patterson    11/3/2010   [Created]
        /// </history>
        public string CheckServerStatus
            (string serviceUrl, string blogId, string username, string password)
        {
            String Results;

            Post[] TestPosts;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPosts = proxy.getRecentPosts(blogId, username, password, 1);

                if (TestPosts.Length > 0)
                {
                    Results = "Connection successful.";
                }
                else
                {
                    Results = "Connection failed. No posts found.";
                }
            }
            catch (Exception ex)
            {
                Results = "Connection failed: " + ex.ToString();
            }

            return(Results);
        }
Example #5
0
        /// <summary>
        /// Updates the post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="postItem">The post object.</param>
        /// <returns>True/False indicating if post was updated.</returns>
        /// <remarks>
        /// It is assumed that the Post object already has the updated
        /// details in it.
        /// </remarks>
        public bool UpdatePost(string serviceUrl, string username, string password,
                               Post postItem)
        {
            object results;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                results = proxy.editPost(postItem.postid.ToString(), username, password,
                                         postItem, true);
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return((bool)results);
        }
Example #6
0
        /// <summary>
        /// Retrieves a blog post.
        /// </summary>
        /// <param name="serviceUrl">The service URL to connect to.</param>
        /// <param name="postId">The post Id to retrieve.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>List collection of posts.</returns>
        /// <history>
        /// Sean Patterson    11/7/2010   [Created]
        /// </history>
        public Post GetPost(string serviceUrl, int postId, string username,
                            string password)
        {
            Post results = new Post();

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                results = proxy.getPost(postId.ToString(), username, password);
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(results);
        }
Example #7
0
        private void btnPost_Click(object sender, EventArgs e)
        {
            blogInfo newBlogPost = default(blogInfo);

            newBlogPost.title       = txtTitle.Text;
            newBlogPost.description = txtPost.Text;

            categories     = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            clientProtocol = (XmlRpcClientProtocol)categories;

            clientProtocol.Url = "http://127.0.0.1/wpl/xmlrpc.php";

            string result = null;

            result = "";

            try {
                result = categories.NewPage(1, "shoban", "shoban", newBlogPost, 1);
                MessageBox.Show("Posted to Blog successfullly! Post ID : " + result);
                txtPost.Text  = "";
                txtTitle.Text = "";
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
        }
Example #8
0
        public object Invoke(MethodInfo methodInfo, params object[] parameters)
        {
            var request = XmlRpcClientProtocol.MakeXmlRpcRequest(methodInfo, parameters);

            using var memoryStream = new MemoryStream();
            var serializer = new XmlRpcRequestSerializer(Configuration);

            serializer.SerializeRequest(memoryStream, request);

            memoryStream.Seek(0, SeekOrigin.Begin);
            using var requestMessage = new HttpRequestMessage()
                  {
                      Method  = HttpMethod.Post,
                      Content = new StreamContent(memoryStream)
                  };

            using var response = _client.SendAsync(requestMessage, HttpCompletionOption.ResponseHeadersRead, CancellationToken.None).ConfigureAwait(false).GetAwaiter().GetResult();
            response.EnsureSuccessStatusCode();

            using var responseStream = response.Content.ReadAsStreamAsync().ConfigureAwait(false).GetAwaiter().GetResult();
            var deserializer   = new XmlRpcResponseDeserializer(Configuration);
            var responseAnswer = deserializer.DeserializeResponse(responseStream, request.MethodInfo.ReturnType);

            return(responseAnswer.ReturnValue);
        }
Example #9
0
        private void btn匯至網站_Click(object sender, EventArgs e)
        {
            blogInfo newBlogPost = default(blogInfo);

            ICL  = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            XRCP = (XmlRpcClientProtocol)ICL;

            XRCP.Url = tb網址.Text;

            string result = null;

            result = "";

            string[] strArrFilePaths = Directory.GetFiles(tb已加值文目錄.Text);

            foreach (string strFilePath in strArrFilePaths)
            {
                newBlogPost.title       = Path.GetFileNameWithoutExtension(strFilePath);
                newBlogPost.description = File.ReadAllText(strFilePath, Encoding.Default);

                try
                {
                    result = ICL.NewPage(1, tb帳號.Text, tb密碼.Text, newBlogPost, 1);
                    MessageBox.Show("Posted to Blog successfullly! Post ID : " + result);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Example #10
0
        /// <summary>
        /// The get proxy.
        /// </summary>
        /// <returns>
        /// The Proxy
        /// </returns>
        internal static IBlogSpamNet GetProxy()
        {
            IBlogSpamNet         _proxy  = (IBlogSpamNet)XmlRpcProxyGen.Create(typeof(IBlogSpamNet));
            XmlRpcClientProtocol _server = (XmlRpcClientProtocol)_proxy;

            _server.Url = (Url == null) ? _Url : Url.ToString();
            return(_proxy);
        }
Example #11
0
        public void Method1()
        {
            ITest proxy             = (ITest)XmlRpcProxyGen.Create(typeof(ITest));
            XmlRpcClientProtocol cp = (XmlRpcClientProtocol)proxy;

            Assert.IsTrue(cp is ITest);
            Assert.IsTrue(cp is XmlRpcClientProtocol);
        }
Example #12
0
        public void Method1Generic()
        {
            ITest2 proxy            = XmlRpcProxyGen.Create <ITest2>();
            XmlRpcClientProtocol cp = (XmlRpcClientProtocol)proxy;

            Assert.IsTrue(cp is ITest2);
            Assert.IsTrue(cp is IXmlRpcProxy);
            Assert.IsTrue(cp is XmlRpcClientProtocol);
        }
Example #13
0
        /// <summary>
        /// Inserts a post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="blogId">The blog Id.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="postItem">The post object.</param>
        /// <returns>Post object that was created by the server.</returns>
        public Post InsertPost(string serviceUrl, string blogId, string username,
                               string password, Post postItem, StreamWriter swLog, bool batchMode)
        {
            Post   results;
            Post   tempPost;
            String postResult;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url         = serviceUrl;
            cp.NonStandard = XmlRpcNonStandard.All;
            tempPost       = new Post();

            try
            {
                tempPost.dateCreated = postItem.dateCreated;
                tempPost.userid      = username;
                tempPost.title       = postItem.title;
                tempPost.description = postItem.description;
                tempPost.categories  = postItem.categories;

                postResult = proxy.newPost(blogId, username, password, tempPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    results = proxy.getPost(postResult, username, password);
                }
                else
                {
                    throw new Exception("Post not created.");
                }
            }
            catch (Exception ex)
            {
                var messageBoxText = "An error occurred migrating blog post:" +
                                     Environment.NewLine + Environment.NewLine +
                                     ex.ToString() +
                                     Environment.NewLine + Environment.NewLine + tempPost.ToString();
                swLog.WriteLine(messageBoxText);
                if (!batchMode)
                {
                    var answer = MessageBox.Show(messageBoxText, "Error Migrating Post",
                                                 MessageBoxButton.OKCancel, MessageBoxImage.Error);
                    if (answer == MessageBoxResult.Cancel)
                    {
                        throw;
                    }
                }
                return(new Post());
            }

            return(results);
        }
Example #14
0
 public Blogger(String url, String userName, SecureString password)
 {
     _userName = userName;
     _password = password;
     ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
     metaWeblogProvider         = (IMetaWeblogProvider)XmlRpcProxyGen.Create(typeof(IMetaWeblogProvider));
     clientProtocol             = (XmlRpcClientProtocol)metaWeblogProvider;
     clientProtocol.Url         = url;
     clientProtocol.UserAgent   = "PS Cmdlet Help Editor/" + Assembly.GetExecutingAssembly().GetName().Version;
     clientProtocol.NonStandard = XmlRpcNonStandard.All;
 }
Example #15
0
        /// <summary>
        /// 参赛者下载
        /// </summary>
        /// <returns></returns>
        private bool downloadUser()
        {
            string mediaUrl = txtFile.Text;
            string usern    = txtUserName.Text;
            string pass     = txtPassword.Text;

            YYTestApi            yyTestApi      = (YYTestApi)XmlRpcProxyGen.Create(typeof(YYTestApi));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)yyTestApi;

            clientProtocol.Url = mediaUrl;
            UserInfo[] users = yyTestApi.getUsers(usern, pass);
            foreach (UserInfo user in users)
            {
                string userName = user.userName;
                string password = user.password;
                string birthday = "2016/01/01";
                bool   sex      = true;
                string mail     = user.mail;
                string tel      = user.tel;
                string address  = user.address;
                int    userId   = user.id;

                if (isUserExists(userId))
                {
                    string sql = "update [tbl_User] set "
                                 + "[UserName] ='" + userName + "'"
                                 + ",[Password]='" + password + "'"
                                 + ",[Birthday]=" + birthday + ""
                                 + ",[Sex]=" + sex + ""
                                 + ",[Mail]='" + mail + "'"
                                 + ",[Tel]='" + tel + "'"
                                 + ",[Address]='" + address + "'"
                                 + " where id=" + userId;
                    db.ExeSQL(sql);
                }
                else
                {
                    string sql = "insert into [tbl_User]([id],[UserName],[Password],[Birthday],[Sex],[Mail],[Tel],[Address],[IsAdmin]) values("
                                 + "" + userId + ""
                                 + ",'" + userName + "'"
                                 + ",'" + password + "'"
                                 + "," + birthday + ""
                                 + "," + sex + ""
                                 + ",'" + mail + "'"
                                 + ",'" + tel + "'"
                                 + ",'" + address + "'"
                                 + ",False)";
                    db.ExeSQL(sql);
                }
            }
            lblProgressInfor.Text = "参赛者下载成功!";
            //MessageBox.Show("参赛者下载成功!");
            return(true);
        }
Example #16
0
        public Blogger(String url, String userName, SecureString password)
        {
            _userName = userName;
            _password = password;

            metaWeblogProvider         = (IMetaWeblogProvider)XmlRpcProxyGen.Create(typeof(IMetaWeblogProvider));
            clientProtocol             = (XmlRpcClientProtocol)metaWeblogProvider;
            clientProtocol.Url         = url;
            clientProtocol.UserAgent   = "PS Cmdlet Help Editor";
            clientProtocol.NonStandard = XmlRpcNonStandard.All;
        }
Example #17
0
        public AddTourneys(string sitename, string username, string password)
        {
            // Initialize member variables
            this.m_siteName  = sitename;
            this.m_userName  = username;
            this.m_password  = password;
            this.m_xmlrpcURL = m_siteName.TrimEnd(new[] { '/', '\\' }) + "/xmlrpc.php";

            m_interface          = (AddTourneysInterface)XmlRpcProxyGen.Create(typeof(AddTourneysInterface));
            m_clientProtocol     = (XmlRpcClientProtocol)m_interface;
            m_clientProtocol.Url = this.m_xmlrpcURL;
        }
Example #18
0
        /// <summary>
        /// 结束竞赛
        /// </summary>
        /// <returns></returns>
        private bool EndTest()
        {
            int    testId   = Convert.ToInt32(cmbTest.Text.ToString().Split(':')[0]);
            string mediaUrl = txtFile.Text;
            string usern    = txtUserName.Text;
            string pass     = txtPassword.Text;

            YYTestApi            yyTestApi      = (YYTestApi)XmlRpcProxyGen.Create(typeof(YYTestApi));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)yyTestApi;

            clientProtocol.Url = mediaUrl;
            return(yyTestApi.setEndTest(usern, pass, testId));
        }
        public BloggerClient(ProviderInformation provider)
        {
            _userName = provider.UserName;
            _password = Crypt.DecryptPassword(provider.Password);
            _blogId   = provider.Blog.blogid;

            _metaWeblogProvider = (IMetaWeblogProvider)XmlRpcProxyGen.Create(typeof(IMetaWeblogProvider));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)_metaWeblogProvider;

            clientProtocol.Url         = provider.ProviderURL;
            clientProtocol.UserAgent   = "PS Cmdlet Help Editor/" + Assembly.GetExecutingAssembly().GetName().Version;
            clientProtocol.NonStandard = XmlRpcNonStandard.All;
        }
Example #20
0
        /// <summary>
        /// カテゴル初期化
        /// </summary>
        private void initCategroy(string mediaUrl, string userName, string password)
        {
            IMetaWeblog          metaWeblog     = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)metaWeblog;

            clientProtocol.Url = mediaUrl;
            Category[] cats = metaWeblog.getCategories("1", userName, password);
            cmbCategry.Items.Clear();
            foreach (Category cat in cats)
            {
                cmbCategry.Items.Add(cat.categoryName);
            }
        }
Example #21
0
    static void Main(string[] args)
    {
        System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatePolicy();
        IStateName           proxy = XmlRpcProxyGen.Create <IStateName>();
        XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

        cp.Url = "https://127.0.0.1:5678/";
        cp.ClientCertificates.Add(new System.Security.Cryptography.X509Certificates.X509Certificate(@"C:\path\to\your\certificate\file\my.cer"));
        cp.KeepAlive = false;
        //cp.Expect100Continue = false;
        //cp.NonStandard = XmlRpcNonStandard.All;

        string stateName = ((IStateName)cp).GetStateName(13);
    }
Example #22
0
        /// <summary>
        /// Inserts a test post.
        /// </summary>
        /// <param name="serviceUrl">The service URL to connect to.</param>
        /// <param name="blogId">The blog Id to login with.</param>
        /// <param name="username">The username to login with.</param>
        /// <param name="password">The password to login with.</param>
        /// <returns>Message indicating success or failure.</returns>
        /// <history>
        /// Sean Patterson    11/3/2010   [Created]
        /// </history>
        public string InsertSamplePost(string serviceUrl, string blogId,
                                       string username, string password)
        {
            String Results;
            String postResult;
            Post   TestPost;
            Post   ReturnPost;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPost             = new Post();
                TestPost.categories  = new string[] { "Cool Category" };
                TestPost.dateCreated = DateTime.Now;
                TestPost.userid      = username;
                TestPost.title       = "Cool new XML-RPC test!";
                TestPost.description = "This is the main body of the post. " +
                                       "It has lots of cool things here to " +
                                       "test the migration I'm about to do.";

                postResult = proxy.newPost(blogId, username, password, TestPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    ReturnPost = proxy.getPost(postResult, username, password);

                    Results = "Success! Post Id = " + ReturnPost.postid
                              + Environment.NewLine +
                              "Link to post is: " + ReturnPost.link;
                }
                else
                {
                    Results = "Fail. No new post.";
                }
            }
            catch (XmlRpcFaultException fex)
            {
                Results = "XML-RPC error connecting to server: " + fex.ToString();
            }
            catch (Exception ex)
            {
                Results = "General error connecting to server: " + ex.ToString();
            }

            return(Results);
        }
Example #23
0
        /// <summary>
        /// 参赛者成绩下载
        /// </summary>
        /// <returns></returns>
        private bool downloadUserTestDetail()
        {
            string mediaUrl = txtFile.Text;
            string usern    = txtUserName.Text;
            string pass     = txtPassword.Text;

            YYTestApi            yyTestApi      = (YYTestApi)XmlRpcProxyGen.Create(typeof(YYTestApi));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)yyTestApi;

            clientProtocol.Url = mediaUrl;
            UserTestDetail[] userTestDetails = yyTestApi.getUserTestDetails(usern, pass);
            foreach (UserTestDetail userTestDetail in userTestDetails)
            {
                int    id           = userTestDetail.id;
                int    userId       = userTestDetail.userId;
                int    testId       = userTestDetail.testId;
                int    questionId   = userTestDetail.QuestionId;
                int    questionType = userTestDetail.QuestionType;
                string Answer       = userTestDetail.Answer;

                if (isUserTestDetailExists(id))
                {
                    string sql = "update [tbl_User_test_detail] set "
                                 + "[userId] =" + userId + ""
                                 + ",[testId]=" + testId + ""
                                 + ",[questionId]=" + questionId + ""
                                 + ",[questionType]=" + questionType + ""
                                 + ",[Answer]='" + Answer + "'"
                                 + " where id=" + id;
                    db.ExeSQL(sql);
                }
                else
                {
                    string sql = "insert into [tbl_User_test_detail]([userId],[testId],[questionId],[QuestionType],[Answer]) values("
                                 + "" + userId + ""
                                 + "," + testId + ""
                                 + "," + questionId + ""
                                 + "," + questionType + ""
                                 + ",'" + Answer + "')";
                    db.ExeSQL(sql);
                }
            }
            lblProgressInfor.Text = "参赛者成绩下载成功!";
            //MessageBox.Show("参赛者成绩下载成功!");
            return(true);
        }
        //internal members
        internal XmlRpcAsyncResult(
		  XmlRpcClientProtocol ClientProtocol,
		  XmlRpcRequest XmlRpcReq,
		  XmlRpcFormatSettings xmlRpcFormatSettings,
		  WebRequest Request,
		  AsyncCallback UserCallback,
		  object UserAsyncState,
		  int retryNumber)
        {
            xmlRpcRequest = XmlRpcReq;
            clientProtocol = ClientProtocol;
            request = Request;
            userAsyncState = UserAsyncState;
            userCallback = UserCallback;
            completedSynchronously = true;
            XmlRpcFormatSettings = xmlRpcFormatSettings;
        }
Example #25
0
        /// <summary>
        /// 试题上传
        /// </summary>
        /// <returns></returns>
        private bool uploadQuestion()
        {
            string mediaUrl = txtFile.Text;
            string usern    = txtUserName.Text;
            string pass     = txtPassword.Text;

            string  sql = "select * from tbl_Question_Single";
            DataSet ds  = db.ReturnDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                QuestionSingle[]     questionSingles = new QuestionSingle[1];
                YYTestApi            yyTestApi       = (YYTestApi)XmlRpcProxyGen.Create(typeof(YYTestApi));
                XmlRpcClientProtocol clientProtocol  = (XmlRpcClientProtocol)yyTestApi;
                clientProtocol.XmlEncoding = System.Text.Encoding.UTF8;
                clientProtocol.Url         = mediaUrl;
                bool result = true;
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    questionSingles[0]            = new QuestionSingle();
                    questionSingles[0].id         = Convert.ToInt32(ds.Tables[0].Rows[i]["id"]);
                    questionSingles[0].Content    = ds.Tables[0].Rows[i]["Content"].ToString();
                    questionSingles[0].SelectionA = ds.Tables[0].Rows[i]["SelectionA"].ToString();
                    questionSingles[0].SelectionB = ds.Tables[0].Rows[i]["SelectionB"].ToString();
                    questionSingles[0].SelectionC = ds.Tables[0].Rows[i]["SelectionC"].ToString();
                    questionSingles[0].SelectionD = ds.Tables[0].Rows[i]["SelectionD"].ToString();
                    questionSingles[0].Answer     = ds.Tables[0].Rows[i]["Answer"].ToString();
                    questionSingles[0].Hardness   = ds.Tables[0].Rows[i]["Hardness"].ToString();
                    questionSingles[0].Score      = Convert.ToInt32(ds.Tables[0].Rows[i]["Score"]);
                    result = result && yyTestApi.setQuestionSingles(usern, pass, questionSingles);
                }
                if (!result)
                {
                    lblProgressInfor.Text = "试题上传失败!";
                    //MessageBox.Show("试题上传失败!");
                }
                else
                {
                    lblProgressInfor.Text = "试题上传成功!";
                    //MessageBox.Show("试题上传成功!");
                }
            }

            return(true);
        }
Example #26
0
        /// <summary>
        /// Inserts a post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="blogId">The blog Id.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="title">The post title.</param>
        /// <param name="content">The post content.</param>
        /// <param name="authorid">The post author id.</param>
        /// <param name="dateCreated">The post creation date.</param>
        /// <param name="categories">The post categories.</param>
        /// <returns>Post object that was created by the server.</returns>
        public Post InsertPost(string serviceUrl, string blogId, string username,
                               string password, string title, string content,
                               string authorid, DateTime dateCreated,
                               List <string> categories)
        {
            Post   results;
            String postResult;
            Post   TestPost;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url = serviceUrl;

            try
            {
                TestPost             = new Post();
                TestPost.dateCreated = dateCreated;
                TestPost.userid      = authorid;
                TestPost.title       = title;
                TestPost.description = content;
                TestPost.categories  = categories.ToArray();

                postResult = proxy.newPost(blogId, username, password, TestPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    results = proxy.getPost(postResult, username, password);
                }
                else
                {
                    throw new Exception("Post not created.");
                }
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(results);
        }
        public string sendPost(string _url, string _username, string _password)
        {
            IcreatePost          _post          = (IcreatePost)XmlRpcProxyGen.Create(typeof(IcreatePost));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)_post;

            clientProtocol.Url = "http://" + _url + "/xmlrpc.php";
            string _postID = "";

            try
            {
                _postID = _post.NewPost(1, _username, _password, _blogPost, 1);
            }
            catch (Exception ex)
            {
                _postID = "Error";
            }
            return(_postID);
        }
Example #28
0
        /// <summary>
        /// Inserts a post.
        /// </summary>
        /// <param name="serviceUrl">The service URL of the blog.</param>
        /// <param name="blogId">The blog Id.</param>
        /// <param name="username">The blog username.</param>
        /// <param name="password">The blog password.</param>
        /// <param name="postItem">The post object.</param>
        /// <returns>Post object that was created by the server.</returns>
        public Post InsertPost(string serviceUrl, string blogId, string username,
                               string password, Post postItem)
        {
            Post   results;
            Post   tempPost;
            String postResult;

            IMetaWeblog          proxy = (IMetaWeblog)XmlRpcProxyGen.Create(typeof(IMetaWeblog));
            XmlRpcClientProtocol cp    = (XmlRpcClientProtocol)proxy;

            cp.Url         = serviceUrl;
            cp.NonStandard = XmlRpcNonStandard.All;

            try
            {
                tempPost             = new Post();
                tempPost.dateCreated = postItem.dateCreated;
                tempPost.userid      = username;
                tempPost.title       = postItem.title;
                tempPost.description = postItem.description;
                tempPost.categories  = postItem.categories;

                postResult = proxy.newPost(blogId, username, password, tempPost, true);

                if (!String.IsNullOrEmpty(postResult))
                {
                    results = proxy.getPost(postResult, username, password);
                }
                else
                {
                    throw new Exception("Post not created.");
                }
            }
            catch (XmlRpcFaultException fex)
            {
                throw fex;
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(results);
        }
Example #29
0
        /// <summary>
        /// 参赛者排名信息下载
        /// </summary>
        /// <returns></returns>
        private bool downloadUserTest()
        {
            string mediaUrl = txtFile.Text;
            string usern    = txtUserName.Text;
            string pass     = txtPassword.Text;

            YYTestApi            yyTestApi      = (YYTestApi)XmlRpcProxyGen.Create(typeof(YYTestApi));
            XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)yyTestApi;

            clientProtocol.Url = mediaUrl;
            UserTest_[] userTests = yyTestApi.getUserTests(usern, pass);
            foreach (UserTest_ userTest in userTests)
            {
                int id     = userTest.id;
                int userId = userTest.userId;
                int testId = userTest.testId;
                int score  = userTest.Score;
                int rank   = userTest.Rank;

                if (isUserTestExists(id))
                {
                    string sql = "update [tbl_User_test] set "
                                 + "[userId] =" + userId + ""
                                 + ",[testId]=" + testId + ""
                                 + ",[score]=" + score + ""
                                 + ",[rank]=" + rank + ""
                                 + " where id=" + id;
                    db.ExeSQL(sql);
                }
                else
                {
                    string sql = "insert into [tbl_User_test]([userId],[testId],[score],[rank]) values("
                                 + "" + userId + ""
                                 + "," + testId + ""
                                 + "," + score + ""
                                 + "," + rank + ")";
                    db.ExeSQL(sql);
                }
            }
            lblProgressInfor.Text = "赛者排名信息下载成功!";
            //MessageBox.Show("赛者排名信息下载成功!");
            return(true);
        }
Example #30
0
        /// <summary>
        /// 竞赛上传
        /// </summary>
        /// <returns></returns>
        private bool uploadTest()
        {
            string mediaUrl = txtFile.Text;
            string usern    = txtUserName.Text;
            string pass     = txtPassword.Text;

            string  sql = "select * from tbl_Test";
            DataSet ds  = db.ReturnDataSet(sql);

            if (ds.Tables[0].Rows.Count > 0)
            {
                Test[] tests = new Test[ds.Tables[0].Rows.Count];
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
                {
                    tests[i]             = new Test();
                    tests[i].id          = Convert.ToInt32(ds.Tables[0].Rows[i]["id"]);
                    tests[i].testName    = ds.Tables[0].Rows[i]["testName"].ToString();
                    tests[i].userId      = Convert.ToInt32(ds.Tables[0].Rows[i]["userId"]);
                    tests[i].testDate    = ds.Tables[0].Rows[i]["testDate"].ToString();
                    tests[i].testAddress = ds.Tables[0].Rows[i]["testAddress"].ToString();
                    tests[i].Bidati      = Convert.ToInt32(ds.Tables[0].Rows[i]["Bidati"]);
                    tests[i].Qiangdati   = Convert.ToInt32(ds.Tables[0].Rows[i]["Qiangdati"]);
                    tests[i].isActive    = Convert.ToInt32(ds.Tables[0].Rows[i]["isActive"]);
                }
                YYTestApi            yyTestApi      = (YYTestApi)XmlRpcProxyGen.Create(typeof(YYTestApi));
                XmlRpcClientProtocol clientProtocol = (XmlRpcClientProtocol)yyTestApi;
                clientProtocol.XmlEncoding = System.Text.Encoding.UTF8;
                clientProtocol.Url         = mediaUrl;
                bool result = yyTestApi.setTests(usern, pass, tests);
                if (!result)
                {
                    lblProgressInfor.Text = "竞赛上传失败!";
                    //MessageBox.Show("竞赛上传失败!");
                }
                else
                {
                    lblProgressInfor.Text = "竞赛上传成功!";
                    //MessageBox.Show("竞赛上传成功!");
                }
            }
            return(true);
        }
Example #31
0
        private void ProcessDataWordpress(String url)
        {
            blogInfo newBlogPost = default(blogInfo);

            newBlogPost.title       = Spinner.Spin(txtTitle.Text);
            newBlogPost.description = Spinner.Spin(editor1.BodyHtml);
            categories     = (IgetCatList)XmlRpcProxyGen.Create(typeof(IgetCatList));
            clientProtocol = (XmlRpcClientProtocol)categories;

            string linkwordpress = "";
            string username      = "";
            string password      = "";

            string[] words = url.Split('|');

            linkwordpress = words[0];
            username      = words[1];
            password      = words[2];

            txtSite.Text = linkwordpress;
            txtUser.Text = username;
            txtPass.Text = password;

            clientProtocol.Url = "https://" + linkwordpress + "/xmlrpc.php";

            string result = null;

            result = "";
            try
            {
                result = categories.NewPage(1, username, password, newBlogPost, 1);
                //MessageBox.Show("Posted to Blog successfullly! Post ID : " + result);
                //txtPost.Text = "";
                //txtTitle.Text = "";
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }