registry key exists disable button - button

no matter what i do if the key is there the button dont disable and i have no idea why this is the code i have for it currently
//2012
using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Autodesk\Maya\2012"))
{
if (Key != null)
{
maya8.Text = "Maya 2012 Installed";
maya8.Enabled = false;
}
else
{
maya8.Text = "Install maya 2012";
maya8.Enabled = true;
}
}
using (RegistryKey Key = Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Autodesk\Maya\8.5"))
{
if (Key != null)
{
maya8.Text = "Maya 8.5 Installed";
maya8.Enabled = false;
}
else
{
maya8.Text = "Install maya 8.5";
maya8.Enabled = true;
}
}
}
and no matter that i do i get this issue and here is a screen of registry
image of program when launched
thank you in advance elfenliedtopfan5

See that you're referencing the local machine key, and then opening a sub key of that local machine key. The path to the sub key should be relative to the local machine key. That is, instead of the following:
Registry.LocalMachine.OpenSubKey(#"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Autodesk\Maya\8.5"))
Try this:
Registry.LocalMachine.OpenSubKey(#"SOFTWARE\Wow6432Node\Autodesk\Maya\8.5"))
The answer was discovered here by simply Googling for examples of the usage of this function!
Also note that your links aren't quite correct in your post. Check your markdown; note that you get a preview before posting!

Related

ASPNET Core 3.1 RedirectResult no longer works in Production

I have an asp.net core application that is hosted at SmarterAsp.net. Basically, I'm inserting data into a sql db with an IActionResult method (see below). After the db insert, I redirect to a page which shows the inserted data. Everything previously worked in production. Everything still works locally.
Now, when I run in Production, the NewValueArray fires, the db is updated but then I get back a "Page not found 404 error" for www.mydomain.com/SiteAssessmentValue/Index?id=##" (where ## is the route value for the assessment).
Two things have changed.
One, I updated from Core 2.2 to Core 3.1.
I also believe there have been changes by SmarterAsp.net on their servers. It only does this in production. I don't know how to troubleshoot this. Even if I change the Redirect to something innocuous like www.google.com, I get the same message.
For some reason, the RedirectResult no longer works. Any idea why that could be? I don't know how to fix something that I can't see what's failing since it only happens in production.
public IActionResult NewValueArray(int? assessmentId)
{
if (Convert.ToInt32(assessmentId) != 0)
{
var data = (
from oa in _context.OutcomeAreas
join oat in _context.OutcomeAttributes on oa.Id equals oat.OutcomeAreaId
join oas in _context.OutcomeAttributeScales on oat.Id equals oas.AttributeId
select new
{
AreaActive = oa.Active,
AttributeActive = oat.Active,
ScaleActive = oas.Active,
ScaleDescription = oas.Description,
oas.ScaleType,
oa.OrganizationId,
oas.Id
}).ToList().Where(z => z.OrganizationId == HttpContext.Session.GetInt32("curOrgId")
&& z.AreaActive == true && z.AttributeActive==true & z.ScaleActive==true);
foreach (var SiteId in data)
{
decimal curScaleFactor;
if (SiteId.ScaleType == "AA")
{
curScaleFactor = 0.2m;
}
else
{
curScaleFactor = 1.0m;
}
var entityValue = new SiteAssessmentValue
{
AssessmentId = Convert.ToInt32(assessmentId),
ItemId = SiteId.Id,
Description = SiteId.ScaleDescription,
Active = true,
ScaleFactor = curScaleFactor,
ActiveScaleFactor = 1.0m,
ModBy = HttpContext.User.Identity.Name.ToString(),
ModDate = DateTime.Now
};
// Add the entity.
_context.SiteAssessmentValue.Add(entityValue);
// Insert the entities in the database.
_context.SaveChanges();
}
// Update the SiteAssessmentValue table with the current ActiveScaleFactor
var id = new SqlParameter("#assessmentId", assessmentId);
_context.Database.ExecuteSqlRaw("EXEC savActiveScaleFactor_upd #assessmentId", id);
}
return Redirect(Url.Content("~/SiteAssessmentValues/Index?id=")+assessmentId);
}
Turns out it was an issue at the host site. They reinstalled core 3.1. Sorry for the bother.

.NET AWS SDK CreateInvalidation doesn't work

I am using this code to invalidate CloudFront Files using ASP.NET AWS SDK.
public bool InvalidateFiles(string[] arrayofpaths)
{
try
{
var client = AWSClientFactory.CreateAmazonCloudFrontClient(MY_AWS_ACCESS_KEY_ID, MY_AWS_SECRET_KEY);
CreateInvalidationResponse r = client.CreateInvalidation(new CreateInvalidationRequest
{
DistributionId = ConfigurationManager.AppSettings["DistributionId"],
InvalidationBatch = new InvalidationBatch
{
Paths = new Paths
{
Quantity = arrayofpaths.Length,
Items = arrayofpaths.ToList()
},
CallerReference = DateTime.Now.Ticks.ToString()
}
});
}
catch
{
return false;
}
return true;
}
I supplied a path like "/images/1.jpg" but it seems that the invalidation doesn't take place. I've waited half and hour and used hard refresh and cleared the cache and the image is the same. I've changed the image to look different so I can notice the difference if invalidation has occurred.
In the console I see that the invalidation took place, because I have the ID and in the status I see 'completed', but again, nothing changed in the image.
My question is how can I check that the invalidation takes place and make it work, it seems that I am missing something.
Also, is there an option to create is asynchronous, so I won't need to answer from Amazon.
Thanks.

Tridion 2009 SP1: Broker how to get Binary Url?

I am trying to retrieve the Binary Url of a multimedia component's file that is published as a dynamic Component Presentation.
I can see the Url in the Binaries table within the Broker database but I can't seem to get the binary url using either of the following bits of code:
using SQLBinaryMetaHome:
using (var sqlBinMetaHome = new Com.Tridion.Broker.Binaries.Meta.SQLBinaryMetaHome())
{
int componentItemId = int.Parse(queryStringId.Split('-')[1]);
var binaryMeta = sqlBinMetaHome.FindByPrimaryKey(new TCDURI(publicationId, 16, componentItemId));
if (binaryMeta != null)
{
VideoBinaryUrl = binaryMeta.GetURLPath();
}
else
{
Logger.Log.ErrorFormat("Failed ot load via SQL Binary Meta {0}", queryStringId);
}
}
Using Binary Meta factory:
using (var b = new BinaryMetaFactory())
{
var binaryMeta = b.GetMeta(queryStringId);
if (binaryMeta != null)
{
VideoBinaryUrl = binaryMeta.UrlPath;
}
else
{
Logger.Log.ErrorFormat("Failed to load binary meta {0}", queryStringId);
}
}
I can load the Component Meta data using the ComponentMetaFactory.
Any ideas on why I can't load the Binary Meta? Am I on the right track?
Rob
It looks like your first example is importing (auto-generated) methods from an internal DLL (Tridion.ContentDelivery.Interop.dll). Please don't use those and stick to the ones in the Tridion.ContentDelivery namespace (Tridion.ContentDelivery.dll).
You can find the official documentation for the Content Delivery .NET API in CHM format on SDL Tridion World (click the link, log in to the site and click the link again). From that documentation comes this example:
//create a new BinaryMetaFactory instance:
BinaryMetaFactory binaryMetaFactory = new BinaryMetaFactory();
//find the metadata for the specified binary
BinaryMeta binaryMeta = binaryMetaFactory.GetBinaryMeta("tcm:1-123");
//print the path to the output stream:
if(binaryMeta!=null) {
Response.Write("Path of the binary: " + binaryMeta.UrlPath);
}
//Dispose the BinaryMetaFactory
binaryMetaFactory.Dispose();
The factory class is Tridion.ContentDelivery.Meta.BinaryMetaFactory from Tridion.ContentDelivery.dll. I indeed also can't find a GetBinaryMeta method in that class, so it seems there is a mistake in the code sample. The most likely method that you should use is GetMeta.
Is there a reason you are not using a Binary Link to get a Link object to the specific Variant of the binary you want? Keep in mind that any DCP may render multiple variations of your multimedia component. From the Link object you can then get the URL to the binary.
Look for BinaryLink in the documentation for more details.
Try this:-
BinaryMeta binaryMeta = b.GetBinaryMeta(queryStringId);
if(binaryMeta != null) {
VideoBinaryUrl = binaryMeta.URLPath;
}
I did a SQL Profiler on the code and noticed that it was because I deployed my test app it wasn't calling the broker. Running the code within the actual Tridion Published site did hit the database but it was passing the value "[#def#]" for the variantId column.
I have now got it working with the following code:
IComponentMeta cm = cmf.GetMeta(queryStringId);
if (cm != null)
{
TcmId = queryStringId;
Title = cm.TryGetValue("title");
Summary = cm.TryGetValue("summary");
Product = cm.TryGetValue("product");
if (cm.SchemaId == StreamingContentSchemaId)
{
VideoId = cm.TryGetValue("video_url");
IsVimeo = true;
}
else if (cm.SchemaId == WebcastSchemaId)
{
using (var b = new BinaryMetaFactory())
{
var binaryMeta = b.GetMeta(queryStringId, "tcm:0-" + cm.OwningPublicationId + "-1");
if (binaryMeta != null)
{
VideoBinaryUrl = binaryMeta.UrlPath;
}
else
{
Logger.Log.ErrorFormat("Failed to load binary meta {0}", queryStringId);
}
}
}

ASP.Net MVC 3.0 C# How to find if a property Exists?

Hi i would like to check if a property exists?
This is my code
string abpath=null;
var hc= HttpContext.Current.Request.UrlReferrer;
if (hc.AbsolutePath !=null)
{
var _temp = HttpContext.Current.Request.UrlReferrer.AbsolutePath;
abpath = _temp.ToString();
}
I would like to Find out if AbsolutePath exists
can any one help me how to check.
right now it throws error as AbsolutePath doesn't exists to check
Thanks for your time
First you have to map the absolute path (url) to a local file system path. Then you can check whether the file exists:
var localPath = Server.MapPath(hc.AbsolutePath);
var exists = System.IO.File.Exists(localPath);
Update:
I guess I misunderstood the question. The problem is, that if your page/action/etc is called directly (e.g. by entering its URL in the browser), then there is no Referrer (previous page). So you have to first check Request.UrlReferrer for null:
if (hc != null && hc.AbsolutePath != null)
{
// ...
}
BTW: since AbsolutePath is already a string, there is no need to call ToString()on it. So you can simplify your code some more:
if (hc != null)
{
abpath = hc.AbsolutePath;
}
Check for url referrer first.
So try using code as below,
string abpath=null;
var hc= HttpContext.Current.Request.UrlReferrer;
if (hc !=null && !string.isNullOrEmpty(hc.AbsolutePath))
{
var _temp = HttpContext.Current.Request.UrlReferrer.AbsolutePath;
abpath = _temp.ToString();
}

Multiple TrackingParticipants not working, have funny side effects?

We are rying to use WF with multiple tracking participants which essentially listen to different queries - one for activity states, one for custom tracknig records which are a subclass of CustomTrackingRecord.
The problem is that we can use both TrackingParticipants indivisually, but not together - we never get our subclass from CustomTrackingRecord but A CustomTrackingRecord.
If I put bopth queries into one TrackingParticipant and then handle everythign in one, both work perfectly (which indicates teh error is not where we throw them).
The code in question for the combined one is:
public WorkflowServiceTrackingParticipant ()
{
this.TrackingProfile = new TrackingProfile()
{
ActivityDefinitionId = "*",
ImplementationVisibility = ImplementationVisibility.All,
Name = "WorkflowServiceTrackingProfile",
Queries = {
new CustomTrackingQuery() { Name = "*", ActivityName = "*" },
new ActivityStateQuery() {
States = {
ActivityStates.Canceled,
ActivityStates.Closed,
ActivityStates.Executing,
ActivityStates.Faulted
}
},
}
};
}
When using two TrackingParticipants we have two TrackingProfile (with different names) that each have one of the queries.
in the track method, when using both separate, the lines:
protected override void Track(TrackingRecord record, TimeSpan timeout)
{
Console.WriteLine("*** ActivityTracking: " + record.GetType());
if (record is ActivityBasedTrackingRecord)
{
System.Diagnostics.Debugger.Break();
}
never result in the debugger hitting, when using only the one to track our CustomTrackingRecord subclass (ActivityBasedTrackingRecord) then it works.
Anyone else knows about this? For now we have combined both TrackingParticipants into one, but this has the bad side effect that we can not dynamically expand the logging possibilities, which we would love to. Is this a known issue with WWF somewhere?
Version used: 4.0 Sp1 Feature Update 1.
I guess I encounterad the exact same problem.
This problem occurs due to the restrictions of the extension mechanism. There can be only one instance per extension type per workflow instance (according to Microsoft's documentation). Interesting enough though, one can add multiple instances of the same type to one workflow's extensions which - in case of TrackingParticipant derivates - causes weird behavior, because only one of their tracking profiles is used for all participants of the respective type, but all their overrides of the Track method are getting invoked.
There is a (imho) ugly workaround to this: derive a new participant class from TrackingParticipant for each task (task1, task2, logging ...)
Regards,
Jacob
I think that this problem isn't caused by extension mechanism, since DerivedParticipant 1 and DerivedParticipant 2 are not the same type(WF internals just use polymorphism on the base class).
I was running on the same issue, my Derived1 was tracking records that weren't described in its profile.
Derived1.TrackingProfile.Name was "Foo" and Derived2.TrackingProfile.Name was null
I changed the name from null to "Bar" and it worked as expected.
Here is a WF internal reference code, describing how is the Profile selected
// System.Activities.Tracking.RuntimeTrackingProfile.RuntimeTrackingProfileCache
public RuntimeTrackingProfile GetRuntimeTrackingProfile(TrackingProfile profile, Activity rootElement)
{
RuntimeTrackingProfile runtimeTrackingProfile = null;
HybridCollection<RuntimeTrackingProfile> hybridCollection = null;
lock (this.cache)
{
if (!this.cache.TryGetValue(rootElement, out hybridCollection))
{
runtimeTrackingProfile = new RuntimeTrackingProfile(profile, rootElement);
hybridCollection = new HybridCollection<RuntimeTrackingProfile>();
hybridCollection.Add(runtimeTrackingProfile);
this.cache.Add(rootElement, hybridCollection);
}
else
{
ReadOnlyCollection<RuntimeTrackingProfile> readOnlyCollection = hybridCollection.AsReadOnly();
foreach (RuntimeTrackingProfile current in readOnlyCollection)
{
if (string.CompareOrdinal(profile.Name, current.associatedProfile.Name) == 0 && string.CompareOrdinal(profile.ActivityDefinitionId, current.associatedProfile.ActivityDefinitionId) == 0)
{
runtimeTrackingProfile = current;
break;
}
}
if (runtimeTrackingProfile == null)
{
runtimeTrackingProfile = new RuntimeTrackingProfile(profile, rootElement);
hybridCollection.Add(runtimeTrackingProfile);
}
}
}
return runtimeTrackingProfile;
}

Resources