Пример #1
0
        /// <summary>
        /// Ведомость участков пересечения сухостойных участков леса  
        /// </summary>
        /// <param name="resultFile">имя выходного файла</param>
        public static void Create(string resultFile)
        {
            WordDocument doc = null;
            string error = string.Empty;
            try
            {

                List<Egp> egps = presenterEGP.ReadEgpFromDb();
                egps = egps.FindAll(x => x.Code == 1);
                doc = new WordDocument(templateName, false);
                NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

                for (int i = 0; i < egps.Count; i++)
                {
                    char[] splinChar = { '-' };
                    string[] km = egps[i].Name.Split(splinChar);

                    double beginKm = 0;
                    double endKm = 0;

                    try
                    {
                        beginKm = Double.Parse(km[0], nfi);
                        endKm = Double.Parse(km[1], nfi);
                    }
                    catch (Exception)
                    {
                        doc.CloseDocument();
                        doc.Close();
                        throw new Exception("Невозможно прочитать километры в таблице EGP");
                    }
                    string[] row = new string[9];
                    row[0] = i.ToString() + 1; // №
                    row[1] = egps[i].ObjId.ToString(); // идентификационный номер
                    row[2] = beginKm.ToString(kmStringTemplate); // начало участка - экс. км
                    row[3] = egps[i].StartPointWgs().X.ToString(gradStringTemplate); // начало участка - Х
                    row[4] = egps[i].StartPointWgs().Y.ToString(gradStringTemplate); // начало участка - У
                    row[5] = endKm.ToString(kmStringTemplate); // конец участка - экспл. км
                    row[6] = egps[i].EndPointWgs().X.ToString(gradStringTemplate); //  конец участка - Х
                    row[7] = egps[i].EndPointWgs().Y.ToString(gradStringTemplate); // конец участка - У
                    row[8] = (endKm - beginKm).ToString(kmStringTemplate); // протяженность
                    doc.AddDataToTable(1, row);
                }
                doc.Save(resultFile);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (doc != null)
                {
                    doc.CloseDocument();
                    doc.Close();
                }
                if (error != string.Empty)
                    throw new Exception(error);
            }
        }
Пример #2
0
        public void Create()
        {
            WordDocument doc = new WordDocument();
            NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

            string templateTable1 = Path.Combine(Path.GetDirectoryName(this.GetType().Assembly.Location), ".//WordTemplates//Приложение Ж.dotx");
            WordDocument tempDocument = new WordDocument(templateTable1, true);

               // tempDocument.ReplaceIncludePicture(1, new Uri("C:\\" ), 1);
            tempDocument.ReplaceVariables("point_number", "____");
            tempDocument.ReplaceVariables("description_date", "_________");
            tempDocument.ReplaceVariables("time", "_________");
            tempDocument.ReplaceVariables("point_position", "_________");
            tempDocument.ReplaceVariables("process_type", "___________________________________________________________________________________________________________________________________");
            tempDocument.ReplaceVariables("relief_form", "____________________________________________________________________________________________________________________________________");
            tempDocument.ReplaceVariables("morfology", "______________________________________________________________________________________________________________________________________");
            tempDocument.ReplaceVariables("Water", "__________________________________________________________________________________________________________________________________________");
            tempDocument.ReplaceVariables("Grass", "__________________________________________________________________________________________________________________________________________");
        }
Пример #3
0
        /// <summary>
        /// Ведомость выявленных на момент проведения обследования форм рельефа, связанных с развитием ЭГП/ареалов СГУ  
        /// </summary>
        /// <param name="resultFile">имя выходного файла</param>
        public static void Create(string resultFile)
        {
            WordDocument doc = null;
            string error = string.Empty;
            try
            {
                List<Egp> egps = presenterEGP.ReadEgpFromDb();
                egps = egps.FindAll(x => x.Code == 9);
                doc = new WordDocument(templateName, false);

                for (int i = 0; i < egps.Count; i++)
                {

                    string[] row = new string[5];
                    row[0] = i.ToString() + 1; //todo check - Номер участка с проявлением  ЭГП/ареала СГУ
                    row[1] = egps[i].Type;     // Название  ЭГП/ СГУ

                    row[2] = egps[i].ObjId.ToString();  //Идентификационный номер формы рельефа ЭГП/ареала СГУ
                    row[3] = egps[i].StartPointWgs().X.ToString(gradStringTemplate); //todo check Координаты контура формы рельефа*
                    row[4] = egps[i].StartPointWgs().Y.ToString(gradStringTemplate);
                    doc.AddDataToTable(1, row);
                }
                doc.Save(resultFile);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (doc != null)
                {
                    doc.CloseDocument();
                    doc.Close();
                }
                if (error != string.Empty)
                    throw new Exception(error);
            }
        }
