public void MWQMPlanSubsectorService_FillMWQMPlanSubsector_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMPlanModel labContractModel = labContractServiceTest.AddMWQMPlanModel();
                    Assert.AreEqual("", labContractModel.Error);

                    TVItemModel tvItemModelSubsector = randomService.RandomTVItem(TVTypeEnum.Subsector);
                    Assert.AreEqual("", tvItemModelSubsector.Error);

                    labContractSubsectorModelNew.MWQMPlanID        = labContractModel.MWQMPlanID;
                    labContractSubsectorModelNew.SubsectorTVItemID = tvItemModelSubsector.TVItemID;
                    FillMWQMPlanSubsectorModel(labContractSubsectorModelNew);

                    ContactOK contactOK = labContractSubsectorService.IsContactOK();

                    string retStr = labContractSubsectorService.FillMWQMPlanSubsector(labContractSubsector, labContractSubsectorModelNew, contactOK);
                    Assert.AreEqual("", retStr);
                    Assert.AreEqual(contactOK.ContactTVItemID, labContractSubsector.LastUpdateContactTVItemID);

                    contactOK = null;

                    retStr = labContractSubsectorService.FillMWQMPlanSubsector(labContractSubsector, labContractSubsectorModelNew, contactOK);
                    Assert.AreEqual("", retStr);
                    Assert.AreEqual(contactModelListGood[0].ContactTVItemID, labContractSubsector.LastUpdateContactTVItemID);
                }
            }
        }
        public void MWQMPlanSubsectorService_MWQMPlanSubsectorModelOK_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture);

                using (TransactionScope ts = new TransactionScope())
                {
                    MWQMPlanModel labContractModel = labContractServiceTest.AddMWQMPlanModel();
                    Assert.AreEqual("", labContractModel.Error);

                    TVItemModel tvItemModelRet = randomService.RandomTVItem(TVTypeEnum.Subsector);
                    Assert.AreEqual("", tvItemModelRet.Error);

                    #region Good
                    labContractSubsectorModelNew.MWQMPlanID        = labContractModel.MWQMPlanID;
                    labContractSubsectorModelNew.SubsectorTVItemID = tvItemModelRet.TVItemID;
                    FillMWQMPlanSubsectorModel(labContractSubsectorModelNew);

                    string retStr = labContractSubsectorService.MWQMPlanSubsectorModelOK(labContractSubsectorModelNew);
                    Assert.AreEqual("", retStr);
                    #endregion Good

                    #region MWQMPlanID
                    labContractSubsectorModelNew.MWQMPlanID = tvItemModelRet.TVItemID;
                    FillMWQMPlanSubsectorModel(labContractSubsectorModelNew);
                    labContractSubsectorModelNew.MWQMPlanID = 0;

                    retStr = labContractSubsectorService.MWQMPlanSubsectorModelOK(labContractSubsectorModelNew);
                    Assert.AreEqual(string.Format(ServiceRes._IsRequired, ServiceRes.MWQMPlanID), retStr);

                    labContractSubsectorModelNew.MWQMPlanID = tvItemModelRet.TVItemID;
                    FillMWQMPlanSubsectorModel(labContractSubsectorModelNew);
                    labContractSubsectorModelNew.MWQMPlanID = 1;

                    retStr = labContractSubsectorService.MWQMPlanSubsectorModelOK(labContractSubsectorModelNew);
                    Assert.AreEqual("", retStr);
                    #endregion MWQMPlanID

                    #region SubsectorTVItemID
                    labContractSubsectorModelNew.SubsectorTVItemID = tvItemModelRet.TVItemID;
                    FillMWQMPlanSubsectorModel(labContractSubsectorModelNew);
                    labContractSubsectorModelNew.SubsectorTVItemID = 0;

                    retStr = labContractSubsectorService.MWQMPlanSubsectorModelOK(labContractSubsectorModelNew);
                    Assert.AreEqual(string.Format(ServiceRes._IsRequired, ServiceRes.SubsectorTVItemID), retStr);

                    labContractSubsectorModelNew.SubsectorTVItemID = tvItemModelRet.TVItemID;
                    FillMWQMPlanSubsectorModel(labContractSubsectorModelNew);
                    labContractSubsectorModelNew.SubsectorTVItemID = 1;

                    retStr = labContractSubsectorService.MWQMPlanSubsectorModelOK(labContractSubsectorModelNew);
                    Assert.AreEqual("", retStr);
                    #endregion SubsectorTVItemID
                }
            }
        }
        public void MWQMPlanController__MWQMPlanAddOrModify_Test()
        {
            foreach (CultureInfo culture in setupData.cultureListGood)
            {
                SetupTest(contactModelListGood[0], culture, controllerAction);

                using (TransactionScope ts = new TransactionScope())
                {
                    RetAddMWQMPlan retAddMWQMPlan = AddMWQMPlanAndSubElements((culture.TwoLetterISOLanguageName == "fr" ? LanguageEnum.fr : LanguageEnum.en));

                    PartialViewResult partialViewResult = controller._MWQMPlanAddOrModify(retAddMWQMPlan.TVItemModelNB.TVItemID, retAddMWQMPlan.MWQMPlanModel.MWQMPlanID) as PartialViewResult;
                    Assert.IsNotNull(partialViewResult);

                    MWQMPlanController mwqmPlanController = (MWQMPlanController)partialViewResult.ViewBag.MWQMPlanController;
                    Assert.IsNotNull(mwqmPlanController);

                    int ProvinceTVItemIDRet = (int)partialViewResult.ViewBag.ProvinceTVItemID;
                    Assert.AreEqual(retAddMWQMPlan.TVItemModelNB.TVItemID, ProvinceTVItemIDRet);

                    int MWQMPlanIDRet = (int)partialViewResult.ViewBag.MWQMPlanID;
                    Assert.AreEqual(retAddMWQMPlan.MWQMPlanModel.MWQMPlanID, MWQMPlanIDRet);

                    MWQMPlanModel MWQMPlanModelRet = (MWQMPlanModel)partialViewResult.ViewBag.MWQMPlanModel;
                    Assert.IsNotNull(MWQMPlanModelRet);
                    Assert.AreEqual(retAddMWQMPlan.MWQMPlanModel.MWQMPlanID, MWQMPlanModelRet.MWQMPlanID);

                    List <MWQMPlanSubsectorModel> MWQMPlanSubsectorModelListRet = (List <MWQMPlanSubsectorModel>)partialViewResult.ViewBag.MWQMPlanSubsectorModelList;
                    Assert.IsTrue(MWQMPlanSubsectorModelListRet.Count == 1);

                    List <ContactModel> AdminContactModelListRet = (List <ContactModel>)partialViewResult.ViewBag.AdminContactModelList;
                    Assert.IsNull(AdminContactModelListRet); // because IsMWQMPlanner == true

                    ContactModel ContactModelRet = (ContactModel)partialViewResult.ViewBag.ContactModel;
                    Assert.IsNotNull(ContactModelRet);
                    Assert.AreEqual(contactModelListGood[0].ContactTVItemID, ContactModelRet.ContactTVItemID);

                    List <TVItemModel> TVItemModelSubsectorListRet = (List <TVItemModel>)partialViewResult.ViewBag.TVItemModelSubsectorList;
                    Assert.IsTrue(TVItemModelSubsectorListRet.Count > 0);

                    List <SampleTypeEnumTextOrdered> SampleTypeEnumTextOrderedListRet = (List <SampleTypeEnumTextOrdered>)partialViewResult.ViewBag.SampleTypeEnumTextOrderedList;
                    Assert.IsTrue(SampleTypeEnumTextOrderedListRet.Count > 0);

                    SampleTypeEnumTextOrdered SampleTypeEnumTextOrderedFirstRet = (SampleTypeEnumTextOrdered)partialViewResult.ViewBag.SampleTypeEnumTextOrderedFirst;
                    Assert.IsNotNull(SampleTypeEnumTextOrderedFirstRet);
                    Assert.AreEqual(SampleTypeEnum.Routine, SampleTypeEnumTextOrderedFirstRet.SampleType);

                    bool IsMWQMPlannerRet = (bool)partialViewResult.ViewBag.IsMWQMPlanner;
                    Assert.IsTrue(IsMWQMPlannerRet);
                }
            }
        }
        public MWQMPlanSubsectorModel AddMWQMPlanSubsectorModel()
        {
            MWQMPlanModel labContractModel = labContractServiceTest.AddMWQMPlanModel();

            if (!string.IsNullOrWhiteSpace(labContractModel.Error))
            {
                return new MWQMPlanSubsectorModel()
                       {
                           Error = labContractModel.Error
                       }
            }
            ;

            TVItemModel tvItemModelSubsector = randomService.RandomTVItem(TVTypeEnum.Subsector);

            if (!string.IsNullOrWhiteSpace(tvItemModelSubsector.Error))
            {
                return new MWQMPlanSubsectorModel()
                       {
                           Error = tvItemModelSubsector.Error
                       }
            }
            ;

            labContractSubsectorModelNew.MWQMPlanID        = labContractModel.MWQMPlanID;
            labContractSubsectorModelNew.SubsectorTVItemID = tvItemModelSubsector.TVItemID;
            FillMWQMPlanSubsectorModel(labContractSubsectorModelNew);

            MWQMPlanSubsectorModel labContractModelRet = labContractSubsectorService.PostAddMWQMPlanSubsectorDB(labContractSubsectorModelNew);

            if (!string.IsNullOrWhiteSpace(labContractModelRet.Error))
            {
                return(labContractModelRet);
            }

            CompareMWQMPlanSubsectorModels(labContractSubsectorModelNew, labContractModelRet);

            return(labContractModelRet);
        }
        private RetAddMWQMPlan AddMWQMPlanAndSubElements(LanguageEnum LanguageRequest)
        {
            TVItemModel tvItemModelRoot = tvItemService.GetRootTVItemModelDB();

            Assert.AreEqual("", tvItemModelRoot.Error);

            TVItemModel tvItemModelCanada = tvItemService.GetChildTVItemModelWithParentIDAndTVTextAndTVTypeDB(tvItemModelRoot.TVItemID, "Canada", TVTypeEnum.Country);

            Assert.AreEqual("", tvItemModelCanada.Error);

            TVItemModel tvItemModelNB = tvItemService.GetChildTVItemModelWithParentIDAndTVTextAndTVTypeDB(tvItemModelCanada.TVItemID, (LanguageRequest == LanguageEnum.fr ? "Nouveau-Brunswick" : "New Brunswick"), TVTypeEnum.Province);

            Assert.AreEqual("", tvItemModelNB.Error);

            List <TVItemModel> tvItemModelSSList = tvItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(tvItemModelNB.TVItemID, TVTypeEnum.Subsector);

            Assert.IsTrue(tvItemModelSSList.Where(c => c.TVText.StartsWith("NB-06-020-002")).Any());

            TVItemModel tvItemModelSS = tvItemModelSSList.Where(c => c.TVText.StartsWith("NB-06-020-002")).FirstOrDefault();

            Assert.IsTrue(tvItemModelSS.TVText.StartsWith("NB-06-020-002"));

            MWQMPlanModel mwqmPlanModelNew = new MWQMPlanModel()
            {
                ConfigFileName   = "UniqueConfigFileName",
                ForGroupName     = "UniqueGroupName",
                SampleType       = SampleTypeEnum.Routine,
                ProvinceTVItemID = tvItemModelNB.TVItemID,
                CreatorTVItemID  = contactModelListGood[0].ContactTVItemID,
                Year             = 2015,
                SecretCode       = "abcdef",
                DailyDuplicatePrecisionCriteria     = 0.6872f,
                IntertechDuplicatePrecisionCriteria = 0.093f,
                ConfigFileTxtTVItemID = null,
            };

            MWQMPlanModel mwqmPlanModelRet = mwqmPlanService.PostAddMWQMPlanDB(mwqmPlanModelNew);

            Assert.AreEqual("", mwqmPlanModelRet.Error);

            MWQMPlanSubsectorModel mwqmPlanSubsectorModelNew = new MWQMPlanSubsectorModel()
            {
                MWQMPlanID        = mwqmPlanModelRet.MWQMPlanID,
                SubsectorTVItemID = tvItemModelSS.TVItemID,
            };

            MWQMPlanSubsectorModel mwqmPlanSubsectorModelRet = mwqmPlanSubsectorService.PostAddMWQMPlanSubsectorDB(mwqmPlanSubsectorModelNew);

            Assert.AreEqual("", mwqmPlanSubsectorModelRet.Error);

            TVItemModel tvItemModelMWQMSite = tvItemService.GetChildrenTVItemModelListWithTVItemIDAndTVTypeDB(tvItemModelSS.TVItemID, TVTypeEnum.MWQMSite).FirstOrDefault();

            Assert.AreEqual(7460, tvItemModelMWQMSite.TVItemID);

            MWQMPlanSubsectorSiteModel mwqmPlanSubsectorSiteModel = new MWQMPlanSubsectorSiteModel()
            {
                MWQMPlanSubsectorID = mwqmPlanSubsectorModelRet.MWQMPlanSubsectorID,
                MWQMSiteTVItemID    = tvItemModelMWQMSite.TVItemID,
                IsDuplicate         = false
            };

            MWQMPlanSubsectorSiteModel mwqmPlanSubsectorSiteModelRet = mwqmPlanSubsectorSiteService.PostAddMWQMPlanSubsectorSiteDB(mwqmPlanSubsectorSiteModel);

            Assert.AreEqual("", mwqmPlanSubsectorSiteModelRet.Error);

            RetAddMWQMPlan retAddMWQMPlan = new RetAddMWQMPlan()
            {
                MWQMPlanModel = mwqmPlanModelRet,
                TVItemModelNB = tvItemModelNB,
                TVItemModelSS = tvItemModelSS
            };

            return(retAddMWQMPlan);
        }
