Esempio n. 1
0
        public override bool IsValid(object value)
        {
            var  email  = (String)value;
            bool result = UserMng.ExistsEmail(email);

            return(result);
        }
Esempio n. 2
0
        public int ReferedActECHRSearchCount(string applicant, string applicationNumber, string ecli)
        {
            //  var searchModel = new ReferedActECHRSearchModel();
            var searchQuery = this.PrepairReferedActECHRSearchQuery(applicant, applicationNumber, ecli);

            int[] wsRes = null;

            SearchResult sr = null;

            string searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath"];

            sr = new SearchResult(SearchSources.HomePage, HttpContext.Application["SearchWrapper"],
                                  searchWrapperUrl,
                                  HttpContext.Application["FilterDocsStruct"],
                                  HttpContext.Application["FilterDocsClassifiers"],
                                  HttpContext.Application["ClassifiersMap"],
                                  HttpContext.Application["ResultsGroupper"],
                                  HttpRuntime.AppDomainAppPath,
                                  this.Language.Id, 20, 10);

            int[] langPref = UserMng.GetUserLangPrefForSearch(UserData.UserId, Language.Id);

            sr.SearchFTQuery(searchQuery, ref wsRes, langPref);
            wsRes = Interlex.BusinessLayer.Search.GetReferedActECHRSearchResult(wsRes);

            Session["ReferedActECHRDocs"] = wsRes;

            return(wsRes.Length);
        }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, Account account)
        {
            if (id != account.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    await UserMng.UpdateAsync(account);
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!AccountExists(account.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(account));
        }
        protected override bool IsAuthorized(HttpActionContext context)
        {
            bool sessionExists = false;

            if (HttpContext.Current.Session["UserData"] != null)
            {
                sessionExists = UserMng.UpdateUserSession(
                    ((UserData)HttpContext.Current.Session["UserData"]).SessionId,
                    HttpContext.Current.Session.Timeout * 60);
            }

            //if (HttpContext.Current.Session["UserData"] == null)
            if (!sessionExists)
            {
                string controller = HttpContext.Current.Request.RequestContext.RouteData.Values["controller"].ToString();
                string action     = HttpContext.Current.Request.RequestContext.RouteData.Values["action"].ToString();
                if (controller != "Login")
                {
                    HttpContext.Current.Session.Abandon();

                    HttpContext.Current.Response.ContentType = "application/json";
                    HttpContext.Current.Response.Clear();
                    string acceptTypeJSON = HttpContext.Current.Request.AcceptTypes.FirstOrDefault(s => s.Contains("application/json") || s.Contains("*/*"));
                    if (!String.IsNullOrEmpty(acceptTypeJSON))
                    {
                        HttpContext.Current.Response.Write("{ \"status\": \"unauth\" }");
                        HttpContext.Current.Response.End();
                        return(false);
                    }
                }
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        public JsonResult RenameFolder(int folderId, string folderName)
        {
            if (String.IsNullOrEmpty(folderName))
            {
                var res = new { status = 400, errorText = Resources.Resources.Notify_FolderNameEmpty };
                return(Json(res));
            }

            folderName = folderName.Trim();
            try
            {
                bool isRenamed = UserMng.RenameUserFolder(UserData.UserId, folderId, folderName);
                if (isRenamed)
                {
                    var res = new { status = 200, folderName = folderName };
                    return(Json(res));
                }
            }
            catch (Exception ex)
            {
                Logger.LogExceptionToFolder(HttpRuntime.AppDomainAppPath, UserData, ex);
                var res = new { status = 500, errorText = Resources.Resources.Notify_FolderRenameError };
                return(Json(res));
            }

            var result = new { status = 400, errorText = Resources.Resources.Notify_FolderNotFoundError };

            return(Json(result));
        }
Esempio n. 6
0
        public JsonResult CreateFolder(string folderName, int?parentId)
        {
            if (UserData.Username.ToLower() == "sysdemo")
            {
                var result = new { status = 401, title = "Access denied", message = "my documents feature" };
                return(Json(result));
            }

            if (String.IsNullOrEmpty(folderName))
            {
                var res = new { status = 400, errorText = Resources.Resources.Notify_FolderNameEmpty };
                return(Json(res));
            }

            folderName = folderName.Trim();
            try
            {
                var folderData = UserMng.AddUserFolder(UserData.UserId, ProductId, folderName, parentId);
                var jsonData   = new UserFolderDataJson(folderData);
                var result     = new { status = 200, folderData = jsonData };

                return(Json(result));
            }
            catch (Exception ex)
            {
                Logger.LogExceptionToFolder(HttpRuntime.AppDomainAppPath, UserData, ex);
                var res = new { status = 500, errorText = Resources.Resources.Notify_FolderCreationError };
                return(Json(res));
            }
        }
Esempio n. 7
0
        public JsonResult GetFolderData(int?parentId)
        {
            var folderData = UserMng.GetUserFoldersParent(UserData.UserId, ProductId, parentId);
            var jsonData   = UserFolderDataJson.FromData(folderData);

            return(Json(jsonData));
        }
Esempio n. 8
0
        public override void OnAuthorization(AuthorizationContext filterContext)
        {
            base.OnAuthorization(filterContext);

            var controller = filterContext.RequestContext.RouteData.GetRequiredString("controller");
            var action     = filterContext.ActionDescriptor.ActionName;

            bool sessionExists = false;

            if (filterContext.HttpContext.Session["UserData"] != null)
            {
                sessionExists = UserMng.UpdateUserSession(
                    ((UserData)filterContext.HttpContext.Session["UserData"]).SessionId,
                    filterContext.HttpContext.Session.Timeout * 60);
            }

            if (!sessionExists)
            {
                // Anonymous controllers list
                List <string> anonymousControllers = new List <string>();
                anonymousControllers.Add("Login");
                anonymousControllers.Add("ContextMenus");
                anonymousControllers.Add("ApplicationUpdate");
                anonymousControllers.Add("Blog");
                anonymousControllers.Add("Presentation");

                if (!anonymousControllers.Contains(controller))
                {
                    filterContext.HttpContext.Session.Abandon();
                    HandleUnauthorizedRequest(filterContext);
                }
            }
        }
Esempio n. 9
0
        public async Task <IActionResult> Register(Account Account)
        {
            var account = await UserMng
                          .FindByEmailAsync(Account.Email);

            if (ModelState.IsValid && account == null)
            {
                var result = await UserMng.CreateAsync(Account);

                var result1 = await UserMng.AddToRoleAsync(Account, "Customer");

                if (result.Succeeded && result1.Succeeded)
                {
                    await SignMng.SignInAsync(Account, isPersistent : false);

                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    ViewBag.UserNameDublicated = "Your UserName is Dublicated ...";
                    return(View(Account));
                }
            }
            ViewBag.EmailExist = "This Email is Exist ...";
            return(View(Account));
        }
Esempio n. 10
0
        public async Task <IActionResult> DeleteConfirmed(int id)
        {
            var Account = await UserMng.FindByIdAsync(id.ToString());

            await UserMng.DeleteAsync(Account);

            return(RedirectToAction(nameof(Index)));
        }
Esempio n. 11
0
        public JsonResult GetDocsCountFolder(int?folderId)
        {
            int currentFolderDocsCount = UserMng.GetUserDocsCountFolder(UserData.UserId, ProductId, folderId);

            return(Json(new
            {
                documentsCount = currentFolderDocsCount
            }));
        }
Esempio n. 12
0
        public ActionResult AddUserDoc(string docLangId, int?folderId)
        {
            if (UserData.Username.ToLower() == "sysdemo")
            {
                var result = new { status = 401, title = "Access denied", message = "my documents feature" };
                return(Json(result));
            }

            int langId = int.Parse(docLangId);

            if (UserMng.GetUserDocsCount(UserData.UserId, ProductId) >= int.Parse(System.Configuration.ConfigurationManager.AppSettings["FavouriteDocumentsCount"]))
            {
                var statusTitle   = Resources.Resources.Notify_DocumentAddMaxCountTitle;
                var statusMessage = Resources.Resources.Notify_DocumentAddMaxCountMessage;

                var result = new { status = 202, title = statusTitle, message = statusMessage };
                Response.StatusCode = 202;

                return(Json(result));
            }
            else if (UserMng.GetUserHasDocument(UserData.UserId, langId, ProductId))
            {
                var statusTitle   = Resources.Resources.Notify_DocumentAddExistingTitle;
                var statusMessage = Resources.Resources.Notify_DocumentAddExistingMessage;

                var result = new { status = 202, title = statusTitle, message = statusMessage };
                Response.StatusCode = 202;

                return(Json(result));
            }
            else
            {
                try
                {
                    UserMng.AddUserDoc(UserData.UserId, langId, ProductId, folderId);

                    var result = new { status = 200, title = "Success", message = "Document added successfuly" };
                    Response.StatusCode = 200;

                    return(Json(result));
                }
                catch (Exception ex)
                {
                    Logger.LogExceptionToFolder(HttpRuntime.AppDomainAppPath, UserData, ex);
                    var statusTitle   = Resources.Resources.Notify_DocumentAddFailTitle;
                    var statusMessage = Resources.Resources.Notify_DocumentAddFailMessage;

                    var result = new { status = 500, title = statusTitle, message = statusMessage };
                    Response.StatusCode = 202;

                    return(Json(result));
                }
            }
        }
Esempio n. 13
0
        public int PalSearchTotalCount(string classifierId, string searchText, string searchNumber, string searchYear, string searchDocNumber, string query)
        {
            Session["PalDocs"] = null;
            string searchQuery;
            int    totalCount = 0;

            if (!String.IsNullOrEmpty(query))
            {
                searchQuery = query;
            }
            else
            {
                searchQuery = PrepairPalSearchQuery(classifierId, searchText, searchNumber, searchYear, searchDocNumber);
            }

            if (!String.IsNullOrEmpty(searchQuery))
            {
                string searchWrapperUrl = null;
                if (ConfigurationManager.AppSettings["SolutionVersion"] == "product")
                {
                    searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath"];
                }
                else
                {
                    searchWrapperUrl = ConfigurationManager.AppSettings["SearchWrapper_BasePath_cc"];
                }

                SearchResult sr = new SearchResult(SearchSources.HomePage, HttpContext.Application["SearchWrapper"],
                                                   searchWrapperUrl,
                                                   HttpContext.Application["FilterDocsStruct"],
                                                   HttpContext.Application["FilterDocsClassifiers"],
                                                   HttpContext.Application["ClassifiersMap"],
                                                   HttpContext.Application["ResultsGroupper"],
                                                   HttpRuntime.AppDomainAppPath,
                                                   this.Language.Id, 20, 10);

                int[] wsRes    = null;
                int[] langPref = UserMng.GetUserLangPrefForSearch(UserData.UserId, Language.Id);

                sr.SearchFTQuery(searchQuery, ref wsRes, langPref);

                int curProductId = 1;
                if (Session["SelectedProductId"] != null)
                {
                    curProductId = int.Parse(Session["SelectedProductId"].ToString());
                }

                wsRes = Interlex.BusinessLayer.Search.GetPALSearchResult(wsRes, curProductId);
                Session["PalDocs"] = wsRes;
                totalCount         = wsRes.Length;
            }

            return(totalCount);
        }
Esempio n. 14
0
        // temp
        public ActionResult TransformUserSearchesMultiDictObjects()
        {
            var updateModel = UserMng.TransformUserSearchesMultiDictObjects();

            if (updateModel != null)
            {
                UserMng.UpdateUserSearchesMultiDictObjects(updateModel);
            }

            return(new EmptyResult());
        }
Esempio n. 15
0
        // GET: Accounts/DisplayUserProfile/
        // return view for display a profile
        // written By khalil Email: [email protected]
        public async Task <IActionResult> DisplayUserProfile()
        {
            var Account = await _context.Users
                          .FirstOrDefaultAsync(m => m.Id == (UserMng.GetUserAsync(HttpContext.User).Result).Id);

            if (Account == null)
            {
                return(NotFound());
            }

            return(View(Account));
        }
Esempio n. 16
0
        public UserData(UserData ud)
            : this()
        {
            this.UserId       = ud.UserId;
            this.UserType     = ud.UserType;
            this.UserTypeId   = ud.UserTypeId;
            this.UserTypeText = ud.UserTypeText;
            //this.UserTypeName = ud.UserTypeName;
            this.SessionId      = ud.SessionId;
            this.ClientId       = ud.ClientId;
            this.Username       = ud.Username;
            this.Email          = ud.Email;
            this.Password       = ud.Password;
            this.Fullname       = ud.Fullname;
            this.ClientName     = ud.ClientName;
            this.PushSessions   = ud.PushSessions;
            this.MaxLoginCount  = ud.MaxLoginCount;
            this.SessionTimeout = ud.SessionTimeout;
            this.Active         = ud.Active;
            this.EmailValid     = ud.EmailValid;
            this.CreateDate     = ud.CreateDate;

            this.OpenDocumentsInNewTab = ud.OpenDocumentsInNewTab;
            this.ShowFreeDocuments     = ud.ShowFreeDocuments;

            this.SellerId  = ud.SellerId;
            this.Code      = ud.Code;
            this.Phone     = ud.Phone;
            this.SkypeName = ud.SkypeName;
            this.CountryId = ud.CountryId;

            this.Note          = ud.Note;
            this.AllowedIpsReq = ud.AllowedIpsReq;

            this.SellerParentId = ud.SellerParentId;
            if (ud.SellerParentId != null && ud.SellerParentId != -1 && ud.SellerParentId != 0)
            {
                this.SellerParentName = UserMng.GetSellerNameBySellerId((int)ud.SellerParentId);
            }

            var products = UserMng.GetUserProducts(this.UserId);

            if (products != null)
            {
                foreach (var product in products)
                {
                    this.Products.Add(product);
                }
            }

            this.OriginId = ud.OriginId;
        }
Esempio n. 17
0
        public ActionResult MyDocumentsList(string orderBy, string orderDir, int?folderId)
        {
            if (orderBy == null)
            {
                orderBy = "add_date";
            }

            if (orderDir == null)
            {
                if (orderBy != "add_date")
                {
                    orderDir = "asc";
                }
                else
                {
                    orderDir = "desc";
                }
            }

            var model = UserMng.GetUserDocsFolder(UserData.UserId, this.Language.Id, orderBy,
                                                  orderDir, ProductId, folderId);

            /*  if (orderBy == "add_date")
             * {
             *    if (orderDir == "desc")
             *    {
             *        model = model.OrderByDescending(m => m.AddedDate);
             *    }
             *    else
             *    {
             *        model = model.OrderBy(m => m.AddedDate);
             *    }
             * }
             * else if (orderBy == "title")
             * {
             *    if (orderDir == "desc")
             *    {
             *        model = model.OrderByDescending(m => m.Title);
             *    }
             *    else
             *    {
             *        model = model.OrderBy(m => m.Title);
             *    }
             * }*/

            ViewBag.OrderBy  = orderBy;
            ViewBag.OrderDir = orderDir;

            return(PartialView(model));
        }
Esempio n. 18
0
 public JsonResult DeleteFolder(int folderId)
 {
     try
     {
         UserMng.DeleteUserFolder(UserData.UserId, folderId);
         var result = new { status = 200, folderId = folderId };
         return(Json(result));
     }
     catch (Exception ex)
     {
         Logger.LogExceptionToFolder(HttpRuntime.AppDomainAppPath, UserData, ex);
         var result = new { status = 500, errorText = Resources.Resources.Notify_FolderDeleteError };
         return(Json(result));
     }
 }
Esempio n. 19
0
        // GET: Accounts/Edit/5
        // return view for edit a profile by user
        // written By khalil Email: [email protected]
        public async Task <IActionResult> Edit(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var Account = await UserMng.FindByIdAsync(id.ToString());

            if (Account == null)
            {
                return(NotFound());
            }
            return(View(Account));
        }
Esempio n. 20
0
        public ActionResult MyDocumentsDeleteAll(int?folderId)
        {
            int userid = int.Parse(UserData.UserId.ToString());

            try
            {
                UserMng.DelAllUserDocs(userid, folderId);
                return(Json("Ok"));
            }
            catch (Exception ex)
            {
                Logger.LogExceptionToFolder(HttpRuntime.AppDomainAppPath, UserData, ex);
                return(Json("Failed"));
            }
        }
Esempio n. 21
0
 public ActionResult MoveDocs(int?fromId, int?toId)
 {
     try
     {
         UserMng.MoveDocsFolderToFolder(UserData.UserId, ProductId, fromId, toId);
         var result = new { status = 200 };
         return(Json(result));
     }
     catch (Exception ex)
     {
         Logger.LogExceptionToFolder(HttpRuntime.AppDomainAppPath, UserData, ex);
         var result = new { status = 500, errorText = Resources.Resources.UI_MoveDocsError };
         return(Json(result));
     }
 }
Esempio n. 22
0
        public async Task <IActionResult> Create(Account Account)
        {
            var account = await UserMng
                          .FindByEmailAsync(Account.Email);

            if (ModelState.IsValid && account == null)
            {
                var result = await UserMng.CreateAsync(Account);

                var result1 = await UserMng.AddToRoleAsync(Account, "Staff");

                return(RedirectToAction("Index", "Home"));
            }
            ViewBag.EmailExist = "This Email is Exist ...";
            return(View(Account));
        }
        protected void Session_End(object sender, EventArgs e)
        {
            if (Session["UserData"] != null)
            {
                System.Diagnostics.Debug.WriteLine("Logged Session end (sessionId=" + ((UserData)Session["UserData"]).SessionId.ToString() + ")");

                string sessionFolder = HttpRuntime.AppDomainAppPath;
                sessionFolder = sessionFolder + "Session_Files\\" + ((UserData)Session["UserData"]).SessionId.ToString();

                UserMng.EndUserSession(((UserData)Session["UserData"]).SessionId, sessionFolder);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("Session_End");
            }
        }
Esempio n. 24
0
        public ActionResult DelAcc(string password)
        {
            var userid   = base.UserData.UserId;
            var username = base.UserData.Username;
            var testGet  = UserMng.GetUser(username, password, false);

            if (testGet == null)
            {
                return(Content("FAIL"));
            }
            else
            {
                UserMng.DelClient(testGet.ClientId);
                Session.Abandon();
                return(Content("OK"));
            }
        }
Esempio n. 25
0
        public ActionResult List(int searchId, int?page)
        {
            SearchResult sr = SearchResult.FindSearchResult(searchId, Session["SearchResults"]);

            // searchId not found
            if (sr == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                //if (sr.LanguageId != this.Language.Id) // Interface language changed. Re-search to show appropriate document language versions
                //{
                //    sr.ChangeLanguage(this.Language.Id);
                //}

                if (!sr.SearchCreated)
                {
                    sr.CreateSearch(this.UserData.UserId, this.UserData.SessionId);

                    // Check if it is real user search
                    if (sr.SearchSource == SearchSources.Search)
                    {
                        string searchText   = (String.IsNullOrWhiteSpace(sr.SearchBoxFilters.SearchText)) ? "" : sr.SearchBoxFilters.SearchText.Trim();
                        int    maxCount     = Convert.ToInt32(ConfigurationManager.AppSettings["UserSearchCount"]);
                        int    curProductId = 1;
                        if (Session["SelectedProductId"] != null)
                        {
                            curProductId = int.Parse(Session["SelectedProductId"].ToString());
                        }

                        UserMng.AddUserSearch(this.UserData.UserId, searchText, sr.SearchBoxFilters, maxCount, curProductId);
                    }
                }
                if (page.HasValue)
                {
                    sr.CurrentPage = page.Value;
                }

                //if (Request.IsAjaxRequest())
                //    return Json(new { result = "Redirect", url = Url.Action("_SearchList", "Search", new { searchId = searchId }) });
                //else
                return(View("~/Views/SearchResult/List.cshtml", sr));
            }
        }
Esempio n. 26
0
        public ActionResult UpdateCommonSettings(string linksInNewTab, string showFreeDocuments)
        {
            if (linksInNewTab != null && showFreeDocuments != null)
            {
                try
                {
                    bool linksInNewTabAsBoolean     = linksInNewTab == "true" ? true : false;
                    bool showFreeDocumentsAsBoolean = showFreeDocuments == "true" ? false : true;                               // it's actually a "show only linked documents" so we are switching the var

                    UserMng.UpdateUserCommonSettings(this.UserData.UserId, linksInNewTabAsBoolean, showFreeDocumentsAsBoolean); // updating DB
                    // updating session values
                    this.UserData.OpenDocumentsInNewTab = linksInNewTabAsBoolean;
                    this.UserData.ShowFreeDocuments     = showFreeDocumentsAsBoolean;

                    return(Json(Resources.Resources.UI_SettingsUpdated));
                }
                catch (Exception)
                {
                    return(Json(Resources.Resources.UI_SettingsUpdatedError));
                }
            }

            return(Json(Resources.Resources.UI_SettingsUpdatedError));

            /* if (linksInNewTab != null)
             * {
             *   try
             *   {
             *       bool linksInNewTabAsBoolean = false;
             *       if (linksInNewTab == "true")
             *       {
             *           linksInNewTabAsBoolean = true;
             *       }
             *
             *       UserMng.SetUserLinksInNewTab(this.UserData.UserId, linksInNewTabAsBoolean);
             *       this.UserData.OpenDocumentsInNewTab = linksInNewTabAsBoolean;
             *
             *       // (Session["UserData"] as UserData).OpenDocumentsInNewTab = linksInNewTabAsBoolean;
             *   }
             *   catch (Exception)
             *   {
             *       return Json(Resources.Resources.UI_SettingsUpdatedError);
             *   }
             * }*/
        }
        public ActionResult AddCookieAgreement()
        {
            var ip = this.GetIPAddress();

            int?userId;

            if (UserData != null)
            {
                userId = UserData.UserId;
            }
            else
            {
                userId = null;
            }

            UserMng.AddCookiesAgreement(userId, ip);

            return(new EmptyResult());
        }
Esempio n. 28
0
        // POST: Accounts/Register
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        // create an invoice for customer by {id}
        // written By khalil Email: [email protected]
        public async Task <IActionResult> CreateInvoiceById(int Id)
        {
            var Account = await _context.Users
                          .FirstOrDefaultAsync(m => m.Id == (UserMng.GetUserAsync(HttpContext.User).Result).Id);

            var userRole = _context.UserRoles.Where(ur => ur.UserId == Account.Id);
            var role     = _context.Roles.Where(r => r.Id == userRole.ToList()[0].RoleId);

            if (role.ToList()[0].Name == "Customer")
            {
                Id = Account.Id;
            }
            var invoice  = new InvoiceViewModel();
            var Customer = await UserMng
                           .FindByIdAsync(Id.ToString());

            var services = await _context.Set <Service>()
                           .Include(s => s.food)
                           .Include(s => s.drink)
                           .Include(s => s.User).Where(s => s.User.Id == Customer.Id)
                           .ToListAsync();

            var rooms = await _context.Set <Reservation>()
                        .Include(r => r.Customer)
                        .Include(r => r.Room).Where(r => r.Customer.Id == Customer.Id)
                        .ToListAsync();

            int cost = 0;

            for (int i = 0; i < services.Count; i++)
            {
                cost += services[i].Cost;
            }
            invoice.Customer = Customer;
            invoice.Services = services;
            invoice.Rooms    = rooms;
            invoice.Cost     = cost;

            return(View(invoice));
        }
Esempio n. 29
0
        public ActionResult DelUserDoc(string docLangId)
        {
            int langId = int.Parse(docLangId);

            try
            {
                UserMng.DelUserDoc(UserData.UserId, langId, ProductId);

                return(new HttpStatusCodeResult(200));
            }
            catch (Exception ex)
            {
                Logger.LogExceptionToFolder(HttpRuntime.AppDomainAppPath, UserData, ex);
                var statusTitle   = Resources.Resources.Notify_DocumentDeletionFailTitle;
                var statusMessage = Resources.Resources.Notify_DocumentDeletionFailMessage;

                var result = new { status = 500, title = statusTitle, message = statusMessage };
                Response.StatusCode = 202;

                return(Json(result));
            }
        }
        private UserData ProcessLogin(string username, string password, bool passHashed, string ipAddr, string language, ref string errorMsg)
        {
            CultureInfo ci = new CultureInfo(language);

            UserData ud = UserMng.Login(username, password, passHashed, ipAddr);

            //string errorMsg = null;
            if (ud != null)
            {
                if (ud.SessionId == -1)
                {
                    errorMsg = Resources.Resources.ResourceManager.GetString("UI_MaxUserLoginCountReached", ci);
                    //errorMsg = Resources.Resources.UI_MaxUserLoginCountReached;
                }
                else if (ud.SessionId == -2)
                {
                    errorMsg = Resources.Resources.UI_SubscriptionExpired;
                }
                else if (ud.SessionId == -3)
                {
                    errorMsg = Resources.Resources.UI_EmailNotValidated;
                }
                else if (ud.SessionId == -4)
                {
                    errorMsg = Resources.Resources.ResourceManager.GetString("UI_UserNotActive", ci);
                    //errorMsg = Resources.Resources.UI_UserNotActive;
                }
                else if (ud.SessionId == -5)
                {
                    errorMsg = Resources.Resources.ResourceManager.GetString("UI_IpNotAllowed", ci);
                }
                else if (ud.SessionId > 0)
                {
                    Session["UserData"] = ud;
                    Session.Timeout     = ud.SessionTimeout; // minutes

                    var browserString   = Request.Browser.Browser;
                    var userAgentString = Request.UserAgent;
                    var browserId       = (int)GetBrowserByBrowserAndUserAgentString(browserString, userAgentString);
                    var isMobileDevice  = Request.Browser.IsMobileDevice;

                    if (Common.CheckRequestOriginIsBotSoft(userAgentString) == false)
                    {
                        Stat.AddLogin(ud.UserId, browserId, isMobileDevice, Request.UserHostAddress, ud.ClientId, ud.SellerId);
                    }

                    var productsList = UserMng.GetProductsList(ud.UserId);
                    Session["ProductsList"] = productsList;

                    var selectedProductCookie = Request.Cookies["SelectedProductId"];
                    int selectedProductId     = 1;

                    if (UserData.Products.Where(p => p.IsActive.HasValue && p.IsActive == true).ToList().Count == 1)
                    {
                        selectedProductId = UserData.Products.Where(p => p.IsActive.HasValue && p.IsActive == true).ToList().FirstOrDefault().ProductId;
                        var newCookie = new HttpCookie("SelectedProductId");
                        newCookie.Value = selectedProductId.ToString();

                        Response.SetCookie(newCookie);
                    }
                    else
                    {
                        if (selectedProductCookie != null && selectedProductCookie.Value != null && selectedProductCookie.Value.ToString() != "")
                        {
                            selectedProductId = int.Parse(selectedProductCookie.Value.ToString());
                        }
                    }

                    Session["SelectedProductId"] = selectedProductId;
                }
            }
            else
            {
                errorMsg = Resources.Resources.UI_InvalidLogin;
            }

            return(ud);
        }