Beispiel #1
0
        private void AddGoalToPiwikAndWriteToPropertyBag(PiwikPROServiceOperations pso, bool?goalTrack, string idSite, string propBagName, string goalAction, SPPropertyBag currentBag, SPWeb webToPropertyBag)
        {
            try
            {
                // if (goalTrack != null && goalTrack == true)
                // {
                // int DocumentAddedGoalId = pso.AddGoalToPiwik(idSite, goalAction);

                if (currentBag.ContainsKey(propBagName) && currentBag[propBagName] != null)
                {
                    if (String.IsNullOrEmpty(currentBag[propBagName]))
                    {
                        int DocumentAddedGoalId = pso.AddGoalToPiwik(idSite, goalAction);
                        currentBag[propBagName] = Convert.ToString(DocumentAddedGoalId);
                        currentBag.Update();
                    }
                    // currentBag[propBagName] = Convert.ToString(DocumentAddedGoalId);
                    // currentBag.Update();
                    // webToPropertyBag.Properties.Update();
                    // webToPropertyBag.Update();
                }
                else
                {
                    int DocumentAddedGoalId = pso.AddGoalToPiwik(idSite, goalAction);
                    currentBag.Add(propBagName, Convert.ToString(DocumentAddedGoalId));
                    currentBag.Update();
                }
                // }
            }
            catch (Exception ex)
            {
                //Logger.WriteLog(Logger.Category.Unexpected, "Piwik AddGoalToPiwikAndWriteToPropertyBag", ex.Message);
            }
        }
Beispiel #2
0
 private static void CreateOrUpdateValueInPropertyBag(string value, SPWeb webToPropertyBag, SPPropertyBag currentBag, string propertyBagKey)
 {
     if (currentBag.ContainsKey(propertyBagKey) && currentBag[propertyBagKey] != null)
     {
         currentBag[propertyBagKey] = value;
         currentBag.Update();
         webToPropertyBag.Properties.Update();
         webToPropertyBag.Update();
     }
     else
     {
         currentBag.Add(propertyBagKey, value);
         currentBag.Update();
     }
 }
Beispiel #3
0
        /// <summary>
        /// A site is being deleted.
        /// </summary>
        public override void SiteDeleting(SPWebEventProperties properties)
        {
            try
            {
                SPWeb         web        = properties.Web as SPWeb;
                SPPropertyBag currentBag = web.Properties;
                if (currentBag.ContainsKey(ConfigValues.PiwikPro_PropertyBag_PiwikIsTrackingActive) && currentBag[ConfigValues.PiwikPro_PropertyBag_PiwikIsTrackingActive] != null)
                {
                    string siteId             = currentBag[ConfigValues.PiwikPro_PropertyBag_SiteId];
                    string siteTitle          = string.Empty;
                    PropertyBagOperations pbo = new PropertyBagOperations();
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        // using (SPWeb web = new SPSite(ConfigValues.PiwikPro_PiwikAdminSiteUrl).OpenWeb())
                        // using (SPWeb webz = new SPSite(pbo.GetPropertyValueFromListByKey("piwik_adminsiteurl")).OpenWeb())
                        //{
                        ClientContext context = new ClientContext(pbo.GetPropertyValueFromListByKey(pbo.GetPropertyValueFromListByKey(ConfigValues.PiwikPro_PropertyBag_AdminSiteUrl)));
                        Configuration cfg     = new Configuration();
                        ListProcessor sdlo    = new ListProcessor(context, cfg, new SPLogger());
                        ListItem item         = sdlo.CheckIfElementIsAlreadyOnList(context.Web.ServerRelativeUrl);
                        if (item != null)
                        {
                            item[ConfigValues.PiwikPro_SiteDirectory_Column_Status] = ConfigValues.PiwikPro_SiteDirectory_Column_Status_Deleted;
                            siteTitle = Convert.ToString(item[ConfigValues.PiwikPro_SiteDirectory_Column_Title]);
                            item.Update();
                        }
                        //}

                        PiwikPROServiceOperations pso = new PiwikPROServiceOperations(pbo.GetPropertyValueFromListByKey(ConfigValues.PiwikPro_PropertyBag_ClientID),
                                                                                      pbo.GetPropertyValueFromListByKey(ConfigValues.PiwikPro_PropertyBag_ClientSecret),
                                                                                      pbo.GetPropertyValueFromListByKey(ConfigValues.PiwikPro_PropertyBag_OldApiToken),
                                                                                      pbo.GetPropertyValueFromListByKey(ConfigValues.PiwikPro_PropertyBag_ServiceUrl), new SPLogger());
                        pso.ChangeNameSiteInPiwik("Deleted - " + Convert.ToString(siteTitle), siteId);
                    });
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.Category.Unexpected, "Piwik WebDeleting", ex.Message);
            }

            base.SiteDeleting(properties);
        }
