Ejemplo n.º 1
0
 /// <summary>
 /// 已更新项.
 /// </summary>
 public override void ItemUpdated(SPItemEventProperties properties)
 {
     base.ItemUpdated(properties);
     if (properties.List.Fields.ContainsField("新闻ID"))
     {
         SPSecurity.RunWithElevatedPrivileges(delegate()
         {
             using (SPSite mySite = new SPSite(properties.Site.ID))
             {
                 using (SPWeb spWeb = mySite.RootWeb)
                 {
                     SPList listNews = spWeb.Lists.TryGetList("新闻");
                     if (listNews != null)
                     {
                         SPListItemCollection itemsNews = listNews.Items;
                         int Newsid          = int.Parse(properties.ListItem["新闻ID"].ToString());
                         SPListItem itemNews = itemsNews.GetItemById(Newsid); //查找指定同步标记ID的这条新闻
                         if (itemNews != null)                                //该条新闻存在
                         {
                             UpdateNews(ref itemNews, properties);
                         }
                     }
                 }
             }
         });
     }
 }
Ejemplo n.º 2
0
        private int GetTaskIDByAction(int actionID, DateTime currDate)
        {
            SPListItemCollection items = GetAllActions;
            SPListItem           item  = items.GetItemById(actionID);
            string typeName            = "";

            if (item["TypeID"] != null)
            {
                SPFieldLookupValueCollection types = (SPFieldLookupValueCollection)item["TypeID"];
                foreach (SPFieldLookupValue type in types)
                {
                    if (type.LookupValue != "项目")
                    {
                        if (type.LookupValue != "工作" && type.LookupValue != "学习")
                        {
                            typeName = "生活类";
                        }
                        else
                        {
                            typeName = type.LookupValue;
                        }
                    }
                }
            }
            if (typeName == "")
            {
                typeName = "生活类";
            }
            string taskCurr = GetRoutineDocName(txtName.Text, typeName, currDate);
            int    taskID   = GetTaskID(taskCurr);

            return(taskID);
        }
Ejemplo n.º 3
0
        public override void ItemAdded(SPItemEventProperties properties)
        {
            /*Reactivate Feature for Syncronization Update*/
            try
            {
                SPFile file = properties.ListItem.File;     //this checks for a File type

                //Only set Folders and DocSets, Files Inherit Permissions from DocSet
                if (file == null)    //check for folders and file types and check out file
                {
                    /*Impersonate System Account*/
                    SPSite      tempSite = properties.Web.Site;
                    SPUserToken systoken = tempSite.SystemAccount.UserToken;    //Use System Account

                    using (SPSite sysSite = new SPSite(tempSite.Url, systoken))
                    {
                        using (SPWeb sysWeb = sysSite.OpenWeb(properties.Web.ServerRelativeUrl))
                        {
                            SPQuery query = new SPQuery();
                            query.ViewXml = "<View Scope='RecursiveAll'/>";
                            SPWeb  sysParentWeb          = sysSite.RootWeb;
                            SPList syslist               = sysWeb.Lists.TryGetList(properties.List.Title);
                            SPListItemCollection coll    = syslist.GetItems(query);
                            SPListItem           sysItem = coll.GetItemById(properties.ListItem.ID);
                            SPList ccpList               = sysParentWeb.Lists.TryGetList("Permissions List"); //get CCPList
                            ItemPermissions.SetItem(sysWeb, ccpList, sysItem);                                //set item permissions
                        }
                    }
                }
                else if (file != null)
                {
                    properties.ListItem["Permission Status"] = "Inherit from Parent";
                    properties.ListItem.Update();
                }
            }
            catch (Exception e)
            {
                /*UPDATE LOGGING TO INCLUDE SITE*/

                //Log
                SPSite     site      = properties.Web.Site;
                SPWeb      parentWeb = site.RootWeb;
                SPList     eventLog  = parentWeb.Lists.TryGetList("CCPEventFeatureLog");//get log list
                SPListItem item      = eventLog.AddItem();
                item["ListEvents"] = e.Message;
                item["Site"]       = properties.Web.Url;

                if (properties.List.Title == "Contracts")
                {
                    item["Contracts"] = properties.Web.Title;
                }
                else if (properties.List.Title == "Proposals")
                {
                    item["Proposals"] = properties.Web.Title;
                }

                item.Update();
            }
        }
