Ejemplo n.º 1
0
        /// ------------------------------------------------------------------------------------
        public Session(string parentElementFolder, string id,
                       Action <ProjectElement, string, string> idChangedNotificationReceiver,
                       SessionFileType sessionFileType,
                       Func <ProjectElement, string, ComponentFile> componentFileFactory,
                       XmlFileSerializer xmlFileSerializer,
                       ProjectElementComponentFile.Factory prjElementComponentFileFactory,
                       IEnumerable <ComponentRole> componentRoles,
                       PersonInformant personInformant, Project project)
            : base(parentElementFolder, id, idChangedNotificationReceiver, sessionFileType,
                   componentFileFactory, xmlFileSerializer, prjElementComponentFileFactory, componentRoles)
        {
            _personInformant = personInformant;

            // ReSharper disable DoNotCallOverridableMethodsInConstructor

            // Using a 1-minute fudge factor is a bit of a kludge, but when a session is created from an
            // existing media file, it already has an ID, and there's no other way to tell it's "new".
            if (project != null &&
                (id == null || MetaDataFile.GetCreateDate().AddMinutes(1) > DateTime.Now) &&
                MetaDataFile.GetStringValue(SessionFileType.kCountryFieldName, null) == null &&
                MetaDataFile.GetStringValue(SessionFileType.kRegionFieldName, null) == null &&
                MetaDataFile.GetStringValue(SessionFileType.kContinentFieldName, null) == null &&
                MetaDataFile.GetStringValue(SessionFileType.kAddressFieldName, null) == null)
            {
                // SP-876: Project Data not displayed in new sessions until after a restart.
                Program.SaveProjectMetadata();

                if (!string.IsNullOrEmpty(project.Country))
                {
                    MetaDataFile.TrySetStringValue(SessionFileType.kCountryFieldName, project.Country);
                }
                if (!string.IsNullOrEmpty(project.Region))
                {
                    MetaDataFile.TrySetStringValue(SessionFileType.kRegionFieldName, project.Region);
                }
                if (!string.IsNullOrEmpty(project.Continent))
                {
                    MetaDataFile.TrySetStringValue(SessionFileType.kContinentFieldName, project.Continent);
                }
                if (!string.IsNullOrEmpty(project.Location))
                {
                    MetaDataFile.TrySetStringValue(SessionFileType.kAddressFieldName, project.Location);
                }
            }

            if (string.IsNullOrEmpty(MetaDataFile.GetStringValue(SessionFileType.kGenreFieldName, null)))
            {
                if (MetaDataFile.TrySetStringValue(SessionFileType.kGenreFieldName, GenreDefinition.UnknownType.Name))
                {
                    MetaDataFile.Save();
                }
            }
// ReSharper restore DoNotCallOverridableMethodsInConstructor
            if (_personInformant != null)
            {
                _personInformant.PersonNameChanged += HandlePersonsNameChanged;
                _personInformant.PersonUiIdChanged += HandlePersonsUiIdChanged;
            }
        }
Ejemplo n.º 2
0
        /// ------------------------------------------------------------------------------------
        private bool GetShouldReportHaveConsent()
        {
            var  allParticipants            = MetaDataFile.GetStringValue(SessionFileType.kParticipantsFieldName, string.Empty);
            var  personNames                = FieldInstance.GetMultipleValuesFromText(allParticipants).ToArray();
            bool allParticipantsHaveConsent = personNames.Length > 0;

            return(personNames.All(name => _personInformant.GetHasInformedConsent(name)) &&
                   allParticipantsHaveConsent);
        }
Ejemplo n.º 3
0
        /// ------------------------------------------------------------------------------------
        public virtual IEnumerable <string> GetAllParticipants()
        {
            var contributions = MetaDataFile.GetValue(SessionFileType.kContributionsFieldName, null) as ContributionCollection;

            if (contributions == null)
            {
                return(new string[0]);                // don't just use ? to return null, that isn't enumerable, callers will fail.
            }
            return(contributions.Select(c => c.ContributorName));
        }
Ejemplo n.º 4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// We get this message from the person informant when a person's name has changed.
        /// When that happens, we need to make sure we update the participant field in case
        /// it contains a name that changed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        private void HandlePersonsNameChanged(object sender, ElementIdChangedArgs e)
        {
            var allParticipants = GetAllParticipants();
            var newNames        = allParticipants.Select(name => (name == e.OldId ? e.NewId : name));

            MetaDataFile.SetStringValue(SessionFileType.kParticipantsFieldName,
                                        FieldInstance.GetTextFromMultipleValues(newNames));

            MetaDataFile.Save();

            ProcessContributorNameChange(e);
        }
