コード例 #1
0
        public static void getExternalImage(ICswResources CswResources, ExternalImageRet Return, ACDSearchParams ACDSearchParams)
        {
            CswNbtResources   _CswNbtResources  = (CswNbtResources)CswResources;
            CswC3SearchParams CswC3SearchParams = new CswC3SearchParams();

            CswC3SearchParams.ACDSearchParams = ACDSearchParams;
            CswC3Product C3ProductDetails = new CswC3Product();

            CswNbtC3ClientManager CswNbtC3ClientManager = new CswNbtC3ClientManager(_CswNbtResources, CswC3SearchParams);
            SearchClient          C3SearchClient        = CswNbtC3ClientManager.initializeC3Client();

            if (null != C3SearchClient)
            {
                CswRetObjSearchResults SearchResults = C3SearchClient.getACDMolImage(CswC3SearchParams);
                if (null != SearchResults.CswC3SearchResults && SearchResults.CswC3SearchResults.Length > 0)
                {
                    C3ProductDetails = SearchResults.CswC3SearchResults[0];
                }
            }

            if (String.IsNullOrEmpty(C3ProductDetails.MolImage))
            {
                CswNbtMetaDataObjectClass ChemicalOC = _CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.ChemicalClass);
                Return.Data = File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + CswNbtMetaDataObjectClass.IconPrefix100 + ChemicalOC.IconFileName);
            }
            else
            {
                Return.Data = Convert.FromBase64String(C3ProductDetails.MolImage);
            }
        }
コード例 #2
0
        private static readonly CookieManagerBehavior _cookieBehavior = new CookieManagerBehavior(); //All ChemWatch service clients must share this

        public static CswNbtChemWatchRequest Initialize(ICswResources CswResources, CswNbtChemWatchRequest Request)
        {
            CswNbtChemWatchRequest Return       = new CswNbtChemWatchRequest();
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;

            CswNbtObjClassChemical ChemicalNode = NbtResources.Nodes[Request.NbtMaterialId];

            Return.Supplier      = ChemicalNode.Supplier.CachedNodeName;
            Return.PartNo        = ChemicalNode.PartNumber.Text;
            Return.MaterialName  = ChemicalNode.TradeName.Text;
            Return.NbtMaterialId = ChemicalNode.NodeId;

            string errorMsg;

            if (_authenticate(NbtResources, out errorMsg))
            {
                CommonServiceClient cwCommonClient = new CommonServiceClient();
                cwCommonClient.Endpoint.Behaviors.Add(_cookieBehavior);

                // Populate Language list
                List <ChemWatchMultiSlctListItem> Languages = new List <ChemWatchMultiSlctListItem>();
                Languages cwLanguages = cwCommonClient.GetLanguages();
                foreach (Language cwLanguage in cwLanguages)
                {
                    if (cwLanguage.UILanguage)
                    {
                        Languages.Add(new ChemWatchMultiSlctListItem()
                        {
                            Name = cwLanguage.Name,
                            Id   = CswConvert.ToString(cwLanguage.Id)
                        });
                    }
                }
                IEnumerable <ChemWatchMultiSlctListItem> SortedLanguages = Languages.OrderBy(si => si.Name);
                Return.Languages.options = SortedLanguages.ToList();

                // Populate Country list
                List <ChemWatchMultiSlctListItem> Countries = new List <ChemWatchMultiSlctListItem>();
                Countries cwCountries = cwCommonClient.GetCountries();
                foreach (Country cwCountry in cwCountries)
                {
                    Countries.Add(new ChemWatchMultiSlctListItem()
                    {
                        Name = cwCountry.Name,
                        Id   = CswConvert.ToString(cwCountry.Id)
                    });
                }
                IEnumerable <ChemWatchMultiSlctListItem> SortedCountries = Countries.OrderBy(si => si.Name);
                Return.Countries.options = SortedCountries.ToList();

                // Attempt to populate the Suppliers list
                _getMatchingSuppliers(Return.Supplier, Return);
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Error, "There was a problem authenticating with ChemWatch", errorMsg);
            }

            return(Return);
        }
コード例 #3
0
        }//getExistingNodes()

        public static void deleteExistingNodes(ICswResources CswResources, CswNbtImportWcf.DltExistingNodesReturn Ret, object EmptyObject)
        {
            // In this case, we need to create a new instance of CswNbtResources
            // so that we can delete all nodes (including MLM nodes)
            CswNbtResources _CswNbtResources = CswNbtResourcesFactory.makeCswNbtResources(CswEnumAppType.Nbt, CswEnumSetupMode.NbtWeb, false);   //ExcludeDisabledModules needs to be false

            _CswNbtResources.AccessId        = CswResources.AccessId;
            _CswNbtResources.InitCurrentUser = _initUser;

            Collection <CswNbtImportWcf.DltExistingNodesReturn.DltExistingNodesReturnData.DoomedNode> DoomedNodes = _retriveDoomedNodes(_CswNbtResources);

            foreach (CswNbtImportWcf.DltExistingNodesReturn.DltExistingNodesReturnData.DoomedNode DoomedNode in DoomedNodes)
            {
                try
                {
                    CswPrimaryKey NodePrimeKey = new CswPrimaryKey();
                    NodePrimeKey.FromString("nodes_" + DoomedNode.NodeId);
                    CswNbtNode CurrentNode = _CswNbtResources.Nodes[NodePrimeKey];
                    if (null != CurrentNode)
                    {
                        CurrentNode.delete(true, true, false);
                    }
                }
                catch (Exception exception)
                {
                    throw new CswDniException(CswEnumErrorType.Error, "Error deleting node: ", exception.Message);
                }
            }

            _CswNbtResources.finalize();
            Ret.Data.DeleteSuccessful = true;
        }
