Esempio n. 1
0
        private static void CopyFiles(Assignment assignment, Submit submit, string teamSubmitDirName, SystemSettings systemSettings)
        {
            MoCS.BuildService.Business.FileSystemWrapper fileSystem = new Business.FileSystemWrapper();

            // Copy nunit.framework.dll to this directory
            fileSystem.FileCopy(Path.Combine(systemSettings.NunitAssemblyPath, "nunit.framework.dll"),
                                Path.Combine(teamSubmitDirName, "nunit.framework.dll"), true);

            //copy the file to this directory
            using (Stream target = fileSystem.FileOpenWrite(Path.Combine(teamSubmitDirName, submit.FileName)))
            {
                try
                {
                    target.Write(submit.Data, 0, submit.Data.Length);
                }
                finally
                {
                    target.Flush();
                }
            }


            // Copy the interface file
            //delete the file if it existed already
            AssignmentFile interfaceFile = assignment.AssignmentFiles.Find(af => af.Name == "InterfaceFile");

            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, interfaceFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, interfaceFile.FileName),
                                Path.Combine(teamSubmitDirName, interfaceFile.FileName));

            //copy the server testfile
            //delete the file if it existed already
            AssignmentFile serverTestFile = assignment.AssignmentFiles.Find(af => af.Name == "NunitTestFileServer");

            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, serverTestFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, serverTestFile.FileName),
                                Path.Combine(teamSubmitDirName, serverTestFile.FileName));

            //copy additional serverfiles
            List <AssignmentFile> serverFilesToCopy = assignment.AssignmentFiles.FindAll(af => af.Name == "ServerFileToCopy");

            foreach (AssignmentFile serverFileToCopy in serverFilesToCopy)
            {
                fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, serverFileToCopy.FileName));

                fileSystem.FileCopy(Path.Combine(assignment.Path, serverFileToCopy.FileName),
                                    Path.Combine(teamSubmitDirName, serverFileToCopy.FileName));
            }

            //copy the client testfile
            AssignmentFile clientTestFile = assignment.AssignmentFiles.Find(af => af.Name == "NunitTestFileClient");

            //delete the file if it existed already
            fileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, clientTestFile.FileName));

            fileSystem.FileCopy(Path.Combine(assignment.Path, clientTestFile.FileName),
                                Path.Combine(teamSubmitDirName, clientTestFile.FileName));
        }
        /// <summary>
        /// Display the assignment file link and URL
        /// </summary>
        /// <param name="file">The assignment file</param>
        /// <param name="counter">The number of the file</param>
        private void DisplayFileLink(AssignmentFile file, int counter)
        {
            HyperLink fileLink = new HyperLink();
            fileLink.ID = "file" + counter.ToString(CultureInfo.InvariantCulture);
            fileLink.Text = file.Name;
            fileLink.Style.Add("display", string.Empty);

            DropBoxEditMode editMode = Status == LearnerAssignmentState.Completed ? DropBoxEditMode.Edit : DropBoxEditMode.View;
            DropBoxEditDetails editDetails = dropBox.GenerateDropBoxEditDetails(file, SPWeb, editMode, returnUrl);
            fileLink.NavigateUrl = editDetails.Url;
            if (string.IsNullOrEmpty(editDetails.OnClick) == false)
            {
                fileLink.Attributes.Add("onclick", editDetails.OnClick + "return false;");
            }
            else
            {
                if (SlkStore.Settings.DropBoxSettings.OpenSubmittedInSameWindow)
                {
                    fileLink.Attributes.Add("onclick", "window.top.location='" + editDetails.Url + "';");
                }
            }

            FilePanel.Controls.Add(new LiteralControl("<div>"));
            FilePanel.Controls.Add(fileLink);
            FilePanel.Controls.Add(new LiteralControl("</div>"));
        }
