Пример #1
0
        public SongGridViewModel(IRegionManager regionManager, IDialogService dialogService)
        {
            _regionManager = regionManager;
            _dialogService = dialogService;
            log            = (ServiceLocator.Current.GetInstance(typeof(ILogger)) as ILogger)?.GetLogger;
            log.Trace(">>>");
            _options = (ServiceLocator.Current.GetInstance(typeof(ISettingsManager)) as ISettingsManager)?.GetOptions;

            // Load the Settings
            _gridColumns = new SongGridViewColumns();
            CreateColumns();

            _songs = new BindingList <SongData>();
            ItemsSourceDataCommand            = new BaseCommand(SetItemsSource);
            SelectionChangedCommand           = new BaseCommand(SelectionChanged);
            ContextMenuCopyCommand            = new BaseCommand(ContextMenuCopy);
            ContextMenuCutCommand             = new BaseCommand(ContextMenuCut);
            ContextMenuPasteCommand           = new BaseCommand(ContextMenuPaste);
            ContextMenuDeleteCommand          = new BaseCommand(ContextMenuDelete);
            ContextMenuSelectAllCommand       = new BaseCommand(ContextMenuSelectAll);
            ContextMenuGoogleSearchCommand    = new BaseCommand(ContextMenuGoogleSearch);
            ContextMenuClearFilterCommand     = new BaseCommand(ContextMenuClearFilter);
            ContextMenuClearAllFiltersCommand = new BaseCommand(ContextMenuClearAllFilters);
            ContextMenuColumnChooserCommand   = new BaseCommand(ContextMenuColumnChooser);

            EventSystem.Subscribe <GenericEvent>(OnMessageReceived, ThreadOption.UIThread);
            BindingOperations.EnableCollectionSynchronization(Songs, _lock);
            log.Trace("<<<");
        }
Пример #2
0
        public LoginInternalResult Login(string username, string password, int companyNumber, string languageID, bool firstLogin, bool singleTenant)
        {
            _nLogLogger.Debug($"username {username}", "Login");
            _nLogLogger.Debug($"password {password}", "Login");
            _nLogLogger.Debug($"companyNumber {companyNumber}", "Login");
            _nLogLogger.Debug($"languageID {languageID}", "Login");
            _nLogLogger.Debug($"firstLogin {firstLogin}", "Login");
            _nLogLogger.Debug($"singleTenant {singleTenant}", "Login");
            var pdsUserLoginDataSet = new pdsUserLoginDataSet();

            pdsUserLoginDataSet.ttblUserLogin.AddttblUserLoginRow(username, password, companyNumber, languageID, firstLogin, singleTenant);
            var cErrorMessage = string.Empty;

            StopwatchUtil.Time(
                () =>
            {
                this._poLoginproxy.Login(ref this._pdsContext, ref pdsUserLoginDataSet, out cErrorMessage);
            });
            _nLogLoggerP.Trace("Login");
            if (!string.IsNullOrEmpty(cErrorMessage))
            {
                if (cErrorMessage.Contains(OperInUse))
                {
                    _nLogLogger.Warn($"Error returned - {cErrorMessage}", "PopulateLoginModel");
                }
                else
                {
                    _nLogLogger.Error($"Error returned - {cErrorMessage}", "PopulateLoginModel");
                }
            }
            if (pdsUserLoginDataSet.HasErrors)
            {
                _nLogLogger.Error("pdsUserContext is showing errors", "Login");
            }
            var result = new UserLogin();

            if (pdsUserLoginDataSet.ttblUserLogin.Count > 0)
            {
                result = UserLogin.BuildUserLoginFromRow(pdsUserLoginDataSet.ttblUserLogin[0]);
            }
            var loginInternalResult = this.PopulateLoginModel(pdsUserLoginDataSet.HasErrors, cErrorMessage, result, firstLogin);

            loginInternalResult.availUsers = new List <AvailUsers>();
            foreach (DataRow row in pdsUserLoginDataSet.ttblAvailUsers)
            {
                _nLogLogger.Debug($"Building Avail Users", "Login");
                loginInternalResult.availUsers.Add(AvailUsers.BuildAvailUsersFromRow(row));
            }
            _nLogLogger.Debug($"Finished Login", "Login");
            return(loginInternalResult);
        }