コード例 #4
0
        private void _setLoad(ICswResources CswResources)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            if (NbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.Containers))
            {
                #region SQL
                String SQLSelect = @"with
RemainingQuantity as (
select jnp.nodeid, jnp.field1_numeric as RemainingQuantity, jnp.field1_fk as RemainingQuantityUnit
        from jct_nodes_props jnp
        inner join nodetype_props ntp on ntp.nodetypepropid = jnp.nodetypepropid
        inner join object_class_props ocp on ocp.objectclasspropid = ntp.objectclasspropid
        where ocp.propname = 'Remaining Source Container Quantity'
),
SourceContainer as (
select jnp.nodeid, jnp.field1_fk as containerid
        from jct_nodes_props jnp
        inner join nodetype_props ntp on ntp.nodetypepropid = jnp.nodetypepropid
        inner join object_class_props ocp on ocp.objectclasspropid = ntp.objectclasspropid
        where ( ocp.propname = 'Source Container' or ocp.propname = 'Destination Container' )
),
containers as (
select n.nodeid
      from nodes n
      inner join nodetypes nt on n.nodetypeid = nt.nodetypeid
        inner join object_class oc on nt.objectclassid = oc.objectclassid
        where oc.objectclass = 'ContainerClass'
),
dispenses as (
select 
c.nodeid containerid,
n.nodeid dispensetransactionid,
rq.RemainingQuantity RemainingQuantity
      from nodes n
      left join RemainingQuantity rq on n.nodeid = rq.nodeid
      left join SourceContainer sc on n.nodeid = sc.nodeid
      left join containers c on sc.containerid = c.nodeid
      inner join nodetypes nt on n.nodetypeid = nt.nodetypeid
        inner join object_class oc on nt.objectclassid = oc.objectclassid
        where oc.objectclass = 'ContainerDispenseTransactionClass'
        and sc.containerid is not null
)
select c.nodeid, ct.dispenses
from containers c 
left join (select c.nodeid containerid, count(d.dispensetransactionid) dispenses
  from containers c
  left join dispenses d on d.containerid = c.nodeid
  group by c.nodeid) ct on c.nodeid = ct.containerid
where c.nodeid not in (select containerid from dispenses where RemainingQuantity is null)";
                #endregion SQL
                CswArbitrarySelect TransactionlessContainers = new CswArbitrarySelect(NbtResources.CswResources, "TransactionlessContainers", SQLSelect);
                DataTable          ContainersTable           = TransactionlessContainers.getTable();
                foreach (DataRow ContainerRow in ContainersTable.Rows)
                {
                    _ContainerIdsWithoutReceiveTransactions.Add(new CswPrimaryKey("nodes", CswConvert.ToInt32(ContainerRow["nodeid"].ToString())));
                    _ContainerHasOtherTransactions.Add(CswConvert.ToInt32(ContainerRow["dispenses"].ToString()) > 0);
                }
            }
        }
コード例 #5
0
        public static void saveFile(ICswResources CswResources, BlobDataReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            BinaryReader br = new BinaryReader(Request.postedFile.InputStream);

            byte[] FileData = new byte[Request.postedFile.InputStream.Length];
            for (int i = 0; i < Request.postedFile.InputStream.Length; i++)
            {
                FileData[i] = br.ReadByte();
            }

            string           Href       = string.Empty;
            CswNbtSdBlobData SdBlobData = new CswNbtSdBlobData(NbtResources);
            int BlobDataId = CswConvert.ToInt32(Request.Blob.BlobDataId);

            //IE9 sends the entire file url - we only want the file name
            string fileName = Path.GetFileName(Request.postedFile.FileName);

            BlobDataId = SdBlobData.saveFile(Request.propid, FileData, Request.postedFile.ContentType, fileName, out Href, BlobDataId);

            Request.Blob.BlobDataId  = BlobDataId;
            Request.Blob.ContentType = Request.postedFile.ContentType;
            Request.Blob.FileName    = fileName;
            Request.Blob.BlobUrl     = Href;

            Request.success = true;
            Return.Data     = Request;
        }
