示例#1
0
        public void TimeBetween_DateTimeIsInRange_Start_End_ReturnsTrue()
        {
            var time    = DateTime.Parse("8:00");
            var program = new CoreFunctions();
            var result  = program.TimeBetween(time, Constants.MorningTimeRange[0], Constants.MorningTimeRange[1]);

            Assert.IsTrue(result);
        }
示例#2
0
        public void TimeBetween_DateTimeIsInRange_StartIsEnd_EndIsStart_ReturnsFalse()
        {
            var time    = DateTime.Parse("18:00");
            var program = new CoreFunctions();
            var result  = program.TimeBetween(time, Constants.AfternoonTimeRange[1], Constants.AfternoonTimeRange[0]);

            Assert.IsFalse(result);
        }
        public void Setup()
        {
            SetupShims();
            SetupShimsSplitTwo();

            testObject    = new CoreFunctions();
            privateObject = new PrivateObject(testObject);
        }
 protected void Page_Load(object sender, EventArgs e)
 {
     currentWebUrl = SPContext.Current.Web.Url;
     if (!IsPostBack)
     {
         analyticsUrl = CoreFunctions.getFarmSetting("UplandAnalyticsURL");
     }
 }
 private string iInstallPropertiesGet(string sPropertyName, bool bLockWeb)
 {
     if (bLockWeb)
     {
         return(CoreFunctions.getLockConfigSetting(oWeb, sPropertyName, false));
     }
     return(CoreFunctions.getConfigSetting(oWeb, sPropertyName));
 }
示例#6
0
        protected override void Render(HtmlTextWriter writer)
        {
            bool doNotRender = false;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite tSite = new SPSite(SPContext.Current.Web.Url))
                {
                    using (SPWeb tWeb = tSite.OpenWeb())
                    {
                        string setting = CoreFunctions.getConfigSetting(tWeb, "EPMLiveDisableCommonActions");
                        doNotRender    = !string.IsNullOrEmpty(setting) ? bool.Parse(setting) : false;
                    }
                }
            });

            if (doNotRender)
            {
                return;
            }

            SPSite site = SPContext.Current.Site;
            SPWeb  web  = SPContext.Current.Web;
            SPList commonActionsList = web.Lists.TryGetList(COMMON_ACTIONS_LIST_NAME);

            _commonActionsDataHostPageUrl = site.MakeFullUrl(web.ServerRelativeUrl) + COMMON_ACTIONS_ASYNC_DATA_PAGE;

            if (commonActionsList != null && commonActionsList.Items.Count > 0)
            {
                // render scripts and variables
                // ====================================================
                writer.Write("<script type=\"text/javascript\"> var commonActionsAsyncUrl = \"" + _commonActionsDataHostPageUrl + "\"; </script>");
                writer.Write("<script type=\"text/javascript\" src=\"" + site.MakeFullUrl(web.ServerRelativeUrl) + "/_layouts/epmlive/BtnCommonActions.js\"></script>");

                // container div
                writer.Write("<div style=\"max-width:35px;height:32px;float:right;margin-right:20px;\" >");

                // render the button
                writer.Write("<A id=\"lnkCommonActions\" title=\"Common Actions\" rel=\"tooltipbottom\" class=\"ms-socialNotif\" onclick=\"ToggleCommonActionsMenu();return false;\" href=\"javascript:;\"  style=\"width:55px\"><SPAN onlick=\"document.getElementById('lnkCommonActions').click()\"><SPAN onlick=\"document.getElementById('lnkCommonActions').click()\" style=\"POSITION: relative; WIDTH: 32px; DISPLAY: inline-block; HEIGHT: 32px; OVERFLOW: hidden\" ><IMG style=\"BORDER-BOTTOM: 0px; POSITION: absolute; BORDER-LEFT: 0px; BORDER-TOP: 0px; BORDER-RIGHT: 0px; LEFT: -409px !important; TOP:-11px;\" src=\"/_layouts/epmlive/images/epmlive-header.png\"></SPAN></SPAN></A>");

                // html for actual menu
                // ===================================================
                writer.Write("<div id=\"divCommonActionsMenu\" style=\"z-index: 103; width:200px; display:none;top:2px;left:-150px;position:relative;\" dir=\"ltr\" class=\"ms-core-menu-box ms-core-defaultFont ms-shadow\" title=\"\" ismenu=\"true\" level=\"0\" _backgroundframeid=\"msomenuid4\" flipped=\"false\" LeftForBackIframe=\"13\" TopForBackIframe=\"30\">");
                writer.Write("<div id=\"divCommonActionsMenuAsync\" >");
                // loading div
                // ========================================
                writer.Write("<div id=\"divCommonActionsLoading\" style=\"width: 100%; text-align: center;padding-top:5px;padding-bottom:5px;\">");
                writer.Write("<img src=\"/_layouts/15/images/gears_anv4.gif\" style=\"vertical-align: middle\" />");
                writer.Write("Loading...");
                writer.Write("</div>");
                // =========================================
                writer.Write("</div>");
                writer.Write("</div>");

                // container div closing tag
                writer.Write("</div>");
            }
        }
