Beispiel #1
0
        public static Dictionary <String, Object> GetExportOptions(ExportFormatEnum currentFormat)
        {
            Dictionary <String, Object> exportOptions = new Dictionary <String, Object>();

            if (currentFormat == ExportFormatEnum.PDF)
            {
                exportOptions.Add("ContentType", "application/pdf");
                exportOptions.Add("Disposition", "inline; filename=report.pdf");
                exportOptions.Add("ReportBuilder", new PdfReportBuilder());
            }
            if (currentFormat == ExportFormatEnum.XLS)
            {
                exportOptions.Add("ContentType", "application/vnd.ms-excel");
                exportOptions.Add("Disposition", "attachment; filename=report.xls");
                exportOptions.Add("ReportBuilder", new XlsReportBuilder());
            }
            if (currentFormat == ExportFormatEnum.CSV)
            {
                exportOptions.Add("ContentType", "application/octet-stream");
                exportOptions.Add("Disposition", "attachment; filename=report.csv");
                exportOptions.Add("ReportBuilder", new CsvReportBuilder());
            }

            return(exportOptions);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the GSP data file.
        /// </summary>
        /// <param name="moveId">The move identifier.</param>
        /// <param name="exportFormat">The export format.</param>
        /// <param name="cookieValue">The cookie value.</param>
        /// <returns>
        /// GPS data string
        /// </returns>
        public async Task <string> GetGpsDataFile(long moveId, ExportFormatEnum exportFormat, string cookieValue)
        {
            var url = string.Format(ExportUrl, moveId, exportFormat.ToString().ToLower());

            this.logger.LogInformation($"Downloading of GPS data of move {moveId} in {exportFormat.ToString()} format");

            return(await this.ExecuteUrlGetRequest <string>(url, client =>
            {
                client.DefaultRequestHeaders.Add("cookie", cookieValue);
            }));
        }
Beispiel #3
0
        // Obtem o mecanismo de renderização de relatórios ( necessário para gerar o arquivo de
        // relatório que será enviado por e-mail )
        private IReportBuilder GetReportBuilder(int exportFormat)
        {
            IReportBuilder reportBuilder = null;

            ExportFormatEnum            currentFormat = (ExportFormatEnum)exportFormat;
            Dictionary <String, Object> exportOptions = ExportFormatContext.GetExportOptions(currentFormat);

            if (exportOptions.ContainsKey("ReportBuilder"))
            {
                reportBuilder = (IReportBuilder)exportOptions["ReportBuilder"];
            }

            return(reportBuilder);
        }
Beispiel #4
0
        /// <summary>
        /// Gets the and store GPS data.
        /// </summary>
        /// <param name="moveId">The move identifier.</param>
        /// <param name="cookieValue">The cookie value.</param>
        /// <param name="exportFormat">The export format.</param>
        /// <param name="fileName">Name of the file.</param>
        /// <returns>Task result</returns>
        public async Task GetAndStoreGpsData(long moveId, string cookieValue, ExportFormatEnum exportFormat,
                                             string fileName)
        {
            if (string.IsNullOrWhiteSpace(configuration.CookieValue))
            {
                this.logger.LogWarning("Cookie values is not set - could not download GPS data.");
                return;
            }

            this.logger.LogInformation($"Downloading of GPS data in {exportFormat.ToString()} format started.");
            var data = await this.client.GetGpsDataFile(moveId, exportFormat, cookieValue);

            await this.storage.StoreData(fileName, data);

            this.logger.LogInformation($"Downloading of GPS data in {exportFormat.ToString()} format done.");
        }
Beispiel #5
0
        public static Dictionary <String, Object> GetExportOptions(int tenantId, SqlConnection sqlConnection)
        {
            ExportFormatEnum currentFormat = ExportFormatEnum.PDF;

            PreferenceDAO preferenceDAO = new PreferenceDAO(sqlConnection);
            Preference    exportFormat  = preferenceDAO.GetTenantPreference(tenantId, "exportFormat");

            // A conversão abaixo seria propensa a estouros de exceção visto que não esão sendo feitas
            // verificações de tipo, faixa de inteiro, etc. Estas verificações são um pouco redundantes
            // pois os valores gravados no banco tem garantia de corretude
            if (exportFormat != null)
            {
                currentFormat = (ExportFormatEnum)int.Parse(exportFormat.value);
            }

            return(GetExportOptions(currentFormat));
        }
Beispiel #6
0
        private void OnGUI()
        {
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            #region Excel 配置信息
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            GUILayout.BeginHorizontal();
            GUILayout.Label("需要解析的Excel路径:", GUILayout.Width(150));
            mLocalizationConfigExcelPath = GUILayout.TextField(mLocalizationConfigExcelPath, GUILayout.Width(Screen.width - 260));
            if (GUILayout.Button("选择Excel", GUILayout.Width(80)))
            {
                string selectExcelPath = EditorUtility.OpenFilePanel("选择本地化Excel 文件", mLocalizationConfigExcelPath, "*.*");
                if (string.IsNullOrEmpty(selectExcelPath) == false)
                {
                    mLocalizationConfigExcelPath = selectExcelPath;
                    PlayerPrefsManager.SetString(EditorPlayerPrefsKeyDefine.S_LastSelectLocalizationExcelPath, mLocalizationConfigExcelPath);
                    Debug.Log("选择本地化Excel 路径为:" + selectExcelPath);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUIStyle rulerGUIStyle = new GUIStyle();
            rulerGUIStyle.normal.textColor = ColorExpand.HtmToColor("#1B7AD4");
            GUILayout.Label("Excel 中第一行为支持的本地化语言key,对应Language 枚举中的有效字符串", rulerGUIStyle);
            GUILayout.Space(2);
            GUILayout.Label("Excel 中第二行为本地户内容的格式,默认是<color=#FF0000>string </color> 类型", rulerGUIStyle);
            GUILayout.Space(2);
            GUILayout.Label(string.Format("Excel 中第一列的Key 必须以<color=#FF0000> {0}</color> 开头,否则会检测到格式错误", ConstDefine.S_LocalizationKeyFlag), rulerGUIStyle);
            GUILayout.EndVertical();
            #endregion

            #region 导出配置
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            GUILayout.BeginHorizontal();
            GUILayout.Label("Excel中导出指定的语言:", GUILayout.Width(150));
            Language selectedLanguage = (Language)EditorGUILayout.EnumFlagsField(mExportLanguageType, GUILayout.Width(Screen.width - 180));
            if (selectedLanguage != mExportLanguageType)
            {
                Debug.LogEditorInfor("切换导出语言为 " + selectedLanguage);
                mExportLanguageType = selectedLanguage;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Excel中导出指定的格式:", GUILayout.Width(150));
            ExportFormatEnum selectedFromat = (ExportFormatEnum)EditorGUILayout.EnumFlagsField(mExportFormatType, GUILayout.Width(Screen.width - 180));
            if (selectedFromat != mExportFormatType)
            {
                Debug.LogEditorInfor("切换导出格式为 " + selectedFromat);
                mExportFormatType = selectedFromat;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Excel中导出的配置保存目录:", GUILayout.Width(150));
            GUILayout.TextField(mLocalizationConfigExcelExportPath, GUILayout.Width(Screen.width - 180));
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
            #endregion


            #region 功能接口
            GUILayout.Space(5);
            GUILayout.BeginVertical("box");

            #region 检测Excel 文件
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("检测Excel 文件格式", GUILayout.Height(35)))
            {
                LoadLocalizationExcel();
                CheckExcelLocalizationKey();
            }
            if (GUILayout.Button("Excel 导出指定语言的配置文件", GUILayout.Height(35)))
            {
                if (mIsFormatEnable == false)
                {
                    Debug.LogError(string.Format("请确保先进行了格式检测并且没有格式错误!!"));
                    return;
                }

                if (mExportLanguageType == 0)
                {
                    Debug.LogError("没有选择需要导出的语言");
                    return;
                }
                if (mExportFormatType == 0)
                {
                    Debug.LogError("没有选择需要导出的格式");
                    return;
                }

                List <Language> allLanguages = EnumUtility.GetEnumValue <Language>();
                if ((int)mExportLanguageType != -1)
                {
                    for (int dex = allLanguages.Count - 1; dex >= 0; dex--)
                    {
                        if ((allLanguages[dex] & mExportLanguageType) != allLanguages[dex])
                        {
                            allLanguages.RemoveAt(dex);
                        }
                    }
                }

                List <ExportFormatEnum> allexportFormats = EnumUtility.GetEnumValue <ExportFormatEnum>();
                if ((int)mExportFormatType != -1)
                {
                    for (int dex = allexportFormats.Count - 1; dex >= 0; dex--)
                    {
                        if ((allexportFormats[dex] & mExportFormatType) != allexportFormats[dex])
                        {
                            allexportFormats.RemoveAt(dex);
                        }
                    }
                }

                ExportExcel(allLanguages, allexportFormats);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            #endregion

            GUILayout.EndVertical();
            #endregion

            GUILayout.EndVertical();
        }
Beispiel #7
0
 /// <summary>
 /// Creates the name of the GPS file map.
 /// </summary>
 /// <param name="exportFormat">The export format.</param>
 /// <returns>GPS file name</returns>
 public string CreateGpsFileMapName(ExportFormatEnum exportFormat) =>
 $"{GpsDataFile}.{exportFormat.ToString().ToLower()}";
Beispiel #8
0
        public static Dictionary <String, Object> GetExportOptions(HttpSessionState Session)
        {
            ExportFormatEnum currentFormat = ExportFormatContext.GetCurrentFormat(Session);

            return(GetExportOptions(currentFormat));
        }
Beispiel #9
0
        private String GetFormatExtension(int exportFormat)
        {
            ExportFormatEnum currentFormat = (ExportFormatEnum)exportFormat;

            return("." + currentFormat.ToString());
        }