Пример #1
0
 static Dictionary <GridViewExportFormat, GridViewExportMethod> CreateExportFormatsInfo()
 {
     return(new Dictionary <GridViewExportFormat, GridViewExportMethod> {
         { GridViewExportFormat.Pdf, GridViewExtension.ExportToPdf },
         {
             GridViewExportFormat.Xls,
             (settings, data) => GridViewExtension.ExportToXls(settings, data, new XlsExportOptionsEx {
                 ExportType = DevExpress.Export.ExportType.WYSIWYG
             })
         },
         {
             GridViewExportFormat.Xlsx,
             (settings, data) => GridViewExtension.ExportToXlsx(settings, data, new XlsxExportOptionsEx {
                 ExportType = DevExpress.Export.ExportType.WYSIWYG
             })
         },
         { GridViewExportFormat.Rtf, GridViewExtension.ExportToRtf },
         {
             GridViewExportFormat.Csv,
             (settings, data) => GridViewExtension.ExportToCsv(settings, data, new CsvExportOptionsEx {
                 ExportType = DevExpress.Export.ExportType.WYSIWYG
             })
         }
     });
 }
Пример #2
0
        public ActionResult ExportTo(string OutputFormat)
        {
            var model = Session["TypedListModel"];

            switch (OutputFormat.ToUpper())
            {
            case "CSV":
                return(GridViewExtension.ExportToCsv(GridViewHelper.ExportGridViewSettings, model));

            case "PDF":
                return(GridViewExtension.ExportToPdf(GridViewHelper.ExportGridViewSettings, model));

            case "RTF":
                return(GridViewExtension.ExportToRtf(GridViewHelper.ExportGridViewSettings, model));

            case "XLS":
                return(GridViewExtension.ExportToXls(GridViewHelper.ExportGridViewSettings, model));

            case "XLSX":
                return(GridViewExtension.ExportToXlsx(GridViewHelper.ExportGridViewSettings, model));

            default:
                return(RedirectToAction("Index"));
            }
        }
