예제 #1
0
        public FilestoreFile Create(SampleEventMap map, EntityBundle sites, EntityBundle instruments)
        {
            if (this.CanModify(map))
            {
                Guid            id  = Guid.NewGuid();
                WaterQualityDET det = new WaterQualityDET();
                det.Id    = id;
                det.Owner = "originator:" + sites.PrincipalOrgId.Identity.ToString() + ":" + instruments.PrincipalOrgId.Identity.ToString();

                int ct = 0;
                foreach (BundleElement cur in sites.Elements)
                {
                    SiteDTO tmp = new SiteDTO();
                    tmp.Key  = cur.LocalKey;
                    tmp.Name = cur.DisplayName;
                    det.Sites.Add(tmp);
                    ct++;
                }
                if (ct > 0) //has to be elements in the collection
                {
                    ct = 0;

                    foreach (BundleElement cur in instruments.Elements)
                    {
                        InstrumentDTO tmp = new InstrumentDTO();
                        tmp.Key  = cur.LocalKey;
                        tmp.Name = cur.DisplayName;
                        det.Instruments.Add(tmp);
                        ct++;
                    }

                    if (ct > 0)
                    {
                        det.Validate();
                        if (det.ValidationIssues.Count == 0)
                        {
                            IFileStoreProvider prov = this.FileStore;

                            if (prov != null)
                            {
                                FilestoreFile fil = prov.Make(id);
                                if (fil != null)
                                {
                                    ExcelWaterQualityDET excel = new ExcelWaterQualityDET(det);
                                    excel.Save(fil);
                                    fil.Flush();
                                    fil.Seek(0, System.IO.SeekOrigin.Begin);
                                    return(fil);
                                }
                            }
                        }
                    }
                }
            }

            return(null);
        }
예제 #2
0
        public static void WriteFile(string fName)
        {
            WaterQualityDET det = new WaterQualityDET();

            det.Id    = Guid.NewGuid();
            det.Owner = "Dr. Frank N. Furter, ESQ";
            ExcelWaterQualityDET excel = new ExcelWaterQualityDET(det);

            CreateListOfPhonyDeployments(det, 4);
            CreateListOfPhonyMeasurements(det, 6);
            CreateListOfPhonySites(det, 4);
            CreateListOfPhonySensors(det, 6);
            excel.Save(fName);
        }