Пример #4
0
        /// <summary>
        /// Категории опасности участков с проявлениями экзогенных геологических процессов
        /// </summary>
        /// <param name="resultFile">Имя выходного файла</param>
        public static void Create(string resultFile)
        {
            WordDocument doc = null;
            string error = string.Empty;
            try
            {
                List<Egp> egps = presenterEGP.ReadEgpFromDb();
                doc = new WordDocument(templateName, false);
                NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

                for (int i = 0; i < egps.Count; i++)
                {
                    char[] splinChar = { '-' };
                    string[] km = egps[i].Name.Split(splinChar);

                    double beginKm = 0;
                    double endKm = 0;

                    try
                    {
                        beginKm = Double.Parse(km[0], nfi);
                        endKm = Double.Parse(km[1], nfi);
                    }
                    catch (Exception)
                    {
                        doc.CloseDocument();
                        doc.Close();
                        throw new Exception("Невозможно прочитать километры в таблице EGP");
                    }
                    string[] row = new string[13];
                    row[0] = i.ToString() + 1;
                    row[1] = egps[i].Code.ToString();
                    row[2] = egps[i].Type;
                    row[3] = egps[i].Category.ToString();
                    row[4] = beginKm.ToString();
                    row[5] = egps[i].StartPointWgs().X.ToString();
                    row[6] = egps[i].StartPointWgs().Y.ToString();
                    row[7] = egps[i].Start.Z.ToString();
                    row[8] = endKm.ToString();
                    row[9] = egps[i].EndPointWgs().X.ToString();
                    row[10] = egps[i].EndPointWgs().Y.ToString();
                    row[11] = egps[i].End.Z.ToString();
                    row[12] = (endKm - beginKm).ToString();

                    doc.AddDataToTable(1, row);
                }
                doc.Save(resultFile);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (doc != null)
                {
                    doc.CloseDocument();
                    doc.Close();
                }
                if (error != string.Empty)
                    throw new Exception(error);
            }
        }
Пример #5
0
 public static WordDocument MergeDocuments(WordDocument[] documents)
 {
     WordDocument result = new WordDocument();
     for (int i = 0; i < documents.Length; i++)
     {
         result.AddDocument(documents[i]);
         //documents[i].doc.ActiveWindow.Selection.WholeStory();
         //documents[i].doc.ActiveWindow.Selection.Copy();
         //result.doc.ActiveWindow.Selection.Paste();
     }
     return result;
 }
Пример #6
0
 public void AddDocument(WordDocument document)
 {
     document.doc.ActiveWindow.Selection.WholeStory();
     document.doc.ActiveWindow.Selection.Copy();
     this.doc.ActiveWindow.Selection.Paste();
 }
