Exemple #1
0
        private void GenerateCafeOwnerPersona()
        {
            var infoObj = PersonaInfoProvider.GetPersonaInfoByCodeName(PERSONA_CAFE_OWNER);

            if (infoObj == null)
            {
                infoObj = new PersonaInfo
                {
                    PersonaDisplayName = "Tony, the Cafe Owner",
                    PersonaName        = PERSONA_CAFE_OWNER,
                    PersonaDescription =
                        "Tony has been running his own cafe for the last 7 years. He always looks at ways of improving the service he provides.\r\n\r\nHe offers coffee that he sources from several roasteries. In addition to that, he also sells brewing machines, accessories and grinders for home use.",
                    PersonaPointsThreshold     = 15,
                    PersonaPictureMetafileGUID = new Guid("220C65BA-2CED-4347-9615-8CF69EAC20E5"),
                    PersonaEnabled             = true
                };
                PersonaInfoProvider.SetPersonaInfo(infoObj);
            }

            var treeNode = DocumentHelper.GetDocuments().All().Culture("en-US").Path("/Partnership").Columns("NodeID")
                           .OnCurrentSite().TopN(1).FirstOrDefault();

            if (treeNode != null)
            {
                var rule = GenerateRule("Visited the Partnership section", 5, infoObj.PersonaScoreID,
                                        "<condition>\r\n  <activity name=\"pagevisit\">\r\n    <field name=\"ActivityCreated\">\r\n      <settings>\r\n        <seconddatetime>1/1/0001 12:00:00 AM</seconddatetime>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityNodeID\">\r\n      <value>" +
                                        treeNode.NodeID +
                                        "</value>\r\n    </field>\r\n    <field name=\"ActivityURL\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityTitle\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityComment\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityCampaign\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityURLReferrer\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityABVariantName\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n    <field name=\"ActivityMVTCombinationName\">\r\n      <settings>\r\n        <operator>0</operator>\r\n      </settings>\r\n    </field>\r\n  </activity>\r\n  <wherecondition>(ActivityType='pagevisit') AND ([ActivityNodeID] = " +
                                        treeNode.NodeID + ")</wherecondition>\r\n</condition>", RuleTypeEnum.Activity, "pagevisit");
                rule.RuleIsRecurring = true;
                rule.RuleMaxPoints   = 15;
                RuleInfoProvider.SetRuleInfo(rule);
            }

            var infoByName = ProviderHelper.GetInfoByName("cms.form", "BusinessCustomerRegistration", _mSite.SiteID);

            if (infoByName != null)
            {
                var obj = infoByName.GetValue("FormName");
                GenerateRule("Submitted the business registration form", 15, infoObj.PersonaScoreID,
                             BuildMacroRuleCondition("{%Rule(\"(Contact.SubmittedForm(\\\"" + obj +
                                                     "\\\", ToInt(0)))\", \"&lt;rules&gt;&lt;r pos=\\\"0\\\" par=\\\"\\\" op=\\\"and\\\" n=\\\"CMSContactHasSubmittedSpecifiedFormInLastXDays\\\" &gt;&lt;p n=\\\"_perfectum\\\"&gt;&lt;t&gt;has&lt;/t&gt;&lt;v&gt;&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;select operation&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"days\\\"&gt;&lt;t&gt;#enter days&lt;/t&gt;&lt;v&gt;0&lt;/v&gt;&lt;r&gt;0&lt;/r&gt;&lt;d&gt;enter days&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;p n=\\\"item\\\"&gt;&lt;t&gt;" +
                                                     obj + "&lt;/t&gt;&lt;v&gt;" + obj +
                                                     "&lt;/v&gt;&lt;r&gt;1&lt;/r&gt;&lt;d&gt;select form&lt;/d&gt;&lt;vt&gt;text&lt;/vt&gt;&lt;tv&gt;0&lt;/tv&gt;&lt;/p&gt;&lt;/r&gt;&lt;/rules&gt;\")%}"),
                             RuleTypeEnum.Macro, null, false);
            }

            GenerateRule("Gmail penalization", -10, infoObj.PersonaScoreID,
                         "<condition>\r\n  <attribute name=\"ContactEmail\">\r\n    <value>gmail.com</value>\r\n    <params>\r\n      <ContactEmailOperator>6</ContactEmailOperator>\r\n    </params>\r\n  </attribute>\r\n  <wherecondition>[ContactEmail] LIKE N'%gmail.com'</wherecondition>\r\n</condition>",
                         RuleTypeEnum.Attribute, "ContactEmail");
        }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        headerActions.ActionPerformed += OnActionPerformed;
        headerActions.PanelCssClass    = PanelCssClass;

        // Create header actions
        var save = new SaveAction();

        headerActions.AddAction(save);

        // Print
        mPrintAction = new HeaderAction
        {
            Text        = GetString("Analytics_Report.Print"),
            Enabled     = PrintEnabled,
            ButtonStyle = ButtonStyle.Default,
        };
        headerActions.AddAction(mPrintAction);

        var cui = MembershipContext.AuthenticatedUser;

        // Report subscription enabled test
        var ri = ProviderHelper.GetInfoByName(PredefinedObjectType.REPORT, ReportName);

        if (ri != null)
        {
            var enableSubscription = ValidationHelper.GetBoolean(ri.GetValue("ReportEnableSubscription"), true);

            // Show enable subscription only for users with subscribe or modify.
            enableSubscription &= (cui.IsAuthorizedPerResource("cms.reporting", "subscribe") || cui.IsAuthorizedPerResource("cms.reporting", "modify"));

            if (enableSubscription)
            {
                // Subscription
                mSubscriptionAction = new HeaderAction
                {
                    Text        = GetString("reporting.subscribe"),
                    ButtonStyle = ButtonStyle.Default,
                };
                headerActions.AddAction(mSubscriptionAction);
            }
        }
    }