Пример #6
0
        private void GenerateWorksheetAContent(WorksheetPart worksheetPart, int SheetOrdinal)
        {
            MergeCells mergeCells = new MergeCells();
            Row        row        = new Row();
            Cell       cell       = new Cell();
            Hyperlinks hyperlinks = new Hyperlinks();
            string     Id         = XlsxBase.sheetNameAndIDList[SheetOrdinal].SheetID;

            XlsxBase.CurrentColumn     = 0;
            XlsxBase.CurrentRow        = 0;
            XlsxBase.CurrentColumnProp = 0;
            Worksheet worksheet = new Worksheet()
            {
                MCAttributes = new MarkupCompatibilityAttributes()
                {
                    Ignorable = "x14ac"
                }
            };

            worksheet.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
            worksheet.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
            worksheet.AddNamespaceDeclaration("x14ac", "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac");

            SheetViews sheetViews = new SheetViews();

            SheetView sheetView = new SheetView()
            {
                TabSelected = true, WorkbookViewId = (UInt32Value)0U
            };
            Selection selection = new Selection()
            {
                ActiveCell = "A1", SequenceOfReferences = new ListValue <StringValue>()
                {
                    InnerText = "A1"
                }
            };

            sheetView.Append(selection);

            sheetViews.Append(sheetView);
            SheetFormatProperties sheetFormatProperties = new SheetFormatProperties()
            {
                DefaultRowHeight = 15D, DyDescent = 0.25D
            };

            Columns        columns         = new Columns();
            List <double?> columnWidthList = new List <double?>()
            {
                20D, 20D, 20D
            };

            foreach (double?width in columnWidthList)
            {
                Column colum = XlsxBase.AddColumnProp(columns, width);
            }

            SheetData sheetData = new SheetData();

            MapInfoService               mapInfoService               = new MapInfoService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            MWQMPlanService              mwqmPlanService              = new MWQMPlanService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            MWQMPlanSubsectorService     mwqmPlanSubsectorService     = new MWQMPlanSubsectorService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            MWQMPlanSubsectorSiteService mwqmPlanSubsectorSiteService = new MWQMPlanSubsectorSiteService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            TVItemService tvItemService = new TVItemService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);

            MWQMPlanModel mwqmPlanModel = mwqmPlanService.GetMWQMPlanModelWithMWQMPlanIDDB(_TaskRunnerBaseService._BWObj.MWQMPlanID);

            XlsxBase.CurrentRowHeight = 18D;
            XlsxBase.CurrentFontSize  = 16;
            XlsxBase.CurrentHorizontalAlignmentValue = HorizontalAlignmentValues.Center;

            if (!string.IsNullOrWhiteSpace(mwqmPlanModel.Error))
            {
                // Config File Name
                row = XlsxBase.AddRow();
                XlsxBase.CurrentFontColor = null;
                cell = XlsxBase.AddCellString(row, XslxServiceMWQMPlanRes.Error + " [" + mwqmPlanModel.Error + "]");
                sheetData.Append(row);
            }
            else
            {
                XlsxBase.CurrentHorizontalAlignmentValue = HorizontalAlignmentValues.Center;

                // Province and Year
                string Province = tvItemService.GetTVItemModelWithTVItemIDDB(mwqmPlanModel.ProvinceTVItemID).TVText;
                row = XlsxBase.AddRow();
                XlsxBase.CurrentFontColor = null;
                cell = XlsxBase.AddCellString(row, Province + "    (" + mwqmPlanModel.Year.ToString() + ")");
                cell = XlsxBase.AddCellString(row, "");
                cell = XlsxBase.AddCellString(row, "");
                sheetData.Append(row);

                MergeCell mergeCell = new MergeCell()
                {
                    Reference = "A" + XlsxBase.CurrentRow.ToString() + ":C" + XlsxBase.CurrentRow.ToString()
                };

                mergeCells.Append(mergeCell);

                // Config File Name
                row = XlsxBase.AddRow();
                XlsxBase.CurrentFontColor = null;
                cell = XlsxBase.AddCellString(row, XslxServiceMWQMPlanRes.FileName + "   (config_" + mwqmPlanModel.ConfigFileName + ".txt)");
                cell = XlsxBase.AddCellString(row, "");
                cell = XlsxBase.AddCellString(row, "");
                sheetData.Append(row);

                mergeCell = new MergeCell()
                {
                    Reference = "A" + XlsxBase.CurrentRow.ToString() + ":C" + XlsxBase.CurrentRow.ToString()
                };

                mergeCells.Append(mergeCell);

                // For Group Name
                row = XlsxBase.AddRow();
                XlsxBase.CurrentFontColor = null;
                cell = XlsxBase.AddCellString(row, XslxServiceMWQMPlanRes.For + "   (" + mwqmPlanModel.ForGroupName + ")");
                cell = XlsxBase.AddCellString(row, "");
                cell = XlsxBase.AddCellString(row, "");
                sheetData.Append(row);

                mergeCell = new MergeCell()
                {
                    Reference = "A" + XlsxBase.CurrentRow.ToString() + ":C" + XlsxBase.CurrentRow.ToString()
                };

                mergeCells.Append(mergeCell);


                row = XlsxBase.AddRow();
                sheetData.Append(row);

                List <MWQMPlanSubsectorModel> mwqmPlanSubsectorModelList = mwqmPlanSubsectorService.GetMWQMPlanSubsectorModelListWithMWQMPlanIDDB(mwqmPlanModel.MWQMPlanID);

                foreach (MWQMPlanSubsectorModel mwqmPlanSubsectorModel in mwqmPlanSubsectorModelList)
                {
                    XlsxBase.CurrentRowHeight = 18D;
                    XlsxBase.CurrentFontSize  = 16;
                    XlsxBase.CurrentHorizontalAlignmentValue = HorizontalAlignmentValues.Center;

                    row = XlsxBase.AddRow();
                    string Subsector = tvItemService.GetTVItemModelWithTVItemIDDB(mwqmPlanSubsectorModel.SubsectorTVItemID).TVText;
                    XlsxBase.CurrentFontColor = null;
                    cell = XlsxBase.AddCellString(row, Subsector);
                    cell = XlsxBase.AddCellString(row, "");
                    cell = XlsxBase.AddCellString(row, "");
                    sheetData.Append(row);

                    mergeCell = new MergeCell()
                    {
                        Reference = "A" + XlsxBase.CurrentRow.ToString() + ":C" + XlsxBase.CurrentRow.ToString()
                    };

                    mergeCells.Append(mergeCell);

                    XlsxBase.CurrentRowHeight                = 16D;
                    XlsxBase.CurrentFontSize                 = 12;
                    XlsxBase.CurrentBorderStyleValue         = BorderStyleValues.Thin;
                    XlsxBase.CurrentBottomBorder             = true;
                    XlsxBase.CurrentBorderColor              = System.Drawing.Color.Green;
                    XlsxBase.CurrentHorizontalAlignmentValue = HorizontalAlignmentValues.Center;

                    List <MWQMPlanSubsectorSiteModel> mwqmPlanSubsectorSiteModelList = mwqmPlanSubsectorSiteService.GetMWQMPlanSubsectorSiteModelListWithMWQMPlanSubsectorIDDB(mwqmPlanSubsectorModel.MWQMPlanSubsectorID);

                    row  = XlsxBase.AddRow();
                    cell = XlsxBase.AddCellString(row, XslxServiceMWQMPlanRes.MWQMSite);
                    cell = XlsxBase.AddCellString(row, XslxServiceMWQMPlanRes.Lat);
                    cell = XlsxBase.AddCellString(row, XslxServiceMWQMPlanRes.Lng);
                    sheetData.Append(row);

                    int count = 0;
                    foreach (MWQMPlanSubsectorSiteModel mwqmPlanSubsectorSiteModel in mwqmPlanSubsectorSiteModelList)
                    {
                        count += 1;
                        row    = XlsxBase.AddRow();

                        if (count % 5 == 0)
                        {
                            XlsxBase.CurrentBorderStyleValue = BorderStyleValues.Thin;
                            XlsxBase.CurrentBottomBorder     = true;
                        }
                        else
                        {
                            XlsxBase.CurrentBorderStyleValue = null;
                            XlsxBase.CurrentBottomBorder     = false;
                        }
                        XlsxBase.CurrentHorizontalAlignmentValue = HorizontalAlignmentValues.Right;
                        cell = XlsxBase.AddCellString(row, mwqmPlanSubsectorSiteModel.MWQMSiteText);

                        List <MapInfoPointModel> mapInfoPointModelList = mapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(mwqmPlanSubsectorSiteModel.MWQMSiteTVItemID, TVTypeEnum.MWQMSite, MapInfoDrawTypeEnum.Point);
                        XlsxBase.CurrentHorizontalAlignmentValue = HorizontalAlignmentValues.Center;
                        if (mapInfoPointModelList.Count > 0)
                        {
                            cell = XlsxBase.AddCellNumber(row, mapInfoPointModelList[0].Lat.ToString("F5"));
                            cell = XlsxBase.AddCellNumber(row, mapInfoPointModelList[0].Lng.ToString("F5"));
                        }
                        else
                        {
                            cell = XlsxBase.AddCellNumber(row, "");
                            cell = XlsxBase.AddCellNumber(row, "");
                        }
                        sheetData.Append(row);
                    }

                    XlsxBase.CurrentBorderStyleValue = null;
                    XlsxBase.CurrentBottomBorder     = false;

                    for (int i = 0; i < 2; i++)
                    {
                        row  = XlsxBase.AddRow();
                        cell = XlsxBase.AddCellString(row, null);
                        sheetData.Append(row);
                    }
                }
            }

            PageMargins pageMargins = new PageMargins()
            {
                Left = 0.7D, Right = 0.7D, Top = 0.75D, Bottom = 0.75D, Header = 0.3D, Footer = 0.3D
            };
            PageSetup pageSetup = new PageSetup()
            {
                Orientation = OrientationValues.Portrait, Id = "rId" + SheetOrdinal.ToString()
            };

            worksheet.Append(sheetViews);
            worksheet.Append(sheetFormatProperties);

            if (columns.ChildElements.Count > 0)
            {
                worksheet.Append(columns);
            }

            worksheet.Append(sheetData);

            mergeCells.Count = (UInt32Value)((UInt32)mergeCells.ChildElements.Count);
            if (mergeCells.ChildElements.Count > 0)
            {
                worksheet.Append(mergeCells);
            }


            if (XlsxBase.UsedHyperlinkList.Count > 0)
            {
                worksheet.Append(hyperlinks);
            }

            worksheet.Append(pageMargins);
            worksheet.Append(pageSetup);

            worksheetPart.Worksheet = worksheet;
        }
