Esempio n. 1
0
        public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
        {
            var results = new List<ValidationResult>();
            var Distinct = new List<Guid>();

            Distinct.AddRange(this.BoardMembers.Where(b => b != Guid.Empty));
            Distinct.AddRange(this.Alternate.Where(b => b != Guid.Empty));
            Distinct.Add(Chairmann);
            Distinct.Add(Accountant);
            if (Auditor != Guid.Empty) Distinct.Add(Auditor);
            if (AuditorAlternate != Guid.Empty) Distinct.Add(AuditorAlternate);

            int BoardMembers = this.BoardMembers == null ? 0 : this.BoardMembers.Where(g => g != Guid.Empty).Count();
            int BoardAlternate = this.Alternate == null ? 0 : this.Alternate.Where(g => g != Guid.Empty).Count();

            if (Chairmann == Guid.Empty) results.Add(new ValidationResult(General.BoardCharimannMissing));
            if (Accountant == Guid.Empty) results.Add(new ValidationResult(General.BoardAccountantMissing));
            //if (Auditor == Guid.Empty) results.Add(new ValidationResult(General.BoardAuditorMissing));
            
            if (BoardMembers < minMember)
            {
                results.Add(new ValidationResult(string.Format(General.BoardMemeberMin, minMember)));
            }
            if (BoardMembers > maxMember)
            {
                results.Add(new ValidationResult(string.Format(General.BoardMemeberMax, maxMember)));
            }
            if (BoardAlternate < minAlternate)
            {
                results.Add(new ValidationResult(string.Format(General.BoardAlternateMin, minAlternate)));
            }
            if (BoardAlternate > maxAlternate)
            {
               results.Add(new ValidationResult(string.Format(General.BoardAlternateMax, maxAlternate)));
            }
            if (ConfigurationManager.AppSettings["BoardEvenOdd"].ToLower() == "odd" & BoardMembers % 2 == 0)
            {
                results.Add(new ValidationResult(General.BoardOdd));
            }
            if (ConfigurationManager.AppSettings["BoardEvenOdd"].ToLower() == "even" & BoardMembers % 2 != 0)
            {
                results.Add(new ValidationResult(General.BoardEven));
            }
            if (Distinct.Count() != Distinct.Distinct().Count())
            {
                results.Add(new ValidationResult(General.BoardSamePerson));
            }


            return results;
        }
Esempio n. 2
0
        // GET: Admin/News
        public ActionResult Index()
        {

            List<NewsAdminViewModel> result = new List<NewsAdminViewModel>();

            foreach (News N in reposetory.GetNews())
            {
                NewsAdminViewModel tmp = new NewsAdminViewModel
                {
                    News = N
                };
                if (N.Source == LevelType.Local)
                { 
                    tmp.Association = reposetory.GetAssociation(N.SourceLink);
                    tmp.SourceName = tmp.Association == null ? "-" : tmp.Association.Name;
                }
                if (N.Source == LevelType.Network)
                { 
                    tmp.Network = reposetory.GetNetwork(N.SourceLink);
                    tmp.SourceName = tmp.Network == null ? "-" : tmp.Network.NetworkName;
                }
                result.Add(tmp);
            }

            return View(result);
        }