コード例 #6
0
        } // _addNodeToData()

        public static void UploadBulkEditData(ICswResources CswResources, BulkEditReturn ret, BulkEditUpload Params)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswTempFile temp     = new CswTempFile(CswResources);
            string      tempPath = temp.saveToTempFile(Params.PostedFile.InputStream, CswResources.AccessId + "_bulkedit_" + DateTime.Now.Ticks.ToString());

            DataSet uploadDataSet = CswNbtImportTools.ReadExcel(tempPath);

            if (uploadDataSet.Tables.Count > 0)
            {
                DataTable uploadTable = uploadDataSet.Tables[0];

                CswNbtBatchOpBulkEdit batch     = new CswNbtBatchOpBulkEdit(NbtResources);
                CswNbtObjClassBatchOp batchNode = batch.makeBatchOp(uploadTable);

                CswNbtView BatchOpsView = new CswNbtView((CswNbtResources)CswResources);
                BatchOpsView.ViewName = "New Batch Operations";
                BatchOpsView.ViewMode = CswEnumNbtViewRenderingMode.Tree;
                CswNbtViewRelationship BatchRel = BatchOpsView.AddViewRelationship(batchNode.NodeType, false);
                BatchRel.NodeIdsToFilterIn.Add(batchNode.NodeId);

                BatchOpsView.SaveToCache(true);
                ret.ViewId = BatchOpsView.SessionViewId.ToString();
            } // if( uploadDataSet.Tables.Count > 0 )
        }     // UploadBulkEditData()
コード例 #7
0
        public static void ReceiveMaterial(ICswResources CswResources, CswNbtReceivingDefinitionReturn Response, CswNbtReceivingDefinition ReceivingDefiniton)
        {
            CswNbtResources    NbtResources = (CswNbtResources)CswResources;
            CswNbtActReceiving ActReceiving = new CswNbtActReceiving(NbtResources, ReceivingDefiniton.MaterialNodeId);
            JObject            ActionData   = ActReceiving.receiveMaterial(ReceivingDefiniton);

            Response.Data.ActionData = ActionData.ToString();


            //Create Print Job
            if (null != ReceivingDefiniton.PrintLabelId && null != ReceivingDefiniton.PrinterNodeId)
            {
                CswNbtObjClassContainer InitialContainer = NbtResources.Nodes.GetNode(ReceivingDefiniton.ContainerNodeId);

                Collection <Dictionary <string, string> > PropVals = new Collection <Dictionary <string, string> >();
                foreach (CswNbtAmountsGridQuantity Quant in ReceivingDefiniton.Quantities)
                {
                    CswNbtObjClassUnitOfMeasure UoMNode = NbtResources.Nodes.GetNode(Quant.UnitNodeId);
                    for (int i = 0; i < Quant.NumContainers; i++)
                    {
                        Dictionary <string, string> vals = InitialContainer.Node.getPropertiesAndValues();
                        vals[InitialContainer.Barcode.PropName]  = Quant.getBarcodes()[i];
                        vals[InitialContainer.Quantity.PropName] = Quant.Quantity + " " + UoMNode.BaseUnit.Text;
                        PropVals.Add(vals);
                    }
                }

                CswNbtWebServicePrintLabels.newPrintJob(CswResources, ReceivingDefiniton.PrinterNodeId, ReceivingDefiniton.PrintLabelId, ReceivingDefiniton.ContainerNodeId, PropVals);
            }
        }
コード例 #8
0
        public void threadCallBack(ICswResources CswResources)
        {
            _LogicRunStatus = CswEnumScheduleLogicRunStatus.Running;

            CswNbtResources CswNbtResources = (CswNbtResources)CswResources;

            CswNbtResources.AuditContext = "Scheduler Task: " + RuleName;

            if (CswEnumScheduleLogicRunStatus.Stopping != _LogicRunStatus)
            {
                try
                {
                    CswNbtResources.execStoredProc("update_nodecounts", new List <CswStoredProcParam>()
                    {
                    });

                    _CswScheduleLogicDetail.StatusMessage = "Completed without error";
                    _LogicRunStatus = CswEnumScheduleLogicRunStatus.Succeeded; //last line
                }//try
                catch (Exception Exception)
                {
                    _CswScheduleLogicDetail.StatusMessage = "CswScheduleLogicNbtNodeCounts::GetUpdatedItems() exception: " + Exception.Message + "; " + Exception.StackTrace;
                    CswNbtResources.logError(new CswDniException(_CswScheduleLogicDetail.StatusMessage));
                    _LogicRunStatus = CswEnumScheduleLogicRunStatus.Failed;
                } //catch
            }     //if we're not shutting down
        }         //threadCallBack()