示例#7
0
        public static Guid AddTimerJob(Guid siteid, Guid webid, Guid listid, string jobname, int jobtype, string data, string key, int runtime, int scheduletype, string days)
        {
            Guid jobuid = Guid.Empty;

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(siteid))
                {
                    using (SqlConnection cn = new SqlConnection(CoreFunctions.getConnectionString(site.WebApplication.Id)))
                    {
                        try
                        {
                            cn.Open();
                            var bExists = false;
                            var status  = 0;

                            using (var sqlCommand = new SqlCommand(
                                       "SELECT status,timerjobuid from vwQueueTimer where siteguid=@siteuid and webguid=@webuid and listguid=@listuid and jobtype=@jobtype",
                                       cn))
                            {
                                sqlCommand.Parameters.AddWithValue("@siteuid", siteid);
                                sqlCommand.Parameters.AddWithValue("@webuid", webid);
                                sqlCommand.Parameters.AddWithValue("@listuid", listid);
                                sqlCommand.Parameters.AddWithValue("@jobtype", jobtype);

                                using (var dataReader = sqlCommand.ExecuteReader())
                                {
                                    if (dataReader.Read())
                                    {
                                        bExists = true;
                                        status  = dataReader.GetInt32(0);
                                        jobuid  = dataReader.GetGuid(1);
                                    }
                                }
                            }

                            if (!bExists)
                            {
                                jobuid = AddTimerJob(cn, siteid, webid, listid, null, jobname, jobtype, data, key, runtime, scheduletype, days);
                            }
                            else
                            {
                                if (status == 2)
                                {
                                    UpdateTimerJob(cn, jobuid, data, key, runtime, scheduletype, days);
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            LoggingService.WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.Webservice, TraceSeverity.Medium, ex.ToString());
                        }
                    }
                }
            });

            return(jobuid);
        }
        private static string CreateJob(string xmlData, bool enqueue)
        {
            var result               = "success";
            var xmlDataManager       = new XMLDataManager(xmlData);
            var siteId               = new Guid(xmlDataManager.GetPropVal("SiteId"));
            var webId                = new Guid(xmlDataManager.GetPropVal("WebId"));
            var listGuid             = Guid.Empty;
            var attachedItemListGuid = xmlDataManager.GetPropVal("AttachedItemListGuid");

            if (!string.IsNullOrWhiteSpace(attachedItemListGuid))
            {
                listGuid = new Guid(attachedItemListGuid);
            }
            var itemId         = -1;
            var attachedItemId = xmlDataManager.GetPropVal("AttachedItemId");

            if (!string.IsNullOrWhiteSpace(attachedItemId))
            {
                itemId = int.Parse(attachedItemId);
            }
            SPSecurity.RunWithElevatedPrivileges(
                () =>
            {
                using (var site = new SPSite(siteId))
                {
                    using (var web = site.OpenWeb(webId))
                    {
                        using (var con = new SqlConnection(CoreFunctions.getConnectionString(site.WebApplication.Id)))
                        {
                            con.Open();
                            var timerJobGuid = Guid.NewGuid();
                            var cmd          = new SqlCommand
                            {
                                CommandText =
                                    "INSERT INTO TIMERJOBS (timerjobuid, siteguid, jobtype, jobname, scheduletype, webguid, listguid, itemid, jobdata) VALUES (@timerjobuid,@siteguid, 100, 'Create Workspace', 0, @webguid, @listguid, @itemid, @jobdata)",
                                Connection = con
                            };

                            cmd.Parameters.Add(new SqlParameter("@timerjobuid", timerJobGuid));
                            cmd.Parameters.Add(new SqlParameter("@siteguid", site.ID.ToString()));
                            cmd.Parameters.Add(new SqlParameter("@webguid", web.ID.ToString()));
                            cmd.Parameters.Add(new SqlParameter("@listguid", listGuid.ToString()));
                            cmd.Parameters.Add(new SqlParameter("@itemid", itemId.ToString()));
                            cmd.Parameters.Add(new SqlParameter("@jobdata", xmlData));
                            cmd.ExecuteNonQuery();

                            if (enqueue)
                            {
                                CoreFunctions.enqueue(timerJobGuid, 0, site);
                                result = "Successfully queued create workspace job.";
                            }
                        }
                    }
                }
            });

            return(result);
        }
