コード例 #1
0
        public PortalPacketHandler(byte packetID, ushort length, PortalContext context, PortalReceive onReceive)
        {
            ID = packetID;
            Length = length;
            Context = context;

            OnReceive = onReceive;
        }
コード例 #2
0
ファイル: JsonFormatter.cs プロジェクト: kimduquan/DMIS
        protected override void WriteMultipleContent(PortalContext portalContext, List <Dictionary <string, object> > contents, int count)
        {
            var resp     = portalContext.OwnerHttpContext.Response;
            var colNames = new List <string>();

            colNames.Add("Nr.");

            ODataSimpleMeta simpleMeta = null;
            ODataFullMeta   fullMeta   = null;

            if (contents != null && contents.Count > 0)
            {
                var firstContent = contents[0];
                if (firstContent.Count > 0)
                {
                    simpleMeta = firstContent.First().Value as ODataSimpleMeta;
                    if (simpleMeta != null)
                    {
                        colNames.Add("__metadata.Uri");
                        colNames.Add("__metadata.Type");
                        fullMeta = simpleMeta as ODataFullMeta;
                        if (fullMeta != null)
                        {
                            colNames.Add("__metadata.Actions");
                            colNames.Add("__metadata.Functions");
                        }
                    }
                }
            }

            foreach (var content in contents)
            {
                foreach (var item in content)
                {
                    if (!colNames.Contains(item.Key) && item.Key != "__metadata")
                    {
                        colNames.Add(item.Key);
                    }
                }
            }

            WriteStart(resp);

            foreach (var colName in colNames)
            {
                if (colName != "__metadata")
                {
                    resp.Write("<td>" + colName + "</td>");
                }
            }
            resp.Write("</tr>\n");

            var localCount = 0;

            foreach (var content in contents)
            {
                var row = new object[colNames.Count];
                row[0] = ++localCount;

                var    colIndex = 0;
                object meta;
                if (content.TryGetValue("__metadata", out meta))
                {
                    simpleMeta = meta as ODataSimpleMeta;
                    if (simpleMeta != null)
                    {
                        colIndex = colNames.IndexOf("__metadata.Uri");
                        if (colIndex >= 0)
                        {
                            row[colIndex] = simpleMeta.Uri;
                        }
                        colIndex = colNames.IndexOf("__metadata.Type");
                        if (colIndex >= 0)
                        {
                            row[colIndex] = simpleMeta.Type;
                        }
                        fullMeta = simpleMeta as ODataFullMeta;
                        if (fullMeta != null)
                        {
                            colIndex = colNames.IndexOf("__metadata.Actions");
                            if (colIndex >= 0)
                            {
                                row[colIndex] = FormatValue(fullMeta.Actions.Where(x => !x.Forbidden).Select(x => x.Name));
                            }
                            colIndex = colNames.IndexOf("__metadata.Functions");
                            if (colIndex >= 0)
                            {
                                row[colIndex] = FormatValue(fullMeta.Functions.Where(x => !x.Forbidden).Select(x => x.Name));
                            }
                        }
                    }
                }

                foreach (var item in content)
                {
                    colIndex = colNames.IndexOf(item.Key);
                    if (colIndex >= 0)
                    {
                        row[colIndex] = item.Value;
                    }
                }
                resp.Write("      <tr>\n");

                for (int i = 0; i < row.Length; i++)
                {
                    resp.Write("        <td>");
                    WriteValue(portalContext, row[i]);
                    resp.Write("</td>\n");
                }
                resp.Write("      </tr>\n");
            }
            resp.Write("    </table>\n");
            resp.Write("  </div>\n");
            if (contents.Count != count)
            {
                resp.Write("  <div>Total count of contents: " + count + "</div>\n");
            }
            resp.Write("</body>\n");
            resp.Write("</html>\n");
        }
コード例 #3
0
ファイル: JsonFormatter.cs プロジェクト: kimduquan/DMIS
 protected override void WriteMultipleContent(PortalContext portalContext, List <Dictionary <string, object> > contents, int count)
 {
     Write(ODataMultipleContent.Create(contents, count), portalContext);
 }
コード例 #4
0
        private Dictionary <string, object> CreateFieldDictionary(Content content, PortalContext portalContext, bool isCollectionItem)
        {
            var projector = Projector.Create(this.ODataRequest, isCollectionItem, content);

            return(projector.Project(content));
        }
コード例 #5
0
        private IEnumerable <Content> ProcessODataFilters(IEnumerable <Content> inputContents, PortalContext portalContext, ODataRequest req)
        {
            var x = inputContents;

            if (req.HasFilter)
            {
                var y = x as IQueryable <Content>;
                if (y != null)
                {
                    x = y.Where((Expression <Func <Content, bool> >)req.Filter);
                }
                else
                {
                    var lambdaExpr = (LambdaExpression)req.Filter;
                    x = x.Where((Func <Content, bool>)lambdaExpr.Compile());
                }
            }
            if (req.HasSort)
            {
                x = AddSortToCollectionExpression(x, req.Sort);
            }
            if (req.HasSkip)
            {
                x = x.Skip(req.Skip);
            }
            if (req.HasTop)
            {
                x = x.Take(req.Top);
            }

            return(x);
        }