Пример #3
0
        public static T DoWebCallString <T>(Uri uri, bool upload, string payload, WebHeaderCollection headers, out bool error, NLogLogger myLogger, bool ignoreResponse = false)
        {
            error = false;
            var webClient        = new CoudSuiteWebClient();
            var progressSettings = new ProgressConfiguration();

            for (var index = 0; index < headers.Count; index++)
            {
                webClient.Headers.Add(headers.AllKeys[index], headers[index]);
            }
            if (progressSettings.InforOverrideHttps)
            {
                myLogger.Trace("Over-riding HTTPS errors");
                ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
            }
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
            try
            {
                var response = upload ? webClient.UploadString(uri, payload) : webClient.DownloadString(uri);
                return(ignoreResponse ? default(T) : JsonConvert.DeserializeObject <T>(response));
            }
            catch (Exception ex)
            {
                myLogger.ErrorException("Web Call Failed", ex);
                error = true;
            }
            finally
            {
                webClient.Dispose();
            }
            return(default(T));
        }
Пример #4
0
        public void WhenCallingTraceShouldRecordOneError()
        {
            // act
            _logger.Trace("Test String");

            // assert
            _memoryTarget.Logs.Count.Should().Be(1, "because we only called the method once");
            _memoryTarget.Logs.All(log => log.Contains("Trace")).Should().BeTrue("Because we only logged an Trace");
        }
Пример #5
0
        private async Task <Album> GetAlbumQuery()
        {
            log.Trace($"Discogs: Querying {ArtistName} -  {AlbumName}");
            var query = new DiscogsSearch {
                artist = ArtistName, release_title = AlbumName, type = DiscogsEntityType.master
            };
            var searchresults = await _discogsClient.SearchAsync(query);

            // Look for the Master Release only
            foreach (var result in searchresults.GetResults())
            {
                var album = await GetRelease(result.id);

                Albums.Add(album);
            }
            log.Trace("Discogs Query Ended");
            // We don't need to return really anything. Just to satisfy that a Task can't return void
            return(null);
        }
Пример #6
0
 /// <summary>
 /// Return the Drives for My Computer or Network
 /// </summary>
 /// <param name="helper"></param>
 /// <param name="isNetwork"></param>
 /// <returns></returns>
 public virtual ObservableCollection <TreeItem> RequestDriveCollection(TreeViewHelper helper, bool isNetwork)
 {
     log.Trace(">>>");
     if (isNetwork)
     {
         return(_rootCollectionNetwork);
     }
     log.Trace("<<<");
     return(_rootCollection);
 }
 public void Trace(string message)
 {
     _nLogLogger.Trace(message);
     _traceWriterLogger.Trace(message);
 }
