小编use*_*967的帖子

如何在xamarin CrossPlatform应用程序中使用Web Api

我创建了web api,它从SQL数据库中检索数据.我需要在xamrin中使用web api for android和xamarin for iOS.截至目前xamarin为Android.我不知道如何根据按钮点击事件调用GET和Post方法.

这是web api

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace MvcAppDept.Controllers
{
public class DeptController : ApiController
{
    // GET api/values
    public IEnumerable<Dept> Get()
    {
        AndroidAppDBEntities db = new AndroidAppDBEntities();
        var data = from dept in db.Depts orderby dept.no select dept;
        return data.ToList();
    }

    // GET api/values/5
    public Dept Get(int id)
    {
        AndroidAppDBEntities db = new AndroidAppDBEntities();
        var data = from dept in db.Depts where dept.no == id …
Run Code Online (Sandbox Code Playgroud)

api android xamarin

8
推荐指数
1
解决办法
1万
查看次数

在Xamarin Cross Platform Application中使用WCF服务

我创建了一个WCF服务,它从SQL数据库中检索数据,并可以将数据更新和修改为SQL数据库.我试图从xamarin for android和xamarin for iOS调用WCF方法.我搜索了一个例子,如何从WCF服务调用PUT和POST方法,通过xamarin for android和xamarin for iOS但没有运气.我在下面添加了WCF代码以供参考....甚至创建了Web API,但所有使用Web API的示例和教程都是关于如何调用GET方法的.我没有看到任何参考文档,它将展示如何通过跨平台从WCF或Web api调用PUT或Post方法.我通过Fiddler测试了WCF服务并且工作正常.下一步将是什么..我已经使用xlsrin文档中提到的SlsvcUtil.exe为此Web服务创建了代理.有人可以发布一个xamarin.Android的例子,它将从下面的wcf服务中调用Update或delete方法.正在寻找help.Service包含webHttp绑定.

WCF

Service1.svc.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.Serialization; 
using System.ServiceModel; 
using System.ServiceModel.Web; 
using System.Text;

public class Service1 : IService1 
{ 
    public List GetDeptsList() 
    { 
        using (DeptDBEntities entities = new DeptDBEntities()) 
        { 
            return entities.Depts.ToList(); 
        } 
    }

    public Dept GetDeptByID(string no)
    {
        try
        {
            int deptId = Convert.ToInt32(no);

            using (DeptDBEntities entities = new DeptDBEntities())
            {
                return entities.Depts.SingleOrDefault(dept => dept.no == deptId);
            }
        }
        catch
        {
            throw new FaultException("Something …
Run Code Online (Sandbox Code Playgroud)

c# wcf xamarin.android xamarin

6
推荐指数
1
解决办法
9930
查看次数

EWS托管API Pull通知以观看新电子邮件无效

我正在创建一个应用程序,它将作为后台的窗口服务.此应用程序将解析收件箱中的新电子邮件并保存附件.我尝试了流媒体通知,但是当连接断开30分钟后,我想使用拉动通知.下面是我调试的代码但我在控制台上看不到任何输出.只要我运行应用程序,它就会关闭控制台窗口,因此不知道它是否正常工作.我希望在收到收件箱后立即收看新邮件,因此需要一些指导如何实现.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Exchange.WebServices.Data;
using System.Configuration;
using System.Timers;

namespace PullNotification
{
    class Program
    {
        static void Main(string[] args)
        {
            ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
             WebCredentials wbcred = new WebCredentials(ConfigurationSettings.AppSettings["user"], ConfigurationSettings.AppSettings["PWD"]); 
            PullSubscription SubscriptionInbox;

            service.Credentials = wbcred;
            service.AutodiscoverUrl(ConfigurationSettings.AppSettings["user-id"], RedirectionUrlValidationCallback);


            SubscriptionInbox = service.SubscribeToPullNotifications(new FolderId[] { WellKnownFolderName.Inbox }, 5/* subcription will end if the server is not polled within 5 mints*/, null/*to start a new subcription*/, EventType.NewMail, EventType.Modified);
            //Timer myTimer = new Timer();
            //myTimer.Elapsed += …
Run Code Online (Sandbox Code Playgroud)

c# email-client exchangewebservices

2
推荐指数
1
解决办法
3706
查看次数