Example #1
0
        public ActionResult Create([Bind(Include = "OrganNo,OrganName,PSUPassport,TitleAdviserName,AdviserName,AdviserLastName,AdviserEmail,AdviserTel,StartPositionDate,EndPositionDate")] Organizations organizations)
        {
            if (ModelState.IsValid)
            {
                db.Organizations.Add(organizations);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(organizations));
        }
Example #2
0
        public static OrganizationModel GetOrganizationModel(Organizations organization)
        {
            if (organization == null)
            {
                return(new OrganizationModel());
            }

            return(new OrganizationModel {
                Id = organization.Id, Name = organization.Name, Address = organization.Address, City = organization.City, State = organization.State, Zip = organization.Zip, Users = UserFactory.GetUserModel(organization.Users)
            });
        }
Example #3
0
 public IActionResult Edit(int id, [Bind("Id,Name,OrganizationTypeId,Longitude,Latitude")] Organizations organizations)
 {
     if (ModelState.IsValid)
     {
         _context.Update(organizations);
         _context.SaveChanges();
         return(RedirectToAction(nameof(Details), new { id = organizations.Id }));
     }
     ViewBag.OrganizationTypeId = new SelectList(_context.OrganizationType, "Id", "Name", organizations.OrganizationTypeId);
     return(View(organizations));
 }
Example #4
0
 public override void Logout()
 {
     _log.Write(LogLevel.Info, "Logging out of GitHub");
     base.Logout();
     SettingsCache.Credentials = null;
     User = null;
     Repositories.Clear();
     Organizations.Clear();
     AllIssues.Clear();
     OnPropertyChanged("Issues");
 }
Example #5
0
        public async Task <IActionResult> Create([Bind("OrganizationId,OrganizationName")] Organizations organizations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(organizations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(organizations));
        }
Example #6
0
        /// <summary>
        /// 添加组织信息
        /// </summary>
        /// <param name="organizations"></param>
        /// <returns></returns>
        public async Task <Organizations> AddOraniztions(Organizations organizations)
        {
            if (organizations == null)
            {
                throw new ArgumentNullException(nameof(organizations));
            }
            dbContext.Organizations.Add(organizations);
            await dbContext.SaveChangesAsync();

            return(organizations);
        }
Example #7
0
        private void CreateContracts()
        {
            for (int i = 1; i <= 10; i++)
            {
                var datumStart = GetRandomDate(new DateTime(2015, 1, 1), true);

                var leverancier = GetRandomItemFromList(Organizations.Where(o => o.OrganizationType == OrganizationType.Supplier).ToList());
                var fabrikant   = GetRandomItemFromList(Organizations.Where(o => o.OrganizationType == OrganizationType.Manufacturer).ToList());
                //var instelling = GetRandomItemFromList(_organizations.Where(o => o.OrganizationType == OrganizationType.Institution).ToList());

                var beheerder     = GetRandomItemFromList(Contacts);
                var ondertekenaar = GetRandomItemFromList(Contacts);

                var auteur        = GetRandomItemFromList(Users);
                var userBeheerder = GetRandomItemFromList(Users);

                var contract = new Contract()
                {
                    Id                     = i,
                    Name                   = "Contract" + i.ToString().PadLeft(3, '0'),
                    Status                 = GetRandomEnum <ContractStatus>(),
                    Revisie                = _random.Next(4).ToString(),
                    DatumStart             = datumStart,
                    DatumEind              = GetRandomDate(datumStart, false),
                    DatumGetekend          = GetRandomDate(datumStart, true),
                    ContractWaarde         = _random.Next(100, 10000),
                    ContractType           = GetRandomEnum <ContractType>(),
                    DocumentUrl            = $"www.somewhereonthenet.com\\document{i.ToString().PadLeft(3, '0')}.pdf",
                    LeverancierId          = leverancier.Id,
                    Leverancier            = leverancier,
                    FabrikantId            = fabrikant.Id,
                    Fabrikant              = fabrikant,
                    ContactBeheerderId     = beheerder.Id,
                    ContactBeheerder       = beheerder,
                    ContactOndertekenaarId = beheerder.Id,
                    ContactOndertekenaar   = ondertekenaar,
                    UserAuteurId           = auteur.Id,
                    UserAuteur             = auteur,
                    UserBeheerderId        = userBeheerder.Id,
                    UserBeheerder          = userBeheerder,
                    Bijlagen               = new List <ContractBijlage>()
                    {
                        CreateRandomBaseModelItem <ContractBijlage>(i)
                    },
                    Componenten = new List <ContractComponent>()
                    {
                        CreateRandomBaseModelItem <ContractComponent>(i)
                    },
                    DocumentType​ = GetRandomEnum <DocumentType>()
                };

                Contracts.Add(contract);
            }
        }
        public static string GetProducts(RestCommand command, int organizationID)
        {
            if (Organizations.GetOrganization(command.LoginUser, organizationID).ParentID != command.Organization.OrganizationID)
            {
                throw new RestException(HttpStatusCode.Unauthorized);
            }
            Products items = new Products(command.LoginUser);

            items.LoadByCustomerID(organizationID);
            return(items.GetXml("Products", "Product", true, command.Filters));
        }
        public static bool IsCompanyValid(string company)
        {
            Organizations organizations = new Organizations(LoginUser.Anonymous);

            organizations.LoadByOrganizationName(company.Trim());
            if (!organizations.IsEmpty)
            {
                return(false);
            }
            return(true);
        }