Пример #8
0
        public static bool CaseConvert(ref SongData song)
        {
            log.Trace(">>>");
            bool bErrors = false;

            // Convert the Filename
            if (_options.ConversionSettings.ConvertFileName)
            {
                var fileName = ConvertCase(Path.GetFileNameWithoutExtension(song.FileName));

                // Now check the length of the filename
                if (fileName.Length > 255)
                {
                    log.Debug($"Filename too long: {fileName}");
                    song.Status    = 2;
                    song.StatusMsg = LocalizeDictionary.Instance.GetLocalizedObject("MPTagThat", "Strings",
                                                                                    "tagAndRename_NameTooLong", LocalizeDictionary.Instance.Culture).ToString();
                    bErrors = true;
                }

                if (!bErrors)
                {
                    // Now that we have a correct Filename
                    if (fileName != Path.GetFileNameWithoutExtension(song.FileName))
                    {
                        song.FileName = $"{fileName}{Path.GetExtension(song.FileName)}";
                        song.Changed  = true;
                    }
                }
            }

            // Convert the Tags
            if (_options.ConversionSettings.ConvertTags)
            {
                string strConv;
                var    bChanged = false;
                if (_options.ConversionSettings.ConvertArtist)
                {
                    strConv  = song.Artist;
                    bChanged = (strConv = ConvertCase(strConv)) != song.Artist;
                    if (bChanged)
                    {
                        song.Artist  = strConv;
                        song.Changed = true;
                    }
                }

                if (_options.ConversionSettings.ConvertAlbumArtist)
                {
                    strConv  = song.AlbumArtist;
                    bChanged = (strConv = ConvertCase(strConv)) != song.AlbumArtist;
                    if (bChanged)
                    {
                        song.AlbumArtist = strConv;
                        song.Changed     = true;
                    }
                }

                if (_options.ConversionSettings.ConvertAlbum)
                {
                    strConv  = song.Album;
                    bChanged = (strConv = ConvertCase(strConv)) != song.Album;
                    if (bChanged)
                    {
                        song.Album   = strConv;
                        song.Changed = true;
                    }
                }

                if (_options.ConversionSettings.ConvertTitle)
                {
                    strConv  = song.Title;
                    bChanged = (strConv = ConvertCase(strConv)) != song.Title;
                    if (bChanged)
                    {
                        song.Title   = strConv;
                        song.Changed = true;
                    }
                }

                if (_options.ConversionSettings.ConvertComment)
                {
                    strConv  = song.Comment;
                    bChanged = (strConv = ConvertCase(strConv)) != song.Comment;
                    if (bChanged)
                    {
                        song.Comment = strConv;
                        song.Changed = true;
                    }
                }
            }
            log.Trace("<<<");
            return(song.Changed == true);
        }
Пример #9
0
        public LoginResponseModel Login(LoginRequestModel loginRequestModel)
        {
            _nLogLogger.Trace("Start", "Login Controller");
            var loginResults = this.loginService.Login(loginRequestModel, this.ActionContext.Request.Headers.Host);

            _nLogLogger.Trace("After Login Call", "Login Controller");

            if (loginResults.Success)
            {
                _nLogLogger.Trace("Before Business Rules", "Login Controller");
                this.DoBusinessRules(loginResults);
                _nLogLogger.Trace("After Business Rules", "Login Controller");

                var token = GenerateToken.Generate(_nLogLogger);
                if (token != "")
                {
                    bool error;
                    var  uriBuilder   = new UriBuilder(loginResults.RestAccessUrl + "/web/api/sa/SaGetEnv");
                    var  saGetRequest = new SaGetEnvResponse
                    {
                        ttblsaenv = new Ttblsaenv
                        {
                            dateformat = ""
                        }
                    };
                    var webHeaderCollection = new WebHeaderCollection
                    {
                        { "Token", token },
                        { "Accept-Encoding", "gzip, deflate" },
                        { "Accept", "application/json" },
                        { "Content-Type", "application/json" }
                    };
                    var responseObject = MakeWebCall.DoWebCallString <SaGetEnvResponse>(uriBuilder.Uri, true,
                                                                                        JsonConvert.SerializeObject(saGetRequest), webHeaderCollection, out error, _nLogLogger);
                    if (!error)
                    {
                        loginResults.DateFormat = responseObject.ttblsaenv.dateformat;
                    }
                    else
                    {
                        _nLogLogger.Error("Failed to get environment");
                    }

                    uriBuilder = new UriBuilder(loginResults.RestAccessUrl + "/web/api/shared/logintimezone");
                    var tokenObject          = GenerateToken.ReturnToken();
                    var loginZoneTimeRequest = new LoginZoneTimeRequest
                    {
                        ttbllogintimezone = new Ttbllogintimezone
                        {
                            cono          = tokenObject.Cono,
                            oper2         = tokenObject.Oper,
                            sessionid     = tokenObject.SessionidGuid,
                            logintimezone = loginRequestModel.OffsetTime
                        }
                    };

                    MakeWebCall.DoWebCallString <string>(uriBuilder.Uri, true,
                                                         JsonConvert.SerializeObject(loginZoneTimeRequest), webHeaderCollection, out error, _nLogLogger, true);
                    if (error)
                    {
                        _nLogLogger.Error("Failed to set timezone");
                    }
                }
            }
            return(loginResults);
        }