Ejemplo n.º 5
0
        /// ------------------------------------------------------------------------------------
        private bool GetShouldReportHaveConsent()
        {
            var contributions = MetaDataFile.GetValue(SessionFileType.kContributionsFieldName, null) as ContributionCollection;
            var personNames   = contributions?.Select(c => c.ContributorName).ToArray();

            if (personNames == null)
            {
                return(false);
            }
            bool allContributorsHaveConsent = personNames.Length > 0;

            return(personNames.All(name => _personInformant.GetHasInformedConsent(name)) &&
                   allContributorsHaveConsent);
        }
Ejemplo n.º 6
0
        /// ------------------------------------------------------------------------------------
        public void SetAdditionalMetsData(RampArchivingDlgViewModel model)
        {
            model.SetScholarlyWorkType(ScholarlyWorkType.PrimaryData);
            model.SetDomains(SilDomain.Ling_LanguageDocumentation);

            var value = MetaDataFile.GetStringValue(SessionFileType.kDateFieldName, null);

            if (!string.IsNullOrEmpty(value))
            {
                model.SetCreationDate(value);
            }

            // Return the session's note as the abstract portion of the package's description.
            value = MetaDataFile.GetStringValue(SessionFileType.kSynopsisFieldName, null);
            if (!string.IsNullOrEmpty(value))
            {
                model.SetAbstract(value, string.Empty);
            }

            // Set contributors
            var contributions = MetaDataFile.GetValue(SessionFileType.kContributionsFieldName, null) as ContributionCollection;

            if (contributions != null && contributions.Count > 0)
            {
                model.SetContributors(contributions);
            }

            // Return total duration of source audio/video recordings.
            TimeSpan totalDuration = GetTotalDurationOfSourceMedia();

            if (totalDuration.Ticks > 0)
            {
                model.SetAudioVideoExtent(string.Format("Total Length of Source Recordings: {0}", totalDuration.ToString()));
            }

            //model.SetSoftwareRequirements("SayMore");
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 加载配置文件
 /// </summary>
 /// <param name="strStandardName">土地利用规划数据库标准名称</param>
 /// <returns></returns>
 public bool LoadConfigFile(EnumDBStandard pEnumDBStandard)
 {
     return MetaDataFile.Initial(pEnumDBStandard);
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 获取要素代码节点
        /// </summary>
        /// <returns></returns>
        public virtual FeatureCodeNode GetFeatureCodeNode()
        {
            try
            {
                FeatureCodeNode pFeatureCodeNode = new FeatureCodeNode();
                ///如果是空间数据
                if (m_pITable is IFeatureClass)
                {
                    ///要素名称
                    pFeatureCodeNode.FeatureName = (m_pITable as IObjectClass).AliasName;

                    //要素代码
                    string sAttriTableName = (m_pITable as IDataset).Name;
                    pFeatureCodeNode.FeatureCode = MetaDataFile.GetFeatureCodeByName(sAttriTableName);

                    ///获取要素类型
                    if ((m_pITable as IFeatureClass).FeatureType != esriFeatureType.esriFTAnnotation)
                    {
                        switch ((m_pITable as IFeatureClass).ShapeType)
                        {
                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryLine:
                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolyline:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Line");
                            break;

                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryMultipoint:
                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Point");
                            break;

                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPolygon:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Polygon");
                            break;

                        case ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryNull:
                            pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("NoneGeometry");
                            break;

                        default:
                            break;
                        }
                    }
                    else
                    {
                        pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("Annotation");
                    }
                    ///数据表名称
                    pFeatureCodeNode.TableName = sAttriTableName;

                    ///获取标识码字段
                    string sKeyFieldName = "";
                    sKeyFieldName = Metadata.MetaDataFile.GetEntityIDFieldName(sAttriTableName);
                    if (sKeyFieldName != "")
                    {
                        m_strEntityFieldName = sKeyFieldName;
                    }

                    ////获取要素代码字段
                    sKeyFieldName = Metadata.MetaDataFile.GetYSDMFieldName(sAttriTableName);
                    if (sKeyFieldName != "")
                    {
                        m_strSYDMFieldName = sKeyFieldName;
                    }
                }
                ///如果是属性数据
                else if (m_pITable != null)
                {
                    pFeatureCodeNode.FeatureName = (m_pITable as IObjectClass).AliasName;
                    string sAttriTableName = (m_pITable as IDataset).Name;
                    pFeatureCodeNode.FeatureCode = MetaDataFile.GetFeatureCodeByName(sAttriTableName);
                    ///数据表名称
                    pFeatureCodeNode.TableName    = sAttriTableName;
                    pFeatureCodeNode.GeometryType = Metadata.MetaDataFile.GraphConfig.GetGraphTypeMark("NoneGeometry");
                }

                return(pFeatureCodeNode);
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return(null);
            }
        }
Ejemplo n.º 9
0
        public void ConfigureAsDecoder()
        {
            using (new WaitCursor())
            {
                var allMetaFiles = _pf.FindAllWithExtention(".meta");
                //allMetaFiles = allMetaFiles.Where(f => f.Name.Contains("anm.meta")).ToList();
                List <MetaDataFile> allMetaData = new List <MetaDataFile>();


                MetaDataFile master = new MetaDataFile()
                {
                    FileName = "Master collection"
                };

                var errorList = new List <Tuple <string, string> >();

                foreach (var file in allMetaFiles)
                {
                    try
                    {
                        var res = MetaDataFileParser.ParseFile(file, _pf);
                        allMetaData.Add(res);

                        foreach (var resultDataItem in res.TagItems)
                        {
                            var masterDataItem = master.TagItems.FirstOrDefault(x => x.Name == resultDataItem.Name && x.Version == resultDataItem.Version);
                            if (masterDataItem == null)
                            {
                                master.TagItems.Add(new MetaDataTagItem()
                                {
                                    Name = resultDataItem.Name, Version = resultDataItem.Version
                                });
                                masterDataItem = master.TagItems.Last();
                            }

                            foreach (var tag in resultDataItem.DataItems)
                            {
                                masterDataItem.DataItems.Add(tag);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        errorList.Add(new Tuple <string, string>(_pf.GetFullPath(file), e.Message));
                    }
                }

                var outputFolder = @"C:\temp\MetaDataDecoded\";

                foreach (var propSetType in master.TagItems)
                {
                    var           filename      = $"{propSetType.DisplayName}_{propSetType.DataItems.Count}.csv";
                    StringBuilder stringBuilder = new StringBuilder();

                    var tableDef = _schemaManager.GetMetaDataDefinition(propSetType.Name, propSetType.Version);
                    if (tableDef != null)
                    {
                        var headers = new List <string>()
                        {
                            "FileName", "Error"
                        };

                        for (int outputRowIndex = 0; outputRowIndex < tableDef.ColumnDefinitions.Count; outputRowIndex++)
                        {
                            headers.Add(tableDef.ColumnDefinitions[outputRowIndex].Name + " - " + tableDef.ColumnDefinitions[outputRowIndex].Type.ToString());
                        }
                        WriteRow(stringBuilder, headers);

                        for (int i = 0; i < propSetType.DataItems.Count(); i++)
                        {
                            var outputRow = new List <string>();
                            for (int outputRowIndex = 0; outputRowIndex < tableDef.ColumnDefinitions.Count + 2; outputRowIndex++)
                            {
                                outputRow.Add("");
                            }

                            var dataRow = new DataTableRow(propSetType.DisplayName, i, tableDef.ColumnDefinitions, propSetType.DataItems[i]);
                            outputRow[0] = propSetType.DataItems[i].ParentFileName;
                            outputRow[1] = dataRow.GetError();
                            if (string.IsNullOrEmpty(outputRow[1]))
                            {
                                for (int valueIndex = 0; valueIndex < dataRow.Values.Count; valueIndex++)
                                {
                                    outputRow[valueIndex + 2] = dataRow.Values[valueIndex].Value;
                                }
                            }
                            WriteRow(stringBuilder, outputRow);
                        }
                    }
                    else
                    {
                        var headers = new List <string>()
                        {
                            "FileName", "Size"
                        };
                        WriteRow(stringBuilder, headers);
                        for (int i = 0; i < propSetType.DataItems.Count(); i++)
                        {
                            var outputRow = new List <string>()
                            {
                                propSetType.DataItems[i].ParentFileName, propSetType.DataItems[i].Size.ToString()
                            };
                            WriteRow(stringBuilder, outputRow);
                        }
                    }

                    DirectoryHelper.EnsureCreated(outputFolder);
                    File.WriteAllText(outputFolder + filename, stringBuilder.ToString());
                }


                master.TagItems             = master.TagItems.OrderBy(x => x.DisplayName).ToList();
                ActiveMentaDataContent.File = master;
            }
        }
Ejemplo n.º 10
0
 /// ------------------------------------------------------------------------------------
 public virtual void Load()
 {
     MetaDataFile.Load();
 }
Ejemplo n.º 11
0
 /// ------------------------------------------------------------------------------------
 public void Save()
 {
     MetaDataFile.Save(SettingsFilePath);
 }
Ejemplo n.º 12
0
        /// <summary>
        /// 保存面图层对应的线图层中的实体到临时数据文件
        /// </summary>
        private void SaveLineNodesToTemp(LineNodeTable pLineNodeTable, string strPolygonTableName)
        {
            //暂时不考虑面与面之间的关联
            MetaTable     metaTable      = MetaDataFile.GetMetaTalbleByName(strPolygonTableName);
            List <string> arrFeatureCode = null;

            if (metaTable != null)
            {
                arrFeatureCode = metaTable.LinkFeatureCode;
            }
            if (arrFeatureCode != null && arrFeatureCode.Count > 0)
            {
                ESRIData.FeatureLayer featureLayer;
                int m = 1;
                for (int i = 0; i < m_nLayerCount; i++)
                {
                    //获取图层对象
                    featureLayer = m_dataset.GetFeatureLayerByIndex(i) as ESRIData.FeatureLayer;
                    ESRIData.LineLayer lineLayer = featureLayer as ESRIData.LineLayer;
                    if (lineLayer != null)
                    {
                        if (arrFeatureCode.Contains(lineLayer.FeatureCode) == true)
                        {
                            List <ESRIData.FeatureEntity> arrFeatureEntity = lineLayer.FeatureEntys;
                            if (arrFeatureEntity == null)
                            {
                                return;
                            }
                            for (int j = 0; j < arrFeatureEntity.Count; j++)
                            {
                                FileData.LineNode lineNode = arrFeatureEntity[j].GetEntityNode() as FileData.LineNode;
                                if (lineNode != null)
                                {
                                    //拆分线:多点一线拆为两点一线
                                    for (int k = 0; k < lineNode.SegmentNodes.Count; k++)
                                    {
                                        FileData.BrokenLineNode brokenLineNode = lineNode.SegmentNodes[k] as FileData.BrokenLineNode;
                                        if (brokenLineNode != null)
                                        {
                                            for (int n = 1; n < brokenLineNode.PointInfoNodes.Count; n++)
                                            {
                                                FileData.PointInfoNodes pointInfoNodes = new FileData.PointInfoNodes();
                                                pointInfoNodes.Add(brokenLineNode.PointInfoNodes[n - 1]);
                                                pointInfoNodes.Add(brokenLineNode.PointInfoNodes[n]);

                                                FileData.BrokenLineNode brokenLineNodeNew = new FileData.BrokenLineNode();
                                                brokenLineNodeNew.PointInfoNodes = pointInfoNodes;

                                                FileData.SegmentNodes segmentNodes = new FileData.SegmentNodes();
                                                segmentNodes.Add(brokenLineNodeNew);

                                                FileData.LineNode lineNodeNew = new FileData.LineNode();
                                                lineNodeNew.SegmentNodes = segmentNodes;

                                                lineNodeNew.EntityID       = lineNode.EntityID;
                                                lineNodeNew.FeatureCode    = lineNode.FeatureCode;
                                                lineNodeNew.LineType       = lineNode.LineType;
                                                lineNodeNew.Representation = lineNode.Representation;

                                                //arrLineNode.Add(lineNodeNew);
                                                //写入临时数据文件
                                                //if (m_pTempFile.LineNodeExs != null)
                                                //{
                                                pLineNodeTable.AddRow(lineNodeNew);
                                                //}

                                                if (m % pLineNodeTable.MaxRecordCount == 0)
                                                {
                                                    pLineNodeTable.Save(true);
                                                }
                                                m++;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                pLineNodeTable.Save(true);
            }
            //return arrLineNode;
        }
Ejemplo n.º 13
0
        /// ------------------------------------------------------------------------------------
        public override void Load()
        {
            base.Load();

            StageCompletedControlValues = ComponentRoles.ToDictionary(role => role.Id,
                                                                      role => (StageCompleteType)Enum.Parse(typeof(StageCompleteType),
                                                                                                            MetaDataFile.GetValue(SessionFileType.kStageFieldPrefix + role.Id, StageCompleteType.Auto.ToString()) as string));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 从mdb到vct转换时,初始化图层列表
        /// </summary>
        private bool InitialFeatureList()
        {
            try
            {
                if (m_pIDataset == null)
                    return false;
                m_FeatureList = new List<TableLayer>();
                IEnumDataset pEnumDataset = m_pIDataset.Subsets;
                IDataset pSet = pEnumDataset.Next();
                while (pSet != null)
                {
                    FeatureLayer pFeatureLayer = null;
                    IFeatureClass pFeatureCls = pSet as IFeatureClass;


                    string sGeometryType = "";
                    ///从配置文件获取要素类型
                    Metadata.MetaTable pMetaTable = Metadata.MetaDataFile.MetaTabls[pSet.Name] as Metadata.MetaTable;
                    if (pMetaTable != null)
                    {
                        sGeometryType = pMetaTable.Type;
                    }
                    else
                    {
                        ///如果不属于标准的数据则不处理
                        pSet = pEnumDataset.Next();
                        continue;
                    }
                    ///根据要素类型创建vct空间数据节点
                    esriGeometryType pFeatureType = pFeatureCls.ShapeType;
                    if (pFeatureType == esriGeometryType.esriGeometryLine
                        || pFeatureType == esriGeometryType.esriGeometryPolyline)
                    {
                        ///构造线节点
                        pFeatureLayer = new LineLayer();
                        if (sGeometryType == "")
                            sGeometryType = "Line";
                    }
                    else if (pFeatureType == esriGeometryType.esriGeometryPolygon)
                    {
                        //构造面节点
                        pFeatureLayer = new PolygonLayer();
                          if (sGeometryType == "")
                            sGeometryType = "Polygon"; 
                    }
                    else if (pFeatureType == esriGeometryType.esriGeometryPoint)
                    {
                        pFeatureLayer = new PointLayer();
                        if (sGeometryType == "")
                            sGeometryType = "Point"; 
                    }
                   
                    ////注记图层
                    if (pFeatureCls.FeatureType == esriFeatureType.esriFTAnnotation)
                    {
                        pFeatureLayer = new AnnotationLayer();
                        pFeatureLayer.GeometryType = "Annotation";
                    }

                    pFeatureLayer.CutGeometry =m_cutGeometry;
                    //挂接空间数据表
                    pFeatureLayer.Table = pSet as ITable;
                    pFeatureLayer.GeometryType = sGeometryType;
                    pFeatureLayer.IsCut = m_bCut;
                    pFeatureLayer.FeatureCode = MetaDataFile.GetFeatureCodeByName(pSet.Name);
                    pFeatureLayer.UpdateFieldIndex();

                    m_FeatureList.Add(pFeatureLayer);
                    pSet = pEnumDataset.Next();
                }

                ///处理属性表集合
                IEnumDataset pAttriTalbelDataSet=  m_pIWorkspace.get_Datasets(esriDatasetType.esriDTTable);
                IDataset pAttriDataset = pAttriTalbelDataSet.Next();
                while (pAttriDataset != null)
                 {
                        TableLayer pAttributeTalbe = new TableLayer();

                        ///从配置文件获取要素类型
                        Metadata.MetaTable pMetaTable = Metadata.MetaDataFile.MetaTabls[pAttriDataset.Name] as Metadata.MetaTable;
                        if (pMetaTable != null)
                        {
                            pAttributeTalbe.GeometryType = pMetaTable.Type;
                            pAttributeTalbe.Table = pAttriDataset as ITable;
                            pAttributeTalbe.UpdateFieldIndex();
                            m_FeatureList.Add(pAttributeTalbe);
                        }
                     pAttriDataset = pAttriTalbelDataSet.Next();
                 }
                return true;
            }
            catch (Exception ex)
            {
                LogAPI.WriteErrorLog(ex);
                return false;
            }
        }
Ejemplo n.º 15
0
        /// ------------------------------------------------------------------------------------
        public virtual IEnumerable <string> GetAllParticipants()
        {
            var allParticipants = MetaDataFile.GetStringValue(SessionFileType.kParticipantsFieldName, string.Empty);

            return(FieldInstance.GetMultipleValuesFromText(allParticipants));
        }