These are chat archives for OrchardCMS/Orchard

21st
Mar 2017
Xceno
@Xceno
Mar 21 2017 07:27
@TemperedEnterprises You should have error logs in app_data. Maybe something has changed in the module that will show up there
Jean Jordaan
@jean
Mar 21 2017 08:42
I'd like to enable a third party to link to thumbnail images in my Orchard site.
This template code
@Display.MediaUrl(Profile: "Test", Path: Url.Content("~/Media/Default/logo.png"))
results in this URL:
src="http://localhost/ams/Media/Default/_Profiles/cc127866/86efedb9/logo.jpg?v=636257065133611784"
I was hoping the URL would turn out to be guessable by the third party, so that they could request thumbnails directly
e.g. something like /Media/Default/_Profiles/PROFILENAME/logo.png ..
is there a proper Orchardy way to get this result?
Xceno
@Xceno
Mar 21 2017 09:45
nope
Jean Jordaan
@jean
Mar 21 2017 09:45
whaaaa
Xceno
@Xceno
Mar 21 2017 09:46
We had this issue too and made a workaround, but that was quite some time ago
Jean Jordaan
@jean
Mar 21 2017 09:46
OK is there a way to call Display.MediaUrl from C# code, or does it have to go via a razor template?
Xceno
@Xceno
Mar 21 2017 09:46
But @jersiovic mentioned he uses profiles a lot. So maybe he knows some magic trick
There's certainly a way, but MediaPart.MediaUrl is the raw uri
I have some code for this somewhere, gonna look it up
Jean Jordaan
@jean
Mar 21 2017 09:55
@Xceno @carlwoodhouse thanks!
@carlwoodhouse that would need to be tweaked to include handling profiles, right?
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 09:58
yeah
there is ervices in the media.processing module that could probably help you
Jean Jordaan
@jean
Mar 21 2017 09:59
OK thanks, we'll look for it
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 09:59
i think you are probably looking for IImageProfileManager
Xceno
@Xceno
Mar 21 2017 10:00

hmm @carlwoodhouse did you ever use this code inside of a caching lambda?
Something along those lines:

cacheManager.Get("MyCacheKey", context => {
     return new Lazy<ViewModel>(()=>{
                 // getting the MediaLibraryPickerField
               return field.MediaParts
     });
});

I had some weird SQL exceptions lately with caching and mediaLib fields

Carl Woodhouse
@carlwoodhouse
Mar 21 2017 10:01
this would cayse an issue i think, nhibernate disconnected state errors or so
Xceno
@Xceno
Mar 21 2017 10:01
exactly
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 10:01
in general you cant cache IContent due to this
we usually caache whatever it is we are trying to get off that
into some kind of summary object
Xceno
@Xceno
Mar 21 2017 10:05
ah nice okay thx! i couldn't figure out exactly what was going wrong; so I switched to cache my complete viewmodels instead and it went away.
Still wonder what exactly is causing this though
@jean found something
jean @jean listens :-)
Xceno
@Xceno
Mar 21 2017 10:08
I was doing this on the fly. probably not an ideal solution though.
var thumb200 = orchardServices.New.ResizeMediaUrl(
                            Width: 200,
                            Height: 200,
                            Mode: "pad",
                            PadColor: this.DominantColor,
                            Alignment: "middlecenter",
                            Path: mediaPart.MediaUrl);
                        this.MediaUrl200 = shapeDisplay.Display(thumb200);
But with resizeMediaUrl you don't need to specify profiles.
So you can have an apiController for example that spits out thumbs on the fly
but you should cache that
Jean Jordaan
@jean
Mar 21 2017 10:09
OK, and a profile would handle the caching?
I mean if we used a profile to get the thumb URL
what's shapeDisplay?
Xceno
@Xceno
Mar 21 2017 10:10
well the profile generates images in the Media/_Profiles folder. So yeah, that's kind of a cache :D
Jean Jordaan
@jean
Mar 21 2017 10:10
:ok_hand:
Xceno
@Xceno
Mar 21 2017 10:10
It's Orchard.DisplayManagement.IShapeDisplay
Jean Jordaan
@jean
Mar 21 2017 10:11
ah OK
Xceno
@Xceno
Mar 21 2017 10:12
But that code is pretty old, so better just take it as an inspiration ;)
Jean Jordaan
@jean
Mar 21 2017 10:12
OK! :-)
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 10:12
@Xceno basically it is caused by nhibernate trying to use the original state for that object when it was added to the cache, so when you try to use a property off it which would require some more sql queries it tries to use the original connection - which could be long terminated.
it's a little more complex, but essentially that
perstenmar
@perstenmar
Mar 21 2017 10:13
@carlwoodhouse My understanding was that on first run Orchard looks in Modules/"modulename"/bin/ and copies those dll files to App_data/Dependencies ? And that don't happen when I'm going through CI in VSTS, but it works when I do a publish from VS (both exclude files from App_Data folder)....
Xceno
@Xceno
Mar 21 2017 10:14
@carlwoodhouse Aha! Now it all makes sense, cause it's throwing an ObjectDisposedException
thank you!
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 10:14
where caching the viewmodels you remove that sql dependency
not surew why its not working @perstenmar if your building the precompiled target in Orchard.proj i think it actually copies them all to the root bin dir during build - but yes they should still end up in the Dependencies folder.
(we deploy from ci too)
maybe acl's arent getting set on the app_data folder or something when you deploy via ci?
Matteo Piovanelli
@MatteoPiovanelli-Laser
Mar 21 2017 13:23

