/// <summary> /// makes an uSync empty file /// </summary> /// <remarks> /// When the changetype is Clean, the key should be the parent folder /// you want to clean. /// </remarks> /// <typeparam name="TObject">type of object (IEntity based)</typeparam> public static XElement MakeEmpty(Guid key, SyncActionType change, string alias) { return(new XElement(uSyncConstants.Serialization.Empty, new XAttribute("Key", key), new XAttribute("Alias", alias), new XAttribute("Change", change))); }
public override SyncAttempt <XElement> SerializeEmpty(TObject item, SyncActionType change, string alias) { var attempt = base.SerializeEmpty(item, change, alias); if (attempt.Success) { attempt.Item.Add(new XAttribute("Level", GetLevel(item))); } return(attempt); }
public void AddAction(SyncActionType actionType, string keyNameValue, Type type) { _actions.Add(new SyncAction() { Action = actionType, Key = Guid.Empty, Name = keyNameValue, TypeName = type.ToString() }); SaveActions(); }
public void AddAction(Guid key, string alias, SyncActionType actionType) { if (!actions.Any(x => x.Key == key && x.Alias == alias)) { actions.Add(new SyncAction() { Key = key, Alias = alias, Action = actionType }); } }
public SyncAction( BackupSource source, BackupDestination destination, SyncActionType actionType, File sourceFile, File destinationFile) { this.Source = source; this.Destination = destination; this.Action = actionType; this.SourceFile = sourceFile; this.DestinationFile = destinationFile; }
public virtual SyncAttempt <XElement> SerializeEmpty(TObject item, SyncActionType change, string alias) { logger.Debug(serializerType, "Base: Serializing Empty Element {alias} {change}", alias, change); if (string.IsNullOrEmpty(alias)) { alias = ItemAlias(item); } var node = XElementExtensions.MakeEmpty(ItemKey(item), change, alias); return(SyncAttempt <XElement> .Succeed("Empty", node, ChangeType.Removed)); }
public virtual SyncAttempt <XElement> SerializeEmpty(TObject item, SyncActionType change, string alias) { logger.Debug <TObject>("Base: Serializing Empty Element (Delete or rename) {0}", alias); if (string.IsNullOrEmpty(alias)) { alias = ItemAlias(item); } var node = new XElement(uSyncConstants.Serialization.Empty, new XAttribute("Key", item.Key), new XAttribute("Alias", alias), new XAttribute("Change", change)); return(SyncAttempt <XElement> .Succeed("Empty", node, ChangeType.Removed)); }
public void AddAction(Guid key, SyncActionType actionType) { AddAction(key, "", actionType); }
public void send_reportContacts(long syncOpRevision, SyncCategory category, List<ContactReport> contactReports, SyncActionType actionType) #endif { oprot_.WriteMessageBegin(new TMessage("reportContacts", TMessageType.Call, seqid_)); reportContacts_args args = new reportContacts_args(); args.SyncOpRevision = syncOpRevision; args.Category = category; args.ContactReports = contactReports; args.ActionType = actionType; args.Write(oprot_); oprot_.WriteMessageEnd(); #if SILVERLIGHT return oprot_.Transport.BeginFlush(callback, state); #else oprot_.Transport.Flush(); #endif }
public IAsyncResult send_reportContacts(AsyncCallback callback, object state, long syncOpRevision, SyncCategory category, List<ContactReport> contactReports, SyncActionType actionType)
public List<ContactReportResult> reportContacts(long syncOpRevision, SyncCategory category, List<ContactReport> contactReports, SyncActionType actionType) { #if !SILVERLIGHT send_reportContacts(syncOpRevision, category, contactReports, actionType); return recv_reportContacts(); #else var asyncResult = Begin_reportContacts(null, null, syncOpRevision, category, contactReports, actionType); return End_reportContacts(asyncResult); #endif }
public IAsyncResult Begin_reportContacts(AsyncCallback callback, object state, long syncOpRevision, SyncCategory category, List<ContactReport> contactReports, SyncActionType actionType) { return send_reportContacts(callback, state, syncOpRevision, category, contactReports, actionType); }
public void Read (TProtocol iprot) { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 2: if (field.Type == TType.I64) { SyncOpRevision = iprot.ReadI64(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 3: if (field.Type == TType.I32) { Category = (SyncCategory)iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 4: if (field.Type == TType.List) { { ContactReports = new List<ContactReport>(); TList _list360 = iprot.ReadListBegin(); for( int _i361 = 0; _i361 < _list360.Count; ++_i361) { ContactReport _elem362 = new ContactReport(); _elem362 = new ContactReport(); _elem362.Read(iprot); ContactReports.Add(_elem362); } iprot.ReadListEnd(); } } else { TProtocolUtil.Skip(iprot, field.Type); } break; case 5: if (field.Type == TType.I32) { ActionType = (SyncActionType)iprot.ReadI32(); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); }
public void AddAction(string alias, SyncActionType actionType) { AddAction(Guid.NewGuid(), alias, actionType); }
public void GetEmptyAction_Is_None_When_Not_Empty() { SyncActionType noAction = _node.GetEmptyAction(); Assert.AreEqual(SyncActionType.None, noAction); }
public SyncAction(SyncActionType syncActionType, SyncTarget syncTarget) { this.SyncActionType = syncActionType; this.SyncTarget = syncTarget; Guid = Guid.NewGuid(); }
public async Task BuildAsync() { if (!string.IsNullOrEmpty(this.Context.LocalCursor) && DirectoryIsEmptyOrDoesNotExist(this.Context.LocalPath)) { // We have a local cursor which means we've run before. And yet the local // directory doesn't exist. Depending on our sync direction this either means // deleting everything remotely or re-downloading everything. This is sufficiently // bad that we will defer to the user. If this is deliberate then the user can // either delete this job, manually delete remotely or reset. If not, perhaps // it's a missing UNC share, then we've just saved the data. throw new SyncotronException( "LocalPath is empty or does not exist, but this job has previously run. " + "Aborting to protect data. If this is all fine and you want to run anyway " + "just run once with \"-CommandType Reset\""); } // Do we already have stored actions? var previous = this.Context.LocalStorage.ActionSelect(); if (previous.Count() > 0) { foreach (var action in previous) { this.Actions.Add(action); } this.LocalCursor = this.Context.LocalStorage.SettingsRead <string>("PendingLocalCursor"); this.RemoteCursor = this.Context.LocalStorage.SettingsRead <string>("PendingRemoteCursor"); return; } // Now scan for new ones var local = this.ScanLocalAsync(); var remote = this.ScanRemoteAsync(); await local; await remote; if (this.Context.ScanMode == ScanMode.Continue) { // There's a minor expense in doing a further scan of files but it saves time // when a previous job has failed (e.g. timeout) and avoids re-transferring // files which already exist. However, it can lead to confusion when working // out what action to take. Current workaround is to use -ConflictStrategy // LatestWin. Consider making this optional instead await this.FurtherScanForContinuation(); } var actions = new List <SyncAction>(); foreach (var action in this.ActionDictionary.Values) { SyncActionType type = this.TypeChooser.Choose(action); if (type != SyncActionType.None) { action.Type = type; actions.Add(action); } } this.Actions.Add(actions.Where(a => a.Type == SyncActionType.DeleteLocal).OrderByDescending(a => a.Key.Length)); this.Actions.Add(actions.Where(a => a.Type == SyncActionType.DeleteRemote).OrderByDescending(a => a.Key.Length)); this.Actions.Add(actions.Where(a => a.Type == SyncActionType.Download).OrderBy(a => a.Key.Length)); this.Actions.Add(actions.Where(a => a.Type == SyncActionType.Upload).OrderBy(a => a.Key.Length)); this.Actions.Add(actions.Where(a => a.Type == SyncActionType.KeepBoth)); this.Context.LocalStorage.BeginTransaction(); foreach (var action in this.Actions) { this.Context.LocalStorage.ActionWrite(action); } this.Context.LocalStorage.EndTransaction(); this.Context.LocalStorage.SettingsWrite("PendingLocalCursor", this.LocalCursor); this.Context.LocalStorage.SettingsWrite("PendingRemoteCursor", this.RemoteCursor); }
private void Synchronize(SPItemEventProperties properties, IReadOnlyCollection <SyncType> syncTypes, SyncActionType syncActionType) { switch (syncTypes.Count) { case 0: return; case 1: this._syncProvider = new SpSyncProvider(syncTypes.FirstOrDefault()); if (this._syncProvider.Synchronize(properties.ListItem, syncActionType)) { base.ItemAdded(properties); } return; default: bool result = false; foreach (SyncType syncType in syncTypes) { this._syncProvider = new SpSyncProvider(syncType); result = this._syncProvider.Synchronize(properties.ListItem, syncActionType); } if (result) { base.ItemAdded(properties); } break; } }
public bool Synchronize(SPListItem spListItem, SyncActionType syncActionType) { try { ArchiveCacheCRUD syncCrud = new ArchiveCacheCRUD(spListItem.ParentList.ParentWeb.Site); switch (this._syncType) { case SyncType.SpList: this.Adapter.TableStruct.TableName = this.Adapter.BuildTableName(spListItem.ParentList.RootFolder.ServerRelativeUrl); break; case SyncType.SpContentType: string tableNameSetting = SettingsProvider.Instance(spListItem.ParentList.ParentWeb).TableName(spListItem.ParentList); this.Adapter.TableStruct.TableName = this.Adapter.BuildTableName(tableNameSetting); break; default: throw new ArgumentOutOfRangeException(); } switch (syncActionType) { case SyncActionType.Add: case SyncActionType.Update: List <Columns> columns = spListItem .ParentList.Fields.Cast <SPField>() .Where(f => !f.Hidden || this.Adapter.IncludedFields.Contains(f.InternalName)) .Select(field => this.Adapter.AsColumn(spListItem, field)) .Where(c => c != null) .ToList(); string editUrl = spListItem.ParentList.DefaultEditFormUrl + "?ID=" + spListItem.ID + "&RootFolder=/" + (spListItem.Folder == null ? string.Empty : spListItem.Folder.Url); columns.Add(new Columns { ColumnName = "EditUrl", ColumnValue = editUrl }); columns.Add(new Columns { ColumnName = "ItemUrl", ColumnValue = spListItem.Url }); Columns keyFieldColumn = columns.FirstOrDefault(c => c.ColumnName == this.Adapter.KeyFieldName); if (columns.Any(x => x.ColumnName == "Versions")) { columns = columns.Where(x => x.ColumnName != "Versions").ToList(); } if (keyFieldColumn == null) { columns.Add(new Columns { ColumnName = this.Adapter.KeyFieldName, ColumnValue = spListItem.ID.ToString() }); } else if (keyFieldColumn.ColumnValue == string.Empty) { keyFieldColumn.ColumnValue = spListItem.ID.ToString(); } this.Adapter.TableStruct.Columns = columns; break; case SyncActionType.Delete: SPField spField = spListItem .ParentList.Fields.Cast <SPField>() .FirstOrDefault(f => f.InternalName == this.Adapter.KeyFieldName); Columns keyColumn = this.Adapter.AsColumn(spListItem, spField); this.Adapter.TableStruct.Columns = new List <Columns> { keyColumn }; this.Adapter.TableStruct.RowIsDeleted = true; break; default: throw new ArgumentOutOfRangeException("syncActionType"); } ErrorCode result = syncCrud.CreateOrUpdateValues(this.Adapter.TableStruct); ErrorCode permissionResult = this.WritePermissions(spListItem, syncCrud); return(result == ErrorCode.NoError && permissionResult == ErrorCode.NoError); } catch (Exception ex) { Logger.WriteError(ex.Message, "SpSyncProvider.Synchronize()"); return(false); } }