コード例 #6
0
        private List <Dictionary <string, object> > ProcessOperationDictionaryResponse(IDictionary <Content, object> input, PortalContext portalContext, ODataRequest req, out int count)
        {
            var x = ProcessODataFilters(input.Keys, portalContext, req);

            var output    = new List <Dictionary <string, object> >();
            var projector = Projector.Create(req, true);

            foreach (var content in x)
            {
                var fields = CreateFieldDictionary(content, portalContext, projector);
                var item   = new Dictionary <string, object>
                {
                    { "key", fields },
                    { "value", input[content] }
                };
                output.Add(item);
            }
            count = req.InlineCount == InlineCount.AllPages ? input.Count() : output.Count;
            if (req.CountOnly)
            {
                return(null);
            }
            return(output);
        }
コード例 #7
0
        private object ProcessOperationResponse(object response, PortalContext portalContext, ODataRequest odataReq, out int count)
        {
            var qdef = response as ChildrenDefinition;

            if (qdef != null)
            {
                return(ProcessOperationQueryResponse(qdef, portalContext, odataReq, out count));
            }

            var coll = response as IEnumerable <Content>;

            if (coll != null)
            {
                return(ProcessOperationCollectionResponse(coll, portalContext, odataReq, out count));
            }

            var dict = response as IDictionary;

            if (dict != null)
            {
                count = dict.Count;
                var targetTypized = new Dictionary <Content, object>();
                foreach (var item in dict.Keys)
                {
                    var content = item as Content;
                    if (content == null)
                    {
                        return(response);
                    }
                    targetTypized.Add(content, dict[content]);
                }
                return(ProcessOperationDictionaryResponse(targetTypized, portalContext, odataReq, out count));
            }

            // get real count from an enumerable
            var enumerable = response as IEnumerable;

            if (enumerable != null)
            {
                var c = 0;
                foreach (var x in enumerable)
                {
                    c++;
                }
                count = c;
            }
            else
            {
                count = 1;
            }

            if (response != null && response.ToString() == "{ PreviewAvailable = True }")
            {
                return(true);
            }
            if (response != null && response.ToString() == "{ PreviewAvailable = False }")
            {
                return(false);
            }
            return(response);
        }