Esempio n. 3
0
        private void DeleteAndCopySingleAssignmentFile(string fileName, string teamSubmitDirName, Assignment assignment)
        {
            AssignmentFile file = assignment.AssignmentFiles.Find(af => af.Name == fileName);

            FileSystem.DeleteFileIfExists(Path.Combine(teamSubmitDirName, file.FileName));

            FileSystem.FileCopy(Path.Combine(assignment.Path, file.FileName),
                                Path.Combine(teamSubmitDirName, file.FileName));
        }
Esempio n. 4
0
        public static Assignment FillAssignmentDetailsFromXml(Assignment a, IFileSystem fileSystem, bool includeServerFiles)
        {
            if (a == null)
            {
                return(null);    //no active assignment
            }

            string path = Path.Combine(a.Path, "assignment.xml");

            if (fileSystem.FileExists(path))
            {
                XmlDocument doc = fileSystem.LoadXml(path);

                a.FriendlyName = GetNodeValue(doc, "Assignment/DisplayName");
                //a.Tagline = GetNodeValue(doc, "Assignment/Hint");

                a.Difficulty = int.Parse(GetNodeValue(doc, "Assignment/Difficulty"));
                a.Author     = GetNodeValue(doc, "Assignment/Author");
                a.Category   = GetNodeValue(doc, "Assignment/Category");

                a.InterfaceNameToImplement = GetNodeValue(doc, "Assignment/Rules/InterfaceNameToImplement");
                a.ClassNameToImplement     = GetNodeValue(doc, "Assignment/Rules/ClassNameToImplement");

                //a.ClassFileName = GetNodeValue(doc, "Assignment/Files/ClassFile");
                //a.InterfaceFileName = GetNodeValue(doc, "Assignment/Files/InterfaceFile");

                //a.UnitTestClientFileName = GetNodeValue(doc, "Assignment/Files/NunitTestFileClient");
                //a.UnitTestServerFileName = GetNodeValue(doc, "Assignment/Files/NunitTestFileServer");

                //a.CaseFileName = GetNodeValue(doc, "Assignment/Files/Case");
                a.AssignmentFiles = new List <AssignmentFile>();
                XmlNode fileNode = doc.SelectSingleNode("Assignment/Files");
                foreach (XmlNode fileChildNode in fileNode.ChildNodes)
                {
                    string nodeName = fileChildNode.Name;
                    string fileName = fileChildNode.InnerText;

                    string filepath = Path.Combine(a.Path, fileName);
                    if (File.Exists(filepath))
                    {
                        if (includeServerFiles || (nodeName != "NunitTestFileServer" && nodeName != "ServerFileToCopy"))
                        {
                            AssignmentFile assignmentFile = new AssignmentFile();
                            assignmentFile.Name     = nodeName;
                            assignmentFile.FileName = fileName;
                            assignmentFile.Data     = FacadeHelpers.ReadByteArrayFromFile(filepath);
                            a.AssignmentFiles.Add(assignmentFile);
                        }
                    }
                }
            }
            else
            {
                throw new ApplicationException("Details for the assignment could not be found");
            }
            return(a);
        }
Esempio n. 5
0
        private void FindDocumentUrl()
        {
            DropBoxManager manager = new DropBoxManager(AssignmentProperties);

            AssignmentFile[] files = manager.LastSubmittedFiles(true);
            if (files.Length == 0)
            {
                // Intial copy must have failed.
                CopyDocumentToDropBox();
            }
            else if (files.Length > 0)
            {
                assignmentFile = files[0];
            }
        }
