Exemplo n.º 1
0
        public async Task <AllUserSettings> GetAllUserSettings(string userName, string previousUser)
        {
            AllUserSettings allUserSettings = new AllUserSettings();

            SettingsLayer settings = new SettingsLayer();

            UserLayer userLayer = new UserLayer();

            //  var //stopwatch0 = new //stopwatch();
            //  var //stopwatch = new //stopwatch();
            //  var //stopwatch1 = new //stopwatch();
            //  var //stopwatch2 = new //stopwatch();
            //  //stopwatch0.Start();
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                sqlCon.Open();

                //stopwatch.Start();

                allUserSettings.session = await userLayer.GetSessionAsync(userName, previousUser, sqlCon);

                //stopwatch.Stop();


                //stopwatch1.Start();
                allUserSettings.columns = await settings.GetUserCollums(userName, sqlCon);


                //stopwatch1.Stop();


                //stopwatch2.Start();
                allUserSettings.settings = await GetSavedUserSettings(new List <string>(), userName, sqlCon);

                //stopwatch2.Stop();
            }
            //stopwatch0.Stop();
            if (previousUser == null || previousUser == "")
            {
                await Task.Run(() =>
                {
                    try
                    {
                        allUserSettings.settings  = allUserSettings.settings.FindAll(a => a.name != "allUserSettings");
                        SavedUserSettings setting = new SavedUserSettings()
                        {
                            name = "allUserSettings", value = new JavaScriptSerializer()
                            {
                                MaxJsonLength = 16777216
                            }.Serialize(allUserSettings)
                        };
                        SaveUserSettings(setting, userName);
                    }
                    catch
                    {
                    }
                });
            }
            return(allUserSettings);
        }
Exemplo n.º 2
0
        public async Task <AllUserSettings> GetAllUserSettings()
        {
            string userName = HttpContext.Current.User.Identity.Name;

            if (HttpContext.Current.Request.UrlReferrer != null && (HttpContext.Current.Request.UrlReferrer.Host.Contains("localhost") && HttpContext.Current.Request.UrlReferrer.Port == 51268))
            {
                userName = "******"; // HttpContext.Current.User.Identity.Name;
            }
            else
            {
                userName = HttpContext.Current.User.Identity.Name;
            }


            AllUserSettings allUserSettings = new AllUserSettings();

            SettingsLayer settings = new SettingsLayer();

            UserLayer1 userLayer = new UserLayer1();

            //  var //  = new //stopwatch();
            //  var //stopwatch = new //stopwatch();
            //  var //stopwatch1 = new //stopwatch();
            //  var //stopwatch2 = new //stopwatch();
            //  //stopwatch0.Start();
            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["CC_ProdConn"].ConnectionString))
            {
                sqlCon.Open();

                //stopwatch.Start();

                allUserSettings.session = await userLayer.GetSessionAsync(sqlCon);

                //stopwatch.Stop();


                //stopwatch1.Start();
                allUserSettings.columns = await settings.GetUserCollums(userName, sqlCon);


                //stopwatch1.Stop();


                //stopwatch2.Start();
                allUserSettings.settings = await GetSavedUserSettings(new List <string>(), sqlCon);

                //stopwatch2.Stop();
            }
            //stopwatch0.Stop();

            return(allUserSettings);
        }