I need to filter my raster image by a fixed threshold. So I use ILogicalOp functions. Whenever I use them, an output file will be saved on workspace, which is unwanted due to my large database. The saving happens exactly after rasOut[i] = RMath.LessThan(inputRas[i], cons01). How can I prevent this? Or how to get saved file name and delete it? Any comments would be Appreciated?
private IGeoDataset[] CalcColdThreshold(IGeoDataset[] inputRas)
{
IGeoDataset[] rasOut = new IGeoDataset[inputRas.Length];
IGeoDataset emptyRas=null;
ILogicalOp RMath;
RMath = new RasterMathOpsClass();
IRasterAnalysisEnvironment env;
env = (IRasterAnalysisEnvironment)RMath;
IWorkspaceFactory workspaceFactory = new RasterWorkspaceFactoryClass();
IWorkspace workspace = workspaceFactory.OpenFromFile(System.IO.Path.GetFullPath(workSpace_save.Text), 0);
env.OutWorkspace = workspace;
IRasterMakerOp Rmaker = new RasterMakerOpClass();
IGeoDataset cons01;
Threshold_value = 15000;
cons01 = Rmaker.MakeConstant(Threshold_value, false);
for (int i = 0; i < inputRas.Length; i++)
{
rasOut[i] = RMath.LessThan(inputRas[i], cons01);
}
return rasOut;
}
(disclaimer: I'm not actually a C++ programmer, just trying to provide some pointers to get you going since no one else seems to have any answers.) (converted from comment)
The IScratchWorkspaceFactory interface sounds like it will do what you want - instead of creating your workspace variable using IWorkspaceFactory.OpenFromFile, try creating a scratch workspace instead? According to the documentation it will be automatically cleaned up when your application exits.
Just remember to use a different workspace for your final output. :)
Related
I'm having an AppModel application in my System Center Configuration Manager(SCCM) console. Please see below screenshot of the properties window of the SCCM application:
I need to know the value of 'Allow this application to be installed from the Install Application task sequence.....' checkbox. It is highlighted in yellow.
I tried to get it through wbemtest tool using below details:
Namespace: root\sms\site_[siteCode] e.g. root\sms\site_lab
Query: select * from SMS_Application
I hope I've got the correct Windows Management Instrumentation(WMI) class for AppModel CM applications.
But the output in wbemtest tool doesn't give any field in the result output which can reflect the current condition of checkbox:
Instance of SMS_Application
{
ApplicabilityCondition = "";
CategoryInstance_UniqueIDs = {};
CI_ID = 16777532;
CI_UniqueID = "ScopeId_6AFF9AA6-E784-4BB8-8DCF-816FCF7A7C09/Application_8e417c4c-da5d-4f1c-91af-ed63d63f9a62/3";
CIType_ID = 10;
CIVersion = 3;
CreatedBy = "NTL\\administrator";
DateCreated = "20190724122559.000000+000";
DateLastModified = "20200422051705.000000+000";
EULAAccepted = 2;
EULAExists = FALSE;
ExecutionContext = 0;
Featured = 0;
HasContent = TRUE;
IsBundle = FALSE;
IsDeployable = TRUE;
IsDeployed = FALSE;
IsEnabled = TRUE;
IsExpired = FALSE;
IsHidden = FALSE;
IsLatest = TRUE;
IsQuarantined = FALSE;
IsSuperseded = FALSE;
IsSuperseding = FALSE;
IsUserDefined = TRUE;
IsVersionCompatible = TRUE;
LastModifiedBy = "NTL\\estateadministrator";
LocalizedCategoryInstanceNames = {};
LocalizedDescription = "";
LocalizedDisplayName = "7-Zip 19.00 (x64 edition)";
LocalizedInformativeURL = "";
LocalizedPropertyLocaleID = 65535;
LogonRequirement = 0;
Manufacturer = "";
ModelID = 16777500;
ModelName = "ScopeId_6AFF9AA6-E784-4BB8-8DCF-816FCF7A7C09/Application_8e417c4c-da5d-4f1c-91af-ed63d63f9a62";
NumberOfDependentDTs = 0;
NumberOfDependentTS = 0;
NumberOfDeployments = 0;
NumberOfDeploymentTypes = 1;
NumberOfDevicesWithApp = 0;
NumberOfDevicesWithFailure = 0;
NumberOfSettings = 0;
NumberOfUsersWithApp = 0;
NumberOfUsersWithFailure = 0;
NumberOfUsersWithRequest = 0;
NumberOfVirtualEnvironments = 0;
PermittedUses = 0;
PlatformCategoryInstance_UniqueIDs = {};
PlatformType = 1;
SDMPackageVersion = 3;
SecuredScopeNames = {"Default"};
SedoObjectVersion = "9B99BA03-D0FA-417C-8BFF-6095B88AD179";
SoftwareVersion = "";
SourceCIVersion = 0;
SourceModelName = "";
SourceSite = "LAB";
SummarizationTime = "20200422125059.533000+***";
};
Is it possible that WMI class is not exposing all the columns of the database backed by this WMI class. Hence, I'm looking for the SQL DB table of SCCM DB so that I can query it directly at DB level. Can anyone help me in this regard?
Update: I also need the table which I can update to set/reset the Boolean field corresponding to the checkbox shown on UI.
The information is stored inside an XML element called SDMPackageXML in WMI. The corresponding table the console uses is fn_listApplicationCIs_List(1031) (it is also present in fn_listApplicationCIs(1031) I am at the moment not sure what the exact difference here is) where it is called SDMPackageDigest. The element is simply called "AutoInstall" and it is only present if set to true. To query it with WQL is impossible, however in a script it could be done by not using a query but a Get() on the SMS_Application Object (because SDMPackageXML is a lazy property) and then parsing the XML.
In SQL however it is possible to directly query the XML Part of a column like this:
SELECT
DisplayName,
CI_UniqueID
FROM
fn_ListApplicationCIs_List(1031) app
WHERE
app.isLatest = 1
AND
app.SDMPackageDigest.value('declare namespace p1="http://schemas.microsoft.com/SystemCenterConfigurationManager/2009/AppMgmtDigest";(p1:AppMgmtDigest/p1:Application/p1:AutoInstall)[1]', 'nvarchar(max)') = 'true'
(the isLatest is necessary to discard older versions of the application).
It is also possible to include the value in the select with that syntax, just keep in mind that it will be true for all Applications that are enabled for TS deployment and NULL for the others.
Now as for how to update. The SCCM DB should never be written to. I don't know if it would even be possible to achieve a change this way (it could be that WMI is always leading and would overwrite it), and as this is all undocumented it could be that changes have to be done at specific places or multiple places at the same time. If this has to be updated you have to resort to scripts, that can work with the lazy WMI properties. However I do not know of a way that is not dependent on SCCM specific dlls (doesn't mean there is none but I do not know how to work with XML well enough for this) so you will need Microsoft.ConfigurationManagement.ApplicationManagement.dll from the bin directory of a ConfigMgr Console Installation dir. (I wrote the code so that it would automatically find it on a computer where the Console is installed). Then you can do it like this (can of course also be wrapped in a for):
[System.Reflection.Assembly]::LoadFrom((Join-Path (Get-Item $env:SMS_ADMIN_UI_PATH).Parent.FullName "Microsoft.ConfigurationManagement.ApplicationManagement.dll"))
$app = gwmi -computer <siteserver> -namespace root\sms\site_<sitecode> -class sms_application -filter "LocalizedDisplayName='<appname>' and isLatest = 'true'"
$app.Get()
$sdmPackageXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::DeserializeFromString($app.SDMPackageXML, $true)
$sdmPackageXML.AutoInstall = $true
$app.SDMPackageXML = [Microsoft.ConfigurationManagement.ApplicationManagement.Serialization.SccmSerializer]::SerializeToString($sdmPackageXML, $true)
$app.Put()
The nice thing is that this deserialization always presents us with an AutoInstall property even if it is not present in the xml because it was written for sccm so we can just set it true/false as we want.
The reason we need the .dll is the serialization. Deserialisation can be done with a simple cast to [xml] as well but I am not sure how it could be serialized again. If this can be done there is no need for external dlls. (However the xml manipulation is less easy).
If you run this code on a machine with the sccm console anyway you could also skip the wmi part and use Get-CMApllication from the sccm ps commandlets (contains SDMPackageXML as well) however while the dll can be moved to any computer, the cmdlets are only installed with the console so I wrote the sample without them.
I am creating items on the fly via Sitecore Web Service. So far I can create the items from this function:
AddFromTemplate
And I also tried this link: http://blog.hansmelis.be/2012/05/29/sitecore-web-service-pitfalls/
But I am finding it hard to access the fields. So far here is my code:
public void CreateItemInSitecore(string getDayGuid, Oracle.DataAccess.Client.OracleDataReader reader)
{
if (getDayGuid != null)
{
var sitecoreService = new EverBankCMS.VisualSitecoreService();
var addItem = sitecoreService.AddFromTemplate(getDayGuid, templateIdRTT, "Testing", database, myCred);
var getChildren = sitecoreService.GetChildren(getDayGuid, database, myCred);
for (int i = 0; i < getChildren.ChildNodes.Count; i++)
{
if (getChildren.ChildNodes[i].InnerText.ToString() == "Testing")
{
var getItem = sitecoreService.GetItemFields(getChildren.ChildNodes[i].Attributes[0].Value, "en", "1", true, database, myCred);
string p = getChildren.ChildNodes[i].Attributes[0].Value;
}
}
}
}
So as you can see I am creating an Item and I want to access the Fields for that item.
I thought that GetItemFields will give me some value, but finding it hard to get it. Any clue?
My advice would be to not use the VSS (Visual Sitecore Service), but write your own service specifically for the thing you want it to do.
This way is usually more efficient because you can do exactly the thing you want, directly inside the service, instead of making a lot of calls to the VSS and handle your logic on the clientside.
For me, this has always been a better solution than using the VSS.
I am assuming you are looking to find out what the fields looks like and what the field IDs are.
You can call GetXml with the ID, it returns the item and all the versions and fields set in it, it won't show fields you haven't set.
So I'm working on an IIS7 native module, and part of what it will do is process some fairly large uploaded files. I'm trying to work on ways to reduce the memory footprint of the module while doing this.
One thing I was able to do with the processed response data, which is nice, is pass open file handles to the underlying system instead of memory buffers by using the HttpDataChunkFromFileHandle chunk types. I'm trying to do the same thing with the request data, but so far no joy.
What I am doing is first I am reading all of the request data, processing it, and then setting the entity chunks in the raw HTTP_REQUEST like this:
HTTP_REQUEST* rawRequest = _context->GetRequest()->GetRawHttpRequest();
rawRequest->EntityChunkCount = 1;
rawRequest->pEntityChunks = new HTTP_DATA_CHUNK[1];
rawRequest->pEntityChunks[0].DataChunkType = HttpDataChunkFromFileHandle;
rawRequest->pEntityChunks[0].FromFileHandle.FileHandle = _requestFile.handle();
rawRequest->pEntityChunks[0].FromFileHandle.ByteRange.StartingOffset.QuadPart = 0;
rawRequest->pEntityChunks[0].FromFileHandle.ByteRange.Length.QuadPart = _requestFile.size();
and returning RQ_NOTIFICATION_CONTINUE.
This results in a 403 response from the server.
If I use a memory chunk instead, it works correctly:
char* bufferOut = static_cast<char*>(_context->AllocateRequestMemory( _requestFile.size() ));
std::memcpy( bufferOut, _requestFile.map( 0, _requestFile.size() ), _requestFile.size() );
HTTP_REQUEST* rawRequest = _context->GetRequest()->GetRawHttpRequest();
rawRequest->EntityChunkCount = 1;
rawRequest->pEntityChunks = new HTTP_DATA_CHUNK[1];
rawRequest->pEntityChunks[0].DataChunkType = HttpDataChunkFromMemory;
rawRequest->pEntityChunks[0].FromMemory.pBuffer = (PVOID)bufferOut;
rawRequest->pEntityChunks[0].FromMemory.BufferLength = _requestFile.size()
So... is HttpDataChunkFromFileHandle just not supported for request entities? Or is there something else I need to do for it to work?
Do I need to set any specific security permissions on the file?
I'm trying to create a thumbnail from a pdf in coldfusion, but no thumbnail gets created and no exception is thrown.
(coldfusion 9)
my code:
var source = "A:\testfolder\test.pdf";
var destination = "A:\testfolder\";
createImageFromPdf(source, destination);
createImageFromPdf function:
public void function createImageFromPdf(required string source, required string destination,
numeric pages = 1, string resolution = "low",
numeric scale = 100, boolean overwrite = true){
var pdf = new pdf();
pdf.setSource(arguments.source);
pdf.thumbnail(pages = arguments.pages, resolution = arguments.resolution,
scale = arguments.scale, overwrite = arguments.overwrite);
}
After running this code, i don't receive errors or exceptions, but no image was generated in A:\testfolder\
I'm probably missing something obvious here, but can't find it.
Also no log records are created in application or exception log, pdf is not protected and I'm sure that the folder is writable.
All help is appreciated.
Thanks.
You just forgot to pass along the destination
pdf.thumbnail(destination=arguments.destination
, pages = arguments.pages
, resolution = arguments.resolution
, scale = arguments.scale
, overwrite = arguments.overwrite);
I'm trying to resolve/close Dynamics CRM4 cases/incidents through webservices.
A single SetStateIncidentRequest is not enough and returns a Server was unable to process request error message. I think it has something to do with active workflows that trigger on case's attribute changes. I don't know if there's anything else preventing the request to work.
Since it is possible to close those cases through the GUI, I guess there's a "correct" set of steps to follow in order to achieve it through CrmService; unfortunately, I've been googleing it for a while without finding what I want. Could anybody help me, please?
To resolve a case in CRM (in VB.NET), I do the following:
Try
Dim activity As New incidentresolution
Dim closeRequest As New CloseIncidentRequest
Dim closeResponse As New CloseIncidentResponse
Dim strErrors As String = String.Empty()
activity.incidentid = New Lookup
activity.incidentid.type = EntityName.incident.ToString
activity.incidentid.Value = //[GUID OF INCIDENT]
activity.ownerid = New Owner
activity.ownerid.type = EntityName.systemuser.ToString
activity.ownerid.Value = //[GUID OF USER PERFORMING ACTION]
activity.statecode = New IncidentResolutionStateInfo
activity.statecode.Value = 1 //Resolved
activity.statuscode = New Status
activity.statuscode.Value = 5 //Problem Solved
closeRequest.IncidentResolution = activity
closeRequest.Status = 5 //Problem Solved
// IF REQUIRED:
activity.timespent = New CrmNumber
activity.timespent.Value = //[INTEGER REPRESENTING No. OF MIN SPENT ON CASE]
closeResponse = objCrm.Execute(closeRequest)
Catch ex As System.Web.Services.Protocols.SoapException
Dim root As XmlElement = ex.Detail
strErrors = strErrors & vbCrLf & vbCrLf & root.ChildNodes(0).ChildNodes(3).InnerText
Return False
End Try
Here's a tip - catch the SoapException and examine the Detail.OuterXML property and you will get a more detailed error message. It's possible you're not building your request correctly.
Indeed, I didn't know that there exists a CloseIncidentRequest class to use with the CrmService.Execute() method. Most probably the SetStateIncidentRequeset won't work because it's expected that incident resolutions are created that way. Pity that names for classes and actions aren't used consistently (case/incident, resolution/closing)...