예제 #1
0
        public List <Users> GetUserList(int limit, int offset, string order, string sort, string FirstName, string LastName, string Email, string Photo, out int total)
        {
            AzureDBContext db = new AzureDBContext();
            // var data = from u in db.smSocialMediaProfile.AsQueryable()
            //where u.UserId == currentUserId
            // select new smSocialMediaProfile { Fid = u.Fid, FirstName = u.FirstName, LastName = u.LastName, Photo = u.Photo, Email = u.Email };
            // var data = GetAll().Where(x => x.UserId == currentUserId && x.IsActive == true).ToList();
            var data = Context.Set <Users>().Where(x => x.UserTypeId == 2 && x.IsDeleted == false);

            if (!string.IsNullOrEmpty(FirstName))
            {
                data = data.Where(x => x.FirstName.Contains(FirstName));
            }
            if (!string.IsNullOrEmpty(LastName))
            {
                data = data.Where(x => x.LastName.Contains(LastName));
            }
            if (!string.IsNullOrEmpty(Photo))
            {
                data = data.Where(x => x.Photo.Contains(Photo));
            }
            if (!string.IsNullOrEmpty(Email))
            {
                data = data.Where(x => x.Email.Contains(Email));
            }
            //Order by
            GetSortedData(ref data, sort + order.ToUpper());
            total = data.Count();
            return(data.Skip(offset).Take(limit).ToList());
        }
        public async Task <SiteFunction> GetAsync(int id)
        {
            var siteFunction = new SiteFunction();

            try
            {
                var a        = new AzureDBContext(_imsConfigHelper.MSGGenDB01);
                var pageList = a.MsgPages.ToList();
                var f        = a.Msgfunctions.FirstOrDefault(fi => fi.Id == id);
                var page     = pageList.FirstOrDefault(p => p.Id == f.Page);

                siteFunction = new SiteFunction()
                {
                    Id            = f.Id,
                    Name          = f.Name,
                    Description   = f.Description,
                    PageName      = page.Name,
                    PageTitle     = page.Title,
                    ApplicationId = f.ApplicationId.GetValueOrDefault()
                };
            }
            catch (Exception e)
            {
                siteFunction.Error = e.Message;
            }

            return(siteFunction);
        }
        public dynamic GetTotalClicks(int UserId)
        {
            AzureDBContext      dbcontext = new AzureDBContext();
            List <smViewsModel> data      = new List <smViewsModel>();

            try
            {
                DbDataReader _reader;
                dbcontext.Database.Initialize(force: false);
                dbcontext.Database.Connection.Open();
                var _dbCmd = dbcontext.Database.Connection.CreateCommand();
                _dbCmd.CommandText    = "[smGetViewClick]";
                _dbCmd.CommandType    = CommandType.StoredProcedure;
                _dbCmd.CommandTimeout = 60 * 5;
                _dbCmd.Parameters.AddRange(new SqlParameter[] {
                    new SqlParameter("@UserId", UserId),
                });
                _reader = _dbCmd.ExecuteReader();

                data = ((IObjectContextAdapter)dbcontext).ObjectContext.Translate <smViewsModel>(_reader).ToList();
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
            }
            return(data.ToList());
        }
예제 #4
0
        public async Task <Will> GetAsync(int id)
        {
            var will = new Will();

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var app = a.LincsWills.FirstOrDefault(fi => fi.Id == id);

                will = new Will()
                {
                    Id          = app.Id,
                    Aliases     = app.Aliases,
                    Collection  = app.Collection,
                    DateString  = app.DateString,
                    Description = app.Description,
                    FirstName   = app.FirstName,
                    Occupation  = app.Occupation,
                    Place       = app.Place,
                    Reference   = app.Reference,
                    Surname     = app.Surname,
                    Typ         = app.Typ.GetValueOrDefault(),
                    Url         = app.Url,
                    Year        = app.Year
                };
            }
            catch (Exception e)
            {
                will.Error = e.Message;
            }
            return(will);
        }