Пример #7
0
        public static void Create(string resultFile)
        {
            List<Egp> egps = presenterEGP.ReadEgpFromDb();
            string conStr = mapViewer.GisProject.ExtraDataConnectionStr("Снимки");
            //mapViewer
               // presenterEGP.SetSelectEgpMode(true);
               // mapViewer.DrawMap();
            WordDocument doc = new WordDocument();
            NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

            for (int i = 0; i < egps.Count; i++)
            {
                char[] splinChar = { '-' };
                string[] km = egps[i].Name.Split(splinChar);

                double beginKm = 0;
                double endKm = 0;

                try
                {
                    beginKm = Double.Parse(km[0], nfi);
                    endKm = Double.Parse(km[1], nfi);
                }

                catch (Exception)
                {
                    doc.CloseDocument();
                    doc.Close();
                    throw new Exception("Невозможно прочитать километры в таблице EGP");
                }

                WordDocument tempDocument = new WordDocument(templateName, false);

                PictureSet pictureSet = new PictureSet(conStr);
                List<Picture> pictures =  pictureSet.getPicturesAtIntervalOfMarks(((int)beginKm).ToString(), ((int)endKm).ToString());
                DateTime pointTime = DateTime.Parse(egps[i].AppearanceTime);
                String longMin = egps[i].Start.Long.ToString();
                String latMin = egps[i].Start.Lat.ToString();
                String longMax = egps[i].End.Long.ToString();
                String latMax = egps[i].End.Lat.ToString();
                String reliefWidth = egps[i].MaxWidth.ToString();

                String orientir = egps[i].Relief;
                String water = egps[i].Watering;
                String grass = egps[i].VegetationAbnormality;
                if (pictures != null)
                {

                    tempDocument.ReplaceIncludePicture(1, new Uri(pictures[0].Session.Folder + "\\" + pictures[0].Name), 1);
                    tempDocument.ReplaceVariables("DayPhoto", pictures[0].Session.Date.ToString());
                    tempDocument.ReplaceVariables("TimePhoto", pictures[0].Session.Date.TimeOfDay.ToString());
                }
                else
                {
                    tempDocument.ReplaceIncludePicture(1, new Uri("C:\\"), 1);
                    tempDocument.ReplaceVariables("DayPhoto", "________");
                    tempDocument.ReplaceVariables("TimePhoto", "________");
                }
                tempDocument.ReplaceVariables("PointNumber", i.ToString());
                tempDocument.ReplaceVariables("description_date", pointTime.Date.ToString("dd.MM.yyyy"));
                tempDocument.ReplaceVariables("time", pointTime.ToString("hh:mm"));
                tempDocument.ReplaceVariables("KmMin-KmMax", beginKm + "-" + endKm);
                tempDocument.ReplaceVariables("point_position1", longMin + ";" + latMin);
                tempDocument.ReplaceVariables("point_position2", longMax + ";" + latMax);
                tempDocument.ReplaceVariables("PhotoName", pictures[0].Name);
                tempDocument.ReplaceVariables("PhotoISN", i.ToString());
                tempDocument.ReplaceVariables("EGPType", egps[i].Category.ToString());
                tempDocument.ReplaceVariables("MaxWidth", reliefWidth);
                tempDocument.ReplaceVariables("Length", ((int)((endKm - beginKm)) * 1000).ToString());
                tempDocument.ReplaceVariables("Orientir", orientir);
                tempDocument.ReplaceVariables("Water", water);
                tempDocument.ReplaceVariables("Grass", grass);

                doc.AddDocument(tempDocument);
                tempDocument.CloseDocument();
                tempDocument.Close();
                tempDocument.Dispose();
            }
            doc.Save(resultFile);
            doc.Close();
            doc.Dispose();
        }
Пример #8
0
        /// <summary>
        /// Общие данные по количеству участков с экзогенными геологическими процессами
        /// </summary>
        /// <param name="resultFile">имя выходного файла</param>
        public static void Create(string resultFile)
        {
            WordDocument doc = null;
            string error = string.Empty;
            try
            {
                List<Egp> egps = presenterEGP.ReadEgpFromDb();

                egps.Sort(CompareEGP);
                doc = new WordDocument(templateName, false);
                NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

                int cat1, cat2, cat3;
                cat1 = cat2 = cat3 = 0;
                string currentName, previousName;
                currentName = previousName = string.Empty;
                for (int i = 0; i <= egps.Count; i++)
                {
                    if (i != egps.Count)
                        currentName = egps[i].Type;
                    if ((currentName != previousName && i != 0) || i == egps.Count)
                    {
                        string[] row = new string[5];
                        row[0] = previousName; //Геологический процесс
                        row[1] = cat1.ToString();     // 1 категория
                        row[2] = cat2.ToString();     // 2 категория
                        row[3] = cat3.ToString();     // 3 категория
                        row[4] = (cat1 + cat2 + cat3).ToString(); // общее число
                        doc.AddDataToTable(1, row);
                        cat1 = cat2 = cat3 = 0;

                    }

                    if (i != egps.Count)
                    {
                        switch (egps[i].Category)
                        {
                            case 1: cat1++;
                                break;
                            case 2: cat2++;
                                break;
                            default: cat3++;
                                break;
                        }
                        previousName = currentName;
                    }
                }
                doc.Save(resultFile);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (doc != null)
                {
                    doc.CloseDocument();
                    doc.Close();
                }
                if (error != string.Empty)
                    throw new Exception(error);
            }
        }