Esempio n. 3
0
        public ActionResult NewMessage(MessageListModel MessageContext)
        {
            List<NR.Models.NRMembership> Active = new List<NR.Models.NRMembership>();
            if (MessageContext.NewMessageTo == null || !MessageContext.NewMessageTo.Any())
            {
                ModelState.AddModelError("NewMessageTo", General.ErrorNoRecipients);

            }

            if (MessageContext.Short)
            {
                if (String.IsNullOrWhiteSpace(MessageContext.BodyShort)) ModelState.AddModelError("BodyShort", General.ErrorNoBody);
            }
            else
            {
                if (String.IsNullOrWhiteSpace(MessageContext.Head) & String.IsNullOrWhiteSpace(MessageContext.Body)) ModelState.AddModelError("", General.ErrorNoHeadOrBody);
            }

            if (ModelState.IsValid)
            {
                //An entity object cannot be referenced by multiple instances of IEntityChangeTracker

                Message Msg = new Message
                {
                    Recivers = new List<MessageReciver>(),
                    SenderID = CurrentProfile.PersonID
                };

                List<Guid> Recivers = new List<Guid>();

                Active = reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID);



                foreach (Guid PersonID in MessageContext.NewMessageTo)
                {
                    if (PersonID == MistConversations.Int2Guid(0))
                    {
                        Recivers = Active.Select(m => m.Person.PersonID).ToList();
                    }
                    else if (PersonID == MistConversations.Int2Guid(1))
                    {
                        Recivers.AddRange(reposetory.GetAssociationTeamLeadersPersons(CurrentProfile.AssociationID).Select(m => m.PersonID).ToList());
                    }
                    else if (PersonID == MistConversations.Int2Guid(2))
                    {
                        Recivers.AddRange(reposetory.GetAssociationBoardPersons(CurrentProfile.AssociationID).Select(m => m.PersonID).ToList());
                    }
                    else if (PersonID == MistConversations.Int2Guid(3))
                    {
                        Recivers.AddRange(reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID, Gender.Woman).Select(m => m.PersonID).ToList());
                    }
                    else if (PersonID == MistConversations.Int2Guid(4))
                    {
                        Recivers.AddRange(reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID, Gender.Man).Select(m => m.PersonID).ToList());
                    }
                    else
                    {
                        Recivers.Add(PersonID);
                    }
                }

                //Recivers = Recivers.Distinct().ToList();

                Msg.Recivers = Recivers.Distinct().Select(Id => new MessageReciver { ReciverID = Id }).ToList();
                //.Add(
                //   new MessageReciver
                //   {
                //       ReciverID = Active.Where(p => p.PersonID == PersonID).FirstOrDefault().PersonID
                //   }
                //   );
                if (MessageContext.Short)
                {
                    Msg.Body = MessageContext.BodyShort;
                    Msg.Type = MessageType.shortMessage;
                }
                else
                {
                    Msg.Head = MessageContext.Head;
                    Msg.Body = MessageContext.Body;
                    Msg.Type = MessageType.LongMessage;
                }
                reposetory.MessageSend(Msg);
                ViewBag.FormSucces = true;

            }


            List<SelectListItem> AssItems = reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID).Select(d => new SelectListItem { Value = d.Person.PersonID.ToString(), Text = d.Person.FullName }).ToList();
            AssItems.Insert(0, new SelectListItem { Text = General.GenderMale, Value = MistConversations.Int2Guid(4).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.GenderFemale, Value = MistConversations.Int2Guid(3).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.Board, Value = MistConversations.Int2Guid(2).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.Teamleaders, Value = MistConversations.Int2Guid(1).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.All, Value = MistConversations.Int2Guid(0).ToString() });

            MessageContext.List = AssItems;

            return View(MessageContext);
        }
Esempio n. 4
0
        //[HttpPost]
        public ActionResult _GetDirectory(string id)
        {
            string DirSetting = Url.Content(ConfigurationManager.AppSettings["BrowseDir"]);
            UrlHelper u = new UrlHelper(this.ControllerContext.RequestContext);

            if (string.IsNullOrWhiteSpace(id)) id = "/";


            string realPath = Server.MapPath(DirSetting + id);
            if (System.IO.Directory.Exists(realPath))
            {
                
                List<FulexTree> Dir = new List<FulexTree>();
                IEnumerable<string> dirList = Directory.EnumerateDirectories(realPath);
                foreach (string dir in dirList)
                {
                    DirectoryInfo d = new DirectoryInfo(dir);

                    FulexTree dirModel = new FulexTree {
                        name = Path.GetFileName(dir),
                        type = "folder",
                        dataAttributes = new FulexdataAttributes 
                        { 
                            id =  id + Path.GetFileName(dir) + "/",
                            children = d.GetDirectories().Any() ? true : false
                        }
                    };
                    
                    Dir.Add(dirModel);
                   
                }
                IEnumerable<string> fileList = Directory.EnumerateFiles(realPath);
                foreach (string file in fileList)
                {
                    FileInfo f = new FileInfo(file);

                    if ((f.Attributes & FileAttributes.Hidden) != 0) continue;

                    FulexTree dirModel = new FulexTree
                    {
                        name = Path.GetFileName(file),
                        type = "item",
                        url = u.Action("DownloadFile", "SI") + id +  Path.GetFileName(file).Replace(".","|"),
                        dataAttributes = new FulexdataAttributes { id = Path.GetFileName(file) }
                    };

                    switch (f.Extension.ToLower())
                    {
                        case ".pdf":
                            dirModel.name = "<i class=\"fa fa-file-pdf-o\"></i> " + dirModel.name;
                            break;
                        case ".xls":
                        case ".xlt":
                        case ".xlm":
                        case ".xlsx":
                        case ".xlsm":
                        case ".xltx":
                            dirModel.name = "<i class=\"fa fa-file-excel-o\"></i> " + dirModel.name;
                            break;
                        case ".doc":
                        case ".dot":
                        case ".docx":
                        case ".docm":
                        case ".dotm":
                            dirModel.name = "<i class=\"fa fa-file-word-o\"></i> " + dirModel.name;
                            break;
                        case ".ppt":
                        case ".pot":
                        case ".pptx":
                        case ".potm":
                        case ".potx":
                            dirModel.name = "<i class=\"fa fa-file-powerpoint-o\"></i> " + dirModel.name;
                            break;
                        case ".jpg":
                        case ".jpeg":
                        case ".png":
                        case ".gif":
                            dirModel.name = "<i class=\"fa fa-file-image-o\"></i> " + dirModel.name;
                            break;
                        case ".zip":
                            dirModel.name = "<i class=\"fa fa-file-archive-o\"></i> " + dirModel.name;
                            break;
                        case ".mov":
                        case ".mpg":
                        case ".wmv":
                            dirModel.name = "<i class=\"fa fa-file-video-o\"></i> " + dirModel.name;
                            break;
                        case ".html":
                            dirModel.name = "<i class=\"fa fa-file-code-o\"></i> " + dirModel.name;
                            break;
                        default:
                            dirModel.name = "<i class=\"fa fa-file-o\"></i> " + dirModel.name;
                            break;

                    }
                    
                    //dirModel.name = "<a href=\"" + u.Action("DownloadFile", "SI", new { src = System.Web.HttpUtility.UrlEncode(id + Path.GetFileName(file)) }) + "\" target=\"_blank\" >" + dirModel.name + "</a>";


                  Dir.Add(dirModel);

                    
                    
                    
                    
                }




                return Json(new
                {
                    error = "",
                    status = "OK",
                    data = Dir
                },
                JsonRequestBehavior.AllowGet);
            }
            return null;
        }