Exemple #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        objectType = UIContextHelper.GetObjectType(UIContext);
        CloneItemButton.Visible = DisplayCloneButton;

        if ((!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ResourceName, "Modify")) || (!MembershipContext.AuthenticatedUser.IsAuthorizedPerResource(ResourceName, "Create")))
        {
            CloneItemButton.ViewStateMode = ViewStateMode.Disabled;
        }

        // Pass tabindex
        int tabIndex = ValidationHelper.GetInteger(UIContext["TabIndex"], 0);

        if (tabIndex != 0)
        {
            tabIndexStr = "&tabindex=" + tabIndex;
        }

        String editElem     = ValidationHelper.GetString(UIContext["itemEdit"], String.Empty);
        String categoryElem = ValidationHelper.GetString(UIContext["categoryedit"], String.Empty);

        categoryPathColumn   = ValidationHelper.GetString(UIContext["pathColumn"], String.Empty);
        categoryParentColumn = ValidationHelper.GetString(UIContext["categoryparentcolumn"], String.Empty);
        categoryObjectType   = ValidationHelper.GetString(UIContext["parentobjecttype"], String.Empty);
        itemParentColumn     = ValidationHelper.GetString(UIContext["parentColumn"], String.Empty);
        newItem = ValidationHelper.GetString(UIContext["newitem"], String.Empty);

        if (!ValidateInput())
        {
            return;
        }

        itemLocation     = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ResourceName, editElem), "?tabslayout=horizontal&displaytitle=false");
        categoryLocation = URLHelper.AppendQuery(UIContextHelper.GetElementUrl(ResourceName, categoryElem), "?tabslayout=horizontal&displaytitle=false");

        RegisterExportScript();
        RegisterTreeScript();
        RegisterMenuScript();
        InitTree();

        // Setup menu action scripts
        String newItemText = newItem.StartsWith("javascript", StringComparison.InvariantCultureIgnoreCase) ? newItem : "NewItem('item'); return false;";

        AddButon.Actions.Add(new CMSButtonAction
        {
            Text          = GetString(objectType + ".newitem"),
            OnClientClick = newItemText
        });
        AddButon.Actions.Add(new CMSButtonAction
        {
            Text          = GetString("development.tree.newcategory"),
            OnClientClick = "NewItem('category'); return false;"
        });

        DeleteItemButton.OnClientClick = "DeleteItem(); return false;";
        ExportItemButton.OnClientClick = "ExportObject(); return false;";
        CloneItemButton.OnClientClick  = "if ((selectedItemId > 0) && (selectedItemType == 'item')) { modalDialog('" + UrlResolver.ResolveUrl("~/CMSModules/Objects/Dialogs/CloneObjectDialog.aspx?reloadall=1&displaytitle=" + UIContext["displaytitle"] + "&objecttype=" + objectType + "&objectid=") + "' + selectedItemId, 'Clone item', 750, 470); } return false;";

        // Tooltips
        DeleteItemButton.ToolTip = GetString("development.tree.deleteselected");
        ExportItemButton.ToolTip = GetString("exportobject.title");
        CloneItemButton.ToolTip  = GetString(objectType + ".clone");

        // URLs for menu actions
        String script = "var doNotReloadContent = false;\n";

        // Script for deleting widget or category
        string delPostback  = ControlsHelper.GetPostBackEventReference(this, "##");
        string deleteScript = @"