コード例 #8
0
    /// <summary>
    /// Reload data.
    /// </summary>
    public override void ReloadData()
    {
        if (StopProcessing)
        {
            // Do nothing
            ucContactList.StopProcessing = true;
            ucIgnoreList.StopProcessing  = true;
            ucInbox.StopProcessing       = true;
            ucOutbox.StopProcessing      = true;
        }
        else
        {
            // Show content only for authenticated users
            if (AuthenticationHelper.IsAuthenticated())
            {
                // Remove 'saved' parameter from querystring
                string absoluteUri = URLHelper.RemoveParameterFromUrl(RequestContext.CurrentURL, "saved");

                // Selected page url
                string selectedPage = string.Empty;

                // Menu initialization
                tabMenu.TabControlIdPrefix = "MyMessages";
                tabMenu.UrlTarget          = "_self";

                int tabIndex        = 0;
                int inboxTabIndex   = 0;
                int outboxTabIndex  = 0;
                int contactTabIndex = 0;
                int ignoreTabIndex  = 0;

                if (DisplayInbox)
                {
                    tabMenu.AddTab(new UITabItem
                    {
                        Text        = GetString("MyMessages.Inbox"),
                        RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, TAB_INBOX),
                    });
                    inboxTabIndex = tabIndex;
                    tabIndex++;
                    selectedPage = string.IsNullOrEmpty(selectedPage) ? TAB_INBOX : selectedPage;
                }

                if (DisplayOutbox)
                {
                    tabMenu.AddTab(new UITabItem
                    {
                        Text        = GetString("MyMessages.Outbox"),
                        RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, TAB_OUTBOX),
                    });
                    outboxTabIndex = tabIndex;
                    tabIndex++;
                    selectedPage = string.IsNullOrEmpty(selectedPage) ? TAB_OUTBOX : selectedPage;
                }

                if (DisplayContactList)
                {
                    tabMenu.AddTab(new UITabItem
                    {
                        Text        = GetString("MyMessages.ContactList"),
                        RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, TAB_CONTACT),
                    });
                    contactTabIndex = tabIndex;
                    tabIndex++;
                    selectedPage = string.IsNullOrEmpty(selectedPage) ? TAB_CONTACT : selectedPage;
                }

                if (DisplayIgnoreList)
                {
                    tabMenu.AddTab(new UITabItem
                    {
                        Text        = GetString("MyMessages.IgnoreList"),
                        RedirectUrl = URLHelper.AddParameterToUrl(absoluteUri, ParameterName, TAB_IGNORE),
                    });
                    ignoreTabIndex = tabIndex;
                    selectedPage   = string.IsNullOrEmpty(selectedPage) ? TAB_IGNORE : selectedPage;
                }

                // Set css class
                pnlBody.CssClass = "MyMessages";

                // Change tabs header css class in dashboard
                if (PortalContext.GetViewMode() == ViewModeEnum.DashboardWidgets)
                {
                    pnlHeader.CssClass = "TabsHeader LightTabs";
                }

                // Get page url
                selectedPage = QueryHelper.GetText(ParameterName, selectedPage);

                // Set controls visibility
                ucInbox.Visible         = false;
                ucInbox.StopProcessing  = true;
                ucInbox.EnableViewState = false;

                ucOutbox.Visible         = false;
                ucOutbox.StopProcessing  = true;
                ucOutbox.EnableViewState = false;

                ucIgnoreList.Visible         = false;
                ucIgnoreList.StopProcessing  = true;
                ucIgnoreList.EnableViewState = false;

                ucContactList.Visible         = false;
                ucContactList.StopProcessing  = true;
                ucContactList.EnableViewState = false;

                // Select current page
                switch (selectedPage)
                {
                default:
                case TAB_INBOX:
                    tabMenu.SelectedTab     = inboxTabIndex;
                    ucInbox.Visible         = true;
                    ucInbox.StopProcessing  = false;
                    ucInbox.EnableViewState = true;
                    break;

                case TAB_OUTBOX:
                    tabMenu.SelectedTab      = outboxTabIndex;
                    ucOutbox.Visible         = true;
                    ucOutbox.StopProcessing  = false;
                    ucOutbox.EnableViewState = true;
                    break;

                case TAB_CONTACT:
                    tabMenu.SelectedTab           = contactTabIndex;
                    ucContactList.Visible         = true;
                    ucContactList.StopProcessing  = false;
                    ucContactList.EnableViewState = true;
                    break;

                case TAB_IGNORE:
                    tabMenu.SelectedTab          = ignoreTabIndex;
                    ucIgnoreList.Visible         = true;
                    ucIgnoreList.StopProcessing  = false;
                    ucIgnoreList.EnableViewState = true;
                    break;
                }
            }
            else
            {
                if (!String.IsNullOrEmpty(NotAuthenticatedMessage))
                {
                    litMessage.Text    = NotAuthenticatedMessage;
                    litMessage.Visible = true;
                    pnlBody.Visible    = false;
                }
                else
                {
                    Visible = false;
                }

                ucContactList.StopProcessing = true;
                ucIgnoreList.StopProcessing  = true;
                ucInbox.StopProcessing       = true;
                ucOutbox.StopProcessing      = true;
            }
        }
    }
コード例 #9
0
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        bool checkCollision = false;

        if (ParentZone != null)
        {
            checkCollision = ParentZone.WebPartManagementRequired;
        }
        else
        {
            checkCollision = PortalContext.IsDesignMode(ViewMode, false);
        }

        if (ScriptHelper.IsPrototypeBoxRegistered() && checkCollision)
        {
            Label lblError = new Label();
            lblError.EnableViewState = false;
            lblError.CssClass        = "ErrorLabel";
            lblError.Text            = GetString("javascript.mootoolsprototype");
            Controls.Add(lblError);
        }
        else
        {
            if (StopProcessing)
            {
                Visible = false;
            }
            else
            {
                string divScript = "<div style=\"" +
                                   "width: " + (DivWidth) + "px; " +
                                   "height: " + DivHeight + "px; " +
                                   "overflow: hidden; " +
                                   "z-index: 0; " + (DivStyle) + "\">" +
                                   "<div id=\"" + ClientID + "\" style=\"" +
                                   "width: " + (DivWidth) + "px; " +
                                   "height: " + DivHeight + "px; " +
                                   "overflow:hidden;" +
                                   "visibility:hidden;" +
                                   "position:relative;\">";

                ltlBefore.Text = divScript;
                ltlAfter.Text  = "</div></div>";

                // Register Slider javascript
                ScriptHelper.RegisterScriptFile(Page, "~/CMSWebParts/Viewers/Effects/ScrollingText_files/ScrollingText.js");

                // Build Javascript
                string jScript =
                    @"window.addEvent('load', function(){
                    try {
                        var scroller_" + ClientID + " = new Sroller('" + ClientID + "'," + JsDirection + "," + JsMoveTime + "," + JsStopTime + ",'" + JsOnMouseStop + "'," + DivWidth + "," + DivHeight + @");
                        if (scrollernodes['" + ClientID + @"'].length != 0) 
                        { 
                            startScroller(scroller_" + ClientID + "," + (JsMoveTime + JsStopTime) + @", false); 
                        } 
                    } catch (ex) {}
                });";

                ScriptHelper.RegisterClientScriptBlock(this, typeof(string), ("scrollingScript" + ClientID), ScriptHelper.GetScript(jScript));

                // Hide control based on repeater datasource and HideControlForZeroRows property
                if (!repItems.HasData())
                {
                    if (!HideControlForZeroRows)
                    {
                        lblNoData.Text    = ZeroRowsText;
                        lblNoData.Visible = true;
                    }
                    else
                    {
                        Visible = false;
                    }
                }
                else
                {
                    Visible = repItems.Visible;
                }
            }
        }
    }