Пример #9
0
        /// <summary>
        /// Общие данные по протяженности участков с экзогенными геологическими процессами
        /// </summary>
        /// <param name="resultFile">имя выходного файла</param>
        public static void Create(string resultFile)
        {
            WordDocument doc = null;
            string error = string.Empty;
            try
            {
                List<Egp> egps = presenterEGP.ReadEgpFromDb();
                egps.Sort(CompareEGP);
                doc = new WordDocument(templateName, false);
                NumberFormatInfo nfi = new CultureInfo("en-US", false).NumberFormat;

                double cat1, cat2, cat3;
                cat1 = cat2 = cat3 = 0;
                string currentName, previousName;
                currentName = previousName = string.Empty;
                for (int i = 0; i <= egps.Count; i++)
                {
                    if (i != egps.Count)
                        currentName = egps[i].Type;
                    if ((currentName != previousName && i != 0) || i == egps.Count)
                    {
                        string[] row = new string[5];
                        row[0] = previousName;          //Геологический процесс
                        row[1] = cat1.ToString(kmStringTemplate);       // 1 категория - протяженность
                        row[2] = cat2.ToString(kmStringTemplate);       // 2 категория - протяженность
                        row[3] = cat3.ToString(kmStringTemplate);       // 3 категория - протяженность
                        row[4] = (cat1 + cat2 + cat3).ToString(kmStringTemplate); // общее число
                        doc.AddDataToTable(1, row);
                        cat1 = cat2 = cat3 = 0;

                    }

                    if (i != egps.Count)
                    {
                        char[] splitChar = { '-' };
                        string[] km = egps[i].Name.Split(splitChar);

                        double beginKm = 0;
                        double endKm = 0;
                        try
                        {
                            beginKm = Double.Parse(km[0], nfi);
                            endKm = Double.Parse(km[1], nfi);
                        }
                        catch (Exception)
                        {
                            doc.CloseDocument();
                            doc.Close();
                            throw new Exception("Невозможно прочитать километры в таблице EGP");
                        }

                        double delta = endKm - beginKm;
                        switch (egps[i].Category)
                        {
                            case 1: cat1 += delta;
                                break;
                            case 2: cat2 += delta;
                                break;
                            default: cat3 += delta;
                                break;
                        }
                        previousName = currentName;
                    }
                }
                doc.Save(resultFile);
            }
            catch (Exception ex)
            {
                error = ex.Message;
            }
            finally
            {
                if (doc != null)
                {
                    doc.CloseDocument();
                    doc.Close();
                }
                if (error != string.Empty)
                    throw new Exception(error);
            }
        }
