private void CheckManager(SPListItem item, string loginName)
        {
            List <string> doubledUsers = new List <string>();

            if (item["Person in charge"] is SPFieldUserValueCollection)
            {
                SPFieldUserValueCollection fieldValues = item["Person in charge"] as SPFieldUserValueCollection;
                if (fieldValues.Where(fv => fv.User.LoginName == loginName).Count() > 0)
                {
                    List <SPFieldUserValue> otherFieldValues = fieldValues.Where(fv => fv.User.LoginName != loginName).ToList();
                    foreach (SPFieldUserValue uv in otherFieldValues)
                    {
                        doubledUsers.Add(uv.LookupId + ";#" + uv.LookupValue);
                    }
                    CompleteTasks(item, doubledUsers);
                    return;
                }
            }


            //CheckManager(sourceItem, "Tax");
            //CheckManager(sourceItem, "Finance");
            //CheckManager(sourceItem, "Compliance");
            //CheckManager(sourceItem, "Internal Control");
        }
Exemplo n.º 2
0
        protected void AGMOffice_SelectedIndexChanged(object sender, EventArgs e)
        {
            SPWebApplication webApplication = SPContext.Current.Site.WebApplication;

            string keyPeopleListName = webApplication.Properties["MasterKeyPeopleListName"].ToString();

            SPList list = SPContext.Current.Web.Lists[keyPeopleListName];

            ShowAuthPanel(false);

            SPQuery query = new SPQuery()
            {
                Query = string.Format(@"<Query>
                                          <Where>
                                            <And>
                                              <Eq>
                                                <FieldRef Name='Agenda Type' />
                                                <Value Type='Choice'>{0}</Value>
                                              </Eq>
                                              <And>
                                                <Eq>
                                                  <FieldRef Name='AGM Office' />
                                                  <Value Type='Choice'>{1}</Value>
                                                </Eq>
                                                <Eq>
                                                  <FieldRef Name='PositionInMarta' />
                                                  <Value Type='Text'>Agenda Coordinator</Value>
                                                </Eq>
                                              </And>
                                            </And>
                                          </Where>
                                        </Query>", ddlAgendaType.SelectedValue, ddlAGMOffice.SelectedValue)
            };

            if (list != null)
            {
                SPFieldUserValueCollection authUsers = new SPFieldUserValueCollection();

                foreach (SPListItem item in list.GetItems(query))
                {
                    //For some reason the Query seems to be returning all data and not what its filtered by, so explicity check here.
                    if ((item["PositionInMarta"].ToString() == "Agenda Coordinator") && (item["AGM Office"].ToString() == ddlAGMOffice.SelectedValue) && (item["Agenda Type"].ToString() == ddlAgendaType.SelectedValue))
                    {
                        string authUsersFieldValue = item["KeyPerson"].ToString();

                        authUsers.Add(new SPFieldUserValue(item.Web, authUsersFieldValue));
                    }
                }

                SPUser currentUser = list.ParentWeb.CurrentUser;
                SPFieldUserValue currentUserValue = new SPFieldUserValue(list.ParentWeb, currentUser.ID, currentUser.Name);

                if (authUsers.Where(u => u.User.LoginName == currentUser.LoginName).SingleOrDefault() != null)
                {
                    ShowAuthPanel(true);
                }
                else
                    ShowAuthPanel(false);

            }
        }