Exemplo n.º 1
0
        private static void ParseConfigurationSettings(AdoDataConnection connection, int deviceID, int profileTaskID)
        {
            TableOperations <Device> deviceTable = new TableOperations <Device>(connection);
            Device device = deviceTable.QueryRecordWhere("ID = {0}", deviceID);
            Dictionary <string, string> deviceConnectionString = device.ConnectionString.ParseKeyValuePairs();

            TableOperations <ConnectionProfile> profileTable = new TableOperations <ConnectionProfile>(connection);
            ConnectionProfile profile = profileTable.QueryRecordWhere("ID = {0}", deviceConnectionString["connectionProfileID"]);

            TableOperations <ConnectionProfileTask> profileTaskTable = new TableOperations <ConnectionProfileTask>(connection);

            profileTaskTable.RootQueryRestriction[0] = profile.ID;

            ConnectionProfileTask         profileTask         = profileTaskTable.QueryRecordWhere("ID = {0}", profileTaskID);
            ConnectionProfileTaskSettings profileTaskSettings = profileTask.Settings;

            s_baseUrl      = deviceConnectionString["baseURL"];
            s_serialNumber = deviceConnectionString["serialNumber"];

            s_getLocalPath = startTime =>
            {
                string subFolder = GetSubFolder(device, profile.Name, profileTaskSettings.DirectoryNamingExpression, startTime);
                return($"{profileTaskSettings.LocalPath}{Path.DirectorySeparatorChar}{subFolder}");
            };
        }
Exemplo n.º 2
0
        public int GetDefaultIGridConnectionProfileID()
        {
            TableOperations <ConnectionProfileTaskQueue> profileTaskQueueTable = DataContext.Table <ConnectionProfileTaskQueue>();
            TableOperations <ConnectionProfile>          profileTable          = DataContext.Table <ConnectionProfile>();
            ConnectionProfile profile = profileTable.QueryRecordWhere("Name = {0}", DefaultIGridConnectionProfileName);

            if ((object)profile == null)
            {
                ConnectionProfileTaskQueue profileTaskQueue = profileTaskQueueTable.NewRecord();
                profileTaskQueue.Name                 = DefaultIGridConnectionProfileTaskQueueName;
                profileTaskQueue.MaxThreadCount       = 4;
                profileTaskQueue.UseBackgroundThreads = false;
                profileTaskQueue.Description          = "Connection Profile Task for I-Grid Devices";
                profileTaskQueueTable.AddNewRecord(profileTaskQueue);
                profileTaskQueue = profileTaskQueueTable.QueryRecordWhere("Name = {0}", DefaultIGridConnectionProfileTaskQueueName);

                profile                    = profileTable.NewRecord();
                profile.Name               = DefaultIGridConnectionProfileName;
                profile.Description        = "Connection Profile for I-Grid Devices";
                profile.DefaultTaskQueueID = profileTaskQueue.ID;
                profileTable.AddNewRecord(profile);
                profile.ID = GetDefaultIGridConnectionProfileID();

                TableOperations <ConnectionProfileTask> profileTaskTable = DataContext.Table <ConnectionProfileTask>();
                profileTaskTable.RootQueryRestriction[0] = profile.ID;
                int taskCount = profileTaskTable.QueryRecordCount();

                if (taskCount == 0)
                {
                    ConnectionProfileTask         profileTask         = profileTaskTable.NewRecord();
                    ConnectionProfileTaskSettings profileTaskSettings = profileTask.Settings;

                    profileTask.ConnectionProfileID = profile.ID;
                    profileTask.Name = "I-Grid Default Downloader Task";

                    profileTaskSettings.FileExtensions            = "*.*";
                    profileTaskSettings.RemotePath                = "/";
                    profileTaskSettings.LocalPath                 = Program.Host.Model.Global.DefaultLocalPath;
                    profileTaskSettings.ExternalOperation         = "IGridDownloader.exe <DeviceID> <TaskID>";
                    profileTaskSettings.DirectoryNamingExpression = @"<YYYY><MM>\<DeviceFolderName>";

                    profileTaskTable.AddNewRecord(profileTask);
                }
            }

            return(profile.ID);
        }