Пример #7
0
        public void Generate(FileInfo fi)
        {
            string NotUsed = "";

            TVItemService  tvItemService  = new TVItemService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            MapInfoService mapInfoService = new MapInfoService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);

            if (_TaskRunnerBaseService._BWObj.appTaskModel.Language == "fr")
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo("fr-CA");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-CA");
            }
            else
            {
                Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-CA");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-CA");
            }

            TVFileService tvFileService  = new TVFileService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            string        ServerFilePath = tvFileService.GetServerFilePath(_TaskRunnerBaseService._BWObj.appTaskModel.TVItemID);

            DirectoryInfo di = new DirectoryInfo(ServerFilePath);

            if (!di.Exists)
            {
                di.Create();
            }

            if (fi.Exists)
            {
                fi.Delete();
            }

            MWQMPlanModel mwqmPlanModel = _MWQMPlanService.GetMWQMPlanModelWithMWQMPlanIDDB(_TaskRunnerBaseService._BWObj.MWQMPlanID);

            if (!string.IsNullOrWhiteSpace(mwqmPlanModel.Error))
            {
                NotUsed = string.Format(TaskRunnerServiceRes.CouldNotFind_With_Equal_, "MWQMPlan", "MWQMPlanID", _TaskRunnerBaseService._BWObj.MWQMPlanID.ToString());
                _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat3List("CouldNotFind_With_Equal_", "MWQMPlan", "MWQMPlanID", _TaskRunnerBaseService._BWObj.MWQMPlanID.ToString());
                return;
            }

            StringBuilder sbKMZ = new StringBuilder();

            sbKMZ.AppendLine(@"<?xml version=""1.0"" encoding=""UTF-8""?>");
            sbKMZ.AppendLine(@"<kml xmlns=""http://www.opengis.net/kml/2.2"" xmlns:gx=""http://www.google.com/kml/ext/2.2"" xmlns:kml=""http://www.opengis.net/kml/2.2"" xmlns:atom=""http://www.w3.org/2005/Atom"">");
            sbKMZ.AppendLine(@"<Document>");
            sbKMZ.AppendLine(@"	<name>KmlFile</name>");
            sbKMZ.AppendLine(@"	<StyleMap id=""msn_ylw-pushpin1"">");
            sbKMZ.AppendLine(@"		<Pair>");
            sbKMZ.AppendLine(@"			<key>normal</key>");
            sbKMZ.AppendLine(@"			<styleUrl>#sn_ylw-pushpin1</styleUrl>");
            sbKMZ.AppendLine(@"		</Pair>");
            sbKMZ.AppendLine(@"		<Pair>");
            sbKMZ.AppendLine(@"			<key>highlight</key>");
            sbKMZ.AppendLine(@"			<styleUrl>#sh_ylw-pushpin1</styleUrl>");
            sbKMZ.AppendLine(@"		</Pair>");
            sbKMZ.AppendLine(@"	</StyleMap>");
            sbKMZ.AppendLine(@"	<Style id=""sn_ylw-pushpin"">");
            sbKMZ.AppendLine(@"		<IconStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"			<scale>1.1</scale>");
            sbKMZ.AppendLine(@"			<Icon>");
            sbKMZ.AppendLine(@"				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>");
            sbKMZ.AppendLine(@"			</Icon>");
            sbKMZ.AppendLine(@"			<hotSpot x=""20"" y=""2"" xunits=""pixels"" yunits=""pixels""/>");
            sbKMZ.AppendLine(@"		</IconStyle>");
            sbKMZ.AppendLine(@"		<LabelStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"		</LabelStyle>");
            sbKMZ.AppendLine(@"		<LineStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"		</LineStyle>");
            sbKMZ.AppendLine(@"		<PolyStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"			<fill>0</fill>");
            sbKMZ.AppendLine(@"		</PolyStyle>");
            sbKMZ.AppendLine(@"	</Style>");
            sbKMZ.AppendLine(@"	<Style id=""sn_ylw-pushpin0"">");
            sbKMZ.AppendLine(@"		<IconStyle>");
            sbKMZ.AppendLine(@"			<scale>1.1</scale>");
            sbKMZ.AppendLine(@"			<Icon>");
            sbKMZ.AppendLine(@"				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>");
            sbKMZ.AppendLine(@"			</Icon>");
            sbKMZ.AppendLine(@"			<hotSpot x=""20"" y=""2"" xunits=""pixels"" yunits=""pixels""/>");
            sbKMZ.AppendLine(@"		</IconStyle>");
            sbKMZ.AppendLine(@"		<LineStyle>");
            sbKMZ.AppendLine(@"			<color>ff0000ff</color>");
            sbKMZ.AppendLine(@"		</LineStyle>");
            sbKMZ.AppendLine(@"		<PolyStyle>");
            sbKMZ.AppendLine(@"			<color>ff0000ff</color>");
            sbKMZ.AppendLine(@"			<fill>0</fill>");
            sbKMZ.AppendLine(@"		</PolyStyle>");
            sbKMZ.AppendLine(@"	</Style>");
            sbKMZ.AppendLine(@"	<StyleMap id=""msn_ylw-pushpin10"">");
            sbKMZ.AppendLine(@"		<Pair>");
            sbKMZ.AppendLine(@"			<key>normal</key>");
            sbKMZ.AppendLine(@"			<styleUrl>#sn_ylw-pushpin0</styleUrl>");
            sbKMZ.AppendLine(@"		</Pair>");
            sbKMZ.AppendLine(@"		<Pair>");
            sbKMZ.AppendLine(@"			<key>highlight</key>");
            sbKMZ.AppendLine(@"			<styleUrl>#sh_ylw-pushpin0</styleUrl>");
            sbKMZ.AppendLine(@"		</Pair>");
            sbKMZ.AppendLine(@"	</StyleMap>");
            sbKMZ.AppendLine(@"	<Style id=""sh_ylw-pushpin"">");
            sbKMZ.AppendLine(@"		<IconStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"			<scale>1.3</scale>");
            sbKMZ.AppendLine(@"			<Icon>");
            sbKMZ.AppendLine(@"				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>");
            sbKMZ.AppendLine(@"			</Icon>");
            sbKMZ.AppendLine(@"			<hotSpot x=""20"" y=""2"" xunits=""pixels"" yunits=""pixels""/>");
            sbKMZ.AppendLine(@"		</IconStyle>");
            sbKMZ.AppendLine(@"		<LabelStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"		</LabelStyle>");
            sbKMZ.AppendLine(@"		<LineStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"		</LineStyle>");
            sbKMZ.AppendLine(@"		<PolyStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"			<fill>0</fill>");
            sbKMZ.AppendLine(@"		</PolyStyle>");
            sbKMZ.AppendLine(@"	</Style>");
            sbKMZ.AppendLine(@"	<Style id=""sh_ylw-pushpin0"">");
            sbKMZ.AppendLine(@"		<IconStyle>");
            sbKMZ.AppendLine(@"			<scale>1.3</scale>");
            sbKMZ.AppendLine(@"			<Icon>");
            sbKMZ.AppendLine(@"				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>");
            sbKMZ.AppendLine(@"			</Icon>");
            sbKMZ.AppendLine(@"			<hotSpot x=""20"" y=""2"" xunits=""pixels"" yunits=""pixels""/>");
            sbKMZ.AppendLine(@"		</IconStyle>");
            sbKMZ.AppendLine(@"		<LineStyle>");
            sbKMZ.AppendLine(@"			<color>ff0000ff</color>");
            sbKMZ.AppendLine(@"		</LineStyle>");
            sbKMZ.AppendLine(@"		<PolyStyle>");
            sbKMZ.AppendLine(@"			<color>ff0000ff</color>");
            sbKMZ.AppendLine(@"			<fill>0</fill>");
            sbKMZ.AppendLine(@"		</PolyStyle>");
            sbKMZ.AppendLine(@"	</Style>");
            sbKMZ.AppendLine(@"	<Style id=""sh_ylw-pushpin1"">");
            sbKMZ.AppendLine(@"		<IconStyle>");
            sbKMZ.AppendLine(@"			<scale>1.3</scale>");
            sbKMZ.AppendLine(@"			<Icon>");
            sbKMZ.AppendLine(@"				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>");
            sbKMZ.AppendLine(@"			</Icon>");
            sbKMZ.AppendLine(@"			<hotSpot x=""20"" y=""2"" xunits=""pixels"" yunits=""pixels""/>");
            sbKMZ.AppendLine(@"		</IconStyle>");
            sbKMZ.AppendLine(@"		<LineStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"		</LineStyle>");
            sbKMZ.AppendLine(@"		<PolyStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"			<fill>0</fill>");
            sbKMZ.AppendLine(@"		</PolyStyle>");
            sbKMZ.AppendLine(@"	</Style>");
            sbKMZ.AppendLine(@"	<Style id=""sn_ylw-pushpin1"">");
            sbKMZ.AppendLine(@"		<IconStyle>");
            sbKMZ.AppendLine(@"			<scale>1.1</scale>");
            sbKMZ.AppendLine(@"			<Icon>");
            sbKMZ.AppendLine(@"				<href>http://maps.google.com/mapfiles/kml/pushpin/ylw-pushpin.png</href>");
            sbKMZ.AppendLine(@"			</Icon>");
            sbKMZ.AppendLine(@"			<hotSpot x=""20"" y=""2"" xunits=""pixels"" yunits=""pixels""/>");
            sbKMZ.AppendLine(@"		</IconStyle>");
            sbKMZ.AppendLine(@"		<LineStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"		</LineStyle>");
            sbKMZ.AppendLine(@"		<PolyStyle>");
            sbKMZ.AppendLine(@"			<color>ff00ff00</color>");
            sbKMZ.AppendLine(@"			<fill>0</fill>");
            sbKMZ.AppendLine(@"		</PolyStyle>");
            sbKMZ.AppendLine(@"	</Style>");
            sbKMZ.AppendLine(@"	<StyleMap id=""msn_ylw-pushpin11"">");
            sbKMZ.AppendLine(@"		<Pair>");
            sbKMZ.AppendLine(@"			<key>normal</key>");
            sbKMZ.AppendLine(@"			<styleUrl>#sn_ylw-pushpin</styleUrl>");
            sbKMZ.AppendLine(@"		</Pair>");
            sbKMZ.AppendLine(@"		<Pair>");
            sbKMZ.AppendLine(@"			<key>highlight</key>");
            sbKMZ.AppendLine(@"			<styleUrl>#sh_ylw-pushpin</styleUrl>");
            sbKMZ.AppendLine(@"		</Pair>");
            sbKMZ.AppendLine(@"	</StyleMap>");

            sbKMZ.AppendLine(@"	<Folder>");
            sbKMZ.AppendLine(@"		<name>"+ mwqmPlanModel.ConfigFileName.Replace(".txt", ".kmz") + "</name>");
            sbKMZ.AppendLine(@"		<open>1</open>");

            List <MWQMPlanSubsectorModel> mwqmPlanSubsectorModelList = _MWQMPlanSubsectorService.GetMWQMPlanSubsectorModelListWithMWQMPlanIDDB(_TaskRunnerBaseService._BWObj.MWQMPlanID);

            foreach (MWQMPlanSubsectorModel MWQMPlanSubsectorModel in mwqmPlanSubsectorModelList)
            {
                sbKMZ.AppendLine(@"		<Folder>");
                sbKMZ.AppendLine(@"			<name>"+ MWQMPlanSubsectorModel.SubsectorTVText + "</name>");
                sbKMZ.AppendLine(@"			<open>1</open>");
                sbKMZ.AppendLine(@"			<Placemark>");
                sbKMZ.AppendLine(@"				<name>Poly</name>");
                sbKMZ.AppendLine(@"				<styleUrl>#msn_ylw-pushpin10</styleUrl>");
                sbKMZ.AppendLine(@"				<Polygon>");
                sbKMZ.AppendLine(@"					<tessellate>1</tessellate>");
                sbKMZ.AppendLine(@"					<outerBoundaryIs>");
                sbKMZ.AppendLine(@"						<LinearRing>");
                sbKMZ.AppendLine(@"							<coordinates>");

                List <MapInfoPointModel> mapInfoPointModelList = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(MWQMPlanSubsectorModel.SubsectorTVItemID, TVTypeEnum.Subsector, MapInfoDrawTypeEnum.Polygon);

                foreach (MapInfoPointModel mapInfoPointModel in mapInfoPointModelList)
                {
                    sbKMZ.Append(mapInfoPointModel.Lng + "," + mapInfoPointModel.Lat + ",0 ");
                }
                sbKMZ.AppendLine("");
                sbKMZ.AppendLine(@"							</coordinates>");
                sbKMZ.AppendLine(@"						</LinearRing>");
                sbKMZ.AppendLine(@"					</outerBoundaryIs>");
                sbKMZ.AppendLine(@"				</Polygon>");
                sbKMZ.AppendLine(@"			</Placemark>");

                mapInfoPointModelList = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(MWQMPlanSubsectorModel.SubsectorTVItemID, TVTypeEnum.Subsector, MapInfoDrawTypeEnum.Point);

                if (mapInfoPointModelList.Count > 0)
                {
                    sbKMZ.AppendLine(@"			<Placemark>");
                    sbKMZ.AppendLine(@"				<name>"+ MWQMPlanSubsectorModel.SubsectorTVText + "</name>");
                    sbKMZ.AppendLine(@"				<styleUrl>#msn_ylw-pushpin1</styleUrl>");
                    sbKMZ.AppendLine(@"				<Point>");
                    sbKMZ.AppendLine(@"					<coordinates>"+ mapInfoPointModelList[0].Lng + "," + mapInfoPointModelList[0].Lat + ",0</coordinates>");
                    sbKMZ.AppendLine(@"				</Point>");
                    sbKMZ.AppendLine(@"			</Placemark>");
                }

                List <MWQMPlanSubsectorSiteModel> mwqmPlanSubsectorSiteModelList = _MWQMPlanSubsectorSiteService.GetMWQMPlanSubsectorSiteModelListWithMWQMPlanSubsectorIDDB(MWQMPlanSubsectorModel.MWQMPlanSubsectorID);

                sbKMZ.AppendLine(@"			<Folder>");
                sbKMZ.AppendLine(@"				<name>MWQMSites</name>");
                sbKMZ.AppendLine(@"				<open>1</open>");

                foreach (MWQMPlanSubsectorSiteModel MWQMPlanSubsectorSiteModel in mwqmPlanSubsectorSiteModelList)
                {
                    mapInfoPointModelList = _MapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(MWQMPlanSubsectorSiteModel.MWQMSiteTVItemID, TVTypeEnum.MWQMSite, MapInfoDrawTypeEnum.Point);
                    if (mapInfoPointModelList.Count > 0)
                    {
                        sbKMZ.AppendLine(@"    			<Placemark>");
                        sbKMZ.AppendLine(@"    				<name>"+ MWQMPlanSubsectorSiteModel.MWQMSiteText + "</name>");
                        sbKMZ.AppendLine(@"    				<styleUrl>#msn_ylw-pushpin11</styleUrl>");
                        sbKMZ.AppendLine(@"    				<Point>");
                        sbKMZ.AppendLine(@"    					<coordinates>"+ mapInfoPointModelList[0].Lng + "," + mapInfoPointModelList[0].Lat + ",0</coordinates>");
                        sbKMZ.AppendLine(@"    				</Point>");
                        sbKMZ.AppendLine(@"    			</Placemark>");
                    }
                }
                sbKMZ.AppendLine(@"			</Folder>");
                sbKMZ.AppendLine(@"		</Folder>");
            }
            sbKMZ.AppendLine(@"	</Folder>");
            sbKMZ.AppendLine(@"</Document>");
            sbKMZ.AppendLine(@"</kml>");

            StreamWriter sw = fi.CreateText();

            sw.Write(sbKMZ.ToString());
            sw.Close();

            //string KMLFileName = fi.FullName;
            //string KMZFileName = fi.FullName.Replace(".kml", ".kmz");

            //// make sure directory exist if not create it
            //di = new DirectoryInfo(KMZFileName.Substring(0, KMZFileName.LastIndexOf("\\")));
            //if (!di.Exists)
            //    di.Create();

            //ProcessStartInfo pZip = new ProcessStartInfo();
            //pZip.Arguments = "a -tzip \"" + KMZFileName + "\" \"" + KMLFileName + "\"";
            //pZip.RedirectStandardInput = true;
            //pZip.UseShellExecute = false;
            //pZip.CreateNoWindow = true;
            //pZip.WindowStyle = ProcessWindowStyle.Hidden;

            //Process processZip = new Process();
            //processZip.StartInfo = pZip;
            //try
            //{
            //    pZip.FileName = @"C:\Program Files\7-Zip\7z.exe";
            //    processZip.Start();
            //}
            //catch (Exception ex)
            //{
            //    NotUsed = string.Format(TaskRunnerServiceRes.CompressKMLDidNotWorkWith7zError_, ex.Message);
            //    _TaskRunnerBaseService._BWObj.TextLanguageList = _TaskRunnerBaseService.GetTextLanguageFormat1List("CompressKMLDidNotWorkWith7zError_", ex.Message);
            //    return;
            //}

            //while (!processZip.HasExited)
            //{
            //    // waiting for the processZip to finish then continue
            //}

            //File.Delete(KMLFileName);
        }
        private void GenerateMWQMPlanDocument(Document document)
        {
            Body      body      = new Body();
            Paragraph paragraph = new Paragraph();
            Run       run       = new Run();
            Table     table     = new Table();
            TableRow  tableRow  = new TableRow();
            TableCell tableCell = new TableCell();
            //string URL = "";

            MapInfoService               mapInfoService               = new MapInfoService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            MWQMPlanService              mwqmPlanService              = new MWQMPlanService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            MWQMPlanSubsectorService     mwqmPlanSubsectorService     = new MWQMPlanSubsectorService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            MWQMPlanSubsectorSiteService mwqmPlanSubsectorSiteService = new MWQMPlanSubsectorSiteService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);
            TVItemService tvItemService = new TVItemService(_TaskRunnerBaseService._BWObj.appTaskModel.Language, _TaskRunnerBaseService._User);

            MWQMPlanModel mwqmPlanModel = mwqmPlanService.GetMWQMPlanModelWithMWQMPlanIDDB(_TaskRunnerBaseService._BWObj.MWQMPlanID);

            DocxBase.CurrentFontColor          = System.Drawing.Color.Black;
            DocxBase.CurrentParagraphStyle     = ParagraphStyleEnum.Heading1;
            DocxBase.CurrentJustificationValue = JustificationValues.Center;
            paragraph = DocxBase.AddParagraph(body);

            if (!string.IsNullOrWhiteSpace(mwqmPlanModel.Error))
            {
                paragraph = DocxBase.AddParagraph(body);
                DocxBase.AddRunWithCurrentParagraphStyle(paragraph, mwqmPlanModel.Error);
            }
            else
            {
                // Province and Year
                string Province = tvItemService.GetTVItemModelWithTVItemIDDB(mwqmPlanModel.ProvinceTVItemID).TVText;
                paragraph = DocxBase.AddParagraph(body);
                //DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.Province);
                DocxBase.AddRunWithCurrentParagraphStyle(paragraph, Province + "   (" + mwqmPlanModel.Year.ToString() + ")");

                // Config File Name
                paragraph = DocxBase.AddParagraph(body);
                //DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.ConfigFileName);
                DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.FileName + "   (config_" + mwqmPlanModel.ConfigFileName + ".txt)");

                // For Group Name
                paragraph = DocxBase.AddParagraph(body);
                //DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.ForGroupName);
                DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.For + "   (" + mwqmPlanModel.ForGroupName + ")");

                paragraph = DocxBase.AddParagraph(body);

                List <MWQMPlanSubsectorModel> mwqmPlanSubsectorModelList = mwqmPlanSubsectorService.GetMWQMPlanSubsectorModelListWithMWQMPlanIDDB(mwqmPlanModel.MWQMPlanID);

                foreach (MWQMPlanSubsectorModel mwqmPlanSubsectorModel in mwqmPlanSubsectorModelList)
                {
                    DocxBase.CurrentParagraphStyle = ParagraphStyleEnum.Heading2;
                    paragraph = DocxBase.AddParagraph(body);

                    //paragraph = DocxBase.AddParagraph(body);
                    string Subsector = tvItemService.GetTVItemModelWithTVItemIDDB(mwqmPlanSubsectorModel.SubsectorTVItemID).TVText;
                    DocxBase.AddRunWithCurrentParagraphStyle(paragraph, Subsector);

                    DocxBase.CurrentTableStyle = TableStyleEnum.ListTable7Colorful_Accent5;
                    table    = DocxBase.AddTableStyle(body);
                    tableRow = DocxBase.AddTableRow(table);

                    // Doing MWQM Site
                    tableCell = DocxBase.AddTableCell(tableRow);
                    paragraph = DocxBase.AddTableCellParagraph(tableCell);
                    run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.MWQMSite);

                    // Doing Lat
                    tableCell = DocxBase.AddTableCell(tableRow);
                    paragraph = DocxBase.AddTableCellParagraph(tableCell);
                    run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.Lat);

                    // Doing Lng
                    tableCell = DocxBase.AddTableCell(tableRow);
                    paragraph = DocxBase.AddTableCellParagraph(tableCell);
                    run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, DocxServiceMWQMPlanRes.Lng);

                    List <MWQMPlanSubsectorSiteModel> mwqmPlanSubsectorSiteModelList = mwqmPlanSubsectorSiteService.GetMWQMPlanSubsectorSiteModelListWithMWQMPlanSubsectorIDDB(mwqmPlanSubsectorModel.MWQMPlanSubsectorID);
                    foreach (MWQMPlanSubsectorSiteModel mwqmPlanSubsectorSiteModel in mwqmPlanSubsectorSiteModelList)
                    {
                        tableRow = DocxBase.AddTableRow(table);

                        // Doing MWQM Site
                        tableCell = DocxBase.AddTableCell(tableRow);
                        paragraph = DocxBase.AddTableCellParagraph(tableCell);
                        run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, mwqmPlanSubsectorSiteModel.MWQMSiteText);

                        List <MapInfoPointModel> mapInfoPointModelList = mapInfoService._MapInfoPointService.GetMapInfoPointModelListWithTVItemIDAndTVTypeAndMapInfoDrawTypeDB(mwqmPlanSubsectorSiteModel.MWQMSiteTVItemID, TVTypeEnum.MWQMSite, MapInfoDrawTypeEnum.Point);

                        if (mapInfoPointModelList.Count > 0)
                        {
                            // Doing Lat
                            tableCell = DocxBase.AddTableCell(tableRow);
                            paragraph = DocxBase.AddTableCellParagraph(tableCell);
                            run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, mapInfoPointModelList[0].Lat.ToString("F5"));

                            // Doing Lng
                            tableCell = DocxBase.AddTableCell(tableRow);
                            paragraph = DocxBase.AddTableCellParagraph(tableCell);
                            run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, mapInfoPointModelList[0].Lng.ToString("F5"));
                        }
                        else
                        {
                            // Doing Lat
                            tableCell = DocxBase.AddTableCell(tableRow);
                            paragraph = DocxBase.AddTableCellParagraph(tableCell);
                            run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, "");

                            // Doing Lng
                            tableCell = DocxBase.AddTableCell(tableRow);
                            paragraph = DocxBase.AddTableCellParagraph(tableCell);
                            run       = DocxBase.AddRunWithCurrentParagraphStyle(paragraph, "");
                        }
                    }
                }
            }

            DocxBase.CurrentParagraphStyle     = ParagraphStyleEnum.Normal;
            DocxBase.CurrentJustificationValue = JustificationValues.Left;
            paragraph = DocxBase.AddParagraph(body);

            paragraph = DocxBase.AddParagraph(body);

            DocxBase.AddRunWithCurrentParagraphStyle(paragraph, "Etc ... ");

            DocxBase.AddSectionProp(body);

            document.Append(body);
        }