示例#9
0
        private bool TryGetListItemsInXml(out XmlNode data)
        {
            // link to web service documentation
            // http://msdn.microsoft.com/en-us/library/lists.lists.getlistitems%28v=office.12%29.aspx

            data = null;
            var listName = _dataManager.GetPropVal("ListName");
            var viewName = _dataManager.GetPropVal("ViewName");

            var xmlDoc = new XmlDocument();

            // create query param
            const string queryNodeName = "Query";
            var          nodeQuery     = xmlDoc.CreateNode(XmlNodeType.Element, queryNodeName, string.Empty);

            nodeQuery.InnerXml = _dataManager.GetPropVal(queryNodeName);

            // create view fields param
            const string viewFieldsName = "ViewFields";
            var          nodeViewFields = xmlDoc.CreateNode(XmlNodeType.Element, viewFieldsName, string.Empty);

            nodeViewFields.InnerXml = _dataManager.GetPropVal(viewFieldsName);

            var rowLimit = _dataManager.GetPropVal("RowLimit");

            // create query options param
            const string queryOptionsName = "QueryOptions";
            var          nodeQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, queryOptionsName, string.Empty);
            var          queryOptions     = _dataManager.GetPropVal(queryOptionsName);

            queryOptions = !string.IsNullOrWhiteSpace(queryOptions) ? queryOptions.Replace(@"\\", @"\") : string.Empty;
            nodeQueryOptions.InnerXml = !string.IsNullOrWhiteSpace(queryOptions)
                ? queryOptions
                : "<Folder>Solutions/" + CoreFunctions.GetAssemblyVersion() + "</Folder>";
            var webId = _dataManager.GetPropVal("WebID");

            using (var listSvc = new WorkEngineSolutionStoreListSvc.Lists())
            {
                // TODO: write a function to get user name and password
                listSvc.Credentials = new NetworkCredential("Solution1", @"J@(Djkhldk2", "EPM");
                listSvc.Url         = CoreFunctions.getFarmSetting("WorkEngineStore") + "_vti_bin/Lists.asmx";
                try
                {
                    ServicePointManager.ServerCertificateValidationCallback =
                        ((sender, certificate, chain, sslPolicyErrors) => true);

                    data = listSvc.GetListItems(listName, null, nodeQuery, null, rowLimit, nodeQueryOptions, null);
                }
                catch (Exception ex)
                {
                    WriteLine(ex);
                    Response.Write($"{{ error : \"{ex.Message}\" }}");
                    return(false);
                }
            }

            return(true);
        }
示例#10
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.LookLikeInspector();
            RacingGameKit.StartPointItem SPItem = target as RacingGameKit.StartPointItem;
            SPItem.name = SPItem.name;


            CoreFunctions.CreateStartPointInspector(SPItem);
        }
示例#11
0
        public void CheckPlateOnRoad_LastDigitIs5_DateIsFriday_TimeIsNoon_ReturnsCanBeOnRoad()
        {
            var date    = DateTime.Parse("06/19/2020");
            var time    = DateTime.Parse("12:00");
            var program = new CoreFunctions();
            var result  = program.CheckPlateOnRoad(5, date, time);

            Assert.AreEqual(Constants.CanBeOnRoad, result);
        }
示例#12
0
        public void ControlRemoteProcess(ControlRemoteProcessAction action)
        {
            if (!IsValid)
            {
                return;
            }

            CoreFunctions.ControlRemoteProcess(handle, action);
        }
示例#13
0
        public void CheckPlateOnRoad_LastDigitIs9_DateIsSunday_TimeIsInRange_ReturnsCanBeOnRoad()
        {
            var date    = DateTime.Parse("06/21/2020");
            var time    = DateTime.Parse("19:30");
            var program = new CoreFunctions();
            var result  = program.CheckPlateOnRoad(9, date, time);

            Assert.AreEqual(Constants.CanBeOnRoad, result);
        }
