コード例 #1
0
ファイル: Program.cs プロジェクト: yvanam/SyncPro
        private static SyncRelationship GetRelationship(Dictionary <string, string> args)
        {
            string strRelationshipId;

            if (!args.TryGetValue("relationshipId", out strRelationshipId))
            {
                throw new Exception("/relationshipId parameter not provided.");
            }

            Guid relationshipId = Guid.Parse(strRelationshipId);

            string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string appDataRoot      = Path.Combine(localAppDataPath, "SyncPro");

            DirectoryInfo appDataRootDir = new DirectoryInfo(appDataRoot);

            foreach (DirectoryInfo relationshipDir in appDataRootDir.GetDirectories())
            {
                Guid guid;
                if (Guid.TryParse(relationshipDir.Name, out guid) && guid == relationshipId)
                {
                    SyncRelationship relationship = SyncRelationship.Load(guid);

                    return(relationship);
                }
            }

            throw new Exception("No relationship found with ID " + relationshipId);
        }
コード例 #2
0
ファイル: GetSyncEntry.cs プロジェクト: yvanam/SyncPro
        private void ProcessInternalOffline()
        {
            string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string appDataRoot      = Path.Combine(localAppDataPath, "SyncPro");

            DirectoryInfo    appDataRootDir = new DirectoryInfo(appDataRoot);
            SyncRelationship relationship   = null;

            foreach (DirectoryInfo relationshipDir in appDataRootDir.GetDirectories())
            {
                Guid guid;
                if (Guid.TryParse(relationshipDir.Name, out guid) && guid == this.RelationshipId)
                {
                    relationship = SyncRelationship.Load(guid);
                    break;
                }
            }

            if (relationship == null)
            {
                throw new RelationshipNotFoundException(
                          "The relationship with ID " + this.RelationshipId + " was not found");
            }

            using (var db = relationship.GetDatabase())
            {
                foreach (SyncEntry syncEntry in db.Entries)
                {
                    this.WriteObject(syncEntry);
                }
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: yvanam/SyncPro
        private static void DumpConfig()
        {
            Global.Initialize(false);

            string localAppDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
            string appDataRoot      = Path.Combine(localAppDataPath, "SyncPro");

            DirectoryInfo appDataRootDir = new DirectoryInfo(appDataRoot);

            foreach (DirectoryInfo relationshipDir in appDataRootDir.GetDirectories())
            {
                Guid guid;
                if (!Guid.TryParse(relationshipDir.Name, out guid))
                {
                    WriteWarning("Failed to parse relationship directory '{0}' as a GUID", relationshipDir.Name);
                    continue;
                }

                SyncRelationship relationship = SyncRelationship.Load(guid);
                //relationship.BeginInitialize();

                // TODO: Do we really need to initialize the relationship in order to dump the configuration?
                //relationship.InitializeAsync().Wait();

                Console.WriteLine("---------------------------- [Relationship] ----------------------------");
                Console.WriteLine("RelationshipId: " + relationship.Configuration.RelationshipId);
                Console.WriteLine("Name: " + relationship.Configuration.Name);
                Console.WriteLine("Description: " + relationship.Configuration.Description);
                Console.WriteLine("Scope: " + relationship.Configuration.Scope);
                Console.WriteLine("SyncAttributes: " + relationship.Configuration.SyncAttributes);
                Console.WriteLine("TriggerType: " + relationship.Configuration.TriggerConfiguration.TriggerType);
                Console.WriteLine("SourceAdapter: " + relationship.Configuration.SourceAdapterId);
                Console.WriteLine("DestinationAdapter: " + relationship.Configuration.DestinationAdapterId);
                Console.WriteLine();
                Console.WriteLine("---------- [Adapters] ---------- ");

                foreach (AdapterBase adapter in relationship.Adapters)
                {
                    Console.WriteLine("Id: " + adapter.Configuration.Id);
                    Console.WriteLine("AdapterTypeId: " + adapter.Configuration.AdapterTypeId);
                    Console.WriteLine("AdapterTypeName: " +
                                      AdapterRegistry.GetRegistrationByTypeId(adapter.Configuration.AdapterTypeId).AdapterType.Name);
                    Console.WriteLine("IsOriginator: " + adapter.Configuration.IsOriginator);
                    Console.WriteLine("Flags: " +
                                      string.Join(",", StringExtensions.GetSetFlagNames <Data.AdapterFlags>(adapter.Configuration.Flags)));
                    Console.WriteLine();
                }

                Console.WriteLine();
            }
        }