Beispiel #1
0
        public IActionResult ModulesBbsList(String procedureCode)
        {
            List <DOL.BBS.DBEntities.Moduli> modulesList = new List <DOL.BBS.DBEntities.Moduli>();

            try
            {
                PandoraSession session = NetCoreUtility.GetSession(HttpContext);
                if (session == null)
                {
                    return(new StatusCodeResult(440));
                }

                #region Recupero i Modules

                if (!String.IsNullOrEmpty(procedureCode))
                {
                    //Recupero i modules Bbs relativi ad un procedureCode chiamando l'ESB
                    DOL.BBS.DBEntities.BBSModules response = _refBbsService.GetModulesBbs(session.Username, procedureCode, _appSettings.APP_CODE, _appSettings.TS_ESB_APPCODE, _appSettings.TS_ESB_VERSION, _appSettings.TS_ESB_PLM_PASSWORD, _appSettings.TS_ESB_URL);

                    if (!PandoraUtility.CheckEsbStatus(response))
                    {
                        modulesList = response.Moduli == null ? new List <DOL.BBS.DBEntities.Moduli>() : response.Moduli.OrderBy(e => e.QU04_DESCRIZIONE).ToList();
                    }
                }

                #endregion
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.Message);
                modulesList = new List <DOL.BBS.DBEntities.Moduli>();
            }

            return(Json(modulesList));
        }
Beispiel #2
0
        public void AddTiredSong(PandoraSession session, PandoraSong song, WebProxy proxy)
        {
            if (session == null || session.User == null)
            {
                throw new PandoraException("User must be logged in to make this request.");
            }

            ExecuteRequest(new SleepSongRequest(session, song.Token), proxy);
            song.TemporarilyBanned = true;
        }
Beispiel #3
0
        /// <summary>
        /// Retrieves a list of stations for the current user.
        /// </summary>
        public List <PandoraStation> GetStations(PandoraSession session, WebProxy proxy)
        {
            if (session == null || session.User == null)
            {
                throw new PandoraException("User must be logged in to make this request.");
            }

            GetStationListResponse response = (GetStationListResponse)ExecuteRequest(new GetStationListRequest(session), proxy);

            return(response.Stations);
        }
Beispiel #4
0
        public PandoraSongFeedback RateSong(PandoraSession session, PandoraStation station, PandoraSong song, PandoraRating rating, WebProxy proxy)
        {
            if (session == null || session.User == null)
            {
                throw new PandoraException("User must be logged in to make this request.");
            }

            PandoraSongFeedback feedbackObj = (PandoraSongFeedback)ExecuteRequest(new AddFeedbackRequest(session, station.Token, song.Token, rating == PandoraRating.Love), proxy);

            song.Rating = rating;

            return(feedbackObj);
        }
Beispiel #5
0
        public IActionResult GetProcedureTypesByBBS(Guid bbsOid)
        {
            ProcedureTypBBSModel model = new ProcedureTypBBSModel();
            //model.ProcedureTypeBbsList = new List<MPR.DTOs.Core.ProcedureTypes.ProcedureType>();
            ResponseResult result = new ResponseResult();

            try
            {
                PandoraSession session = NetCoreUtility.GetSession(HttpContext);
                if (session == null)
                {
                    return(new StatusCodeResult(440));
                }
                GetProcedureTypesByBBSRequest request = new GetProcedureTypesByBBSRequest
                {
                    BBSOid = bbsOid
                };
                GetProcedureTypeByBBSResponse response = _bbsService.GetProcedureTypesByBBS(session.Username, request, _appSettings.APP_CODE, _appSettings.TS_ESB_MPR_APPCODE, _appSettings.TS_ESB_VERSION, _appSettings.TS_ESB_PLM_PASSWORD, _appSettings.TS_ESB_URL);

                if (PandoraUtility.CheckEsbStatus(response))
                {
                    result.Message = AppUtility.GetErrorDescription(Utility.Modules.Registries_BBS, Commands.GetProducedureTypesByBBS, response.Status.Code, null, response.Status.Description);
                }
                else
                {
                    result.Success = true;
                    //model.ProcedureTypeBbsList = response.ProcedureTypesList;
                    model.ProcedureTypeBbsList = response.ProcedureTypesList.Select(p => new ProcTypeBbsModel()
                    {
                        code = p.Id.ToString()
                    }).ToList();
                }
            }
            catch (BaseException be)
            {
                _logger.LogInformation(be.Message);
                model.Result.Message = PandoraErrorCodes.Exception_Error;
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.ToString());
                model.Result.Message = PandoraErrorCodes.Exception_Error;
            }
            model.Result = result;
            return(Json(model));
        }
