Exemple #1
0
///////////////////////////////////////////////////////////////////////////////////////////////////
        private void exportSections(IExportFields fields, string PathToExport, Guid guid, ref int section_num, ref Sections SectionsContainer)
        {
            foreach (IExportField curField in fields)
            {
                if (curField.Items != null & curField.Children == null)
                {
                    exportSections(curField.Items, PathToExport, guid, ref section_num, ref SectionsContainer);
                }

                if (curField.Items == null & curField.Children != null)
                {
                    section_num++;

                    String FileName = guid.ToString() + "_" + section_num.ToString("D3") + "_" + curField.Name;
                    SectionsContainer.Add(FileName, curField.Regions[0].PageIndex);

                    StreamWriter sw = File.CreateText(PathToExport + "\\" + FileName + ".txt");
                    sw.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    sw.WriteLine("<Document xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">");
                    sw.WriteLine("<Section Name=\"" + curField.Name + "\">");
                    exportAllFields(curField.Children, sw);
                    sw.WriteLine("</Section>");
                    sw.WriteLine("</Document>");
                    sw.Close();
                }
            }
        }
 //string indent
 // Getting field collection
 private void getFields(IExportFields fields, IExportDocument docRef, string fieldName)
 {
     foreach (IExportField curField in fields)
     {
         getField(curField, docRef, fieldName);
     }
 }
Exemple #3
0
///////////////////////////////////////////////////////////////////////////////////////////////////
        private void exportAllFields(IExportFields fields, StreamWriter sw)
        {
            CultureInfo cultureUS, cultureRU;

            cultureUS = CultureInfo.CreateSpecificCulture("en-US");
            cultureRU = CultureInfo.CreateSpecificCulture("ru-RU");

            // Use standard numeric format specifiers.
            foreach (IExportField curField in fields)
            {
                // сохраняем имя поля
                if (curField.IsExportable)
                {
                    sw.Write("   <{0}", curField.Name);

                    // сохраняем значение поля, если оно доступно
                    if (IsNullFieldValue(curField))
                    {
                        sw.WriteLine("></{0}>", curField.Name);
                    }
                    else
                    {
                        switch ((TExportFieldType)curField.Type)
                        {
                        case TExportFieldType.EFT_NumberField:
                            if (!DBNull.Value.Equals(curField.Value))
                            {
                                sw.Write(">{0}", ((double)curField.Value).ToString(cultureUS));
                            }
                            else
                            {
                                sw.Write(">");
                            }
                            break;

                        case TExportFieldType.EFT_Checkmark:
                            sw.Write(">{0}", curField.Value.ToString().ToUpper());
                            break;

                        case TExportFieldType.EFT_DateTimeField:
                            sw.Write(">{0}", curField.Text);
                            break;

                        default:
                            sw.Write(">{0}", curField.Text);
                            break;
                        }
                        sw.WriteLine("</{0}>", curField.Name);
                    }
                }
                if (curField.Children != null)
                {
                    // экспорт дочерних полей
                    exportAllFields(curField.Children, sw);
                }
                else if (curField.Items != null)
                {
                    // экспорт экземпляров поля
                    exportAllFields(curField.Items, sw);
                }
            }
        }
 //string indent
 // Exporting field collection
 private void exportFields(IExportFields fields, IExportDocument docRef, StreamWriter sw)
 {
     foreach (IExportField curField in fields)
     {
         //exportField(curField, docRef, indent);
         exportField(curField, docRef, sw);
     }
 }