Exemplo n.º 1
0
        public static string GetFileOrFolderBasedUserFriendlyConnectionName(IConnectionParams cp)
        {
            string displayName = cp[ConnectionParamsKeys.DisplayNameConnectionParam];

            if (!string.IsNullOrEmpty(displayName))
            {
                return(displayName);
            }
            string rotatedLogFolder = cp[ConnectionParamsKeys.RotatedLogFolderPathConnectionParam];

            if (!string.IsNullOrEmpty(rotatedLogFolder))
            {
                var patterns = string.Join(";", GetRotatedLogPatterns(cp));
                if (patterns != "")
                {
                    patterns = $" ({patterns})";
                }
                return(rotatedLogFolder + patterns);
            }
            string id = cp[ConnectionParamsKeys.IdentityConnectionParam];

            if (!string.IsNullOrEmpty(id))
            {
                return(id);
            }
            return(cp[ConnectionParamsKeys.PathConnectionParam] ?? "");
        }
Exemplo n.º 2
0
        IConnectionParams ILogProviderFactory.GetConnectionParamsToBeStoredInMRUList(IConnectionParams originalConnectionParams)
        {
            var ret = new ConnectionParams();

            ret[ConnectionParamsUtils.IdentityConnectionParam] = connectionIdentity;
            return(ret);
        }
Exemplo n.º 3
0
        private async void ReadAll(
            ILogProviderFactory factory,
            IConnectionParams connectParams)
        {
            try
            {
                provider = factory.CreateFromConnectionParams(this, connectParams);

                var messages = new List <IMessage>();
                await this.provider.EnumMessages(
                    0, m =>
                {
                    messages.Add(m);
                    return(true);
                },
                    EnumMessagesFlag.Forward,
                    LogProviderCommandPriority.RealtimeUserAction,
                    CancellationToken.None
                    );

                model.SetMessages(messages);
                await logPresenter.GoHome();

                UpdateStatusControls(messages.Count, null);
            }
            catch (Exception e)
            {
                UpdateStatusControls(0, e);
            }
        }
Exemplo n.º 4
0
        public LogSource(ILogSourcesManagerInternal owner, int id,
                         ILogProviderFactory providerFactory, IConnectionParams connectionParams,
                         IModelThreads threads, ITempFilesManager tempFilesManager, Persistence.IStorageManager storageManager,
                         IInvokeSynchronization invoker, Settings.IGlobalSettingsAccessor globalSettingsAccess, IBookmarks bookmarks)
        {
            this.owner                = owner;
            this.tracer               = new LJTraceSource("LogSource", string.Format("ls{0:D2}", id));
            this.tempFilesManager     = tempFilesManager;
            this.invoker              = invoker;
            this.globalSettingsAccess = globalSettingsAccess;
            this.bookmarks            = bookmarks;

            try
            {
                this.logSourceThreads              = new LogSourceThreads(this.tracer, threads, this);
                this.timeGaps                      = new TimeGapsDetector(tracer, invoker, new LogSourceGapsSource(this));
                this.timeGaps.OnTimeGapsChanged   += timeGaps_OnTimeGapsChanged;
                this.logSourceSpecificStorageEntry = CreateLogSourceSpecificStorageEntry(providerFactory, connectionParams, storageManager);

                var extendedConnectionParams = connectionParams.Clone(true);
                this.LoadPersistedSettings(extendedConnectionParams);
                this.provider = providerFactory.CreateFromConnectionParams(this, extendedConnectionParams);
            }
            catch (Exception e)
            {
                tracer.Error(e, "Failed to initialize log source");
                ((ILogSource)this).Dispose();
                throw;
            }

            this.owner.Container.Add(this);
            this.owner.FireOnLogSourceAdded(this);

            this.LoadBookmarks();
        }
Exemplo n.º 5
0
        public SimpleFileMedia(IFileSystem fileSystem, IConnectionParams connectParams)
        {
            if (fileSystem == null)
            {
                throw new ArgumentNullException("fileSystem");
            }

            this.fileSystem = fileSystem;
            this.fileName   = connectParams[fileNameParam];
            if (string.IsNullOrEmpty(fileName))
            {
                throw new ArgumentException("Invalid or incomplete connection params");
            }

            try
            {
                Stream fs = fileSystem.OpenFile(fileName);
                this.stream.SetStream(fs, true);
                this.fsInfo = (IFileStreamInfo)fs;
                Update();
            }
            catch (Exception)
            {
                Dispose();
                throw;
            }
        }