コード例 #10
0
        public static Freelancer GetRefundFreelancer(Refund refund, PortalContext db)
        {
            var refundOwner = GetRefundOwner(refund, db);

            return(refundOwner == null ? null : refundOwner.Freelancer);
        }
コード例 #11
0
    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    protected void Page_Load(object sender, EventArgs e)
    {
        // Public user is not allowed for widgets
        if (!AuthenticationHelper.IsAuthenticated())
        {
            RedirectToAccessDenied(GetString("widgets.security.notallowed"));
        }

        string aliasPath = QueryHelper.GetString("aliaspath", "");

        selectElem.AliasPath      = aliasPath;
        selectElem.CultureCode    = QueryHelper.GetString("culture", LocalizationContext.PreferredCultureCode);
        selectElem.PageTemplateId = QueryHelper.GetInteger("templateid", 0);
        selectElem.ZoneId         = QueryHelper.GetString("zoneid", "");
        selectElem.ZoneType       = QueryHelper.GetString("zonetype", "").ToEnum <WidgetZoneTypeEnum>();

        // Ensure the design mode for the dialog
        if (String.IsNullOrEmpty(aliasPath))
        {
            PortalContext.SetRequestViewMode(ViewModeEnum.Design);
        }

        bool isInline = QueryHelper.GetBoolean("inline", false);

        selectElem.IsInline = isInline;

        ScriptHelper.RegisterWOpenerScript(Page);

        btnOk.OnClientClick = "SelectCurrentWidget(); return false;";

        // Base tag is added in master page
        AddBaseTag = false;

        // Proceeds the current item selection
        StringBuilder script = new StringBuilder();

        script.Append(@"
function SelectCurrentWidget() 
{                
    SelectWidget(selectedValue, selectedSkipDialog);
}
function SelectWidget(value, skipDialog)
{
    if ((value != null) && (value != ''))
    {");

        if (isInline)
        {
            script.Append(@"
        if (skipDialog) {
            AddInlineWidgetWithoutDialog(value);
        }
        else {
            var editor = wopener.currentEditor || wopener.CMSPlugin.currentEditor;
            if (editor) {
                editor.getCommand('InsertWidget').open(value);
            }

            CloseDialog(false);
        }");
        }
        else
        {
            script.Append(@"
	    if (wopener.OnSelectWidget)
        {                    
            wopener.OnSelectWidget(value, skipDialog);                      
        }

        CloseDialog();");
        }

        script.Append(@"  
	}
	else
	{
        alert(document.getElementById('", hdnMessage.ClientID, @"').value);		    
	}                
}            
// Cancel action
function Cancel()
{
    CloseDialog(false);
} ");

        ScriptHelper.RegisterStartupScript(this, typeof(string), "WidgetSelector", script.ToString(), true);
        selectElem.SelectFunction = "SelectWidget";
        selectElem.IsLiveSite     = false;

        // Set the title and icon
        PageTitle.TitleText = GetString("widgets.selectortitle");
        CurrentMaster.PanelContent.RemoveCssClass("dialog-content");

        // Remove default css class
        if (CurrentMaster.PanelBody != null)
        {
            Panel pnl = CurrentMaster.PanelBody.FindControl("pnlContent") as Panel;
            if (pnl != null)
            {
                pnl.CssClass = String.Empty;
            }
        }

        // Register scripts for inline widgets with the property 'Skip initial configuration' set (insert widget without configuration dialog)
        string skipInitialConfigurationScript = @"
// Inline widgets
function AddInlineWidgetWithoutDialog(widgetId) {
    " + Page.ClientScript.GetCallbackEventReference(this, "widgetId", "OnReceiveAddInlineWidgetScript", null) + @";
    }

function OnReceiveAddInlineWidgetScript(rvalue, context) {
    if ((rvalue != null) && (rvalue != '')) {
        setTimeout(rvalue, 1);
    }
}";

        ScriptHelper.RegisterStartupScript(this, typeof(string), "inlinewidgetsscript", skipInitialConfigurationScript, true);
    }
コード例 #12
0
    /// <summary>
    /// Saves widget properties.
    /// </summary>
    public bool Save()
    {
        if (VariantID > 0)
        {
            // Check MVT/CP security
            if (!CheckPermissions("Manage"))
            {
                DisplayError("general.modifynotallowed");
                return(false);
            }
        }

        // Save the data
        if ((CurrentPageInfo != null) && (mTemplateInstance != null) && SaveForm(formCustom))
        {
            ViewModeEnum viewMode = PortalContext.ViewMode;

            // Check manage permission for non-livesite version
            if (!viewMode.IsLiveSite() && (viewMode != ViewModeEnum.DashboardWidgets))
            {
                if (CurrentUser.IsAuthorizedPerDocument(CurrentPageInfo.NodeID, CurrentPageInfo.ClassName, NodePermissionsEnum.Modify) != AuthorizationResultEnum.Allowed)
                {
                    DisplayError("general.modifynotallowed");
                    return(false);
                }
            }

            PageTemplateInfo pti = mTemplateInstance.ParentPageTemplate;
            if (PortalContext.IsDesignMode(viewMode) && SynchronizationHelper.IsCheckedOutByOtherUser(pti))
            {
                string   userName = null;
                UserInfo ui       = UserInfo.Provider.Get(pti.Generalized.IsCheckedOutByUserID);
                if (ui != null)
                {
                    userName = HTMLHelper.HTMLEncode(ui.GetFormattedUserName(false));
                }

                DisplayError(string.Format(GetString("ObjectEditMenu.CheckedOutByAnotherUser"), pti.TypeInfo.ObjectType, pti.DisplayName, userName));
                return(false);
            }

            // Get the zone
            mWebPartZoneInstance = mTemplateInstance.EnsureZone(ZoneId);

            if (mWebPartZoneInstance != null)
            {
                mWebPartZoneInstance.WidgetZoneType = ZoneType;

                // Add new widget
                if (IsNewWidget)
                {
                    bool isLayoutZone = (QueryHelper.GetBoolean("layoutzone", false));
                    int  widgetID     = ValidationHelper.GetInteger(WidgetId, 0);

                    // Create new widget instance
                    mWidgetInstance = PortalHelper.AddNewWidget(widgetID, ZoneId, ZoneType, isLayoutZone, mTemplateInstance);
                }

                // Ensure handling of the currently edited object (if not exists -> redirect)
                UIContext.EditedObject = mWidgetInstance;

                mWidgetInstance.XMLVersion = 1;

                bool isLayoutWidget = ((mWebPartInfo != null) && ((WebPartTypeEnum)mWebPartInfo.WebPartType == WebPartTypeEnum.Layout));

                // Get basicform's datarow and update widget
                SaveFormToWidget(formCustom, mTemplateInstance, isLayoutWidget);

                // Ensure unique id for new widget variant or layout widget
                if (IsNewVariant || (isLayoutWidget && IsNewWidget))
                {
                    string controlId = GetUniqueWidgetId(mWidgetInfo.WidgetName);

                    if (!string.IsNullOrEmpty(controlId))
                    {
                        mWidgetInstance.ControlID = controlId;
                    }
                    else
                    {
                        DisplayError("Unable to generate unique widget id.");
                        return(false);
                    }
                }

                // Allow set dashboard in design mode
                if ((ZoneType == WidgetZoneTypeEnum.Dashboard) && String.IsNullOrEmpty(PortalContext.DashboardName))
                {
                    viewMode = ViewModeEnum.Design;
                    PortalContext.SetViewMode(ViewModeEnum.Design);
                }

                // Save the changes
                if ((viewMode.IsEdit(true) || viewMode.IsEditLive()) && (ZoneType == WidgetZoneTypeEnum.Editor))
                {
                    if (DocumentManager.AllowSave)
                    {
                        // Store the editor widgets in the temporary interlayer
                        PortalContext.SaveEditorWidgets(CurrentPageInfo.DocumentID, mTemplateInstance.GetZonesXML(WidgetZoneTypeEnum.Editor));
                    }
                }
                else
                {
                    // Save the changes
                    CMSPortalManager.SaveTemplateChanges(CurrentPageInfo, mTemplateInstance, ZoneType, viewMode, mTreeProvider);
                }
            }

            // Reload the form (because of macro values set only by JS)
            formCustom.ReloadData();

            // Display info message
            ShowChangesSaved();

            // Clear the cached web part
            CacheHelper.TouchKey("webpartinstance|" + InstanceGUID.ToString().ToLowerCSafe());

            return(true);
        }

        return(false);
    }
コード例 #13
0
 internal static void ContentAlreadyExists(PortalContext portalContext, string path)
 {
     throw new ODataException(SNSR.GetString(SNSR.Exceptions.OData.ContentAlreadyExists_1, path), ODataExceptionCode.ContentAlreadyExists);
 }
コード例 #14
0
ファイル: PortalRepository.cs プロジェクト: edhemaga/Portal
 public PortalRepository(PortalContext context)
 {
     this.context = context;
     entities     = context.Set <T>();
 }
コード例 #15
0
 public PortalPacketHandler(ushort packetID, PortalContext context, PortalReceive onReceive)
 {
     ID = packetID;
     Context = context;
     OnReceive = onReceive;
 }
コード例 #16
0
    protected override void OnPreRender(EventArgs e)
    {
        bool errorOccurred = !string.IsNullOrEmpty(lblError.Text);

        if (StopProcessing)
        {
            Visible = false;
        }
        else
        {
            // AllowSave property needs to be accessed to initialize the security properties in context of updated document instance - CM-815
            bool initSecurity = propertiesElem.AllowSave;

            // Render the styles link if live site mode
            if (PortalContext.ViewMode.IsLiveSite())
            {
                CSSHelper.RegisterDesignMode(Page);
            }

            pnlUpdate.Visible = !errorOccurred;

            btnLocalizeSaveClose.Visible = localizeElem.Visible && localizeElem.AllowSave;

            // Ensure correct dialog buttons
            if ((CurrentModal != null) && (((CurrentModal == mdlProperties) && (propertiesElem.Node != null)) || ((CurrentModal == mdlLocalize) && (localizeElem.Node != null))))
            {
                bool properties = (CurrentModal == mdlProperties);

                // Get workflow information
                WorkflowInfo wi = DocumentManager.Workflow;
                if (wi != null)
                {
                    if (!wi.WorkflowAutoPublishChanges)
                    {
                        if (!properties)
                        {
                            btnLocalizeSaveClose.Visible = false;
                        }
                    }
                }
            }
        }

        // Set up the captions
        btnClose1.ResourceString = btnLocalizeSaveClose.Visible ? "general.cancel" : "general.close";
        btnClose2.ResourceString = "general.close";

        if (Visible && pnlUpdate.Visible)
        {
            if (RequestHelper.IsPostBack() && (CurrentModal != null))
            {
                // Show popup after postback
                CurrentModal.Show();
            }
        }

        lblError.Visible = errorOccurred && (PortalContext.IsDesignMode(PortalContext.ViewMode));

        // Set viewstate
        pnlLocalizePopup.EnableViewState    = (CurrentDialog == pnlLocalizePopup);
        pnlCopyPopup.EnableViewState        = (CurrentDialog == pnlCopyPopup);
        pnlDeletePopup.EnableViewState      = (CurrentDialog == pnlDeletePopup);
        pnlPermissionsPopup.EnableViewState = (CurrentDialog == pnlPermissionsPopup);
        pnlVersionsPopup.EnableViewState    = (CurrentDialog == pnlVersionsPopup);
        pnlPropertiesPopup.EnableViewState  = (CurrentDialog == pnlPropertiesPopup);
    }
コード例 #17
0
 public AccountsController(PortalContext context)
 {
     _context = context;
 }
コード例 #18
0
 protected abstract void WriteOperationCustomResult(PortalContext portalContext, object result);
コード例 #19
0
        protected void WriteRaw(object response, PortalContext portalContext)
        {
            var resp = portalContext.OwnerHttpContext.Response;

            resp.Write(response);
        }
コード例 #20
0
        private List <Dictionary <string, object> > ProcessOperationQueryResponse(ChildrenDefinition qdef, PortalContext portalContext, ODataRequest req, out int count)
        {
            var cdef = new ChildrenDefinition
            {
                PathUsage            = qdef.PathUsage,
                ContentQuery         = qdef.ContentQuery,
                Top                  = req.Top > 0 ? req.Top : qdef.Top,
                Skip                 = req.Skip > 0 ? req.Skip : qdef.Skip,
                Sort                 = req.Sort != null && req.Sort.Count() > 0 ? req.Sort : qdef.Sort,
                EnableAutofilters    = req.AutofiltersEnabled != FilterStatus.Default ? req.AutofiltersEnabled : qdef.EnableAutofilters,
                EnableLifespanFilter = req.LifespanFilterEnabled != FilterStatus.Default ? req.AutofiltersEnabled : qdef.EnableLifespanFilter
            };

            var sourceCollectionItemType = typeof(Content);
            var lucQuery = SnExpression.BuildQuery(req.Filter, typeof(Content), null, cdef);
            var result   = lucQuery.Execute();
            var idResult = result.Select(x => x.NodeId);

            //var count = req.InlineCount == InlineCount.AllPages ? ExecuteQueryWithCountOnly(lucQuery, cdef.EnableAutofilters, cdef.EnableLifespanFilter) : idResult.Count();
            count = req.InlineCount == InlineCount.AllPages ? lucQuery.TotalCount : idResult.Count();

            if (req.CountOnly)
            {
                return(null);
            }

            var contents  = new List <Dictionary <string, object> >();
            var projector = Projector.Create(req, true);

            foreach (var id in idResult)
            {
                var content = Content.Load(id);
                var fields  = CreateFieldDictionary(content, portalContext, projector);
                contents.Add(fields);
            }
            return(contents);
        }
コード例 #21
0
 protected abstract void WriteServiceDocument(PortalContext portalContext, IEnumerable <string> names);
コード例 #22
0
        private List <Dictionary <string, object> > ProcessOperationCollectionResponse(IEnumerable <Content> inputContents, PortalContext portalContext, ODataRequest req, out int count)
        {
            var x = ProcessODataFilters(inputContents, portalContext, req);

            var outContents = new List <Dictionary <string, object> >();
            var projector   = Projector.Create(req, true);

            foreach (var content in x)
            {
                var fields = CreateFieldDictionary(content, portalContext, projector);
                outContents.Add(fields);
            }

            count = req.InlineCount == InlineCount.AllPages ? inputContents.Count() : outContents.Count;
            if (req.CountOnly)
            {
                return(null);
            }
            return(outContents);
        }
コード例 #23
0
        //----------------------------------------------------------------------------------------------------------------------------------- contents

        internal void WriteSingleContent(String path, PortalContext portalContext)
        {
            WriteSingleContent(ODataHandler.LoadContentByVersionRequest(path), portalContext);
        }
コード例 #24
0
 private Dictionary <string, object> CreateFieldDictionary(Content content, PortalContext portalContext, Projector projector)
 {
     return(projector.Project(content));
 }
コード例 #25
0
 protected abstract void WriteSingleContent(PortalContext portalContext, Dictionary <string, object> fields);
コード例 #26
0
    /// <summary>
    /// Handles reset button click. Resets zones of specified type to default settings.
    /// </summary>
    protected void btnReset_Click(object sender, EventArgs e)
    {
        // Disable the reset action when document editing is not allowed (i.e. non-editable workflow step)
        if (!WidgetActionsEnabled)
        {
            resetAllowed = false;
        }

        // Security check
        if (!DisplayResetButton || !resetAllowed)
        {
            return;
        }

        PageInfo pi = CurrentPageInfo;

        if (pi == null)
        {
            return;
        }

        if ((zoneType == WidgetZoneTypeEnum.Editor) || (zoneType == WidgetZoneTypeEnum.Group))
        {
            // Clear document webparts/group webparts
            TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider);

            if (node != null)
            {
                bool updateDocument = true;

                if (zoneType == WidgetZoneTypeEnum.Editor)
                {
                    if (ViewMode.IsEdit(true) || ViewMode.IsEditLive())
                    {
                        // Do not save the document to the database, keep it in only in the memory
                        updateDocument = false;

                        // Get the default template widgets
                        PortalContext.SaveEditorWidgets(pi.DocumentID, pi.UsedPageTemplateInfo.TemplateInstance.GetZonesXML(WidgetZoneTypeEnum.Editor));
                    }
                    else
                    {
                        node.SetValue("DocumentWebParts", String.Empty);
                    }

                    // Delete all variants
                    if (pi.UsedPageTemplateInfo != null)
                    {
                        foreach (WebPartZoneInstance zoneInstance in zoneInstances)
                        {
                            if (zoneInstance.WebPartsContainVariants)
                            {
                                VariantHelper.DeleteWidgetVariants(zoneInstance.ZoneID, pi.UsedPageTemplateInfo.PageTemplateId, node.DocumentID);
                            }
                        }
                    }
                }
                else if (zoneType == WidgetZoneTypeEnum.Group)
                {
                    node.SetValue("DocumentGroupWebParts", String.Empty);
                }

                if (updateDocument)
                {
                    // Save the document
                    DocumentHelper.UpdateDocument(node, TreeProvider);
                }
            }
        }
        else if (zoneType == WidgetZoneTypeEnum.User)
        {
            // Delete user personalization info
            PersonalizationInfo up = PersonalizationInfoProvider.GetUserPersonalization(MembershipContext.AuthenticatedUser.UserID, pi.DocumentID);
            PersonalizationInfoProvider.DeletePersonalizationInfo(up);

            // Clear cached values
            TreeNode node = DocumentHelper.GetDocument(pi.DocumentID, TreeProvider);
            if (node != null)
            {
                CacheHelper.TouchKeys(TreeProvider.GetDependencyCacheKeys(node, SiteContext.CurrentSiteName));
            }
        }
        else if (zoneType == WidgetZoneTypeEnum.Dashboard)
        {
            // Delete user personalization info
            PersonalizationInfo up = PersonalizationInfoProvider.GetDashBoardPersonalization(MembershipContext.AuthenticatedUser.UserID, PortalContext.DashboardName, PortalContext.DashboardSiteName);
            PersonalizationInfoProvider.DeletePersonalizationInfo(up);

            // Clear cached page template
            if (pi.UsedPageTemplateInfo != null)
            {
                CacheHelper.TouchKey("cms.pagetemplate|byid|" + pi.UsedPageTemplateInfo.PageTemplateId);
            }
        }

        // Make redirect to see changes after load
        string url = RequestContext.CurrentURL;

        if (ViewMode.IsEdit(true) || ViewMode.IsEditLive())
        {
            // Ensure that the widgets will be loaded from the session layer (not from database)
            url = URLHelper.UpdateParameterInUrl(url, "cmscontentchanged", "true");
        }

        URLHelper.Redirect(url);
    }
コード例 #27
0
 protected abstract void WriteMultipleContent(PortalContext portalContext, List <Dictionary <string, object> > contents, int count);
コード例 #28
0
ファイル: JsonFormatter.cs プロジェクト: kimduquan/DMIS
 protected override void WriteCount(PortalContext portalContext, int count)
 {
     WriteRaw(count, portalContext);
 }
コード例 #29
0
 protected abstract void WriteCount(PortalContext portalContext, int count);
コード例 #30
0
ファイル: JsonFormatter.cs プロジェクト: kimduquan/DMIS
 protected override void WriteServiceDocument(PortalContext portalContext, IEnumerable <string> names)
 {
     throw new NotImplementedException();
 }
コード例 #31
0
        internal void WriteContentProperty(String path, string propertyName, bool rawValue, PortalContext portalContext, ODataRequest req)
        {
            var content = ODataHandler.LoadContentByVersionRequest(path);

            if (content == null)
            {
                ODataHandler.ContentNotFound(portalContext.OwnerHttpContext, path);
                return;
            }

            if (propertyName == ODataHandler.PROPERTY_ACTIONS)
            {
                var backUrl = portalContext.BackUrl;

                //Get actions without back url: let the client append the back parameter,
                //as we are in a service here that does not know about the redirect url.
                var snActions = ODataHandler.ActionResolver.GetActions(content, req.Scenario, string.IsNullOrEmpty(backUrl) ? null : backUrl);

                var actions = snActions.Where(a => a.IsHtmlOperation).Select(a => new ODataActionItem
                {
                    Name           = a.Name,
                    DisplayName    = SNSR.GetString(a.Text),
                    Icon           = a.Icon,
                    Index          = a.Index,
                    Url            = a.Uri,
                    IncludeBackUrl = a.GetApplication() == null ? 0 : (int)a.GetApplication().IncludeBackUrl,
                    ClientAction   = a is ClientAction && !string.IsNullOrEmpty(((ClientAction)a).Callback),
                    Forbidden      = a.Forbidden
                });
                WriteActionsProperty(portalContext, actions.ToArray(), rawValue);
                return;
            }

            Field field;

            if (content.Fields.TryGetValue(propertyName, out field))
            {
                var refField = field as ReferenceField;
                if (refField != null)
                {
                    var refFieldSetting = refField.FieldSetting as ReferenceFieldSetting;
                    var isMultiRef      = true;
                    if (refFieldSetting != null)
                    {
                        isMultiRef = refFieldSetting.AllowMultiple == true;
                    }
                    if (isMultiRef)
                    {
                        WriteMultiRefContents(refField.GetData(), portalContext, req);
                    }
                    else
                    {
                        WriteSingleRefContent(refField.GetData(), portalContext);
                    }
                }
                else if (!rawValue)
                {
                    WriteSingleContent(portalContext, new Dictionary <string, object> {
                        { propertyName, field.GetData() }
                    });
                }
                else
                {
                    WriteRaw(field.GetData(), portalContext);
                }
            }
            else
            {
                //ResourceNotFound(content, propertyName);
                WriteOperationResult(portalContext, req);
            }
        }
コード例 #32
0
ファイル: PortalClient.cs プロジェクト: Vita-Nex/Multiverse
        public PortalPacketHandler Register(ushort id, PortalContext context, PortalReceive onReceive)
        {
            lock (((ICollection)Handlers).SyncRoot)
            {
                if (Handlers.ContainsKey(id))
                {
                    ToConsole("Warning: Replacing Packet Handler for {0}", id);
                }

                return Handlers[id] = new PortalPacketHandler(id, context, onReceive);
            }
        }
コード例 #33
0
 protected abstract void WriteActionsProperty(PortalContext portalContext, ODataActionItem[] actions, bool raw);
コード例 #34
0
ファイル: BaseService.cs プロジェクト: gabrielfds/aurant
 /// <summary>
 /// Receives the context and sets to internal context property
 /// </summary>
 /// <param name="context"></param>
 public BaseService(PortalContext context)
 {
     this.context = context;
 }
コード例 #35
0
ファイル: PortalClient.cs プロジェクト: Crome696/Multiverse
 public PortalPacketHandler Register(byte id, ushort length, PortalContext context, PortalReceive onReceive)
 {
     lock (((ICollection)Handlers).SyncRoot)
     {
         return Handlers[id] = new PortalPacketHandler(id, length, context, onReceive);
     }
 }