Пример #1
0
        public ActionResult ExportCoursesDeadline(string check)
        {
            string searchCheck = check.Split('^')[0];
            string Course_Name = check.Split('^')[1];
            string Semester_ID = check.Split('^')[2];

            Course_Name = Course_Name == "2" ? "" : Course_Name;
            Semester_ID = Semester_ID == "3" ? "" : Semester_ID;
            List <Cour_dealine> list = new List <Cour_dealine>();

            if (searchCheck != "1")
            {
                list = unitOfWork.DeadLine.GetPageList(Course_Name, Semester_ID);
            }
            var myExport = new CSVExport();

            foreach (var course in list)
            {
                myExport.AddRow();
                myExport[""]            = course.groupRowNo;
                myExport["Subject ID"]  = course.Subject_ID;
                myExport["Course Name"] = course.Courses_Name;
                myExport["Deadline"]    = course.deadlineString;
                myExport["Semester"]    = course.Semester_Name;
            }

            return(File(myExport.ExportToBytes(), "text/csv", "Courses-Deadline.csv"));
        }
Пример #2
0
        public void Cardinality(string casesFilesDir, int maxNumOfDiag)
        {
            CSVExport myExport = new CSVExport();
            List <PhysioCaseInstance> physioCases = new List <PhysioCaseInstance>();
            List <string>             files       = Directory.GetFiles(casesFilesDir).ToList();

            foreach (string file in files)
            {
                PhysioCaseInstance physioCase = caseParser.ParseCase(file);
                if (physioCase != null)
                {
                    physioCases.Add(physioCase);
                }
            }
            foreach (PhysioCaseInstance physioCase in physioCases)
            {
                if (physioCase.Diagnoses.Count < 2 || (maxNumOfDiag > 0 && physioCase.Diagnoses.Count > maxNumOfDiag))
                {
                    continue;
                }
                myExport.AddRow();
                myExport["Observation"]  = physioCase.Id;
                myExport["RealDiagCard"] = physioCase.RealDiagCardinality;
                myExport["MaxCard"]      = physioCase.MaxCardinality;
                myExport["MinCard"]      = physioCase.MinCardinality;
            }
            myExport.ExportToFile("Physiotherapy_Cardinality.csv");
        }
