예제 #1
0
        public static List <Check> GetResearchChecks()
        {
            List <Check> researchChecks = new List <Check>();

            using (OpidDB opidcontext = new OpidDB())
            {
                List <RCheck> rchecks = opidcontext.RChecks.Select(u => u).ToList();

                foreach (var lu in rchecks)
                {
                    researchChecks.Add(new Check
                    {
                        RecordID          = lu.RecordID,
                        InterviewRecordID = lu.InterviewRecordID,
                        Num         = lu.Num,
                        Name        = lu.Name,
                        Date        = lu.Date,
                        Service     = lu.Service,
                        Disposition = lu.Disposition,
                    });
                }
            }

            return(researchChecks);
        }
예제 #2
0
        public static List <CheckViewModel> GetChecks()
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                var pchecks = (from check in opidcontext.RChecks select check).ToList();

                List <CheckViewModel> checks = new List <CheckViewModel>();

                foreach (RCheck rc in pchecks)
                {
                    checks.Add(new CheckViewModel
                    {
                        RecordID          = rc.RecordID,
                        InterviewRecordID = rc.InterviewRecordID,
                        Num         = rc.Num,
                        Name        = rc.Name,
                        Date        = rc.Date, //rc.Date.ToShortDateString(),
                        Service     = rc.Service,
                        Disposition = rc.Disposition
                    });
                }

                return(checks);
            }
        }
예제 #3
0
 public static void DeleteResearchTable()
 {
     using (OpidDB opidcontext = new OpidDB())
     {
         opidcontext.RChecks.RemoveRange(opidcontext.RChecks);  // Remove all checks from table RChecks (the Research Table)
         opidcontext.SaveChanges();
         return;
     }
 }
예제 #4
0
        // Don't know how to move this to the DataManager where it belongs because of return type issues.
        // Just leave it here for now.
        public JsonResult GetChecks([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest requestModel)
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                IQueryable <RCheck> query = opidcontext.RChecks;

                /* Used when searching for bottleneck.
                 * IQueryable<RCheck> query = opidcontext.RChecks.Where(c => c.Name.StartsWith("A") || c.Name.StartsWith("B") || c.Name.StartsWith("C") || c.Name.StartsWith("D")
                 || c.Name.StartsWith("E") || c.Name.StartsWith("F") || c.Name.StartsWith("G") || c.Name.StartsWith("H") || c.Name.StartsWith("I") || c.Name.StartsWith("J")
                 || c.Name.StartsWith("K") || c.Name.StartsWith("L") || c.Name.StartsWith("M") || c.Name.StartsWith("N") || c.Name.StartsWith("O") || c.Name.StartsWith("P")
                 || c.Name.StartsWith("Q") || c.Name.StartsWith("R") || c.Name.StartsWith("S") || c.Name.StartsWith("T") || c.Name.StartsWith("U") || c.Name.StartsWith("V")
                 || c.Name.StartsWith("W") || c.Name.StartsWith("X") || c.Name.StartsWith("Y") || c.Name.StartsWith("Z"));
                 */

                var totalCount = query.Count();

                // Apply filters for searching
                if (requestModel.Search.Value != string.Empty)
                {
                    var value = requestModel.Search.Value.Trim();
                    query = query.Where(p => p.Name.Contains(value) ||
                                        p.sRecordID.Contains(value) ||
                                        p.sInterviewRecordID.Contains(value) ||
                                        p.sNum.Contains(value) ||
                                        p.sDate.Contains(value) ||
                                        p.Service.Contains(value) ||
                                        p.Disposition.Contains(value)
                                        );
                }

                var filteredCount = query.Count();

                var fqo = query.OrderBy("Id asc");  // Order by the primary key for speed. Oredering by Name times out, because Name is not an indexed field.

                // Paging
                var fqop = fqo.Skip(requestModel.Start).Take(requestModel.Length);

                var data = fqop.Select(rcheck => new
                {
                    sRecordID          = rcheck.sRecordID,
                    sInterviewRecordID = rcheck.sInterviewRecordID,
                    Name = rcheck.Name,
                    sNum = rcheck.sNum,
                    //  Date = rcheck.Date,
                    sDate       = rcheck.sDate,
                    Service     = rcheck.Service,
                    Disposition = rcheck.Disposition
                }).ToList();

                return(Json(new DataTablesResponse(requestModel.Draw, data, filteredCount, totalCount), JsonRequestBehavior.AllowGet));
            }
        }
예제 #5
0
        public static bool ResearchTableIsEmpty()
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                var checks = opidcontext.RChecks;

                if (checks.Count() == 0) // Is the table empty for a restore operation?
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #6
0
        public static Invitation AcceptedInvitation(string userName, string email)
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                Invitation invite = opidcontext.Invitations.Where(i => i.UserName == userName).SingleOrDefault();

                if (invite != null && invite.Email == email)
                {
                    invite.Accepted = DateTime.Today;
                    opidcontext.SaveChanges();
                    return(invite);
                }

                return(null);
            }
        }