Beispiel #6
0
        /// <summary>
        /// Given the username and password, attempts to log into the Pandora music service.
        /// </summary>
        /// <returns>If login is successful, returns a PandoraUser object. If invalid username or password
        /// null is returned.</returns>
        public PandoraUser UserLogin(PandoraSession session, string username, string password, WebProxy proxy)
        {
            try {
                PandoraUser user = (PandoraUser)ExecuteRequest(new UserLoginRequest(session, username, password), proxy);
                session.User  = user;
                user.Password = password;
                return(user);
            }
            catch (PandoraException e) {
                if (e.ErrorCode == ErrorCodeEnum.AUTH_INVALID_USERNAME_PASSWORD)
                {
                    return(null);
                }

                throw;
            }
        }
Beispiel #7
0
 /// <summary>
 /// Given the username and password, attempts to log into the Pandora music service.
 /// </summary>
 /// <returns>If login is successful, returns a PandoraUser object. If invalid username or password
 /// null is returned.</returns>
 public PandoraUser UserLogin(PandoraSession session, string username, string password)
 {
     return(UserLogin(session, username, password, null));
 }
Beispiel #8
0
 public PandoraRequest(PandoraSession session)
 {
     this.Session = session;
     this.User    = session == null ? null : session.User;
 }
Beispiel #9
0
 public void AddTiredSong(PandoraSession session, PandoraSong song)
 {
     AddTiredSong(session, song, null);
 }
Beispiel #10
0
 public AddFeedbackRequest(PandoraSession session, string stationToken, string trackToken, bool positive) :
     base(session)
 {
     this.StationToken = stationToken;
     this.TrackToken   = trackToken;
 }
Beispiel #11
0
 public PandoraSongFeedback RateSong(PandoraSession session, PandoraStation station, PandoraSong song, PandoraRating rating)
 {
     return(RateSong(session, station, song, rating, null));
 }