Esempio n. 5
0
        public ActionResult Edit (Lead lead)
        {

            Lead dbLead = new Lead();
            if (lead.LeadID != Guid.Empty)
            {
                dbLead = reposetory.GetLead(lead.LeadID);
                if (dbLead == null) return RedirectToAction("Index");
            }
           
            if (ModelState.IsValid)
            {
                LeadStatus oldStatus = dbLead.Status;
                
                
                
                dbLead.FirstName = lead.FirstName;
                dbLead.FamilyName = lead.FamilyName;
                dbLead.Status = lead.Status;
                dbLead.AssociationID = lead.AssociationID == Guid.Empty ? null : lead.AssociationID;
                dbLead.Address = lead.Address;
                dbLead.City = lead.City;
                dbLead.Zip = lead.Zip;
                dbLead.Phone = lead.Phone;
                dbLead.Mobile = lead.Mobile;
                dbLead.Email = lead.Email;
                dbLead.Age = lead.Age;
                dbLead.Comments = lead.Comments;
                dbLead.RequestUpdateMail = false;

                if (reposetory.Save(dbLead))
                {
                    if ((oldStatus == LeadStatus.New | oldStatus == LeadStatus.Acknowledge | 
                        oldStatus == LeadStatus.Clarification  | lead.LeadID == Guid.Empty) 
                        & dbLead.Status == LeadStatus.Assigned & dbLead.AssociationID != null)
                    {
                        string to = string.Empty;
                        List<string> cc = new List<string>();

                        AccessModel Access = reposetory.GetAccess((Guid)dbLead.AssociationID);

                        BoardModelView Board = reposetory.GetBoardView((Guid)dbLead.AssociationID);

                        to = string.Format("{0} <{1}>", Board.Chairmann.FullName, Board.Chairmann.Email);

                        foreach (PersonAccess M in Access.Form)
                        {
                            if (M.Secretary)
                            {
                                NRMembership p =  reposetory.GetMembership(M.FunctionID);
                                //cc += string.Format("{0},", p.Person.Email);
                                cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                            }
                            else if (M.Planner)
                            {
                                NRMembership p = reposetory.GetMembership(M.FunctionID);
                                //cc += string.Format("{0},", p.Person.Email);
                                cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                            }
                        }
                        
                        
                        
                        var mail = new LeadAssign
                        {
                            to = to,
                            cc = cc,
                            lead  = dbLead
                        };

                        //return new EmailViewResult(mail);

                        mail.Send();


                    }
                    lead.LeadID = dbLead.LeadID;
                    ModelState.Clear();
                    
                    
                    ViewBag.FormSucces = true;
                }






            }
            
            List<AssociationListModel> tmp = reposetory.GetAssociationList(); //.RemoveAll(item => CU.Memberships.ToList().Exists(p => p.Association.AssociationID == item.AssociationID));
            ViewBag.Attach = new SelectList(tmp, "AssociationID", "Name");
            return View(lead);
        }
