Esempio n. 1
0
    protected void btnOK_Click(object sender, EventArgs e)
    {
        string process = this.dProcess.Value.Trim();
        ProcessInfoDef processInfo = new ProcessInfoDef();
        try
        {
            processInfo = iProcessManager.ExportProcess(process);
        }
        catch (FisException ex)
        {
            SendComplete(ex.mErrmsg);
            return;
        }
        catch (Exception ex)
        {
            SendComplete(ex.Message);
            return;
        }
        DataTable dt = new DataTable();
        dt.Columns.Add("");
        dt.Columns.Add("");
        dt.Columns.Add("");
        dt.Columns.Add("");
        dt.Columns.Add("");
        dt.Columns.Add("");
        try
        {

            DataRow dr;
            dr = dt.NewRow();
            dr[0] = "Process Name";
            dr[1] = processInfo.ProcessInfo.Process;
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "Process Type";
            dr[1] = processInfo.ProcessInfo.Type;
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "Process Descr";
            dr[1] = processInfo.ProcessInfo.Description;
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "Editor";
            dr[1] = processInfo.ProcessInfo.Editor;
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "Cdt";
            dr[1] = processInfo.ProcessInfo.Cdt.ToString("yyyy-MM-dd");
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "Udt";
            dr[1] = processInfo.ProcessInfo.Udt.ToString("yyyy-MM-dd");
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "Station List";
            dt.Rows.Add(dr);
            dr = dt.NewRow();
            dr[0] = "Prev Station";
            dr[1] = "Status";
            dr[2] = "Station";
            dr[3] = "Editor";
            dr[4] = "Cdt";
            dr[5] = "Udt";
            dt.Rows.Add(dr);

            foreach (ProcessStationMaintainInfo info in processInfo.ProcessStationList)
            {
                dr = dt.NewRow();
                dr[0] = info.PreStation;
                if (info.Status == 0)
                {
                    dr[1] = "FAIL";
                }
                else if (info.Status == 1)
                {
                    dr[1] = "PASS";
                }
                else if (info.Status == 2)
                {
                    dr[1] = "PROCESSING";
                }
                dr[2] = info.Station;
                dr[3] = info.Editor;
                dr[4] = info.Cdt.ToString("yyyy-MM-dd");
                dr[5] = info.Udt.ToString("yyyy-MM-dd");
                dt.Rows.Add(dr);
            }


            System.Web.HttpContext curContext = System.Web.HttpContext.Current;
            MemoryStream ms = ExcelManager.ExportDataTableToExcel(dt);
            //HSSFWorkbook workbook = new HSSFWorkbook();
            //MemoryStream ms = new MemoryStream();
            //ISheet sheet = workbook.CreateSheet("sheetA");
            //HSSFRow headerRow = sheet.CreateRow(0);

            //// handling header.
            //foreach (DataColumn column in dt.Columns)
            //    headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);

            // handling value.
            //int rowIndex = 0;

            //foreach (DataRow row in dt.Rows)
            //{
            //    IRow dataRow = sheet.CreateRow(rowIndex);

            //    foreach (DataColumn column in dt.Columns)
            //    {
            //        dataRow.CreateCell(column.Ordinal).SetCellValue(row[column].ToString());
            //    }

            //    rowIndex++;
            //}

            //workbook.Write(ms);
            curContext.Response.AddHeader("Content-Disposition", string.Format("attachment; filename=" + process + ".xls"));
            curContext.Response.BinaryWrite(ms.ToArray());

            //workbook = null;
            ms.Close();
            ms.Dispose();

        }
        catch (FisException ex)
        {
            SendComplete(ex.mErrmsg);
            return;
        }
        catch (Exception ex)
        {
            //show error
            SendComplete(ex.Message);
            return;
        }
    }
Esempio n. 2
0
        public ProcessInfoDef ExportProcess(string process)
        {
            ProcessInfoDef item = new ProcessInfoDef();
            ProcessMaintainInfo processInfo= getProcess(process);
            if (processInfo.Process == null || processInfo.Process == "")
            {
                //Copy的process源已经不存在
                FisException ex;
                List<string> paraError = new List<string>();
                ex = new FisException("DMT142", paraError);
                throw ex;
            }

            IList<ProcessStationMaintainInfo> processStationList = getProcessStationList(process);

            item.ProcessInfo = processInfo;
            item.ProcessStationList = processStationList;
            return item;

        }