function DeleteItem() { 
    if ((selectedItemId > 0) && (selectedItemParent > 0) && confirm(" + ScriptHelper.GetLocalizedString("general.deleteconfirmation") + @")) {
        " + delPostback.Replace("'##'", "selectedItemType+';'+selectedItemId+';'+selectedItemParent") + @"
    }
}";

        script += deleteScript;

        // Preselect tree item
        if (!RequestHelper.IsPostBack())
        {
            int parentobjectid = QueryHelper.GetInteger("parentobjectid", 0);
            int objectID       = QueryHelper.GetInteger("objectID", 0);

            // Select category
            if (parentobjectid > 0)
            {
                BaseInfo biParent = ProviderHelper.GetInfoById(categoryObjectType, parentobjectid);
                if (biParent != null)
                {
                    String path     = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty);
                    int    parentID = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0);
                    script += SelectAfterLoad(path + "/", parentobjectid, "category", parentID, true, true);
                }
            }
            // Select item
            else if (objectID > 0)
            {
                BaseInfo bi = ProviderHelper.GetInfoById(objectType, objectID);
                if (bi != null)
                {
                    script += SelectItem(bi);
                }
            }
            else
            {
                // Selection by hierarchy URL
                BaseInfo biSel    = UIContext.EditedObject as BaseInfo;
                BaseInfo biParent = UIContext.EditedObjectParent as BaseInfo;

                // Check for category selection
                if ((biParent != null) && (biParent.TypeInfo.ObjectType == categoryObjectType))
                {
                    String path     = ValidationHelper.GetString(biParent.GetValue(categoryPathColumn), String.Empty);
                    int    parentID = ValidationHelper.GetInteger(biParent.GetValue(categoryParentColumn), 0);
                    script += SelectAfterLoad(path, biParent.Generalized.ObjectID, "category", parentID, false, true);
                }
                // Check for item selection
                else if ((biSel != null) && (biSel.TypeInfo.ObjectType == objectType))
                {
                    script += SelectItem(biSel);
                }
                else
                {
                    // Select root by default
                    BaseInfo bi = ProviderHelper.GetInfoByName(categoryObjectType, "/");

                    if (bi != null)
                    {
                        script += SelectAfterLoad("/", bi.Generalized.ObjectID, "category", 0, true, true);
                    }
                }
            }
        }

        ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "GeneralTree_" + ClientID, ScriptHelper.GetScript(script));
    }
    /// <summary>
    /// Imports default metafiles which were changed in the new version.
    /// </summary>
    /// <param name="upgradeFolder">Folder where the generated metafiles.xml file is</param>
    private static void ImportMetaFiles(string upgradeFolder)
    {
        try
        {
            // To get the file use Phobos - Generate files button, Metafile settings.
            // Choose only those object types which had metafiles in previous version and these metafiles changed to the new version.
            String xmlPath = Path.Combine(upgradeFolder, "metafiles.xml");
            if (File.Exists(xmlPath))
            {
                XmlDocument xDoc = new XmlDocument();
                xDoc.Load(xmlPath);

                XmlNode metaFilesNode = xDoc.SelectSingleNode("MetaFiles");
                if (metaFilesNode == null)
                {
                    return;
                }

                String filesDirectory = Path.Combine(upgradeFolder, "Metafiles");

                using (new CMSActionContext {
                    LogEvents = false
                })
                {
                    foreach (XmlNode metaFile in metaFilesNode)
                    {
                        // Load metafiles information from XML
                        if (metaFile.Attributes == null)
                        {
                            continue;
                        }

                        String objType     = metaFile.Attributes["ObjectType"].Value;
                        String groupName   = metaFile.Attributes["GroupName"].Value;
                        String codeName    = metaFile.Attributes["CodeName"].Value;
                        String fileName    = metaFile.Attributes["FileName"].Value;
                        String extension   = metaFile.Attributes["Extension"].Value;
                        String fileGUID    = metaFile.Attributes["FileGUID"].Value;
                        String title       = (metaFile.Attributes["Title"] != null) ? metaFile.Attributes["Title"].Value : null;
                        String description = (metaFile.Attributes["Description"] != null) ? metaFile.Attributes["Description"].Value : null;

                        // Try to find correspondent info object
                        BaseInfo infoObject = ProviderHelper.GetInfoByName(objType, codeName);
                        if (infoObject == null)
                        {
                            continue;
                        }

                        int infoObjectId = infoObject.Generalized.ObjectID;

                        // Check if metafile exists
                        InfoDataSet <MetaFileInfo> metaFilesSet = MetaFileInfoProvider.GetMetaFilesWithoutBinary(infoObjectId, objType, groupName, "MetaFileGUID = '" + fileGUID + "'", null);
                        if (!DataHelper.DataSourceIsEmpty(metaFilesSet))
                        {
                            continue;
                        }

                        // Create new metafile if does not exists
                        String       mfFileName = String.Format("{0}.{1}", fileGUID, extension.TrimStart('.'));
                        MetaFileInfo mfInfo     = new MetaFileInfo(Path.Combine(filesDirectory, mfFileName), infoObjectId, objType, groupName);
                        mfInfo.MetaFileGUID = ValidationHelper.GetGuid(fileGUID, Guid.NewGuid());

                        // Set correct properties
                        mfInfo.MetaFileName = fileName;
                        if (title != null)
                        {
                            mfInfo.MetaFileTitle = title;
                        }
                        if (description != null)
                        {
                            mfInfo.MetaFileDescription = description;
                        }

                        // Save new meta file
                        MetaFileInfo.Provider.Set(mfInfo);
                    }

                    // Remove existing files after successful finish
                    String[] files = Directory.GetFiles(upgradeFolder);
                    foreach (String file in files)
                    {
                        File.Delete(file);
                    }
                }
            }
        }
        catch (Exception ex)
        {
            Service.Resolve <IEventLogService>().LogException(EventLogSource, "IMPORTMETAFILES", ex);
        }
    }