示例#14
0
 private static string GetBasePath(SPWeb web)
 {
     try
     {
         var basePath = CoreFunctions.getConfigSetting(web.Site.RootWeb, "EPKBasepath").Replace("/", "").Replace("\\", "");
         return(basePath);
     }
     catch { return(string.Empty); }
 }
示例#15
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.LookLikeInspector();
            CheckPointItem CPItem = target as CheckPointItem;

            CPItem.name = CPItem.name;

            CoreFunctions.CreateCheckPointItemInspector(CPItem);
        }
示例#16
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.LookLikeInspector();
            CheckPointManager CPManager = target as CheckPointManager;

            CPManager.name = CPManager.name;

            CoreFunctions.CreateCheckPointManagerInspector(CPManager);
        }
示例#17
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.LookLikeInspector();
            WayPointManager WPManager = target as WayPointManager;

            WPManager.name = WPManager.name;

            CoreFunctions.CreateRGKWayPointManagerInspector(WPManager);
        }
示例#18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string username = CoreFunctions.GetJustUsername(SPContext.Current.Web.CurrentUser.LoginName);
                Guid   gAuth    = Guid.NewGuid();

                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SqlConnection cn = new SqlConnection(CoreFunctions.getConnectionString(SPContext.Current.Site.WebApplication.Id));
                    cn.Open();

                    SqlCommand cmd  = new SqlCommand("spAddAuth", cn);
                    cmd.CommandType = System.Data.CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@authid", gAuth);
                    cmd.Parameters.AddWithValue("@username", username);
                    cmd.Parameters.AddWithValue("@email", SPContext.Current.Web.CurrentUser.Email);
                    cmd.ExecuteNonQuery();


                    cn.Close();
                });

                string b64 = EncodeTo64(CoreFunctions.getWebAppSetting(SPContext.Current.Site.WebApplication.Id, "epmliveapiurl") + "/integration.asmx`" + gAuth);

                string reportsurl = CoreFunctions.getConfigSetting(SPContext.Current.Web, "UplandAnalyticsUrl");
                if (string.IsNullOrEmpty(reportsurl))
                {
                    reportsurl = CoreFunctions.getFarmSetting("UplandAnalyticsUrl");
                }

                string url = "";

                if (reportsurl != "")
                {
                    url = reportsurl + "/?dbid=" + SPContext.Current.Site.WebApplication.Id + "&siteid=" + SPContext.Current.Site.ID + "&webid=" + SPContext.Current.Web.ID + "&authid=" + b64;
                }

                if (url != "")
                {
                    string rn = "";
                    try { rn = Request["rn"].ToString(); }
                    catch { }

                    if (rn != "")
                    {
                        url += "&rn=" + rn;
                    }

                    Response.Redirect(url + "&InFrame=1&RepUrl=" + System.Web.HttpUtility.UrlEncode(SPContext.Current.Web.Url + "/_layouts/epmlive/reporting/izenda/reporting.aspx"));
                }
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
        private void addWebPeriods(SPWeb web, ArrayList periods, string url)
        {
            try
            {
                web.AllowUnsafeUpdates = true;

                if (CoreFunctions.getConfigSetting(web, "EPMLiveTimePhasedURL").ToLower() == url.ToLower())
                {
                    SPList list = web.Lists["EPMLiveTimePhased"];
                    foreach (string period in periods)
                    {
                        try
                        {
                            SPField f = list.Fields.GetFieldByInternalName(period.Replace(" ", "_x0020_"));
                        }
                        catch
                        {
                            list.Fields.Add(period, SPFieldType.Number, false);
                        }
                    }

                    ArrayList arrDelFields = new ArrayList();

                    foreach (SPField f in list.Fields)
                    {
                        if (!f.Hidden && !f.Sealed && f.Type == SPFieldType.Number)
                        {
                            string fName = f.InternalName.Replace("_x0020_", " ");
                            if (!periods.Contains(fName))
                            {
                                arrDelFields.Add(fName);
                            }
                        }
                    }

                    foreach (string fName in arrDelFields)
                    {
                        list.Fields.GetFieldByInternalName(fName.Replace(" ", "_x0020_")).Delete();
                    }
                    //f.Delete();
                }
            }
            catch { }
            foreach (SPWeb w in web.Webs)
            {
                try
                {
                    addWebPeriods(w, periods, url);
                }
                catch (Exception ex) { LoggingService.WriteTrace(Area.EPMLiveCore, Categories.EPMLiveCore.Event, TraceSeverity.Medium, ex.ToString()); }
                finally { if (w != null)
                          {
                              w.Dispose();
                          }
                }
            }
        }
        /// <summary>
        ///     Gets the data from reporting DB.
        /// </summary>
        /// <param name="spWeb">The sp web.</param>
        /// <param name="data">The data.</param>
        /// <returns></returns>
        private static IEnumerable <DataTable> GetDataFromReportingDb(
            SPWeb spWeb,
            string data)
        {
            Guard.ArgumentIsNotNull(spWeb, nameof(spWeb));

            SqlDateTime dateTimeFrom;
            SqlDateTime dateTimeTo;
            bool        getCompletedItems;
            var         listIdQuery = ListIdQuery(data, out dateTimeFrom, out dateTimeTo, out getCompletedItems);

            Guid myWorkListId;
            var  theWeb    = spWeb;
            var  lockedWeb = CoreFunctions.getLockedWeb(theWeb);

            using (var configWeb = Utils.GetConfigWeb(theWeb, lockedWeb))
            {
                myWorkListId = configWeb.Lists[MyWorkText].ID;
            }

            var       tables = new List <DataTable>();
            DataTable myWorkDataTable;
            DataTable fieldsTable;
            DataTable flagsTable;
            var       siteId = spWeb.Site.ID;

            using (var myWorkReportData = new MyWorkReportData(siteId))
            {
                MapCompleteField(spWeb, myWorkReportData);

                string sql;
                var    currentUser = CurrentUser(spWeb, listIdQuery, getCompletedItems, siteId, dateTimeFrom, dateTimeTo, out sql);

                IEnumerable <string>    columns;
                IList <string>          lists;
                IEnumerable <DataTable> enumerable = null;

                if (ProcessDataTables(myWorkReportData, sql, tables, myWorkListId, out myWorkDataTable, out columns, out lists, ref enumerable))
                {
                    return(enumerable);
                }

                sql =
                    $@"SELECT ColumnName, InternalName, SharePointType, RPTListId AS ListId 
                                 FROM dbo.RPTColumn WHERE (ColumnName IN ({string.Join(Comma, columns.ToArray())})) AND (RPTListId IN ({string.Join(Comma, lists.ToArray())}))";
                fieldsTable = myWorkReportData.ExecuteSql(sql);

                sql =
                    $@"SELECT ListId, ItemId, Value FROM dbo.PERSONALIZATIONS WHERE [Key] = 'Flag' AND UserId = N'{currentUser.LoginName.ToSqlCompliant()}'";
                flagsTable            = myWorkReportData.ExecuteEpmLiveSql(sql);
                flagsTable.PrimaryKey = new[] { flagsTable.Columns[ListId], flagsTable.Columns[ItemId] };
            }

            AddTables(spWeb, myWorkDataTable, fieldsTable, flagsTable, tables);

            return(tables);
        }
 protected void Button1_OnClick(object sender, EventArgs e)
 {
     CoreFunctions.setFarmSetting("PollingInterval", txtInterval.Text);
     CoreFunctions.setFarmSetting("QueueThreads", txtMainThreads.Text);
     CoreFunctions.setFarmSetting("SecQueueThreads", txtSecurityThreads.Text);
     CoreFunctions.setFarmSetting("RollupQueueThreads", txtRollupQueueThreads.Text);
     CoreFunctions.setFarmSetting("HighQueueThreads", txtHighPriorityQueueThreads.Text);
     CoreFunctions.setFarmSetting("TSQueueThreads", txtTimesheetThreads.Text);
 }