Beispiel #12
0
        public IActionResult UpdateBBS([FromBody] BBSAddModel bbs)
        {
            ResponseResult result = new ResponseResult
            {
                Success = false
            };

            try
            {
                PandoraSession session = NetCoreUtility.GetSession(HttpContext);
                if (session == null)
                {
                    return(new StatusCodeResult(440));
                }
                #region Verifica Rules

                List <string> rulesList = new List <string> {
                    AppUtility.Rules.UpdateBBSRule
                };
                string pandoraRulePath = _appSettings.PANDORA_BASE_PATH + _appSettings.PANDORA_RULE_PATH + "/verifyrules";
                Dictionary <string, bool> rulesResult = VerifyRules(rulesList, session.RandomId, session.AccessToken, session.ScopeId, pandoraRulePath);

                #endregion
                if (PandoraUtility.IsVisibleRule(rulesResult, AppUtility.Rules.UpdateBBSRule))
                {
                    UpdateBBSRelationRequest request = new UpdateBBSRelationRequest()
                    {
                        Oid                = bbs.Oid,
                        FamilyOid          = bbs.FamilyOid,
                        ProductOid         = bbs.ProductOid,
                        ProcedureOid       = bbs.ProcedureOid,
                        ModuleOid          = bbs.ModuleOid,
                        ProcedureBBSOid    = bbs.ProcedureBBSOid,
                        ProcedureBBSName   = bbs.ProcedureBBSName,
                        ModuleBBSOid       = bbs.ModuleBBSOid,
                        ModuleBBSName      = bbs.ModuleBBSName,
                        Enabled            = bbs.Enabled,
                        ProcedureTypesList = bbs.ProcedureTypeBbsList?.Select(s => Int32.Parse(s.code)).ToList()
                    };
                    UpdateBBSRelationResponse response = _bbsService.UpdateBbs(session.Username, request, _appSettings.APP_CODE, _appSettings.TS_ESB_MPR_APPCODE, _appSettings.TS_ESB_VERSION, _appSettings.TS_ESB_PLM_PASSWORD, _appSettings.TS_ESB_URL);
                    if (PandoraUtility.CheckEsbStatus(response))
                    {
                        result.Message = AppUtility.GetErrorDescription(Utility.Modules.Registries_BBS, Commands.UpdateBBS, response.Status.Code, null, response.Status.Description);
                    }
                    else
                    {
                        result.Success = true;
                        result.Message = PandoraAppResources.Succes_UpdateBbsRelation;
                    }
                }
                else
                {
                    result.Message = PandoraErrorCodes.Permission_Denied;
                }
            }
            catch (BaseException be)
            {
                _logger.LogInformation(be.Message);
                result.Message = PandoraErrorCodes.Exception_Error;
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.ToString());
                result.Message = PandoraErrorCodes.Exception_Error;
            }
            bbs.Result = result;
            return(Json(bbs));
        }
Beispiel #13
0
 /// <summary>
 /// Retrieves all available genre stations.
 /// </summary>
 /// <param name="session"></param>
 /// <returns></returns>
 public List <PandoraStationCategory> GetGenreStations(PandoraSession session)
 {
     return(GetGenreStations(session, null));
 }
Beispiel #14
0
 /// <summary>
 /// Retrieves a playlist for the given station.
 /// </summary>
 public List <PandoraSong> GetSongs(PandoraSession session, PandoraStation station)
 {
     return(GetSongs(session, station, null));
 }
 public GetPlaylistRequest(PandoraSession session, string stationToken) :
     base(session)
 {
     this.StationToken = stationToken;
 }
 public SleepSongRequest(PandoraSession session, string trackToken) :
     base(session)
 {
     this.TrackToken = trackToken;
 }
Beispiel #17
0
 /// <summary>
 /// Retrieves a list of stations for the current user.
 /// </summary>
 public List <PandoraStation> GetStations(PandoraSession session)
 {
     return(GetStations(session, null));
 }
 public GetGenreStationsRequest(PandoraSession session) :
     base(session)
 {
 }
