예제 #1
0
파일: Program.cs 프로젝트: yvanam/SyncPro
        private static void SetToken(Dictionary <string, string> args)
        {
            Global.Initialize(false);

            AdapterBase adapter = GetAdapter(args);
            string      file;

            if (!args.TryGetValue("file", out file))
            {
                throw new Exception("/file is required");
            }

            if (adapter.Configuration.AdapterTypeId == OneDriveAdapter.TargetTypeId)
            {
                string        tokenContent = File.ReadAllText(file);
                TokenResponse token        = JsonConvert.DeserializeObject <TokenResponse>(tokenContent);

                // Encrypt the token if not already encrypted
                token.Protect();

                ((OneDriveAdapterConfiguration)adapter.Configuration).CurrentToken = token;

                adapter.SaveConfiguration();
            }
            else
            {
                AdapterRegistration registration =
                    AdapterRegistry.GetRegistrationByTypeId(adapter.Configuration.AdapterTypeId);

                throw new Exception(
                          string.Format("Cannot set token from adapter with type {0} ({1})",
                                        registration.AdapterType.Name, adapter.Configuration.AdapterTypeId));
            }
        }
예제 #2
0
        private void DispatcherTimer_Tick(object sender, EventArgs eventArgs)
        {
            try
            {
                m_updatingSelectedMeasurements = true;

                MeasurementPager.SelectedMeasurements.Clear();

                foreach (Guid signalID in AdapterBase.ParseOutputMeasurementKeys(GetDataSource(), false, FilterExpressionTextBox.Text).Select(key => key.SignalID))
                {
                    MeasurementPager.SelectedMeasurements.Add(signalID);
                }
            }
            catch
            {
                MeasurementPager.SelectedMeasurements.Clear();
            }
            finally
            {
                MeasurementPager.ReloadDataGrid();
                MeasurementPager.UpdateSelections();
                m_updatingSelectedMeasurements = false;
                m_dispatcherTimer.Stop();
            }
        }
 /// <summary>
 ///     <para>Initializes an instance of the <see cref="AdapterTransaction"/> class.</para>
 /// </summary>
 /// <param name="id">
 /// The id string of the transaction.
 /// </param>
 /// <param name="underlyingTransaction">
 /// The underlying transaction object.
 /// </param>
 /// <param name="adapter">
 /// The adapter owning the transaction.
 /// </param>
 public AdapterTransaction(string id, object underlyingTransaction, AdapterBase adapter)
 {
     this.id = id;
     this.underlyingTransaction = underlyingTransaction;
     this.adapter = adapter;
     this.state   = TransactionState.Unknown;
 }
예제 #4
0
        private async Task RestoreFileAsync(
            EntryUpdateInfo updateInfo,
            AdapterBase fromAdapter,
            AdapterBase toAdapter)
        {
            if (updateInfo.Entry.Type == SyncEntryType.Directory)
            {
                await toAdapter.CreateItemAsync(updateInfo.Entry).ConfigureAwait(false);

                return;
            }

            FileCopyHelper fileCopyHelper = new FileCopyHelper(
                this.Relationship,
                fromAdapter,
                toAdapter,
                updateInfo,
                null,
                this.encryptionCertificate,
                this.CancellationToken,
                this.CopyProgressChanged);

            if (this.Relationship.EncryptionMode == EncryptionMode.Encrypt)
            {
                fileCopyHelper.EncryptionMode = EncryptionMode.Decrypt;
            }

            fileCopyHelper.UpdateSyncEntry = false;

            Logger.Debug("Creating item with content");
            await fileCopyHelper.CopyFileAsync().ConfigureAwait(false);
        }
