public void saveMol(string MolString, string PropId, out string Href, out string FormattedMolString, out string errorMsg, bool PostChanges = true, CswNbtNode Node = null)
        {
            CswPropIdAttr PropIdAttr = new CswPropIdAttr(PropId);
            CswNbtMetaDataNodeTypeProp MetaDataProp = _CswNbtResources.MetaData.getNodeTypeProp(PropIdAttr.NodeTypePropId);

            //Case 29769 - enforce correct mol file format
            FormattedMolString = MoleculeBuilder.FormatMolFile(MolString);

            errorMsg = string.Empty;
            Href     = string.Empty;
            if (null == Node)
            {
                Node = _CswNbtResources.Nodes[PropIdAttr.NodeId];
            }
            if (null != Node)
            {
                CswNbtNodePropMol molProp = Node.Properties[MetaDataProp];
                if (null != molProp)
                {
                    molProp.setMol(FormattedMolString);

                    //If DirectStructureSearch is enabled, use the new code to generate an image. Otherwise, use the legacy code.
                    byte[] molImage =
                        (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.DirectStructureSearch) ?
                         _CswNbtResources.AcclDirect.GetImage(FormattedMolString) :
                         CswStructureSearch.GetImage(FormattedMolString));

                    CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(_CswNbtResources);
                    Href = CswNbtNodePropMol.getLink(molProp.JctNodePropId, Node.NodeId);

                    //Save the mol image to blob_data
                    SdBlobData.saveFile(PropId, molImage, CswNbtNodePropMol.MolImgFileContentType, CswNbtNodePropMol.MolImgFileName, out Href, Int32.MinValue, PostChanges, Node: Node);

                    //case 28364 - calculate fingerprint and save it
                    _CswNbtResources.StructureSearchManager.InsertFingerprintRecord(PropIdAttr.NodeId.PrimaryKey, FormattedMolString, out errorMsg);
                }
            }
        }
Exemple #2
0
        private CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspection _addChecklistNodesToResponse(CswNbtNode InspectionNode)
        {
            CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspection Ret = null;
            if (false == InspectionDesignNodeIds.Contains(InspectionNode.NodeId) &&
                false == InspectionNode.ReadOnly)
            {
                InspectionDesignNodeIds.Add(InspectionNode.NodeId);
                CswNbtObjClassInspectionDesign NodeAsInspectionDesign = InspectionNode;
                Ret = new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspection
                {
                    DesignId = InspectionNode.NodeTypeId,

                    DueDateAsDate       = NodeAsInspectionDesign.DueDate.DateTimeValue,
                    InspectionId        = NodeAsInspectionDesign.NodeId.PrimaryKey,
                    InspectionPointName = NodeAsInspectionDesign.Target.CachedNodeName,
                    LocationPath        = NodeAsInspectionDesign.Location.Gestalt,
                    RouteName           = default(string),
                    Status   = NodeAsInspectionDesign.Status.Value,
                    Counts   = new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspection.QuestionCounts(),
                    ReadOnly = InspectionNode.ReadOnly
                };

                foreach (CswNbtNodePropWrapper Prop in InspectionNode.Properties)
                {
                    if (Prop.getFieldTypeValue() == CswEnumNbtFieldType.Question &&
                        false == Prop.ReadOnly &&
                        _CswNbtResources.Permit.isPropWritable(CswEnumNbtNodeTypePermission.Edit, Prop.NodeTypeProp, null))
                    {
                        CswNbtNodePropQuestion PropAsQuestion = Prop.AsQuestion;
                        Ret.Counts.Total += 1;
                        if (false == string.IsNullOrEmpty(PropAsQuestion.Answer) || PropAsQuestion.DateAnswered != DateTime.MinValue)
                        {
                            if (PropAsQuestion.IsCompliant)
                            {
                                Ret.Counts.Answered += 1;
                            }
                            else
                            {
                                Ret.Counts.Ooc += 1;
                            }
                        }
                        else
                        {
                            Ret.Counts.UnAnswered += 1;
                        }

                        var ResponseQuestion = new CswNbtSdInspectionsDataModels.InspectionData.CswNbtInspection.QuestionAnswer
                        {
                            Answer           = PropAsQuestion.Answer,
                            AnswerId         = PropAsQuestion.JctNodePropId,
                            IsAnswerEditable = PropAsQuestion.IsAnswerEditable,
                            Comments         = PropAsQuestion.Comments,
                            CorrectiveAction = PropAsQuestion.CorrectiveAction,
                            DateAnswered     = PropAsQuestion.DateAnswered,
                            QuestionId       = PropAsQuestion.NodeTypePropId,
                            Status           = NodeAsInspectionDesign.Status.Value,
                            DateCorrected    = PropAsQuestion.DateCorrected
                        };

                        Ret.Questions.Add(ResponseQuestion);
                    }
                    else if (Prop.getFieldTypeValue() == CswEnumNbtFieldType.Image &&
                             _CswNbtResources.Permit.isPropWritable(CswEnumNbtNodeTypePermission.Edit, Prop.NodeTypeProp, null))
                    {
                        CswNbtNodePropImage PropAsImage = Prop.AsImage;
                        CswNbtSdBlobData    sdBlobData  = new CswNbtSdBlobData(_CswNbtResources);
                        Ret.Images      = sdBlobData.GetImages(NodeAsInspectionDesign.NodeId, PropAsImage.JctNodePropId);
                        Ret.MaxImages   = PropAsImage.MaxFiles >= 1 ? PropAsImage.MaxFiles : 10; //if no value set for MaxFiles, default to 10
                        Ret.ImagePropId = new CswPropIdAttr(InspectionNode, PropAsImage.NodeTypeProp).ToString();
                    }
                }
            }
            return(Ret);
        }