Esempio n. 6
0
        public ActionResult StatusUpdateRequest(Guid ID)
        {
            Lead dbLead = new Lead();

            dbLead = reposetory.GetLead(ID);
            if (dbLead == null) return null;
            if (dbLead.AssociationID == null) return null;


            dbLead.RequestUpdateMail = true;

            if (reposetory.Save(dbLead))
            {

                if (dbLead.AssociationID != null)
                {
                    string to = string.Empty;
                    List<string> cc = new List<string>();

                    AccessModel Access = reposetory.GetAccess((Guid)dbLead.AssociationID);

                    BoardModelView Board = reposetory.GetBoardView((Guid)dbLead.AssociationID);

                    to = string.Format("{0} <{1}>", Board.Chairmann.FullName, Board.Chairmann.Email);

                    foreach (PersonAccess M in Access.Form)
                    {
                        if (M.Secretary)
                        {
                            NRMembership p = reposetory.GetMembership(M.FunctionID);
                            //cc += string.Format("{0},", p.Person.Email);
                            cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                        }
                        else if (M.Planner)
                        {
                            NRMembership p = reposetory.GetMembership(M.FunctionID);
                            //cc += string.Format("{0},", p.Person.Email);
                            cc.Add(string.Format("{0} <{1}>", p.Person.FullName, p.Person.Email));
                        }
                    }



                    var mail = new LeadRequestUpdate
                    {
                        to = to,
                        cc = cc,
                        lead = dbLead
                    };

                    //return new EmailViewResult(mail);

                    mail.Send();

                }
















                ViewBag.FormSucces = true;
            }

            return RedirectToAction("Index");
        }
Esempio n. 7
0
        public ActionResult Communicate(MessageFolderModel MessageContext)
        {
            List<NR.Models.NRMembership> Active = new List<NR.Models.NRMembership>();
            if (MessageContext.NewMessageTo == null || !MessageContext.NewMessageTo.Any())
            {
                ModelState.AddModelError("NewMessageTo", General.ErrorNoRecipients);

            }

            if (MessageContext.Short)
            {
                if (String.IsNullOrWhiteSpace(MessageContext.BodyShort)) ModelState.AddModelError("BodyShort", General.ErrorNoBody);
            }
            else
            {
                if (String.IsNullOrWhiteSpace(MessageContext.Head) & String.IsNullOrWhiteSpace(MessageContext.Body)) ModelState.AddModelError("", General.ErrorNoHeadOrBody);
            }

            if (ModelState.ContainsKey("Folder.FoldereName"))
                ModelState["Folder.FoldereName"].Errors.Clear();

            MessageContext.Folder = reposetory.GetFolder(MessageContext.Folder.FolderID);
            MessageContext.LinkActive = MessageContext.Folder.Status != FolderStatus.Input;

            if (ModelState.IsValid)
            {

                List<Guid> Recivers = new List<Guid>();

                Active = reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID);
                Person Sender = reposetory.GetPerson(CurrentProfile.PersonID);


                foreach (Guid PersonID in MessageContext.NewMessageTo)
                {
                    if (PersonID == MistConversations.Int2Guid(0))
                    {
                        Recivers = Active.Select(m => m.Person.PersonID).ToList();
                    }
                    else if (PersonID == MistConversations.Int2Guid(1))
                    {
                        Recivers.AddRange(reposetory.GetAssociationTeamLeadersPersons(CurrentProfile.AssociationID).Select(m => m.PersonID).ToList());
                    }
                    else if (PersonID == MistConversations.Int2Guid(2))
                    {
                        Recivers.AddRange(reposetory.GetAssociationPersonsNoFeedback(CurrentProfile.AssociationID, MessageContext.Folder.FolderID).Select(m => m.PersonID).ToList());
                    }
                    else
                    {
                        Recivers.Add(PersonID);
                    }
                }

                foreach (Guid PID in Recivers)
                {
                    Person P = reposetory.GetPerson(PID);
                    if (!string.IsNullOrWhiteSpace(P.Email))
                    {
                        FeedbackFolder email = new FeedbackFolder();
                        //// set up the email ...
                        email.To = P.Email;
                        email.ReplyTo = CurrentProfile.Email;
                        email.folder = MessageContext.Folder;
                        email.Person = P;
                        email.message = MessageContext.Body;
                        email.Link = MessageContext.Link;
                        try
                        {
                            email.Send();
                        }
                        catch (Exception e)
                        {
                            LogFile.Write(e, "Email:" + P.Email);
                        }
                    }
                    if (MessageContext.Short)
                    {
#if DUMMYTEXT
                        ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance("NR.Infrastructure.DummyTextGateway", CurrentProfile.TextServiceProviderUserName, CurrentProfile.TextServiceProviderPassword);
#else
                        ITextMessage SMSGateway = TextServiceProviderFactory.GetTextServiceProviderrInstance(CurrentProfile.TextServiceProvider, CurrentProfile.TextServiceProviderUserName, CurrentProfile.TextServiceProviderPassword);
#endif

                        if (CurrentProfile.PersonID == Guid.Empty)
                        {
                            SMSGateway.FromText = General.SystemTextMessagesFrom;
                        }
                        else
                        {
                            SMSGateway.From = Sender;
                        }
                        
                        //SMSGateway.FromText = CurrentProfile.PersonID == Guid.Empty ? General.SystemTextMessagesFrom : string.IsNullOrWhiteSpace(CurrentProfile.Mobile) ? General.SystemTextMessagesFrom : CurrentProfile.Mobile;
                        SMSGateway.Message = MessageContext.BodyShort.ReplaceTagPerson(P);

                        //if (MessageContext.Link) SMSGateway.Message += "\r\n" + string.Format(General.FeedbackTextLink, Url.Action("FeedBack", "Planning", new { P = PID, F = MessageContext.Folder.FolderID }, "http"));
                        SMSGateway.Recipient = new List<Person> { P };
                        if (DateTime.Now.AddMinutes(1).Hour < 11) SMSGateway.DeliveryTime = DateTime.Now.AddMinutes(1).Date.AddHours(11);
                        reposetory.NewTextMessage(SMSGateway, CurrentProfile.AssociationID);

                        SMSGateway.HandShakeUrl = Url.Action("TextXStatus", "Account", new { ID = SMSGateway.TextId }, "http");

                        if (SMSGateway.Send())
                        {

                        };
                    }

                }

                ViewBag.FormSucces = true;

            }


            List<SelectListItem> AssItems = reposetory.GetAssociationActivePersons(CurrentProfile.AssociationID).Select(d => new SelectListItem { Value = d.Person.PersonID.ToString(), Text = d.Person.FullName }).ToList();
            AssItems.Insert(0, new SelectListItem { Text = General.MissingFeedback, Value = MistConversations.Int2Guid(2).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.Teamleaders, Value = MistConversations.Int2Guid(1).ToString() });
            AssItems.Insert(0, new SelectListItem { Text = General.All, Value = MistConversations.Int2Guid(0).ToString() });

            MessageContext.List = AssItems;

            return View(MessageContext);
        }
