public ActionResult UserPrefer(AjaxUserPreference ajaxuserprefer)
        {
            var schoolid = ajaxuserprefer.School.SchoolID;

            foreach (var acyear in ajaxuserprefer.AcademicYear)
            {
                UserPreference UserSchool = new UserPreference();
                UserSchool.AcademicYearRefID = acyear.ActiveYear;
                UserSchool.SchoolRefID = schoolid;
                UserSchool.UserID = ajaxuserprefer.osisuserid;
                db.UserPreferences.Attach(UserSchool);
                db.Entry(UserSchool).Property("CurrentYear").IsModified = true;
                db.Entry(UserSchool).Property("CurrentSchool").IsModified = true;
                break;
            }

            db.SaveChanges();

               if(ajaxuserprefer.loggedin == 1)
               {
                return RedirectToAction("Index", "Student");
               }

              return RedirectToAction("Index", "Account");
        }
Example #2
0
        private static void Main(string[] args)
        {
            _boligScraper = new Scraper();

            _userPreference = GetUserPreference();
            _boligPortalRequest = new BoligPortalRequest
                                      {
                                          Amt = ((int) _userPreference.Region).ToString(),
                                          RentMin = "0",
                                          RentMax = _userPreference.RentMax,
                                          ZipCodes = _userPreference.ZipCodes,
                                          ApartmentType = _userPreference.ApartmentTypes,
                                          RentLength = new List<string> {"4"},
                                          Page = "1",
                                          Limit = "15",
                                          SortCol = "3",
                                          SortDesc = "1"
                                      };

            Console.WriteLine("{0} :: Creating infinite loop\n", DateTime.Now);

            // infinite loop
            while (true)
            {
                Tick();

                Thread.Sleep(120000); // 2 minutes
            }
        }
        public void MapFromUserPreference(UserPreference objectToRentPreference)
        {
            LocalizationPreference temp = JsonConvert.DeserializeObject <LocalizationPreference>(objectToRentPreference.PreferenceDescription);

            this.Latitude         = temp.Latitude;
            this.Longitude        = temp.Longitude;
            this.PreferedDistance = temp.PreferedDistance;
        }
Example #4
0
        public UserPreference Update(UserPreference userPreferenceChanges)
        {
            var userPreference = context.UserPreferences.Attach(userPreferenceChanges);

            userPreference.State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            context.SaveChanges();
            return(userPreference.Entity);
        }
 public static UserPreferenceViewModel ToViewModel(this UserPreference entity)
 {
     return(new UserPreferenceViewModel
     {
         projectName = entity.projectName,
         auth_Token = entity.auth_Token
     });
 }
        public void Preference()
        {
            var model = new ManagementModel();
            var data  = new UserPreference();

            model.Preference = data;
            Assert.AreEqual <UserPreference>(data, model.Preference);
        }
        public void CanCreateApplication()
        {
            var up = new UserPreference();

            Assert.IsFalse(up.CanCreateApplication);
            up.CanCreateApplication = true;
            Assert.IsTrue(up.CanCreateApplication);
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        tempThemePage = this.DDL_ThemePage.SelectedValue;
        tempThemeFrame = this.DDL_ThemeFrame.SelectedValue;

        if (TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE) != null)
        {
            this.DDL_ThemePage.SelectedValue = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE).Value;
        }
        else
        {
            this.DDL_ThemePage.SelectedValue = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE).Value;
        }

        if (TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME) != null)
        {
            this.DDL_ThemeFrame.SelectedValue = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME).Value;
        }
        else
        {
            this.DDL_ThemeFrame.SelectedValue = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME).Value;

        }

        this.DDL_ThemeFrame.DataSource = TheCodeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME);
        this.DDL_ThemeFrame.DataBind();

        this.DDL_ThemePage.DataSource = TheCodeMasterMgr.GetCachedCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE);
        this.DDL_ThemePage.DataBind();

         

        //Language
        up = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, BusinessConstants.CODE_MASTER_LANGUAGE);
        tempLanguage = this.ddlLanguage.SelectedValue;
        if (up != null)
        {
            this.ddlLanguage.Text = up.Value == null ? string.Empty : up.Value;
        }
        else
        {
            this.ddlLanguage.Text = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_LANGUAGE).Value;
        }

        //清除Tab状态
        if (Request.Cookies["TabStatus"] != null && Request.Cookies["TabStatus"].Value == "Theme")
        {
            this.divRefresh.Visible = true;
            Response.Cookies["TabStatus"].Values.Remove("Theme");
            ShowSuccessMessage("Security.UserPreference.Update.Successfully");
        }
        else
        {
            this.divRefresh.Visible = false;
        }


    }
Example #9
0
        private void RefreshClick(object sender, System.EventArgs e)
        {
            if (this.comboBoxInputs.Text.IndexOf(":") == 0)
            {
                return;
            }

            UserPreference.Save("Inputs" + m_db.ToString(), this.comboBoxInputs.Text);

            this.dragPoint1.Active = false;
            Cursor = Cursors.WaitCursor;
            timeSeriesSpreadsheet1.Clear();
            Application.DoEvents();
            try
            {
                dataTable = this.GetTimeSeries();
                dataTable.AcceptChanges();
                dataTable.RowChanged += new DataRowChangeEventHandler(dataTable_RowChanged);
                Logger.WriteLine(UserPreference.Lookup("HydrometServer"), "ui");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Logger.WriteLine("error reading data from " + UserPreference.Lookup("HydrometServer") + " " + ex.ToString(), "ui");
                Logger.WriteLine(ex.ToString());
            }
            finally
            {
                Cursor = Cursors.Default;
            }
            if (dataTable == null)
            {
                return;
            }


            Logger.WriteLine(dataTable.Rows.Count + " rows of data read", "ui");
            if (dataTable.Rows.Count > 0)
            {
                dataTable.WriteXml(originalDataXmlFilename, XmlWriteMode.WriteSchema);
            }

            Graph();

            SetupUsgsLink();
            timeSeriesSpreadsheet1.SetDataTable(dataTable, m_db, true);
            timeSeriesSpreadsheet1.AutoFlagDayFiles = UserPreference.Lookup("AutoFlagDayFiles") == "True";

            //this.comboBoxEditSeries.Items.Clear();
            //this.comboBoxEditSeries.Items.Add("None");
            //for(int i=0; i<tChart1.Series.Count; i++)
            //{
            //    string columnName = tChart1.Series[i].Title;
            //    this.comboBoxEditSeries.Items.Add(columnName);
            //}

            //this.comboBoxEditSeries.SelectedIndex =0;
        }
Example #10
0
        public async Task <ActionResult> DeleteConfirmed(int id)
        {
            UserPreference userPreference = await db.UserPreferences.FindAsync(id);

            db.UserPreferences.Remove(userPreference);
            await db.SaveChangesAsync();

            return(RedirectToAction("Index"));
        }
        public void ConvertNullUser()
        {
            var up = new UserPreference()
            {
                Application = new Application(),
            };

            up.Convert();
        }
        /// <summary>
        /// Returns the instance of BaseListViewSource. Based on Factory method.
        /// </summary>
        /// <param name="listType"></param>
        /// <param name="showCheckBoxColumn"></param>
        /// <param name="dbConnection"></param>
        /// <param name="dbQueries"></param>
        /// <returns></returns>
        public static BaseListViewSource CreateListViewSource(ListViewType listType, DIConnection dbConnection, DIQueries dbQueries)
        {
            BaseListViewSource RetVal            = null;
            UserPreference     DIUserPreferencce = new UserPreference();

            RetVal = ListViewSourceFactory.CreateListViewSource(listType, dbConnection, dbQueries, DIUserPreferencce);

            return(RetVal);
        }
Example #13
0
        /// <summary>
        /// Toggles the favorite status of a thing.
        /// </summary>
        /// <typeparam name="T">The type on which to base the save.</typeparam>
        /// <param name="thing">The thing to persist/remove from persistence</param>
        /// <param name="session">The session in which to persist.</param>
        /// <returns>The empty task.</returns>
        public async Task ToggleFavorite <T>(ISession session, T thing) where T : Thing
        {
            var transaction = new ThingTransaction(TransactionContextResolver.ResolveContext(session.ActivePerson));

            var preferenceShortname = this.GetPreferenceShortname(typeof(T));
            var preference          = this.GetFavoritePreference(session, preferenceShortname);

            var userClone = session.ActivePerson.Clone(false);

            HashSet <Guid> valueSet;

            if (preference == null)
            {
                // if property not there, create it and add
                valueSet = new HashSet <Guid>
                {
                    thing.Iid
                };

                preference = new UserPreference(Guid.NewGuid(), null, null)
                {
                    ShortName = preferenceShortname
                };

                userClone.UserPreference.Add(preference);
                transaction.CreateOrUpdate(userClone);
            }
            else
            {
                // if property is there, see if thing is in the array, true => remove, false => append
                valueSet = this.GetIidsFromUserPreference(preference);

                if (valueSet.Contains(thing.Iid))
                {
                    valueSet.Remove(thing.Iid);
                }
                else
                {
                    valueSet.Add(thing.Iid);
                }

                preference = preference.Clone(false);
            }

            preference.Value = string.Join(",", valueSet);
            transaction.CreateOrUpdate(preference);

            try
            {
                var operationContainer = transaction.FinalizeTransaction();
                await session.Write(operationContainer);
            }
            catch (Exception ex)
            {
                logger.Error("The inline update operation failed: {0}", ex.Message);
            }
        }
