internal void BuildAttachments(string folderName, IApplicationResponse dataResponse) { var resultObject = ((ApplicationDetailResult)dataResponse).ResultObject; resultObject.Attributes["attachment_"] = null; var path = MetadataProvider.GlobalProperty("faqfspath", true) + folderName; if (!Directory.Exists(path)) { resultObject.SetAttribute("hasattachment", false); return; } var fileEntries = Directory.GetFiles(path); var attachments = new List <Dictionary <string, object> >(); if (fileEntries.Length == 0) { resultObject.SetAttribute("hasattachment", false); return; } var pdfs = fileEntries.Where(f => f.EndsWith("pdf")); var enumerable = pdfs as string[] ?? pdfs.ToArray(); if (!enumerable.Any() || enumerable.Count() > 1) { resultObject.SetAttribute("hasattachment", false); resultObject.SetAttribute("hasinvalidattachment", true); return; } resultObject.SetAttribute("hasattachment", true); }
private void ClearSchemaIfCached(IApplicationResponse applicationResponse, HttpActionExecutedContext actionExecutedContext) { if (applicationResponse == null) { return; } var cachedSchemas = RequestUtil.GetValue(actionExecutedContext.Request, "cachedschemas"); if (cachedSchemas == null) { return; } if (applicationResponse is SchemaChoosingDataResponse) { HandleSchemasToChoose(applicationResponse, cachedSchemas); } else if (applicationResponse.Schema != null && cachedSchemas.Contains(";" + applicationResponse.Schema.GetApplicationKey() + ";")) { //to reduce payload SWWEB-1317 applicationResponse.CachedSchemaId = applicationResponse.Schema.SchemaId; var applicationName = applicationResponse.ApplicationName; applicationResponse.Schema = new ApplicationSchemaDefinition { //to play safe since it might be a delegation method to the schema ApplicationName = applicationName, SchemaId = applicationResponse.Schema.SchemaId, Mode = applicationResponse.Schema.Mode }; } }
private static void HandleSchemasToChoose(IApplicationResponse applicationResponse, string cachedSchemas) { var schemaChoosingResponse = (SchemaChoosingDataResponse)applicationResponse; var resultList = new List <ApplicationSchemaDefinition>(); foreach (var schemaToChoose in schemaChoosingResponse.Schemas) { if (!cachedSchemas.Contains(";" + schemaToChoose.GetApplicationKey() + ";")) { resultList.Add(schemaToChoose); } else { var applicationName = applicationResponse.ApplicationName; resultList.Add(new ApplicationSchemaDefinition { //to play safe since it might be a delegation method to the schema ApplicationName = applicationName, SchemaId = schemaToChoose.SchemaId, Mode = schemaToChoose.Mode, Cached = true }); } } //reducing payload schemaChoosingResponse.Schemas = resultList; }
private String BuildQueryString(IApplicationResponse response, string id, string application, ClientPlatform platform, ApplicationMetadata applicationMetadata, string popupmode) { var title = _i18NResolver.I18NSchemaTitle(applicationMetadata.Schema); var sb = new StringBuilder(); ApplicationSchemaDefinition schema; if (response is ApplicationDetailResult) { schema = response.Schema; WebAPIUtil.AppendToQueryString(sb, "id", ((ApplicationDetailResult)response).Id); } else { if (!String.IsNullOrWhiteSpace(id)) { WebAPIUtil.AppendToQueryString(sb, "id", id); } schema = applicationMetadata.Schema; } WebAPIUtil.AppendToQueryString(sb, "popupmode", popupmode); WebAPIUtil.AppendToQueryString(sb, "key.schemaId", schema.SchemaId); WebAPIUtil.AppendToQueryString(sb, "key.platform", schema.Platform); WebAPIUtil.AppendToQueryString(sb, "key.mode", schema.Mode); WebAPIUtil.AppendToQueryString(sb, "title", title); return(sb.ToString()); }
private object BuildParameter(string entityid, string application, ClientPlatform platform, IApplicationResponse response, string popupmode, ApplicationMetadata applicationMetadata) { object parameters; if (response is ActionRedirectResponse) { var actionResponse = (ActionRedirectResponse)response; var queryString = actionResponse.Parameters == null ? null : String.Join("&", actionResponse.Parameters.ToArray()); parameters = new { actionToRedirect = actionResponse.Action, controllerToRedirect = actionResponse.Controller, queryString = queryString, popupmode = popupmode ?? "none", message = response.SuccessMessage }; } else { parameters = new { application = application, popupmode = popupmode ?? "none", queryString = BuildQueryString(response, entityid, application, platform, applicationMetadata, popupmode), message = response.SuccessMessage }; } return(parameters); }
public ApplicationModel(string application, string schema, string mode, string title, IApplicationResponse responseData) : base(title, "/Content/Controller/Application.html", responseData) { var internalData = new ApplicationInternalData(application, schema, mode); InitialMetadataJSON = JsonConvert.SerializeObject(internalData, Newtonsoft.Json.Formatting.None, new JsonSerializerSettings() { ContractResolver = new CamelCasePropertyNamesContractResolver() }); }