public ExportTable Export()
        {
            // 取得匯出規則描述
            XmlElement        descElement      = TeacherBulkProcess.GetExportDescription();
            IFieldFormater    fieldFormater    = new BaseFieldFormater();
            IResponseFormater responseFormater = new ResponseFormater();

            FieldCollection       fieldCollection = fieldFormater.Format(descElement);
            ExportFieldCollection exportFields    = responseFormater.Format(descElement);

            fieldCollection = FieldUtil.Match(fieldCollection, _selectFields);
            exportFields    = FieldUtil.Match(exportFields, _selectFields);

            IRequestGenerator reqGenerator = new ExportStudentRequestGenerator();

            reqGenerator.SetSelectedFields(_selectFields);

            ICondition condition = new BaseCondition("ID", "-1");

            reqGenerator.AddCondition(condition);
            foreach (string id in _conditions)
            {
                ICondition condition2 = new BaseCondition("ID", id);
                reqGenerator.AddCondition(condition2);
            }

            DSRequest  request  = reqGenerator.Generate();
            DSResponse response = TeacherBulkProcess.GetExportList(request);

            ExportTable table = new ExportTable();

            foreach (ExportField field in exportFields)
            {
                table.AddColumn(field);
            }

            foreach (XmlElement record in response.GetContent().GetElements("Teacher"))
            {
                ExportRow row = table.AddRow();
                foreach (ExportField column in table.Columns)
                {
                    int        columnIndex = column.ColumnIndex;
                    ExportCell cell        = row.Cells[columnIndex];
                    XmlNode    cellNode    = record.SelectSingleNode(column.XPath);
                    if (cellNode != null)
                    {
                        cell.Value = cellNode.InnerText;
                    }
                }
            }
            return(table);
        }
示例#2
0
        public override IExportColumn CreateExportColumn()
        {
            var er = new ExportRow()
            {
                Name        = this.Name,
                Size        = this.Size,
                Location    = this.Location,
                CanGrow     = this.CanGrow,
                BackColor   = this.BackColor,
                DesiredSize = this.Size
            };

            return(er);
        }
示例#3
0
        public override IExportColumn CreateExportColumn()
        {
            var er = new ExportRow();

            er.ToExportItem(this);
//			var er = new ExportRow(){
//				Name = this.Name,
//				Size = this.Size,
//				Location = this.Location,
//				CanGrow = this.CanGrow,
//				BackColor = this.BackColor,
//				DesiredSize = this.Size
//			};
            return(er);
        }
示例#4
0
文件: users.cs 项目: lokygb/FrontDesk
        /// <summary>
        /// Get the export heading for a course export
        /// </summary>
        public ExportRow GetCourseExportHeading(int courseID)
        {
            ExportRow row = new ExportRow();

            Assignment.AssignmentList assts = new Courses(m_ident).GetAssignments(courseID);

            //User
            row.Fields.Add("Username");
            //Course Total
            row.Fields.Add("Course Total");
            foreach (Assignment asst in assts)
            {
                row.Fields.AddRange(GetAsstExportHeading(asst.ID).Fields);
            }

            return(row);
        }
        public static void ExportGameLevels()
        {
            string path = EditorUtility.SaveFilePanel("Export Game Levels", "", "", "xls");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            using (Stream writer = File.Create(path))
            {
                ExportData exportData = new ExportData();
                foreach (GameLevelInfo gameLevel in InfoResolver.Resolve <FortInfo>().GameLevel.GameLevelInfos.Select(pair => pair.Value))
                {
                    ExportRow exportRow = new ExportRow();
                    exportRow.AddParameter("Id", new Parameter
                    {
                        Value = gameLevel.Id,
                        Type  = typeof(string)
                    });

/*                    exportRow.AddParameter("Scene", new Parameter
 *                  {
 *                      Value = gameLevel.Scene == null?null: gameLevel.Scene.Value.SceneName,
 *                      Type = typeof(string)
 *                  });*/
/*                    exportRow.AddParameter("DisplayName", new Parameter
 *                  {
 *                      Value = gameLevel.DisplayName,
 *                      Type = typeof(string)
 *                  });*/
                    exportRow.AddParameter("Name", new Parameter
                    {
                        Value = gameLevel.Name,
                        Type  = typeof(string)
                    });
                    exportRow.AddCustomExportParameter(gameLevel);
                    exportData.AddRow(exportRow);
                }
                HSSFWorkbook workbook = new HSSFWorkbook();

                HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Game Levels");
                exportData.SerializeToSheet(sheet);
                workbook.Write(writer);
            }
        }
示例#6
0
文件: users.cs 项目: lokygb/FrontDesk
        /// <summary>
        /// Get the heading row for an export
        /// </summary>
        public ExportRow GetAsstExportHeading(int asstID)
        {
            Rubrics   rubda = new Rubrics(m_ident);
            ExportRow row   = new ExportRow();

            //Get all rubric entries for the assignment
            Assignment asst = new Assignments(m_ident).GetInfo(asstID);
            Rubric     rub  = new Assignments(m_ident).GetRubric(asstID);

            Rubric.RubricList rublist = rubda.Flatten(rub);

            //Total
            row.Fields.Add(asst.Description + " Total");
            foreach (Rubric rubent in rublist)
            {
                row.Fields.Add(rubent.Name);
            }

            return(row);
        }