Example #14
0
        /// <inheritdoc />
        public DBResult <IEnumerable <UserPreference> > SaveUserPreferences(string hdid, IEnumerable <UserPreference> newPreferences, bool commit = true)
        {
            DBResult <IEnumerable <UserPreference> > preferences = this.GetUserPreferences(hdid);
            DBResult <IEnumerable <UserPreference> > result      = new DBResult <IEnumerable <UserPreference> >();
            List <UserPreference> payload = new List <UserPreference>();

            result.Status  = DBStatusCode.Deferred;
            result.Payload = payload;

            foreach (UserPreference newPreference in newPreferences)
            {
                UserPreference preference = preferences.Payload.FirstOrDefault(p => p.Preference == newPreference.Preference);
                if (preference != null)
                {
                    preference.UpdatedBy       = newPreference.UpdatedBy;
                    preference.UpdatedDateTime = DateTime.UtcNow;
                    preference.Value           = newPreference.Value;
                    payload.Add(preference);
                }
                else
                {
                    this.dbContext.UserPreference.Add(newPreference);
                    payload.Add(newPreference);
                }
            }

            foreach (UserPreference preference in preferences.Payload)
            {
                if (!newPreferences.Any(p => p.Preference == preference.Preference))
                {
                    this.dbContext.UserPreference.Remove(preference);
                }
            }

            if (commit)
            {
                try
                {
                    this.dbContext.SaveChanges();
                    result.Status = DBStatusCode.Updated;
                }
                catch (DbUpdateConcurrencyException e)
                {
                    result.Status  = DBStatusCode.Concurrency;
                    result.Message = e.Message;
                }
                catch (DbUpdateException e)
                {
                    this.logger.LogError($"Unable to update UserPreference to DB {e}");
                    result.Status  = DBStatusCode.Error;
                    result.Message = e.Message;
                }
            }

            return(result);
        }
Example #15
0
        public void Create(UserPreference value)
        {
            using (log.Activity(m => m($"Creating {nameof(UserPreference)} by {Thread.CurrentPrincipal?.Identity?.Name}")))
            {
                using (log.Activity(m => m("Authorization")))
                {
                    try
                    {
                        security.ValidateCreate(value);
                    }
                    catch (UnauthorizedAccessException)
                    {
                        log.Warn($"Authorization Denied");
                        throw;
                    }
                    catch (Exception e)
                    {
                        log.Error($"Authorization Error", e);
                        throw;
                    }
                }

                var entity = null as UserPreference;
                using (log.Activity(m => m("Create Entity")))
                {
                    try
                    {
                        entity = context.UserPreferences.Add(value);
                        context.SaveChanges();
                    }
                    //TODO: KB: Do this on index validation
                    //throw new DuplicateKeyException(value.Name)
                    catch (Exception e)
                    {
                        log.Error($"Update Error", e);
                        throw;
                    }
                }
                var newValue = entity.Filter();

                using (log.Activity(m => m("Emit Event")))
                {
                    try
                    {
                        emitter.OnCreated(newValue);
                    }
                    catch (Exception e)
                    {
                        log.Error($"Emit Event Error", e);
                        throw;
                    }
                }

                log.Info(m => m($"Created {nameof(UserPreference)}[{entity.Id}] by {Thread.CurrentPrincipal?.Identity?.Name}"));
            }
        }
Example #16
0
 private void Init()
 {
     SaveToVMS           = UserPreference.Lookup("SaveToVMS") == "True";
     ComputeDependencies = UserPreference.Lookup("ComputeDependencies") == "True";
     if (m_interval == TimeInterval.Monthly)
     {
         checkBoxDependencies.Enabled = false;
         checkBoxDependencies.Checked = false;
     }
 }
Example #17
0
        /*
         * data members describing user go here
         * need to develop appropriate getters/setters
         */

        static User()
        {
            appPath      = "";
            users        = new List <string>();
            currentUser  = "";
            locationCity = "";
            emailAddr    = "";
            alertPref    = UserPreference.Desktop;
            alerts       = new List <UserAlert>();
        }
Example #18
0
 public UserPreferencesDTO(UserPreference preferences)
 {
     UserId = preferences.User.Id;
     AutoRefreshingFrequency             = preferences.AutoRefreshingFrequency;
     TasksPerPage                        = preferences.TasksPerPage;
     DisplayOnlyTasksWithMyParticipation = preferences.DisplayOnlyTasksWithMyParticipation;
     EnableTasksListAutoRefreshing       = preferences.EnableTasksListAutoRefreshing;
     DisplayTasksRefreshingProgressBar   = preferences.DisplayTasksRefreshingProgressBar;
     HideCanceledTasks                   = preferences.HideCanceledTasks;
 }
Example #19
0
        //public bool AgrimetOptionsVisible
        //{
        //   // get { return this.groupBoxAgrimet.Visible; }
        //    set { this.groupBoxAgrimet.Visible = value; }
        //}


        //public bool ComputeET
        //{
        //    get { return checkBoxET.Checked; }
        //}
        ////public bool SendToWeb
        //{
        //    get { return checkBoxWeb.Checked; }
        //}
        //public bool CropCharts
        //{
        //    get { return checkBoxCropCharts.Checked; }
        //}


        void ReadPreferences()
        {
            this.textBoxUser.Text = UserPreference.Lookup("UserName");
            this.Text             = "Save changes " + UserPreference.Lookup("HydrometServer");

            //  this.checkBoxCropCharts.Checked = (UserPreference.Lookup("BuildCropCharts") == "True");
            //this.checkBoxET.Checked = (UserPreference.Lookup("ComputeET") == "True");
            this.checkBoxArchiver.Checked = (UserPreference.Lookup("RunArchiver") == "True");
//            this.checkBoxWeb.Checked = (UserPreference.Lookup("SendToWeb") == "True");
        }
        public void Country()
        {
            var data = StringHelper.ValidString();
            var up   = new UserPreference()
            {
                Country = data,
            };

            Assert.AreEqual <string>(data, up.Country);
        }
        public void UTCOffset()
        {
            var data = DateTimeOffset.Now;
            var up   = new UserPreference()
            {
                UTCOffset = data,
            };

            Assert.AreEqual <DateTimeOffset?>(data, up.UTCOffset);
        }
        public void Application()
        {
            var app = new Application();
            var up  = new UserPreference()
            {
                Application = app,
            };

            Assert.AreEqual <Application>(app, up.Application);
        }
        public void User()
        {
            var user = new User();
            var up   = new UserPreference()
            {
                User = user,
            };

            Assert.AreEqual <User>(user, up.User);
        }
Example #24
0
 private static void AddUserPreferenceToTable(DataTable table, UserPreference userPreference)
 {
     table.Rows.Add(new object[] {
         1,
         userPreference.PortalId,
         userPreference.UserId,
         userPreference.MessagesEmailFrequency,
         userPreference.NotificationsEmailFrequency,
     });
 }
        public void TimeZone()
        {
            var data = TimeZoneInfo.Utc;
            var up   = new UserPreference()
            {
                TimeZone = data,
            };

            Assert.AreEqual <TimeZoneInfo>(data, up.TimeZone);
        }
Example #26
0
        private static string GetPassword()
        {
            var pw = UserPreference.Lookup("timeseries_database_password", "");

            if (pw != "")
            {
                pw = StringCipher.Decrypt(pw, "");
            }
            return(pw);
        }
        public void TwitterHandle()
        {
            var data = StringHelper.ValidString();
            var up   = new UserPreference()
            {
                TwitterHandle = data,
            };

            Assert.AreEqual <string>(data, up.TwitterHandle);
        }
Example #28
0
 /// <summary>
 /// Set User Preferences of Public Profile
 /// </summary>
 /// <param name="user">User</param>
 public static void Set(this UserPublicProfile profile, UserPreference preferences)
 {
     profile.AbcHandle           = preferences.AbcHandle;
     profile.TwitterHandle       = preferences.TwitterHandle;
     profile.TimeZone            = preferences.TimeZone;
     profile.GitHubHandle        = preferences.GitHubHandle;
     profile.Country             = preferences.Country;
     profile.City                = preferences.City;
     profile.ApplicationsMaximum = preferences.MaximumAllowedApplications ?? 1;
 }
        public UserPreference Update(UserPreference userPreferenceChanges)
        {
            UserPreference userPreferenceToUpdate = GetPreference(userPreferenceChanges.userId, userPreferenceChanges.imageId);

            if (userPreferenceToUpdate != null)
            {
                userPreferenceToUpdate.preference = userPreferenceChanges.preference;
            }

            return(userPreferenceToUpdate);
        }
Example #30
0
        public async Task CreateUserPreferenceColumnAsync(UserPreference userPreference)
        {
            var queryParameters = new DynamicParameters();

            queryParameters.Add("@UserId", userPreference.UserId);
            queryParameters.Add("@CompanyId ", userPreference.Company);
            queryParameters.Add("@UIComponentCode ", userPreference.ComponentId);
            queryParameters.Add("@ColumnConfig", userPreference.ColumnConfig);

            await ExecuteNonQueryAsync(StoredProcedureNames.CreateUserPreferenceColumns, queryParameters, true);
        }
        protected override async Task <Domain.Models.UserPreference> GetData()
        {
            UserPreference pref = null;

            using (var db = new Repository(User))
            {
                var nameToUse = UserNameToUse;
                pref = await db.GetUserPreferences(nameToUse);
            }
            return(pref.Map());
        }