Beispiel #4
0
        /// <summary>
        /// Get the Blacklist Items from PropertyBag as String Array
        /// </summary>
        /// <param name="siteUrl">The Url of the Site Collection</param>
        /// <returns></returns>
        public static string[] GetBlackList(string siteUrl)
        {
            using (SPSite site = new SPSite(siteUrl))
            {
                SPPropertyBag props = site.RootWeb.Properties;

                // Property is already there
                if (props.ContainsKey(Names.PROPBAG_BLACKLIST_KEY))
                {
                    return(props[Names.PROPBAG_BLACKLIST_KEY].Split(';'));
                }
                // Property is not set -> set it from default Value
                else
                {
                    props.Add(Names.PROPBAG_BLACKLIST_KEY, string.Join(";", Names.BLACKLIST_DOCUMENTLIBRARIES));
                    props.Update();

                    return(Names.BLACKLIST_DOCUMENTLIBRARIES);
                }
            }
        }
 public bool ContainsKey(string key)
 {
     return(m_propertyBag.ContainsKey(key));
 }
Beispiel #6
0
        public override void ItemUpdated(SPItemEventProperties properties)
        {
            try
            {
                SPListItem item = properties.ListItem;
                if (item != null)
                {
                    //check if item is master file
                    if (properties.ListItem.File.Name.ToLower().EndsWith(".master"))
                    {
                        //in case of publish
                        if (Convert.ToString(properties.AfterProperties["vti_doclibmodstat"]) == Convert.ToString((int)SPModerationStatusType.Approved))
                        {
                            //in case if the list requires check out of document
                            if (properties.List.ForceCheckout)
                            {
                                AddJSToMasterFileAndCheckinAndPublish(properties, true, true);
                            }
                            else
                            {
                                AddJSToMasterFileAndCheckinAndPublish(properties, false, true);
                            }
                        }
                        //in case of upload new doc
                        else
                        {
                            //in case if the list requires check out of document
                            if (properties.List.ForceCheckout)
                            {
                                if (properties.AfterProperties["vti_sourcecontrolcheckedoutby"] == null &&
                                    properties.BeforeProperties["vti_sourcecontrolcheckedoutby"] != null)
                                {
                                    AddJSToMasterFileAndCheckinAndPublish(properties, true, false);
                                }
                            }
                            else
                            {
                                SPPropertyBag currentBag = item.Web.Properties;
                                string        docID      = item.UniqueId.ToString();
                                if ((currentBag.ContainsKey(docID) && currentBag[docID] != null) || properties.ListItem.File.Versions.Count == 0)
                                {
                                    currentBag[docID] = null;
                                    currentBag.Update();
                                    item.Web.Update();
                                    AddJSToMasterFileAndCheckinAndPublish(properties, false, false);
                                }
                                else
                                {
                                    currentBag.Add(docID, "added");
                                    currentBag.Update();
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.WriteLog(Logger.Category.Unexpected, "Piwik ItemUpdated", ex.Message);
            }

            base.ItemUpdated(properties);
        }