示例#22
0
        public void Encrypt_Always_EncryptorManagedCorrectly()
        {
            // Arrange, Act
            var result = CoreFunctions.Encrypt(string.Empty, string.Empty);

            // Assert
            Assert.AreEqual(1, _cryptographyShims.EncryptorsCreated.Count);
            Assert.IsTrue(_cryptographyShims.CheckIfAllEncryptorsDisposed());
        }
示例#23
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.LookLikeInspector();
            //get the selected object the inspector is revealing
            SPItem      = target as SpawnPointItem;
            SPItem.name = SPItem.name;

            CoreFunctions.CreateRGKSpawnPointInspector(SPItem);
        }
示例#24
0
        public void Decrypt_Always_RijndaelManagedManagedCorrectly()
        {
            // Arrange, Act
            var result = CoreFunctions.Decrypt(string.Empty, string.Empty);

            // Assert
            Assert.AreEqual(1, _cryptographyShims.RijndaelManagedCreated.Count);
            Assert.IsTrue(_cryptographyShims.CheckIfAllRijindaelManagedDisposed());
        }
示例#25
0
        public void Encrypt_Always_CryptoStreamManagedCorrectly()
        {
            // Arrange, Act
            var result = CoreFunctions.Encrypt(string.Empty, string.Empty);

            // Assert
            Assert.IsTrue(_ioShims.StreamsCreated.OfType <CryptoStream>().Any());
            Assert.IsTrue(_ioShims.StreamsDisposed.OfType <CryptoStream>().Any());
        }
        protected void btnTest_Click(object sender, EventArgs e)
        {
            try
            {
                saveSettings();
                //using (SPSite site = SPContext.Current.Site)
                //{
                //    using (SPWeb web = site.RootWeb)
                //    {
                //        //NotificationsJob tjNotif = new NotificationsJob();
                //        //tjNotif.ShowGreeting = false;
                //        //tjNotif.LogDetailedErrors = true;
                //        //tjNotif.ErrorLogDetailLevel = NotificationsJob.ErrorLogDetailLevelEnum.JobLevelErrors;
                //        //tjNotif.ExecuteJob(web);

                //        //if (web.Properties.ContainsKey("epmlivenotificationlastrun"))
                //        //{
                //        //    lblLastRun.Text = web.Properties["epmlivenotificationlastrun"];
                //        //}
                //    }
                //}

                SPSite site = SPContext.Current.Site;
                {
                    using (var sqlConnection = new SqlConnection(CoreFunctions.getConnectionString(site.WebApplication.Id)))
                    {
                        SPSecurity.RunWithElevatedPrivileges(delegate { sqlConnection.Open(); });

                        var jobGuid = Guid.Empty;

                        using (var sqlCommand = new SqlCommand(
                                   "select timerjobuid from timerjobs where siteguid=@siteguid and jobtype=3",
                                   sqlConnection))
                        {
                            sqlCommand.Parameters.AddWithValue("@siteguid", site.ID.ToString());
                            using (var dataReader = sqlCommand.ExecuteReader())
                            {
                                if (dataReader.Read())
                                {
                                    jobGuid = dataReader.GetGuid(0);
                                }

                                if (jobGuid != Guid.Empty)
                                {
                                    CoreFunctions.enqueue(jobGuid, 0);
                                }
                            }
                        }
                    }
                }
                Microsoft.SharePoint.Utilities.SPUtility.Redirect("epmlive/notificationsadmin.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.RelativeToLayoutsPage, HttpContext.Current);
            }
            catch (Exception ex)
            {
                Response.Write("Error: " + ex.Message);
            }
        }
        public WEPickerDialog() : base(new WEPeopleQuery(SPContext.Current.Web.ID), new TableResultControl(), new WEPeopleEditor())
        {
            ArrayList columnDisplayNames = ((TableResultControl)base.ResultControl).ColumnDisplayNames;

            columnDisplayNames.Clear();

            ArrayList columnNames = ((TableResultControl)base.ResultControl).ColumnNames;

            columnNames.Clear();

            ArrayList columnWidths = ((TableResultControl)base.ResultControl).ColumnWidths;

            columnWidths.Clear();

            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                try
                {
                    using (SPSite site = new SPSite(SPContext.Current.Site.ID))
                    {
                        using (SPWeb web = site.OpenWeb(SPContext.Current.Web.ID))
                        {
                            string resUrl = CoreFunctions.getLockConfigSetting(web, "EPMLiveResourceURL", false);

                            Dictionary <string, string> arrCols;

                            if (resUrl.ToLower() == web.ServerRelativeUrl.ToLower())
                            {
                                arrCols = getColumns(web);
                            }
                            else
                            {
                                using (SPSite rsite = new SPSite(resUrl))
                                {
                                    using (SPWeb w = rsite.OpenWeb())
                                    {
                                        arrCols = getColumns(w);
                                    }
                                }
                            }

                            if (arrCols != null)
                            {
                                foreach (string k in arrCols.Keys)
                                {
                                    columnDisplayNames.Add(arrCols[k]);
                                    columnNames.Add(k);
                                    columnWidths.Add("180px");
                                }
                            }
                        }
                    }
                }
                catch { }
            });
        }
        /// <summary>
        ///     Sets the lists and fields.
        /// </summary>
        /// <returns></returns>
        private void SetListsAndFields()
        {
            var listsAndFields       = new Dictionary <string, List <string> >();
            var myWorkListsAndFields = new Dictionary <string, List <string> >();

            foreach (SPList spList in _web.Lists)
            {
                try
                {
                    List <string> fields =
                        (from SPField spField in spList.Fields
                         where !spField.Hidden && spField.Reorderable
                         select spField.InternalName).ToList();

                    string title = spList.Title;

                    listsAndFields.Add(title, fields);

                    if ((int)spList.BaseTemplate == MyWorkListServerTemplateId || title.Equals("My Work"))
                    {
                        myWorkListsAndFields.Add(title, fields);
                    }
                }
                catch { }
            }

            string serializedListsAndFields = listsAndFields.Aggregate(string.Empty, (current, listAndFields)
                                                                       =>
                                                                       current +
                                                                       string.Format(@"{0}:{1}|",
                                                                                     listAndFields.Key,
                                                                                     string.Join(",",
                                                                                                 listAndFields
                                                                                                 .
                                                                                                 Value
                                                                                                 .
                                                                                                 ToArray
                                                                                                     ())));

            CoreFunctions.setConfigSetting(_web, GeneralSettingsListsAndFields, serializedListsAndFields.Compress());

            string serializedMyWorkListsAndFields = myWorkListsAndFields.Aggregate(string.Empty,
                                                                                   (current, myWorkListAndFields)
                                                                                   =>
                                                                                   current +
                                                                                   string.Format(@"{0}:{1}|",
                                                                                                 myWorkListAndFields.Key,
                                                                                                 string.Join(",",
                                                                                                             myWorkListAndFields
                                                                                                             .Value.
                                                                                                             ToArray
                                                                                                                 ())));

            CoreFunctions.setConfigSetting(_web, GeneralSettingsMyWorkListsAndFields,
                                           serializedMyWorkListsAndFields.Compress());
        }