Example #32
0
        public SnowGG()
        {
            InitializeComponent();
            this.comboBoxCbtt.Text  = UserPreference.Lookup("Snowgg->cbtt");
            this.comboBoxPcode.Text = UserPreference.Lookup("Snowgg->pcode");


            Reset();
            this.timeSeriesGraph1.AfterEditGraph  += timeSeriesGraph1_AfterEditGraph;
            timeSeriesGraph1.AnnotationOnMouseMove = true;
        }
        public void GenerateUsers(int count = 10)
        {
            var repository = DependencyResolver.Current.GetService <IRepository>();

            var cities = repository.Cities.ToList();

            for (int i = 0; i < count; i++)
            {
                var city      = cities.OrderBy(p => Guid.NewGuid()).FirstOrDefault();
                var firstName = Name.GetRandom();
                var lastName  = Surname.GetRandom();

                var user = new User()
                {
                    CityID      = city.ID,
                    FirstName   = string.Format("{0} {1}", firstName, lastName),
                    Password    = "******",
                    Description = Textarium.GetRandomText(1).Teaser(250),
                    Birthday    = GetRandomBirthDay(18, 75),
                    AvatarPath  = Imaginarium.SaveRandomImage("/Content/files/avatars/"),
                    Sex         = rand.Next(2) == 1,
                    Height      = rand.Next(30) + 160,
                    Weight      = rand.Next(40) + 50,
                    Rating      = rand.Next(1000)
                };
                user.Email = Email.GetRandom(firstName, lastName);
                user.Login = user.Email;
                repository.CreateUser(user);
                Console.WriteLine("Создан человечек : " + user.FirstName);
                var status     = Textarium.GetRandomText(1).Teaser(120, "...");
                var userStatus = new UserStatus()
                {
                    UserID = user.ID,
                    Text   = status,
                };
                repository.CreateUserStatus(userStatus);
                Console.WriteLine("Человечек " + user.FirstName + " сделал статус: " + userStatus.Text);

                var max         = rand.Next(3) + 3;
                var preferences = repository.Preferences.ToList();
                for (int j = 0; j < max; j++)
                {
                    var preference     = preferences.OrderBy(p => Guid.NewGuid()).First();
                    var userPreference = new UserPreference()
                    {
                        UserID       = user.ID,
                        PreferenceID = preference.ID
                    };
                    repository.CreateUserPreference(userPreference);
                    Console.WriteLine("Человечек " + user.FirstName + " любит : " + preference.Name);
                }
            }
            Assert.AreEqual(0, 0);
        }
Example #34
0
        private static void HandleEmail(BoligPortalResponse boligPortalResponse, string id,
                                        UserPreference userPreference)
        {
            BoligPortalProperty boligPortalProperty = boligPortalResponse.Properties.SingleOrDefault(p => p.Id == id);

            if (boligPortalProperty == null)
                return;

            _boligScraper.SendEmail(boligPortalProperty, userPreference);

            Console.WriteLine(string.Format("{0} :: Send email for '{1}' to '{2}'", DateTime.Now, boligPortalProperty.Id, userPreference.Email));
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     up = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, BusinessConstants.CODE_MASTER_LANGUAGE);
     tempvalue = this.ddlLanguage.SelectedValue;
     if (up != null)
     {
         this.ddlLanguage.Text = up.Value;
     }
     else
     {
         this.ddlLanguage.Text = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_LANGUAGE).Value;
     }
 }
Example #36
0
 protected void DDL_CSModule_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (upCS == null)
     {
         upCS = new UserPreference();
         upCS.User = this.CurrentUser;
         upCS.Code = BusinessConstants.PERMISSION_CATEGORY_TERMINAL;
         upCS.Value = this.ddlCSModule.SelectedValue;
         TheUserPreferenceMgr.CreateUserPreference(upCS);
     }
     else
     {
         upCS.Value = this.ddlCSModule.SelectedValue;
         TheUserPreferenceMgr.UpdateUserPreference(upCS);
     }
     ShowSuccessMessage("Security.UserPreference.Update.Successfully");
     //SavetabStatus();
 }
Example #37
0
    protected override void InitializeCulture()
    {
        this.language = this.CurrentUser.UserLanguage;
        if (this.language == null || this.language.Trim() == string.Empty)
        {
            this.language = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_DEFAULT_LANGUAGE).Value;
            this.CurrentUser.UserLanguage = this.language;

            UserPreference usrpf = new UserPreference();
            usrpf.User = this.CurrentUser;
            usrpf.Code = BusinessConstants.CODE_MASTER_LANGUAGE;
            usrpf.Value = this.language;
            TheUserPreferenceMgr.CreateUserPreference(usrpf);
        }

        Thread.CurrentThread.CurrentUICulture = new CultureInfo(this.language);

        //Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
    }
Example #38
0
 protected void DDL_Language_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (up == null)
     {
         up = new UserPreference();
         up.User = this.CurrentUser;
         up.Code = BusinessConstants.CODE_MASTER_LANGUAGE;
         up.Value = tempLanguage;
         TheUserPreferenceMgr.CreateUserPreference(up);
         this.ddlLanguage.Text = tempLanguage;
     }
     else
     {
         up.Value = tempLanguage;
         TheUserPreferenceMgr.UpdateUserPreference(up);
         this.ddlLanguage.Text = tempLanguage;
     }
     this.CurrentUser.UserLanguage = tempLanguage;
     SavetabStatus();
 }
Example #39
0
    protected override void InitializeCulture()
    {
        if (this.CurrentUser.UserLanguage == null || this.CurrentUser.UserLanguage.Trim() == string.Empty)
        {
            string userLanguage = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_LANGUAGE).Value;
            this.CurrentUser.UserLanguage = userLanguage;
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(userLanguage);

            UserPreference usrpf = new UserPreference();
            usrpf.User = this.CurrentUser;
            usrpf.Code = BusinessConstants.CODE_MASTER_LANGUAGE;
            usrpf.Value = userLanguage;
            TheUserPreferenceMgr.CreateUserPreference(usrpf);
        }
        else
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(this.CurrentUser.UserLanguage);
        }

        //Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
    }
Example #40
0
    protected void DDL_ThemeFrame_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.DDL_ThemeFrame.SelectedValue != tempThemeFrame)
        {
            this.DDL_ThemeFrame.SelectedValue = tempThemeFrame;
            UserPreference usrpf = new UserPreference();
            usrpf.User = this.CurrentUser;
            usrpf.Code = BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME;
            usrpf.Value = this.DDL_ThemeFrame.SelectedValue;
            TheUserPreferenceMgr.UpdateUserPreference(usrpf);

            HttpCookie cookiePicDate = new HttpCookie("RandomPicDate");
            HttpCookie cookieThemeFrame = new HttpCookie("ThemeFrame");
            switch (this.DDL_ThemeFrame.SelectedValue)
            {
                case "Picture":
                    string picDate = (Request.Cookies["PicDate"] == null) ? Request.Cookies["RandomPicDate"].Value : Request.Cookies["PicDate"].Value;
                    picDate = (picDate == null) ? ThemeHelper.GetRandomDate() : picDate;
                    cookiePicDate.Value = picDate;
                    Response.Cookies.Add(cookiePicDate);
                    cookieThemeFrame.Value = string.Empty;
                    Response.Cookies.Add(cookieThemeFrame);
                    break;
                case "Random":
                    cookieThemeFrame.Value = TheCodeMasterMgr.GetRandomTheme("ThemeFrame");
                    Response.Cookies.Add(cookieThemeFrame);
                    break;
                default:
                    cookieThemeFrame.Value = this.DDL_ThemeFrame.SelectedValue;
                    Response.Cookies.Add(cookieThemeFrame);
                    break;
            }
            this.CurrentUser.UserThemeFrame = this.DDL_ThemeFrame.SelectedValue;
        }
        SavetabStatus();
    }
Example #41
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DisplayFilterValueArgs"/> class.
 /// </summary>
 /// <param name="userPreference">The user preference.</param>
 public DisplayFilterValueArgs( UserPreference userPreference )
 {
     Key = userPreference.Key;
     Name = userPreference.Name;
     Value = userPreference.Value;
 }
Example #42
0
        private void ProcessLoginEvent(string userCode, string password)
        {
            try
            {
                User user = TheSmartDeviceMgr.LoadUser(userCode);
                if (user != null && user.Password.ToUpper() == password.ToUpper())
                {
                    this.user = user;

                    userPreference = TheSmartDeviceMgr.LoadUserPerference(user.Code,
                        BusinessConstants.CODE_MASTER_PERMISSION_CATEGORY_TYPE_VALUE_TERMINAL);
                    string moduleType;
                    if (userPreference == null || userPreference.Value == null || userPreference.Value == string.Empty
                        || userPreference.Value == BusinessConstants.TRANSFORMER_MODULE_TYPE_SELECTION)
                    {
                        moduleType = BusinessConstants.TRANSFORMER_MODULE_TYPE_SELECTION;
                    }
                    else
                    {
                        moduleType = userPreference.Value;
                    }
                    this.SwitchModule(moduleType);
                }
                else
                {
                    Utility.ShowMessageBox("验证失败");
                    this.ucLogin.InitialLogin();
                }
            }
            catch (Exception ex)
            {
                Utility.ShowMessageBox(ex.Message);
            }
        }
