Exemple #1
0
        private void HandleTexts(string org, string app, Dictionary <string, Dictionary <string, TextResourceElement> > modelTexts)
        {
            // <textResourceElement.Id <language, textResourceElement>>
            Dictionary <string, Dictionary <string, TextResourceElement> > existingTexts = _repository.GetServiceTexts(org, app);

            if (existingTexts == null)
            {
                existingTexts = new Dictionary <string, Dictionary <string, TextResourceElement> >();
            }

            foreach (KeyValuePair <string, Dictionary <string, TextResourceElement> > textResourceElementDict in modelTexts)
            {
                string textResourceElementId = textResourceElementDict.Key;

                if (!existingTexts.ContainsKey(textResourceElementId))
                {
                    existingTexts.Add(textResourceElementId, new Dictionary <string, TextResourceElement>());
                }

                foreach (KeyValuePair <string, TextResourceElement> localizedString in textResourceElementDict.Value)
                {
                    string language = localizedString.Key;
                    TextResourceElement textResourceElement = localizedString.Value;
                    if (!existingTexts[textResourceElementId].ContainsKey(language))
                    {
                        existingTexts[textResourceElementId].Add(language, textResourceElement);
                    }
                }
            }

            _repository.SaveServiceTexts(org, app, existingTexts);
        }
Exemple #2
0
        private async Task <DataElement> StorePDF(Stream pdfStream, Instance instance, TextResource textResource)
        {
            string fileName = null;
            string app      = instance.AppId.Split("/")[1];

            TextResourceElement titleText = textResource.Resources.Find(textResourceElement => textResourceElement.Id.Equals("ServiceName"));

            if (titleText != null && !string.IsNullOrEmpty(titleText.Value))
            {
                fileName = titleText.Value + ".pdf";
            }
            else
            {
                fileName = app + ".pdf";
            }

            fileName = GetValidFileName(fileName);

            return(await _dataService.InsertBinaryData(
                       instance.Id,
                       pdfElementType,
                       "application/pdf",
                       fileName,
                       pdfStream));
        }