Example #10
0
        public static int GetParticipantCountForOrganizations(Organizations organizations)
        {
            List <int> idArray = new List <int>();

            foreach (Organization organization in organizations)
            {
                idArray.Add(organization.Identity);
            }

            return(GetParticipantCountForOrganizations(idArray.ToArray()));
        }
Example #11
0
        public Organizations GetByID(int _organizationId)
        {
            OrganizationsDAC _organizationsComponent = new OrganizationsDAC();
            IDataReader      reader         = _organizationsComponent.GetByIDOrganizations(_organizationId);
            Organizations    _organizations = null;

            while (reader.Read())
            {
                _organizations = new Organizations();
                if (reader["OrganizationId"] != DBNull.Value)
                {
                    _organizations.OrganizationId = Convert.ToInt32(reader["OrganizationId"]);
                }
                if (reader["OrganizationName"] != DBNull.Value)
                {
                    _organizations.OrganizationName = Convert.ToString(reader["OrganizationName"]);
                }
                if (reader["OrganizationDescription"] != DBNull.Value)
                {
                    _organizations.OrganizationDescription = Convert.ToString(reader["OrganizationDescription"]);
                }
                if (reader["Phone1"] != DBNull.Value)
                {
                    _organizations.Phone1 = Convert.ToString(reader["Phone1"]);
                }
                if (reader["Phone2"] != DBNull.Value)
                {
                    _organizations.Phone2 = Convert.ToString(reader["Phone2"]);
                }
                if (reader["Phone3"] != DBNull.Value)
                {
                    _organizations.Phone3 = Convert.ToString(reader["Phone3"]);
                }
                if (reader["Fax1"] != DBNull.Value)
                {
                    _organizations.Fax1 = Convert.ToString(reader["Fax1"]);
                }
                if (reader["Fax2"] != DBNull.Value)
                {
                    _organizations.Fax2 = Convert.ToString(reader["Fax2"]);
                }
                if (reader["AddressLine1"] != DBNull.Value)
                {
                    _organizations.AddressLine1 = Convert.ToString(reader["AddressLine1"]);
                }
                if (reader["AddressLine2"] != DBNull.Value)
                {
                    _organizations.AddressLine2 = Convert.ToString(reader["AddressLine2"]);
                }
                _organizations.NewRecord = false;
            }
            reader.Close();
            return(_organizations);
        }
Example #12
0
    private void LoadCustomers()
    {
        cmbCustomers.Items.Clear();
        Organizations organizations = new Organizations(UserSession.LoginUser);

        organizations.LoadByParentID(UserSession.LoginUser.OrganizationID, true);
        foreach (Organization organization in organizations)
        {
            cmbCustomers.Items.Add(new RadComboBoxItem(organization.Name, organization.OrganizationID.ToString()));
        }
    }
Example #13
0
    private void Populate(int levels)
    {
        if (root == null)
        {
            root = Organization.Root;
        }

        Organizations orgs = root.GetTree();


        // We need a real f*****g tree structure.

        Dictionary <int, Organizations> lookup = new Dictionary <int, Organizations>();

        foreach (Organization org in orgs)
        {
            if (!lookup.ContainsKey(org.ParentIdentity))
            {
                lookup[org.ParentIdentity] = new Organizations();
            }

            lookup[org.ParentIdentity].Add(org);
        }
        //Sort rootlevel
        if (lookup.ContainsKey(Organization.RootIdentity))
        {
            lookup[Organization.RootIdentity].Sort(
                delegate(Organization o1, Organization o2)
            {
                if (o1.DefaultCountryId != topSortCountryId && o2.DefaultCountryId != topSortCountryId)
                {
                    return(0);
                }
                else if (o1.DefaultCountryId != topSortCountryId && o2.DefaultCountryId == topSortCountryId)
                {
                    return(1);
                }
                else if (o1.DefaultCountryId == topSortCountryId && o2.DefaultCountryId != topSortCountryId)
                {
                    return(-1);
                }
                else
                {
                    return(0);
                }
            });
        }


        Tree.Nodes.Add(RecursiveAdd(lookup, orgs[0].ParentIdentity, levels - 1)[0]);
        Tree.Nodes[0].Expanded = true;
        Tree.Nodes[0].Selected = true;
    }
Example #14
0
        public bool OragnizationsValuesIsWithoutMdash(Organizations obj)
        {
            for (int j = 0; j < obj.values.Count; j++)
            {
                if (!obj.values[j].Contains("—"))
                {
                    return(false);
                }
            }

            return(true);
        }
Example #15
0
        private static void GetTableRow(DataTable table, Organizations organization)
        {
            DataRow row = table.NewRow();

            row["Name"]    = organization.Name;
            row["TaxId"]   = organization.TaxId;
            row["Website"] = organization.Website;
            row["Phone"]   = organization.Phone;
            row["Email"]   = organization.Email;

            table.Rows.Add(row);
        }
Example #16
0
        public async Task <Guid?> ProviderIdForOrg(Guid orgId)
        {
            if (Organizations.Any(org => org.Id == orgId))
            {
                return(null);
            }

            var po = (await GetProviderOrganizations())
                     .FirstOrDefault(po => po.OrganizationId == orgId);

            return(po?.ProviderId);
        }