Example #43
0
        private static UserPreference GetUserPreference()
        {
            var region = AppSettingsHelper.GetValue<string>("Region");
            var regionEnum = (RegionEnum) Enum.Parse(typeof (RegionEnum), region, true);

            var userPreference = new UserPreference
                                     {
                                         Region = regionEnum,
                                         Email = AppSettingsHelper.GetValue<string>("Email"),
                                         RentMax = AppSettingsHelper.GetValue<string>("RentMax"),
                                         ZipCodes = GetZipCodes(),
                                         ApartmentTypes = GetApartmentTypes()
                                     };

            Console.WriteLine(string.Format("{0} ::\nRegion: {1}\n Email: {2}\n RentMax: {3}\n ZipCodes: {4}\n ApartmentTypes: {5}\n", DateTime.Now, userPreference.Region, userPreference.Email, userPreference.RentMax, AppSettingsHelper.GetValue<string>("ZipCodes"), AppSettingsHelper.GetValue<string>("ApartmentTypes")));

            return userPreference;
        }
Example #44
0
        public async Task<ActionResult> Edit(EditUserViewModel model)
        {
            var dbmgtm = new ApplicationDbContext();
            if (ModelState.IsValid)
            {
                var user = await UserManager.FindByNameAsync(model.UserName);

                user.Email = model.Email;
                user.FirstName = model.FirstName;
                user.LastName = model.LastName;

                using (var securitytrans = dbmgtm.Database.BeginTransaction())
                {

                    //try
                    //{
                    
                        IdentityResult result;
                        result = await UserManager.UpdateAsync(user);

                        if (result.Succeeded)
                        {
                            
                            if(model.AcademicYearID > 0 && model.SchoolID > 0 )
                            { 
                                var userid = dbmgtm.UserPreferences.Where(a => a.UserName == model.UserName).Select(x => new { x.UserID }).FirstOrDefault();
                                UserPreference up = new UserPreference();
                                up.UserID = userid.UserID;
                                up.SchoolRefID = model.SchoolID;
                                up.AcademicYearRefID = model.AcademicYearID;

                                dbmgtm.UserPreferences.Attach(up);
                                dbmgtm.Entry(up).Property("SchoolRefID").IsModified = true;
                                dbmgtm.Entry(up).Property("AcademicYearRefID").IsModified = true;
                                //dbmgtm.Entry(up).State = EntityState.Modified;
                            
                                await dbmgtm.SaveChangesAsync();
                            
                                securitytrans.Commit();
                                return RedirectToAction("Index", "Account");
                              }
                            else
                            {
                                securitytrans.Rollback();
                                return RedirectToAction("Index", "Account");

                            }
                            //await SignInAsync(user, isPersistent: false);
                            
                        }

                //        else
                //        {
                //            ModelState.AddModelErrsor(string.Empty, "There are error in the form");
                //        }
                //    }
                //    catch (Exception e)
                //    {
                //        securitytrans.Rollback();
                //        ModelState.AddModelError(e.Message, "There are error in the form");
                //    }
                        //return View(model);
                }
                  
            }
            ViewBag.SchoolID = new SelectList(dbmgtm.Schools.AsNoTracking().Select(x => new { x.SchoolID, x.SchoolName }), "SchoolID", "SchoolName",model.SchoolID);
            ViewBag.AcademicYearID = new SelectList(dbmgtm.AcademicYears.AsNoTracking().Select(x => new { x.AcademicYearID, x.DisplayYear }), "AcademicYearID", "DisplayYear",model.AcademicYearID);

            return View(model);
        }