Пример #3
0
    /// <summary>
    /// 保存文件到path,可能是源文件也可能是其他文件
    /// </summary>
    /// <param name="path"></param>
    /// <returns保存是否成功></returns>
    public bool SaveFile(string path)
    {
        SaveLayout();

        DataGridViewConsoleForm.Level verifyLevel = VerifySelfAndShowConsole("保存文件");

        bool canSave = false;

        if (verifyLevel == DataGridViewConsoleForm.Level.Info)
        {
            canSave = true;
        }
        else if (verifyLevel == DataGridViewConsoleForm.Level.Warning)
        {
            if (MessageBox.Show("您现在有Warning,确定存储吗?", "提示", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                canSave = true;
            }
        }

        if (canSave)
        {
            // 保存文件
            CSVExport myExport = new CSVExport(",", false);
            try
            {
                for (int rowIdx = 0; rowIdx < m_DataTable.Rows.Count; rowIdx++)
                {
                    myExport.AddRow();
                    DataRow dataRow = m_DataTable.Rows[rowIdx];
                    for (int colIdx = 0; colIdx < m_DataTable.Columns.Count; colIdx++)
                    {
                        string value = (string)dataRow[colIdx];
                        myExport[colIdx.ToString()] = value;
                    }
                }

                myExport.ExportToFile(path);
            }
            catch (Exception ex)
            {
                DebugUtility.ShowExceptionMessageBox(string.Format("保存文件({0})失败", path), ex);
                return(false);
            }
            return(true);
        }
        else
        {
            MessageBox.Show(string.Format("保存文件({0})失败", path), "提示");
            return(false);
        }
    }
Пример #4
0
        public ActionResult Export()
        {
            var myExport = new CSVExport();

            myExport.AddRow();
            myExport["Roll Number"] = "SE0001";
            myExport["Full Name"]   = "Full name";
            myExport["Email"]       = "*****@*****.**";
            myExport["Subject"]     = "PMG201c";

            myExport.AddRow();
            myExport["Roll Number"] = "SE0002";
            myExport["Full Name"]   = "Full name";
            myExport["Email"]       = "*****@*****.**";
            myExport["Subject"]     = "PMG201c";

            myExport.AddRow();
            myExport["Roll Number"] = "SE0003";
            myExport["Full Name"]   = "Full name";
            myExport["Email"]       = "*****@*****.**";
            myExport["Subject"]     = "PMG201c";

            return(File(myExport.ExportToBytes(), "text/csv", "StudentTemplate.csv"));
        }
Пример #5
0
        public void RealWC(string casesFilesDir, int maxNumOfDiag, BatchCostEstimator bce)
        {
            CSVExport myExport = new CSVExport();
            List <PhysioCaseInstance> physioCases = new List <PhysioCaseInstance>();
            string        bceType  = bce.Type();
            string        overhead = bce.Overhead + "";
            List <string> files    = Directory.GetFiles(casesFilesDir).ToList();

            foreach (string file in files)
            {
                PhysioCaseInstance physioCase = caseParser.ParseCase(file);
                if (physioCase != null)
                {
                    physioCases.Add(physioCase);
                }
            }
            foreach (PhysioCaseInstance physioCase in physioCases)
            {
                if (physioCase.Diagnoses.Count < 2 || (maxNumOfDiag > 0 && physioCase.Diagnoses.Count > maxNumOfDiag))
                {
                    continue;
                }
                SystemState currSystemState = new SystemState(physioCase.Diagnoses.Components);
                currSystemState.Diagnoses = physioCase.Diagnoses; //!! check for bug
                double wc = bce.WastedCostUtility(new RepairAction(physioCase.RealDiagnosis.Diag), currSystemState);
                myExport.AddRow();
                myExport["Objective Function"] = bceType;
                myExport["Overhead"]           = overhead;
                myExport["Observation"]        = physioCase.Id;
                myExport["RealDiag"]           = physioCase.RealDiagnosis;
                myExport["RealWC"]             = wc;
            }
            string fileName = "Physiotherapy_RealWC";

            if (maxNumOfDiag > 0)
            {
                fileName += "_maxDiag=" + maxNumOfDiag;
            }
            fileName += "_" + bceType + "_o=" + overhead;
            myExport.ExportToFile(fileName + ".csv");
        }
Пример #6
0
        public ActionResult ExportCoursera(string check)
        {
            string searchCheck = check.Split('^')[0];
            string Email       = check.Split('^')[1];
            string Semester_ID = check.Split('^')[2];
            string Campus_ID   = check.Split('^')[3];

            var students = unitOfWork.Students.GetAll();

            if (searchCheck != "1")
            {
                if (Email != "2")
                {
                    students = students.Where(s => s.Email.Trim().ToUpper().Contains(Email.Trim().ToUpper())).ToList();
                }
                if (Semester_ID != "3")
                {
                    students = students.Where(s => s.Semester_ID.Trim() == Semester_ID.Trim()).ToList();
                }
                if (Campus_ID != "4")
                {
                    students = students.Where(s => s.Campus_ID.Trim() == Campus_ID.Trim()).ToList();
                }
            }
            var myExport = new CSVExport();

            foreach (var student in students)
            {
                myExport.AddRow();
                myExport["Full Name"] = student.Full_Name;
                myExport["Email"]     = student.Email;
                var subject = unitOfWork.SubjectStudent.getListSubject(student.Roll + "^" + student.Semester_ID).ToString();
                myExport["External ID"] = subject + "@" + student.Campus_ID + "-" + student.Roll;
            }

            return(File(myExport.ExportToBytes(), "text/csv", "Coursera-Invitation.csv"));
        }
Пример #7
0
        public ActionResult Export(string check)
        {
            string searchCheck = check.Split('^')[0];
            string Email       = check.Split('^')[1];
            string Semester_ID = check.Split('^')[2];
            string Campus_ID   = check.Split('^')[3];

            var students = unitOfWork.Students.GetAll();

            if (searchCheck != "1")
            {
                if (Email != "2")
                {
                    students = students.Where(s => s.Email.Trim().ToUpper().Contains(Email.Trim().ToUpper())).ToList();
                }
                if (Semester_ID != "3")
                {
                    students = students.Where(s => s.Semester_ID.Trim() == Semester_ID.Trim()).ToList();
                }
                if (Campus_ID != "4")
                {
                    students = students.Where(s => s.Campus_ID.Trim() == Campus_ID.Trim()).ToList();
                }
            }
            var myExport = new CSVExport();

            foreach (var student in students)
            {
                myExport.AddRow();
                myExport["Roll Number"] = student.Roll;
                myExport["Full Name"]   = student.Full_Name;
                myExport["Email"]       = student.Email;
            }

            return(File(myExport.ExportToBytes(), "text/csv", "Student.csv"));
        }
Пример #8
0
        public void BatchRepair(string casesFilesDir, BatchPlanner planner, double overhead, int maxNumOfDiag)
        {
            Console.WriteLine(planner.Type() + " o=" + overhead);
            Stopwatch stopwatch = new Stopwatch();
            CSVExport myExport  = new CSVExport();
            List <PhysioCaseInstance> physioCases = new List <PhysioCaseInstance>();
            List <string>             files       = Directory.GetFiles(casesFilesDir).ToList();

            foreach (string file in files)
            {
                PhysioCaseInstance physioCase = caseParser.ParseCase(file);
                if (physioCase != null)
                {
                    physioCases.Add(physioCase);
                }
            }
            foreach (PhysioCaseInstance physioCase in physioCases)
            {
                if (physioCase.Diagnoses.Count < 2 || (physioCase.Diagnoses.Count > maxNumOfDiag && maxNumOfDiag > 0))//!!
                {
                    continue;
                }
                // Console.WriteLine(physioCase.Id); //!!
                int         iterationCounter = 0;
                double      totalCost        = 0;
                int         numberOfFixed    = 0;
                int         expanded         = 0;
                bool        foundOpt         = true;
                bool        finished         = false;
                List <Comp> toRepair         = new List <Comp>(physioCase.RealDiagnosis.Diag);
                SystemState currSystemState  = new SystemState(physioCase.Diagnoses.Components);
                currSystemState.Diagnoses = physioCase.Diagnoses; //!! check for bug
                stopwatch.Start();
                while (!finished)
                {
                    RepairAction action = planner.Plan(currSystemState);
                    if (action == null)
                    {
                        break; //!!
                    }
                    iterationCounter++;
                    totalCost     += overhead;
                    numberOfFixed += action.Count;
                    foreach (Comp comp in action.R)
                    {
                        totalCost += comp.Cost;
                        if (toRepair.Contains(comp))
                        {
                            toRepair.Remove(comp);
                        }
                    }
                    if (toRepair.Count > 0)
                    {
                        currSystemState.SetNextState(action);
                    }
                    else
                    {
                        finished = true;
                    }
                    if (iterationCounter == 1)
                    {
                        expanded = planner.IterationDetails.NumOfExpanded;
                        foundOpt = planner.IterationDetails.FoundOpt;
                    }
                    planner.ExportIterationDetails("1", physioCase.Id, iterationCounter, finished);
                }
                if (!finished)//!!
                {
                    continue;
                }
                stopwatch.Stop();
                int time = stopwatch.Elapsed.Milliseconds;
                stopwatch.Reset();
                myExport.AddRow();
                //myExport["System"] = model.Id;
                myExport["Algorithm"] = planner.Algorithm();
                if (planner.Bounded)
                {
                    myExport["Bound"] = planner.Bound;
                }
                else
                {
                    myExport["Bound"] = "No Bound";
                }
                myExport["Objective Function"] = planner.ObjectiveFunction();
                myExport["Overhead"]           = overhead;
                myExport["Observation"]        = physioCase.Id;
                myExport["# Diagnoses"]        = physioCase.Diagnoses.Count;
                myExport["Runtime(ms)"]        = time;
                myExport["# Iterations"]       = iterationCounter;
                myExport["Cost"] = totalCost;
                myExport["# Fixed Components"]            = numberOfFixed;
                myExport["# Expanded In First Iteration"] = expanded;
                myExport["Found Opt"] = foundOpt;
            }
            string fileName = "Physiotherapy " + planner.Type() + "_o=" + overhead;

            if (maxNumOfDiag > 0)
            {
                fileName += "_MaxDiag" + maxNumOfDiag;
            }
            myExport.ExportToFile(fileName + ".csv");
            planner.CreateIterationDetailsFile(fileName + "_IterationDetails");
        }