コード例 #9
0
        public static void GetSearchMenuItems(ICswResources CswResources, CswNbtSearchMenuReturn Return, bool universalSearchOnly)
        {
            _CswNbtResources = (CswNbtResources)CswResources;

            Collection <SearchMenuResponse.SearchTarget> SearchTargets = new Collection <SearchMenuResponse.SearchTarget>();

            if (false == universalSearchOnly)
            {
                if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.CISPro))
                {
                    SearchMenuResponse.SearchTarget ss = new SearchMenuResponse.SearchTarget();
                    ss.name         = "Structure Search";
                    ss.iconfilename = "Images/newicons/16/atommag.png";
                    SearchTargets.Add(ss);
                }

                if (_CswNbtResources.Modules.IsModuleEnabled(CswEnumNbtModuleName.C3))
                {
                    SearchMenuResponse.SearchTarget c3 = new SearchMenuResponse.SearchTarget();
                    c3.name         = "ChemCatCentral Search";
                    c3.iconfilename = "Images/newicons/16/cat.png";
                    SearchTargets.Add(c3);
                }
            }

            Return.Data.searchTargets = SearchTargets;
        }
コード例 #10
0
        public static void getScheduledRulesGrid(ICswResources CswResources, CswNbtScheduledRulesReturn Return, string AccessId)
        {
            try
            {
                CswNbtResources NbtResources = (CswNbtResources)CswResources;

                //Here we are using the web reference for the schedule service,
                //overwriting the app.config endpoint uri with the one defined in SetupVbls.
                //The CswSchedSvcAdminEndPointClient::getRules() method will return a collection of objects,
                //each of which represents a scheduled rule for the accessid specified as in CswSchedSvcParams.
                //You can find the server side of this connection in /CswCommon/Csw/MtSched/port
                CswSchedSvcAdminEndPointClient SchedSvcRef = new CswSchedSvcAdminEndPointClient();
                EndpointAddress URI = new EndpointAddress(CswResources.SetupVbls["SchedServiceUri"]);
                SchedSvcRef.Endpoint.Address = URI;
                CswSchedSvcParams CswSchedSvcParams = new CswSchedSvcParams();
                CswSchedSvcParams.CustomerId = AccessId;
                CswSchedSvcReturn svcReturn = SchedSvcRef.getRules(CswSchedSvcParams);

                if (null != svcReturn)
                {
                    _addScheduledRulesGrid(NbtResources, svcReturn.Data, Return);
                }
                Return.Data.CustomerId = AccessId;
            }
            catch (Exception ex)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Could not find the Schedule Service.  Check to make sure the service is running and that the endpoint url is configured correctly.", ex.Message, ex);
            }
        }//getScheduledRulesGrid()
コード例 #11
0
        }//getScheduledRulesGrid()

        public static void updateAllScheduledRules(ICswResources CswResources, CswNbtScheduledRulesReturn Return, CswNbtScheduledRulesReturn.Ret Request)
        {
            CswNbtResources   NbtResources             = (CswNbtResources)CswResources;
            CswSchedSvcReturn svcReturn                = new CswSchedSvcReturn();
            CswSchedSvcAdminEndPointClient SchedSvcRef = new CswSchedSvcAdminEndPointClient();
            //Overwrite the app.config endpoint uri with the one defined in SetupVbls
            EndpointAddress URI = new EndpointAddress(CswResources.SetupVbls["SchedServiceUri"]);

            SchedSvcRef.Endpoint.Address = URI;

            CswSchedSvcParams CswSchedSvcParams = new CswSchedSvcParams();

            CswSchedSvcParams.CustomerId   = Request.CustomerId;
            CswSchedSvcParams.LogicDetails = new Collection <CswScheduleLogicDetail>();
            foreach (CswExtJsGridRow GridRow in Request.Grid.rowData.rows)
            {
                if (CswConvert.ToBoolean(GridRow.data[new CswExtJsGridDataIndex("ScheduledRules", CswEnumScheduleLogicDetailColumnNames.HasChanged)]))
                {
                    CswScheduleLogicDetail Rule = _getLogicDetailFromGridRow(GridRow, "ScheduledRules");
                    CswSchedSvcParams.LogicDetails.Add(Rule);
                }
            }

            svcReturn = SchedSvcRef.updateScheduledRules(CswSchedSvcParams);
            if (null != svcReturn)
            {
                _updateScheduledRulesTable(NbtResources, CswSchedSvcParams.LogicDetails);
                _addScheduledRulesGrid(NbtResources, svcReturn.Data, Return);
            }
        }
コード例 #12
0
        } // getSubscriptions()

        public static void saveSubscriptions(ICswResources CswResources, CswWebSvcReturn Return, MailReportSubscriptions Request)
        {
            CswNbtResources           CswNbtResources = (CswNbtResources)CswResources;
            CswPrimaryKey             ThisUserPk      = CswNbtResources.CurrentNbtUser.UserId;
            CswNbtMetaDataObjectClass MailReportOC    = CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.MailReportClass);

            foreach (MailReportSubscriptions.Subscription sub in Request.Subscriptions)
            {
                if (sub.Modified)
                {
                    CswPrimaryKey NodeId = new CswPrimaryKey();
                    NodeId.FromString(sub.NodeId);

                    CswNbtObjClassMailReport MailReportNode = CswNbtResources.Nodes[NodeId];
                    if (sub.Subscribed)
                    {
                        MailReportNode.Recipients.AddUser(ThisUserPk);
                    }
                    else
                    {
                        MailReportNode.Recipients.RemoveUser(ThisUserPk);
                    }
                    MailReportNode.postChanges(false);
                }
            }
        } // saveSubscriptions()