Beispiel #19
0
        public IActionResult GetBbsModulesForProcedure(Guid procedureOid)
        {
            ModuleProcedureList model = new ModuleProcedureList();

            model.ModulesProcedureList = new List <Module>();
            ResponseResult result = new ResponseResult();

            result.Success = false;
            GetModulesForProcedureResponse response = new GetModulesForProcedureResponse();

            try
            {
                model.Rules = new List <string>();
                PandoraSession session = NetCoreUtility.GetSession(HttpContext);
                if (session == null)
                {
                    return(new StatusCodeResult(440));
                }

                #region Verifica Validità Access Token
                if (PandoraUtility.IsAccessTokenExpired(session.AccessToken))
                {
                    string            pandoraTokenPath = _appSettings.PANDORA_BASE_PATH + _appSettings.PANDORA_TOKEN_PATH;
                    AuthorizationData authData         = PandoraUtility.GetNewAccessToken(pandoraTokenPath, session.UserCode, session.Username, session.Refreshtoken);
                    session.AccessToken  = authData.Access_Token;
                    session.Refreshtoken = authData.Refresh_Token;
                    NetCoreUtility.SetSession(HttpContext, session);
                }
                #endregion

                #region Verifica Rules
                List <string> rulesList = new List <string> {
                    AppUtility.Rules.ACPReadProcedure
                };
                string pandoraRulePath = _appSettings.PANDORA_BASE_PATH + _appSettings.PANDORA_RULE_PATH + "/verifyrules";
                Dictionary <string, bool> rulesResult = VerifyRules(rulesList, session.RandomId, session.AccessToken, session.ScopeId, pandoraRulePath);

                #endregion

                #region Recupero le Relations

                if (PandoraUtility.IsVisibleRule(rulesResult, AppUtility.Rules.ACPReadProcedure))
                {
                    model.Rules.AddRange(rulesResult.Where(p => p.Value).Select(p => p.Key));
                    //need to be changed with the new request and passing the version oid
                    GetModulesForProcedureRequest request = new GetModulesForProcedureRequest
                    {
                        ProcedureOid = procedureOid
                    };
                    response = _bbsService.GetBbsModulesForProcedure(session.Username, request, _appSettings.APP_CODE, _appSettings.TS_ESB_MPR_APPCODE, _appSettings.TS_ESB_VERSION, _appSettings.TS_ESB_PLM_PASSWORD, _appSettings.TS_ESB_URL);
                    if (PandoraUtility.CheckEsbStatus(response))
                    {
                        result.Message = AppUtility.GetErrorDescription(Utility.Modules.ACP_Registries_Modules, Commands.GetBbsModulesByProcedure, response.Status.Code, null, response.Status.Description);
                    }
                    else
                    {
                        result.Success             = true;
                        model.ModulesProcedureList = response.ModulesList;
                    }
                }
                else
                {
                    result.Message = PandoraErrorCodes.Permission_Denied;
                }
                #endregion
            }
            catch (BaseException be)
            {
                _logger.LogInformation(be.Message);
                result.Message = PandoraErrorCodes.Exception_Error;
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.ToString());
                result.Message = PandoraErrorCodes.Exception_Error;
            }

            model.Result = result;
            return(Json(model));
        }
Beispiel #20
0
        public IActionResult DeleteBBS([FromBody] string id)
        {
            BbsDeleteModel model  = new BbsDeleteModel();
            ResponseResult result = new ResponseResult
            {
                Success = false
            };

            try
            {
                PandoraSession session = NetCoreUtility.GetSession(HttpContext);
                if (session == null)
                {
                    return(new StatusCodeResult(440));
                }

                #region Verifica Rules
                List <string> rulesList = new List <string> {
                    AppUtility.Rules.DeleteBBSRule
                };
                string pandoraRulePath = _appSettings.PANDORA_BASE_PATH + _appSettings.PANDORA_RULE_PATH + "/verifyrules";
                Dictionary <string, bool> rulesResult = VerifyRules(rulesList, session.RandomId, session.AccessToken, session.ScopeId, pandoraRulePath);

                #endregion
                if (PandoraUtility.IsVisibleRule(rulesResult, AppUtility.Rules.DeleteBBSRule))
                {
                    DeleteBBSRelationRequest request = new DeleteBBSRelationRequest()
                    {
                        BBSRelationOid = Guid.Parse(id),
                        Username       = session.UserCode
                    };

                    DeleteBBSRelationResponse response = _bbsService.DeleteBbs(session.Username, request, _appSettings.APP_CODE, _appSettings.TS_ESB_MPR_APPCODE, _appSettings.TS_ESB_VERSION, _appSettings.TS_ESB_PLM_PASSWORD, _appSettings.TS_ESB_URL);

                    if (PandoraUtility.CheckEsbStatus(response))
                    {
                        result.Message = AppUtility.GetErrorDescription(Utility.Modules.Registries_BBS, Commands.DeleteBBS, response.Status.Code, null, response.Status.Description);
                    }
                    else
                    {
                        result.Success = true;
                        result.Message = PandoraAppResources.Success_DeleteBbs;
                    }
                }
                else
                {
                    result.Success = false;
                    result.Message = PandoraErrorCodes.Permission_Denied;
                }
            }
            catch (BaseException be)
            {
                _logger.LogInformation(be.Message);
                result.Message = PandoraErrorCodes.Exception_Error;
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.ToString());
                result.Message = PandoraErrorCodes.Exception_Error;
            }
            model.Result = result;
            return(Json(model));
        }