Example #17
0
    /// <summary> Handles when a pin is clicked </summary>
    public void Pin_Click(OnlineMapsMarkerBase marker)
    {
        try
        {
            Vector2 pos       = OnlineMapsLocationService.instance.position;
            Vector2 markerPos = marker.position;

            double pinDist = PinUtilities.DistanceInMeters(pos.y, pos.x, markerPos.y, markerPos.x);
            if (pinDist < pinRadius)
            {
                PointData pd = PinUtilities.GetPointData(marker.tags, PinUtilities.PointDatas);

                if (PinUtilities.GetTypeFromTag(marker.tags) != "Tokens")
                {
                    UserUtilities.AllocatePoints(pd._Value);
                    UIManager.Instance.IndicateScore(pd._Value, true);

                    SoundManager.Instance.PlaySound("CoinCollect");

                    long now = (long)(DateTime.UtcNow - epochStart).TotalMilliseconds;
                    PinUtilities.pinDeltas[marker.label] = now;

                    pd.RemovePin();

                    PinUtilities.SavePins();
                    UserUtilities.Save();

                    Organizations pinOrg = (Organizations)Enum.Parse(typeof(Organizations), pd._Type.ToString());

                    if (MinigamePinUnlock.Contains(pinOrg) && MiniGameEnabledOrgs.Contains(pinOrg))
                    {
                        Unlock(pinOrg);
                    }

                    if (TriviaEnabledOrgs.Contains(pinOrg))
                    {
                        TriviaGame.CheckForTrivia(marker.label);
                    }

                    return;
                }
                else
                {
                    pd = PinUtilities.GetPointData(marker.tags, PinUtilities.TokenPointDatas);
                    TokenPinActivate(pd, pd._Position.Latitude.ToString() + pd._Position.Longitude.ToString());
                }
            }
        }
        catch (Exception e)
        {
            Debug.Log("ERROR: " + e.Message);
        }
    }
Example #18
0
        private void PopulateData()
        {
            Organization objorg = new Organization()
            {
                Name = "artexacta"
            };

            Area area = new Area()
            {
                Name = "marketing"
            };

            objorg.Areas.Add(area.ObjectId, area);
            area.Owner = objorg;
            Areas.Add(area.ObjectId, area);

            area = new Area()
            {
                Name = "development"
            };
            objorg.Areas.Add(area.ObjectId, area);
            area.Owner = objorg;
            Areas.Add(area.ObjectId, area);


            ////Kpi kpi = new Kpi()
            ////{
            ////    Name = "KPI Test Data",
            ////    Progress = 32
            ////};
            ////kpi.Owner = objOrg;
            ////Kpis.Add(kpi.ObjectId, kpi);
            ////objOrg.Kpis.Add(kpi.ObjectId, kpi);
            Project project = new Project()
            {
                Name = "Project 1"
            };

            project.Owner = objorg;
            Projects.Add(project.ObjectId, project);
            objorg.Projects.Add(project.ObjectId, project);

            Activity activity = new Activity()
            {
                Name = "Activity 1"
            };

            activity.Owner = objorg;
            Activities.Add(activity.ObjectId, activity);
            objorg.Activities.Add(activity.ObjectId, activity);

            Organizations.Add(objorg.ObjectId, objorg);
        }
Example #19
0
        public bool Insert(Organizations organizations)
        {
            int autonumber = 0;
            OrganizationsDAC organizationsComponent = new OrganizationsDAC();
            bool             endedSuccessfuly       = organizationsComponent.InsertNewOrganizations(ref autonumber, organizations.OrganizationName, organizations.OrganizationDescription, organizations.Phone1, organizations.Phone2, organizations.Phone3, organizations.Fax1, organizations.Fax2, organizations.AddressLine1, organizations.AddressLine2);

            if (endedSuccessfuly)
            {
                organizations.OrganizationId = autonumber;
            }
            return(endedSuccessfuly);
        }
Example #20
0
        public ActionResult OrganizationDetail(int id)
        {
            Organizations organization = organizationBLL.GetOrganization(id);

            Session["Organization"] = organization;
            OrganizationParticipantModel model = new OrganizationParticipantModel
            {
                organizations = organization
            };

            return(View(model));
        }
Example #21
0
    private static Organizations instantiate(DataSet ds)
    {
        Organizations o = new Organizations();

            o.Id = Convert.ToInt16(ds.Tables[0].Rows[0]["id"]);
            o.Name = ds.Tables[0].Rows[0]["name"].ToString();
            o.Website = ds.Tables[0].Rows[0]["website"].ToString();
            o.UserId = Convert.ToInt16(ds.Tables[0].Rows[0]["user_id"]);
            o.Description = ds.Tables[0].Rows[0]["description"].ToString();

        return o;
    }
Example #22
0
        public ActionResult SendMessage(Messages message)
        {
            Users         usr          = Session["Login"] as Users;
            Organizations organization = Session["Organization"] as Organizations;

            message.FromUserID = usr.UserID;
            message.ToUserID   = organization.UserID;
            message.Date       = DateTime.Now;

            messagesBLL.AddMessage(message);
            return(RedirectToAction("MyMessagesList"));
        }