Example #45
0
        /// <summary>
        /// Perform SubTotal Calculations
        /// </summary>
        /// <param name="userPreference"></param>
        /// <param name="lastAreaLevel">Last area Level ,It is milastAreaLevel in UI application </param>
        /// <param name="Step2SelectionDataTable">Data Table having Step 2 selections of area level</param>
        public void FillSubtotalSummaryLog(UserPreference.UserPreference userPreference, Int32 lastAreaLevel, DataTable Step2SelectionDataTable)
        {
            try
            {
                //Required Information: UserPreferance
                //milastAreaLevel from set level method
                //Step 2 selections of area level

                this.RaiseEventSetCursor(false);
                IWorksheet SummarySheet;
                IWorksheet LogSheet;
                int i = 0;
                int j = 0;
                int k = 0;
                int iAreaCount = 0;
                int iCtrFillFrom = 0;
                int iCtrFillTo = 0;
                int iDataCol = 0;
                string sOrgRowFilter = "";
                string Str = string.Empty;
                DataView dvSubgroup;

                //*** Initialize Progress Bar
                this.RaiseEventSetProgress(1);

                // Copy Log to temp location
                if (File.Exists(this.LogFilePath))
                {
                    File.Copy(this.LogFilePath, this.TempLogFilePath, true);
                    System.IO.File.SetAttributes(TempLogFilePath, FileAttributes.Normal);
                }

                ApplyLanguageSettings();

                //  Opening and getting workbook
                this.DIExcel = new DIExcel(TempLogFilePath);
                SummarySheet = this.DIExcel.GetWorksheet(0);
                LogSheet = this.DIExcel.GetWorksheet(1);
                SummarySheet.Name = LangStrings.SUMMARY;
                LogSheet.Name = LangStrings.LOG;

                //*************************** SHOW INDEX ******************************************
                this.RaiseEventSetProgress(10);

                // Get presentation data
                DataView dvMain = this.PresentationData;

                //Get subgroup details using user selection
                Str = this.DBQueries.Calculates.Indicator_Subgroup_Selected(true, userPreference.UserSelection, userPreference.Database.SelectedConnectionDetail.ServerType);
                dvSubgroup = this.DBConnection.ExecuteDataTable(Str).DefaultView;

                ////Get area details using user selection
                Str = this.DBQueries.Area.GetArea(Lib.DI_LibDAL.Queries.FilterFieldType.NId, userPreference.UserSelection.AreaNIds);
                DataView dvArea = this.DBConnection.ExecuteDataTable(Str).DefaultView;

                //Getting Log array. //*** Data Array for Log Sheet 'dvArea.Count for blank rows
                string[,] msLogArray = new string[dvMain.Count + dvArea.Count + 2, 8];

                //Use Filter Indicator NId form indicator selected in step 1
                dvSubgroup.RowFilter = Indicator.IndicatorNId + " = " + Convert.ToInt32(this.Step1SelectionDataTable.Rows[0][Indicator.IndicatorNId]);//  lv4_1_Selected.Items(0).Tag;
                StringCollection oSubgroup = new StringCollection();
                StringCollection oSubgroupVal = new StringCollection();
                StringCollection oSubgroupGId = new StringCollection();

                for (k = 0; k <= dvSubgroup.Count - 1; k++)
                {
                    // add subgroup and subgroup gid into subgroup collection
                    if (oSubgroup.Count > 0)
                    {
                        //oSubgroup.Add((string)dvSubgroup[k]["Subgroup_Val_NId"]) give error unable to convert int to string
                        if (oSubgroup.Contains(Convert.ToInt32(dvSubgroup[k][SubgroupVals.SubgroupValNId]).ToString()) == false)
                        {
                            //oSubgroup.Add((string)dvSubgroup[k]["Subgroup_Val_NId"]);
                            oSubgroup.Add(Convert.ToInt32(dvSubgroup[k][SubgroupVals.SubgroupValNId]).ToString());
                            oSubgroupVal.Add((string)dvSubgroup[k][SubgroupVals.SubgroupVal]);
                        }
                    }
                    else
                    {
                        oSubgroup.Add(Convert.ToInt32(dvSubgroup[k][SubgroupVals.SubgroupValNId]).ToString());
                        oSubgroupVal.Add((string)dvSubgroup[k][SubgroupVals.SubgroupVal]);
                    }
                }

                string PrevAreaId = "";
                int iAreaParentNId = 0;

                ArrayList ArrAreaNId = new ArrayList();
                Hashtable AreaCol = new Hashtable();
                string sSource = string.Empty;
                string sTimePeriod = string.Empty;

                //* Data Filters
                if (dvMain.RowFilter == "")
                {
                    sOrgRowFilter = "";
                }
                else
                {
                    sOrgRowFilter = dvMain.RowFilter + " AND ";
                }

                // Add selected area indicator and last area level in filter. So if area level is 3
                dvMain.RowFilter = sOrgRowFilter + Indicator.IndicatorNId + " = " + Convert.ToInt32(this.Step1SelectionDataTable.Rows[0][Indicator.IndicatorNId]) + " AND Area_Level=" + lastAreaLevel;
                dvMain.Sort = Timeperiods.TimePeriod + " DESC"; // GetMostRecent Data

                foreach (DataRowView drv in dvMain)
                {
                    //*** Fill Datavalue for Numerator Indicator against each AreaID
                    dvArea.RowFilter = Area.AreaNId + "=" + Convert.ToInt32(drv[Area.AreaNId]);
                    iAreaParentNId = Convert.ToInt32(dvArea[0][Area.AreaParentNId]);
                    dvArea.RowFilter = Area.AreaNId + "=" + iAreaParentNId;
                    if (AreaCol.ContainsKey(iAreaParentNId) == false)
                    {
                        ArrAreaNId.Add(iAreaParentNId);
                        AreaCol.Add(iAreaParentNId, 0);
                        AreaCol[iAreaParentNId] = new Hashtable();
                        for (k = 0; k <= oSubgroup.Count - 1; k++)
                        {
                            ((Hashtable)AreaCol[iAreaParentNId]).Add((string)oSubgroup[k], 0);
                        }
                    }
                     ((Hashtable)AreaCol[iAreaParentNId])[(int)drv[SubgroupVals.SubgroupValNId]] = Convert.ToDouble(((Hashtable)AreaCol[iAreaParentNId])[(int)drv["Subgroup_Val_NId"]]) + Convert.ToDouble(drv["Data_Value"]);

                    //((Hashtable)AreaCol[iAreaParentNId])[(string)drv["Subgroup_Val_NId"]] = (int)((Hashtable)AreaCol[iAreaParentNId](string)drv["Subgroup_Val_NId"]]  + (int)drv["Data_Value"];
                    sSource = drv[IndicatorClassifications.ICName].ToString();
                    sTimePeriod = drv[Timeperiods.TimePeriod].ToString();
                }

                //*** BugFix 10 Aug 2006 Skipping of areas without child nodes at last level
                dvMain.RowFilter = sOrgRowFilter + Indicator.IndicatorNId + " = " + Convert.ToInt32(this.Step1SelectionDataTable.Rows[0][Indicator.IndicatorNId]) + " AND Area_Level=" + Convert.ToString(lastAreaLevel - 1);
                dvMain.Sort = Timeperiods.TimePeriod + " DESC";
                //*** GetMostRecent Data
                foreach (DataRowView drv in dvMain)
                {
                    //*** Fill Datavalue for Numerator Indicator against each AreaID
                    if (AreaCol.Count > 0)
                    {
                        if (AreaCol.ContainsKey(drv[Area.AreaNId]) == false)
                        {
                            ArrAreaNId.Add(drv[Area.AreaNId]);
                            AreaCol.Add(drv[Area.AreaNId], 0);
                            AreaCol[drv[Area.AreaNId]] = new Hashtable();
                            for (k = 0; k <= oSubgroup.Count - 1; k++)
                            {
                                ((Hashtable)AreaCol[drv[Area.AreaNId]]).Add((string)oSubgroup[k], 0);
                            }
                        }

                    }
                    else
                    {
                        ArrAreaNId.Add(drv[Area.AreaNId]);
                        AreaCol.Add(drv[Area.AreaNId], 0);
                        AreaCol[drv[Area.AreaNId]] = new Hashtable();
                        for (k = 0; k <= oSubgroup.Count - 1; k++)
                        {
                            ((Hashtable)AreaCol[drv[Area.AreaNId]]).Add((string)oSubgroup[k], 0);
                        }

                    }

                    ((Hashtable)AreaCol[drv[Area.AreaNId]])[(int)drv[SubgroupVals.SubgroupValNId]] = Convert.ToDouble(drv["Data_Value"]);
                }

                ArrayList ArrAreaNIdOrg = new ArrayList();
                ArrAreaNIdOrg = ArrAreaNId;
                Hashtable AreaColOrg = new Hashtable();
                AreaColOrg = AreaCol;

                //----------------------- Retrive the index count before declaring array --------------
                i = 2;
                object ColItem;
                int iDataArrCtr = 0;
                for (j = lastAreaLevel - 1; j >= 1; j += -1)
                {
                    //?? 1 may not be the top level
                    Hashtable AreaColTemp = new Hashtable();
                    ArrayList ArrAreaNIdTemp = new ArrayList();
                    for (int l = 0; l <= ArrAreaNId.Count - 1; l++)
                    {
                        ColItem = AreaCol[ArrAreaNId[l]];
                        dvArea = null;
                        string sSql = string.Empty;
                        sSql = this.DBQueries.Area.GetArea(Lib.DI_LibDAL.Queries.FilterFieldType.NId, ((int)ArrAreaNId[l]).ToString());
                        dvArea = this.DBConnection.ExecuteDataTable(sSql).DefaultView;

                        iAreaParentNId = Convert.ToInt32(dvArea[0][Area.AreaParentNId]);
                        if (AreaColTemp.Count == 0 || AreaColTemp.ContainsKey(iAreaParentNId) == false)
                        {
                            ArrAreaNIdTemp.Add(iAreaParentNId);
                            AreaColTemp.Add(iAreaParentNId, 0);
                            AreaColTemp[iAreaParentNId] = new Hashtable();
                        }
                        if (Step2SelectionDataTable.Rows[j - 1]["Checked"].ToString().Trim().Length > 0 && Convert.ToBoolean(Step2SelectionDataTable.Rows[j - 1]["Checked"]) == true)
                        {
                            for (k = 0; k <= oSubgroup.Count - 1; k++)
                            {
                                iDataArrCtr += 1;
                            }
                            i += 1;
                        }
                    }

                    dvMain.RowFilter = sOrgRowFilter + Indicator.IndicatorNId + " = " + Convert.ToInt32(this.Step1SelectionDataTable.Rows[0][Indicator.IndicatorNId]) + " AND Area_Level=" + Convert.ToString(j - 1);
                    dvMain.Sort = Timeperiods.TimePeriod + " DESC";
                    //*** GetMostRecent Data
                    foreach (DataRowView drv in dvMain)
                    {
                        //*** Fill Datavalue for Numerator Indicator against each AreaID
                        if (AreaColTemp.Count == 0 || AreaColTemp.ContainsKey(drv[Area.AreaNId]) == false)
                        {
                            ArrAreaNIdTemp.Add(Convert.ToInt32(drv[Area.AreaNId]));
                            AreaColTemp.Add(Convert.ToInt32(drv[Area.AreaNId]), 0);
                            AreaColTemp[drv[Area.AreaNId]] = new Hashtable();
                            for (k = 0; k <= oSubgroup.Count - 1; k++)
                            {
                                ((Hashtable)AreaColTemp[drv[Area.AreaNId]]).Add((string)oSubgroup[k], 0);
                            }
                        }
                    }
                    ArrAreaNId = ArrAreaNIdTemp;
                    AreaCol = AreaColTemp;
                }

                ArrAreaNId = ArrAreaNIdOrg;
                AreaCol = AreaColOrg;
                //-----------------------------------------------------------------------------------

                //--------------------- Declare Array -----------------------------------------------
                string[,] msSummaryArray = new string[i - 1 + 3, 1 + oSubgroup.Count + 1];
                string[,] msTempDataArray = new string[iDataArrCtr, 6];

                msSummaryArray[0, 0] = LangStrings.AREAID;
                msSummaryArray[0, 1] = LangStrings.AREANAME;
                for (k = 0; k <= oSubgroup.Count - 1; k++)
                {
                    dvSubgroup.RowFilter = SubgroupVals.SubgroupValNId + " =" + Convert.ToInt32(oSubgroup[k]);
                    msSummaryArray[0, 2 + k] = dvSubgroup[0][SubgroupVals.SubgroupVal].ToString();
                }

                i = 2;
                iDataArrCtr = 0;
                for (j = lastAreaLevel - 1; j >= 1; j += -1)
                {
                    //??? 1 may not be the top level
                    Hashtable AreaColTemp = new Hashtable();
                    ArrayList ArrAreaNIdTemp = new ArrayList();

                    for (int l = 0; l <= ArrAreaNId.Count - 1; l++)
                    {
                        ColItem = AreaCol[ArrAreaNId[l]];
                        dvArea = null;

                        string sSql = string.Empty;
                        sSql = this.DBQueries.Area.GetArea(Lib.DI_LibDAL.Queries.FilterFieldType.NId, ArrAreaNId[l].ToString());
                        dvArea = this.DBConnection.ExecuteDataTable(sSql).DefaultView;

                        //if (lv4_2_Level.Items(j - 1).Checked)
                        if (Step2SelectionDataTable.Rows[j - 1]["Checked"].ToString().Trim().Length > 0 && Convert.ToBoolean(Step2SelectionDataTable.Rows[j - 1]["Checked"]) == true)
                        {
                            msSummaryArray[i, 0] = dvArea[0][Area.AreaID].ToString();
                            msSummaryArray[i, 1] = dvArea[0][Area.AreaName].ToString();
                        }
                        // Get Parent area Nid
                        iAreaParentNId = Convert.ToInt32(dvArea[0][Area.AreaParentNId]);
                        if (AreaColTemp.Count == 0 || AreaColTemp.ContainsKey(iAreaParentNId) == false)
                        {
                            ArrAreaNIdTemp.Add(iAreaParentNId);
                            AreaColTemp.Add(iAreaParentNId, 0);
                            AreaColTemp[iAreaParentNId] = new Hashtable();
                            for (k = 0; k <= oSubgroup.Count - 1; k++)
                            {
                                ((Hashtable)AreaColTemp[iAreaParentNId]).Add(Convert.ToInt32(oSubgroup[k]), 0);
                            }
                        }

                        //if (lv4_2_Level.Items(j - 1).Checked)
                        if (Step2SelectionDataTable.Rows[j - 1]["Checked"].ToString().Trim().Length > 0 && Convert.ToBoolean(Step2SelectionDataTable.Rows[j - 1]["Checked"]) == true)
                        {
                            for (k = 0; k <= oSubgroup.Count - 1; k++)
                            {
                                msSummaryArray[i, k + 2] = Convert.ToString(((Hashtable)AreaCol[ArrAreaNId[l]])[(Convert.ToInt32(oSubgroup[k]))]);
                                msTempDataArray[iDataArrCtr, 0] = sTimePeriod;
                                msTempDataArray[iDataArrCtr, 1] = dvArea[0][Area.AreaID].ToString();
                                msTempDataArray[iDataArrCtr, 2] = dvArea[0][Area.AreaName].ToString();
                                msTempDataArray[iDataArrCtr, 3] = msSummaryArray[i, k + 2].ToString();
                                msTempDataArray[iDataArrCtr, 4] = (string)oSubgroupVal[k];
                                msTempDataArray[iDataArrCtr, 5] = sSource;
                                iDataArrCtr += 1;

                                //*** Bugfix 19 Apr 2007 Error for very high datavalue due to usage of CINT
                                //CType(AreaColTemp.Item(iAreaParentNId), Hashtable).Item(CStr(oSubgroup.Item(k))) =
                                //(CType(AreaColTemp.Item(iAreaParentNId), Hashtable).Item(CStr(oSubgroup.Item(k)))) +
                                //(CType(AreaCol.Item(ArrAreaNId(l)), Hashtable).Item(CStr(oSubgroup.Item(k))))
                                ((Hashtable)AreaColTemp[iAreaParentNId])[Convert.ToInt32(oSubgroup[k])] =
                                     Convert.ToDouble(((Hashtable)AreaColTemp[iAreaParentNId])[Convert.ToInt32(oSubgroup[k])]) + Convert.ToDouble(((Hashtable)AreaCol[ArrAreaNId[l]])[Convert.ToInt32(oSubgroup[k])]);
                            }
                            i += 1;
                        }
                    }

                    //*** BugFix 10 Aug 2006 Skipping of areas without child nodes at last level
                    //dvMain.RowFilter = sOrgRowFilter + "Indicator_NId = " + lv4_1_Selected.Items(0).Tag + " AND Area_Level=" + j - 1;
                    dvMain.RowFilter = sOrgRowFilter + Indicator.IndicatorNId + " = "
                        + Convert.ToInt32(this.Step1SelectionDataTable.Rows[0][Indicator.IndicatorNId]) + " AND " + Area_Level.AreaLevel + " =" + Convert.ToString(j - 1);
                    dvMain.Sort = Timeperiods.TimePeriod + " DESC";
                    //*** GetMostRecent Data
                    foreach (DataRowView DataviewRow in dvMain)
                    {
                        //*** Fill Datavalue for Numerator Indicator against each AreaID
                        if (AreaColTemp.ContainsKey(DataviewRow[Area.AreaNId]) == false)
                        {
                            ArrAreaNIdTemp.Add(DataviewRow[Area.AreaNId].ToString());
                            AreaColTemp.Add(DataviewRow[Area.AreaNId], 0);
                            AreaColTemp[Convert.ToInt32(DataviewRow[Area.AreaNId])] = new Hashtable();
                            for (k = 0; k <= oSubgroup.Count - 1; k++)
                            {
                                ((Hashtable)AreaColTemp[DataviewRow[Area.AreaNId]]).Add((string)oSubgroup[k], 0);
                            }
                        }
                        //*** Overwrite the subtotal achieved through cumulation, if data for an area exists.
                        ((Hashtable)AreaColTemp[DataviewRow[Area.AreaNId]])[Convert.ToInt32(DataviewRow[SubgroupVals.SubgroupValNId])] = Convert.ToDouble(DataviewRow[Data.DataValue]);
                    }
                    ArrAreaNId = ArrAreaNIdTemp;
                    AreaCol = AreaColTemp;
                }

                //Finish button error - SubTotal
                msDataArray = new string[iDataArrCtr, 6];
                for (i = 0; i <= iDataArrCtr - 1; i++)
                {
                    for (j = 0; j <= 5; j++)
                    {
                        msDataArray[i, j] = msTempDataArray[i, j].ToString();
                    }
                }

                msLogArray[0, 0] = LangStrings.AREAID;
                msLogArray[0, 1] = LangStrings.AREANAME;
                msLogArray[0, 2] = LangStrings.INDICATOR;
                msLogArray[0, 3] = LangStrings.SUBGROUP;
                msLogArray[0, 4] = LangStrings.TIME;
                msLogArray[0, 5] = LangStrings.DATAVALUE;
                msLogArray[0, 6] = LangStrings.UNIT;
                msLogArray[0, 7] = LangStrings.SOURCE;

                PrevAreaId = "";
                i = 1;

                dvMain.RowFilter = sOrgRowFilter + Indicator.IndicatorNId + " = " + Convert.ToInt32(this.Step1SelectionDataTable.Rows[0][Indicator.IndicatorNId]);// lv4_1_Selected.Items(0).Tag;
                dvMain.GetEnumerator().Reset();
                dvMain.Sort = " Area_ID";

                foreach (DataRowView drv in dvMain)
                {
                    if (PrevAreaId != drv[Area.AreaID].ToString())
                    {
                        i += 1;
                        PrevAreaId = drv[Area.AreaID].ToString();
                        msLogArray[i, 0] = drv[Area.AreaID].ToString();
                        msLogArray[i, 1] = drv[Area.AreaName].ToString();
                    }
                    msLogArray[i, 2] = drv[Indicator.IndicatorName].ToString();
                    msLogArray[i, 3] = drv[SubgroupVals.SubgroupVal].ToString();
                    msLogArray[i, 4] = drv[Timeperiods.TimePeriod].ToString();
                    msLogArray[i, 5] = drv[Data.DataValue].ToString();
                    msLogArray[i, 6] = drv[Unit.UnitName].ToString();
                    msLogArray[i, 7] = drv[IndicatorClassifications.ICName].ToString();
                    i += 1;
                }

                //*** Special Handling for Subgroup in SubTotal
                this.DESheetInformation.Subgroup = new string[oSubgroup.Count];
                this.DESheetInformation.SubgroupGUID = new string[oSubgroup.Count];
                for (i = 0; i <= oSubgroup.Count - 1; i++)
                {
                    string sSql = string.Empty;
                    sSql = this.DBQueries.Subgroup.GetSubgroupVals(Lib.DI_LibDAL.Queries.FilterFieldType.NId, oSubgroup[i].ToString());
                    dvMain = this.DBConnection.ExecuteDataTable(sSql).DefaultView;

                    this.DESheetInformation.Subgroup[i] = dvMain[0][SubgroupVals.SubgroupVal].ToString();
                    if (dvMain.Count > 0)
                    {
                        this.DESheetInformation.SubgroupGUID[i] = dvMain[0][SubgroupVals.SubgroupValGId].ToString();
                    }
                    else
                    {
                        this.DESheetInformation.SubgroupGUID[i] = Guid.NewGuid().ToString();
                    }
                }

                SummarySheet.Cells[0, 0].Value = LangStrings.VAR_WIZARD_NAME;
                SummarySheet.Cells[2, 0].Value = LangStrings.sMODULE;
                SummarySheet.Cells[2, 1].Value = LangStrings.VAR_WIZARD_NAME;

                SummarySheet.Cells[3, 0].Value = LangStrings.DATE_TIME;
                SummarySheet.Cells[3, 1].Value = TimeStamp;

                SummarySheet.Cells[4, 0].Value = LangStrings.LOG_FILE_NAME;
                SummarySheet.Cells[4, 1].Value = "Log_Subtotal (" + TimeStamp + ").xls";

                SummarySheet.Cells[8, 2].Value = this.DESheetInformation.Indicator;
                this.RaiseEventSetProgress(25);

                //*** Set Data
                iDataCol = 2 + oSubgroup.Count;
                iCtrFillFrom = 9; //10;
                iCtrFillTo = iCtrFillFrom + msSummaryArray.GetLength(0) - 1;

                SummarySheet.Range[iCtrFillFrom, 0, iCtrFillTo, iDataCol - 1].Value = msSummaryArray;
                this.RaiseEventSetProgress(35);

                //Fill Data Values and Formula for each records
                //*** Setting the Font
                SummarySheet.Range[0, 0, iCtrFillTo, iDataCol - 1].Font.Name = this.FontName;
                SummarySheet.Range[0, 0, iCtrFillTo, iDataCol - 1].Font.Size = (float)this.FontSize;
                SummarySheet.Range[iCtrFillFrom, 0, iCtrFillTo, iDataCol - 1].Columns.AutoFit();
                //SummarySheet.Range[iCtrFillFrom, 0, iCtrFillTo, iDataCol - 1].Rows.AutoFit();

                SummarySheet.Cells[0, 0].Font.Bold = true;
                SummarySheet.Cells[0, 0].Font.Italic = true;
                SummarySheet.Cells[0, 0].Font.Size = this.TitleFontSize;
                SummarySheet.Cells[8, 2].Font.Bold = true;

                //*** Progress
                this.RaiseEventSetProgress(45);

                //*********************************** S H O W L O G **************************************

                LogSheet.Cells[0, 0].Value = LangStrings.VAR_LOG_NAME;
                LogSheet.Cells[2, 0].Value = LangStrings.sMODULE;
                LogSheet.Cells[2, 1].Value = LangStrings.VAR_WIZARD_NAME;
                LogSheet.Cells[3, 0].Value = LangStrings.DATE_TIME;
                LogSheet.Cells[3, 1].Value = this.TimeStamp;
                LogSheet.Cells[4, 0].Value = LangStrings.LOG_FILE_NAME;
                LogSheet.Cells[4, 1].Value = "Log_Subtotol (" + this.TimeStamp + ").xls";

                iCtrFillFrom = 8;// 9;
                //*** Set Data
                LogSheet.Range[iCtrFillFrom, 0, iCtrFillFrom + msLogArray.GetLength(0) - 1, 7].Value = msLogArray;
                //*** Autofit
                LogSheet.Range[iCtrFillFrom, 0, iCtrFillFrom + msLogArray.GetLength(0) - 1, 7].Columns.AutoFit();
                LogSheet.Range[iCtrFillFrom, 4, iCtrFillFrom + msLogArray.GetLength(0) - 1, 4].HorizontalAlignment = HAlign.Left;// -4131;
                //xlLeft 'Time column

                //*** Set Font
                LogSheet.Range[0, 0, iCtrFillFrom + msLogArray.GetLength(0) - 1, 7].Font.Name = this.FontName;
                LogSheet.Range[0, 0, iCtrFillFrom + msLogArray.GetLength(0) - 1, 7].Font.Size = (float)this.FontSize;

                LogSheet.Cells[0, 0].Font.Bold = true;
                LogSheet.Cells[0, 0].Font.Italic = true;
                LogSheet.Cells[0, 0].Font.Size = this.TitleFontSize;

                //******************************************************************************************

                this.RaiseEventSetProgress(100);
                this.DIExcel.GetWorksheet(0).Cells[0, 0].Activate();
                this.DIExcel.Save();

                //*** hide progress bar
                this.RaiseEventHideProgressBar();
                SummarySheet = null;
                LogSheet = null;
                dvMain.RowFilter = string.Empty;

                //goExcel.SetParent(pnl4_3.Handle.ToInt32);
                this.RaiseEventCalculateStepCompleted("pnl4_3");
            }

            catch (Exception ex)
            {
            }
            finally
            {
                this.RaiseEventSetCursor(true);
            }
        }
