Problem using AddAsync

6 posts, 0 answers
  1. Manuel
    Manuel avatar
    5 posts
    Member since:
    Mar 2012

    Posted 06 Apr 2014 Link to this post

    Hi all,

    I'm working with the sample Azure sample :

    http://www.telerik.com/help/windows-phone/radcontrols-cloud-synchronization-gettingstarted-azure.html  with WP8 with the last telerik build (2014.1.226.3040). Following the forum i correct two points before execute :

    1 - Replace Newtonsoft by the last nugget version : 6.0.0.0.
    2 - Add a column : synchronizationid (string) in my azur mobile database.

    In the AddPerson.Xaml file i have : await this.newPerson.SynchronizeAsync();

    When i add a new person with wifi => the new Person is added in Azure and in my local database : LocalDB => ok
    When i add a new person without wifi => error : it's normal because it can't synchronize without connection

    Now in my scenario i want to : Add localy a person and Synchronize it after.

    Then i replace "await this.newPerson.SynchronizeAsync();" by "await "MainViewModel.Instance.Context.AddAsync(newPerson);"

    The person is added in my local database with
    synchronizationid = 00000000-0000-0000-0000-000000000000
    Id = null

    But when i do "await MainViewModel.Instance.Context.SynchronizeAsync();" nothing append in the azure server the Person isn't uploaded even when i do "await MainViewModel.Instance.Context.SynchronizeAsync(SynchronizationOperationFlags.Upload);"

    I try the same syntax that http://www.telerik.com/help/windows-phone/radcontrols-cloud-synchronization-synccontext.html

    SynchronizationContext<Task> tasksContext = SynchronizationContextPool.GetContextForType<Task>();
    Task task = new Task();
    task.Name = "Meeting with John";
    task.Description = "Meet with John to discuss the sales statistics from the last month.";
    task.DueDate = new DateTime(26, 12, 2013);// Registers adds the item to the context. This stores is locally and schedules the item for server creation during the next synchronization routine
    await tasksContext.AddAsync(task);// Starts a new synchronization routine which makes sure local and Cloud items of the corresponding type are synchronized
    await tasksContext.SynchronizeAsync();

    adapted to my Person sample but nothing appened, the object isn't uploaded in azure ??

    Question 1 :
    how can i upload a Person locally added with AddAsync(newPerson) ?

    Question 2 :
    how can i upload the list of Person added with AddAsync(newPerson) ?           

    IQueryable<Person> reso = MainViewModel.Instance.Context.LocalDatabase.Where(p=>p.Id==null);
                foreach (var person in reso)
                {
    ??????
                }
    ?????????

    For your information i try  this to do a delete:           


    IQueryable<Person> reso = MainViewModel.Instance.Context.LocalDatabase.Where(p => p.Id != null);
                foreach (var person in reso)
                {
                    Debug.WriteLine(person.Name);
                    await MainViewModel.Instance.Context.DeleteAsync(person);
                }

    It's work great for delete but impossible to upload after AddAsync 
    Thanks you very much for your help
    Best regards Manuel
  2. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 09 Apr 2014 Link to this post

    Hi Manuel,

    Thanks for writing.

    It seems that there is something which prevents the upload of the data item to Azure. Based on the code snippets I cannot exactly say what happens.

    Will it be possible that you send us here your project in a ZIP archive for further investigation?

    You will have to open a new support ticket to be able to upload your file.

    Thanks for your time.

    We are looking forward to your response.

    Regards,
    Deyan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
  4. Manuel
    Manuel avatar
    5 posts
    Member since:
    Mar 2012

    Posted 09 Apr 2014 in reply to Deyan Link to this post

    Thanks Deyan,

    i have just open a new ticket with the project in a zip archive


    Manuel
  5. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 10 Apr 2014 Link to this post

    Hello Manuel,

    Thanks for writing back and for the attached project.

    I think the problem comes from the fact you are using the new Azure Mobile Services Table Schema but also have modified the backend scripts for insert and update. Our online help article here states exactly this:

    http://www.telerik.com/help/windows-phone/radcontrols-cloud-synchronization-gettingstarted-azure.html

    But it is important to know that this is needed for the old Azure Mobile Services table schema which does not automatically initialize the CreatedAt  and ModifiedAt values.

    You don't need to do that now so if you simply reset your backend scripts to their default state things should be working as expected.

    We will make sure to update our Online Help stating this to avoid any future confusions.

    Regards,
    Deyan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  6. Manuel
    Manuel avatar
    5 posts
    Member since:
    Mar 2012

    Posted 13 Apr 2014 in reply to Deyan Link to this post

    Hi Deyan,

    I have done the changes in Azur but i keep having the same issue...Does it work with my project for you ?

    Thanks for your answer
  7. Deyan
    Admin
    Deyan avatar
    2037 posts

    Posted 17 Apr 2014 Link to this post

    Hi Manuel,

    Thanks for writing back.

    I have tried the scenario with a newly created Azure Synchronization Project and I was able to correctly synchronize with my Azure Mobile Service table.

    I just need to make sure that my Dynamic Schema is enabled in the Azure Portal configuration settings for my table.

    Additionally, to prevent the exception which is thrown by the SDK when trying to fetch the objects from a table which is empty, I need to first upload an object or simply use a try-catch block.

    I hope this is helpful.

    Let me know if you need further assistance here.

    Regards,
    Deyan
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top
DevCraft banner