예제 #5
0
        /// <summary>
        /// Parses query expression from annotation for annotation type.
        /// </summary>
        /// <param name="annotation">Grafana annotation.</param>
        /// <param name="useFilterExpression">Determines if query is using a filter expression.</param>
        /// <returns>Parsed annotation type for query expression from <paramref name="annotation"/>.</returns>
        public static AnnotationType ParseQueryType(this Annotation annotation, out bool useFilterExpression)
        {
            if (annotation == null)
            {
                throw new ArgumentNullException(nameof(annotation));
            }

            string query = annotation.query ?? "";

            Tuple <AnnotationType, bool> result = TargetCache <Tuple <AnnotationType, bool> > .GetOrAdd(query, () =>
            {
                AnnotationType type         = AnnotationType.Undefined;
                bool parsedFilterExpression = false;

                if (AdapterBase.ParseFilterExpression(query, out string tableName, out string _, out string _, out int _))
                {
                    parsedFilterExpression = true;

                    switch (tableName.ToUpperInvariant())
                    {
                    case "RAISEDALARMS":
                        type = AnnotationType.RaisedAlarms;
                        break;

                    case "CLEAREDALARMS":
                        type = AnnotationType.ClearedAlarms;
                        break;

                    default:
                        throw new InvalidOperationException("Invalid FILTER table for annotation query expression.");
                    }
                }
예제 #6
0
        /// <summary>
        /// Returns a collection of mappings that match the given filter expression.
        /// </summary>
        /// <param name="filterExpression">The filter expression to be matched.</param>
        /// <returns>The collection of mappings that match the given expression.</returns>
        public IEnumerable <TypeMapping> EnumerateTypeMappings(string filterExpression)
        {
            string tableName;
            string whereExpression;
            string sortField;
            int    takeCount;

            if ((object)m_mappingTable == null)
            {
                m_mappingTable = GetMappingTable();
            }

            if (!AdapterBase.ParseFilterExpression(filterExpression, out tableName, out whereExpression, out sortField, out takeCount))
            {
                return(filterExpression
                       .Split(';')
                       .Select(str => str.Trim())
                       .Where(str => !string.IsNullOrEmpty(str))
                       .Select(GetTypeMapping));
            }

            if (!tableName.Equals("Mappings", StringComparison.OrdinalIgnoreCase))
            {
                return(Enumerable.Empty <TypeMapping>());
            }

            return(m_mappingTable
                   .Select(whereExpression, sortField)
                   .Take(takeCount)
                   .Select(row => row.Field <string>("MappingIdentifier"))
                   .Select(GetTypeMapping));
        }
예제 #7
0
 /// <summary>
 ///     <para>Initializes an instance of the <see cref="TcpAdapterEndPoint"/> class.</para>
 /// </summary>
 /// <param name="adapter">
 /// The adapter which owns the endpoint.
 /// </param>
 /// <param name="socket">
 /// The underlying <see cref="Socket"/> object.
 /// </param>
 public TcpAdapterEndPoint(AdapterBase adapter, Socket socket)
     : base(adapter, new UriBuilder("tcp", ((IPEndPoint)socket.RemoteEndPoint).Address.ToString(),
                                    ((IPEndPoint)socket.RemoteEndPoint).Port).Uri)
 {
     this.socket  = socket;
     this.timeout = DateTime.MaxValue;
 }
예제 #8
0
        /// <summary>
        /// Parses source definitions for an annotation query.
        /// </summary>
        /// <param name="annotation">Grafana annotation.</param>
        /// <param name="type">Annotation type.</param>
        /// <param name="source">Metadata of source definitions.</param>
        /// <param name="useFilterExpression">Determines if query is using a filter expression.</param>
        /// <returns>Parsed source definitions from <paramref name="annotation"/>.</returns>
        public static Dictionary <string, DataRow> ParseSourceDefinitions(this Annotation annotation, AnnotationType type, DataSet source, bool useFilterExpression)
        {
            if ((object)annotation == null)
            {
                throw new ArgumentNullException(nameof(annotation));
            }

            if ((object)source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }

            if (type == AnnotationType.Undefined)
            {
                throw new InvalidOperationException("Unrecognized type or syntax for annotation query expression.");
            }

            string query = annotation.query ?? "";

            return(TargetCache <Dictionary <string, DataRow> > .GetOrAdd(query, () =>
            {
                DataRow[] rows;

                if (useFilterExpression)
                {
                    string tableName, expression, sortField;
                    int takeCount;

                    if (AdapterBase.ParseFilterExpression(query, out tableName, out expression, out sortField, out takeCount))
                    {
                        rows = source.Tables[tableName.Translate()].Select(expression, sortField).Take(takeCount).ToArray();
                    }
                    else
                    {
                        throw new InvalidOperationException("Invalid FILTER syntax for annotation query expression.");
                    }
                }
                else
                {
                    // Assume all records if no filter expression was provided
                    rows = source.Tables[type.TableName().Translate()].Rows.Cast <DataRow>().ToArray();
                }

                Dictionary <string, DataRow> definitions = new Dictionary <string, DataRow>(StringComparer.OrdinalIgnoreCase);

                foreach (DataRow row in rows)
                {
                    MeasurementKey key = GetTargetFromGuid(row[type.TargetFieldName()].ToString());

                    if (key != MeasurementKey.Undefined)
                    {
                        definitions[key.TagFromKey(source)] = row;
                    }
                }

                return definitions;
            }));
        }
예제 #9
0
        /// <inheritdoc/>
        public virtual TAdapter GetAdapter <TAdapter>() where TAdapter : IAdapter, new()
        {
            if (Factory is IAdapterCreation adapterCreation)
            {
                return(adapterCreation.GetAdapter <TAdapter>());
            }

            return(AdapterBase.Create <TAdapter>(Factory));
        }
예제 #10
0
파일: MainForm.cs 프로젝트: lyrain2009/gsf
        private void AssignOutputMeasurements(Dictionary <string, string> settings)
        {
            MeasurementKey[] outputMeasurementKeys = settings.TryGetValue("outputMeasurements", out string setting) ?
                                                     AdapterBase.ParseOutputMeasurements(m_dataSource, false, setting).MeasurementKeys() :
                                                     Array.Empty <MeasurementKey>();

            m_outputSignalIDs = outputMeasurementKeys.Select(k => k.SignalID).ToArray();
            LoadMeasurements(m_outputSignalIDs, dataGridViewOutputMeasurements, groupBoxOutputMeasurements);
        }
예제 #11
0
        /// <summary>
        /// Initializes <see cref="SynchronizedClientSubscription"/>.
        /// </summary>
        public override void Initialize()
        {
            MeasurementKey[] inputMeasurementKeys;
            string           setting;

            if (Settings.TryGetValue("inputMeasurementKeys", out setting))
            {
                // IMPORTANT: The allowSelect argument of ParseInputMeasurementKeys must be null
                //            in order to prevent SQL injection via the subscription filter expression
                inputMeasurementKeys   = AdapterBase.ParseInputMeasurementKeys(DataSource, false, setting);
                m_requestedInputFilter = setting;

                // IMPORTANT: We need to remove the setting before calling base.Initialize()
                //            or else we will still be subject to SQL injection
                Settings.Remove("inputMeasurementKeys");
            }
            else
            {
                inputMeasurementKeys   = new MeasurementKey[0];
                m_requestedInputFilter = null;
            }

            base.Initialize();

            // Set the InputMeasurementKeys and UsePrecisionTimer properties after calling
            // base.Initialize() so that the base class does not overwrite our settings
            InputMeasurementKeys = inputMeasurementKeys;
            UsePrecisionTimer    = false;

            if (Settings.TryGetValue("bufferBlockRetransmissionTimeout", out setting))
            {
                m_bufferBlockRetransmissionTimeout = double.Parse(setting);
            }
            else
            {
                m_bufferBlockRetransmissionTimeout = 5.0D;
            }

            if (Settings.TryGetValue("requestNaNValueFilter", out setting))
            {
                m_isNaNFiltered = m_parent.AllowNaNValueFilter && setting.ParseBoolean();
            }
            else
            {
                m_isNaNFiltered = false;
            }

            m_bufferBlockRetransmissionTimer           = Common.TimerScheduler.CreateTimer((int)(m_bufferBlockRetransmissionTimeout * 1000.0D));
            m_bufferBlockRetransmissionTimer.AutoReset = false;
            m_bufferBlockRetransmissionTimer.Elapsed  += BufferBlockRetransmissionTimer_Elapsed;

            // Handle temporal session initialization
            if (this.TemporalConstraintIsDefined())
            {
                m_iaonSession = this.CreateTemporalSession();
            }
        }
예제 #12
0
        public IMeasurement[] GetMeasurements(string filterExpression)
        {
            MeasurementKey[] keys        = AdapterBase.ParseInputMeasurementKeys(m_dataSource, false, filterExpression);
            IMeasurement     measurement = null;

            return(keys
                   .Where(key => m_measurementLookup.TryGetValue(key, out measurement))
                   .Select(key => measurement)
                   .ToArray());
        }
예제 #13
0
 public void CreateAdapterTestCase()
 {
     GivenCreateFactory()
     .When("create adapter", _ => AdapterBase.Create <Adapter>(Factory))
     .Then("Check result", adapter =>
     {
         Assert.IsNotNull(adapter, "adapter cannot be null");
     })
     .Run();
 }
예제 #14
0
 public void BindFactoryTestCase()
 {
     GivenCreateFactory()
     .When("create adapter", _ => AdapterBase.Create <Adapter>(Factory))
     .Then("Check result", adapter =>
     {
         adapter.AssertFactory(Factory);
     })
     .Run();
 }
예제 #15
0
        static void Main(string[] args)
        {
            var target = new Adapter();
            target.Request();

            var targetbase = new AdapterBase();
            targetbase.Request();

            Console.ReadLine();
        }
예제 #16
0
        public FolderBrowserViewModel(AdapterBase syncAdapter)
        {
            Pre.ThrowIfArgumentNull(syncAdapter, "syncAdapter");

            this.CloseWindowCommand = new DelegatedCommand(o => this.HandleClose(false));
            this.CancelCommand      = new DelegatedCommand(o => this.HandleClose(false));
            this.OKCommand          = new DelegatedCommand(o => this.HandleClose(true), this.CanOkCommandExecute);

            this.syncAdapter = syncAdapter;
        }
예제 #17
0
        private void Subscribe()
        {
            if (m_selectedMeasurements.Count == 0)
            {
                Unsubscribe();
            }
            else
            {
                if (m_subscriber == null)
                {
                    InitializeSubscription();
                }
                else
                {
                    if (m_subscribedSynchronized && !string.IsNullOrEmpty(m_selectedSignalIDs))
                    {
                        m_subscriber.Unsubscribe();

                        if (m_historicalPlayback)
                        {
                            Dispatcher.BeginInvoke(new Action(delegate
                            {
                                string startTime       = TextBoxStartTime.Text;
                                string stopTime        = TextBoxStopTime.Text;
                                int processingInterval = int.Parse(TextBoxProcessInterval.Text);

                                if (DateTime.Compare(AdapterBase.ParseTimeTag(startTime),
                                                     AdapterBase.ParseTimeTag(stopTime)) < 0)
                                {
                                    ModeMessage.Text = "Initializing historical playback...";

                                    //m_synchronizedSubscriber.SynchronizedSubscribe(true, m_framesPerSecond, m_lagTime, m_leadTime, m_selectedSignalIDs, null, m_useLocalClockAsRealtime, m_ignoreBadTimestamps, startTime: TextBoxStartTime.Text, stopTime: TextBoxStopTime.Text, processingInterval: (int)SliderProcessInterval.Value);
                                    m_subscriber.UnsynchronizedSubscribe(true, false, m_selectedSignalIDs, null, true,
                                                                         m_lagTime, m_leadTime,
                                                                         m_useLocalClockAsRealtime, startTime, stopTime,
                                                                         null, processingInterval);
                                    m_waitingForData = true;
                                }
                                else
                                {
                                    MessageBox.Show("Start time must precede end time");
                                }
                            }));
                        }
                        else
                        {
                            //m_synchronizedSubscriber.SynchronizedSubscribe(true, m_framesPerSecond, m_lagTime, m_leadTime, m_selectedSignalIDs, null, m_useLocalClockAsRealtime, m_ignoreBadTimestamps);
                            m_subscriber.UnsynchronizedSubscribe(true, false, m_selectedSignalIDs, null, true, m_lagTime, m_leadTime, m_useLocalClockAsRealtime);
                        }
                    }

                    ChartPlotterDynamic.Dispatcher.BeginInvoke((Action)StartRefreshTimer);
                }
            }
        }
예제 #18
0
        /// <summary>
        /// Parses query expression from annotation for annotation type.
        /// </summary>
        /// <param name="annotation">Grafana annotation.</param>
        /// <param name="useFilterExpression">Determines if query is using a filter expression.</param>
        /// <returns>Parsed annotation type for query expression from <paramref name="annotation"/>.</returns>
        public static AnnotationType ParseQueryType(this Annotation annotation, out bool useFilterExpression)
        {
            if ((object)annotation == null)
            {
                throw new ArgumentNullException(nameof(annotation));
            }

            string query = annotation.query ?? "";

            Tuple <AnnotationType, bool> result = TargetCache <Tuple <AnnotationType, bool> > .GetOrAdd(query, () =>
            {
                AnnotationType type = AnnotationType.Undefined;
                string tableName, expression, sortField;
                int takeCount;
                bool parsedFilterExpression = false;

                if (AdapterBase.ParseFilterExpression(query, out tableName, out expression, out sortField, out takeCount))
                {
                    parsedFilterExpression = true;

                    switch (tableName.ToUpperInvariant())
                    {
                    case "RAISEDALARMS":
                        type = AnnotationType.RaisedAlarms;
                        break;

                    case "CLEAREDALARMS":
                        type = AnnotationType.ClearedAlarms;
                        break;

                    default:
                        throw new InvalidOperationException("Invalid FILTER table for annotation query expression.");
                    }
                }
                else if (query.StartsWith("#RaisedAlarms", StringComparison.OrdinalIgnoreCase))
                {
                    type = AnnotationType.RaisedAlarms;
                }
                else if (query.StartsWith("#ClearedAlarms", StringComparison.OrdinalIgnoreCase))
                {
                    type = AnnotationType.ClearedAlarms;
                }

                if (type == AnnotationType.Undefined)
                {
                    throw new InvalidOperationException("Unrecognized type or syntax for annotation query expression.");
                }

                return(new Tuple <AnnotationType, bool>(type, parsedFilterExpression));
            });

            useFilterExpression = result.Item2;

            return(result.Item1);
        }
예제 #19
0
        private static void Main(string[] args)
        {
            string      codeBase   = Assembly.GetExecutingAssembly().CodeBase;
            UriBuilder  uri        = new UriBuilder(codeBase);
            string      path       = Uri.UnescapeDataString(uri.Path);
            string      dir        = Path.GetDirectoryName(path);
            string      pathToLoad = Path.Combine(dir, "MyCustomFolder");
            AdapterBase adapter    = LoadAdapterFromPath(pathToLoad);

            adapter.PrintHello();
        }
예제 #20
0
 public void CreateProxyTestCase()
 {
     GivenCreateFactory()
     .And("Create adapter", factory => AdapterBase.Create <AdapterProxy>(factory))
     .When("Create proxy", adapter => adapter.CreateProxy())
     .Then("Check result", proxy =>
     {
         Assert.IsNotNull(proxy, "proxy cannot be null");
     })
     .Run();
 }
예제 #21
0
 public void CreateAdapterParamWithoutFuncTestCase()
 {
     GivenCreateFactory()
     .When("Create adapter", factory => ExpectedException <Exception>(() => AdapterBase.Create <InvalidAdapterProxyParameter>(factory)))
     .Then("Check result", ex =>
     {
         Assert.IsNotNull(ex, "error cannot be null");
         Assert.AreEqual("createProxyFuncWithParam", ((ArgumentNullException)ex.InnerException).ParamName, "expected another message");
     })
     .Run();
 }
예제 #22
0
 public GoogleDriveAdapterItem(Item item, IAdapterItem parent, AdapterBase adapter)
     : base(
         item.Name,
         parent,
         adapter,
         GetItemType(item),
         item.Id,
         item.Size,
         item.CreatedTime,
         item.ModifiedTime)
 {
     this.Item = item;
 }
예제 #23
0
 internal OneDriveAdapterItem(Drive drive, AdapterBase adapter)
     : base(
         DefaultDriveName,
         null,
         adapter,
         SyncAdapterItemType.Directory,
         drive.Id,
         0,
         DateTime.MinValue,
         DateTime.MinValue)
 {
     this.Drive = drive;
 }
예제 #24
0
        public void CreateProxyWithParamTestCase()
        {
            var param = new object();

            GivenCreateFactory()
            .And("Create adapter", factory => AdapterBase.Create <AdapterProxyParameter>(factory))
            .When("Create proxy", adapter => adapter.CreateProxy(param))
            .Then("Check result", proxy =>
            {
                Assert.IsNotNull(proxy, "proxy cannot be null");
                Assert.AreEqual(param, proxy.Param, "expected another value parameter");
            })
            .Run();
        }
예제 #25
0
        public EntryUpdateInfo(SyncEntry entry, AdapterBase originatingAdapter, SyncEntryChangedFlags flags, string relativePath)
        {
            Pre.ThrowIfArgumentNull(entry, "entry");
            Pre.ThrowIfArgumentNull(originatingAdapter, "originatingAdapter");

            this.Entry = entry;
            this.OriginatingAdapter = originatingAdapter;
            this.Flags        = flags;
            this.RelativePath = relativePath;

            if (flags != SyncEntryChangedFlags.None)
            {
                this.State = EntryUpdateState.NotStarted;
            }
        }
예제 #26
0
        /// <summary>
        /// Raises the <see cref="StatusMessage"/> event and sends this data to the <see cref="Logger"/>.
        /// </summary>
        /// <param name="level">The <see cref="MessageLevel"/> to assign to this message</param>
        /// <param name="status">New status message.</param>
        /// <param name="eventName">A fixed string to classify this event; defaults to <c>null</c>.</param>
        /// <param name="flags"><see cref="MessageFlags"/> to use, if any; defaults to <see cref="MessageFlags.None"/>.</param>
        /// <remarks>
        /// <see pref="eventName"/> should be a constant string value associated with what type of message is being
        /// generated. In general, there should only be a few dozen distinct event names per class. Exceeding this
        /// threshold will cause the EventName to be replaced with a general warning that a usage issue has occurred.
        /// </remarks>
        protected virtual void OnStatusMessage(MessageLevel level, string status, string eventName = null, MessageFlags flags = MessageFlags.None)
        {
            try
            {
                Log.Publish(level, flags, eventName ?? "DataGapRecovery", status);

                using (Logger.SuppressLogMessages())
                    StatusMessage?.Invoke(this, new EventArgs <string>(AdapterBase.GetStatusWithMessageLevelPrefix(status, level)));
            }
            catch (Exception ex)
            {
                // We protect our code from consumer thrown exceptions
                OnProcessException(MessageLevel.Info, new InvalidOperationException($"Exception in consumer handler for StatusMessage event: {ex.Message}", ex), "ConsumerEventException");
            }
        }
예제 #27
0
        public async Task CommitTrackedChangesAsync(SyncRelationship relationship)
        {
            foreach (KeyValuePair <int, AnalyzeAdapterResult> adapterResult in AdapterResults)
            {
                if (adapterResult.Value.TrackedChanges != null)
                {
                    AdapterBase adapterBase =
                        relationship.Adapters.First(a => a.Configuration.Id == adapterResult.Key);

                    Logger.Info("Committing tracked change for adapter {0}", adapterBase.Configuration.Id);

                    IChangeTracking changeTracking = (IChangeTracking)adapterBase;
                    await changeTracking.CommitChangesAsync(adapterResult.Value.TrackedChanges).ConfigureAwait(false);
                }
            }
        }
예제 #28
0
        public MeasurementKey GetMeasurementKey(string filterExpression)
        {
            MeasurementKey[] keys = AdapterBase.ParseInputMeasurementKeys(m_dataSource, false, filterExpression);

            if (keys.Length > 1)
            {
                throw new InvalidOperationException($"Ambiguous filter returned {keys.Length} measurement keys: {filterExpression}.");
            }

            if (keys.Length == 0)
            {
                return(MeasurementKey.Undefined);
            }

            return(keys[0]);
        }
예제 #29
0
        public sealed override void LoadContext()
        {
            AdapterBase sourceAdapter      = this.BaseModel.Adapters.First(a => a.Configuration.Id == this.BaseModel.Configuration.SourceAdapterId);
            AdapterBase destinationAdapter = this.BaseModel.Adapters.First(a => a.Configuration.Id == this.BaseModel.Configuration.DestinationAdapterId);

            this.SyncSourceAdapter      = SyncTargetViewModelFactory.FromAdapter(sourceAdapter);
            this.SyncDestinationAdapter = SyncTargetViewModelFactory.FromAdapter(destinationAdapter);

            foreach (SyncJob job in this.BaseModel.GetSyncJobHistory())
            {
                App.Current.Dispatcher.Invoke(() =>
                {
                    this.SyncJobHistory.Insert(0, new SyncJobViewModel(job, this, true));
                });
            }
        }
예제 #30
0
 public ApplicationAdapterEndPoint(AdapterBase adapter, string applicationName, string sessionId)
     : base(adapter, new UriBuilder("app", sessionId).Uri)
 {
     _config                    = ConfigurationManager.GetSection(MessagingSection.SectionKey) as MessagingSection;
     _sessionId                 = sessionId;
     _applicationName           = applicationName;
     _mutex                     = new Mutex(false, string.Format("IMI_MOBILE_MUTEX_{0}", _sessionId));
     _memoryMappedFile          = MemoryMappedFile.CreateOrOpen(string.Format("IMI_MOBILE_QUEUE_{0}", _sessionId), MemoryMappedFileSize);
     _stream                    = _memoryMappedFile.CreateViewStream(0, 0, MemoryMappedFileAccess.ReadWrite);
     _serverNotifyEvent         = new EventWaitHandle(false, EventResetMode.AutoReset, string.Format("IMI_MOBILE_SERVER_NOTIFY_{0}", _sessionId));
     _serverReceivedNotifyEvent = new EventWaitHandle(false, EventResetMode.AutoReset, string.Format("IMI_MOBILE_SERVER_RECEIVED_NOTIFY_{0}", _sessionId));
     _clientNotifyEvent         = new EventWaitHandle(false, EventResetMode.AutoReset, string.Format("IMI_MOBILE_CLIENT_NOTIFY_{0}", _sessionId));
     _clientReceivedNotifyEvent = new EventWaitHandle(false, EventResetMode.AutoReset, string.Format("IMI_MOBILE_CLIENT_RECEIVED_NOTIFY_{0}", _sessionId));
     _clientProcessedEvent      = new EventWaitHandle(false, EventResetMode.ManualReset, string.Format("IMI_MOBILE_CLIENT_PROCESSED_NOTIFY_{0}", _sessionId));
     _abortEvent                = new EventWaitHandle(false, EventResetMode.ManualReset);
 }
예제 #31
0
        public virtual void RefreshMetadata()
        {
            // Force a recalculation of input measurement keys so that system can appropriately update routing tables
            string setting;

            if (Settings.TryGetValue("inputMeasurementKeys", out setting))
            {
                InputMeasurementKeys = AdapterBase.ParseInputMeasurementKeys(DataSource, setting);
            }
            else
            {
                InputMeasurementKeys = null;
            }

            InputSourceIDs = InputSourceIDs;
        }