Exemplo n.º 6
0
 static IEnumerable <LoadedPreprocessingStep> LoadStepsFromConnectionParams(IConnectionParams connectParams)
 {
     for (int stepIdx = 0; ; ++stepIdx)
     {
         string stepStr = connectParams[string.Format("{0}{1}", ConnectionParamsUtils.PreprocessingStepParamPrefix, stepIdx)];
         if (stepStr == null)
         {
             break;
         }
         stepStr = stepStr.Trim();
         if (stepStr.Length == 0)
         {
             break;
         }
         int idx = stepStr.IndexOf(' ');
         if (idx == -1)
         {
             yield return(new LoadedPreprocessingStep(stepStr, ""));
         }
         else
         {
             yield return(new LoadedPreprocessingStep(stepStr.Substring(0, idx), stepStr.Substring(idx + 1)));
         }
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Отправить устройству параметры для подключения к роутеру
        /// </summary>
        /// <param name="connectionParams"></param>
        /// <returns></returns>
        public async Task <bool> SendConnectionParamsToDeviceAsAP(IConnectionParams connectionParams)
        {
            return(await Task.Run(async() =>
            {
                List <CommandParameter> content = new List <CommandParameter>
                {
                    new CommandParameter("ssid", connectionParams.Ssid),
                    new CommandParameter("password", connectionParams.Password)
                };

                //TODO: изменить на устройстве код приёма параметров подключения
                Communicator communicator = new Communicator();
                OperationResult result = await communicator.SendToDevice(_ip, CommandNames.ConnectionParams, content);

                if (!result.Success)
                {
                    ConnectorByWiFi connector = new ConnectorByWiFi();
                    WiFiAdapter wiFiAdapter = await connector.GetWiFiAdapter();
                    if (wiFiAdapter.NetworkAdapter.NetworkItem.GetNetworkTypes() == Windows.Networking.Connectivity.NetworkTypes.None)
                    {
                        result.Success = await connector.Reconnect();
                    }
                }

                return result.Success;
            }));
        }
Exemplo n.º 8
0
 internal MSSQLConnection(IConnectionParams @params, bool connect = true) : this()
 {
     if (connect)
     {
         Connect(@params);
     }
 }
Exemplo n.º 9
0
        string IManager.ExtractUserBrowsableFileLocationFromConnectionParams(IConnectionParams connectParams)
        {
            var    steps       = LoadStepsFromConnectionParams(connectParams).ToArray();
            var    stepObjects = steps.Select(s => CreateStepByName(s.StepName, null));
            var    getStep     = stepObjects.FirstOrDefault() as IGetPreprocessingStep;
            string fileName    = null;

            if (getStep != null)
            {
                var secondStep = stepObjects.Skip(1).FirstOrDefault();
                if (secondStep == null || secondStep is IUnpackPreprocessingStep)
                {
                    fileName = steps[0].Argument;
                }
            }
            else
            {
                fileName = connectParams[ConnectionParamsKeys.PathConnectionParam];
            }
            if (!string.IsNullOrEmpty(fileName) && !tempFilesManager.IsTemporaryFile(fileName))
            {
                return(fileName);
            }
            return(null);
        }
Exemplo n.º 10
0
 public static void ValidateConnectionParams(IConnectionParams cp, ILogProviderFactory againstFactory)
 {
     if (GetConnectionIdentity(cp) == null)
     {
         throw new InvalidConnectionParamsException("no connection identity in connectino params");
     }
 }
Exemplo n.º 11
0
 public LogProvider(ILogProviderHost host, IConnectionParams connectParams, ILogProviderFactory factory)
     :
     base(host, factory, connectParams)
 {
     this.fileName = connectParams[ConnectionParamsKeys.PathConnectionParam];
     StartLiveLogThread(string.Format("'{0}' listening thread", fileName));
 }
Exemplo n.º 12
0
        public AzureConnectionParams(IConnectionParams connectParams)
        {
            Account = new StorageAccount(connectParams);

            var fmtProv = CultureInfo.InvariantCulture.DateTimeFormat;
            Func <string, DateTime> parseDate     = str => DateTime.ParseExact(str, ConnectionParamsConsts.DateConnectionParamFormat, fmtProv);
            Func <string, TimeSpan> parseTimeSpan = str => TimeSpan.ParseExact(str, ConnectionParamsConsts.TimespanConnectionParamFormat, fmtProv);

            var fromStr   = connectParams[ConnectionParamsConsts.FromConnectionParam];
            var tillStr   = connectParams[ConnectionParamsConsts.TillConnectionParam];
            var periodStr = connectParams[ConnectionParamsConsts.RecentConnectionParam];
            var liveStr   = connectParams[ConnectionParamsConsts.LiveConnectionParam];

            if (fromStr != null)
            {
                Mode = LoadMode.FixedRange;
                From = parseDate(fromStr);
                Till = parseDate(tillStr);
            }
            else if (periodStr != null)
            {
                Mode   = LoadMode.Recent;
                Period = parseTimeSpan(periodStr);
                bool live;
                bool.TryParse(connectParams[ConnectionParamsConsts.LiveConnectionParam] ?? "", out live);
                Live = live;
            }
            else
            {
                throw new InvalidConnectionParamsException("Bad connection params for Azure log provider");
            }
        }
Exemplo n.º 13
0
        void ApplyRotatedLogMode()
        {
            var folder = ((string)view.ReadControlValue(ControlId.FolderSelector)).Trim();

            if (folder == "")
            {
                return;
            }
            if (!System.IO.Directory.Exists(folder))
            {
                alerts.ShowPopup("Error", "Specified folder does not exist", AlertFlags.Ok | AlertFlags.WarningIcon);
                return;
            }

            view.WriteControlValue(ControlId.FolderSelector, "");

            folder = folder.TrimEnd('\\');

            IConnectionParams connectParams = factory.CreateRotatedLogParams(folder);

            try
            {
                model.Create(factory, connectParams);
            }
            catch (Exception e)
            {
                alerts.ShowPopup("Error", e.Message, AlertFlags.Ok | AlertFlags.WarningIcon);
            }
        }
Exemplo n.º 14
0
        void InitPathDependentMembers(IConnectionParams connectParams)
        {
            isSavableAs     = false;
            taskbarFileName = null;
            bool   isTempFile      = false;
            string guessedFileName = null;

            string fname = connectParams[ConnectionParamsKeys.PathConnectionParam];

            if (fname != null)
            {
                isTempFile  = host.TempFilesManager.IsTemporaryFile(fname);
                isSavableAs = isTempFile;
            }
            string connectionIdentity = connectParams[ConnectionParamsKeys.IdentityConnectionParam];

            if (connectionIdentity != null)
            {
                guessedFileName = ConnectionParamsUtils.GuessFileNameFromConnectionIdentity(connectionIdentity);
            }
            if (isSavableAs)
            {
                suggestedSaveAsFileName = SanitizeSuggestedFileName(guessedFileName);
            }
            taskbarFileName = guessedFileName;
        }
        void ApplyRotatedLogMode()
        {
            var folder = ((string)view.ReadControlValue(ControlId.FolderSelector)).Trim();

            if (folder == "")
            {
                return;
            }
            if (!System.IO.Directory.Exists(folder))
            {
                alerts.ShowPopup("Error", "Specified folder does not exist", AlertFlags.Ok | AlertFlags.WarningIcon);
                return;
            }

            view.WriteControlValue(ControlId.FolderSelector, "");

            folder = folder.TrimEnd(System.IO.Path.DirectorySeparatorChar);

            var patters = (string)view.ReadControlValue(ControlId.PatternsSelector);

            IConnectionParams connectParams = factory.CreateRotatedLogParams(folder,
                                                                             patters.Split(';').Where(s => !string.IsNullOrWhiteSpace(s)));

            try
            {
                model.Create(factory, connectParams);
            }
            catch (Exception e)
            {
                alerts.ShowPopup("Error", e.Message, AlertFlags.Ok | AlertFlags.WarningIcon);
            }
        }
Exemplo n.º 16
0
        public IConnectionParams GetConnectionParamsToBeStoredInMRUList(IConnectionParams originalConnectionParams)
        {
            var ret = new ConnectionParams();

            ret[ConnectionParamsUtils.IdentityConnectionParam] = connectionIdentity;
            return(ret);
        }
Exemplo n.º 17
0
 public YieldedProvider(ILogProviderFactory factory, IConnectionParams connectionParams, string displayName, bool isHiddenLog)
 {
     Factory          = factory;
     ConnectionParams = connectionParams;
     DisplayName      = displayName;
     IsHiddenLog      = isHiddenLog;
 }
Exemplo n.º 18
0
        bool IPresenter.ShowDialog(ILogProviderFactory sampleLogFactory, IConnectionParams sampleLogConnectionParams)
        {
            ReadAll(sampleLogFactory, sampleLogConnectionParams);

            view.Show();
            return(statusOk);
        }
Exemplo n.º 19
0
        IConnectionParams IManager.AppendStep(
            IConnectionParams connectParams, string stepName, string stepArgument)
        {
            var steps = LoadStepsFromConnectionParams(connectParams).ToList();

            if (steps.Count == 0)
            {
                var path = connectParams[ConnectionParamsKeys.PathConnectionParam];
                if (path == null)
                {
                    return(null);
                }
                steps.Add(new PreprocessingHistoryItem(GetPreprocessingStep.name, path));
            }
            steps.Add(new PreprocessingHistoryItem(stepName, stepArgument));
            var retVal  = connectParams.Clone(makeWritebleCopyIfReadonly: true);
            int stepIdx = 0;

            foreach (var step in steps)
            {
                retVal[string.Format("{0}{1}", ConnectionParamsKeys.PreprocessingStepParamPrefix, stepIdx)] =
                    string.Format(string.IsNullOrEmpty(step.Argument) ? "{0}" : "{0} {1}", step.StepName, step.Argument);
                ++stepIdx;
            }
            return(retVal);
        }
Exemplo n.º 20
0
 public ConnectionParamsReadOnlyView(IConnectionParams underlyingParams)
 {
     if (underlyingParams == null)
     {
         throw new ArgumentNullException("underlyingParams");
     }
     this.underlyingParams = underlyingParams;
 }
Exemplo n.º 21
0
 public static IConnectionParams RemoveInitialTimeOffset(IConnectionParams cp)
 {
     if (!string.IsNullOrEmpty(cp[TimeOffsetConnectionParam]))
     {
         cp[TimeOffsetConnectionParam] = null;
     }
     return(cp);
 }
Exemplo n.º 22
0
        readonly long defaultBackupMaxFileSize = 0;        //16 * 1024 * 1024;

        static ConnectionParams CreateConnectionParams(IConnectionParams originalConnectionParams, ITempFilesManager tempFilesManager)
        {
            ConnectionParams connectParams = new ConnectionParams();

            connectParams.AssignFrom(originalConnectionParams);
            connectParams[ConnectionParamsUtils.PathConnectionParam] = tempFilesManager.CreateEmptyFile();
            return(connectParams);
        }
Exemplo n.º 23
0
        ILogSource CreateLogSourceInternal(ILogProviderFactory factory, IConnectionParams cp, bool makeHidden)
        {
            ILogSource src = logSources.FindLiveLogSourceOrCreateNew(factory, cp);

            src.Visible = !makeHidden;
            mruLogsList.RegisterRecentLogEntry(src.Provider, src.Annotation);
            return(src);
        }
Exemplo n.º 24
0
        IConnectionParams ILogProviderFactory.GetConnectionParamsToBeStoredInMRUList(IConnectionParams originalConnectionParams)
        {
            var cp = originalConnectionParams.Clone(true);

            cp[ConnectionParamsKeys.PathConnectionParam] = null;
            ConnectionParamsUtils.RemoveInitialTimeOffset(cp);
            return(cp);
        }
Exemplo n.º 25
0
 private SimpleFileMedia(IFileSystem fileSystem, IConnectionParams connectParams)
 {
     this.fileSystem = fileSystem ?? throw new ArgumentNullException("fileSystem");
     this.fileName   = connectParams[fileNameParam];
     if (string.IsNullOrEmpty(fileName))
     {
         throw new ArgumentException("Invalid or incomplete connection params");
     }
 }
Exemplo n.º 26
0
 ILogSource ILogSourcesManager.Create(ILogProviderFactory providerFactory, IConnectionParams cp)
 {
     return(logSourceFactory.CreateLogSource(
                this,
                ++lastLogSourceId,
                providerFactory,
                cp
                ));
 }
Exemplo n.º 27
0
        public static string GetConnectionIdentity(IConnectionParams cp)
        {
            var ret = cp[IdentityConnectionParam];

            if (string.IsNullOrWhiteSpace(ret))
            {
                return(null);
            }
            return(ret);
        }
Exemplo n.º 28
0
        public bool AreEqual(IConnectionParams other)
        {
            SemicolonSeparatedMap map = other as SemicolonSeparatedMap;

            if (map == null)
            {
                return(false);
            }
            return(base.AreEqual(map));
        }
Exemplo n.º 29
0
        public static bool ConnectionsHaveEqualIdentities(IConnectionParams cp1, IConnectionParams cp2)
        {
            var id1 = GetConnectionIdentity(cp1);
            var id2 = GetConnectionIdentity(cp2);

            if (id1 == null || id2 == null)
            {
                return(false);
            }
            return(id1 == id2);
        }
Exemplo n.º 30
0
 public RollingStrategy(LJTraceSource trace, IConnectionParams connectionParams)
 {
     baseFileName = connectionParams[fileNameParam];
     if (string.IsNullOrEmpty(baseFileName))
     {
         throw new ArgumentException("Base file name is not specified in the connection params");
     }
     baseFileNameFirstChar = GetFileNameFirstChar(baseFileName);
     baseDirectory         = Path.GetDirectoryName(baseFileName);
     trace.Info("Base file name first character: {0}", baseFileNameFirstChar);
 }