예제 #7
0
        private static void AppendToResearchChecks(List <Check> checks)
        {
            try
            {
                using (OpidDB opidcontext = new OpidDB())
                {
                    foreach (Check check in checks)
                    {
                        RCheck existing = opidcontext.RChecks.Where(u => u.Num == check.Num).FirstOrDefault();

                        if (existing == null) // && string.IsNullOrEmpty(check.Clr))
                        {
                            RCheck rcheck = new RCheck
                            {
                                RecordID           = check.RecordID,
                                sRecordID          = check.RecordID.ToString(),
                                InterviewRecordID  = check.InterviewRecordID,
                                sInterviewRecordID = check.InterviewRecordID.ToString(),
                                Num         = check.Num,
                                sNum        = check.Num.ToString(),
                                Name        = check.Name,
                                Date        = check.Date,
                                sDate       = check.Date.ToString("MM/dd/yyyy"),
                                Service     = check.Service,
                                Disposition = check.Disposition,
                            };

                            opidcontext.RChecks.Add(rcheck);
                        }
                        else if (!string.IsNullOrEmpty(check.Disposition))
                        {
                            // The existing check may have its disposition
                            // changed to, for example, Voided/Replaced.
                            // If a file of voided checks contains a check with number existing.Num
                            // then this change of disposition will protect this check from having its status
                            // in Apricot changed from Voided/Replaced to Voided
                            existing.Disposition = check.Disposition;
                        }
                    }

                    opidcontext.SaveChanges();
                }
            }
            catch (Exception e)
            {
            }
        }
예제 #8
0
        public static void MarkMistakenlyResolvedChecks(List <Check> mistakenlyResolved)
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                foreach (Check mr in mistakenlyResolved)
                {
                    List <RCheck> rchecks = opidcontext.RChecks.Where(u => u.Num == mr.Num).ToList();

                    foreach (RCheck rcheck in rchecks)
                    {
                        rcheck.Disposition = "Mistakenly Resolved";
                    }
                }

                opidcontext.SaveChanges();
            }
        }
예제 #9
0
        public static string EditUser(InvitationViewModel invite)
        {
            using (OpidDB referralscontext = new OpidDB())
            {
                Invitation invitation = referralscontext.Invitations.Find(invite.Id);

                if (invitation != null && invitation.Accepted != (System.DateTime)System.Data.SqlTypes.SqlDateTime.Null)
                {
                    return("Registered");
                }

                invitation.UserName = invite.UserName;
                invitation.Email    = invite.Email;
                invitation.Role     = invite.Role;

                referralscontext.SaveChanges();
                return("Success");
            }
        }
예제 #10
0
        public static void ResolveResearchChecks()
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                var researchChecks = opidcontext.RChecks;

                foreach (CheckViewModel check in resolvedChecks)
                {
                    List <RCheck> rchecks = researchChecks.Where(u => u.Num == check.Num || u.Num == -check.Num).ToList();

                    foreach (RCheck rcheck in rchecks)
                    {
                        rcheck.Disposition = check.Disposition;
                    }
                }

                opidcontext.SaveChanges();
            }
        }
예제 #11
0
        /*
         * private static void SendEmailInvitation(InvitationViewModel invitation)
         * {
         *  var message = new MailMessage();
         *  message.To.Add(new MailAddress(invitation.Email));
         *  message.From = new MailAddress(ConfigurationManager.AppSettings["DonotreplyEmailAddr"]);
         *  message.Subject = "Invitation";
         *  message.Body = InvitationMessage(invitation);
         *  message.IsBodyHtml = true;
         *
         *  using (var smtp = new SmtpClient())
         *  {
         *      var credential = new NetworkCredential
         *      {
         *          UserName = ConfigurationManager.AppSettings["GmailUser"],
         *          Password = ConfigurationManager.AppSettings["GmailUserPassword"]
         *      };
         *
         *      smtp.Credentials = credential;
         *      smtp.Host = "smtp.gmail.com";
         *      smtp.Port = 587;
         *      smtp.EnableSsl = true;
         *      smtp.Send(message);
         *  }
         * }
         */

        public static void ExtendInvitation(InvitationViewModel invitation)
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                Invitation invite = new Invitation
                {
                    Extended = DateTime.Today,
                    Accepted = (System.DateTime)System.Data.SqlTypes.SqlDateTime.Null,
                    UserName = invitation.UserName,
                    FullName = invitation.FullName,
                    Email    = invitation.Email,
                    Role     = invitation.Role,
                };

                opidcontext.Invitations.Add(invite);
                opidcontext.SaveChanges();
            }

            //  SendEmailInvitation(invitation);
        }
예제 #12
0
        public async Task <string> DeleteUser(int id)
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                Invitation invite = opidcontext.Invitations.Where(i => i.Id == id).SingleOrDefault();

                if (invite != null)
                {
                    var user = await UserManager.FindByNameAsync(invite.UserName);

                    if (user != null)
                    {
                        UserManager.Delete(user);
                        opidcontext.Invitations.Remove(invite);
                        opidcontext.SaveChanges();
                        return("Success");
                    }
                }

                return("Failure");
            }
        }
예제 #13
0
        private static void RestoreRChecksTable(List <CheckViewModel> rChecks)
        {
            using (OpidDB opidcontext = new OpidDB())
            {
                var checks = opidcontext.RChecks;

                int checkCount = rChecks.Count;
                int i          = 0;

                if (checks.Count() == 0) // Is the table empty for rebuild?
                {
                    foreach (CheckViewModel rc in rChecks)
                    {
                        checks.Add(new RCheck
                        {
                            RecordID           = rc.RecordID,
                            sRecordID          = rc.sRecordID,
                            InterviewRecordID  = rc.InterviewRecordID,
                            sInterviewRecordID = rc.sInterviewRecordID,
                            Num         = rc.Num,
                            sNum        = rc.sNum,
                            Name        = rc.Name,
                            Date        = Convert.ToDateTime(rc.Date),
                            sDate       = Convert.ToDateTime(rc.Date).ToString("MM/dd/yyyy"),
                            Service     = rc.Service,
                            Disposition = rc.Disposition
                        });

                        i += 1;
                        ProgressHub.SendProgress("Restore in progress...", i, checkCount);
                    }

                    opidcontext.SaveChanges();
                    return;
                }
            }
        }