コード例 #13
0
        } // MailReportSubscriptions

        #endregion WCF Data Objects

        public static void getSubscriptions(ICswResources CswResources, MailReportSubscriptionsReturn Return, object Request)
        {
            CswNbtResources         CswNbtResources = (CswNbtResources)CswResources;
            MailReportSubscriptions Subs            = new MailReportSubscriptions();

            CswPrimaryKey ThisUserPk = CswNbtResources.CurrentNbtUser.UserId;

            CswNbtMetaDataObjectClass MailReportOC = CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.MailReportClass);

            foreach (CswNbtObjClassMailReport MailReportNode in MailReportOC.getNodes(false, false))
            {
                if (CswNbtResources.Permit.canNode(CswEnumNbtNodeTypePermission.View, MailReportNode.getPermissionGroupId()))
                {
                    MailReportSubscriptions.Subscription sub = new MailReportSubscriptions.Subscription
                    {
                        Name       = MailReportNode.NodeName,
                        NodeId     = MailReportNode.NodeId.ToString(),
                        Subscribed = MailReportNode.Recipients.IsSubscribed(ThisUserPk),
                        IsDemo     = MailReportNode.IsDemo
                    };
                    Subs.Subscriptions.Add(sub);
                }
            }
            Return.Data = Subs;
        } // getSubscriptions()
コード例 #14
0
        public static CswNbtChemWatchRequest MaterialSearch(ICswResources CswResources, CswNbtChemWatchRequest Request)
        {
            CswNbtChemWatchRequest Return       = new CswNbtChemWatchRequest();
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;
            string errorMsg;

            if (_authenticate(NbtResources, out errorMsg))
            {
                MaterialServiceClient cwMaterialClient = new MaterialServiceClient();
                cwMaterialClient.Endpoint.Behaviors.Add(_cookieBehavior);

                List <ChemWatchListItem> Materials   = new List <ChemWatchListItem>();
                ListResultOfMaterial     cwMaterials = cwMaterialClient.GetMaterialsByVendorGroupId(Request.Supplier, Request.MaterialName, Request.PartNo, false, 1, 100, "", 0);
                foreach (Material cwMaterial in cwMaterials.Rows)
                {
                    Materials.Add(new ChemWatchListItem()
                    {
                        Id   = CswConvert.ToString(cwMaterial.MaterialID),
                        Name = cwMaterial.Name
                    });
                }
                IEnumerable <ChemWatchListItem> SortedMaterials = Materials.OrderBy(si => si.Name);
                Return.Materials = SortedMaterials.ToList();
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Error, "There was a problem authenticating with ChemWatch", errorMsg);
            }

            return(Return);
        }
コード例 #15
0
        }//importC3Product()

        public static void CreateMaterialRequestFromC3(ICswResources CswResources, CswNbtC3CreateMaterialReturn Return, CswNbtC3Import.Request Request)
        {
            CswNbtResources           NbtResources       = (CswNbtResources)CswResources;
            CswNbtMetaDataObjectClass RequestItemOC      = NbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.RequestItemClass);
            CswNbtMetaDataNodeType    FirstRequestItemNT = RequestItemOC.getNodeTypes().FirstOrDefault();

            if (null == FirstRequestItemNT)
            {
                throw new CswDniException(CswEnumErrorType.Error, "Cannot create a Create Material Request because there are no Request Item Types", "Cannot create a Create Material Request when there are no Request Item Nodetypes");
            }

            CswNbtObjClassRequestItem RequestItemNode = NbtResources.Nodes.makeNodeFromNodeTypeId(FirstRequestItemNT.NodeTypeId, IsTemp : true, OnAfterMakeNode : delegate(CswNbtNode NewNode)
            {
                CswNbtObjClassRequestItem AsRequestItem = NewNode;
                AsRequestItem.Type.Value        = CswNbtObjClassRequestItem.Types.MaterialCreate;
                AsRequestItem.C3CDBRegNo.Value  = Request.Cdbregno;
                AsRequestItem.C3ProductId.Value = Request.C3ProductId;

                AsRequestItem.NewMaterialTradename.Text = "TEST THING";
            });

            //RequestItemNode.NewMaterialSupplier.setHidden( true, true );
            //RequestItemNode.NewMaterialTradename.setHidden( true, true );
            //RequestItemNode.NewMaterialPartNo.setHidden( true, true );
            //RequestItemNode.Location.setHidden( true, true );
            //RequestItemNode.postChanges( false );

            Return.Data.state = new C3CreateMaterialResponse.State();
            Return.Data.state.materialType      = new C3CreateMaterialResponse.State.MaterialType();
            Return.Data.state.materialId        = RequestItemNode.NodeId.ToString();
            Return.Data.state.materialType.name = FirstRequestItemNT.NodeTypeName;
            Return.Data.state.materialType.val  = FirstRequestItemNT.NodeTypeId;
        }