示例#7
0
文件: users.cs 项目: lokygb/FrontDesk
        /// <summary>
        /// Get a user's grades for a course in "export" format
        /// </summary>
        public ExportRow GetCourseExport(string username, int courseID)
        {
            double    totpoints, points;
            ExportRow row = new ExportRow();

            Assignment.AssignmentList assts = new Courses(m_ident).GetAssignments(courseID);

            //User
            row.Fields.Add(username);

            totpoints = 0;
            foreach (Assignment asst in assts)
            {
                row.Fields.AddRange(GetAsstExport(username, asst.ID, out points).Fields);
                totpoints += points;
            }

            //Course Total
            row.Fields.Insert(1, totpoints.ToString());

            return(row);
        }
示例#8
0
 public virtual void Visit(ExportRow exportRow)
 {
 }
示例#9
0
        public static void ExportIapPackages()
        {
            string path = EditorUtility.SaveFilePanel("Export Iap packages", "", "", "xls");

            if (string.IsNullOrEmpty(path))
            {
                return;
            }
            using (Stream writer = File.Create(path))
            {
                ExportData exportData = new ExportData();
                foreach (IapPackageInfo iapPackageInfo in InfoResolver.Resolve <FortInfo>().Package.Packages)
                {
                    ExportRow exportRow = new ExportRow();
                    exportRow.AddParameter("Sku", new Parameter
                    {
                        Value = iapPackageInfo.Sku,
                        Type  = typeof(string)
                    });
                    LanguageInfo[] languageInfos = EditorInfoResolver.Resolve <LanguageEditorInfo>().Languages;
                    if (languageInfos.Length == 1)
                    {
                        if (iapPackageInfo.DisplayName != null)
                        {
                            if (languageInfos[0].LanguageDatas.ContainsKey(iapPackageInfo.DisplayName.Id))
                            {
                                exportRow.AddParameter("DisplayName", new Parameter
                                {
                                    Value = languageInfos[0].LanguageDatas[iapPackageInfo.DisplayName.Id],
                                    Type  = typeof(string)
                                });
                            }
                        }
                    }
                    else
                    {
                        foreach (LanguageInfo languageInfo in EditorInfoResolver.Resolve <LanguageEditorInfo>().Languages)
                        {
                            if (iapPackageInfo.DisplayName != null)
                            {
                                if (languageInfo.LanguageDatas.ContainsKey(iapPackageInfo.DisplayName.Id))
                                {
                                    exportRow.AddParameter(string.Format("DisplayName-{0}", languageInfo.Name), new Parameter
                                    {
                                        Value = languageInfo.LanguageDatas[iapPackageInfo.DisplayName.Id],
                                        Type  = typeof(string)
                                    });
                                }
                            }
                        }
                    }
                    exportRow.AddParameter("Price", new Parameter
                    {
                        Value = iapPackageInfo.Price,
                        Type  = typeof(int)
                    });
                    exportRow.AddCustomExportParameter(iapPackageInfo);
                    exportData.AddRow(exportRow);
                }
                HSSFWorkbook workbook = new HSSFWorkbook();

                HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Iap packages");
                exportData.SerializeToSheet(sheet);
                workbook.Write(writer);
            }
        }
