Beispiel #1
0
        private static int?GetModel(Vault vault, PropertyValues pvs)
        {
            var modelPV = pvs.SearchForPropertyByAlias(vault, "PropOwnedModel", true);

            if (modelPV == null)
            {
                return(null);
            }
            if (modelPV.Value.IsNULL())
            {
                return(null);
            }
            return(modelPV.Value.GetLookupID());
        }
Beispiel #2
0
        public DocumentOperation(StateEnvironment stateEnvironment)
        {
            vault  = stateEnvironment.Vault;
            objver = stateEnvironment.ObjVer;

            try
            {
                var config = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
                SignaturePicturePath = string.Empty;
                var spp = config.AppSettings.Settings["SignaturePicturePath"];
                if (spp != null)
                {
                    SignaturePicturePath = spp.Value;
                }

                var files = vault.ObjectFileOperations.GetFiles(objver);
                filepath = Path.GetTempFileName();

                foreach (ObjectFile objectFile in files)
                {
                    vault.ObjectFileOperations.DownloadFile(objectFile.ID, objectFile.Version, filepath);
                    break;
                }
                var sc = new SearchCondition();
                sc.ConditionType = MFConditionType.MFConditionTypeEqual;
                sc.Expression.DataStatusValueType = MFStatusType.MFStatusTypeObjectTypeID;
                sc.TypedValue.SetValueToLookup(new Lookup
                {
                    Item =
                        vault.GetMetadataStructureItemIDByAlias(
                            MFMetadataStructureItem.MFMetadataStructureItemObjectType, MfilesAliasConfig.ObjProject)
                });
                var sr = vault.ObjectSearchOperations.SearchForObjectsByCondition(sc, false).ObjectVersions;
                if (sr.Count < 1)
                {
                    Writelog(string.Format("DocumentOperation- can't find project object in the vault <{0}>--", vault.Name));
                }
                foreach (ObjectVersion objectVersion in sr)
                {
                    pvs = vault.ObjectPropertyOperations.GetProperties(objectVersion.ObjVer);

                    Project = new ProjectInMfiles
                    {
                        PropProjName =
                            pvs.SearchForPropertyByAlias(vault, MfilesAliasConfig.PropProjName, true).GetValueAsLocalizedText(),
                        PropProjNum     = pvs.SearchForPropertyByAlias(vault, MfilesAliasConfig.PropProjNum, true).GetValueAsLocalizedText(),
                        PropDescription =
                            pvs.SearchForPropertyByAlias(vault, MfilesAliasConfig.PropDescription, true).GetValueAsLocalizedText(),
                        PropProprietorUnit =
                            pvs.SearchForPropertyByAlias(vault, MfilesAliasConfig.PropProprietorUnit, true).GetValueAsLocalizedText(),
                        PropSupervisorUnit =
                            pvs.SearchForPropertyByAlias(vault, MfilesAliasConfig.PropSupervisorUnit, true).GetValueAsLocalizedText(),
                        PropDesignUnit =
                            pvs.SearchForPropertyByAlias(vault, MfilesAliasConfig.PropDesignUnit, true).GetValueAsLocalizedText(),
                        PropStartDate =
                            pvs.SearchForPropertyByAlias(vault, MfilesAliasConfig.PropStartDate, true).GetValueAsLocalizedText(),
                        Deadline =
                            pvs.SearchForProperty((int)MFBuiltInPropertyDef.MFBuiltInPropertyDefDeadline)
                            .GetValueAsLocalizedText(),
                    };
                    break;
                }
                pvs = vault.ObjectPropertyOperations.GetProperties(objver);
                app = new Application();
                object unknow = Type.Missing;
                doc = app.Documents.Open(filepath,
                                         ref unknow, false, ref unknow, ref unknow, ref unknow,
                                         ref unknow, ref unknow, ref unknow, ref unknow, ref unknow,
                                         ref unknow, ref unknow, ref unknow, ref unknow, ref unknow);
                table = doc.Tables[doc.Tables.Count];
            }
            catch (Exception ex)
            {
                Writelog(string.Format("DocumentOperation-- vault={0},type={1},id={2},version={3},CurrentUserID={4},StateID={5},DisplayID={6},{7}",
                                       vault.Name, objver.Type, objver.ID, objver.Version, stateEnvironment.CurrentUserID, stateEnvironment.StateID, stateEnvironment.DisplayID, ex.Message));
            }
        }