Example #23
0
 public OrganizationMember LoadOrgMember(int PeopleId, string OrgName, bool orgmustexist)
 {
     if (orgmustexist)
     {
         var org = Organizations.SingleOrDefault(oo => oo.OrganizationName == OrgName);
         if (org == null)
         {
             throw new Exception("Org Named '" + OrgName + "' does not exist");
         }
     }
     return(OrganizationMember.Load(this, PeopleId, OrgName));
 }
        private static void ConfirmBaseData(LoginUser loginUser)
        {
            Organization organization = (Organization)Organizations.GetOrganization(loginUser, loginUser.OrganizationID);
            TicketTypes  types        = new TicketTypes(loginUser);

            types.LoadAllPositions(loginUser.OrganizationID);

            if (types.IsEmpty)
            {
                Organizations.CreateStandardData(loginUser, organization, true, true);
            }
        }
        /// <summary>
        /// Dependent type names of this entity
        /// </summary>
        public void DeleteChildren(DatabaseEntities dbContext)
        {
            foreach (var x in Organizations.ToList())
            {
                x.DeleteFull(dbContext);
            }

            foreach (var x in OrganizationTypeOrganizationRelationshipTypes.ToList())
            {
                x.DeleteFull(dbContext);
            }
        }
        public ActionResult OrganizationCreated(Organizations organization)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Something went wrong!");
                return(View("CreateOrganization"));
            }
            _context.Organizations.Add(organization);
            _context.SaveChanges();

            return(RedirectToAction("AllOrganization"));
        }
Example #27
0
        public bool Validate(Organizations organization, out string message)
        {
            message = String.Empty;

            if (_organizationsRepository.FindAll().Any(x => x.FriendlyName == organization.FriendlyName && (organization.OrganizationId != x.OrganizationId || organization.OrganizationId == Guid.Empty)))
            {
                message = "FriendlyName is already exist.";
                return(false);
            }

            return(true);
        }
/// <summary>
/// Update Organizations
/// </summary>
/// <param name="entity"></param>
/// <returns>Message</returns>
        public async Task <string> UpdateOrganizations(Organizations entity)
        {
            try
            {
                var result = await new OrganizationsRepository(logger).Update(entity);
                return(result);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message);
                throw ex;
            }
        }
Example #29
0
        public static Org[] Select()
        {
            List <Org> res = new List <Org>();

            Organizations orgs = Organizations.GetAll();

            foreach (Organization org in orgs)
            {
                res.Add(new Org(org));
            }

            return(res.ToArray());
        }
Example #30
0
 public IActionResult Edit(int id, [Bind] Organizations organization)
 {
     if (id != organization.Id)
     {
         return(null);
     }
     if (ModelState.IsValid)
     {
         _organizationFacade.EditOrganization(organization);
         return(RedirectToAction("Index"));
     }
     return(View(organization));
 }
Example #31
0
        public void AddOrganizationTest()
        {
            var organizations = new Organizations();
            var organization  = new Organization {
                Identifier = "organization1", Title = "Title"
            };

            ManifestManager.AddOrganization(organizations, organization);

            var org = organizations.OrganizationsList.Single(i => i.Title == "Title");

            Assert.AreEqual("organization1", org.Identifier);
        }
Example #32
0
        internal static void ProcessLostMember (BasicPWEvent newPwEvent)
        {
            // This function handles the case when a member was purged from the database. Several things are hardcoded
            // for UP at this point.

            Person victim = Person.FromIdentity(newPwEvent.AffectedPersonId);

            Organizations orgs = new Organizations();
            Geography geography = Geography.FromIdentity(newPwEvent.GeographyId);

            string[] orgStrings = newPwEvent.ParameterText.Split(' ');

            foreach (string orgString in orgStrings)
            {
                int orgId = Int32.Parse(orgString);
                orgs.Add(Organization.FromIdentity(orgId));
            }

            People concernedPeople = new People();

            bool showName = true;
            foreach (Organization org in orgs)
            {
                concernedPeople =
                    concernedPeople.LogicalOr(
                        People.FromIdentities(Roles.GetAllUpwardRoles(org.Identity, newPwEvent.GeographyId)));
                //Only show name if all orgs allow it
                if (org.ShowNamesInNotificationsInh == false)
                    showName = false;
            }

            concernedPeople = ApplySubscription(concernedPeople, NewsletterFeed.TypeID.OfficerNewMembers);

            string body = "A member was lost within your area of authority.\r\n\r\n";
            if (showName)
            {
                body += "Person:       " + victim.Name + "\r\n";
            }

            foreach (Organization org in orgs)
            {
                body += "Organization: " + org.Name + "\r\n";
            }

            body +=
                "Geography:    " + geography.Name + "\r\n\r\n" +
                "Event source: " + newPwEvent.EventSource.ToString() + "\r\n\r\n";

            string orgSubjectLine = string.Empty;

            foreach (Organization org in orgs)
            {
                orgSubjectLine += ", " + org.NameShort;
            }

            orgSubjectLine = orgSubjectLine.Substring(2);

            new MailTransmitter(Strings.MailSenderName, Strings.MailSenderAddress,
                                                       "Member Lost: " + (showName ? "[" + victim.Name + "] - " : "") + "[" + orgSubjectLine +
                                                       "], [" + geography.Name + "]",
                                                       body, concernedPeople, true).Send();
        }
Example #33
0
        private static string SerializeOrgs(IQueryable<Organization> q, string root, string OrgElement, string MembersElement)
        {
            var sw = new StringWriter();
            var a = new Organizations { status = "ok", List = q.ToList() };

            var ao = new XmlAttributeOverrides();
            ao.Add(typeof(Organizations), new XmlAttributes
            {
                XmlRoot = new XmlRootAttribute(root)
            });
            ao.Add(typeof(Organizations), "List", new XmlAttributes
            {
                XmlElements = { new XmlElementAttribute(OrgElement) }
            });
            ao.Add(typeof(Organization), "members", new XmlAttributes
            {
                XmlArray = new XmlArrayAttribute(MembersElement)
            });

            var xs = new XmlSerializer(typeof(Organizations), ao);
            xs.Serialize(sw, a);
            return sw.ToString();
        }
