/// <summary> /// The derived class might need to call CleanUp in ProcessResponse. /// </summary> protected void CleanUp() { if ((!ServerSyncML.Body.HasFinal) && // server should has more (Facade.ResponseCommandPool.Count < 2) && //there's no command to send except the status for server's SyncHdr (ClientSyncML.Body.HasFinal)) // last client message has final { SyncMLAlert alert = SyncMLAlert.Create(); alert.CmdID = ClientSyncML.NextCmdID; alert.Data.Content = "222"; SyncMLItem item = SyncMLItem.Create(); item.Target.LocURI.Content = Facade.ContactDataSourceAtServer; item.Source.LocURI.Content = Facade.LocalDataSource.DataSourceName; alert.ItemCollection.Add(item); Facade.ResponseCommandPool.Add(alert); CommandAndStatusRegister.Add(alert); Facade.clientRequestMore = true; } //7: while (Facade.ResponseCommandPool.Count > 1)//if there's only one which is for Status with Hdr, no need to send back { CleaningUpStep mapStep = new CleaningUpStep(Facade); mapStep.Send(); } }
public void TestAlert() { XElement nav = XElement.Load(CaseFile("Alert.xml")); SyncMLAlert f = SyncMLAlert.Create(nav); Assert.IsTrue(CompareXml(nav, f.Xml), f.Xml.ToString()); }
private SyncMLAlert CreateSyncAlert(SyncType syncType) { //Tell the server what sync type SyncMLAlert alert = SyncMLAlert.Create(); alert.CmdID = ClientSyncML.NextCmdID; MetaAnchor anchor; Facade.NextAnchor = DateTime.UtcNow.Ticks.ToString(); switch (syncType) { case SyncType.TwoWay: alert.Data.Content = "200"; anchor = MetaAnchor.Create(Facade.NextAnchor, Facade.LastAnchor); Facade.DisplayOperationMessage("Last anchor: " + anchor.Last.Content); break; case SyncType.Slow: alert.Data.Content = "201"; // anchor = MetaAnchor.Create(DateTime.Now.ToString("yyyyMMddTHHmmssZ"), "0"); anchor = MetaAnchor.Create(Facade.NextAnchor, Facade.LastAnchor); break; case SyncType.OneWayFromClient: alert.Data.Content = "202"; anchor = MetaAnchor.Create(Facade.NextAnchor, Facade.LastAnchor); Facade.DisplayOperationMessage("Last anchor: " + anchor.Last.Content); break; case SyncType.RefreshFromClient: alert.Data.Content = "203"; anchor = MetaAnchor.Create(Facade.NextAnchor, Facade.LastAnchor); Facade.DisplayOperationMessage("Last anchor: " + anchor.Last.Content); break; case SyncType.OneWayFromServer: alert.Data.Content = "204"; anchor = MetaAnchor.Create(Facade.NextAnchor, Facade.LastAnchor); Facade.DisplayOperationMessage("Last anchor: " + anchor.Last.Content); break; case SyncType.RefreshFromServer: alert.Data.Content = "205"; anchor = MetaAnchor.Create(Facade.NextAnchor, Facade.LastAnchor); Facade.DisplayOperationMessage("Last anchor: " + anchor.Last.Content); break; default: throw new FacadeErrorException("Unexpected sync type"); } //Tell what to sync SyncMLItem item = SyncMLItem.Create(); item.Target.LocURI.Content = Facade.ContactDataSourceAtServer; item.Source.LocURI.Content = Facade.LocalDataSource.DataSourceName; //Tell anchors item.Meta.Xml.Add(anchor.Xml); alert.ItemCollection.Add(item); return(alert); }