Пример #3
0
        public ActionResult ExportXLS(GridViewExportedRowType exportRowType)
        {
            var setting = GridHelper.GetSettingExport(vIndustrias.GetDynamicCollectionList(vIndustrias.GetViewModel()), _ControllerName);

            setting.SettingsExport.ExportedRowType = exportRowType;

            // retornamos el excel al usuario
            return(GridViewExtension.ExportToXls(setting, vIndustrias.GetViewModel(), string.Format("{0}s_{1}.{2}", typeof(vIndustrias).Name, DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
        }
Пример #4
0
        public virtual ActionResult ExportXLS(GridViewExportedRowType exportRowType)
        {
            var setting = GridHelper.GetSettingExport(typeof(TEntity), _ControllerName);
            var rep     = new CRM.Common.RepositoryDomain.Repository <TEntity, Int32>(new Business.Contexts.ConfigurationContext());

            setting.SettingsExport.ExportedRowType = exportRowType;

            // retornamos el excel al usuario
            return(GridViewExtension.ExportToXls(setting, rep.GetAll().ToList(), string.Format("{0}s_{1}.{2}", typeof(TEntity).Name, DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
        }
        public ActionResult ExportXLS(GridViewExportedRowType exportRowType)
        {
            vacontecimientos.Datos = (DataTable)Session["ListadoAcontecimientos"];
            var setting = GridHelper.GetSettingExport(vacontecimientos.GetDynamicCollectionList(vacontecimientos.Datos), _ControllerName);

            setting.SettingsExport.ExportedRowType = exportRowType;
            //setting.SettingsExport.ExportSelectedRowsOnly =
            // retornamos el excel al usuario
            return(GridViewExtension.ExportToXls(setting, vacontecimientos.Datos, string.Format("{0}s_{1}.{2}", "Acontemiento", DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
        }
        public ActionResult ExportXLS(GridViewExportedRowType exportRowType)
        {
            vContactosSinFoto = vContactosSinFoto.GetByUserRol(base.UserContext.RolesCliente.ToList());


            var setting = GridHelper.GetSettingExport(vContactosSinFoto.GetDynamicCollectionList(vContactosSinFoto.Datos), _ControllerName);

            setting.SettingsExport.ExportedRowType = exportRowType;

            // retornamos el excel al usuario
            return(GridViewExtension.ExportToXls(setting, vContactosSinFoto.Datos, string.Format("{0}s_{1}.{2}", typeof(vContactos).Name, DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
        }
Пример #7
0
 static Dictionary <string, GridViewExportMethod> CreateExportFormatsInfo()
 {
     return(new Dictionary <string, GridViewExportMethod> {
         {
             "CustomExportToXLS",
             (settings, data) => GridViewExtension.ExportToXls(settings, data, new XlsExportOptionsEx {
                 ExportType = DevExpress.Export.ExportType.WYSIWYG
             })
         },
         {
             "CustomExportToXLSX",
             (settings, data) => GridViewExtension.ExportToXlsx(settings, data, new XlsxExportOptionsEx {
                 ExportType = DevExpress.Export.ExportType.WYSIWYG
             })
         }
     });
 }
        public ActionResult ExportXLS(GridViewExportedRowType exportRowType)
        {
            if (IsAdmin)
            {
                vProductos = new Business.Views.vProductos();
            }
            else
            {
                vProductos = new Business.Views.vProductos(base.UserContext.RolesCliente.ToList());
            }

            var setting = GridHelper.GetSettingExport(vProductos.GetDynamicCollectionList(vProductos.GetViewModel()), _ControllerName);

            setting.SettingsExport.ExportedRowType = exportRowType;

            // retornamos el excel al usuario
            return(GridViewExtension.ExportToXls(setting, vProductos.GetViewModel(), string.Format("{0}s_{1}.{2}", typeof(vProductos).Name, DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
        }
        public ActionResult ExportTo(string id, string OutputFormat)
        {
            ActionResult obj;
            var          model = Session[id + "_resultado"] as ListadoResultado;

            var settings = Session[id + "Settings"] as GridViewSettings;

            if (settings.Columns["Action"] != null)
            {
                settings.Columns.Remove(settings.Columns["Action"]);
            }

            switch (OutputFormat.ToUpper())
            {
            case "CSV":
                obj = GridViewExtension.ExportToCsv(settings, model.Listado, true);
                break;

            case "PDF":
                obj = GridViewExtension.ExportToPdf(settings, model.Listado, true);
                break;

            case "RTF":
                obj = GridViewExtension.ExportToRtf(settings, model.Listado, true);
                break;

            case "XLS":
                obj = GridViewExtension.ExportToXls(settings, model.Listado, true);
                break;

            case "XLSX":
                obj = GridViewExtension.ExportToXlsx(settings, model.Listado, true);
                break;

            default:
                obj = RedirectToAction("Index", "Home");
                break;
            }

            var result = obj as FileStreamResult;

            result.FileDownloadName = (model.TituloListado ?? "ListadosMarfil") + "." + OutputFormat.ToLower();
            return(result);
        }
Пример #10
0
        public ActionResult ExportTo(string exportid, string OutputFormat)
        {
            ActionResult obj;
            var          model    = Session[session] as TarifasModel;
            var          settings = Session["TarifasSettings"]  as GridViewSettings;

            if (settings.Columns["Action"] != null)
            {
                settings.Columns.Remove(settings.Columns["Action"]);
            }

            switch (OutputFormat.ToUpper())
            {
            case "CSV":
                obj = GridViewExtension.ExportToCsv(settings, model.Lineas, true);
                break;

            case "PDF":
                obj = GridViewExtension.ExportToPdf(settings, model.Lineas, true);
                break;

            case "RTF":
                obj = GridViewExtension.ExportToRtf(settings, model.Lineas, true);
                break;

            case "XLS":
                obj = GridViewExtension.ExportToXls(settings, model.Lineas, true);
                break;

            case "XLSX":
                obj = GridViewExtension.ExportToXlsx(settings, model.Lineas, true);
                break;

            default:
                obj = RedirectToAction("Index");
                break;
            }

            var result = obj as FileStreamResult;

            result.FileDownloadName = (model.Descripcion ?? Tarifas.TituloEntidad) + "." + OutputFormat.ToLower();
            return(result);
        }
        public ActionResult ExportDetailsTo(string OutputFormat)
        {
            ActionResult obj;
            var          model    = Session["_tablasvariaslin_"] as BaseTablasVariasModel;;
            var          settings = Session["TablavariaSettings"] as GridViewSettings;

            if (settings.Columns["Action"] != null)
            {
                settings.Columns.Remove(settings.Columns["Action"]);
            }

            switch (OutputFormat.ToUpper())
            {
            case "CSV":
                obj = GridViewExtension.ExportToCsv(settings, model.Lineas, true);
                break;

            case "PDF":
                obj = GridViewExtension.ExportToPdf(settings, model.Lineas, true);
                break;

            case "RTF":
                obj = GridViewExtension.ExportToRtf(settings, model.Lineas, true);
                break;

            case "XLS":
                obj = GridViewExtension.ExportToXls(settings, model.Lineas, true);
                break;

            case "XLSX":
                obj = GridViewExtension.ExportToXlsx(settings, model.Lineas, true);
                break;

            default:
                obj = RedirectToAction("Index");
                break;
            }

            var result = obj as FileStreamResult;

            result.FileDownloadName = (model.DisplayName ?? "ExportMarfil") + "." + OutputFormat.ToLower();
            return(result);
        }
Пример #12
0
        public ActionResult ExportTo(GridViewExportFormat format)
        {
            var setting = GetGridViewSetting();
            var data    = QuotesProvider.GetQuotes();

            if (format == GridViewExportFormat.Pdf)
            {
                return(GridViewExtension.ExportToPdf(setting, data));
            }

            if (format == GridViewExportFormat.Rtf)
            {
                return(GridViewExtension.ExportToRtf(setting, data));
            }

            if (format == GridViewExportFormat.Xls)
            {
                return(GridViewExtension.ExportToXls(setting, data, new XlsExportOptionsEx {
                    ExportType = DevExpress.Export.ExportType.WYSIWYG
                }));
            }

            if (format == GridViewExportFormat.Xlsx)
            {
                return(GridViewExtension.ExportToXlsx(setting, data, new XlsxExportOptionsEx {
                    ExportType = DevExpress.Export.ExportType.WYSIWYG
                }));
            }

            if (format == GridViewExportFormat.Csv)
            {
                return(GridViewExtension.ExportToCsv(setting, data, new CsvExportOptionsEx {
                    ExportType = DevExpress.Export.ExportType.WYSIWYG
                }));
            }

            return(Content(string.Empty));
        }
Пример #13
0
        private ActionResult ExportToType(string OutputFormat, GridViewSettings exportSettings, dynamic model)
        {
            switch (OutputFormat.ToUpper())
            {
            case "CSV":
                return(GridViewExtension.ExportToCsv(exportSettings, model));

            case "PDF":
                return(GridViewExtension.ExportToPdf(exportSettings, model));

            case "RTF":
                return(GridViewExtension.ExportToRtf(exportSettings, model));

            case "XLS":
                return(GridViewExtension.ExportToXls(exportSettings, model));

            case "XLSX":
                return(GridViewExtension.ExportToXlsx(exportSettings, model));

            default:
                return(RedirectToAction("Index"));
            }
        }
Пример #14
0
        public static ActionResult ExportToXls(string metaViewName, DataTable dt)
        {
            var settings = GridExportHelper.GetGridViewSettings(metaViewName, dt);

            return(GridViewExtension.ExportToXls(settings, dt));
        }
Пример #15
0
        public ActionResult ExportTo(GridViewExportFormat?exportFormat, int stationId, /*DateTime datePck,*/ DateTime dFrom, DateTime dTo /*, string filterString*/)
        {
            string _stationName = (from tt in DB.Stations
                                   where tt.ID == stationId && tt.IS_DELETED == false
                                   select new { tt.NAME }).FirstOrDefault().NAME;

            if (exportFormat == null || !GridViewExportHelper.ExportFormatsInfo.ContainsKey(exportFormat.Value))
            {
                return(RedirectToAction("InvDetailReportPartial", stationId));
            }

            // DateTime dts = Convert.ToDateTime(datePck);
            DateTime date1  = Convert.ToDateTime(dFrom);
            DateTime date2  = Convert.ToDateTime(dTo);
            DateTime date1_ = date1.Date;
            DateTime date2_ = date2.Date;

            date2_ = date2_.AddHours(23);
            date2_ = date2_.AddMinutes(59);
            GridHelper gh = new GridHelper(stationId);



            var _TempInvOzet = (from x in DB.InvSums
                                join inv in DB.Inverters on x.Inv_Id equals inv.ID
                                where
                                x.STATION_ID == stationId
                                &&
                                date1_ <= x.Tarih.Value
                                &&
                                date2_ >= x.Tarih.Value
                                //&&
                                //date2.Month >= x.Tarih.Value.Month
                                //&&
                                //date1.Month <= x.Tarih.Value.Month
                                //&&
                                //date2.Day >= x.Tarih.Value.Day
                                //&&
                                //date1.Day <= x.Tarih.Value.Day
                                select new
            {
                x,
                inv.NAME
            }).OrderBy(X => X.x.Tarih.Value).ToList();

            List <ExportEsso> ListExport = new List <ExportEsso>();

            for (int i = 0; i < _TempInvOzet.Count; i++)
            {
                ExportEsso _cExportEsso = new ExportEsso();

                _cExportEsso.Id          = _TempInvOzet[i].x.Id;
                _cExportEsso.DATE        = _TempInvOzet[i].x.Tarih.Value.ToString("dd/MM/yyyy HH:mm");
                _cExportEsso.INV         = _TempInvOzet[i].NAME;
                _cExportEsso.CRNT_AC     = Convert.ToDecimal(_TempInvOzet[i].x.Akim_AC);
                _cExportEsso.CRNT_DC     = Convert.ToDecimal(_TempInvOzet[i].x.Akim_DC);
                _cExportEsso.V_AC        = Convert.ToDecimal(_TempInvOzet[i].x.Gerilim_AC);
                _cExportEsso.V_DC        = Convert.ToDecimal(_TempInvOzet[i].x.Gerilim_DC);
                _cExportEsso.PWR_AC      = Convert.ToDecimal(_TempInvOzet[i].x.Guc_AC);
                _cExportEsso.PWR_DC      = Convert.ToDecimal(_TempInvOzet[i].x.Guc_DC);
                _cExportEsso.DAILY_YIELD = Convert.ToDecimal(_TempInvOzet[i].x.Gunluk_Enerji);
                _cExportEsso.TOTAL_YIELD = Convert.ToDecimal(_TempInvOzet[i].x.Toplam_Enerji);

                ListExport.Add(_cExportEsso);
            }

            if (exportFormat == GridViewExportFormat.Xls)
            {
                XlsExportOptionsEx exportOptions = new XlsExportOptionsEx();
                exportOptions.CustomizeCell += new DevExpress.Export.CustomizeCellEventHandler(exportOptions_CustomizeCell);

                string filename = _stationName + " (" + date1.ToShortDateString() + " - " + date2.ToShortDateString() + ")";

                return(GridViewExtension.ExportToXls(gh.GridStationSettings, ListExport, filename, exportOptions));
            }
            else
            {
                return(GridViewExportHelper.ExportFormatsInfo[exportFormat.Value](
                           gh.GridStationSettings, ListExport));
            }
        }
Пример #16
0
        // This action method sends a document with the exported Grid to response.
        public ActionResult ExportTo()
        {
            var data = new Acme.Core.EquipmentManagement.WebService.Impl.EquipmentManagement().GetProcedures();

            return(GridViewExtension.ExportToXls(GetGridSettings(), data));
        }
Пример #17
0
 public ActionResult ExportToXls()
 {
     return(GridViewExtension.ExportToXls(CreateExportGridViewSettings(), GetListIndex()));
 }
Пример #18
0
        public ActionResult Index(string dateStockSinTratar, string dateStockTratados, string dateHorasCartera, string exportarStockSinTratar, int?segundosPorPaso,
                                  string exportarStockTratados, string exportarHorasCartera, string filtrarStockSinTratar, string filtrarStockTratados, string filtrarHorasCartera)
        {
            if (dateStockSinTratar == "")
            {
                dateStockSinTratar = DateTime.Now.Date.ToShortDateString();
            }
            if (dateStockTratados == "")
            {
                dateStockTratados = DateTime.Now.Date.ToShortDateString();
            }
            if (dateHorasCartera == "")
            {
                dateHorasCartera = DateTime.Now.Date.ToShortDateString();
            }

            try
            {
                if (exportarStockSinTratar != null)
                {
                    var setting = GridHelper.GetEspecialSettingExport(vStockValorizadosSinTratar.GetDynamicCollectionList(vStockValorizadosSinTratar.Get_Datos(dateStockSinTratar)), _ControllerName);

                    // retornamos el excel al usuario
                    return(GridViewExtension.ExportToXls(setting, vStockValorizadosSinTratar.Get_Datos(dateStockSinTratar), string.Format("{0}s_{1}.{2}",
                                                                                                                                          typeof(vStockValorizadoSinTratar).Name, DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
                }

                if (exportarStockTratados != null)
                {
                    var setting = GridHelper.GetEspecialSettingExport(vStockValorizadoTratados.GetDynamicCollectionList(vStockValorizadoTratados.Get_Datos(dateStockTratados)), _ControllerName);

                    // retornamos el excel al usuario
                    return(GridViewExtension.ExportToXls(setting, vStockValorizadoTratados.Get_Datos(dateStockTratados), string.Format("{0}s_{1}.{2}",
                                                                                                                                       typeof(vStockValorizadoTratados).Name, DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
                }

                if (exportarHorasCartera != null)
                {
                    var setting2 = GridHelper.GetEspecialSettingExport(vHorasEnCartera.GetDynamicCollectionList(vHorasEnCartera.Get_Datos(dateHorasCartera)), _ControllerName);

                    // retornamos el excel al usuario
                    return(GridViewExtension.ExportToXls(setting2, vHorasEnCartera.Get_Datos(dateHorasCartera), string.Format("{0}s_{1}.{2}",
                                                                                                                              typeof(vHorasEnCartera).Name, DateTime.Now.ToString("ddMMyyyy_HHmmss"), "xls")));
                }

                if (segundosPorPaso != null)
                {
                    vPaneldeControlActualizarValor.ActualizarValores(segundosPorPaso.Value);
                    ViewBag.SegundosPorPaso = segundosPorPaso;
                }

                vStockValorizadosSinTratar.Datos      = vStockValorizadosSinTratar.Get_Datos(dateStockSinTratar);
                Session["DateStockSinTratar"]         = dateStockSinTratar;
                Session["vStockValorizadosSinTratar"] = vStockValorizadosSinTratar.Datos;

                vStockValorizadoTratados.Datos      = vStockValorizadoTratados.Get_Datos(dateStockTratados);
                Session["DateStockTratados"]        = dateStockTratados;
                Session["vStockValorizadoTratados"] = vStockValorizadoTratados.Datos;

                vHorasEnCartera.Datos       = vHorasEnCartera.Get_Datos(dateHorasCartera);
                Session["DateHorasCartera"] = dateHorasCartera;
                Session["vHorasEnCartera"]  = vHorasEnCartera.Datos;

                //DATOS PARA EL GRAFICO EQUIVALENTE
                ViewBag.ValuesChartEquivalente_SinTratar = (SortedDictionary <DateTime, double>)Session["ValuesChartEquivalente_SinTratar"];
                ViewBag.ValuesChartEquivalente_Tratados  = (SortedDictionary <DateTime, double>)Session["ValuesChartEquivalente_Tratados"];

                //DATOS PARA EL GRAFICO FISICO
                ViewBag.ValuesChartFisico_SinTratar = (SortedDictionary <DateTime, double>)Session["ValuesChartFisico_SinTratar"];
                ViewBag.ValuesChartFisico_Tratados  = (SortedDictionary <DateTime, double>)Session["ValuesChartFisico_Tratados"];

                //DATOS PARA EL GRAFICO STOCKVAL
                ViewBag.ValuesChartStockVal_SinTratar = (SortedDictionary <DateTime, double>)Session["ValuesChartStockVal_SinTratar"];
                ViewBag.ValuesChartStockVal_Tratados  = (SortedDictionary <DateTime, double>)Session["ValuesChartStockVal_Tratados"];

                //DATOS PARA EL GRAFICO DE HORAS
                ViewBag.ValuesChartHoras_SinTratar = (SortedDictionary <DateTime, double>)Session["ValuesChartHoras_SinTratar"];
                ViewBag.ValuesChartHoras_Cartera   = (SortedDictionary <DateTime, double>)Session["ValuesChartHoras_Cartera"];
            }
            catch (Exception ex)
            {
            }

            var vistas = new Tuple <vStockValorizadoSinTratar, vStockValorizadoTratados, vHorasEnCartera>(vStockValorizadosSinTratar, vStockValorizadoTratados, vHorasEnCartera);

            return(View("Index", vistas));
        }
Пример #19
0
        public ActionResult ExportTo(GridViewExportFormat?exportFormat, int companyId, DateTime d_From, DateTime d_To)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
            string _CompanyName = (from tt in DB.Companies
                                   where tt.ID == companyId && tt.IS_DELETED == false
                                   select new { tt.NAME }).FirstOrDefault().NAME;

            if (exportFormat == null || !GridViewExportHelper.ExportFormatsInfo.ContainsKey(exportFormat.Value))
            {
                return(RedirectToAction("CompanyAlarmListPartial", companyId));
            }

            //DateTime dts = Convert.ToDateTime(datePck);
            string date1 = Convert.ToString(d_From);

            date1 = date1.Substring(0, date1.Length - 9);
            DateTime date_1 = Convert.ToDateTime(date1);

            DateTime date_2;
            DateTime date2 = Convert.ToDateTime(d_To);

            if (date2.Hour == 00)
            {
                date_2 = date2.AddHours(23);
                date_2 = date_2.AddMinutes(59);
            }
            else
            {
                date_2 = date2;
            }

            var _list = (from tt in DB.AlarmStatus
                         join t in DB.Stations on tt.STATION_ID equals t.ID
                         where t.COMPANY_ID == companyId
                         select new { tt.INVERTER_ID, tt.ERROR_NUMBER, tt.START_DATE, tt.STATION_ID, tt.END_DATE, t.NAME }).OrderBy(X => X.START_DATE).ToList();



            var _listInv       = DB.Inverters.ToList();
            var _listAlarmDesc = DB.AlarmDesc.ToList();
            List <AlarmStatusDTO> _ListDataSource = new List <AlarmStatusDTO>();

            for (int i = 0; i < _list.Count; i++)
            {
                AlarmStatusDTO alarmStatus = new AlarmStatusDTO();

                alarmStatus.INVERTER_ID = _list[i].INVERTER_ID;

                TBL_INVERTER _TblInv = _listInv.Where(x => x.ID == _list[i].INVERTER_ID).FirstOrDefault();

                if (_TblInv != null)
                {
                    alarmStatus.INV_NAME = _TblInv.NAME;
                }
                else
                {
                    alarmStatus.INV_NAME = "-";
                }

                alarmStatus.ERROR_NUMBER = _list[i].ERROR_NUMBER;
                //alarmStatus.STATUS = _list[i].STATUS;
                alarmStatus.START_DATE   = _list[i].START_DATE;
                alarmStatus.STATION_NAME = _list[i].NAME;
                alarmStatus.END_DATE     = _list[i].END_DATE;
                alarmStatus.STATION_ID   = _list[i].STATION_ID;

                alarmStatus.ERROR_NUMBER_NAME = _listAlarmDesc.Where(a => a.ERROR_NUMBER == _list[i].ERROR_NUMBER).FirstOrDefault().ERROR_DESC;
                //switch (_list[i].ERROR_NUMBER)
                //{
                //	case "0001":
                //		alarmStatus.ERROR_NUMBER_NAME = "Communication Error";
                //		break;
                //	case "0002":
                //		alarmStatus.ERROR_NUMBER_NAME = "Station Voltage L2 Fault";
                //		break;
                //	case "0003":
                //		alarmStatus.ERROR_NUMBER_NAME = "Station Voltage L1 Fault";
                //		break;
                //	case "0004":
                //		alarmStatus.ERROR_NUMBER_NAME = "Station Voltage L3 Fault";
                //		break;
                //	case "0005":
                //		alarmStatus.ERROR_NUMBER_NAME = "EKK No Connection";
                //		break;
                //	case "0006":
                //		alarmStatus.ERROR_NUMBER_NAME = "No Main Voltage";
                //		break;
                //	case "0007":
                //		alarmStatus.ERROR_NUMBER_NAME = "No Production";
                //		break;
                //	case "0008":
                //		alarmStatus.ERROR_NUMBER_NAME = "AC Voltage Fault";
                //		break;
                //}

                _ListDataSource.Add(alarmStatus);
            }

            List <CompanyAlarmStatusExportDTO> _ListExport = new List <CompanyAlarmStatusExportDTO>();

            var _TempList = _ListDataSource.Where(x => x.START_DATE >= date_1 && x.START_DATE <= date_2) /*.OrderBy(x => x.START_DATE)*/.ToList();


            for (int i = 0; i < _TempList.Count; i++)
            {
                CompanyAlarmStatusExportDTO _ExportDto = new CompanyAlarmStatusExportDTO();

                _ExportDto.ID               = i + 1;
                _ExportDto.DEVICE           = _TempList[i].INV_NAME;
                _ExportDto.ERROR_DEFINITION = _TempList[i].ERROR_NUMBER_NAME;
                _ExportDto.ALERT_START_DATE = _TempList[i].START_DATE.ToString();
                _ExportDto.ALERT_END_DATE   = _TempList[i].END_DATE.ToString();


                _ExportDto.STATION_NAME = _TempList[i].STATION_NAME;



                _ListExport.Add(_ExportDto);
            }

            string     filename = _CompanyName + " (" + date1.ToString() + " - " + date2.ToShortDateString() + ")";
            GridHelper gh       = new GridHelper(companyId);

            if (exportFormat == GridViewExportFormat.Xls)
            {
                XlsExportOptionsEx exportOptions = new XlsExportOptionsEx();
                exportOptions.CustomizeCell += new DevExpress.Export.CustomizeCellEventHandler(exportOptions_CustomizeCell);
                return(GridViewExtension.ExportToXls(gh.GridStationSetting, _ListExport, filename, exportOptions));
            }
            else if (exportFormat == GridViewExportFormat.Pdf)
            {
                return(GridViewExtension.ExportToPdf(gh.GridStationSetting, _ListExport, filename));
            }
            else if (exportFormat == GridViewExportFormat.Xlsx)
            {
                return(GridViewExtension.ExportToXlsx(gh.GridStationSetting, _ListExport, filename));
            }
            return(View(companyId));
        }
Пример #20
0
        public ActionResult ExportTo(GridViewExportFormat?exportFormat, int stationId, DateTime d_From, DateTime d_To)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("tr-TR");
            string _stationName = (from tt in DB.Stations
                                   where tt.ID == stationId && tt.IS_DELETED == false
                                   select new { tt.NAME }).FirstOrDefault().NAME;

            if (exportFormat == null || !GridViewExportHelper.ExportFormatsInfo.ContainsKey(exportFormat.Value))
            {
                return(RedirectToAction("AlarmListPartial", stationId));
            }

            //DateTime dts = Convert.ToDateTime(datePck);
            string date1 = Convert.ToString(d_From);

            date1 = date1.Substring(0, date1.Length - 9);
            DateTime date_1 = Convert.ToDateTime(date1);

            DateTime date_2;
            DateTime date2 = Convert.ToDateTime(d_To);

            if (date2.Hour == 00)
            {
                date_2 = date2.AddHours(23);
                date_2 = date_2.AddMinutes(59);
            }
            else
            {
                date_2 = date2;
            }

            var stationName    = DB.Stations.Where(a => a.ID == stationId).FirstOrDefault().NAME;
            var _listAlarmDesc = DB.AlarmDesc.ToList();
            var _list          = DB.AlarmStatus.Where(x => x.STATION_ID == stationId).OrderBy(x => x.START_DATE).ToList();

            var _listInv = DB.Inverters.ToList();

            List <AlarmStatusDTO> _ListDataSource = new List <AlarmStatusDTO>();

            for (int i = 0; i < _list.Count; i++)
            {
                AlarmStatusDTO alarmStatus = new AlarmStatusDTO();

                alarmStatus.INVERTER_ID = _list[i].INVERTER_ID;

                TBL_INVERTER _TblInv = _listInv.Where(x => x.ID == _list[i].INVERTER_ID).FirstOrDefault();

                if (_TblInv != null)
                {
                    alarmStatus.INV_NAME = _TblInv.NAME;
                }
                else
                {
                    alarmStatus.INV_NAME = stationName;
                }

                alarmStatus.ERROR_NUMBER = _list[i].ERROR_NUMBER;
                //alarmStatus.STATUS = _list[i].STATUS;
                alarmStatus.START_DATE = _list[i].START_DATE;

                alarmStatus.END_DATE   = _list[i].END_DATE;
                alarmStatus.STATION_ID = _list[i].STATION_ID;

                alarmStatus.ERROR_NUMBER_NAME = _listAlarmDesc.Where(a => a.ERROR_NUMBER == _list[i].ERROR_NUMBER).FirstOrDefault().ERROR_DESC;

                _ListDataSource.Add(alarmStatus);
            }

            List <AlarmStatusExportDTO> _ListExport = new List <AlarmStatusExportDTO>();

            var _TempList = _ListDataSource.Where(x => x.START_DATE >= date_1 && x.START_DATE <= date_2) /*.OrderBy(x => x.START_DATE)*/.ToList();


            for (int i = 0; i < _TempList.Count; i++)
            {
                AlarmStatusExportDTO _ExportDto = new AlarmStatusExportDTO();

                _ExportDto.ID               = i + 1;
                _ExportDto.DEVICE           = _TempList[i].INV_NAME;
                _ExportDto.ERROR_DEFINITION = _TempList[i].ERROR_NUMBER_NAME;
                _ExportDto.ALERT_START_DATE = _TempList[i].START_DATE.ToString();
                _ExportDto.ALERT_END_DATE   = _TempList[i].END_DATE.ToString();

                _ListExport.Add(_ExportDto);
            }

            string     filename = _stationName + " (" + date1.ToString() + " - " + date2.ToShortDateString() + ")";
            GridHelper gh       = new GridHelper(stationId);

            if (exportFormat == GridViewExportFormat.Xls)
            {
                XlsExportOptionsEx exportOptions = new XlsExportOptionsEx();
                exportOptions.CustomizeCell += new DevExpress.Export.CustomizeCellEventHandler(exportOptions_CustomizeCell);
                return(GridViewExtension.ExportToXls(gh.GridStationSetting, _ListExport, filename, exportOptions));
            }
            else if (exportFormat == GridViewExportFormat.Pdf)
            {
                return(GridViewExtension.ExportToPdf(gh.GridStationSetting, _ListExport, filename));
            }
            else if (exportFormat == GridViewExportFormat.Xlsx)
            {
                return(GridViewExtension.ExportToXlsx(gh.GridStationSetting, _ListExport, filename));
            }
            return(View(stationId));
        }