Example #34
0
        public static PersonIconSpec ForPerson (Person person, Organizations organizations)
        {
            // HACK: For now, cheat and assume only PPSE roles matter. A future expansion of this is needed.
            // HACK: Rehacked to use another org in case there is one and PPSE is not among selected
            Organization org = null;

            if (organizations.Contains(Organization.PPSE) || organizations.Count == 0)
            {
                org = Organization.PPSE;
            }
            else
            {
                org = organizations[0];
            }

            bool isMember = false;
            foreach (Organization org1 in organizations)
            {
                if (person.MemberOf(org1)) isMember = true;
            }

            if (!isMember)
            {
                // if he/she used to be a member, use exmember icons

                Memberships memberships = person.GetMemberships(true);

                foreach (Membership membership in memberships)
                {
                    if (membership.Organization.Identity == org.Identity)
                    {
                        return new PersonIconSpec("pwcustom/exmember-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Expired member, " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                    }
                }

                // If activist, use activist icon (as sex is unknown, use silhouette)

                if (person.IsActivist)
                {
                    return new PersonIconSpec("pwcustom/activist-silhouette.png", "Activist");
                }

                // TODO: Add case for was-activist

                // otherwise, use unknown icon

                return new PersonIconSpec("user-silhouette.png", "Unknown");
            }

            Authority auth = person.GetAuthority();

            if (auth.SystemPersonRoles.Length == 0 && auth.LocalPersonRoles.Length == 0 && auth.OrganizationPersonRoles.Length == 0)
            {
                // This is a fairly regular joe.

                if (person.IsActivist)
                {
                    return new PersonIconSpec("pwcustom/activist-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Activist, " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }
                else
                {
                    return new PersonIconSpec("pwcustom/member-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Member, " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }
            }

            // HACK: Cheat and return "org leader" for ID 1

            if (person.Identity == 1)
            {
                return new PersonIconSpec("pwcustom/orglevel-3-male.png", "Org Lead");
            }
            bool foundOddRole = false;
            foreach (Organization org1 in organizations)
            {
                string orgName = org1.NameShort + ", ";

                if (org1 == Organization.PPSE)
                    orgName = "";


                // Chairman / equivalent

                if (auth.HasRoleAtOrganization(org1, RoleType.OrganizationChairman, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/boardlevel-3-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Chairman, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // Board member

                if (auth.HasRoleAtOrganization(org1, RoleType.OrganizationBoardMember, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/boardlevel-2-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Board member, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // Board deputy

                if (auth.HasRoleAtOrganization(org1, RoleType.OrganizationBoardDeputy, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/boardlevel-1-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Board deputy, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // Auditor

                if (auth.HasRoleAtOrganization(org1, RoleType.OrganizationAuditor, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/boardlevel-1-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Autitor, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // Org-level leader or deputy

                if (auth.HasLocalRoleAtOrganizationGeography(org1, org1.PrimaryGeography, RoleType.LocalLead, Authorization.Flag.ExactGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/orglevel-3-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Org Lead, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }
                if (auth.HasLocalRoleAtOrganizationGeography(org1, org1.PrimaryGeography, RoleType.LocalDeputy, Authorization.Flag.ExactGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/orglevel-3-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Org Deputy, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // Org-level secretary

                if (auth.HasRoleAtOrganization(org1, RoleType.OrganizationSecretary, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/orglevel-2-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Org secretary, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // system roles

                if (auth.HasRoleType(RoleType.SystemAdmin))
                {
                    return new PersonIconSpec("user-worker.png", "Sys.adm., " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // Org-level admin

                if (auth.HasRoleAtOrganization(org1, RoleType.OrganizationAdmin, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/orglevel-1-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Org admin, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }
                if (auth.HasLocalRoleAtOrganizationGeography(org1, org1.PrimaryGeography, RoleType.LocalAdmin, Authorization.Flag.ExactGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/orglevel-1-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Org admin, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                // TODO: ADD THE REST OF THE ROLES HERE SOMEWHERE

                // local roles

                if (auth.HasLocalRoleAtOrganizationGeography(org1, Geography.Root, RoleType.LocalLead, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/officer-lead-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Local lead, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                if (auth.HasLocalRoleAtOrganizationGeography(org1, Geography.Root, RoleType.LocalDeputy, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/officer-deputy-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Local deputy, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                if (auth.HasLocalRoleAtOrganizationGeography(org1, Geography.Root, RoleType.LocalAdmin, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    return new PersonIconSpec("pwcustom/officer-admin-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Local admin, " + orgName + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }

                if (auth.HasRoleAtOrganization(org1, Authorization.Flag.AnyGeographyExactOrganization)
                 || auth.HasLocalRoleAtOrganizationGeography(org1, Geography.Root, Authorization.Flag.AnyGeographyExactOrganization))
                {
                    foundOddRole = true;
                }
            }

            if (!foundOddRole)
            {
                if (person.IsActivist)
                {
                    return new PersonIconSpec("pwcustom/activist-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Activist, " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }
                else
                {
                    return new PersonIconSpec("pwcustom/member-" + (person.IsFemale ? "female" : person.IsMale ? "male" : "") + ".png", "Member, " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
                }
            }
            else
            {
                // unhandled role type
                return new PersonIconSpec("user-silhouette-question.png", "unknown role, " + (person.IsFemale ? "female" : person.IsMale ? "male" : ""));
            }
        }
        public static Organization[] SelectSortedStatic (Organizations Organizations, string sort)
        {
            if (Organizations == null)
            {
                return new Organization[0];
            }


            List<Organization> pList = new List<Organization>();
            Organization[] foundOrganizations = SelectStatic((Organizations)Organizations);
            foreach (Organization pers in foundOrganizations)
            {
                pList.Add(pers);
            }

            switch (sort)
            {
                case "OrganizationId": pList.Sort(IdentityComparison); break;
            }

            return pList.ToArray();
        }
        public static Organization[] SelectStatic (Organizations Organizations)
        {
            if (Organizations == null)
            {
                return new Organization[0];
            }

            return Organizations.ToArray();
        }
Example #37
0
 public Organizations OrganisationsWithPermission (Permission perm, RoleType[] roles)
 {
     Organizations orgList = GetOrganizations(roles);
     Organizations retList = new Organizations();
     foreach (Organization org in orgList)
     {
         if (HasPermission(perm, org.Identity, -1, Authorization.Flag.Default))
             if (!retList.Contains(org))
                 retList.Add(org);
     }
     return retList;
 }
Example #38
0
        public static void CreateUngPiratUptakeMap()
        {
            string svg = string.Empty;
            string legendTemplate = string.Empty;

            using (
                StreamReader reader = new StreamReader("content/se-up-uptake-municipalities-template.svg",
                                                       Encoding.Default))
            {
                svg = reader.ReadToEnd();
            }

            using (
                StreamReader reader = new StreamReader("content/se-up-uptakemap-legend-template.txt", Encoding.Default))
            {
                legendTemplate = reader.ReadToEnd();
            }

            Organizations effectiveOrgs = new Organizations();
            Organizations possibleOrgs = Organization.FromIdentity(2).GetTree();

            foreach (Organization org in possibleOrgs)
            {
                if (org.AcceptsMembers && org.AutoAssignNewMembers)
                {
                    effectiveOrgs.Add(org);
                }
            }

            string legend = string.Empty;

            effectiveOrgs.Sort();

            Dictionary<int, string> colorLookup = new Dictionary<int, string>();
            int position = 0;
            float curLight = .35f;
            float curSaturation = 1f;

            foreach (Organization org in effectiveOrgs)
            {
                curLight += .25f;
                if (curLight > .85f)
                {
                    curLight = .35f;
                }
                else if (curLight > .8f)
                {
                    curLight = .75f;
                }

                curSaturation = 1.45f - curSaturation;


                Color color = ColorFromAhsb(128, (float) position*360/(float) effectiveOrgs.Count, curSaturation,
                                            curLight);

                if (org.CatchAll)
                {
                    color = Color.FromArgb(240, 240, 240);
                }

                string colorString = String.Format("#{0:x2}{1:x2}{2:x2}", color.R, color.G, color.B);
                colorLookup[org.Identity] = colorString;

                string orgLegend = legendTemplate.
                    Replace("%%NAME%%", Encoding.Default.GetString(Encoding.UTF8.GetBytes(org.NameShort))).
                    Replace("%%YPOS%%", (position*17).ToString()).
                    Replace("%%COLOR%%", colorString).
                    Replace("%%GROUPID%%", "org" + org.Identity.ToString());

                legend += orgLegend;

                position++;
            }

            Mappery mappery = new Mappery();
            mappery.OrgColorLookup = colorLookup; // Ugly way to transfer data to delegate

            svg = svg.Replace("<!--%%LEGEND%%-->", legend);

            Regex regex =
                new Regex("(?<start>\\<path.+?fill:)(?<color>.+?)(?<middle>;.+?id=\\\")(?<id>.+?)(?<end>\\\".+?/\\>)",
                          RegexOptions.Singleline);

            MatchEvaluator matchEvaluator = new MatchEvaluator(mappery.UPUptakeLookupReplacer);

            Persistence.Key["OrgUptakeMap-2"] = regex.Replace(svg, matchEvaluator);
        }
	SeriesCollection GetDistributionData(Organizations orgs)
	{
        string cacheDataKey = "ChartData-AllMembershipEvents";

        MembershipEvents events = (MembershipEvents)Cache.Get(cacheDataKey);

        if (events == null)
        {
            events = MembershipEvents.LoadAll();
            Cache.Insert(cacheDataKey, events, null, DateTime.Today.AddDays(1).ToUniversalTime(), System.Web.Caching.Cache.NoSlidingExpiration);
        }

		/*
		using (StreamReader reader = new StreamReader(HttpContext.Current.Server.MapPath("~/Data/MembershipEvents.xml")))
		{
			string xml = reader.ReadToEnd();

			events = MembershipEvents.FromXml(xml);
		}*/

		Dictionary<int, bool> lookup = new Dictionary<int,bool>();

		foreach (Organization org in orgs)
		{
			lookup[org.Identity] = true;
		}


		SeriesCollection collection = new SeriesCollection();
		DateTime dateIterator = new DateTime(2006, 1, 1);

		string dayCount = Request.QueryString["Days"];

        if (dayCount != null)
		{
            dateIterator = DateTime.Now.Date.AddDays(-Int32.Parse(dayCount));
		}

        Series seriesMale = new Series();
        Series seriesFemale = new Series();
        seriesMale.Name = "";
        seriesFemale.Name = "";
        DateTime today = DateTime.Now.Date;
		int eventIndex = 0;

        Dictionary<PersonGender, int> genderCount = new Dictionary<PersonGender, int>();
        genderCount[PersonGender.Male] = 0;
        genderCount[PersonGender.Female] = 0;

        Dictionary<int, int> personMembershipCountLookup = new Dictionary<int, int>();

		while (dateIterator < today)
		{
			DateTime nextDate = dateIterator.AddDays (1);
			while (eventIndex < events.Count && events[eventIndex].DateTime < nextDate)
			{
                // This is f*****g problematic because some people can be members of more than one org,
                // so the relatively simple op becomes complicated one of a sudden when we have to keep
                // track of that.

                // The logic is horrible compared to just iterating over DeltaCount over time.

				if (lookup.ContainsKey (events[eventIndex].OrganizationId))
				{
                    int personId = events[eventIndex].PersonId;

                    if (events[eventIndex].DeltaCount > 0)
                    {
                        // A membership was added.

                        // Was this person already a member?

                        if (personMembershipCountLookup.ContainsKey(personId))
                        {
                            // yes, increment that person's membership count, not the people count

                            personMembershipCountLookup[personId]++;
                        }
                        else
                        {
                            // no, create the key, increment the people count and set this person's membership count to 1

                            genderCount[events [eventIndex].Gender]++;
                            personMembershipCountLookup[personId] = 1;
                        }
                    }
                    else if (events [eventIndex].DeltaCount < 0)
                    {
                        // a membership was lost

                        int membershipCountForPerson = 1;

                        try
                        {
                            membershipCountForPerson = personMembershipCountLookup[personId];
                        }
                        catch (Exception)
                        {
                            // some corrupt data in db, so need to handle key not present
                        }

                        // in the extreme majority of cases, membershipCountForPerson will be 1, meaning this
                        // is their only and now terminated membership

                        if (membershipCountForPerson == 1)
                        {
                            personMembershipCountLookup.Remove(personId);
                            genderCount[events[eventIndex].Gender]--;
                        }
                        else
                        {
                            // but this person had more than one, decrement their membership count but not the total

                            personMembershipCountLookup[personId]--;
                        }
                    }

                    // no case for when DeltaCount is 0, it can't be at the time of this writing,
                    // but who knows how PirateWeb will expand and grow

                    // assumes DeltaCount is always 1 or -1
				}

				eventIndex++;
			}

			Element newElement = new Element();
			newElement.XDateTime = dateIterator;
			newElement.YValue = genderCount [PersonGender.Male];
			seriesMale.Elements.Add(newElement);

            newElement = new Element();
            newElement.XDateTime = dateIterator;
            newElement.YValue = genderCount[PersonGender.Female];
            seriesFemale.Elements.Add(newElement);

			dateIterator = nextDate;
		}

        seriesMale.DefaultElement.Transparency = 98;
        seriesMale.DefaultElement.Color = Color.Blue;
        seriesFemale.DefaultElement.Color = Color.Red;

		collection.Add(seriesFemale);
        collection.Add(seriesMale);

		return collection;

	}
Example #40
0
 /// <summary>
 /// Returns most recent membership for each org wich is active or terminated within the grace period
 /// </summary>
 /// <param name="orgs">List of ids. If empty, all orgs</param>
 /// <param name="gracePeriod">For exired, number of days to add to allow it to be returned</param>
 /// <returns></returns>
 public Memberships GetRecentMemberships (Organizations orgs, int gracePeriod)
 {
     List<int> orgIdList = new List<int>(orgs.Identities);
     return GetRecentMemberships(orgIdList, gracePeriod);
 }
Example #41
0
        internal static void ProcessAddedMember (BasicPWEvent newPwEvent)
        {
            // This function handles the case when a new member has been added. Several things are hardcoded
            // for UP at this point.

            Person victim = Person.FromIdentity(newPwEvent.AffectedPersonId);
            Person perpetrator = Person.FromIdentity(newPwEvent.ActingPersonId);
            Organizations orgs = new Organizations();
            Geography geography = Geography.FromIdentity(newPwEvent.GeographyId);
            string referrerString = string.Empty;

            if (newPwEvent.ParameterText.Contains(","))
            {
                string[] eventParts = newPwEvent.ParameterText.Split(',');

                string[] orgStrings = eventParts[0].Split(' ');

                foreach (string orgString in orgStrings)
                {
                    int orgId = 0;
                    if (int.TryParse(orgString, out orgId))
                    {
                        orgs.Add(Organization.FromIdentity(orgId));
                    }
                }

                if (eventParts.Length > 2)
                {
                    referrerString = eventParts[2];
                }
            }
            else
            {
                orgs.Add(Organization.FromIdentity(newPwEvent.OrganizationId));
            }

            People concernedPeople = new People();

            bool showName = true;

            foreach (Organization org in orgs)
            {
                concernedPeople =
                    concernedPeople.LogicalOr(
                        People.FromIdentities(Roles.GetAllUpwardRoles(org.Identity, newPwEvent.GeographyId)));

                //Only show name if all orgs allow it
                if (org.ShowNamesInNotificationsInh == false)
                    showName = false;
            }

            //Filter to only get the interested people in this event
            concernedPeople = ApplySubscription(concernedPeople, NewsletterFeed.TypeID.OfficerNewMembers);

            string body = "A new member has appeared within your area of authority.\r\n\r\n";

            if (showName)
            {
                body += "Person:       " + victim.Name + "\r\n";
            }

            foreach (Organization org in orgs)
            {
                body += "Organization: " + org.Name + "\r\n";
            }

            body +=
                "Geography:    " + geography.Name + "\r\n\r\n" +
                "Event source: " + newPwEvent.EventSource.ToString() + "\r\n";

            if (newPwEvent.EventSource == EventSource.SignupPage && referrerString.Length > 0)
            {
                body += "Referrer:     " + referrerString + "\r\n";
            }

            body += "\r\n";

            if (newPwEvent.EventSource == EventSource.PirateWeb)
            {
                body += "This member was added manually";
                body += " by " + perpetrator.Name + ".\r\n\r\n";
            }

            // Send welcoming mails

            string mailsSent = MailResolver.CreateWelcomeMail(victim, Organization.FromIdentity(newPwEvent.OrganizationId));
            // HACK - should be for all orgs

            body += "Welcoming automails sent:\r\n" + mailsSent +
                    "\r\nTo add an automatic welcome mail for your organization and geography, " +
                    "go to PirateWeb, Communications, Triggered Automails, Automail type \"Welcome\".\r\n\r\n";

            // Add some hardcoded things for UP

            /*
            if (organization.Inherits(2))
            {
                int membersTotal = Organization.FromIdentity(2).GetTree().GetMemberCount();
                int membersHere = organization.GetMemberCount();

                body += "Member count for Ung Pirat SE: " + membersTotal.ToString("#,##0") + "\r\n" +
                    "Member count for " + organization.Name + ": " + membersHere.ToString("#,##0") + "\r\n";
            }*/

            string orgSubjectLine = string.Empty;

            foreach (Organization org in orgs)
            {
                orgSubjectLine += ", " + org.NameShort;
            }

            orgSubjectLine = orgSubjectLine.Substring(2);

            new MailTransmitter(Strings.MailSenderName, Strings.MailSenderAddress,
                                                       "New Member: " + (showName ? "[" + victim.Name + "] - " : "") + "[" + orgSubjectLine + "], [" +
                                                       geography.Name + "]",
                                                       body, concernedPeople, true).Send();
        }
Example #42
0
        internal static void ProcessExtendedMembership (BasicPWEvent newPwEvent)
        {
            // This function handles the case when a membership has been extended for a year.


            BasicPerson victim = Person.FromIdentity(newPwEvent.AffectedPersonId);
            BasicPerson perpetrator = Person.FromIdentity(newPwEvent.ActingPersonId);
            Organization organization = Organization.FromIdentity(newPwEvent.OrganizationId);
            Geography node = Geography.FromIdentity(newPwEvent.GeographyId);

            int[] concernedPeopleId = Roles.GetAllUpwardRoles(newPwEvent.OrganizationId, newPwEvent.GeographyId);

            Organizations orgs = Organizations.FromSingle(organization);

            bool showName = true;
            if (organization.ShowNamesInNotificationsInh == false)
                showName = false;

            if (newPwEvent.ParameterText.Contains(" "))
            {
                // 2nd-gen: several orgs can be passed

                orgs = new Organizations();

                string[] orgStrings = newPwEvent.ParameterText.Split(' ');
                foreach (string orgString in orgStrings)
                {
                    if ((!orgString.Contains(".")) && (!orgString.Contains("/"))) // IP address or SMS
                    {
                        if (orgString.Trim().Length > 0)
                        {
                            orgs.Add(Organization.FromIdentity(Int32.Parse(orgString)));
                        }
                    }
                }
            }

            string orgNames = string.Empty;

            string body =
                "A membership was extended within your area of authority.\r\n\r\n" +
                (showName ? "Person:       " + victim.Name + "\r\n" : "");

            foreach (Organization org in orgs)
            {
                body +=
                    "Organization: " + org.Name + "\r\n";

                orgNames += ", " + org.NameShort;
            }

            orgNames = orgNames.Substring(2);


            body +=
                "Geography:    " + node.Name + "\r\n\r\n" +
                "Event source: " + newPwEvent.EventSource.ToString() + "\r\n";

            People concernedPeople = People.FromIdentities(concernedPeopleId);

            concernedPeople = ApplySubscription(concernedPeople, NewsletterFeed.TypeID.OfficerNewMembers);

            new MailTransmitter(Strings.MailSenderName, Strings.MailSenderAddress,
                                                       "Extended Membership: " + (showName ? "[" + victim.Name + "] - " : "") + "[" + orgNames +
                                                       "], [" + node.Name + "]",
                                                       body, concernedPeople, true).Send();
        }
Example #43
0
        public static int[] PersonsWithRoleInOrg (RoleType roleType, int p, bool includeChildOrgs)
        {
            Organizations line = new Organizations();
            if (includeChildOrgs)
                line = Organization.FromIdentity(p).GetLine();
            else
                line.Add(Organization.FromIdentity(p));

            BasicPersonRole[] basPersons
                = SwarmDb.GetDatabaseForReading().GetPeopleWithRoleType(roleType, line.Identities, new int[] { });

            List<int> retList = new List<int>();

            foreach (BasicPersonRole b in basPersons)
                retList.Add(b.PersonId);

            return retList.ToArray();
        }