Beispiel #21
0
        public IActionResult BbsGrid(string keyword, int?page, int?rows, string sort, string order)
        {
            BbsGridModel   model  = new BbsGridModel();
            ResponseResult result = new ResponseResult
            {
                Success = false
            };

            model.Bbs = new List <BBSRelations>();

            try
            {
                PandoraSession session = NetCoreUtility.GetSession(HttpContext);
                if (session == null)
                {
                    return(new StatusCodeResult(440));
                }
                #region Verifica Validità Access Token

                if (PandoraUtility.IsAccessTokenExpired(session.AccessToken))
                {
                    string            pandoraTokenPath = _appSettings.PANDORA_BASE_PATH + _appSettings.PANDORA_TOKEN_PATH;
                    AuthorizationData authData         = PandoraUtility.GetNewAccessToken(pandoraTokenPath, session.UserCode, session.Username, session.Refreshtoken);
                    session.AccessToken  = authData.Access_Token;
                    session.Refreshtoken = authData.Refresh_Token;
                    NetCoreUtility.SetSession(HttpContext, session);
                }

                #endregion

                #region Verifica Rules

                List <string> rulesList = new List <string> {
                    AppUtility.Rules.ReadBBSRule, AppUtility.Rules.DeleteBBSRule
                };
                string pandoraRulePath = _appSettings.PANDORA_BASE_PATH + _appSettings.PANDORA_RULE_PATH + "/verifyrules";
                Dictionary <string, bool> rulesResult = VerifyRules(rulesList, session.RandomId, session.AccessToken, session.ScopeId, pandoraRulePath);

                #endregion

                #region Recupero le Bbs

                if (PandoraUtility.IsVisibleRule(rulesResult, AppUtility.Rules.ReadBBSRule))
                {
                    GetBBSRequest request = new GetBBSRequest()
                    {
                        Keyword = keyword,
                        //we use || because if a parameter is null or empty, it doesn't cause any error
                        OrderByPropertyName = (string.IsNullOrEmpty(sort) || string.IsNullOrEmpty(order)) ? "Name asc" : sort + " " + order,
                        PageNumber          = page ?? 1,
                        PageSize            = rows ?? 10
                    };

                    GetBBSResponse response = _bbsService.GetBbs(session.Username, request, _appSettings.APP_CODE, _appSettings.TS_ESB_MPR_APPCODE, _appSettings.TS_ESB_VERSION, _appSettings.TS_ESB_PLM_PASSWORD, _appSettings.TS_ESB_URL);
                    if (PandoraUtility.CheckEsbStatus(response))
                    {
                        result.Message = AppUtility.GetErrorDescription(Utility.Modules.Registries_BBS, Commands.GetBBS, response.Status.Code, null, response.Status.Description);
                    }
                    else
                    {
                        result.Success  = true;
                        model.Bbs       = response.BBSList;
                        model.TotalRows = response.RecordNumber;
                    }
                }
                else
                {
                    result.Message = PandoraErrorCodes.Permission_Denied;
                }

                #endregion
            }
            catch (BaseException be)
            {
                _logger.LogInformation(be.Message);
                result.Message = PandoraErrorCodes.Exception_Error;
            }
            catch (Exception ex)
            {
                _logger.LogCritical(ex.ToString());
                result.Message = PandoraErrorCodes.Exception_Error;
            }
            ViewBag.TotalRows = model.TotalRows;
            model.Result      = result;
            return(PartialView(model));
        }
 public UserLoginRequest(PandoraSession session, string username, string password) :
     base(session)
 {
     this.UserName = username;
     this.Password = password;
 }
 public GetStationListRequest(PandoraSession session) :
     base(session)
 {
 }