Пример #10
0
        public MingleWorkflowResponse StartMingleWorkflow(MingleWorkflowRequest req)
        {
            var uriBuilder = new UriBuilder(this._tokenObject.IonApiUrl + "/Mingle/SocialService.Svc/User/Detail");

            NLogLogger.Trace(uriBuilder.Uri.ToString(), "StartMingleWorkflow ionApiUrl");
            NLogLogger.Trace(this._bearerToken, "StartMingleWorkflow bearerToken");

            if (this._bearerToken == null)
            {
                var error = new Errorlist()
                {
                    Severity = 1, Code = 400
                };
                var errorResponse = new MingleWorkflowResponse()
                {
                    ErrorList = new[] { error }, Status = 0
                };
                NLogLogger.Error("bearertoken not harvested from request header", "StartMingleWorkflow");
                return(errorResponse);
            }

            var bearerTokenObject = JsonConvert.DeserializeObject <BearerTokenObject>(this._bearerToken);

            if (this._progressConfiguration.InforOverrideHttps)
            {
                ServicePointManager.ServerCertificateValidationCallback += ValidateRemoteCertificate;
            }
            ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;


            //get ming.le user guid
            string userGuid = null;

            var webHeaderCollection = new WebHeaderCollection
            {
                { "Authorization", $"Bearer {bearerTokenObject.access_token}" },
                { "Accept", "application/json" },
                { "Content-Type", "application/json" }
            };


            var responseObject =
                MakeWebCall.DoWebCallString <MingleUserDetailResponse>(uriBuilder.Uri, false, string.Empty, webHeaderCollection, out var inError,
                                                                       NLogLogger);

            if (!inError)
            {
                if (responseObject.UserDetailList.Length == 1)
                {
                    userGuid = responseObject.UserDetailList[0].UserGUID;

                    var emailParam = new Startparameter {
                        Name = "EmailAddr", SerializedValue = responseObject.UserDetailList[0].Email
                    };
                    req.StartParameters = (req.StartParameters ?? Enumerable.Empty <Startparameter>()).Concat(Enumerable.Repeat(emailParam, 1)).ToArray();
                }
            }
            else
            {
                var error = new Errorlist()
                {
                    Severity = 1, Code = 500, Message = "User Details Error"
                };
                var errorResponse = new MingleWorkflowResponse()
                {
                    ErrorList = new[] { error }, Status = 0
                };
                NLogLogger.Error($"Error retrieving UserGUID");
                return(errorResponse);
            }

            //get customer details, add to payload
            var customerNumber = req.StartParameters.SingleOrDefault(item => item.Name == "CustomerNumber");

            if (customerNumber != null)
            {
                var arscRepository = new ArscRepository(this._connection);
                var arsc           = arscRepository.Get(0, int.Parse(customerNumber.SerializedValue), false, 1, "");
                var custNameParam  = new Startparameter {
                    Name = "CustomerName", SerializedValue = arsc.name
                };
                req.StartParameters = (req.StartParameters ?? Enumerable.Empty <Startparameter>()).Concat(Enumerable.Repeat(custNameParam, 1)).ToArray();
            }

            webHeaderCollection = new WebHeaderCollection
            {
                { "Accept", "application/json" },
                { "Content-Type", "application/json" }
            };
            uriBuilder = new UriBuilder(uriBuilder.Uri + $"/Mingle/IONDataService.Svc/User/{userGuid}/Workflow/Start");
            var returnObject = MakeWebCall.DoWebCallString <MingleWorkflowResponse>(uriBuilder.Uri, true,
                                                                                    JsonConvert.SerializeObject(req), webHeaderCollection, out inError, NLogLogger);

            if (inError)
            {
                var error = new Errorlist()
                {
                    Severity = 1, Code = 500, Message = "User Details Error"
                };
                var errorResponse = new MingleWorkflowResponse()
                {
                    ErrorList = new[] { error }, Status = 0
                };
                NLogLogger.Error($"Error starting workflow");
                return(errorResponse);
            }
            return(returnObject);
        }