Ejemplo n.º 4
0
        public SPListItemInstance GetItemById(int id)
        {
            var listItem = m_listItemCollection.GetItemById(id);

            return(listItem == null
                ? null
                : new SPListItemInstance(Engine, listItem));
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 根据需要从计算所得的某天起生成计算所得天数的例行计划,并填入planList列表
        /// </summary>
        /// <param name="LogList">执行历史列表</param>
        /// <param name="rPlanList">例行计划列表</param>
        /// <param name="siteUrl">网站地址</param>
        /// <param name="planList">生成计划保存的列表</param>
        /// <param name="days">用户设置的天数</param>
        private void MakeRoutinePlan(string LogList, string rPlanList, string siteUrl, string planList, int days)
        {
            SPUser currentUser = SPContext.Current.Site.OpenWeb().CurrentUser;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                try
                {
                    int k = 0;
                    using (SPSite spSite = new SPSite(siteUrl)) //找到网站集
                    {
                        using (SPWeb spWeb = spSite.OpenWeb())
                        {
                            spWeb.AllowUnsafeUpdates = true;

                            SPList spList = spWeb.Lists.TryGetList(rPlanList);
                            if (spList != null)
                            {
                                SPListItemCollection rPlanListItems = spList.GetItems();
                                if (rPlanListItems.Count > 0)
                                {
                                    Dictionary <int, string> dict = GetChecked(cblPlans);
                                    foreach (KeyValuePair <int, string> kv in dict)
                                    {
                                        int planId               = kv.Key;
                                        string planTitle         = kv.Value;
                                        SPListItem rPlanListItem = rPlanListItems.GetItemById(planId);
                                        ArrayList leftdays       = SetLog(spWeb, LogList, days, currentUser, planId, planTitle);
                                        if (cbWeekEnd.Checked)//跳过周末
                                        {
                                            ArrayList workDays = QueryWeekDays(leftdays);
                                            writeToPlan(spWeb, planList, workDays, currentUser, rPlanListItem);
                                        }
                                        else
                                        {
                                            writeToPlan(spWeb, planList, leftdays, currentUser, rPlanListItem);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                lbErr.Text = "“" + rPlanList + "”列表不存在!";
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    lbErr.Text = "行号 " + ex.StackTrace + ":" + ex.ToString();
                }
            });
        }
Ejemplo n.º 6
0
        public void AtualizaItemLista(string NomeLista, int idListItem, Dictionary <string, object> Valores)
        {
            SPWeb objSite = Site.AllWebs[SPContext.Current.Web.ID];
            SPListItemCollection objLista = objSite.Lists[NomeLista].Items;
            SPListItem           objItem  = objLista.GetItemById(idListItem);

            //para item no dicionario
            foreach (var i in Valores)
            {
                objItem[i.Key] = i.Value;
            }

            objItem.Web.AllowUnsafeUpdates = true;
            objItem.Update();
        }
Ejemplo n.º 7
0
        private void writeNewsDept(SPItemEventProperties properties)
        {
            //更新当前事件中的新闻
            using (SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb())
            {
                string loginName = oWebsite.CurrentUser.LoginName;
                loginName = loginName.Substring(loginName.IndexOf("|") + 1).ToLower();

                oWebsite.AllowUnsafeUpdates = true;
                SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].Items;
                SPListItem           thisItem  = collItems.GetItemById(properties.ListItemId);
                thisItem["所属系部"] = GetUserDept(loginName);
                thisItem.Update();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据任务ID,查询该任务对应的活动的所有附件媒体
        /// 一个任务对应m个活动,一个活动对应n个媒体,媒体总数m*n
        /// </summary>
        /// <param name="taskId">任务ID</param>
        /// <param name="AttachmentsTable">附件表</param>
        private DataTable GetMediasByTaskID(int taskId, DataTable AttachmentsTable)
        {
            string query = @"<Where>
							  <Eq>
								 <FieldRef Name='TaskID'  LookupId='True'/>
								 <Value Type='Lookup'>"                                 + taskId + @"</Value>
							  </Eq>
						   </Where>"                        ;
            SPListItemCollection activities = GetDataFromList(webObj.Activity, query);

            if (activities != null)
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < activities.Count; i++)
                {
                    int aId = activities[i].ID;
                    query = @"<Where>
							  <Eq>
								 <FieldRef Name='AssistantID' />
								 <Value Type='Number'>"                                 + aId + @"</Value>
							  </Eq>
						   </Where>"                        ;
                    SPListItemCollection aMedias = GetDataFromList(webObj.ActivityMedia, query);                     //指定活动ID为aId的活动媒体关系
                    if (aMedias != null)
                    {
                        SPListItemCollection medias = GetDataFromList(webObj.MediaLibrary, "");
                        //DataTable dtMedias = medias.GetDataTable();
                        for (int j = 0; j < aMedias.Count; j++)
                        {
                            DataRow    dr      = AttachmentsTable.NewRow();
                            int        mediaId = int.Parse(aMedias[j]["MediaID"].ToString());
                            SPListItem media   = medias.GetItemById(mediaId);
                            dr["Title"] = media["FileLeafRef"];
                            string url = media["FileRef"].ToString();
                            //if (media["内容类型"].ToString()=="视频")
                            //{
                            //    url = "<div class='box'>";
                            //}
                            dr["Url"]  = ConvertUrl(media["FileRef"].ToString());
                            dr["Type"] = media["内容类型"];
                            AttachmentsTable.Rows.Add(dr);
                        }
                    }
                }
            }
            return(AttachmentsTable);
        }
        //返回操作列表
        private DataTable GetBindData(string listName, string parentId)
        {
            DataTable dt = null;

            if (ViewState["dtAction"] != null)
            {
                dt = (DataTable)ViewState["dtAction"];
            }
            else
            {
                SPWeb   web  = SPContext.Current.Web;
                SPList  list = web.Lists.TryGetList(listName);//先到我的操作表中去找
                SPQuery qry  = new SPQuery
                {
                    DatesInUtc = false
                };
                if (list != null)
                {
                    qry.Query = "<Where><Eq><FieldRef Name='Author' LookupId='True' /><Value Type='Integer'>" + SPContext.Current.Web.CurrentUser.ID + @"</Value></Eq></Where><OrderBy><FieldRef Name='Period' Ascending='TRUE' /><FieldRef Name='Frequency' Ascending='FALSE' /></OrderBy>";
                    dt        = list.GetItems(qry).GetDataTable();
                    SPListItemCollection items = list.GetItems(qry);
                    SPListItem           item;
                    if (dt != null && dt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in dt.Rows)
                        {
                            item     = items.GetItemById((int)dr["ID"]);
                            dr["ID"] = new SPFieldLookupValue(item["ActionID"].ToString()).LookupId;
                        }
                        dt.AcceptChanges();
                    }
                }

                if (dt == null || dt.Rows.Count == 0)
                {
                    list      = web.Lists.TryGetList(webObj.ActionList);
                    qry       = new SPQuery();
                    qry.Query = "<OrderBy><FieldRef Name='Period' Ascending='TRUE' /><FieldRef Name='Frequency' Ascending='FALSE' /></OrderBy>";
                    dt        = list.GetItems(qry).GetDataTable();
                }
                ViewState["dtAction"] = dt;
            }
            return(dt);
        }
Ejemplo n.º 10
0
        public override void ItemDeleting(SPItemEventProperties properties)
        {
            base.ItemDeleting(properties);

            SPUser loginUser = properties.Web.CurrentUser;
            string loginInfo = loginUser.ID + ";#" + loginUser.Name;
            SPList lstNews   = properties.List;//
            bool   hasRight  = UserHaveApproveRight(properties.SiteId, properties.Web.Name, properties.List.Title, loginUser);
            string modeState = properties.ListItem["审批状态"].ToString();

            if (modeState == "0" && !hasRight)//审批通过
            {
                properties.Status = SPEventReceiverStatus.CancelNoError;
            }
            else if (properties.Status == SPEventReceiverStatus.Continue)
            {
                if (properties.List.Fields.ContainsField("新闻ID"))
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        using (SPSite mySite = new SPSite(properties.Site.ID))
                        {
                            using (SPWeb spWeb = mySite.RootWeb)
                            {
                                SPList listNews = spWeb.Lists.TryGetList("新闻");
                                if (listNews != null)
                                {
                                    SPListItemCollection itemsNews = listNews.Items;
                                    int Newsid          = int.Parse(properties.ListItem["新闻ID"].ToString());
                                    SPListItem itemNews = itemsNews.GetItemById(Newsid); //查找指定同步标记ID的这条新闻
                                    if (itemNews != null)                                //该条新闻存在
                                    {
                                        itemNews.Delete();
                                        listNews.Update();
                                    }
                                }
                            }
                        }
                    });
                }
            }
        }