Esempio n. 8
0
        public ActionResult View(Guid Id)
        {
            Team team = reposetory.GetTeam(Id);

            if (team == null) return HttpNotFound();
            List<Team> teams = new List<Team>();
            teams.Add(team);
            return View(teams);
        }
Esempio n. 9
0
        public ActionResult _UploadCSV(HttpPostedFileBase file, Guid id, string Forening)
        {
            if (file != null)
            {
                string line;
                Dictionary<string, string> ProfilImages = new Dictionary<string, string>();
                ProfilDirSetting = Server.MapPath(Url.Content(ConfigurationManager.AppSettings["ProfileImage"]));
                var Memberships = new List<NRMembership>();
                List<String[]> Data = new List<String[]>();

                //FileStream aFile = new FileStream("../../sportsResults.csv", FileMode.Open);
                StreamReader sr = new StreamReader(file.InputStream, Encoding.GetEncoding(1252));

                // read data in line by line
                string header = sr.ReadLine();
                if (!header.StartsWith(@"""ID"";""Forening (R)"";""Username"";""Password"";""Indmeldt"";""Fodselsdag"";""Fornavn"";""Efternavn"";""Adresse"";""Postnr"";""By"";""Email"";""Mobil"";""Telefon"";""Notat"";""Aktiv"";""Udmeldt"";""Udmeldt"";""Ønsker IKKE Natteravnenyt"";""Idkort"";""Førstehjælp"";""Grunduddannelse"";""Billede"";""Login"";""Netværk"";""Login"";""Funktioner"";")) return Json(new { success = false, errorMessage = "Ikke korrekt header" });
                Data.Add(header.Split(';'));

                while ((line = sr.ReadLine()) != null)
                {
                    while (!line.Trim().EndsWith("\";"))
                    {
                        line += sr.ReadLine();
                    }
                    var AvivaData = line.Split(';');
                    for (int t = 0; t < AvivaData.Length; t++)
                    {
                        AvivaData[t] = AvivaData[t].TrimStart('"').TrimEnd('"');
                    }


                    if (AvivaData.Length > 15 & (Forening == string.Empty | Forening == AvivaData[1]))
                    {
                        Data.Add(AvivaData);
                        DateTime OutDate;
                        var membership = new NRMembership
                        {
                            Person = new Person()
                        };
                        int Avivaid;
                        if (int.TryParse(AvivaData[0].Trim(), out Avivaid)) membership.Person.IDWEB = Avivaid;
                        membership.Person.UserName = AvivaData[2] + new Guid().ToString();
                        membership.Person.Password = AvivaData[3];
                        if (DateTime.TryParse(AvivaData[4], out OutDate)) membership.SignupDate = OutDate;
                        if (DateTime.TryParse(AvivaData[5], out OutDate)) membership.Person.BirthDate = OutDate;
                        membership.Person.FirstName = AvivaData[6];
                        membership.Person.FamilyName = AvivaData[7];
                        membership.Person.Address = AvivaData[8];
                        membership.Person.Zip = AvivaData[9];
                        membership.Person.City = AvivaData[10];
                        membership.Person.Email = AvivaData[11];
                        membership.Person.Mobile = AvivaData[12];
                        membership.Person.Phone = AvivaData[13];
                        membership.Note = AvivaData[14];

                        membership.Type = AvivaData[15].Contains("x") ? PersonType.Active : PersonType.Passiv;

                        if (AvivaData[16].Contains("x")) membership.AbsentDate = DateTime.Now;
                        if (AvivaData[18].Contains("x")) membership.Person.PrintNewslettet = false;

                        if (AvivaData[26].Contains("Holdleder")) membership.Teamleader = true;
                        if (AvivaData[26].Contains("Administrator")) membership.Secretary = true;

                        if (AvivaData[26].Contains("Formand")) membership.BoardFunction = BoardFunctionType.BoardMember;
                        if (AvivaData[26].Contains("Næstformand")) membership.BoardFunction = BoardFunctionType.BoardMember;
                        if (AvivaData[26].Contains("Kasserer")) membership.BoardFunction = BoardFunctionType.Accountant;
                        if (AvivaData[26].Contains("Sekretær")) membership.BoardFunction = BoardFunctionType.BoardMember;
                        if (AvivaData[26].Contains("Bestyrelses medlem")) membership.BoardFunction = BoardFunctionType.BoardMember;
                        if (AvivaData[26].Contains("Suppleant")) membership.BoardFunction = BoardFunctionType.Alternate;
                        
                        
                        if (AvivaData[26].Contains("Revisor")) membership.BoardFunction = BoardFunctionType.Auditor;
                        if (AvivaData[26].Contains("Revisor Suppleant")) membership.BoardFunction = BoardFunctionType.AuditorAlternate;

                        membership.Person.Gender = Gender.NotDefined;

                        membership.Person.Trim();

                        if (!string.IsNullOrWhiteSpace(membership.Person.FullName) &
                            !string.IsNullOrWhiteSpace(membership.Person.Mobile) &
                            !string.IsNullOrWhiteSpace(membership.Person.Email)
                            )
                        {
                            membership.Person.Country = Country.DK;
                            if (string.IsNullOrWhiteSpace(membership.Person.Phone) | membership.Person.Phone.Length < 8) membership.Person.Phone = String.Empty;
                            if (string.IsNullOrWhiteSpace(membership.Person.Mobile) | membership.Person.Mobile.Length < 8) membership.Person.Mobile = String.Empty;
                            if (membership.Person.Address.Length < 2) membership.Person.Address = "  ";
                            if (membership.Person.Address.Length > 70) membership.Person.Address = membership.Person.Address.Substring(0, 70);
                            if (membership.Person.City.Length < 2) membership.Person.City = "  ";
                            if (membership.Person.Zip.Length < 2) membership.Person.Zip = "  ";
                            if (membership.Person.FirstName.Length < 2) membership.Person.FirstName = "**";
                            if (membership.Person.FamilyName.Length < 2) membership.Person.FamilyName = "**";

                            if (membership.Person.UserName.Length > 10 || Regex.Replace(membership.Person.UserName, @"[^A-Z0-9ÆØÅ]", "") != membership.Person.UserName || WebSecurity.GetUserId(membership.Person.UserName) > 0)
                                GenerateUniqUsername(membership.Person);

                            if (!string.IsNullOrEmpty(membership.Person.Email) && !Regex.IsMatch(membership.Person.Email, @"^\S+@\S+\.\S+$"))
                                membership.Person.Email = "";
                            if (membership.Person.UserName.Length < 3) GenerateUniqUsername(membership.Person);
                            if (Regex.IsMatch(membership.Person.Password, @"^[a-zA-Z0-9æøåÆØÅ*!#%&]{6,10}$")) membership.Person.Password.GeneratePassword();

                            Memberships.Add(membership);
                            if (AvivaData[22].Contains("media/"))
                            {
                                ProfilImages.Add(membership.Person.UserName, AvivaData[22]);
                            }
                        }
                    }

                    //line = sr.ReadLine();
                }
                sr.Close();

                string HtmlData = "<table border=\"1\">";


                foreach (var ld in Data)
                {
                    HtmlData += "<tr>";
                    foreach (string str in ld)
                    {
                        HtmlData += "<td>" + str + "</td>";
                    }

                    HtmlData += "</tr>";
                }
                HtmlData += "</table>";

                using (var context = new Repository())
                {

                    Association association = context.Associations.Find(id);

                    foreach (var M in Memberships)
                    {
                        M.AssociationID = association.AssociationID;
                        context.Entry(M).State = EntityState.Added;
                        try
                        {
                            context.SaveChanges();
                            if (!M.Absent) //&& !WebSecurity.UserExists(m.Person.UserName))
                            {
                                WebSecurity.CreateAccount(M.Person.UserName, M.Person.Password);
                                //if (WebSecurity.ConfirmAccount(M.Person.UserName))
                                //{
                                //    System.Diagnostics.Debug.WriteLine("**Migrating Person: \"" + M.Person.UserName + "\" / (" + M.Person.Password + ")");
                                //}


                            }

                            string ImagePath;
                            if (ProfilImages.TryGetValue(M.Person.UserName, out ImagePath))
                            {

                                var img = DownloadImageFromUrl(string.Format("http://www.natteravnene.dk/aviva/{0}", ImagePath));

                            if (img != null)
                            {
                                string newFileName = string.Format(ProfilDirSetting, M.Person.PersonID.ToString());
                                string newFileLocation = newFileName;
                                if (Directory.Exists(Path.GetDirectoryName(newFileLocation)) == false)
                                {
                                    Directory.CreateDirectory(Path.GetDirectoryName(newFileLocation));
                                }

                                img.Save(newFileLocation);
                                //progress += " - Image transferred";
                            }
                            }

                        }
                        catch (Exception e)
                        {
                            System.Diagnostics.Debug.WriteLine(string.Format("{0} Exception caught.", e));


                        }



                    }
                }


                return Json(new
                           {
                               success = true,
                               data = HtmlData
                           });

            }


            return Json(new { success = false, errorMessage = "Tjaa... Fejl" });
        }
Esempio n. 10
0
        // GET: Migration
        public ActionResult Index()
        {
            List<SelectListItem> Forningliste = new List<SelectListItem>();
            using (SqlConnection cn = new SqlConnection(seedConnectionString))
            {


                SqlCommand cmd = new SqlCommand("SELECT * FROM [Foreninger] ORDER BY Navn", cn);
                cmd.CommandType = CommandType.Text;
                cn.Open();
                var reader = cmd.ExecuteReader(CommandBehavior.CloseConnection);


                Forningliste.Add(new SelectListItem
                {
                    Text = "Alle",
                    Value = "0"
                });

                while ((reader.Read()))
                {
                    int StrId = (int)TjekDBNull(reader["ForeningsID"]);
                    if (StrId != 0 && !NoGoAss.Contains(StrId))
                    {
                        Forningliste.Add(new SelectListItem
                        {
                            Text = (String)reader["Navn"],
                            Value = StrId.ToString()
                        });
                    }
                }
            }


            return View(Forningliste);
        }
Esempio n. 11
0
        public ActionResult RemoveExternalLogins()
        {
            ICollection<OAuthAccount> accounts = OAuthWebSecurity.GetAccountsFromUserName(User.Identity.Name);
            List<ExternalLogin> externalLogins = new List<ExternalLogin>();
            foreach (OAuthAccount account in accounts)
            {
                AuthenticationClientData clientData = OAuthWebSecurity.GetOAuthClientData(account.Provider);

                externalLogins.Add(new ExternalLogin
                {
                    Provider = account.Provider,
                    ProviderDisplayName = clientData.DisplayName,
                    ProviderUserId = account.ProviderUserId,
                });
            }

            ViewBag.ShowRemoveButton = externalLogins.Count > 1 || OAuthWebSecurity.HasLocalAccount(WebSecurity.GetUserId(User.Identity.Name));
            return PartialView("_RemoveExternalLoginsPartial", externalLogins);
        }
Esempio n. 12
0
        public ActionResult Ajax([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest param)
        {
            if (param.Draw == 0)
            {
                return Json(new
                {
                    draw = param.Draw,
                    error = "ERROR"
                },
               JsonRequestBehavior.AllowGet);
            }

            int recordsTotal = reposetory.People.Count();
            int recordsFiltered = recordsTotal;
            List<PersonAdminList> result = new List<PersonAdminList>();


            if (recordsTotal > 0)
            {

                IOrderedQueryable<Person> FilteredPersons;

                //Filtering
                if (param.Search != null && !string.IsNullOrEmpty(param.Search.Value))
                {
                    FilteredPersons = (IOrderedQueryable<Person>)(from p in reposetory.People.Include(p => p.Memberships.Select(m => m.Association))
                                                                  where p.UserName.Contains(param.Search.Value) | String.Concat(p.FirstName, " ", p.FamilyName).Contains(param.Search.Value) |
                                                                      p.Mobile.Contains(param.Search.Value) | p.Phone.Contains(param.Search.Value) |
                                                                      p.Email.Contains(param.Search.Value)
                                                                  select p);

                    recordsFiltered = (from p in reposetory.People
                                       where p.UserName.Contains(param.Search.Value) | String.Concat(p.FirstName, " ", p.FamilyName).Contains(param.Search.Value) |
                                            p.Mobile.Contains(param.Search.Value) | p.Phone.Contains(param.Search.Value) |
                                            p.Email.Contains(param.Search.Value)
                                       select p).Count();
                }
                else
                {
                    FilteredPersons = (IOrderedQueryable<Person>)reposetory.People;

                }


                //Sorting
                var sortedColumns = param.Columns.GetSortedColumns();
                var isSorted = false;
                string sortdata;
                foreach (var column in sortedColumns)
                {
                    sortdata = column.Data;
                    //Fullname not supportet by Entity ordering
                    if (column.Data == "FullName")
                    {
                        if (!isSorted)
                        {
                            if (column.SortDirection == DataTables.Mvc.Column.OrderDirection.Ascendant)
                            {
                                FilteredPersons = FilteredPersons.OrderBy(p => p.FirstName.Trim()).ThenBy(p => p.FamilyName.Trim());

                            }
                            else
                            {
                                FilteredPersons = FilteredPersons.OrderByDescending(p => p.FirstName.Trim()).ThenByDescending(p => p.FamilyName.Trim());
                            }
                        }
                        else
                        {
                            if (column.SortDirection == DataTables.Mvc.Column.OrderDirection.Ascendant)
                            {
                                FilteredPersons = FilteredPersons.ThenBy(p => p.FirstName).ThenBy(p => p.FamilyName);

                            }
                            else
                            {
                                FilteredPersons = FilteredPersons.ThenByDescending(p => p.FirstName).ThenByDescending(p => p.FamilyName);
                            }
                        }
                        isSorted = true;
                    }

                    else if (!isSorted)
                    {
                        if (column.SortDirection == DataTables.Mvc.Column.OrderDirection.Ascendant)
                        {
                            FilteredPersons = FilteredPersons.OrderBy(column.Data);

                        }
                        else
                        {
                            FilteredPersons = FilteredPersons.OrderByDescending(column.Data);
                        }

                        isSorted = true;
                    }
                    else
                    {
                        if (column.SortDirection == DataTables.Mvc.Column.OrderDirection.Ascendant)
                        {
                            FilteredPersons = FilteredPersons.ThenBy(column.Data);
                        }
                        else
                        {
                            FilteredPersons = FilteredPersons.OrderByDescending(column.Data);
                        }
                    }
                }

                foreach (Person p in FilteredPersons.Skip(param.Start)
                            .Take(param.Length == 0 ? 10 : param.Length).Include("Memberships.Association").Include("Causes.Cause"))
                {
                    result.Add(new PersonAdminList(p));
                }



            }
            return Json(new
            {
                draw = param.Draw,
                recordsTotal = recordsTotal,
                recordsFiltered = recordsFiltered,
                error = "",
                data = result
            },
            JsonRequestBehavior.AllowGet);
        }
Esempio n. 13
0
        public ActionResult PrintNewsList()
        {
            IEnumerable<PrintMailingModel> All = reposetory.GetPrintNewsPersons().Select(X => new PrintMailingModel(X)).ToList();

            List<PrintMailingModel> result = new List<PrintMailingModel>();

            //var duplicate = All.GroupBy(x => x.SortAddress).Where(x => x.Count() > 1).Select(x => x);
            var duplicate = All.GroupBy(x => x.SortAddress).Select(x => x);
            foreach (var group in duplicate)
            {
                PrintMailingModel tmpMail = null;
                foreach (PrintMailingModel item in group)
                {
                    if (!string.IsNullOrWhiteSpace(item.Address) & !string.IsNullOrWhiteSpace(item.Zip) & !string.IsNullOrWhiteSpace(item.City))
                    {
                        if (tmpMail == null)
                        {
                            tmpMail = item;
                            tmpMail.Names = new List<NameModel>();
                            tmpMail.Names.Add(new NameModel { FirstName = item.FirstName, FamilyName = item.FamilyName });
                        }
                        else
                        {
                            tmpMail.ID = "00000000000000000000000000000000";
                            tmpMail.UserName += " / " + item.UserName;
                            tmpMail.Names.Add(new NameModel { FirstName = item.FirstName, FamilyName = item.FamilyName });
                        }
                    }
                }
                if (tmpMail != null) result.Add(tmpMail);
            }
            Response.ClearContent();
            Response.AddHeader("Content-Type", "application/vnd.ms-excel");
            Response.AddHeader("content-disposition", @"attachment;filename=""Natteravne Mailingliste.xls""");
            return View(result.OrderBy(r => r.Country).ThenBy(r => r.Zip).ToList());

        }