Пример #11
0
        private IEnumerable <GetImageUrlResponse> ReturnUrlFromCall(List <GetImageUrlRequest> getImageUrlRequest, out bool inError)
        {
            var queryToGet = getImageUrlRequest.Aggregate($"/{this._supportedRespository.IdmEntityType}[(", (current, request) => current + (current.Length > 14 ? " OR " : string.Empty) + string.Format(this._supportedRespository.Formatter, request.Key.Replace('"', ' ')));

            queryToGet += $") AND @Company_Number={this._tokenObject.Cono}]";

            NLogLogger.Trace($"queryToGet - {queryToGet}");

            var oAuthBase = new OAuthBase();


            var query = oAuthBase.CreateQueryParam("$offset", "0");

            query = query + "&" + oAuthBase.CreateQueryParam("$limit", getImageUrlRequest.Count.ToString());
            query = query + "&" + oAuthBase.CreateQueryParam("$includeCount", "false");
            query = query + "&" + oAuthBase.CreateQueryParam("$language", "en");

            NLogLogger.Trace($"url - {query}");


            UriBuilder uriBuilder;

            string signature;

            if (!new ProgressConfiguration().SSoEnabled)
            {
                // Use OAuth 1.0
                if (string.IsNullOrEmpty(this._tokenObject.IdmUrl))
                {
                    inError = true;
                    NLogLogger.Error("The IDM URL was empty - Unable to retrieve images");
                    return(new List <GetImageUrlResponse>());
                }
                // PMC 02/09/2018 - IBM AppScan - This has been manually reviewed and passed as being safe
                uriBuilder = new UriBuilder(this._tokenObject.IdmUrl)
                {
                    Query = query
                };
                signature = oAuthBase.GenerateSignature(uriBuilder.Uri, this._tokenObject.IdmConsumerKey, this._tokenObject.IdmSharedSecret, string.Empty, string.Empty, "POST", oAuthBase.GenerateTimeStamp(), oAuthBase.GenerateNonce(6));
                NLogLogger.Trace($"OAuth 1.0 - signature - {signature}");
            }
            else
            {
                // Use OAuth 2.0
                if (string.IsNullOrEmpty(this._tokenObject.IonApiUrl))
                {
                    inError = true;
                    NLogLogger.Error("The ION API URL was empty - Unable to retrieve images");
                    return(new List <GetImageUrlResponse>());
                }
                if (this._bearerToken == null)
                {
                    NLogLogger.Error("bearertoken not harvested from request header", "ReturnUrlFromCall");
                    inError = true;
                    return(new List <GetImageUrlResponse>());
                }

                // PMC 02/09/2018 - IBM AppScan - This has been manually reviewed and passed as being safe
                uriBuilder = new UriBuilder(this._tokenObject.IonApiUrl + "/IDM/api/items/search")
                {
                    Query = query
                };
                var bearerTokenObject = JsonConvert.DeserializeObject <BearerTokenObject>(this._bearerToken);

                signature = $"Bearer {bearerTokenObject.access_token}";
                NLogLogger.Trace($"OAuth 2.0 - signature - {signature}");
            }
            NLogLogger.Trace($"Calling URI - {uriBuilder.Uri}");

            var webHeaderCollection = new WebHeaderCollection
            {
                { "Authorization", signature },
                { "x-ionapi-docrequest", "DistributionSxe" },
                { "Accept-Encoding", "gzip, deflate" },
                { "Accept", "application/json" },
                { "Content-Type", "text/plain" }
            };
            var idmResponseObject = MakeWebCall.DoWebCallString <IdmResponse>(uriBuilder.Uri, true,
                                                                              queryToGet, webHeaderCollection, out inError, NLogLogger);
            List <GetImageUrlResponse> returnValue;

            if (!inError)
            {
                NLogLogger.Trace($"idmResponseString - {JsonConvert.SerializeObject(idmResponseObject)}");
                returnValue = idmResponseObject.ReturnImageUrl(getImageUrlRequest, this._tokenObject.InforIdmCacheExpirationAbsolute / 2);
            }
            else
            {
                returnValue = new List <GetImageUrlResponse>();
                NLogLogger.Error("Image Retrieval failed");
            }
            return(returnValue);
        }