コード例 #16
0
        public static void saveMaterialProps(ICswResources CswResources, MaterialResponse Response, string PropDefinition)
        {
            if (null != CswResources)
            {
                CswNbtResources         NbtResources         = (CswNbtResources)CswResources;
                CswNbtActCreateMaterial CreateMaterialAction = new CswNbtActCreateMaterial(NbtResources);

                // Convert PropDefintion to JObject
                JObject PropsObj = CswConvert.ToJObject(PropDefinition);

                if (PropsObj.HasValues)
                {
                    // Convert the nodeid to a primary key
                    CswPrimaryKey NodePk = CswConvert.ToPrimaryKey(CswConvert.ToString(PropsObj["NodeId"]));

                    // Convert the Nodetypeid to an Int32
                    Int32 NodeTypeId = CswConvert.ToInt32(CswConvert.ToString(PropsObj["NodeTypeId"]));

                    // Properties only
                    JObject Properties = CswConvert.ToJObject(PropsObj["Properties"]);

                    // Save the properties
                    JObject PropValues = CreateMaterialAction.saveMaterialProps(NodePk, Properties, NodeTypeId);

                    // Set the return object
                    if (PropValues.HasValues)
                    {
                        if (null != PropValues.Property("PhysicalState"))
                        {
                            Response.Data.Properties.PhysicalState = CswConvert.ToString(PropValues["PhysicalState"]);
                        }
                    }
                }//if( PropsObj.HasValues )
            }
        }
コード例 #17
0
        } // getBulkEditProperties()

        public static void DownloadBulkEditData(ICswResources CswResources, BulkEditDownload ret, BulkEditParams Params)
        {
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;
            CswNbtMetaDataNodeType NodeType     = NbtResources.MetaData.getNodeType(Params.NodeTypeId);

            if (null != NodeType)
            {
                ret.CsvData = new DataTable();
                ret.CsvData.Columns.Add("nodeid");
                foreach (Int32 PropId in Params.PropIds)
                {
                    CswNbtMetaDataNodeTypeProp Prop = NodeType.getNodeTypeProp(PropId);
                    if (Prop.getFieldTypeRule().SubFields.Count > 1)
                    {
                        foreach (CswNbtSubField SubField in Prop.getFieldTypeRule().SubFields)
                        {
                            ret.CsvData.Columns.Add(Prop.PropName + " " + SubField.Name);
                        }
                    }
                    else
                    {
                        ret.CsvData.Columns.Add(Prop.PropName);
                    }
                }

                CswNbtView  View = NbtResources.ViewSelect.restoreView(new CswNbtViewId(Params.ViewId));
                ICswNbtTree Tree = NbtResources.Trees.getTreeFromView(View, RequireViewPermissions: true, IncludeSystemNodes: false, IncludeHiddenNodes: false);
                _recurseBulkEditData(NodeType, Tree, ret, Params);
            }
        } // DownloadBulkEditData()
コード例 #18
0
        public static void getOcColumns(ICswResources CswResources, Columns Response, Int32 ObjectClassId)
        {
            if (null != CswResources)
            {
                CswNbtResources           NbtResources = (CswNbtResources)CswResources;
                CswNbtMetaDataObjectClass ObjectClass  = NbtResources.MetaData.getObjectClass(ObjectClassId);
                if (null != ObjectClass)
                {
                    Response.Tablename = ObjectClass.DbViewName;

                    Column NodeId = new Column();
                    NodeId.Name   = ObjectClass.ObjectClass + "Id";
                    NodeId.DbName = "nodeid";
                    NodeId.Type   = "number(12,0)";
                    Response.ColumnCol.Add(NodeId);

                    foreach (CswNbtMetaDataObjectClassProp ObjectClassProp in from _ObjectClass in ObjectClass.getObjectClassProps() orderby _ObjectClass.PropName select _ObjectClass)
                    {
                        foreach (Column Column in ObjectClassProp.DbViewColumns)
                        {
                            Response.ColumnCol.Add(Column);
                        }
                    }
                }
            }
        }
