Exemple #1
0
        public static HttpContext SetUserAndPermission()
        {
            RevenuePlanner.BDSService.BDSServiceClient objBDSServiceClient = new RevenuePlanner.BDSService.BDSServiceClient();


            string userName                = Convert.ToString(ConfigurationManager.AppSettings["Username"]);
            string password                = Convert.ToString(ConfigurationManager.AppSettings["Password"]);
            Guid   applicationId           = Guid.Parse(ConfigurationManager.AppSettings["BDSApplicationCode"]);
            string singlehash              = DataHelper.ComputeSingleHash(password);
            double DefaultPlanExchangeRate = 1;


            HttpContext.Current = MockHelpers.FakeHttpContext();

            HttpContext.Current.Session["User"] = objBDSServiceClient.ValidateUser(applicationId, userName, singlehash);

            HttpContext.Current.Session["Permission"] = objBDSServiceClient.GetPermission(applicationId, ((RevenuePlanner.BDSService.User)(HttpContext.Current.Session["User"])).RoleId);

            Message msg            = new Message();
            var     xmlMsgFilePath = Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).Parent.FullName + "\\" + System.Configuration.ConfigurationManager.AppSettings.Get("XMLCommonMsgFilePath");

            msg.loadMsg(xmlMsgFilePath);
            HttpContext.Current.Cache["CommonMsg"] = msg;
            CacheDependency dependency = new CacheDependency(xmlMsgFilePath);

            HttpContext.Current.Cache.Insert("CommonMsg", msg, dependency);
            Common.objCached = msg;


            return(HttpContext.Current);
        }
Exemple #2
0
        public static HttpContext SetUserAndPermission(bool IsLogin = false, string Username = "", string Password = "")
        {
            RevenuePlanner.BDSService.BDSServiceClient objBDSServiceClient = new RevenuePlanner.BDSService.BDSServiceClient();
            string userName, password;

            if (IsLogin && !string.IsNullOrEmpty(Username) && !string.IsNullOrEmpty(Password))
            {
                userName = Username;
                password = Password;
            }
            else
            {
                userName = Convert.ToString(ConfigurationManager.AppSettings["Username"]);
                password = Convert.ToString(ConfigurationManager.AppSettings["Password"]);
            }

            Guid   applicationId = Guid.Parse(ConfigurationManager.AppSettings["BDSApplicationCode"]);
            string singlehash = DataHelper.ComputeSingleHash(password);

            HttpContext.Current = MockHelpers.MockHelpers.FakeHttpContext();

            var Users = objBDSServiceClient.ValidateUser(applicationId, userName, singlehash);

            if (Users != null)
            {
                HttpContext.Current.Session["User"]       = Users;
                HttpContext.Current.Session["Permission"] = objBDSServiceClient.GetPermission(applicationId, ((RevenuePlanner.BDSService.User)(HttpContext.Current.Session["User"])).RoleId);
            }

            Message msg = new Message();
            //var xmlMsgFilePath = Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).Parent.FullName + "\\" + System.Configuration.ConfigurationManager.AppSettings.Get("XMLCommonMsgFilePath");
            var xmlMsgFilePath = Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).Parent.Parent.FullName + "\\" + System.Configuration.ConfigurationManager.AppSettings.Get("XMLCommonIntegrationMsgFilePath");

            msg.loadMsg(xmlMsgFilePath);
            HttpContext.Current.Cache["CommonMsg"] = msg;
            CacheDependency dependency = new CacheDependency(xmlMsgFilePath);

            HttpContext.Current.Cache.Insert("CommonMsg", msg, dependency);
            Common.objCached = msg;


            return(HttpContext.Current);
        }
        public void Get_Filter_With_No_Parameters()
        {
            Console.WriteLine("To check to retrieve Home view with no parameters.\n");
            //// Set session value
            HttpContext.Current = DataHelper.SetUserAndPermission();

            string userName   = Convert.ToString(ConfigurationManager.AppSettings["Username"]);
            string password   = Convert.ToString(ConfigurationManager.AppSettings["Password"]);
            string singlehash = DataHelper.ComputeSingleHash(password);

            RevenuePlanner.BDSService.BDSServiceClient objBDSServiceClient = new RevenuePlanner.BDSService.BDSServiceClient();
            Sessions.User = objBDSServiceClient.Validate_UserOverAll(userName, singlehash);

            //// Call index method
            FilterController objFilterController = new FilterController();
            var result = objFilterController.Index() as PartialViewResult;

            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name + " \n The Assert Value ActiveMenu :  " + result.ViewBag.ActiveMenu);
            Assert.IsNotNull(result.ViewBag.ActiveMenu);
        }