Esempio n. 6
0
        private void SetupFileAction(AssignmentFile file, SlkButton button, bool includeReload)
        {
            DropBoxManager dropBoxMgr = new DropBoxManager(AssignmentProperties);

            DropBoxEditMode editMode = DropBoxEditMode.Edit;

            switch (LearnerAssignmentProperties.Status)
            {
            case LearnerAssignmentState.Completed:
            case LearnerAssignmentState.Final:
                editMode = DropBoxEditMode.View;
                break;
            }

            DropBoxEditDetails editDetails = dropBoxMgr.GenerateDropBoxEditDetails(file, SPWeb, editMode, Page.Request.RawUrl);

            string script = editDetails.OnClick;

            if (string.IsNullOrEmpty(script))
            {
                if (includeReload)
                {
                    script = string.Format(CultureInfo.InvariantCulture, "window.location='{0}&{1}=true';", CurrentUrl, startQueryStringName);
                }
            }
            else
            {
                if (LearnerAssignmentProperties.Status == LearnerAssignmentState.NotStarted && includeReload)
                {
                    script = string.Format(CultureInfo.InvariantCulture, "{0}window.location='{1}&{2}=true';return false;", script, CurrentUrl, startQueryStringName);
                }
                else
                {
                    script = script + "return false;";
                }
            }

            button.OnClientClick = script;
            button.NavigateUrl   = editDetails.Url;
        }
    /// <summary>
    /// (未上传则)上传作业/(已上传则)重新上传作业
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void btnUp_Click(object sender, EventArgs e)
    {
        this.lbtUp.Enabled = false;
        this.btSubmit.Enabled = false;
        //贡献分
        DataTable member = new Search().GetMenbersByGroupId(Convert.ToInt32(HiddenField2.Value));
        List<int> members = new List<int>();
        List<int> scores = new List<int>();
        int sumScore = 0;
        for (int i = 0; i < member.Rows.Count; i++)
        {
            members.Add(Convert.ToInt32(member.Rows[i]["ID"]));
            string score = ((TextBox)StuScores.Controls[i].Controls[1]).Text;
            if (score == "")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
               "<script>alert('成员贡献分不可为空!')</script>");
                return;
            }
            scores.Add(Convert.ToInt32(score));
            sumScore += scores[i];
        }
        if (sumScore > 100)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
               "<script>alert('成员贡献分之和超出100!')</script>");
            return;
        }
        else if (sumScore < 100)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
               "<script>alert('成员贡献分之和不足100!')</script>");
            return;
        }

        bool fileIsValid = false;
        //如果确认了上传文件,则判断文件类型是否符合要求
        if (this.InputFile1.HasFile)
        {
            //获取上传文件的后缀
            String fileExtension = System.IO.Path.GetExtension(this.InputFile1.FileName).ToLower();
            String[] restrictExtension = { ".rar", ".zip" };
            //判断文件类型是否符合要求
            for (int i = 0; i < restrictExtension.Length; i++)
            {
                if (fileExtension == restrictExtension[i])
                {
                    fileIsValid = true;
                }
            }

            ////////////////////////////////////////////////////////////
            /////可以增加一条,时间过期,不准再上传文件
            ////其实这样子写数据库操作很不规范,真正的三层架构是不许这样子写的,
            ////但是时间原因和编码人员的习惯问题导致,希望后续人员能够改进
            ////////////////////////////////////////////////////////////
            //连接数据库
            SqlConnection sqlCon = CC.GetConnection();
            //定义SQL语句
            int assmtID = Convert.ToInt32(HiddenField1.Value);
            string SqlStr = "select * from Assignment where ID=" + assmtID;

            //实例化SqlDataAdapter对象
            SqlDataAdapter da = new SqlDataAdapter(SqlStr, sqlCon);
            //实例化数据集DataSet
            DataSet ds = new DataSet();
            da.Fill(ds, "GroupAssmtInfo");
            DateTime deadline = Convert.ToDateTime(ds.Tables["GroupAssmtInfo"].Rows[0][4]);
            DateTime time = DateTime.Now;
            sqlCon.Close();

            //连接数据库
            SqlConnection sqlCon1 = CC.GetConnection();
            //定义SQL语句
            //int assmtID = Convert.ToInt32(HiddenField1.Value);
            int grpID = Convert.ToInt32(HiddenField2.Value);
            string SqlStr1 = "select * from Assignment_Group where assignmentID=" + assmtID + " and groupID=" + grpID;

            //实例化SqlDataAdapter对象
            SqlDataAdapter da1 = new SqlDataAdapter(SqlStr1, sqlCon1);
            //实例化数据集DataSet
            DataSet ds1 = new DataSet();
            da1.Fill(ds1, "AssmtFile");
            bool n = ds1.Tables["AssmtFile"].Rows[0][7] == DBNull.Value ? false : true;

            sqlCon1.Close();
            if (time < deadline)
            {
                //如果文件类型符合要求,调用moveto方法实现上传,并显示相关信息;在此处修改贡献分
                if (fileIsValid == true)
                {
                    if (new Student().AttributeScores(members, scores, Convert.ToInt32(HiddenField1.Value), Convert.ToInt32(HiddenField2.Value)))
                    {
                        try
                        {
                            //胡媛媛修改,上传大文件到服务器,2010-3-11,修改作业上传的位置,2010-6-11
                            string FilePath = Server.MapPath("..//") + "SiteFile" + "\\" + "homework";
                            //  this.FileUpload1.SaveAs(FilePath + "//" + FileUpload1.FileName);
                            string SaveFileName = FilePath + "\\" + InputFile1.FileName;
                            // this.InputFile1.MoveTo(SaveFileName, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
                            //胡媛媛修改,上传大文件到服务器,2010-3-11,修改作业上传的位置,2010-6-11

                            /////////////////////////////////////////////////////////////////////////////
                            /////////////向数据库里相关表里插入一条记录并改变其他表相关字段的值
                            ////////////////////////////////////////////////////////////////////////////
                            if (false == n)//n=1的时候是第一次上传文件
                            {
                                bool success = false;
                                AssignmentFile afile = new AssignmentFile();
                                AssignmentFileInfo afileInfo = new AssignmentFileInfo();
                                afileInfo.StrFileName = InputFile1.FileName;
                                afileInfo.StrFileTrueName = "[" + new AssignmentFile().GetAutoId() + "]" + InputFile1.FileName;
                                afileInfo.StrFileURL = FilePath + "\\" + afileInfo.StrFileTrueName;
                                afileInfo.IAssignmentId = Convert.ToInt32(HiddenField1.Value);
                                afileInfo.IGroupId = Convert.ToInt32(HiddenField2.Value);
                                afileInfo.DtSubmitTime = DateTime.Now;

                                //上传文件的函数,想数据库中添加
                                success = afile.UploadAssignmentFile(afileInfo);
                                if (true == success)
                                {
                                    //胡媛媛修改,调整文件保存的位置,使其先删除后保存,2010-6-4
                                    this.InputFile1.MoveTo(afileInfo.StrFileURL, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
                                    //胡媛媛修改,调整文件保存的位置,使其先删除后保存,2010-6-4
                                    this.Label1.Text = "上传成功!";

                                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                                    "<script>alert('上传成功!');location=location;</script>");
                                    n = true;
                                    return;
                                }
                                else
                                {
                                    //回滚
                                    string myupdate = "delete Assignment_Group where assignmentID='" + assmtID + "'and groupID=' " + grpID + "'";
                                    sqlCon1.Open();
                                    SqlCommand mycmd = new SqlCommand(myupdate, sqlCon1);
                                    mycmd.ExecuteNonQuery();
                                    sqlCon1.Close();

                                    this.Label1.Text = "上传失败!";
                                }

                            }
                            else
                            {
                                //重新上传
                                //胡媛媛添加,获取原来上传的文件ID,2010-03-03
                                int assmfileid = Convert.ToInt32(ds1.Tables["AssmtFile"].Rows[0][0]);
                                //胡媛媛添加,获取原来上传的文件ID,2010-03-03

                                bool success = false;
                                AssignmentFile afile = new AssignmentFile();
                                AssignmentFileInfo afileInfo = new AssignmentFileInfo();
                                afileInfo.StrFileName = InputFile1.FileName;
                                afileInfo.StrFileTrueName = "[" + new AssignmentFile().GetAutoId() + "]" + InputFile1.FileName;
                                afileInfo.StrFileURL = FilePath + "\\" + afileInfo.StrFileTrueName;
                                afileInfo.IAssignmentId = Convert.ToInt32(HiddenField1.Value);
                                afileInfo.IGroupId = Convert.ToInt32(HiddenField2.Value);
                                afileInfo.DtSubmitTime = DateTime.Now;
                                //胡媛媛添加,得到原来上传的文件Id,2010-03-03
                                afileInfo.IAssignmentFileId = assmfileid;
                                //胡媛媛添加,得到原来上传的文件Id,2010-03-03

                                success = afile.ReuploadAssignmentFile(afileInfo);
                                if (true == success)
                                {
                                    //胡媛媛修改,调整文件保存的位置,使其先删除后保存,2010-6-4
                                    this.InputFile1.MoveTo(afileInfo.StrFileURL, Brettle.Web.NeatUpload.MoveToOptions.Overwrite);
                                    //胡媛媛修改,调整文件保存的位置,使其先删除后保存,2010-6-4
                                    this.Label1.Text = "上传成功!";

                                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert",
                                    "<script>alert('上传成功!');location=location;</script>");
                                    n = true;
                                    //Response.AddHeader("Refresh", "0");
                                    return;
                                }
                                else
                                {
                                    this.Label1.Text = "上传失败!";
                                    n = true;
                                }
                            }
                        }
                        catch
                        {
                            this.Label1.Text = "文件上传不成功!";
                        }
                    }
                    else
                    {
                        this.Label1.Text = "服务器繁忙,请稍后再试!";
                    }
                }
                else
                {
                    this.Label1.Text = "只能是.zip或.rar文件";
                }
            }
            else
            {
                this.Label1.Text = "超过作业要求上传最后期限,不能上传!";
            }
        }
        else
        {
            this.Label1.Text = "未选择需上传的文件";
        }
    }
    //页面加载
    protected void Page_Load(object sender, EventArgs e)
    {
        //判断用户名是否为空
        if (Session["UserName"] == null)
        {
            System.Web.HttpContext.Current.Response.Write("<script>alert('请先登录');window.location.href='../Default.aspx'</script>");
            return;
        }
        //判断用户类型是否为学生
        if (Session["Type"].ToString() == "Student")
        {
            System.Web.HttpContext.Current.Response.Write("<script>window.location.href='../WarningPage.aspx'</script>");
            return;
        }
        //判断用户类型是否为教师并且激活
        if (Session["Type"].ToString() == "Teacher" && Session["UserState"].ToString() != "Active")
        {
            System.Web.HttpContext.Current.Response.Write("<script>alert('帐号未激活,请激活后重试');window.location.href='../Activate.aspx'</script>");
            return;
        }

        try
        {
            course = Session["Course"].ToString();
            strUserName = Session["UserName"].ToString();
            type = Session["Type"].ToString();
            assmtID = Int32.Parse(Request.QueryString["aid"]).ToString();
            groupID = Int32.Parse(Request.QueryString["gid"]).ToString();
        }
        catch
        {
            Response.Redirect("../Default.aspx");
            return;
        }

        //设置默认焦点在评语发表框
        if (!IsPostBack)
        {
            //程军添加,教师点击新留言后,使newMsg状态变为0。2010-3-10
            int aid = Convert.ToInt32(assmtID);
            int gid = Convert.ToInt32(groupID);
            string sql = ConfigurationManager.AppSettings["SQLConnStringSTEduSys"].ToString();
            SqlConnection myConn = new SqlConnection(sql);
            myConn.Open();
            string mySql = "update Assignment_Group set newMsgNum = 0 where assignmentID = " + aid + "and groupID = " + gid;
            SqlCommand myCmd = myConn.CreateCommand();
            myCmd.CommandText = mySql;
            myCmd.ExecuteNonQuery();
            myConn.Close();

            //程军添加,教师点击新留言后,使newMsg状态变为0。2010-3-10

            tbNewMsg.Focus();
            if (assmtID != null)
            {
                RepeaterDataBind();
            if (1 != index)
            {
                this.lbfirst.Visible = false;
            }

                //SubjectInfo si = new Forum().GetSubjectById(Convert.ToInt32(Request.QueryString["id"]));
                //AssignmentInfo ass = new Assignment().GetAssignmentById(Convert.ToInt32(Request.QueryString["aid"]));
                //获得作业名
                AssignmentInfo ass = new Assignment().GetAssignmentById(Convert.ToInt32(assmtID));
                lbAssTitle.Text = ass.StrTitle;
                //DataTable dt = new Assignment().GetClassNameandGroupNO(Convert.ToInt32(Request.QueryString["aid"]), Convert.ToInt32(Request.QueryString["gid"]));
               //获得组的班组号
                DataTable dt = new Assignment().GetClassNameandGroupNO(Convert.ToInt32(groupID));
                if (null != dt)
                {
                    string classname = Convert.ToString(dt.Rows[0][0]);
                    string groupNO = Convert.ToString(dt.Rows[0][1]);

                    lbGroup.Text = classname + groupNO + "组";
                }
                else
                    lbGroup.Text="不存在该组!";
                //获得组内学生姓名
                string groupLeader = new Search().GetGroupLeaderByGroupID(Convert.ToInt32(groupID));
                DataTable sdt = new Search().GetMenbersByGroupId(Convert.ToInt32(groupID));
                if (null != sdt)
                {
                    string stuname = null;
                    for (int i = 0; i < sdt.Rows.Count; i++)
                    {
                        if (sdt.Rows[i][3].ToString() == groupLeader)
                        {
                            stuname = stuname + sdt.Rows[i][3] + "(组长) ";
                        }
                        else
                        {
                            stuname = stuname + sdt.Rows[i][3] + " ";
                        }
                    }
                    lbMembers.Text = stuname;

                }
                else
                    lbMembers.Text = "不存在该组学生!";

                //获得作业名
                DataTable ads = new AssignmentFile().GetAssignmentFileByAssignmentIdAndGroupID(Convert.ToInt32(assmtID), Convert.ToInt32(groupID));
                if (ads.Rows.Count!=0)
                {
                    string af =Convert.ToString( ads.Rows[0][1]);
                    lbFileName.Text = af;
                }
                else
                    lbFileName.Text = "未提交";

                //lbTitle.Text = "主题:" + si.StrTheme;

                //UserControl_ThemeOfMsg theme = this.ThemeOfMsg1;
                //theme.Subject = si;

            }
        }
    }
