Beispiel #1
0
 public Incident(Organization org)
 {
     this.IncidentIdentifier = Guid.NewGuid();
     this.LocationAddresses = new List<IncidentAddress>();
     this.Units = new List<IncidentUnit>();
     this.Notes = new List<IncidentNote>();
     this.OrganizationId = org.Id;
 }
 public ActionResult Index(int orgID)
 {
     Organization orgModel = new Organization();
     using (var db = new StationCADDb())
     {
         orgModel = db.Organizations
             .Include("Addresses")
             .Include("IncidentHistory")
             .Where(x => x.Id == orgID)
             .FirstOrDefault();
     }
     return View(orgModel);
 }
        public void TestDispatchEventParsing()
        {
            string tag = "CC51-FWFC";
            using (var db = new StationCADDb())
            {

                string data;
                using (StreamReader sr = new StreamReader(@"TestData\UnitDispatchReport-F16001716.htm"))
                { data = sr.ReadToEnd(); }
                DispatchManager dispMgr = new DispatchManager();

                Organization org = db.Organizations.Where(x => x.Tag == tag).FirstOrDefault();
                if (org == null)
                {
                    org = new Organization();
                    org.Name = "First West Chester Fire Company";
                    org.Status = OrganizationStatus.Active;
                    org.Type = OrganizationType.Fire;
                    org.Tag = tag;
                    org.ContactEmail = "*****@*****.**";
                    org.ContactPhone = "610.883.3253";

                    db.Organizations.Add(org);
                    try
                    {
                        db.SaveChanges();
                    }
                    catch (Exception ex)
                    {
                        ex.ToString();
                    }
                }
                // Add UserProfile
                string email = "*****@*****.**";
                User user;
                UserProfile usrp;
                user = db.Users
                    .Include("Profile")
                    .Include("Profile.OrganizationAffiliations")
                    .Include("Profile.MobileDevices")
                    .Where(w => w.Email == email)
                    .FirstOrDefault();
                if (user == null)
                {
                    user = new User { Id = Guid.NewGuid().ToString(), UserName = email, Email = email };
                    usrp = new UserProfile();
                    usrp.FirstName = string.Format("FirstName_{0}", DateTime.Now.Ticks);
                    usrp.LastName = string.Format("LastName_{0}", DateTime.Now.Ticks);
                    usrp.AccountEmail = email;                    usrp.IdentificationNumber = DateTime.Now.Ticks.ToString();
                    //usrp.UserName = string.Format("{0}.{1}", usrp.FirstName, usrp.LastName);
                    usrp.OrganizationAffiliations = new List<OrganizationUserAffiliation>();
                    usrp.OrganizationAffiliations.Add(new OrganizationUserAffiliation { Status = OrganizationUserStatus.Active, Role = OrganizationUserRole.User });
                    usrp.NotificationEmail = email;
                    usrp.MobileDevices = new List<UserMobileDevice>();
                    usrp.MobileDevices.Add(new UserMobileDevice { Carrier = MobileCarrier.ATT, EnableSMS = true, MobileNumber = "6108833253" });
                    user.Profile = usrp;
                    user.Profile.OrganizationAffiliations = new List<OrganizationUserAffiliation>();
                    OrganizationUserAffiliation uoa = new OrganizationUserAffiliation();
                    uoa.CurrentOrganization = org;
                    uoa.Role = OrganizationUserRole.User;
                    uoa.Status = OrganizationUserStatus.Active;

                    user.Profile.OrganizationAffiliations.Add(uoa);
                    db.Users.Add(user);
                }

                //usr2 = db.UserProfiles
                //    .Include("OrganizationAffiliations")b
                //    .Include("MobileDevices")
                //    .Where(w => w.NotificationEmail == "*****@*****.**")
                //    .FirstOrDefault();
                //if (usr2 == null)
                //{
                //    usr2 = new UserProfile();
                //    usr2.FirstName = "Michael";
                //    usr2.LastName = "Lam";
                //    usr2.IdentificationNumber = DateTime.Now.Ticks.ToString();
                ////    usr2.UserName = string.Format("{0}.{1}", usr2.FirstName, usr2.LastName);
                //    usr2.OrganizationAffiliations = new List<UserOrganizationAffiliation>();
                //    usr2.OrganizationAffiliations.Add(new UserOrganizationAffiliation { Status = OrganizationUserStatus.Active, Role = OrganizationUserRole.User });
                //    usr2.NotificationEmail = "*****@*****.**";
                //    usr2.MobileDevices = new List<UserMobileDevice>();
                //    usr2.MobileDevices.Add(new UserMobileDevice { Carrier = MobileCarrier.ATT, EnableSMS = true, MobileNumber = "6108833253" });
                //    db.UserProfiles.Add(usr2);
                //}
                db.SaveChanges();
                dispMgr.ProcessEvent(org, data, DispatchManager.MessageType.Html);

                //db.UserProfiles.Remove(usrp);
                //db.SaveChanges();
            }
        }