Xamarin.android Pullasync错误新表

Xamarin.android Pullasync错误新表,xamarin.android,azure-sql-database,azure-mobile-services,Xamarin.android,Azure Sql Database,Azure Mobile Services,我使用VisualStudio在数据库中创建了一个新表 我为我的新表创建了一个数据对象,添加到我的startup.mobileApp、控制器和模型中。无论我的pullasync()有什么错误 “您正在查找的资源已被删除,名称已更改或暂时不可用” 我的项目移动: public class AlertMateriel { public string Id { get; set; } [JsonProperty(PropertyName = "IdMateriel")] pu

我使用VisualStudio在数据库中创建了一个新表

我为我的新表创建了一个数据对象,添加到我的startup.mobileApp、控制器和模型中。无论我的pullasync()有什么错误

“您正在查找的资源已被删除,名称已更改或暂时不可用”

我的项目移动:

public class AlertMateriel
{
    public string Id { get; set; }

    [JsonProperty(PropertyName = "IdMateriel")]
    public string IdMateriel { get; set; }

    [JsonProperty(PropertyName = "IdDemandeur")]
    public string IdDemandeur { get; set; }

    [JsonProperty(PropertyName = "Demande")]
    public string Demande{ get; set; }

    [JsonProperty(PropertyName = "IdAssignMat")]
    public string IdAssignMat { get; set; }

    [JsonProperty(PropertyName = "IdReceveur")]

    public string IdReceveur { get; set; }

    [JsonProperty(PropertyName = "VU")]
    public bool VU { get; set; }

    [JsonProperty(PropertyName = "Deleted")]
    public string Deleted { get; set; }

    [Microsoft.WindowsAzure.MobileServices.Version]
    public byte[] Version
    {
        get;
        set;
    }
}
服务:

 public class AlertMateriel : EntityData
{
    public string IdMateriel { get; set; }

    public string IdDemandeur { get; set; }
    public string Demande { get; set; }
    public string IdAssignMat { get; set; }
    public bool VU { get; set; }
    public string IdReceveur { get; set; }

}
控制器:

 public class AlertMaterielController : TableController<AlertMateriel>
{
    protected override void Initialize(HttpControllerContext controllerContext)
    {
        base.Initialize(controllerContext);
        ChantierContext context = new ChantierContext();
        DomainManager = new EntityDomainManager<AlertMateriel>(context, Request);
    }

    // GET tables/MaterielDB
    public IQueryable<AlertMateriel> GetAllAlertMateriel()
    {
        return Query();
    }

    public SingleResult<AlertMateriel> GetAllMateriel(string id)
    {
        return Lookup(id);
    }


    public Task<AlertMateriel> PatchAlertMateriel(string id, Delta<AlertMateriel> patch)
    {
        return UpdateAsync(id, patch);
    }


    public async Task<IHttpActionResult> PostAlertMateriel(AlertMateriel item)
    {
        AlertMateriel current = await InsertAsync(item);
        return CreatedAtRoute("Tables", new { id = current.Id }, current);
    }


    public Task DeleteAlertMateirel(string id)
    {
        return DeleteAsync(id);
    }
}
公共类AlertMaterialController:TableController
{
受保护的覆盖无效初始化(HttpControllerContext controllerContext)
{
初始化(controllerContext);
ChantierContext=新的ChantierContext();
DomainManager=新实体DomainManager(上下文、请求);
}
//获取表格/材料B
公共IQueryable getAllalertMaterial()
{
返回查询();
}
公共单结果GetAllMaterials(字符串id)
{
返回查找(id);
}
公共任务修补程序(字符串id,增量修补程序)
{
返回UpdateSync(id,补丁);
}
公共异步任务PostalertMaterial(警报物资项)
{
AlertMaterial current=等待插入同步(项目);
返回CreatedAtRoute(“Tables”,new{id=current.id},current);
}
公共任务DeleteAlertMateirel(字符串id)
{
返回deletesync(id);
}
}
活动:

public class DefMatTable : Activity
{
    private IMobileServiceSyncTable<AlertMateriel> AlertMat;
    private IMobileServiceSyncTable<AssignMaterielDB> AssignMaterielTable;
    private IMobileServiceSyncTable<Chantiers> ChantiersTable;
    private IMobileServiceSyncTable<MaterielDB> MaterielTable;
    private IMobileServiceSyncTable<Personnel> PersonnelTable;
    private TableLayout _table;
    private MobileServiceClient client;
    private ArrayAdapter _adapter3;
    private string idengin="";
    private string idassign = "";
    private string iddemandeur = "";
    private string idreceveur = "";

    /*
    private TextView Engin;
    private TextView Chantier;
    private TextView Cdt;
    private TextView datedu;
    private TextView dateau;
    private ArrayAdapter _adapter;*/

    const string applicationURL = @"url";
    const string applicationKey = @"key";
    public List<string> assignmatod { get; private set; }
    const string localDbFilename = "localstore.db";
    private ProgressDialog progress;

    protected override async void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        SetContentView(Resource.Layout.Layout_DemandeMat2);
        this.Window.AddFlags(WindowManagerFlags.Fullscreen);
        this.Window.ClearFlags(WindowManagerFlags.Fullscreen);
        //this.Title += " " + ;
        CurrentPlatform.Init();
        client = new MobileServiceClient(applicationURL);
        await InitLocalStoreAsync();
        ChantiersTable = client.GetSyncTable<Chantiers>();
        AssignMaterielTable = client.GetSyncTable<AssignMaterielDB>();
        MaterielTable = client.GetSyncTable<MaterielDB>();
        PersonnelTable = client.GetSyncTable<Personnel>();
        AlertMat = client.GetSyncTable<AlertMateriel>();
        // Create your application here


        await SyncAsync(pullData: true);
        string idass = Intent.GetStringExtra("IdAssignMat");
        AssignMaterielDB assign = await AssignMaterielTable.LookupAsync(idass);

        _table = FindViewById<TableLayout>(Resource.Id.table_main);
       TableRow.LayoutParams layoutParams = new TableRow.LayoutParams(
            ViewGroup.LayoutParams.WrapContent,
            ViewGroup.LayoutParams.WrapContent
            );

        List<string> assignmatod = new List<string>();
        try
        {
            //string idass = Intent.GetStringExtra("IdAssignMat");
            string IdUser = Intent.GetStringExtra("IdUser");
            string Estcdt = Intent.GetStringExtra("iscdt");

            if (Estcdt == "True")
            {
                var thelist = await AssignMaterielTable.Where(idmat => idmat.Id == idass).Take(1).ToListAsync();

                //var thelist2 = await AssignPersonnelTable.Where(n => n.IdUser == IdUser).ToListAsync();

                foreach (AssignMaterielDB item in thelist)
                {

                    var chantier = await ChantiersTable.Where(idchat => idchat.Id == item.IdChantier).Take(1).ToListAsync();

                    var Matthelist = await MaterielTable.Where(Idmat => Idmat.Id == item.IdEngin).Take(1).ToListAsync();
                    foreach (MaterielDB mat in Matthelist)
                    {
                        foreach (Chantiers ch in chantier)
                        {
                            var listper = await PersonnelTable.Where(Idmat => Idmat.Id == ch.Cdt).ToListAsync();
                            foreach (Personnel pe in listper)
                            {
                                assignmatod.Add(item.Id);
                                TableRow tableR = new TableRow(this);
                                TextView text = new TextView(this);
                                text.SetText(ch.NomChantier.ToCharArray(), 0, ch.NomChantier.Length);
                                text.Gravity = GravityFlags.Center;
                                tableR.AddView(text,0);
                                TextView text2 = new TextView(this);
                                text2.Gravity = GravityFlags.Center;
                                string cdttr = pe.Pers_Prenom + " " + pe.Pers_Nom;
                                text2.SetText(cdttr.ToCharArray(), 0,cdttr.Length);
                                tableR.AddView(text2, 1);
                                TextView text3 = new TextView(this);
                                text3.Gravity = GravityFlags.Center;
                                text3.SetText(item.DateDebut.ToString("d").ToCharArray(), 0, item.DateDebut.ToString("d").Length);
                                tableR.AddView(text3, 2);
                                TextView text4 = new TextView(this);
                                text3.Gravity = GravityFlags.Center;
                                text4.SetText(item.DateFin.ToString("d").ToCharArray(), 0, item.DateFin.ToString("d").Length);
                                tableR.AddView(text4, 3);
                                tableR.Id =View.GenerateViewId();
                                tableR.Clickable = true;
                                idengin = item.IdEngin;
                                idassign = idass;
                                iddemandeur = IdUser;
                                idreceveur = ch.Cdt;
                                tableR.Click += HandleClick;
                                _table.AddView(tableR);
                                //    _listView.ItemClick += _listView_ItemClick;

                            }
                        }
                    }
                }
            }

            _adapter3 = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, assignmatod);

        }
        catch (MobileServiceInvalidOperationException e)
        {
            Console.Error.WriteLine(@"ERROR {0}", e.Message);
            //  return null;
        }


    }



    private   void HandleClick(object sender, EventArgs e)
     {
         var clickedTableRow = sender as TableRow;
         int s = clickedTableRow.Id;
         var tag = clickedTableRow.Tag;
        string ideng = idengin;
        string idass = idassign;
        string idrecev = idreceveur;
        string iddeman = iddemandeur;
         string arg = _adapter3.GetItem(s-1).ToString();
        string message = "Envoyer une demande pour cette engin sur la période concernée?";
       CreateAndShowDialogDemande(message, "DEMANDE ENGIN", ideng, iddeman, idass, idrecev);


       Toast.MakeText(this, tag + " idassign "+ s+ "arg " + arg, ToastLength.Long).Show();

     }


    private async void CreateAndShowDialogDemande(string message, string title, string idmat, string IdDemande, string IdAssignMat, string Idreceveur )
    {
        Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);
        string IdDuChantier = Intent.GetStringExtra("IdDuChantier");
        builder.SetMessage(message);
        builder.SetTitle(title);
        builder.Create();
        builder.SetPositiveButton("Faire la demande ?", async (senderAlert, args) =>
        {

            var Demande = new AlertMateriel
            {

                IdMateriel = idmat,
                IdDemandeur = IdDemande,
                IdAssignMat = IdAssignMat,
                IdReceveur = Idreceveur,
                VU = false,
                Deleted = "False",



            };
            try
            {
                progress = new Android.App.ProgressDialog(this);
                progress.Indeterminate = true;
                progress.SetProgressStyle(Android.App.ProgressDialogStyle.Spinner);
                progress.SetMessage("Envoie de la Demande ...");
                progress.SetCancelable(false);
                progress.Show();
                await AlertMat.InsertAsync(Demande);
                await SyncAsync(pullData: true);
                progress.Cancel();
                CreateAndShowDialog("Demande", "Votre demande a été envoyé...");
                // Toast.MakeText(this, "Votre demande a été envoyé", ToastLength.Long).Show();
                //await client.SyncContext.PushAsync();
            }
            catch (Exception e)
            {
                CreateAndShowDialog(e.ToString(), "Error");
            }



        });
        builder.SetNegativeButton("Annuler", (senderAlert, args) =>
        {
            builder.Dispose();
        });



        builder.Show();

    }

    private void CreateAndShowDialog(String title, string message)
    {
        Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this);

        builder.SetMessage(message);
        builder.SetTitle(title);
        builder.SetNegativeButton("Rester sur la page", (senderAlert, args) =>
        {
            builder.Dispose();
        });
        builder.Create().Show();


    }


    private async Task InitLocalStoreAsync()
    {
        // new code to initialize the SQLite store
        string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), localDbFilename);

        if (!File.Exists(path))
        {
            File.Create(path).Dispose();
        }

        var store = new MobileServiceSQLiteStore(path);
        store.DefineTable<AlertMateriel>();
        store.DefineTable<Personnel>();
        store.DefineTable<Chantiers>();
        store.DefineTable<AssignMaterielDB>();
        store.DefineTable<MaterielDB>();

        // Uses the default conflict handler, which fails on conflict
        // To use a different conflict handler, pass a parameter to InitializeAsync. For more details, see http://go.microsoft.com/fwlink/?LinkId=521416
        await client.SyncContext.InitializeAsync(store);
    }
    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        base.OnActivityResult(requestCode, resultCode, data);
        AuthenticationAgentContinuationHelper.SetAuthenticationAgentContinuationEventArgs(requestCode, resultCode, data);
    }


    private async Task SyncAsync(bool pullData = false)
    {
        try
        {
            await client.SyncContext.PushAsync();

            await ChantiersTable.PullAsync("allTodoItems", ChantiersTable.CreateQuery()); // query ID is used for incremental sync
            await AssignMaterielTable.PullAsync("allMat", AssignMaterielTable.CreateQuery());
            await MaterielTable.PullAsync("alltvx", MaterielTable.CreateQuery());
            await PersonnelTable.PullAsync("allUsers", PersonnelTable.CreateQuery());
            await AlertMat.PullAsync("AlertMateirel", AlertMat.CreateQuery());
        }
        catch (Java.Net.MalformedURLException)
        {
            CreateAndShowDialog("", "Error");
        }
        catch (Exception e)
        {
            CreateAndShowDialog( "Error", e.ToString());
        }
    }
}}
公共类可定义:活动
{
专用IMobileServiceSyncTable AlertMat;
私有IMobileServiceSyncTable可分配材料;
私有IMobileServiceSyncTable;
私有IMobileServiceSyncTable MaterialTable;
私人IMobileServiceSyncTable个人资料;
专用表布局_表;
私人移动服务客户端;
专用阵列适配器3;
私有字符串idengin=“”;
私有字符串idassign=“”;
私有字符串iddemandeur=“”;
私有字符串idreceveur=“”;
/*
私有文本视图引擎;
私有文本视图尚蒂尔;
私有文本视图Cdt;
私有文本视图数据单元;
私有文本视图数据;
专用阵列适配器*/
常量字符串applicationURL=@“url”;
常量字符串applicationKey=@“key”;
公共列表assignmatod{get;private set;}
常量字符串localDbFilename=“localstore.db”;
私人进展对话进展;
受保护的重写异步void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Layout_DemandeMat2);
this.Window.AddFlags(WindowManagerFlags.Fullscreen);
this.Window.ClearFlags(WindowManagerFlags.Fullscreen);
//此.Title+=“”+;
CurrentPlatform.Init();
客户端=新的MobileServiceClient(applicationURL);
等待InitLocalStoreAsync();
ChantiersTable=client.GetSyncTable();
AssignMaterialTable=client.GetSyncTable();
MaterialTable=client.GetSyncTable();
PersonnelTable=client.GetSyncTable();
AlertMat=client.GetSyncTable();
//在此处创建应用程序
等待SyncAsync(pullData:true);
字符串idass=Intent.GetStringExtra(“IdAssignMat”);
AssignMaterialLab assign=等待AssignMaterialTable.LookupAsync(idass);
_table=findviewbyd(Resource.Id.table\u main);
TableRow.LayoutParams LayoutParams=新建TableRow.LayoutParams(
ViewGroup.LayoutParams.WrapContent,
ViewGroup.LayoutParams.WrapContent
);
List assignmatod=新列表();
尝试
{
//字符串idass=Intent.GetStringExtra(“IdAssignMat”);
字符串IdUser=Intent.GetStringExtra(“IdUser”);
字符串Estcdt=Intent.GetStringExtra(“iscdt”);
如果(Estcdt==“真”)
{
var thelist=await assignmaterialtable.Where(idmat=>idmat.Id==idass).Take(1.toListSync();
//var thelist2=await AssignPersonnelTable.Where(n=>n.IdUser==IdUser.toListSync();
foreach(分配列表中的物料项)
{
var chantier=wait ChantiersTable.Where(idchat=>idchat.Id==item.IdChantier.Take(1.ToListAsync();
var Matthelist=await materialtable.Where(Idmat=>Idmat.Id==item.IdEngin).Take(1.ToListAsync();
foreach(Matthelist中的MaterialDB垫)
{
foreach(Chantiers ch in chantier)
{
var listper=await PersonnelTable.Where(Idmat=>Idmat.Id==ch.Cdt.tolistSync();
foreach(列表中的人员pe)
{
assignmatod.Add(项目Id);
TableRow tableR=新的TableRow(本);
TextView text=新的TextView(此);
text.SetText(ch.NomChantier.ToCharArray(),0,ch.NomChantier.Length);
text.Gravity=GravityFlags.Center;
tableR.AddView(文本,0);
TextView text2=新的TextView(此);
text2.重力=重力梯度.中心;
字符串cdttr=pe.Pers\u Prenom+“”+pe.Pers\u Nom;
text2.SetText(cdttr.ToCharArray(),0,cdttr.Length);
tableR.AddView(text2,1);
TextView text3=新的TextView(此);
text3.重力=重力梯度.中心;
text3.SetText(item.datededusth.ToString(“d”).tocharray(),0,item.datededusth.ToString(“d”).Length);
tableR.AddView(text3,2);
TextView text4=新的TextView(此);
text3.重力=重力梯度.中心;
text4.SetT