Esempio n. 9
0
        private void CopyDocumentToDropBox()
        {
            DropBoxManager manager = new DropBoxManager(AssignmentProperties);

            assignmentFile = manager.CopyFileToDropBox();
        }
    /// <summary>
    /// 文件打包下载这个功能未实现,如要实现时  可以参考SAssignmentInfo.aspx.cs 只需一个文件路径即可 问题是要得到所有的路径并分班打包
    /// 打包函数用张航留下的那个
    /// 可能需要引用gridview单元格内的内容(比如班级),可以试一试用GridView1.Rows[i].Cells[1].ToString();
    /// 路径这个字段在TAssmtInfo视图中有可以参考下一行注释使用这个字段
    /// 如另想要TAssmtInfo视图的其他字段可以再在页面添加
    ///  <asp:BoundField DataField="submitTime" HeaderText="提交日期" Visible=false/>之类的,但是注意要Visible=false就可以
    /// 关于复选框的获得可以参考admin中学生管理页面的cs代码
    /// 当然,如果不用gridview实现的话,上面都是废话了
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    ///胡媛媛添加btDownLoad_Click事件代码,2010-03-06
    protected void btDownLoad_Click(object sender, EventArgs e)
    {
        int asscount = 0;
        int flag = 1; //用来判断是否有小组未上传作业,初始值为1,如果有小组未交上传作业则值为0;
        List<pathitem> FilePathArray = new List<pathitem>();
        //ArrayList FilePathArray = new ArrayList();

        for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
        {
            //建立模板列中CheckBox控件的引用
            CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("chkCheck");
            if (chk.Checked == true)
            {
                asscount++;  //统计选中的作业数目
                if (GridView1.Rows[i].Cells[3].Text == "&nbsp;")  //文件名为空,作业未上传。
                {
                    flag = 0;
                }
            }
        }
        if (asscount == 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('未选中任何作业,请选择一个作业后再下载!')</script>");
            return;
        }
        if (flag == 0)
        {
            Page.ClientScript.RegisterStartupScript(this.GetType(), "Alert", "<script>alert('有小组未交作业,无法下载!')</script>;");
            return;
        }
        if ((asscount != 0) && (flag == 1))
        {

            //胡媛媛修改,获取班级名称和文件路径,2010-3-13
            // ArrayList classname = new ArrayList(); //记录班级的名称
            // int k=0;
            SqlConnection myconn = CC.GetConnection();
            string mystr = "select fileName,fileURL from Assignment_Group where assignmentID =" + Convert.ToInt32(id);
            SqlDataAdapter mydata = new SqlDataAdapter(mystr, myconn);
            DataSet ds = new DataSet();
            mydata.Fill(ds, "AssmtFile");

            for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
            {
                CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("chkCheck");
                if (chk.Checked == true)
                {
                    for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                    {
                        if (GridView1.Rows[i].Cells[3].Text == ds.Tables[0].Rows[j][0].ToString())
                        {
                            string tmpname = GridView1.Rows[i].Cells[1].Text;
                            StringBuilder filename = new StringBuilder(tmpname);
                            filename.Append(GridView1.Rows[i].Cells[2].Text).Append("组");
                            pathitem item1 = new pathitem(filename.ToString(), ds.Tables[0].Rows[j][1].ToString());
                            FilePathArray.Add(item1);
                        }
                    }
                }
            }

            AssignmentFile zfile = new AssignmentFile();
            bool fg=zfile.Compreassmtfile(FilePathArray, this.lbTitle.Text);
            //胡媛媛修改,获取班级名称和文件路径,2010-3-13
            //程军修改,2010-3-9
            if (fg==true)
            {
                for (int i = 0; i <= GridView1.Rows.Count - 1; i++)
                {
                    CheckBox chk = (CheckBox)GridView1.Rows[i].FindControl("chkCheck");
                    if (chk.Checked == true)
                    {

                        string className = GridView1.Rows[i].Cells[1].Text.ToString();
                        int groupNO = Convert.ToInt32(GridView1.Rows[i].Cells[2].Text.ToString());
                        SqlParameter[] parms = {
                                                new SqlParameter("@className",className),
                                                new SqlParameter("@groupNO",groupNO),
                                                new SqlParameter("@courseName", course)
                                              };
                        SqlDataReader reader = SQLHelper.ExecuteReader(SQLHelper.ConnectionStringSTEduSys, CommandType.StoredProcedure, "SP_GetGroupIdByClassNameAndGroupNO", parms);
                        reader.Read();
                        int groupID = Convert.ToInt32(reader[0].ToString());
                        reader.Close();

                        SqlConnection myConn = CC.GetConnection();
                        myConn.Open();
                        string mySql = "update Assignment_Group set state = 2 where assignmentID=" + Convert.ToInt32(id) + "and groupID =" + groupID;
                        SqlCommand myCmd = myConn.CreateCommand();
                        myCmd.CommandText = mySql;
                        myCmd.ExecuteNonQuery();
                        myConn.Close();
                    }
                }
                Response.Write("<script>window.location.reload(true);</script>");
            }
            else
            {
                Response.Write("<script>alert('下载失败!');</script>");
            }

            System.Web.HttpContext.Current.Response.End();

            //程军修改,2010-3-9

        }
    }