示例#29
0
        /// <summary>
        ///     Gets the archived webs.
        /// </summary>
        /// <param name="siteId">The site id.</param>
        /// <returns></returns>
        public static List <Guid> GetArchivedWebs(Guid siteId)
        {
            try
            {
                var archivedWebs = new List <Guid>();

                using (var spSite = new SPSite(siteId))
                {
                    using (
                        var sqlConnection =
                            new SqlConnection(CoreFunctions.getConnectionString(spSite.WebApplication.Id)))
                    {
                        const string QueryString =
                            "SELECT WebId FROM dbo.PERSONALIZATIONS WHERE ([Key] = 'webarchived') AND (SiteId = @siteId)";

                        using (var sqlCommand = new SqlCommand(QueryString, sqlConnection))
                        {
                            sqlCommand.Parameters.AddWithValue(AtSiteId, siteId);

                            try
                            {
                                SPSecurity.RunWithElevatedPrivileges(sqlConnection.Open);

                                var sqlDataReader = sqlCommand.ExecuteReader();

                                while (sqlDataReader.Read())
                                {
                                    archivedWebs.Add(new Guid(sqlDataReader[0].ToString()));
                                }
                            }
                            catch (SqlException sqlException)
                            {
                                Trace.WriteLine(sqlException);
                                throw new APIException(2013, sqlException.Message);
                            }
                            finally
                            {
                                sqlConnection.Close();
                            }
                        }
                    }
                }

                return(archivedWebs);
            }
            catch (APIException apiException)
            {
                Trace.WriteLine(apiException);
                throw;
            }
            catch (Exception exception)
            {
                Trace.WriteLine(exception);
                throw new APIException(2012, exception.Message);
            }
        }
示例#30
0
        public void Encrypt_Always_PasswordDeriveBytesManagedCorrectly()
        {
            // Arrange, Act
            var result = CoreFunctions.Encrypt(string.Empty, string.Empty);

            // Assert
            Assert.AreEqual(1, _cryptographyShims.DeriveBytesCreated.Count);
            Assert.IsTrue(_cryptographyShims.DeriveBytesCreated.All(pred => pred is PasswordDeriveBytes));
            Assert.IsTrue(_cryptographyShims.CheckIfAllDeriveBytesDisposed());
        }