コード例 #19
0
        public static void getBulkEditProperties(ICswResources CswResources, BulkEditProperties ret, BulkEditParams Params)
        {
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;
            CswNbtMetaDataNodeType NodeType     = NbtResources.MetaData.getNodeType(Params.NodeTypeId);

            if (null != NodeType)
            {
                ret.Data = new Collection <BulkEditProperty>();
                if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, NodeType))
                {
                    foreach (CswNbtMetaDataNodeTypeProp Prop in NodeType.getNodeTypeProps()
                             .Where(p => false == p.getFieldType().IsDisplayType() &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.File &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.Image &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.ImageList &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.LogicalSet &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.MOL &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.MetaDataList &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.Password &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.TimeInterval &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.ViewPickList &&
                                    p.getFieldType().FieldType != CswEnumNbtFieldType.ViewReference)
                             .OrderBy(p => p.PropName))
                    {
                        ret.Data.Add(new BulkEditProperty()
                        {
                            id   = Prop.PropId,
                            name = Prop.PropNameWithQuestionNo
                        });
                    }
                }
            }
        } // getBulkEditProperties()
コード例 #20
0
        public static void initializeImpersonate(ICswResources CswResources, CswNbtMainMenuReturn Return, object Object)
        {
            CswNbtResources CswNbtResources = (CswNbtResources)CswResources;

            if (CswNbtResources.CurrentNbtUser.IsAdministrator())
            {
                // get the impersonate view
                DataTable DataTable = CswNbtResources.ViewSelect.getView("Impersonation NodeSelect View", CswEnumNbtViewVisibility.Hidden, null, null);
                if (DataTable.Rows.Count > 0)
                {
                    Int32        ViewId    = CswConvert.ToInt32(DataTable.Rows[0]["nodeviewid"].ToString());
                    CswNbtViewId NbtViewId = new CswNbtViewId(ViewId);
                    Return.Data.ImpersonateViewId = NbtViewId.ToString();
                }

                // We always want to exclude the current user
                Return.Data.ExcludeNodeIds.Add(CswNbtResources.CurrentNbtUser.UserId.ToString());
                // and exclude any users of chemsw_admin_role
                CswNbtObjClassUser ChemSWAdminUser = CswNbtResources.Nodes.makeUserNodeFromUsername("chemsw_admin");
                Return.Data.ExcludeNodeIds.Add(ChemSWAdminUser.UserId.ToString());
                //todo: make this encompass _all_ users of chemsw_admin_role
            }
            else
            {
                throw new CswDniException(CswEnumErrorType.Warning,
                                          "You do not have permission to use this feature.",
                                          "User " + CswNbtResources.CurrentNbtUser.Username + " attempted to run initalizeImpersonate().");
            }
        } //initializeImpersonate()
コード例 #21
0
        public static void GetSearchImageLink(ICswResources CswResources, CswNbtLayoutDataReturn Ret, string Req)
        {
            CswNbtResources        NbtResources = (CswNbtResources)CswResources;
            CswPrimaryKey          NodeId       = CswConvert.ToPrimaryKey(Req);
            CswNbtNode             Node         = NbtResources.Nodes.GetNode(NodeId);
            CswNbtMetaDataNodeType NodeType     = NbtResources.MetaData.getNodeType(Node.NodeTypeId);

            foreach (CswNbtNodePropWrapper Prop in Node.Properties)
            {
                if (CswEnumNbtFieldType.Image == Prop.getFieldTypeValue())
                {
                    Ret.Data.ImageLink = CswNbtNodePropImage.getLink(Prop.JctNodePropId, NodeId);
                }
                if (CswEnumNbtFieldType.MOL == Prop.getFieldTypeValue())
                {
                    Ret.Data.ImageLink = CswNbtNodePropMol.getLink(Prop.JctNodePropId, NodeId);
                }
            }

            if (string.Empty == Ret.Data.ImageLink)
            {
                if (NodeType.IconFileName != string.Empty)
                {
                    Ret.Data.ImageLink = CswNbtMetaDataObjectClass.IconPrefix100 + NodeType.IconFileName;
                }
                else
                {
                    Ret.Data.ImageLink = "Images/icons/300/_placeholder.gif";
                }
            }
        }
コード例 #22
0
        public static void getReportInfo( ICswResources CswResources, CswNbtWebServiceReport.ReportReturn Return, CswNbtWebServiceReport.ReportData reportParams )
        {
            CswNbtResources NBTResources = (CswNbtResources) CswResources;
            reportParams.ReportNode = NBTResources.Nodes[reportParams.NodeId];
            if( null != reportParams.ReportNode )
            {
                reportParams.doesSupportCrystal = ( false == reportParams.ReportNode.RPTFile.Empty );

                CswNbtNode SourceNode = null;
                if( CswTools.IsPrimaryKey( reportParams.SourceId ) )
                {
                    SourceNode = NBTResources.Nodes[reportParams.SourceId];
                }

                reportParams.reportParams = new Collection<ReportData.ReportParam>();
                foreach( var paramPair in reportParams.ReportNode.ExtractReportParams( NBTResources.Nodes[NBTResources.CurrentNbtUser.UserId], SourceNode ) )
                {
                    ReportData.ReportParam paramObj = new ReportData.ReportParam();
                    paramObj.name = paramPair.Key;
                    paramObj.value = paramPair.Value;
                    reportParams.reportParams.Add( paramObj );
                }
            }
            Return.Data = reportParams;
        }