示例#10
0
        public ExportTable Export()
        {
            // 取得縣市對照表
            XmlElement schoolLocationList = Config.GetSchoolLocationList().GetContent().BaseElement;

            // 取得匯出規則描述
            XmlElement        descElement      = StudentBulkProcess.GetExportDescription();
            IFieldFormater    fieldFormater    = new BaseFieldFormater();
            IResponseFormater responseFormater = new ResponseFormater();

            FieldCollection       fieldCollection = fieldFormater.Format(descElement);
            ExportFieldCollection exportFields    = responseFormater.Format(descElement);



            fieldCollection = FieldUtil.Match(fieldCollection, _selectFields);
            exportFields    = FieldUtil.Match(exportFields, _selectFields);

            //// 有選狀態時加入
            //if (_selectFields.FindByDisplayText("狀態") != null)
            //{
            //    fieldCollection.Add(_selectFields.FindByDisplayText("狀態"));
            //    ExportField ex = new ExportField();
            //    ex.DisplayText = "狀態";
            //    ex.RequestName = "StudentStatus";
            //    ex.ColumnIndex = exportFields.Length;
            //    ex.DataType = "";
            //    ex.XPath = "";
            //    exportFields.Add(ex);

            //}


            IRequestGenerator reqGenerator = new ExportStudentRequestGenerator();

            _selectFieldsID = new FieldCollection();
            foreach (Field fd in _selectFields)
            {
                _selectFieldsID.Add(fd);
            }

            if (_selectFieldsID.Find("StudentID") == null)
            {
                Field fd1 = new Field();
                fd1.FieldName   = "StudentID";
                fd1.DisplayText = "學生系統編號";
                _selectFieldsID.Add(fd1);
            }
            reqGenerator.SetSelectedFields(_selectFieldsID);

            // 預設找-1, 不然會傳回所有學生
            ICondition condition = new BaseCondition("ID", "-1");

            reqGenerator.AddCondition(condition);
            foreach (string id in _conditions)
            {
                ICondition condition2 = new BaseCondition("ID", id);
                reqGenerator.AddCondition(condition2);
            }

            reqGenerator.AddOrder(new Order("GradeYear"));
            reqGenerator.AddOrder(new Order("Department"));
            reqGenerator.AddOrder(new Order("RefClassID"));
            reqGenerator.AddOrder(new Order("SeatNo"));

            DSRequest  request  = reqGenerator.Generate();
            DSResponse response = QueryStudent.GetExportList(request);

            ExportTable table = new ExportTable();



            foreach (ExportField field in exportFields)
            {
                table.AddColumn(field);
            }

            //// 取得學生狀態
            //Dictionary<string, string> StudStatusDic = new Dictionary<string, string>();
            //foreach (JHSchool.Data.JHStudentRecord stud in JHSchool.Data.JHStudent.SelectByIDs(K12.Presentation.NLDPanels.Student.SelectedSource ))
            //    StudStatusDic.Add(stud.ID, stud.Status.ToString());

            foreach (XmlElement record in response.GetContent().GetElements("Student"))
            {
                ExportRow row = table.AddRow();
                foreach (ExportField column in table.Columns)
                {
                    int        columnIndex = column.ColumnIndex;
                    ExportCell cell        = row.Cells[columnIndex];

                    XmlNode cellNode = record.SelectSingleNode(column.XPath);

                    //if(column.DisplayText !="狀態")
                    //    cellNode = record.SelectSingleNode(column.XPath);
                    // CustodianOtherInfo/CustodianOtherInfo[1]/EducationDegree[1]

                    #region 這段程式是處理匯入/匯出程式不一致問題
                    if (column.XPath.StartsWith("CustodianOtherInfo/Custodian"))
                    {
                        if (cellNode == null)
                        {
                            string x = column.XPath.Replace("CustodianOtherInfo/Custodian", "CustodianOtherInfo/CustodianOtherInfo");
                            cellNode = record.SelectSingleNode(x);
                            if (cellNode == null)
                            {
                                x        = column.XPath.Replace("CustodianOtherInfo/CustodianOtherInfo", "CustodianOtherInfo/Custodian");
                                cellNode = record.SelectSingleNode(x);
                            }
                        }
                    }
                    if (column.XPath.StartsWith("FatherOtherInfo/Father"))
                    {
                        if (cellNode == null)
                        {
                            string x = column.XPath.Replace("FatherOtherInfo/Father", "FatherOtherInfo/FatherOtherInfo");
                            cellNode = record.SelectSingleNode(x);
                            if (cellNode == null)
                            {
                                x        = column.XPath.Replace("FatherOtherInfo/FatherOtherInfo", "FatherOtherInfo/Father");
                                cellNode = record.SelectSingleNode(x);
                            }
                        }
                    }
                    if (column.XPath.StartsWith("MotherOtherInfo/Mother"))
                    {
                        if (cellNode == null)
                        {
                            string x = column.XPath.Replace("MotherOtherInfo/Mother", "MotherOtherInfo/MotherOtherInfo");
                            cellNode = record.SelectSingleNode(x);
                            if (cellNode == null)
                            {
                                x        = column.XPath.Replace("MotherOtherInfo/MotherOtherInfo", "MotherOtherInfo/Mother");
                                cellNode = record.SelectSingleNode(x);
                            }
                        }
                    }
                    #endregion

                    if (cellNode != null)
                    {
                        if (column.FieldName == "GraduateSchoolLocationCode")
                        {
                            cell.Value = GetCounty(schoolLocationList, cellNode.InnerText);
                        }
                        else if (column.FieldName == "DeptName") //處理科別繼承問題。
                        {
                            //這個欄位的資料一定會被回傳,因為設定了 Mandatory 屬性。
                            XmlNode selfDept = record.SelectSingleNode("SelfDeptName");
                            if (string.IsNullOrEmpty(selfDept.InnerText))
                            {
                                cell.Value = cellNode.InnerText;
                            }
                            else
                            {
                                cell.Value = selfDept.InnerText;
                            }
                        }
                        else if (column.FieldName == "Status")
                        {
                            cell.Value = GetStudStatusStr(cellNode.InnerText);
                        }
                        else
                        {
                            cell.Value = cellNode.InnerText;
                        }
                    }

                    //if (column.DisplayText == "狀態")//record.SelectSingleNode("StudentID")!=null )
                    //{
                    //    // 學生狀態
                    //    if (StudStatusDic.ContainsKey(record.SelectSingleNode("StudentID").InnerText))
                    //        cell.Value = StudStatusDic[record.SelectSingleNode("StudentID").InnerText];
                    //}
                }
            }
            return(table);
        }