Example #46
0
    protected void DDL_ThemePage_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (this.DDL_ThemePage.SelectedValue != tempThemePage)
        {
            this.DDL_ThemePage.SelectedValue = tempThemePage;
            UserPreference pf = new UserPreference();
            pf.User = this.CurrentUser;
            pf.Code = BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE;
            pf.Value = this.DDL_ThemePage.SelectedValue;
            if (this.CurrentUser.UserThemePage == string.Empty || this.CurrentUser.UserThemePage == null)
            {
                try
                {
                    TheUserPreferenceMgr.CreateUserPreference(pf);
                }
                catch (Exception)
                {
                    TheUserPreferenceMgr.UpdateUserPreference(pf);
                }

            }
            else
            {
                TheUserPreferenceMgr.UpdateUserPreference(pf);
            }

            if (this.DDL_ThemePage.SelectedValue != BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE_RANDOM)
            {
                HttpCookie cookieThemePage = new HttpCookie("ThemePage");
                cookieThemePage.Value = this.DDL_ThemePage.SelectedValue;
                Response.Cookies.Add(cookieThemePage);
            }
            this.CurrentUser.UserThemePage = this.DDL_ThemePage.SelectedValue;
        }
        SavetabStatus();
    }
 public virtual void UpdateUserPreference(UserPreference entity)
 {
     entityDao.UpdateUserPreference(entity);
 }
 public virtual void DeleteUserPreference(UserPreference entity)
 {
     entityDao.DeleteUserPreference(entity);
 }
        /// <summary>
        /// Initilize the object for Graph
        /// </summary>
        /// <param name="presentationData">DataView</param>
        /// <param name="DIConnection">DIConnection used in IC Classification of step 3 & its implementation in step 6 and also for footnotes text and comments text in step 6</param>
        /// <param name="DIQueries">DIQueries</param>
        /// <param name="UserSelection">UserSelection2 (New UserSelection)</param>
        /// <remarks>
        /// This class using Table presenation class for generating datasource
        /// </remarks>
        public GraphPresentation(DIDataView dIDataView, DIConnection dIConnection, DIQueries dIQueries, UserPreference.UserPreference userPreference)
        {
            // - Create object of TablePresentation
            this._TablePresentation = new TablePresentation(dIDataView, dIConnection, dIQueries, userPreference, string.Empty);

            // - Set the Presenatation Type
            this._TablePresentation.PresentationType = Presentation.PresentationType.Graph;

            // - Initilize the graph appearence oject
            this._GraphAppearence = new StyleTemplate(Presentation.PresentationType.Graph, userPreference.General.ShowExcel);

            // Set the user pref for internal use
            this.UserPreference = userPreference;

            this._SpreadsheetGearChartType = GetSpreadsheetChartTypeFromXlChartType(this.UserPreference.Chart.ChartType);

            // Initilize the all the language strings
            this.ApplyLanguageSettings();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dIDataView"></param>
        /// <param name="dIConnection"></param>
        /// <param name="dIQueries"></param>
        /// <param name="userPreference"></param>
        /// <param name="outputFolderPath"></param>
        /// <param name="outputType"></param>
        public GraphPresentation(DIDataView dIDataView, DIConnection dIConnection, DIQueries dIQueries, UserPreference.UserPreference userPreference, string outputFolderPath, PresentationOutputType outputType)
        {
            // - Create object of TablePresentation
            this._TablePresentation = new TablePresentation(dIDataView, dIConnection, dIQueries, userPreference, string.Empty);

            // - Set the Presenatation Type
            this._TablePresentation.PresentationType = Presentation.PresentationType.Graph;

            this._TablePresentation.ShowExcel = userPreference.General.ShowExcel;

            // - Initilize the graph appearence oject
            this._GraphAppearence = new StyleTemplate(Presentation.PresentationType.Graph, userPreference.General.ShowExcel);

            if (!userPreference.General.ShowExcel)
            {
                if (outputType == PresentationOutputType.ExcellSheet)
                {
                    this._TablePresentation.PresentationOutputType = PresentationOutputType.ExcellSheet;
                }
                else
                {
                    this._TablePresentation.PresentationOutputType = PresentationOutputType.MHT;
                }

                // Set the user pref.
                this.UserPreference = userPreference;

                this._SpreadsheetGearChartType = GetSpreadsheetChartTypeFromXlChartType(this.UserPreference.Chart.ChartType);

                // Initilize the all the language strings
                this.ApplyLanguageSettings();
            }
        }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            //string entityCode = TheEntityPreferenceMgr.LoadEntityPreference("CompanyCode").Value;
            string entityCode = TheEntityPreferenceMgr.LoadEntityPreference(BusinessConstants.ENTITY_PREFERENCE_CODE_PORTAL_PARAM).Value;

            // read config
            string companyCode = string.Empty;
            string redirectUrl = string.Empty;
            string urlLogin = string.Empty;
            string userCode = string.Empty;
            string password = string.Empty;
            string partyCode = string.Empty;

            //string userCode = "su";
            //string password = "******";
            //string partyCode = "s0000208";
            //?105=201027&language=en&redirectUrl=Main.aspx%3Fmid%3DOrder.OrderIssue__mp--ModuleType-SupplierDistribution_ModuleSubType-Nml&userCode=SupplyUser&password=supplyuser%40sconit.com
            string[] keys = Request.Params.AllKeys;
            foreach (string key in keys)
            {
                if (key.EndsWith(entityCode))
                {
                    partyCode = Request.Params.Get(key).ToLower();
                }
                else if (key.EndsWith("languageId"))
                {
                    language = Request.Params.Get(key);
                    if (language=="zh_CN")
                    {
                        language = "zh-CN";
                    }
                    else if (language == "en_US")
                    {
                        language = "en";
                    }
                    InitializeCulture();
                }
                else if (key.EndsWith("feature"))
                {
                    redirectUrl = Request.Params.Get(key);
                }
                else if (key.EndsWith("urlLogin"))
                {
                    urlLogin = Request.Params.Get(key);
                }
                else if (key.EndsWith("userid"))
                {
                    userCode = Request.Params.Get(key).ToLower();
                }
                else if (key.EndsWith("password"))
                {
                    password = Request.Params.Get(key);
                }
            }
            //LoginPage
            HttpCookie loginPageCookie = new HttpCookie("LoginPage");
            loginPageCookie.Value = urlLogin;
            Response.Cookies.Add(loginPageCookie);

            ////test
            //userCode = "SupplyUser";
            //password = "******";
            //partyCode = "ADKJ";

            //this.message.Text = userCode + "|" + password + "|" + partyCode;
            //return;

            if (userCode != null && userCode.Trim() != string.Empty)
            {
                if ((userCode + password).ToLower() == @"supplyusersconit.yfkey")
                {
                    User user = TheUserMgr.CheckAndLoadUser(partyCode.ToLower());

                    bool isExistUserPreferenceLanguage = false;
                    if (user != null && user.UserPreferences != null)
                    {
                        foreach (UserPreference userPreference in user.UserPreferences)
                        {
                            if (userPreference.Code == BusinessConstants.CODE_MASTER_LANGUAGE)
                            {
                                userPreference.Value = language;
                                isExistUserPreferenceLanguage = true;
                            }
                        }
                    }
                    if (!isExistUserPreferenceLanguage || user.UserPreferences == null)
                    {
                        UserPreference up = new UserPreference();
                        up.Code = BusinessConstants.CODE_MASTER_LANGUAGE;
                        up.Value = language;
                        up.User = user;
                        user.UserPreferences.Add(up);
                    }
                    this.Session["Current_User"] = user;
                    this.Session["Hiddensmp"] = "Hiddensmp";
                    this.TreeView1.TreeNodeDataBound += new TreeNodeEventHandler(TreeView1_TreeNodeDataBound);
                    return;
                }
            }
            this.Response.Redirect("about:blank");
        }
        catch (BusinessErrorException ex)
        {
            this.Response.Redirect("about:blank");
        }
    }
 public virtual void CreateUserPreference(UserPreference entity)
 {
     entityDao.CreateUserPreference(entity);
 }