migration question:
I am trying a

SchemaBuilder.AlterTable("bla", table => 
    table.AlterColumn("col", column =>
        column.WithType(DbType.Decimal)));

But that fails because the column was created like this:

SchemaBuilder.AlterTable("bla", table =>
    AddColumn<double>("col", column =>
        column.NotNull().WithDefault(-1)));

The .WithDefault(-1) seems to cause SQL server to add a default constraint to the column, so before changing the type I should do table.DropUniqueConstraint("name").

The question is: How do I get the name of the constraint at runtime (in my migration)?

a workaround I could probably use would be to drop the column and recreate it (having care to copy stuff over), but I was wondering if there was an alternative
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 14:26
other then querying sys.check_constraints (in sqlserver) im not sure
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 14:34
the feeling of moving your whole product to https-only is oddly gratifying ;)
Kaspar Kallas
@kasparkallas
Mar 21 2017 15:30
Has anyone ever implemented a multi-tenancy solution where the tenants were stored in the same tables (distinguished by tenant id column)?
Sébastien Ros
@sebastienros
Mar 21 2017 15:31
@kasparkallas no, and you can't
what you can only do is a table prefix per tenant to reuse the same database
I can't see any advantage of your question compared to table prefix
Kaspar Kallas
@kasparkallas
Mar 21 2017 15:39
I've been considering Orchard for an application with single sign-on and querying over tenants. Storing in the same tables should improve performance and comprehensibility.
Orchard not very feasible for an application like that?
Basically using multi-tenancy but it would still be one app
Sébastien Ros
@sebastienros
Mar 21 2017 15:48
No it wouldn't be faster, on the contrary.
To implement SSO you need to use an external service to handle the user accounts, for instance a different Orchard tenant. You can also use AAD or something similar.
Carl Woodhouse
@carlwoodhouse
Mar 21 2017 15:49
You'd actually be adding lots of extra data (loads of ci's to the tables) probably, which might hinder query performance. If the endgame is single sign on you might be better re-writing the authentication to use sso (maybe all provided by one tenant, or whatever sso provider you wanted)
heh ^
Sébastien Ros
@sebastienros
Mar 21 2017 15:50
Note there is an OpenId module in the dev branch, and an Azure Active Directory one too.
Kaspar Kallas
@kasparkallas
Mar 21 2017 15:51
Endgame is SSO with per tenant permissions and querying over tenants for data (dashboard, notifications, lists of stuff)
Kaspar Kallas
@kasparkallas
Mar 21 2017 15:56
Concrete example - make a GitHub-like site using @siyamandayubi https://github.com/siyamandayubi/Orchardcollaboration where the main tenant could display lists of OrchardCollaboration tenants with latest updatest
Too ambitious?
Matteo Piovanelli
@MatteoPiovanelli-Laser
Mar 21 2017 15:59
I am not sure you'd want to go multitenant there
Kaspar Kallas
@kasparkallas
Mar 21 2017 16:00
I'm sure it's not conventional
Sébastien Ros
@sebastienros
Mar 21 2017 16:02
I have done it, on weblogs.asp.net
each tenant has a common module that exposes some data through a web api. And the default tenant is the "portal" which knows about all of the tenants and will query their data using the api to display aggregated data.
SSO is handled though Microsoft Accounts
Kaspar Kallas
@kasparkallas
Mar 21 2017 16:04
Awesome
Does the portal need to keep an inner list of which tenants/endpoints to query?
Sébastien Ros
@sebastienros
Mar 21 2017 16:08
It's the default tenant, it's one tenant among the others, it owns the list of all the tenants
Kaspar Kallas
@kasparkallas
Mar 21 2017 16:08
What if I had 1000 tenants?
Sébastien Ros
@sebastienros
Mar 21 2017 16:09
you have 1000 issues
Kaspar Kallas
@kasparkallas
Mar 21 2017 16:09
Ok
So it's not meant to scale like that, right?
Sébastien Ros
@sebastienros
Mar 21 2017 16:10
you define how you want to get your data, if a push model is better suited, that's up to you, Orchard is not the limitation here, it's how you design your data exchange
weblogs.asp.net has 800 tenants
on a single Azure Large instance
Kaspar Kallas
@kasparkallas
Mar 21 2017 16:11
Very cool, good job
Sébastien Ros
@sebastienros
Mar 21 2017 16:11
but it'll depend on what your sites do
with Orchard Core you can host way more tenants though
Kaspar Kallas
@kasparkallas
Mar 21 2017 16:26
Thanks guys