Пример #10
0
        static void WriteReport()
        {
            MapObjSet objSet = MifReader.ReadMifMid(@"C:\Users\Тинкс\Documents\Visual Studio 2010\Projects\Работа\geo_reports\Source\ареалы_май_2011_final.mif");
                WordDocument doc = new WordDocument();
                int i = 109;
                StreamWriter writer = new StreamWriter("C:/noPictures.txt");

                List<MapEntity> sorted = new List<MapEntity>();
                foreach (MapEntity me in objSet)
                {
                    sorted.Add(me);
                }
                sorted.Sort(delegate(MapEntity me1, MapEntity me2)
                {
                    string kmMin1 = me1.Semantics["ISN"].ToString();
                    string kmMin2 = me2.Semantics["ISN"].ToString();

                    return (Double.Parse(kmMin1)).CompareTo(Double.Parse(kmMin2));
                });
                foreach (MapEntity me in sorted)
                {

                    /// MapEntity me - объект, содержит географию и семантику
                    DPoint[] p = me.Points; // точки, которые описывают географию
                    DataRow r = me.Semantics; // строка таблицы, содержит всю семантику

                    string pointNumber = r["ISN"].ToString();
                    DateTime pointTime = DateTime.Parse( r["дата_время"].ToString());
                    string kmMin = r["KM_MIN"].ToString();
                    string kmMax = r["KM_MAX"].ToString();
                    string picturePath = r["PhotoISN"].ToString();
                    string longMin = r["Long_MIN"].ToString();
                    string latMin = r["Lat_MIN"].ToString();
                    string longMax = r["Long_MAX"].ToString();
                    string latMax = r["Lat_MAX"].ToString();
                    string PhotoName = r["Фотка"].ToString();

                    string egp = r["ЭГП"].ToString();
                    int egpType = Int32.Parse( r["Тип_ЭГП"].ToString());
                    string reliefWidth = r["макс_ширина"].ToString();
                    if (reliefWidth.Length == 0) reliefWidth = "  ";
                 //   string reliefLength = r["протяженность"].ToString();
                    string orientir = r["напр_измен_границ"].ToString();
                    string water = r["обводнение"].ToString();
                    string grass = r["нарушен_растительности"].ToString();

                    if (!File.Exists((Path.Combine("L:\\Photo_ЭГП", picturePath + ".jpg"))))
                    {
                      //  writer.WriteLine(picturePath + "     " + PhotoName);
                        continue;
                    }
                    if (egpType == 1 ||
                        egpType == 2 ||
                        egpType == 3 ||
                        egpType == 4 ||
                        egpType == 5 ||
                        egpType == 6 ||
                        egpType == 7 ||
                        egpType == 8 ||
                        egpType == 9 ||
                        egpType == 11 ||
                        egpType == 12 ||
                        egpType == 20 ||
                        egpType == 22 ||
                        egpType == 26
                        )
                    {
                        WordDocument tempDocument = new WordDocument(@"C:\Users\Тинкс\Documents\Visual Studio 2010\Projects\Работа\geo_reports\Source\GeoReports\WordTemplates\Приложение Ж.dotx", false);

                        tempDocument.ReplaceVariables("PointNumber", pointNumber);
                        tempDocument.ReplaceVariables("description_date", pointTime.Date.ToString("dd.MM.yyyy"));
                        tempDocument.ReplaceVariables("time", pointTime.ToString("hh:mm"));
                        tempDocument.ReplaceVariables("KmMin-KmMax", kmMin + "-" + kmMax);
                        tempDocument.ReplaceVariables("point_position1", longMin + ";" + latMin);
                        tempDocument.ReplaceVariables("point_position2", longMax + ";" + latMax);
                        tempDocument.ReplaceVariables("PhotoName", PhotoName);
                        tempDocument.ReplaceVariables("PhotoISN", picturePath);
                        tempDocument.ReplaceVariables("EGPType", egp);
                        tempDocument.ReplaceVariables("MaxWidth", reliefWidth);
                        tempDocument.ReplaceVariables("Length", ((int)((Double.Parse(kmMax) - Double.Parse(kmMin))*1000)).ToString());
                        tempDocument.ReplaceVariables("Orientir", orientir);
                        tempDocument.ReplaceVariables("Water", water);
                        tempDocument.ReplaceVariables("Grass", grass);

                        if (Double.Parse(kmMax) < 200)
                        {
                            tempDocument.ReplaceVariables("Sorname", "Макарычева Л.");
                            tempDocument.ReplaceVariables("Proff", "Инженер-исследователь");
                        }
                        else if (Double.Parse(kmMax) < 450)
                        {
                            tempDocument.ReplaceVariables("Sorname", "Разумец М.");
                            tempDocument.ReplaceVariables("Proff", "Инженер-исследователь");
                        }
                        else if (Double.Parse(kmMax) < 960)
                        {
                            tempDocument.ReplaceVariables("Sorname", "Смирнова Л.");
                            tempDocument.ReplaceVariables("Proff", "Инженер-исследователь");
                        }
                        else if (Double.Parse(kmMax) < 1567)
                        {
                            tempDocument.ReplaceVariables("Sorname", "Разумец М.");
                            tempDocument.ReplaceVariables("Proff", "Инженер-исследователь");
                        }
                        else if (Double.Parse(kmMax) < 2300)
                        {
                            tempDocument.ReplaceVariables("Sorname", "Смирнова Л.");
                            tempDocument.ReplaceVariables("Proff", "Инженер-исследователь");
                        }
                        else
                        {
                            tempDocument.ReplaceVariables("Sorname", "Халилова Ю.");
                            tempDocument.ReplaceVariables("Proff", "м.н.с.");
                        }

                        tempDocument.ReplaceIncludePicture(1, new Uri(Path.Combine("L:\\Photo_ЭГП", picturePath + ".jpg")), 1);

                        doc.AddDocument(tempDocument);
                        tempDocument.CloseDocument();
                        tempDocument.Close();
                        tempDocument.Dispose();
                    }
                  }
                doc.Save("C:\\result.doc");
                doc.Close();
                doc.Dispose();
        }