Example #53
0
        public async Task<ActionResult> UserChangeAcademicYear(UserChangeAcademicYearVM vmodel)
        {
            var dbcontext = new ApplicationDbContext();
            string userid = User.Identity.GetUserId();
            if(ModelState.IsValid)
            {
                
                // Create a object with partial fields of Userpreference(UP) object
                var UPAcademicyearupdate = new UserPreference()
                {
                    UserID = User.Identity.GetUserId(),
                    AcademicYearRefID = vmodel.AcademicYearID
                };
                    dbcontext.UserPreferences.Attach(UPAcademicyearupdate);
                    dbcontext.Entry(UPAcademicyearupdate).Property("AcademicYearRefID").IsModified = true;
                    await dbcontext.SaveChangesAsync();

                    return RedirectToAction("StudentCurrentYearIndex", "Student");
                
            }

            ViewBag.AcademicYearID = new SelectList(dbcontext.AcademicYears.AsNoTracking().Where(a => a.SchoolRefID == vmodel.SchoolRefID).Select(x => new { x.AcademicYearID, x.DisplayYear }), "AcademicYearID", "DisplayYear", vmodel.AcademicYearID);
            return View(vmodel);

        }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (this.Session["Current_User"] == null)
        {
            this.Response.Redirect("~/Logoff.aspx");
        }
        else
        {
            this.Title = TheEntityPreferenceMgr.LoadEntityPreference("CompanyName").Value;

            if (!Page.IsPostBack)
            {
                string ThemePage = string.Empty;

                HttpCookie cookieThemePage = new HttpCookie("ThemePage");
                if (this.CurrentUser.UserThemePage == null || this.CurrentUser.UserThemePage.Trim() == string.Empty)
                {
                    cookieThemePage.Value = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE).Value;
                    Response.Cookies.Add(cookieThemePage);

                    this.CurrentUser.UserThemePage = cookieThemePage.Value;

                    UserPreference usrpf = new UserPreference();
                    usrpf.User = this.CurrentUser;
                    usrpf.Code = BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE;
                    usrpf.Value = cookieThemePage.Value;
                    TheUserPreferenceMgr.CreateUserPreference(usrpf);
                }
                else
                {
                    UserPreference userPreferenceThemePage = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, "ThemePage");
                    if (userPreferenceThemePage != null && userPreferenceThemePage.Value == BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE_RANDOM)
                    {
                        ThemePage = TheCodeMasterMgr.GetRandomTheme(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEPAGE);
                    }
                    else
                    {
                        ThemePage = userPreferenceThemePage.Value;
                    }
                    cookieThemePage.Value = ThemePage;
                    Response.Cookies.Add(cookieThemePage);

                }

                #region 随机框架主题
                HttpCookie cookieThemeFrame = new HttpCookie("ThemeFrame");
                if (this.CurrentUser.UserThemeFrame == null || this.CurrentUser.UserThemeFrame.Trim() == string.Empty)
                {
                    cookieThemeFrame.Value = string.Empty;
                    Response.Cookies.Add(cookieThemeFrame);

                    this.CurrentUser.UserThemeFrame = TheCodeMasterMgr.GetDefaultCodeMaster(BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME).Value;

                    UserPreference usrpf = new UserPreference();
                    usrpf.User = this.CurrentUser;
                    usrpf.Code = BusinessConstants.CODE_MASTER_USER_PREFERENCE_VALUE_THEMEFRAME;
                    usrpf.Value = this.CurrentUser.UserThemeFrame;
                    TheUserPreferenceMgr.CreateUserPreference(usrpf);
                }
                else
                {
                    string themeFrame = TheUserPreferenceMgr.LoadUserPreference(this.CurrentUser.Code, "ThemeFrame").Value;
                    switch (themeFrame)
                    {
                        case "Picture":
                            cookieThemeFrame.Value = string.Empty;
                            Response.Cookies.Add(cookieThemeFrame);
                            break;
                        case "Random":
                            cookieThemeFrame.Value = TheCodeMasterMgr.GetRandomTheme("ThemeFrame");
                            Response.Cookies.Add(cookieThemeFrame);
                            break;
                        default:
                            cookieThemeFrame.Value = themeFrame;
                            Response.Cookies.Add(cookieThemeFrame);
                            break;
                    }
                }
                #endregion
            }

            //确定MainFrame的页面为退出前的页面
            if (Request.Params.Get("rightFrameUrl") == null)
            {
                Favorites favorites = TheFavoritesMgr.LoadLastFavorites(this.CurrentUser.Code, "History");

                if (favorites != null)
                {
                    MenuView menuView = TheMenuViewMgr.GetMenuView(favorites.PageName);
                    if (menuView != null)
                    {
                        url = menuView.PageUrl.Substring(2);
                    }
                    else
                    {
                        url = "Main.aspx?mid=Security.UserPreference";
                    }
                }
                else
                {
                    url = "Main.aspx?mid=Security.UserPreference";
                }
            }
            else
            {
                url = Request.Params.Get("rightFrameUrl");
            }

        }
    }
