Free Support Forum - groupdocs.com

Annotation Subscription Problem

Hello,

I’m trying to implement annotation subscriptions for tracing who made what with annotation and who comments on annotations. First i tried it in our project. Until now we were running annotations under guest account. When you made a change it saved as guest. Now we want to implement subscription to tracing. I’m doing it like below, after annotation control created.

private bool LoadAnnotationMode(Stream stream, string filename)
{
container.Attributes.Add(“IsAnnotation”, “1”);
        <span style="color:#2b91af;">Control</span> ph = <span style="color:blue;">this</span>.Page.FindControl(<span style="color:#a31515;">"phViewerScripts"</span>);
        ph.Controls.Clear();
        ph.Controls.Add(<span style="color:blue;">new</span> <span style="color:#2b91af;">LiteralControl</span>(<span style="color:blue;">new</span> <span style="color:#2b91af;">WidgetFactory</span>().AnnotationScripts().UseHttpHandlers(<span style="color:blue;">true</span>).ToString()));

        <span style="color:blue;">var</span> annotate = <span style="color:blue;">new</span> <span style="color:#2b91af;">WidgetFactory</span>().Annotation()
            .Stream(stream, filename)
            .AccessRights(Rights)
            .AnyToolSelection(AnyToolSelection)
            .ClickableAnnotations(ClickableAnnotations)
            .ElementId(<span style="color:#a31515;">"divHTML5ViewerContainer"</span>)
            .EnableRightClickMenu(<span style="color:blue;">false</span>)<span style="color:green;">// default browser sağ tık menüsü açıyor. Sabit false değeri olacak.</span>
            .EnableSidePanel(EnableSidePanel)
            .EnableTabNavigation(EnableTabNavigation)
            .EnableTextSelection(EnableTextSelection)
            .EnableTooltips(EnableTooltips)
            .EnableUndo(EnableUndo)
            .OpenThumbnails(OpenThumbnails)
            .PreloadPageCount(PreloadPagesCount)
            .PrinterSetup(<span style="color:#2b91af;">PrintViewComponents</span>.All)
            .SaveReplyOnFocusLoss(SaveReplyOnFocusLoss)
            .ScrollOnFocus(ScrollOnFocus)
            .ShowFileExplorer(<span style="color:blue;">false</span>)<span style="color:green;">//default false</span>
            .ShowHeader(ShowHeader)
            .ShowPaging(ShowPaging)
            .ShowPrint(ShowPrint && hasPrintPermission)
            .ShowThumbnails(ShowThumbnails)
            .ShowToolbar(ShowToolbar)
            .ShowZoom(ShowZoom);
        <span style="color:blue;">if</span> (ZoomMode.Equals(<span style="color:#a31515;">"FitToWidth"</span>, <span style="color:#2b91af;">StringComparison</span>.InvariantCultureIgnoreCase))
        {
            annotate.ZoomToFitWidth(<span style="color:blue;">true</span>);
        }
        <span style="color:blue;">else</span>
        {
            annotate.ZoomToFitHeight(<span style="color:blue;">true</span>);
        }

        <span style="color:blue;">if</span> (<span style="color:blue;">string</span>.IsNullOrWhiteSpace(Locale))
        {
            <span style="color:blue;">string</span> userLang = <span style="color:#2b91af;">WebUtilities</span>.GetUserLanguage();
            <span style="color:blue;">string</span> defaultLang = <span style="color:#2b91af;">MultiLanguageWeb</span>.MultiLanguageDictionary.DefaultLanguage;
            <span style="color:blue;">string</span> lang = supportedLocales.ContainsKey(userLang) ? userLang : (supportedLocales.ContainsKey(defaultLang) ? defaultLang : <span style="color:blue;">string</span>.Empty);

            <span style="color:blue;">if</span> (!<span style="color:blue;">string</span>.IsNullOrEmpty(lang) && supportedLocales.ContainsKey(lang))
            {
                annotate.Locale(supportedLocales[lang]);
            }
        }
        <span style="color:blue;">else</span>
        {
            annotate.Locale(Locale);
        }

        container.InnerHtml = annotate.ToHtmlString();
        container.Attributes.Add(<span style="color:#a31515;">"IsLoaded"</span>, <span style="color:#a31515;">"1"</span>);

        <span style="color:#2b91af;">IAnnotationService</span> svc = <span style="color:#2b91af;">ObjectFactory</span>.GetInstance<<span style="color:#2b91af;">IAnnotationService</span>>();
        svc.AddCollaborator(filename, <span style="color:#2b91af;">Globals</span>.User.Email, <span style="color:#2b91af;">Globals</span>.User.FirstName, <span style="color:#2b91af;">Globals</span>.User.LastName, <span style="color:blue;">null</span>);


        <span style="color:blue;">return</span> <span style="color:blue;">true</span>;
    }</pre>When i control the database tables(Users and AnnotationCollabrators tables) datas are correct as it should be. But still when i made a comment or, reply a comment it still do it as guest.<br><br>After that i thought i'm missing something and i found your example for using annotation and viewer together. In that demo you use Anonym A. user and it works great then i changed it as <br><pre style="font-family:Consolas;font-size:13;color:black;background:white;">svc.AddCollaborator(<span style="color:#a31515;">"candy.pdf"</span>, <span style="color:#a31515;">"groupdocs2@groupdocs.com"</span>, <span style="color:#a31515;">"Anonym2"</span>, <span style="color:#a31515;">"A2."</span>, <span style="color:blue;">null</span>); <span style="color:green;">// allow anonymous users to annotate on a document<br></span></pre>Then i tried it again but the results are the same. It still make comments as Anonym A. not Anonym2 A2.<br><br>I tried to clear browser history but it didn't solve the problem.<br><br>You can download demo project from <a rel="nofollow" href="https://www.dropbox.com/s/z8gnkqubz36yaw7/ViewerAndAnnotationWebForms.rar?dl=0">here</a>, you can check it from demo.<br>Am i doing it wrong or what am i missing?<br><br>Kind regards,<br>

Hello,


We are sorry to hear that you have such issue. I have checked and fixed your solution, please download it here .

Investigate it carefully and pay attention that the user name is a URL parameter, since that to set or change it you should use “un” property.
For example: http:\localhost\annotation?un=Bob

Best regards.

Hello,

Thank you for your help. It worked, cookie is mandatory i guess?

Kind Regards

Hi,


Glad to hear that. Yes, cookie is mandatory because of using SignalR.

Best regards.

Hello again,

Your solution is worked but in our project i’m facing with different problem. It’s related with this one so i’m writing it in here.

Now i can manage to change to commented user guest to real user. Now when i comment it shows username. But unfortunately if i reopen annotation for same document it changes showing names in comments as guest again. Then i look database, in the datas userid is always null. Thats why when i reopen annotaion they automaticly change to guest.

I inspect your exaple a few time but i cant found what is missing. I do everything, AuthenticationService class, membership provider class, add cookie. But when i make annotaion, icant set the userid. Do you have any idea what could cause it. I cant share our project unfortunately

Hello again,

Sorry for false alarm :smiley:

I found the reason. When i writing Authentication Service class i need to override only username property. But i was overrided userkey property too. Then i removed it it worked, probably annotation handle userkey itself

Hi,


Can you please share with me the GroupDocs.Annotation code which you use after update - for example make same changes to the example project that I shared. Also which DB you use is it SQL Compact (default) or some other?

Thank you.

Thank you for your help and offer,

But it works now. It was my mistake.

Kind regards,

Great, glad to hear that.


Best regards.