예제 #5
0
        public async Task <Site> GetAsync(int id)
        {
            var site = new Site();

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var pageList = a.MsgPages.ToList();

                var app = a.Msgapplications.FirstOrDefault(fi => fi.Id == id);

                var page = pageList.FirstOrDefault(p => p.Id == app.DefaultPage);

                site = new Site()
                {
                    Id               = app.Id,
                    Name             = app.ApplicationName,
                    Description      = app.Description,
                    DefaultPageName  = page.Name,
                    DefaultPageTitle = page.Title
                };
            }
            catch (Exception e)
            {
                site.Error = e.Message;
            }



            return(site);
        }
        public List <smPost> GetAllSocialMediaPost(int limit, int offset, string order, string sort, string Name, string Description, string Url, string ImageUrl, int currentUserId, out int total)
        {
            AzureDBContext db = new AzureDBContext();


            var data = (from a in db.smPost.AsEnumerable()
                        where a.UserId == currentUserId && a.IsDeleted == false && a.IsActive == true && a.PostDate <= DateTime.UtcNow
                        select a);

            if (!string.IsNullOrEmpty(Name))
            {
                data = data.Where(x => x.Name.Contains(Name));
            }
            if (!string.IsNullOrEmpty(Description))
            {
                data = data.Where(x => x.Description.Contains(Description));
            }
            if (!string.IsNullOrEmpty(ImageUrl))
            {
                data = data.Where(x => x.ImageUrl.Contains(ImageUrl));
            }
            if (!string.IsNullOrEmpty(Url))
            {
                data = data.Where(x => x.Url.Contains(Url));
            }

            GetSortedPost(ref data, sort + order.ToUpper());
            total = data.Count();

            data = (from a in data
                    join u in db.Users on a.UserId equals u.UserId
                    let c = Context.Set <Users>().Where(c => c.UserId == a.CreatedBy).FirstOrDefault()
                            select new smPost
            {
                PostId = a.PostId,
                UserId = a.UserId,
                SocialMediaProfileId = a.SocialMediaProfileId,
                SocialMedia = a.SocialMedia,
                Name = a.Name,
                Caption = a.Caption,
                Description = a.Description,
                Url = a.Url,
                ImageUrl = a.ImageUrl,
                PostDate = a.PostDate,
                IsActive = a.IsActive,
                IsDeleted = a.IsDeleted,
                ModifiedDate = a.ModifiedDate,
                FirstName = u.FirstName,
                LastName = u.LastName,
                CreatedByName = c.Email,
                RoleType = c.UserTypeId,
                LikesCount = a.LikesCount,
                CommentsCount = a.CommentsCount,
                LikesNames = a.LikesNames,
                CommentsText = a.CommentsText
            });
            return(data.Skip(offset).Take(limit).ToList());
        }
        public async Task <Results <FTMView> > FTMViewList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <FTMView>();

            var results = new Results <FTMView>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);



                var unpaged = a.FTMPersonView.Where(w => w.Surname != "")
                              .WhereIfSurname(searchParams.Surname)
                              .WhereIfLocation(searchParams.Location)
                              .WhereIfYearsBetween(searchParams.YearStart, searchParams.YearEnd)
                              .FTMViewSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new FTMView()
                    {
                        Id              = app.Id,
                        FirstName       = app.FirstName ?? "",
                        Surname         = app.Surname ?? "",
                        AltLocation     = app.AltLocation ?? "",
                        AltLat          = app.AltLat.GetValueOrDefault(),
                        AltLocationDesc = app.AltLocationDesc ?? "",
                        AltLong         = app.AltLong.GetValueOrDefault(),
                        YearFrom        = app.YearFrom,
                        YearTo          = app.YearTo,
                        BirthLat        = app.BirthLat.GetValueOrDefault(),
                        Location        = app.Location ?? "",
                        BirthLong       = app.BirthLong.GetValueOrDefault(),
                        Origin          = app.Origin ?? "",
                        PersonId        = app.PersonId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
예제 #8
0
        public async Task <Results <ADBSource> > SourceList(ADBSourceParamObj searchParams)
        {
            var parishList = new List <ADBSource>();

            var results = new Results <ADBSource>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.Sources.WhereIfLocation(searchParams.Location)
                              .WhereIfSourceRef(searchParams.SourceRef)
                              .WhereIfYearsBetween(searchParams.YearStart, searchParams.YearEnd)
                              .OrderBy(o => o.SourceRef);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    parishList.Add(new ADBSource()
                    {
                        Id                = app.Id,
                        DateAdded         = app.DateAdded,
                        IsCopyHeld        = app.IsCopyHeld,
                        IsThackrayFound   = app.IsThackrayFound,
                        IsViewed          = app.IsViewed,
                        OriginalLocation  = app.Location,
                        SourceDate        = app.YearFrom,
                        SourceDateTo      = app.YearTo,
                        SourceDateStr     = app.SourceDateStr,
                        SourceDateStrTo   = app.SourceDateStrTo,
                        SourceDescription = app.SourceDescription,
                        SourceFileCount   = app.SourceFileCount,
                        SourceNotes       = app.SourceNotes,
                        SourceRef         = app.SourceRef,
                        UserId            = app.UserId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = parishList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
예제 #9
0
        public async Task <Results <ADBParish> > ParishList(ADBParishParamObj searchParams)
        {
            //column sort not needed

            var parishList = new List <ADBParish>();

            var results = new Results <ADBParish>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.Parishs
                              .WhereIfMatchParishCounty(searchParams.County)
                              .WhereIfMatchParishName(searchParams.ParishName)
                              .OrderBy(o => o.Name);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    parishList.Add(new ADBParish()
                    {
                        Id                       = app.Id,
                        ParentParish             = app.ParentParish,
                        ParishCounty             = app.County,
                        ParishEndYear            = app.ParishEndYear,
                        ParishName               = app.Name,
                        ParishNotes              = app.ParishNotes,
                        ParishRegistersDeposited = app.ParishRegistersDeposited,
                        ParishStartYear          = app.ParishStartYear,
                        ParishX                  = app.ParishX,
                        ParishY                  = app.ParishY
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = parishList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
        public async Task <Results <Dupe> > DupeList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <Dupe>();

            var results = new Results <Dupe>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);


                var unpaged = a.DupeEntries
                              .WhereIfSurname(searchParams.Surname)
                              .DupeSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new Dupe()
                    {
                        Id        = app.Id,
                        FirstName = app.FirstName ?? "",
                        Surname   = app.Surname ?? "",
                        YearFrom  = app.YearFrom,
                        YearTo    = app.YearTo,
                        Ident     = app.Ident ?? "",
                        Location  = app.Location ?? "",
                        Origin    = app.Origin ?? "",
                        PersonId  = app.PersonId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
        public List <smPreference> GetAllSocialPreference(int limit, int offset, string order, string sort, string Preference, int currentUserId, out int total)
        {
            AzureDBContext db = new AzureDBContext();

            var data = Context.Set <smPreference>().Where(x => x.UserId == currentUserId && x.IsDeleted == false);

            if (!string.IsNullOrEmpty(Preference))
            {
                data = data.Where(x => x.Preference.Contains(Preference));
            }

            //Order by
            GetSortedPreference(ref data, sort + order.ToUpper());
            total = data.Count();
            return(data.Skip(offset).Take(limit).ToList());
        }
예제 #12
0
        public List <Users> GetEndUserList(int limit, int offset, string order, string sort, string FirstName, string LastName, string Email, string Photo, int userType, int Role, int industryId, out int total)
        {
            AzureDBContext db   = new AzureDBContext();
            var            data = Context.Set <Users>().Where(x => x.IsDeleted == false);

            if (userType == 3) // SUperadmin
            {
                if (Role == 1)
                {
                    data = Context.Set <Users>().Where(x => x.UserTypeId != 3 && x.IsDeleted == false && x.UserTypeId == 1);
                }
                else if (Role == 2)
                {
                    data = Context.Set <Users>().Where(x => x.IsDeleted == false && x.UserTypeId == 2);
                }
                else if (Role == 3)
                {
                    data = Context.Set <Users>().Where(x => x.UserTypeId != 3 && x.IsDeleted == false);
                }
            }
            else if (userType == 2) // Admin
            {
                data = Context.Set <Users>().Where(x => x.UserTypeId == 1 && x.IsDeleted == false && x.IndustryId == industryId);
            }
            if (!string.IsNullOrEmpty(FirstName))
            {
                data = data.Where(x => x.FirstName.Contains(FirstName));
            }
            if (!string.IsNullOrEmpty(LastName))
            {
                data = data.Where(x => x.LastName.Contains(LastName));
            }
            if (!string.IsNullOrEmpty(Photo))
            {
                data = data.Where(x => x.Photo.Contains(Photo));
            }
            if (!string.IsNullOrEmpty(Email))
            {
                data = data.Where(x => x.Email.Contains(Email));
            }
            //Order by
            GetSortedData(ref data, sort + order.ToUpper());
            total = data.Count();
            return(data.Skip(offset).Take(limit).ToList());
        }
예제 #13
0
        public async Task <Results <ADBParishRec> > ParishRecList(int parishId)
        {
            var parishList = new List <ADBParishRec>();

            var results = new Results <ADBParishRec>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.ParishRecords.Where(w => w.ParishId == parishId);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged)
                {
                    parishList.Add(new ADBParishRec()
                    {
                        Id               = app.Id,
                        ParishId         = app.ParishId,
                        DataTypeId       = app.DataTypeId,
                        OriginalRegister = app.OriginalRegister,
                        RecordType       = app.RecordType,
                        Year             = app.Year,
                        YearEnd          = app.YearEnd
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = parishList;
            results.Page          = 0;
            results.total_pages   = 1;
            results.total_results = totalRecs;

            return(results);
        }
        public async Task <Results <SiteFunction> > ListAsync(int applicationId, ClaimsPrincipal user)
        {
            var results = new Results <SiteFunction>();

            _sites = new List <SiteFunction>();
            try
            {
                var a        = new AzureDBContext(_imsConfigHelper.MSGGenDB01);
                var pageList = a.MsgPages.ToList();
                var app      = a.Msgfunctions.Where(fi => fi.ApplicationId == applicationId);


                foreach (var f in app)
                {
                    var page = pageList.FirstOrDefault(p => p.Id == f.Page);

                    var siteFunction = new SiteFunction()
                    {
                        Id            = f.Id,
                        Name          = f.Name,
                        Description   = f.Description,
                        PageName      = page.Name,
                        PageTitle     = page.Title,
                        ApplicationId = applicationId
                    };

                    _sites.Add(siteFunction);
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = _sites;
            results.Page          = 0;
            results.total_pages   = 1;
            results.total_results = results.results.Count();

            return(results);
        }
        public async Task <Results <TreeRec> > TreeList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <TreeRec>();
            var results  = new Results <TreeRec>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.TreeRecord.WhereIfOrigin(searchParams.Origin).TreeRecSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new TreeRec()
                    {
                        Id          = app.ID,
                        CM          = app.CM,
                        Located     = app.Located,
                        Origin      = app.Origin ?? "",
                        PersonCount = app.PersonCount,
                        Name        = app.Name
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
예제 #16
0
        /// <summary>
        /// Check the user activity
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            int Created           = 0;
            int ImpersonateUserId = SessionManager.LoggedInUser.ImpersonateUserId;

            if (ImpersonateUserId != 0)
            {
                Created = ImpersonateUserId;
            }
            else
            {
                Created = SessionManager.LoggedInUser.UserID;
            }
            //Stores the Request in an Accessible object
            var    request  = filterContext.HttpContext.Request;
            string hostName = Dns.GetHostName();
            string myIP     = (HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"] ??
                               HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]).Split(',')[0].Trim();
            // Generate an Audit
            smActivityLog activity = new smActivityLog()
            {
                UserId    = SessionManager.LoggedInUser.UserID,
                IpAddress = myIP,
                UserName  = (request.IsAuthenticated) ?
                            filterContext.HttpContext.User.Identity.Name : "Anonymous",
                //The URL that was accessed
                AreaAccessed = request.RawUrl,
                //Creates our Timestamp
                TimeStamp = DateTime.UtcNow,
                Event     = Event,
                Message   = Message,
                CreatedBy = Created
            };

            AzureDBContext db = new AzureDBContext();

            db.smActivityLogs.Add(activity);
            db.SaveChanges();

            base.OnActionExecuting(filterContext);
        }
예제 #17
0
        public async Task <Results <ADBInternalSourceType> > SourceTypeList(ADBSourceParamObj searchParams)
        {
            var parishList = new List <ADBInternalSourceType>();

            var results = new Results <ADBInternalSourceType>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.SourceTypes.OrderBy(o => o.Id);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    parishList.Add(new ADBInternalSourceType()
                    {
                        Id = app.Id,
                        SourceDateAdded = app.SourceDateAdded,
                        SourceTypeDesc  = app.SourceTypeDesc
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = parishList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
예제 #18
0
        public async Task <Results <ADBParishData> > ParishDataList(int parishId)
        {
            var parishList = new List <ADBParishData>();

            var results = new Results <ADBParishData>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.ParishTranscriptionDetails.Where(w => w.ParishId == parishId);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged)
                {
                    parishList.Add(new ADBParishData()
                    {
                        Id = app.Id,
                        ParishDataString = app.ParishDataString,
                        ParishId         = app.ParishId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = parishList;
            results.Page          = 0;
            results.total_pages   = 1;
            results.total_results = totalRecs;

            return(results);
        }
예제 #19
0
        public async Task <Results <Site> > ListAsync(Dictionary <string, string> query,
                                                      ClaimsPrincipal user)
        {
            List <Site> _sites = new List <Site>();

            var results = new Results <Site>();

            try
            {
                var a        = new AzureDBContext(_imsConfigHelper.MSGGenDB01);
                var pageList = a.MsgPages.ToList();

                foreach (var app in a.Msgapplications)
                {
                    var page = pageList.FirstOrDefault(p => p.Id == app.DefaultPage);

                    _sites.Add(new Site()
                    {
                        Id               = app.Id,
                        Name             = app.ApplicationName,
                        Description      = app.Description,
                        DefaultPageName  = page.Name,
                        DefaultPageTitle = page.Title
                    });
                }
            }
            catch (Exception e) {
                results.Error = e.Message;
            }


            results.results       = _sites;
            results.Page          = 0;
            results.total_pages   = 1;
            results.total_results = results.results.Count();

            return(results);
        }
예제 #20
0
        public List <smActivityLog> GetActivityList(int limit, int offset, string order, string sort, string Name, string Email, int userType, int role, out int total)
        {
            IEnumerable <smActivityLog> data;
            AzureDBContext db = new AzureDBContext();

            var data1 = (from activity in db.smActivityLogs
                         let user = db.Users.Where(c => c.UserId == activity.UserId).FirstOrDefault()
                                    let createdEmail = db.Users.Where(d => d.UserId == activity.CreatedBy).Select(c => c.Email).FirstOrDefault()
                                                       where activity.UserId != 0
                                                       select new
            {
                activity,
                user,
                createdEmail
            });



            if (!string.IsNullOrEmpty(Name))
            {
                data1 = data1.Where(x => x.activity.FirstName.ToLower().Contains(Name) || x.activity.LastName.ToLower().Contains(Name));
            }


            if (!string.IsNullOrEmpty(Email))
            {
                data1 = data1.Where(x => x.activity.UserName.ToLower().Contains(Email));
            }


            if (!string.IsNullOrEmpty(Name))
            {
                data1 = data1.Where(x => x.activity.Name.ToLower().Contains(Name));
            }

            if (role == 1 || role == 2)
            {
                data1 = data1.Where(x => x.user.UserTypeId == role);
            }

            if (userType == 3)
            {
                data1 = data1.Where(r => r.user.UserTypeId != 3);
            }
            else
            {
                data1 = data1.Where(r => r.user.UserTypeId == 1);
            }

            var result = data1.ToList().Select(d => new smActivityLog
            {
                ActivityId     = d.activity.ActivityId,
                UserId         = d.activity.UserId,
                IpAddress      = d.activity.IpAddress,
                UserName       = d.activity.UserName,
                AreaAccessed   = d.activity.AreaAccessed,
                TimeStamp      = d.activity.TimeStamp,
                FirstName      = d.user.FirstName,
                LastName       = d.user.LastName,
                Role           = d.user.UserTypeId,
                Name           = d.user.FirstName + " " + d.user.LastName,
                Email          = d.user.Email,
                Event          = d.activity.Event,
                Message        = d.activity.Message,
                CreatedBy      = d.activity.CreatedBy,
                CreatedByEmail = d.createdEmail
            }).AsEnumerable();

            GetSortedActivityList(ref result, sort + order.ToUpper());
            total = result.Count();
            return(result.Skip(offset).Take(limit).ToList());

            throw new NotImplementedException();
            //data1 = (from a in data1
            //         let createdUser = db.Users.Where(d => d.UserId == a.activity.CreatedBy).FirstOrDefault()
            //         select new smActivityLog
            //             {
            //                 ActivityId = a.activity.ActivityId,
            //                 UserId = a.activity.UserId,
            //                 IpAddress = a.activity.IpAddress,
            //                 UserName = a.activity.UserName,
            //                 AreaAccessed = a.activity.AreaAccessed,
            //                 TimeStamp = a.activity.TimeStamp,
            //                 FirstName = a.user.FirstName,
            //                 LastName = a.user.LastName,
            //                 Role = a.user.UserType,
            //                 Name = a.user.FirstName + " " + a.user.LastName,
            //                 Email = a.user.Email,
            //                 Event = a.activity.Event,
            //                 Message = a.activity.Message,
            //                 CreatedBy = a.activity.CreatedBy,
            //                 CreatedByEmail = createdUser.Email
            //             });


            //GetSortedActivityList(ref data1, sort + order.ToUpper());
            //total = data1.Count();
            //return data1.Skip(offset).Take(limit).ToList();

            //// SuperAdmin
            //if (userType == 3)
            //{
            //    data = (from a in Context.Set<smActivityLog>().AsNoTracking().AsEnumerable()
            //            let user = Context.Set<Users>().AsNoTracking().Where(c => c.UserId == a.UserId).FirstOrDefault()
            //            let createdUser = Context.Set<Users>().AsNoTracking().Where(d => d.UserId == a.CreatedBy).FirstOrDefault()
            //            where a.UserId != 0 && user.UserType != 3
            //            select new smActivityLog
            //            {
            //                ActivityId = a.ActivityId,
            //                UserId = a.UserId,
            //                IpAddress = a.IpAddress,
            //                UserName = a.UserName,
            //                AreaAccessed = a.AreaAccessed,
            //                TimeStamp = a.TimeStamp,
            //                FirstName = user.FirstName,
            //                LastName = user.LastName,
            //                Role = user.UserType,
            //                Name = user.FirstName + " " + user.LastName,
            //                Email = user.Email,
            //                Event = a.Event,
            //                Message = a.Message,
            //                CreatedBy = a.CreatedBy,
            //                CreatedByEmail = createdUser.Email
            //            });
            //}
            //else // Admin
            //{
            //    data = (from a in Context.Set<smActivityLog>().AsNoTracking().AsEnumerable()
            //            let user = Context.Set<Users>().AsNoTracking().Where(c => c.UserId == a.UserId).FirstOrDefault()
            //            let createdUser = Context.Set<Users>().AsNoTracking().Where(d => d.UserId == a.CreatedBy).FirstOrDefault()
            //            where a.UserId != 0 && user.UserType == 1
            //            select new smActivityLog
            //            {
            //                ActivityId = a.ActivityId,
            //                UserId = a.UserId,
            //                IpAddress = a.IpAddress,
            //                UserName = a.UserName,
            //                AreaAccessed = a.AreaAccessed,
            //                TimeStamp = a.TimeStamp,
            //                FirstName = user.FirstName,
            //                LastName = user.LastName,
            //                Role = user.UserType,
            //                Name = user.FirstName + " " + user.LastName,
            //                Email = user.Email,
            //                Event = a.Event,
            //                Message = a.Message,
            //                CreatedBy = a.CreatedBy,
            //                CreatedByEmail = createdUser.Email
            //            });
            //}

            //if (!string.IsNullOrEmpty(Name))
            //{
            //    data = data.Where(x => x.FirstName.ToLower().Contains(Name) || x.LastName.ToLower().Contains(Name));
            //}

            //if (!string.IsNullOrEmpty(Email))
            //{
            //    data = data.Where(x => x.Email.ToLower().Contains(Email));
            //}

            //if (!string.IsNullOrEmpty(Name))
            //{
            //    data = data.Where(x => x.Name.ToLower().Contains(Name));
            //}

            //if (role == 1) // User
            //{
            //    data = data.Where(x => x.Role == 1);
            //}
            //else if (role == 2) // Admin
            //{
            //    data = data.Where(x => x.Role == 2);
            //}
            //else // All
            //{
            //    data = data.ToList();
            //}

            ////Order by
            //GetSortedActivityList(ref data, sort + order.ToUpper());
            //total = data.Count();
            //return data.Skip(offset).Take(limit).ToList();
        }
예제 #21
0
        public ActionResult DisplayInsights(string id)
        {
            InsightsModel model = new ProductInsight.Models.InsightsModel();

            model.id = id; model.positive = model.negative = 0;

            model.RecentReview = new List <Models.Reviews>();
            model.LogisticDept = new List <string>();
            model.FinanceDept  = new List <string>();
            model.QualityDept  = new List <string>();
            model.LineChart    = new SortedDictionary <DateTime, int>();

            var userStore = new UserStore <ApplicationUser>(new ApplicationDbContext());
            var manager   = new UserManager <ApplicationUser>(userStore);
            var curUser   = manager.FindById(User.Identity.GetUserId());


            ViewBag.message = id;
            List <Reviews> rev = AzureDB.ReviewSet.Where(x => x.productID == id && x.AuthToken == curUser.ApiToken).ToList();

            if (rev.Count() == 0)
            {
                return(Content("<div class='alert-danger alert'>The Product ID you searched for cannot be found in our database. Please recheck!</div>"));
            }

            List <Results> idx = new List <Results>();

            rev = rev.OrderByDescending(x => x.timestamp).ToList();

            int count = 0;

            foreach (Reviews p in rev)
            {
                if (p.downvotes > p.upvotes + 5)
                {
                    continue;
                }

                Results Res = AzureDB.ResultSet.Where(x => x.rev_id == p.id).ToList().First();
                p.reviewerText = ProcessReview(p.reviewerText, Res.logisticsDept, Res.qualityDept, Res.financeDept);

                if (Res.rep_score > 2.5)
                {
                    p.Status = true;
                }
                else
                {
                    p.Status = false;
                }

                model.RecentReview.Add(p);

                if (Res.rep_score >= 2.5)
                {
                    model.positive++;
                }
                else
                {
                    model.negative++;
                }
                if (Res.logisticsDept != "0")
                {
                    model.LogisticDept.Add(p.reviewerText);
                }
                if (Res.qualityDept != "0")
                {
                    model.QualityDept.Add(p.reviewerText);
                }
                if (Res.financeDept != "0")
                {
                    model.FinanceDept.Add(p.reviewerText);
                }

                if (!model.LineChart.ContainsKey(p.timestamp.Date))
                {
                    model.LineChart.Add(p.timestamp.Date, 1);
                }
                else
                {
                    model.LineChart[p.timestamp.Date]++;
                }

                count++;
                model.score += Res.rep_score;
            }

            AzureDBContext FeatDB = new AzureDBContext();
            Features       ft     = FeatDB.FeatureSet.Where(x => x.ProductID == id && x.AuthToken == curUser.ApiToken).ToList().First();

            string[] features = ft.Feature.Split(',');
            string[] scores   = ft.FeatureScores.Split(',');

            model.Features = new List <InsightsModel.Pair>();
            for (int i = 0; i < features.Length; i++)
            {
                model.Features.Add(new InsightsModel.Pair(features[i], Convert.ToDouble(scores[i])));
            }



            model.score /= count;
            return(PartialView("ProductView", model));
        }
        public async Task <Results <PersonOfInterestSubset> > PersonOfInterestList(DNASearchParamObj searchParams)
        {
            var dupeList = new List <PersonOfInterestSubset>();
            var results  = new Results <PersonOfInterestSubset>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.PersonsOfInterest
                              .WhereIfTesterName(searchParams.Name)
                              .WhereIfSurname(searchParams.Surname)
                              .WhereIfLocation(searchParams.Location)
                              .WhereIfMinCM(searchParams.MinCM)
                              .WhereIfYearBetween(searchParams.YearStart, searchParams.YearEnd)
                              .PersonOfInterestSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    dupeList.Add(new PersonOfInterestSubset()
                    {
                        Id                   = app.Id,
                        BirthCountry         = app.BirthCountry ?? "",
                        BirthCounty          = app.BirthCounty ?? "",
                        BirthPlace           = app.Location ?? "",
                        BirthYear            = app.Year,
                        ChristianName        = app.ChristianName ?? "",
                        Confidence           = app.Confidence,
                        CreatedDate          = app.CreatedDate,
                        KitId                = app.KitId,
                        Memory               = app.Memory ?? "",
                        Name                 = app.Name ?? "",
                        RootsEntry           = app.RootsEntry,
                        SharedCentimorgans   = app.SharedCentimorgans,
                        TestAdminDisplayName = app.TestAdminDisplayName ?? "",
                        TestDisplayName      = app.TestDisplayName ?? "",
                        TestGuid             = app.TestGuid,
                        TreeUrl              = app.TreeUrl ?? "",
                        Surname              = app.Surname ?? "",

                        PersonId = app.PersonId
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = dupeList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
예제 #23
0
        public async Task <Results <ADBPerson> > PersonList(ADBPersonParamObj searchParams)
        {
            //column sort not needed

            var parishList = new List <ADBPerson>();

            var results = new Results <ADBPerson>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.Persons.WhereIfBirthCounty(searchParams.BirthCounty)
                              .WhereIfBirthLocation(searchParams.BirthLocation)
                              .WhereIfDeathCounty(searchParams.DeathCounty)
                              .WhereIfDeathLocation(searchParams.DeathLocation)
                              .WhereIfFatherChristianName(searchParams.FatherChristianName)
                              .WhereIfFatherOccupation(searchParams.FatherOccupation)
                              .WhereIfFatherSurname(searchParams.FatherSurname)
                              .WhereIfMotherChristianName(searchParams.MotherChristianName)
                              .WhereIfMotheSurname(searchParams.MotherSurname)
                              .WhereIfOccupation(searchParams.Occupation)
                              .WhereIfPersonWithinYears(searchParams.YearStart, searchParams.YearEnd)
                              .WhereIfSource(searchParams.Source)
                              .WhereIfSpouseName(searchParams.SpouseName)
                              .WhereIfSpouseSurname(searchParams.SpouseSurname)
                              .WhereIfSurname(searchParams.Surname)
                              .WhereIfFirstName(searchParams.FirstName)
                              .PersonSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    parishList.Add(new ADBPerson()
                    {
                        Id                  = app.Id,
                        BapInt              = app.BapInt,
                        BaptismDateStr      = app.BaptismDateStr,
                        BirthCounty         = app.BirthCounty,
                        BirthDateStr        = app.BirthDateStr,
                        BirthInt            = app.BirthInt,
                        BirthLocation       = app.BirthLocation,
                        ChristianName       = app.ChristianName,
                        DateAdded           = app.DateAdded,
                        DateLastEdit        = app.DateLastEdit,
                        DeathCounty         = app.DeathCounty,
                        DeathDateStr        = app.DeathDateStr,
                        DeathInt            = app.DeathInt,
                        DeathLocation       = app.DeathLocation,
                        EstBirthYearInt     = app.EstBirthYearInt,
                        EstDeathYearInt     = app.EstDeathYearInt,
                        EventPriority       = app.EventPriority,
                        FatherChristianName = app.FatherChristianName,
                        //FatherId = app.FatherId,
                        FatherOccupation    = app.FatherOccupation,
                        FatherSurname       = app.FatherSurname,
                        IsDeleted           = app.IsDeleted,
                        IsEstBirth          = app.IsEstBirth,
                        IsEstDeath          = app.IsEstDeath,
                        IsMale              = app.IsMale,
                        MotherChristianName = app.MotherChristianName,
                        // MotherId = app.MotherId,
                        MotherSurname     = app.MotherSurname,
                        Notes             = app.Notes,
                        Occupation        = app.Occupation,
                        OrigFatherSurname = app.OrigFatherSurname,
                        OrigMotherSurname = app.OrigMotherSurname,
                        OrigSurname       = app.OrigSurname,
                        ReferenceDateInt  = app.ReferenceDateInt,
                        ReferenceDateStr  = app.ReferenceDateStr,
                        ReferenceLocation = app.ReferenceLocation,
                        Source            = app.Source,
                        SpouseName        = app.SpouseName,
                        SpouseSurname     = app.SpouseSurname,
                        Surname           = app.Surname,
                        TotalEvents       = app.TotalEvents,
                        UniqueRef         = app.UniqueRef
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = parishList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
예제 #24
0
        public async Task <Results <ADBMarriage> > MarriageList(ADBMarriageParamObj searchParams)
        {
            var marriageList = new List <ADBMarriage>();

            var results = new Results <ADBMarriage>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                var unpaged = a.Marriages.WhereIfMatchParticipants(searchParams.MaleSurname, searchParams.FemaleSurname)
                              .WhereIfLocation(searchParams.Location)
                              .WhereIfYearBetween(searchParams.YearStart, searchParams.YearEnd)
                              .MarriageSortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    marriageList.Add(new ADBMarriage()
                    {
                        Id                 = app.Id,
                        Date               = app.Date,
                        DateAdded          = app.DateAdded,
                        DateLastEdit       = app.DateLastEdit,
                        EventPriority      = app.EventPriority,
                        FemaleBirthYear    = app.FemaleBirthYear,
                        FemaleCname        = app.FemaleCname,
                        FemaleInfo         = app.FemaleInfo,
                        FemaleIsKnownWidow = app.FemaleIsKnownWidow,
                        FemaleLocation     = app.FemaleLocation,
                        FemaleOccupation   = app.FemaleOccupation,
                        FemaleSname        = app.FemaleSname,
                        IsBanns            = app.IsBanns,
                        IsLicence          = app.IsLicence,
                        MaleBirthYear      = app.MaleBirthYear,
                        MaleCname          = app.MaleCname,
                        MaleInfo           = app.MaleInfo,
                        MaleIsKnownWidower = app.MaleIsKnownWidower,
                        MaleLocation       = app.MaleLocation,
                        MaleOccupation     = app.MaleOccupation,
                        MaleSname          = app.MaleSname,
                        MarriageCounty     = app.MarriageCounty,
                        MarriageLocation   = app.Location,
                        Source             = app.Source,
                        TotalEvents        = app.TotalEvents,
                        UniqueRef          = app.UniqueRef,
                        Witness1           = app.Witness1,
                        Witness2           = app.Witness2,
                        Witness3           = app.Witness3,
                        Witness4           = app.Witness4
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = marriageList;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }
예제 #25
0
        public async Task <Results <Will> > NorfolkWillsList(WillSearchParamObj searchParams)
        {
            var _wills = new List <Will>();

            var results = new Results <Will>();

            int totalRecs = 0;

            try
            {
                var a = new AzureDBContext(_imsConfigHelper.MSGGenDB01);

                //searchParams.First

                Func <int, int, bool> validDates = (start, end) => {
                    if (start <= 0 && end <= 0)
                    {
                        return(false);
                    }
                    if (start > end)
                    {
                        return(false);
                    }

                    return(true);
                };

                var unpaged = a.NorfolkWills
                              .WhereIf(!string.IsNullOrEmpty(searchParams.Surname), w => w.Surname.ToLower().Contains(searchParams.Surname))
                              .WhereIf(!string.IsNullOrEmpty(searchParams.Desc), w => w.Description.ToLower().Contains(searchParams.Desc))
                              .WhereIf(!string.IsNullOrEmpty(searchParams.RefArg), w => w.Reference.ToLower().Contains(searchParams.RefArg))
                              .WhereIf(!string.IsNullOrEmpty(searchParams.Place), w => w.Place.ToLower().Contains(searchParams.Place))
                              .WhereIf(validDates(searchParams.YearStart, searchParams.YearEnd),
                                       w => w.Year >= searchParams.YearStart && w.Year <= searchParams.YearEnd)
                              .SortIf(searchParams.SortColumn, searchParams.SortOrder);

                totalRecs = unpaged.Count();

                foreach (var app in unpaged.Skip(searchParams.Offset).Take(searchParams.Limit))
                {
                    _wills.Add(new Will()
                    {
                        Id          = app.Id,
                        Aliases     = app.Aliases ?? "",
                        Collection  = app.Collection ?? "",
                        DateString  = app.DateString ?? "",
                        Description = app.Description ?? "",
                        FirstName   = app.FirstName ?? "",
                        Occupation  = app.Occupation ?? "",
                        Place       = app.Place ?? "",
                        Reference   = app.Reference ?? "",
                        Surname     = app.Surname ?? "",
                        Typ         = app.Typ.GetValueOrDefault(),
                        Url         = app.Url ?? "",
                        Year        = app.Year
                    });
                }
            }
            catch (Exception e)
            {
                results.Error = e.Message;
            }



            results.results       = _wills;
            results.Page          = searchParams.Offset == 0 ? 0 : searchParams.Offset / searchParams.Limit;
            results.total_pages   = totalRecs / searchParams.Limit;
            results.total_results = totalRecs;

            return(results);
        }