コード例 #23
0
        public static void clearBlob(ICswResources CswResources, BlobDataReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;
            CswPropIdAttr   PropId       = new CswPropIdAttr(Request.propid);
            CswNbtNode      Node         = NbtResources.Nodes[PropId.NodeId];

            if (null != Node)
            {
                CswNbtMetaDataNodeTypeProp MetaDataProp = NbtResources.MetaData.getNodeTypeProp(PropId.NodeTypePropId);
                if (null != MetaDataProp)
                {
                    CswNbtNodePropWrapper FileProp = Node.Properties[MetaDataProp];
                    if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.Edit, MetaDataProp.getNodeType(), NbtResources.CurrentNbtUser) &&
                        NbtResources.Permit.isPropWritable(CswEnumNbtNodeTypePermission.Edit, MetaDataProp, null, FileProp))
                    {
                        CswNbtSdTabsAndProps tabsandprops = new CswNbtSdTabsAndProps(NbtResources);
                        tabsandprops.ClearPropValue(Request.propid, true);

                        Request.Blob    = new CswNbtSdBlobData.CswNbtBlob();
                        Request.success = true;

                        Return.Data = Request;
                    }
                    else
                    {
                        throw new CswDniException(CswEnumErrorType.Warning, "You do not have sufficient priveledges to clear this File property", "User " + NbtResources.CurrentNbtUser.UserId + " attempted to call clearBlob without sufficient priviledges.");
                    }
                }
            }
        }
コード例 #24
0
        public static void getExistingNodes(ICswResources CswResources, CswNbtImportWcf.DltExistingNodesReturn Ret, object EmptyObject)
        {
            CswNbtResources _CswNbtResources = (CswNbtResources)CswResources;

            Ret.Data = new CswNbtImportWcf.DltExistingNodesReturn.DltExistingNodesReturnData();
            Ret.Data.NodesToDelete = _retriveDoomedNodes(_CswNbtResources);
        }//getExistingNodes()
コード例 #25
0
        }//if we got any result

        public static void getImageProp(ICswResources CswResources, NodePropImageReturn Return, BlobDataParams Request)
        {
            CswNbtResources NbtResources = (CswNbtResources)CswResources;

            CswPropIdAttr PropIdAttr = new CswPropIdAttr(Request.propid);
            CswNbtNode    node       = NbtResources.Nodes[PropIdAttr.NodeId];

            if (null != node)
            {
                CswNbtMetaDataNodeType NodeType = node.getNodeType();
                CswNbtNodePropWrapper  prop     = node.Properties[PropIdAttr.NodeTypePropId];

                if (NbtResources.Permit.canNodeType(CswEnumNbtNodeTypePermission.View, NodeType, NbtResources.CurrentNbtUser))
                {
                    if (Int32.MinValue == prop.JctNodePropId)
                    {
                        prop.makePropRow(); //if we don't have a jct_node_prop row for this prop, we do now
                        node.postChanges(true);
                    }
                    prop.AsImage.SetImages(Request.date);
                    if (null != prop)
                    {
                        Return.Data = prop;
                    }
                }
                else
                {
                    throw new CswDniException(CswEnumErrorType.Warning, "You do not have sufficient priviledges to get this image property", "User " + NbtResources.CurrentNbtUser.UserId + " attempted to call getImageProp on prop " + prop.JctNodePropId);
                }
            }
        }
コード例 #26
0
        public static CswNbtChemWatchRequest CreateSDSDocuments(ICswResources CswResources, CswNbtChemWatchRequest Request)
        {
            CswNbtChemWatchRequest Return          = new CswNbtChemWatchRequest();
            CswNbtResources        CswNbtResources = (CswNbtResources)CswResources;

            CswNbtMetaDataObjectClass SDSDocumentOC = CswNbtResources.MetaData.getObjectClass(CswEnumNbtObjectClass.SDSDocumentClass);

            foreach (ChemWatchSDSDoc SDSDoc in Request.SDSDocuments)
            {
                string Language = _getLanguage(SDSDoc.Language);
                string FileName = SDSDoc.FileName;
                string Country  = SDSDoc.Country;
                CswNbtResources.Nodes.makeNodeFromNodeTypeId(SDSDocumentOC.FirstNodeType.NodeTypeId, delegate(CswNbtNode NewNode)
                {
                    CswNbtObjClassSDSDocument NewSDSDocNode = NewNode;
                    NewSDSDocNode.FileType.Value            = CswNbtObjClassSDSDocument.CswEnumDocumentFileTypes.ChemWatch;
                    NewSDSDocNode.ChemWatch.Text            = FileName;
                    NewSDSDocNode.Language.Value            = Language;
                    NewSDSDocNode.Country.Text        = Country;
                    NewSDSDocNode.Owner.RelatedNodeId = Request.NbtMaterialId;
                });
            }

            return(Return);
        }