Ejemplo n.º 11
0
 public override void ItemUpdated(SPItemEventProperties properties)
 {
     base.ItemUpdated(properties);
     //合并字段
     if (properties.List.Fields.ContainsField("操作") && properties.List.Fields.ContainsField("作品"))
     {
         if (properties.ListItem["操作"] != null && properties.ListItem["作品"] != null)
         {
             string title = "" + properties.ListItem["操作"] + properties.ListItem["作品"];
             using (SPWeb oWebsite = new SPSite(properties.SiteId).OpenWeb(properties.RelativeWebUrl))
             {
                 oWebsite.AllowUnsafeUpdates = true;
                 SPListItemCollection collItems = oWebsite.Lists[properties.ListTitle].Items;
                 SPListItem           item      = collItems.GetItemById(properties.ListItemId);
                 item["Title"] = title;
                 item.Update();
                 oWebsite.AllowUnsafeUpdates = false;
             }
         }
     }
     //更新任务的状态
 }
Ejemplo n.º 12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string ID = Page.Request.QueryString["postID"];
                using (SPSite site = new SPSite("http://novosite.tce.se.gov.br"))
                {
                    using (SPWeb web = site.RootWeb)
                    {
                        SPList list = web.GetList("/Lists/Conteudo");
                        SPListItemCollection itens = list.GetItems();
                        SPListItem           item  = itens.GetItemById(Convert.ToInt32(ID));

                        lblIDCategoria.Text = Convert.ToString(item["Categoria"]);

                        DateTime dtCriacao = Convert.ToDateTime(item["Modified"]);
                        lblDia.Text = dtCriacao.Day.ToString().PadLeft(2, '0');
                        lblMes.Text = dtCriacao.Month.ToString().PadLeft(2, '0');

                        lblTitulo.Text = Convert.ToString(item["Título"]);

                        lblUsername.Text = Convert.ToString(item["Author"]).Split('#')[1];

                        string imagem = Convert.ToString(item["Imagem"]).Split(',')[0];
                        if (imagem.Equals(""))
                        {
                            imgNoticia.Visible = false;
                        }

                        imgNoticia.ImageUrl = imagem;
                        imgNoticia.ToolTip  = imagem;
                        ltlCorpo.Text       = "<span style=\"line-height: 150%; text-align:justify\">" + Convert.ToString(item["Conteudo"]) + "<span>";
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 13
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string ID = Page.Request.QueryString["postID"];
                using (SPSite site = new SPSite("http://novosite.tce.se.gov.br"))
                {
                    using (SPWeb web = site.RootWeb)
                    {
                        SPList list = web.GetList("/noticias/Lists/Postagens");
                        //SPList list = web.GetList("/noticias/SitePages");

                        SPListItemCollection itens = list.GetItems();
                        //SPList list2 = web.GetListFromWebPartPageUrl("");
                        SPListItem item = itens.GetItemById(Convert.ToInt32(ID));

                        //web.ParentWeb.Title = "xxxxxx";
                        //string sTitle = ((WebPart)this.Parent).Title;
                        //Label1.Text = "";


                        //System.Web.UI.MasterPage yourMaster = (System.Web.UI.MasterPage)Page.Master;
                        //yourMaster.Parent.Page.Title = "yyyyyyyy";

                        //Label1.Text = web.Title;
                        //web.Title = "xxx";

                        //list.BreakRoleInheritance(true);
                        //list.Update();

                        //web.RoleAssignments.Add()

                        string categoria = Convert.ToString(item["Categoria"]);
                        if (!categoria.Equals(""))
                        {
                            if (categoria.Contains("#"))
                            {
                                lblIDCategoria.Text = categoria.Split('#')[1];
                            }
                            else
                            {
                                lblIDCategoria.Text = categoria;
                            }
                        }


                        // Necessário permissão para adicionar o contador
                        //string contador_str = Convert.ToString(item["Contador"]);
                        //int contador = 1;
                        //if (!contador_str.Equals(""))
                        //    contador = Convert.ToInt32(contador_str)+1;

                        //web.AllowUnsafeUpdates = true;
                        //item["Contador"] = Convert.ToString(contador);
                        //item.Update();
                        //web.AllowUnsafeUpdates = false;


                        SPQuery oQuery = itens.SourceQuery;
                        //Pega apenas as matérias populares dos últimos 10 dias
                        oQuery.Query = "<Where><Geq><FieldRef Name='Created' /><Value Type='DateTime'><Today OffsetDays='-10' /></Value></Geq></Where> "
                                       + "<OrderBy><FieldRef Name='Contador' Ascending='FALSE' /></OrderBy>";

                        //oQuery.Query = "<OrderBy><FieldRef Name='Contador' Ascending='FALSE' /></OrderBy>";

                        //oQuery.Query = "<Where><Eq><FieldRef Name='ID'/>" +
                        //                 "<Value Type='Text'>"+ ID +"</Value></Eq></Where>";

                        oQuery.RowLimit = 4;
                        itens           = list.GetItems(oQuery);

                        foreach (SPListItem itemPopular in itens)
                        {
                            //string imagemMin = itemPopular["ImagemPrincipal"].ToString().Split(',')[0];
                            string imagemMin = itemPopular["Imagem"].ToString().Split(',')[0];

                            ltlPopulares.Text += "<li>";
                            ltlPopulares.Text += "	<div class=\"post-image\">";
                            ltlPopulares.Text += "		<div class=\"img-thumbnail\">";
                            ltlPopulares.Text += "			<a href=\"noticia.aspx?postID="+ itemPopular.ID + "\"></a>";
                            ltlPopulares.Text += "				<img src=\""+ imagemMin + "\" alt=\"\" style=\"width:50px; height:50px\">";
                            ltlPopulares.Text += "			</a>";
                            ltlPopulares.Text += "		</div>";
                            ltlPopulares.Text += "	</div>";
                            ltlPopulares.Text += "	<div class=\"post-info\">";
                            ltlPopulares.Text += "		<a href=\"noticia.aspx?postID="+ itemPopular.ID + "\">" + itemPopular["Título"].ToString() + "</a>";
                            ltlPopulares.Text += "		<div class=\"post-meta\">";
                            ltlPopulares.Text += Convert.ToDateTime(itemPopular["Modified"]).ToString("dd-MM-yyyy HH:mm");
                            ltlPopulares.Text += "		</div>";
                            ltlPopulares.Text += "	</div>";
                            ltlPopulares.Text += "</li>";
                        }


                        string imagem = item["Imagem"].ToString().Split(',')[0];
                        //string imagem = item["ImagemPrincipal"].ToString();

                        ltlImagens.Text += "<div class=\"owl-item\">";
                        ltlImagens.Text += "   <div>";
                        ltlImagens.Text += "		<div class=\"img-thumbnail\">";
                        ltlImagens.Text += "			<img class=\"img-responsive\" src=\""+ imagem + "\" alt=\"\">";
                        ltlImagens.Text += "		</div>";
                        ltlImagens.Text += "	</div>";
                        ltlImagens.Text += "</div>";


                        DateTime dtCriacao = Convert.ToDateTime(item["Modified"]);
                        lblDia.Text = dtCriacao.Day.ToString().PadLeft(2, '0');
                        lblMes.Text = dtCriacao.Month.ToString().PadLeft(2, '0');

                        lblTitulo.Text = Convert.ToString(item["Título"]);
                        //lblTitulo.Text = Convert.ToString(item["Titulo"]);


                        //lblUsername.Text = Convert.ToString(item["Author"]).Split('#')[1];
                        lblUsername.Text = "DICOM/TCE";
                        ltlCorpo.Text    = "<span style=\"line-height: 150%; text-align:justify; color: black; \">" + Convert.ToString(item["Corpo"]) + "<span>";

                        HtmlMeta wppMeta = new HtmlMeta();
                        wppMeta.Attributes.Add("property", "og:title");
                        wppMeta.Content = lblTitulo.Text;
                        Page.Header.Controls.Add(wppMeta);

                        wppMeta = new HtmlMeta();
                        wppMeta.Attributes.Add("property", "og:description");
                        wppMeta.Content = "Tribunal de Contas do Estado de Sergipe - TCE/SE";
                        Page.Header.Controls.Add(wppMeta);

                        wppMeta = new HtmlMeta();
                        wppMeta.Attributes.Add("property", "og:url");
                        wppMeta.Content = "http://www.tce.se.gov.br/SitePages/noticia.aspx?postID=" + ID;
                        Page.Header.Controls.Add(wppMeta);

                        wppMeta = new HtmlMeta();
                        wppMeta.Attributes.Add("property", "og:image");
                        wppMeta.Content = imagem;
                        Page.Header.Controls.Add(wppMeta);

                        oQuery          = itens.SourceQuery;
                        oQuery.Query    = "<OrderBy><FieldRef Name='Modified' Ascending='FALSE' /></OrderBy>";
                        oQuery.RowLimit = 4;
                        itens           = list.GetItems(oQuery);

                        foreach (SPListItem itemRecente in itens)
                        {
                            string imagemMin = itemRecente["Imagem"].ToString().Split(',')[0];
                            //string imagemMin = itemRecente["ImagemPrincipal"].ToString();

                            ltlRecentes.Text += "<li>";
                            ltlRecentes.Text += "	<div class=\"post-image\">";
                            ltlRecentes.Text += "		<div class=\"img-thumbnail\">";
                            ltlRecentes.Text += "			<a href=\"noticia.aspx?postID="+ itemRecente.ID + "\"></a>";
                            ltlRecentes.Text += "				<img src=\""+ imagemMin + "\" alt=\"\" style=\"width:50px; height:50px\">";
                            ltlRecentes.Text += "			</a>";
                            ltlRecentes.Text += "		</div>";
                            ltlRecentes.Text += "	</div>";
                            ltlRecentes.Text += "	<div class=\"post-info\">";
                            ltlRecentes.Text += "		<a href=\"noticia.aspx?postID="+ itemRecente.ID + "\">" + itemRecente["Título"].ToString() + "</a>";
                            ltlRecentes.Text += "		<div class=\"post-meta\">";
                            ltlRecentes.Text += Convert.ToDateTime(itemRecente["Modified"]).ToString("dd-MM-yyyy HH:mm");
                            ltlRecentes.Text += "		</div>";
                            ltlRecentes.Text += "	</div>";
                            ltlRecentes.Text += "</li>";
                        }


                        SPList listCategorias = web.GetList("/noticias/Lists/Categorias");
                        SPListItemCollection itensCategorias = listCategorias.GetItems();
                        foreach (SPListItem cat in itensCategorias)
                        {
                            ltlCategorias.Text += "<li><a href=\"/noticias/Lists/Categorias/Category.aspx?CategoryId=" + cat.ID + "&Name=" + cat.Title + "\">" + cat.Title + "</a></li>";
                        }



                        // addthis_inline_share_toolbox
                        ltlShare.Text  = "<script type=\"text/javascript\" src=\"//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-4fd1d3bd5a4b404a\"></script>";
                        ltlShare.Text += "<div class=\"addthis_inline_share_toolbox_u0cl\" addthis:url=\"/noticia.aspx?postID=" + ID + "\" addthis:title=\"" + lblTitulo.Text + "\" addthis:description=\"" + lblTitulo.Text + "\" data-title=\"" + lblTitulo.Text + "\" data-description=\"" + lblTitulo.Text + "\" addthis:media=\"" + imagem + "\"></div>";
                        //ltlShare.Text = "<div class=\"addthis_inline_share_toolbox\" data-url=\"/noticia.aspx?postID=" + ID + "\" data-description=\"" + lblTitulo.Text + "\" data-title=\"" + lblTitulo.Text + "\" data-media=\"" + imagem + "\"></div>";
                    }
                }
            }
            catch (Exception ex)
            {
                lblTitulo.Text = ex.Message.ToString();
            }
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 根据当前用户ID,获取操作设置数据
        /// </summary>
        /// <param name="userId">当前用户ID</param>
        /// <returns></returns>
        private DataTable GetBindData(int userId)
        {
            DataTable dt  = InitSouceTable();
            string    url = Request.Path;

            try
            {
                using (SPSite spSite = new SPSite(SPContext.Current.Site.ID)) //找到网站集
                {
                    using (SPWeb spWeb = spSite.OpenWeb(SPContext.Current.Web.ID))
                    {
                        //我的操作
                        SPList myactionlist = spWeb.Lists.TryGetList(webObj.MyActions);

                        if (myactionlist != null)
                        {
                            SPQuery myqry = new SPQuery
                            {
                                Query = @"<Where>
                              <Eq>
                                 <FieldRef Name='Author' LookupId='True' />
                                 <Value Type='Integer'>" + userId + @"</Value>
                              </Eq>
                             </Where>
                             <OrderBy>
                                 <FieldRef Name='Frequency' Ascending='FALSE' />
                                 <FieldRef Name='Frequency' Ascending='FALSE' />
                             </OrderBy>"
                            };
                            SPListItemCollection myActions = myactionlist.GetItems(myqry);

                            //所有操作
                            SPList  actionList = spWeb.Lists.TryGetList(webObj.ActionList);
                            SPQuery allQuery   = new SPQuery
                            {
                                Query = @" <OrderBy>
                                  <FieldRef Name='Frequency' Ascending='FALSE' />
                                  <FieldRef Name='Frequency' Ascending='FALSE' />
                               </OrderBy>"
                            };
                            SPListItemCollection actions = actionList.GetItems(allQuery);
                            if (myActions.Count > 0)//已有我的操作
                            {
                                url = myactionlist.DefaultDisplayFormUrl + "?Source=" + url + "&ID=";
                                if (myActions.Count == actions.Count)//所有系统操作均已被我个性化设置
                                {
                                    #region 所有系统操作均已被我个性化设置,则只绑定我的操作
                                    for (int i = 0; i < myActions.Count; i++)
                                    {
                                        DataRow dr = dt.NewRow();
                                        dr[0] = myActions[i]["ID"];
                                        dr[1] = myActions[i]["ActionID"];
                                        dr[2] = myActions[i]["Frequency"];
                                        dr[3] = myActions[i]["MinDuring"];
                                        dr[4] = myActions[i]["MaxDuring"];
                                        dr[5] = myActions[i]["NormalDuring"];
                                        dr[6] = myActions[i]["Desc"];
                                        int        actionId   = int.Parse(myActions[i]["ActionID"].ToString().Split(';')[0]);
                                        SPListItem thisaction = actions.GetItemById(actionId);
                                        dr[7]  = thisaction["Title"];// myActions[i]["Title"];
                                        dr[8]  = myActions[i]["Period"];
                                        dr[9]  = myActions[i]["DorM"];
                                        dr[10] = myActions[i]["Healthy"];
                                        dr[11] = myActions[i]["Interaction"];
                                        dr[12] = url + myActions[i]["ID"];

                                        //系统设置
                                        dr[13] = actionList.Fields.GetField("Frequency").Description + GetToolTip(webObj.Frequencies, thisaction["Frequency"]);
                                        dr[14] = actionList.Fields.GetField("Period").Description + GetToolTip(webObj.Periods, thisaction["Period"]);
                                        dr[15] = actionList.Fields.GetField("DorM").Description + GetToolTip(webObj.DoMs, thisaction["DorM"]);
                                        dr[16] = actionList.Fields.GetField("Healthy").Description + GetToolTip("", thisaction["Healthy"]);
                                        dr[17] = actionList.Fields.GetField("Interaction").Description + GetToolTip("", thisaction["Interaction"]);
                                        dr[18] = actionList.Fields.GetField("Desc").Description + GetToolTip("", thisaction["Desc"]);
                                        string jiliang = Environment.NewLine;
                                        if (thisaction["Measurement"] != null)
                                        {
                                            jiliang += actionList.Fields.GetField("Measurement").Title + ":" + thisaction["Measurement"];
                                        }
                                        if (thisaction["MUnits"] != null)
                                        {
                                            if (jiliang != Environment.NewLine)
                                            {
                                                jiliang += Environment.NewLine;
                                            }
                                            jiliang += actionList.Fields.GetField("MUnits").Title + ":" + thisaction["MUnits"];
                                        }
                                        //dr[19] = "时长或数量"+Environment.NewLine+ jiliang;
                                        dr[20] = myactionlist.Fields.GetField("MinDuring").Description + jiliang;
                                        dr[21] = myactionlist.Fields.GetField("MaxDuring").Description + jiliang;
                                        dr[22] = myactionlist.Fields.GetField("NormalDuring").Description + jiliang;
                                        dt.Rows.Add(dr);
                                    }
                                    #endregion
                                }
                                else
                                {
                                    #region 部分操作已经个性化,则首先绑定已个性化的部分
                                    for (int i = 0; i < myActions.Count; i++)//先绑定我已设置的操作
                                    {
                                        DataRow dr = dt.NewRow();
                                        dr[0] = myActions[i]["ID"];
                                        dr[1] = myActions[i]["ActionID"];
                                        dr[2] = myActions[i]["Frequency"];
                                        dr[3] = myActions[i]["MinDuring"];
                                        dr[4] = myActions[i]["MaxDuring"];
                                        dr[5] = myActions[i]["NormalDuring"];
                                        dr[6] = myActions[i]["Desc"];
                                        int        actionId   = int.Parse(myActions[i]["ActionID"].ToString().Split(';')[0]);
                                        SPListItem thisaction = actions.GetItemById(actionId);
                                        dr[7]  = thisaction["Title"];
                                        dr[8]  = myActions[i]["Period"];
                                        dr[9]  = myActions[i]["DorM"];
                                        dr[10] = myActions[i]["Healthy"];
                                        dr[11] = myActions[i]["Interaction"];
                                        dr[12] = url + myActions[i]["ID"];

                                        //系统设置
                                        dr[13] = actionList.Fields.GetField("Frequency").Description + GetToolTip(webObj.Frequencies, thisaction["Frequency"]);
                                        dr[14] = actionList.Fields.GetField("Period").Description + GetToolTip(webObj.Periods, thisaction["Period"]);
                                        dr[15] = actionList.Fields.GetField("DorM").Description + GetToolTip(webObj.DoMs, thisaction["DorM"]);
                                        dr[16] = actionList.Fields.GetField("Healthy").Description + GetToolTip("", thisaction["Healthy"]);
                                        dr[17] = actionList.Fields.GetField("Interaction").Description + GetToolTip("", thisaction["Interaction"]);
                                        dr[18] = actionList.Fields.GetField("Desc").Description + GetToolTip("", thisaction["Desc"]);
                                        string jiliang = Environment.NewLine;
                                        if (thisaction["Measurement"] != null)
                                        {
                                            jiliang += actionList.Fields.GetField("Measurement").Title + ":" + thisaction["Measurement"];
                                        }
                                        if (thisaction["MUnits"] != null)
                                        {
                                            if (jiliang != Environment.NewLine)
                                            {
                                                jiliang += Environment.NewLine;
                                            }
                                            jiliang += actionList.Fields.GetField("MUnits").Title + ":" + thisaction["MUnits"];
                                        }
                                        //dr[19] = "时长或数量"+Environment.NewLine+ jiliang;
                                        dr[20] = myactionlist.Fields.GetField("MinDuring").Description + jiliang;
                                        dr[21] = myactionlist.Fields.GetField("MaxDuring").Description + jiliang;
                                        dr[22] = myactionlist.Fields.GetField("NormalDuring").Description + jiliang;
                                        dt.Rows.Add(dr);
                                    }
                                    #endregion

                                    #region 部分未经过个性化设置,继续绑定该部分系统操作
                                    for (int i = 0; i < actions.Count; i++)
                                    {
                                        string actionId = actions[i]["ID"].ToString();
                                        //DataTable dtMy = myActions.GetDataTable();
                                        SPListItem item = GetItemByField(myActions, "ActionID", actionId);
                                        //DataRow[] drs = dtMy.Select("ActionID="+actionId);
                                        if (item == null)//找到那些尚未设置的操作
                                        {
                                            DataRow    dr         = dt.NewRow();
                                            SPListItem thisaction = actions[i];
                                            dr[0]  = 0;
                                            dr[1]  = thisaction["ID"];
                                            dr[2]  = thisaction["Frequency"];
                                            dr[3]  = null;
                                            dr[4]  = null;
                                            dr[5]  = null;
                                            dr[6]  = thisaction["Desc"];
                                            dr[7]  = thisaction["Title"];
                                            dr[8]  = thisaction["Period"];
                                            dr[9]  = thisaction["DorM"];;
                                            dr[10] = thisaction["Healthy"];
                                            dr[11] = thisaction["Interaction"];
                                            dr[12] = null;

                                            //系统设置
                                            dr[13] = actionList.Fields.GetField("Frequency").Description + GetToolTip(webObj.Frequencies, thisaction["Frequency"]);
                                            dr[14] = actionList.Fields.GetField("Period").Description + GetToolTip(webObj.Periods, thisaction["Period"]);
                                            dr[15] = actionList.Fields.GetField("DorM").Description + GetToolTip(webObj.DoMs, thisaction["DorM"]);
                                            dr[16] = actionList.Fields.GetField("Healthy").Description + GetToolTip("", thisaction["Healthy"]);
                                            dr[17] = actionList.Fields.GetField("Interaction").Description + GetToolTip("", thisaction["Interaction"]);
                                            dr[18] = actionList.Fields.GetField("Desc").Description + GetToolTip("", thisaction["Desc"]);
                                            string jiliang = Environment.NewLine;
                                            if (thisaction["Measurement"] != null)
                                            {
                                                jiliang += actionList.Fields.GetField("Measurement").Title + ":" + thisaction["Measurement"];
                                            }
                                            if (thisaction["MUnits"] != null)
                                            {
                                                if (jiliang != Environment.NewLine)
                                                {
                                                    jiliang += Environment.NewLine;
                                                }
                                                jiliang += actionList.Fields.GetField("MUnits").Title + ":" + thisaction["MUnits"];
                                            }
                                            //dr[19] = "时长或数量"+Environment.NewLine+ jiliang;
                                            dr[20] = myactionlist.Fields.GetField("MinDuring").Description + jiliang;
                                            dr[21] = myactionlist.Fields.GetField("MaxDuring").Description + jiliang;
                                            dr[22] = myactionlist.Fields.GetField("NormalDuring").Description + jiliang;
                                            dt.Rows.Add(dr);
                                        }
                                    }
                                    #endregion
                                }
                                //lbckCount.Text =myActions.Count.ToString();
                            }
                            else//尚无我的操作,则绑定系统操作
                            {
                                for (int i = 0; i < actions.Count; i++)
                                {
                                    DataRow    dr         = dt.NewRow();
                                    SPListItem thisaction = actions[i];
                                    dr[0]  = 0;
                                    dr[1]  = actions[i]["ID"];
                                    dr[2]  = actions[i]["Frequency"];
                                    dr[3]  = null;
                                    dr[4]  = null;
                                    dr[5]  = null;
                                    dr[6]  = actions[i]["Desc"];
                                    dr[7]  = actions[i]["Title"];
                                    dr[8]  = actions[i]["Period"];
                                    dr[9]  = actions[i]["DorM"];;
                                    dr[10] = actions[i]["Healthy"];
                                    dr[11] = actions[i]["Interaction"];
                                    dr[12] = null;

                                    //系统设置
                                    dr[13] = actionList.Fields.GetField("Frequency").Description + GetToolTip(webObj.Frequencies, thisaction["Frequency"]);
                                    dr[14] = actionList.Fields.GetField("Period").Description + GetToolTip(webObj.Periods, thisaction["Period"]);
                                    dr[15] = actionList.Fields.GetField("DorM").Description + GetToolTip(webObj.DoMs, thisaction["DorM"]);
                                    dr[16] = actionList.Fields.GetField("Healthy").Description + GetToolTip("", thisaction["Healthy"]);
                                    dr[17] = actionList.Fields.GetField("Interaction").Description + GetToolTip("", thisaction["Interaction"]);
                                    dr[18] = actionList.Fields.GetField("Desc").Description + GetToolTip("", thisaction["Desc"]);
                                    string jiliang = Environment.NewLine;
                                    if (thisaction["Measurement"] != null)
                                    {
                                        jiliang += actionList.Fields.GetField("Measurement").Title + ":" + thisaction["Measurement"];
                                    }
                                    if (thisaction["MUnits"] != null)
                                    {
                                        if (jiliang != Environment.NewLine)
                                        {
                                            jiliang += Environment.NewLine;
                                        }
                                        jiliang += actionList.Fields.GetField("MUnits").Title + ":" + thisaction["MUnits"];
                                    }
                                    //dr[19] = "时长或数量"+Environment.NewLine+ jiliang;
                                    dr[20] = myactionlist.Fields.GetField("MinDuring").Description + jiliang;
                                    dr[21] = myactionlist.Fields.GetField("MaxDuring").Description + jiliang;
                                    dr[22] = myactionlist.Fields.GetField("NormalDuring").Description + jiliang;
                                    dt.Rows.Add(dr);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                lbErr.Text = ex.ToString();
            }
            return(dt);
        }
Ejemplo n.º 15
0
        private DataTable GetBindData(string listName, string parentId, int userID = 0)
        {
            if (userID == 0)
            {
                userID = int.Parse(txtID.Text);
            }
            DataTable dt   = null;
            SPSite    site = new SPSite("http://localhost");
            SPWeb     web  = site.OpenWeb(txtWebUrl.Text);
            SPList    list = web.Lists.TryGetList(listName);//先到我的操作表中去找
            SPQuery   qry  = new SPQuery
            {
                DatesInUtc = false
            };
            List <string> actions = new List <string>();

            if (list != null)
            {
                qry.Query = "<Where><Eq><FieldRef Name='Author' LookupId='True' /><Value Type='Integer'>" + userID + @"</Value></Eq></Where><OrderBy><FieldRef Name='Frequency' Ascending='FALSE' /></OrderBy>";
                dt        = list.GetItems(qry).GetDataTable();
                SPListItemCollection items = list.GetItems(qry);
                SPListItem           item;
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        item = items.GetItemById((int)dr["ID"]);
                        SPFieldLookupValue actionID = new SPFieldLookupValue(item["ActionID"].ToString());
                        dr["ID"]    = actionID.LookupId;
                        dr["Title"] = actionID.LookupValue;
                        actions.Add(actionID.LookupValue);
                    }
                    dt.AcceptChanges();
                }
            }
            list = web.Lists.TryGetList(webObj.ActionList);
            if (dt == null || dt.Rows.Count < list.ItemCount)// 我的操作设置了部分操作
            {
                qry       = new SPQuery();
                qry.Query = "<OrderBy><FieldRef Name='Frequency' Ascending='FALSE' /></OrderBy>";
                DataTable dtALL = list.GetItems(qry).GetDataTable();
                if (dt == null)
                {
                    dt = dtALL.Copy();
                }
                else
                {
                    foreach (DataRow drTemp in dtALL.Rows)
                    {
                        if (!actions.Contains(drTemp["Title"].ToString()))
                        {
                            DataRow dr = dt.NewRow();
                            dr["ID"]        = drTemp["ID"];
                            dr["Title"]     = drTemp["Title"];
                            dr["Frequency"] = drTemp["Frequency"];
                            dt.Rows.Add(dr);
                        }
                    }
                }
            }

            dt.DefaultView.Sort = "Frequency desc";
            dt = dt.DefaultView.ToTable();
            return(dt);
        }
Ejemplo n.º 16
0
        public virtual SPGENRepositoryDataItem GetDataItem(SPListItemCollection itemCollection, int itemId, string[] fieldNames, SPGENEntityFileOperationArguments fileOperationParams)
        {
            var dataItem = new SPGENRepositoryDataItem(fieldNames);

            ConvertToDataItem(itemCollection.GetItemById(itemId), dataItem, fileOperationParams);

            return dataItem;
        }
        private DataTable GetYeJiParents(int userID, string listName, string year)
        {
            string    siteUrl      = SPContext.Current.Site.Url;
            DataTable retDataTable = null;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite spSite = new SPSite(siteUrl)) //找到网站集
                {
                    using (SPWeb spWeb = spSite.OpenWeb(SPContext.Current.Web.ID))
                    {
                        SPList spList = spWeb.Lists.TryGetList(listName);
                        if (spList != null)
                        {
                            SPQuery qry = new SPQuery();
                            qry.Query   = @"<Where><And><And><Eq><FieldRef Name='AuthorName' LookupId='True' /><Value Type='Integer'>" + userID + "</Value></Eq><Eq><FieldRef Name='Year' /><Value Type='Text'>" + year + "</Value></Eq></And><Eq><FieldRef Name='Flag'/><Value Type='Number'>1</Value></Eq></And></Where>";
                            SPListItemCollection listItems = spList.GetItems(qry);
                            if (listItems.Count > 0)// 获取主表满足条件的数据
                            {
                                DataTable dt     = listItems.GetDataTable();
                                string delFields = "Attachments;MetaInfo;FileLeafRef;Order;ContentType";//AuthorName";
                                #region define column
                                foreach (SPField field in spList.Fields)
                                {
                                    try
                                    {
                                        if (field.ReadOnlyField && field.InternalName != "ID" || delFields.Contains(field.InternalName))
                                        {
                                            dt.Columns.Remove(field.InternalName);
                                        }
                                    }
                                    catch
                                    { }
                                }
                                #endregion
                                #region enumerate
                                DataRow drNew;
                                retDataTable           = dt.Clone();
                                retDataTable.TableName = listName;

                                foreach (DataRow dr in dt.Rows)//遍历主表,是否已经审核
                                {
                                    SPListItem subITem = listItems.GetItemById((int)dr["ID"]);

                                    SPFieldUserValueCollection users = subITem["AuthorName"] as SPFieldUserValueCollection;
                                    if (users[0].LookupId == userID)//第一作者的是要查的
                                    {
                                        drNew           = retDataTable.NewRow();
                                        drNew.ItemArray = dr.ItemArray;
                                        retDataTable.Rows.Add(drNew);
                                    }
                                }
                                retDataTable.AcceptChanges();
                                #endregion
                                retDataTable.Columns.Remove("ID");         //移除Id一列
                                retDataTable.Columns.Remove("AuthorName"); //移除Id一列
                                retDataTable.AcceptChanges();
                            }
                        }
                    }
                }
            });
            return(retDataTable);
        }
        //获取满足条件的主表想
        private DataTable GetYeJiParentsWithNoAuthor(List <int> userIDs, string listName, string year)
        {
            string    siteUrl      = SPContext.Current.Site.Url;
            DataTable retDataTable = null;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite spSite = new SPSite(siteUrl)) //找到网站集
                {
                    using (SPWeb spWeb = spSite.OpenWeb(SPContext.Current.Web.ID))
                    {
                        SPList spList = spWeb.Lists.TryGetList(listName);
                        if (spList != null)
                        {
                            SPQuery qry;
                            #region  enumerate user
                            DataRow drNew;

                            foreach (int userID in userIDs)
                            {
                                qry       = new SPQuery();
                                qry.Query = @"<Where><And><And><And><IsNull><FieldRef Name='AuthorName'/></IsNull><Eq><FieldRef Name='Author' LookupId='True'/><Value Type='Integer'>" + userID + "</Value></Eq></And><Eq><FieldRef Name='Year' /><Value Type='Text'>" + year + "</Value></Eq></And><Eq><FieldRef Name='Flag'/><Value Type='Number'>1</Value></Eq></And></Where>";
                                SPListItemCollection listItems = spList.GetItems(qry);
                                if (listItems.Count > 0)
                                {
                                    DataTable dt = listItems.GetDataTable();
                                    if (retDataTable == null)
                                    {
                                        retDataTable           = dt.Clone();
                                        retDataTable.TableName = listName;
                                    }
                                    string account;

                                    foreach (DataRow dr in dt.Rows)//
                                    {
                                        SPListItem subITem = listItems.GetItemById((int)dr["ID"]);
                                        //SPFieldUserValueCollection users = subITem["Author"] as SPFieldUserValueCollection;
                                        SPFieldUserValue f = new SPFieldUserValue(spWeb, subITem["Author"].ToString());

                                        drNew                = retDataTable.NewRow();
                                        drNew.ItemArray      = dr.ItemArray;
                                        account              = GetAccount(f.User);
                                        drNew["AuthorName"]  = account;
                                        drNew["ContentType"] = f.User.Name;
                                        retDataTable.Rows.Add(drNew);
                                    }
                                }
                            }
                            #endregion
                            if (retDataTable != null)
                            {
                                retDataTable.AcceptChanges();
                                string delFields = "Attachments;MetaInfo;FileLeafRef;Order";//AuthorName";;ContentType去掉相关文档一列
                                #region define column
                                foreach (SPField field in spList.Fields)
                                {
                                    try
                                    {
                                        if (field.ReadOnlyField && !field.InternalName.StartsWith("ClassHour") || delFields.Contains(field.InternalName) || field.Type == SPFieldType.URL)
                                        {
                                            retDataTable.Columns.Remove(field.InternalName);
                                        }
                                    }
                                    catch
                                    { }
                                }
                                #endregion

                                //retDataTable.Columns.Remove("ID");//移除Id一列
                                retDataTable.Columns["AuthorName"].Caption  = "工号";//移除Id一列
                                retDataTable.Columns["ContentType"].Caption = "姓名";
                                //retDataTable.Columns.Remove("Flag");//移除Id一列
                                retDataTable.Columns["Flag"].Caption = "人数";//新开课使用
                                retDataTable.AcceptChanges();
                            }
                        }
                    }
                }
            });
            return(retDataTable);
        }
        private DataTable GetYeJiParents(List <int> userIDs, string listName, string year)
        {
            string    siteUrl      = SPContext.Current.Site.Url;
            DataTable retDataTable = null;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite spSite = new SPSite(siteUrl)) //找到网站集
                {
                    using (SPWeb spWeb = spSite.OpenWeb(SPContext.Current.Web.ID))
                    {
                        SPList spList = spWeb.Lists.TryGetList(listName);
                        if (spList != null)
                        {
                            SPQuery qry;
                            #region  enumerate user
                            DataRow drNew;
                            bool exportRatio = true;
                            if (listName.Contains("研究生") || listName.Contains("本科") || listName.Contains("毕业论文"))
                            {
                                exportRatio = false;
                            }
                            foreach (int userID in userIDs)
                            {
                                qry       = new SPQuery();
                                qry.Query = @"<Where><And><And><Eq><FieldRef Name='AuthorName' LookupId='True' /><Value Type='Integer'>" + userID + "</Value></Eq><Eq><FieldRef Name='Year' /><Value Type='Text'>" + year + "</Value></Eq></And><Eq><FieldRef Name='Flag'/><Value Type='Number'>1</Value></Eq></And></Where>";
                                SPListItemCollection listItems = spList.GetItems(qry);
                                if (listItems.Count > 0)
                                {
                                    DataTable dt = listItems.GetDataTable();
                                    if (retDataTable == null)
                                    {
                                        retDataTable           = dt.Clone();
                                        retDataTable.TableName = listName;
                                        if (exportRatio)
                                        {
                                            retDataTable.Columns.Add(webObj.RatioCaption, typeof(double));
                                        }
                                    }
                                    string account;
                                    if (listName == "新开课")              //多个人平分课时
                                    {
                                        foreach (DataRow dr in dt.Rows) //
                                        {
                                            SPListItem subITem = listItems.GetItemById((int)dr["ID"]);
                                            SPFieldUserValueCollection users = subITem["AuthorName"] as SPFieldUserValueCollection;

                                            foreach (SPFieldUserValue usr in users)
                                            {
                                                if (usr.LookupId == userID)
                                                {
                                                    drNew                = retDataTable.NewRow();
                                                    drNew.ItemArray      = dr.ItemArray;
                                                    account              = GetAccount(usr.User);//users[0].User错误,只找第一个人
                                                    drNew["AuthorName"]  = account;
                                                    drNew["ContentType"] = usr.User.Name;
                                                    drNew["Flag"]        = users.Count;
                                                    retDataTable.Rows.Add(drNew);
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                    else
                                    {
                                        SPListItemCollection yejiItems = null;
                                        foreach (DataRow dr in dt.Rows)//
                                        {
                                            SPListItem subITem = listItems.GetItemById((int)dr["ID"]);

                                            try
                                            {
                                                SPFieldUserValueCollection users = subITem["AuthorName"] as SPFieldUserValueCollection;

                                                if (users[0].LookupId == userID)//第一作者的是要查的
                                                {
                                                    //2019-4-23业绩项需要导入每个有系数的教师

                                                    if (exportRatio)
                                                    {
                                                        yejiItems = GetYeJiItems(listName, subITem.ID);
                                                        foreach (SPListItem yejiItem in yejiItems)
                                                        {
                                                            drNew                      = retDataTable.NewRow();
                                                            drNew.ItemArray            = dr.ItemArray;
                                                            SPFieldUserValue user      = new SPFieldUserValue(spWeb, yejiItem["姓名"].ToString());
                                                            account                    = GetAccount(user.User);
                                                            drNew["AuthorName"]        = account;
                                                            drNew["ContentType"]       = user.LookupValue;
                                                            drNew[webObj.RatioCaption] = yejiItem["Ratio"];
                                                            retDataTable.Rows.Add(drNew);
                                                        }
                                                    }
                                                    if (yejiItems == null || yejiItems.Count == 0)
                                                    {
                                                        drNew                = retDataTable.NewRow();
                                                        drNew.ItemArray      = dr.ItemArray;
                                                        account              = GetAccount(users[0].User);
                                                        drNew["AuthorName"]  = account;
                                                        drNew["ContentType"] = users[0].User.Name;
                                                        if (exportRatio)
                                                        {
                                                            drNew[webObj.RatioCaption] = 1;
                                                        }
                                                        retDataTable.Rows.Add(drNew);
                                                    }
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                //当字段设置中显示名称设置为姓名时,读出来的值为null;只需改动列表设置即可。
                                            }
                                        }
                                    }
                                }
                            }
                            #endregion
                            if (retDataTable != null)
                            {
                                retDataTable.AcceptChanges();
                                string delFields = "Attachments;MetaInfo;FileLeafRef;Order";//AuthorName";;ContentType去掉相关文档一列
                                #region define column
                                foreach (SPField field in spList.Fields)
                                {
                                    try
                                    {
                                        if (field.ReadOnlyField && !field.InternalName.StartsWith("ClassHour") || delFields.Contains(field.InternalName) || field.Type == SPFieldType.URL)
                                        {
                                            retDataTable.Columns.Remove(field.InternalName);
                                        }
                                    }
                                    catch
                                    { }
                                }
                                #endregion

                                //retDataTable.Columns.Remove("ID");//移除Id一列
                                retDataTable.Columns["AuthorName"].Caption  = "工号";//移除Id一列
                                retDataTable.Columns["ContentType"].Caption = "姓名";
                                //retDataTable.Columns.Remove("Flag");//移除Id一列
                                retDataTable.Columns["Flag"].Caption = "人数";//新开课使用
                                retDataTable.AcceptChanges();
                            }
                        }
                    }
                }
            });
            return(retDataTable);
        }