Example #55
0
        public async Task<ActionResult> Register(RegisterViewModel model)
        {
            var dbmgtm = new ApplicationDbContext();

            IdentityResult result;
            
            using (var securitytrans = dbmgtm.Database.BeginTransaction())
            {
                        try 
                        {
                                if (ModelState.IsValid)
                                {
                                    var user = new ApplicationUser()
                                    {
                                        UserName = model.UserName,
                                        FirstName = model.FirstName,
                                        LastName = model.LastName,
                                        Email = model.Email
                                    };
                

                                    var um = new UserManager<ApplicationUser>(
                                    new UserStore<ApplicationUser>(dbmgtm));

                                    result = await um.CreateAsync(user, model.Password);
                                    

                                    if (result.Succeeded)
                                    {   
                                        
                                        UserPreference userpref = new UserPreference()
                                        {
                                            UserID = user.Id,
                                            UserName = model.UserName,
                                            SchoolRefID = model.SchoolID,
                                            AcademicYearRefID = model.AcademicYearID
                                        };
                                        dbmgtm.UserPreferences.Add(userpref);

                                        await dbmgtm.SaveChangesAsync();
                                        securitytrans.Commit();
                                        //await SignInAsync(user, isPersistent: false);
                                        return RedirectToAction("Index", "Account");
                                    }
                            }
                          
                    }
                    catch (Exception e)
                    {
                                                                         
                        securitytrans.Rollback();
                        ModelState.AddModelError("", e.Message);
                        ViewBag.SchoolID = new SelectList(dbmgtm.Schools.AsNoTracking().Select(x => new { x.SchoolID, x.SchoolName }), "SchoolID", "SchoolName", model.SchoolID);
                        ViewBag.AcademicYearID = new SelectList(dbmgtm.AcademicYears.AsNoTracking().Select(x => new { x.AcademicYearID, x.DisplayYear }), "AcademicYearID", "DisplayYear", model.AcademicYearID);
                       return View(model);
                    }
                }
            
                ViewBag.SchoolID = new SelectList(dbmgtm.Schools.AsNoTracking().Select(x => new { x.SchoolID, x.SchoolName }), "SchoolID", "SchoolName", model.SchoolID);
                ViewBag.AcademicYearID = new SelectList(dbmgtm.AcademicYears.AsNoTracking().Select(x => new { x.AcademicYearID, x.DisplayYear }), "AcademicYearID", "DisplayYear", model.AcademicYearID);
            
            return View(model);                
                      
            } 
Example #56
0
 private void ProcessLoginEvent(User user, string LoginModule)
 {
     this.user = user;
     this.userPreference = TheClientMgr.LoadUserPerference(user.Code, BusinessConstants.CODE_MASTER_PERMISSION_CATEGORY_TYPE_VALUE_TERMINAL);
     if (this.userPreference == null || this.userPreference.Value == null
         || this.userPreference.Value == string.Empty || this.userPreference.Value == BusinessConstants.TRANSFORMER_MODULE_TYPE_SELECTION)
     {
         openModuleSelectionUserControl();
     }
     else
     {
         SwitchModule(userPreference.Value);
     }
 }