Esempio n. 1
0
        /// <summary>
        /// Shortcut method for creating a simple 'upsert' command by adding an
        /// ON CONFLICT DO UPDATE clause to the insert statement. Any columns
        /// included in the conflict statement will be exclude from the UPDATE's
        /// SET clause. This method only supports columns as the ON CONFLICT target.
        /// For more control over how the update will be preformed, use the
        /// <see cref="OnConflict(Insert, IEnumerable{ISqlElement}, Update)"/>
        /// method instead and supply your own update command.
        /// </summary>
        /// <param name="insert">The insert action to add to.</param>
        /// <param name="onConflict">The ON CONFLICT columns for this statement</param>
        /// <returns>A Postgres-type INSERT statement with the specified clause.</returns>
        /// <remarks>
        /// If no addition columns besides the ON CONFLICT columns are included
        /// in the source update's column list, an ON CONFLICT DO NOTHING command
        /// will be created instead.
        /// </remarks>
        public static PostgresInsert OnConflictUpdate(this Insert insert, params Column[] onConflict)
        {
            var assignments = insert.Columns
                              .Zip(insert.Values, (c, v) => new Assignment(c, v))
                              .Where(set =>
            {
                if (set.Target is Column column &&
                    onConflict.Any(c => c.Name == column.Name))
                {
                    return(false);
                }
                return(true);
            });

            var assignmentCollection = new AssignmentCollection(assignments);

            if (!assignmentCollection.Any())
            {
                return(insert.OnConflictDoNothing());
            }

            return(new PostgresInsert(insert)
            {
                OnConflict = new PostgresOnConflict
                {
                    Target = new ColumnCollection {
                        onConflict
                    },
                    DoUpdate = new Update
                    {
                        Set = assignmentCollection
                    }
                }
            });
        }
        protected override IEnumerable <PageLayout> RetrieveDataObjects()
        {
            List <PageLayout> layouts = new List <PageLayout>();

            SPWeb web = null;

            if (Web != null)
            {
                web = Web.Read();

                if (!PublishingWeb.IsPublishingWeb(web))
                {
                    throw new ArgumentException("The specified web is not a publishing web.");
                }

                AssignmentCollection.Add(web);
                AssignmentCollection.Add(web.Site);
            }

            switch (ParameterSetName)
            {
            case "PageLayout":
                foreach (SPPageLayoutPipeBind pipeBind in PageLayout)
                {
                    PageLayout    layout = pipeBind.Read(web);
                    SPContentType ct1    = null;
                    if (AssociatedContentType != null)
                    {
                        ct1 = AssociatedContentType.Read(layout.ListItem.Web);
                    }
                    if (ct1 == null || ct1.Id == layout.AssociatedContentType.Id)
                    {
                        WriteResult(layout);
                    }
                }
                break;

            case "SPWeb":
                PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);
                SPContentType ct2    = null;
                if (AssociatedContentType != null)
                {
                    ct2 = AssociatedContentType.Read(web);
                }
                if (ct2 == null)
                {
                    WriteResult(pubWeb.GetAvailablePageLayouts());
                }
                else
                {
                    WriteResult(pubWeb.GetAvailablePageLayouts(ct2.Id));
                }
                break;

            default:
                break;
            }

            return(null);
        }
        protected override IEnumerable <SPFile> RetrieveDataObjects()
        {
            foreach (SPFilePipeBind filePipe in Identity)
            {
                SPFile file = filePipe.Read();
                AssignmentCollection.Add(file.Web);
                AssignmentCollection.Add(file.Web.Site);
                WriteResult(file);
            }

            return(null);
        }
        protected override IEnumerable <SPLimitedWebPartManager> RetrieveDataObjects()
        {
            List <SPLimitedWebPartManager> managers = new List <SPLimitedWebPartManager>();

            if (base.DataObject != null)
            {
                managers.Add(base.DataObject);
                AssignmentCollection.Add(base.DataObject.Web);
                AssignmentCollection.Add(base.DataObject.Web.Site);

                return(managers);
            }

            return(managers);
        }
Esempio n. 5
0
        protected override IEnumerable <object> RetrieveDataObjects()
        {
            List <object> customizedPages = new List <object>();

            switch (ParameterSetName)
            {
            case "SPWeb":
                foreach (SPWebPipeBind webPipe in Web)
                {
                    SPWeb web = webPipe.Read();

                    if (Recurse.IsPresent)
                    {
                        Common.Pages.EnumUnGhostedFiles.RecurseSubWebs(web, ref customizedPages, AsString.IsPresent);
                    }
                    else
                    {
                        Common.Pages.EnumUnGhostedFiles.CheckFoldersForUnghostedFiles(web.RootFolder, ref customizedPages, AsString.IsPresent);
                    }
                }
                break;

            case "SPSite":
                foreach (SPSitePipeBind sitePipe in Site)
                {
                    SPSite site = sitePipe.Read();
                    Common.Pages.EnumUnGhostedFiles.RecurseSubWebs(site.RootWeb, ref customizedPages, AsString.IsPresent);
                }
                break;
            }

            foreach (object page in customizedPages)
            {
                if (!AsString.IsPresent)
                {
                    AssignmentCollection.Add(((SPFile)page).Web);
                    AssignmentCollection.Add(((SPFile)page).Web.Site);
                }
                WriteResult(page);
            }

            return(null);
        }
Esempio n. 6
0
        protected override IEnumerable <SPList> RetrieveDataObjects()
        {
            List <SPList> lists = new List <SPList>();
            SPWeb         web   = null;

            if (this.Web != null)
            {
                web = this.Web.Read();
            }

            if (Identity == null && ParameterSetName != "AllListsByType")
            {
                foreach (SPList list in web.Lists)
                {
                    lists.Add(list);
                }
            }
            else if (Identity == null && ParameterSetName == "AllListsByType")
            {
                foreach (SPList list in web.GetListsOfType(ListType))
                {
                    lists.Add(list);
                }
            }
            else
            {
                SPList list = this.Identity.Read(web);
                if (list != null)
                {
                    lists.Add(list);
                }
            }

            AssignmentCollection.Add(web);
            foreach (SPList list1 in lists)
            {
                AssignmentCollection.Add(list1.ParentWeb);
                AssignmentCollection.Add(list1.ParentWeb.Site);
            }

            return(lists);
        }
        public void GetAssignmentsByUserTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.AssignedTo = "testing";
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentsByUser("testing");

            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp), "The new assignment collection did not contain the same data as the original");
            }
            Assert.IsTrue(tempAssignmentCol2.Count >= tempAssignmentCol.Count);
        }
        public void GetAssignmentsByTicketIdTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.TicketId = 0;
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentsByTicketId(0);
            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp));
            }

            Assert.IsTrue(tempAssignmentCol2.Count == tempAssignmentCol.Count);
        }
        public void GetAssignmentsByTicketIdTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.TicketId = 0;
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentsByTicketId(0);

            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp));
            }

            Assert.IsTrue(tempAssignmentCol2.Count == tempAssignmentCol.Count);
        }
Esempio n. 10
0
        public void GetAssignmentsByUserAndActiveTest()
        {
            AssignmentCollection tempAssignmentCol = new AssignmentCollection();

            //Create a new assignment, insert it into the database, and then insert it into the Assignment Collection.
            for (int x = 0; x < 10; x++)
            {
                Assignment temp = NewAssignment();
                temp.AssignedTo = "testing";
                temp.IsActive = true;
                InsertAssignmentIntoDatabase(temp);
                tempAssignmentCol.Add(temp);
            }

            //Get all Assignments by that Ticket Id...
            AssignmentCollection tempAssignmentCol2 = HelpdeskService.GetAssignmentByUserAndActive("testing", true);

            foreach (Assignment temp in tempAssignmentCol)
            {
                Assert.IsTrue(tempAssignmentCol2.Contains(temp), "The new assignment collection did not contain the same data as the original");
            }
            Assert.IsTrue(tempAssignmentCol2.Count >= tempAssignmentCol.Count);
        }
        protected override IEnumerable <PublishingPage> RetrieveDataObjects()
        {
            List <PublishingPage> publishingPages = new List <PublishingPage>();

            switch (ParameterSetName)
            {
            case "SPWeb":
                foreach (SPWebPipeBind webPipe in Web)
                {
                    SPWeb web = webPipe.Read();

                    WriteVerbose("Getting publishing page from " + web.Url);
                    if (!PublishingWeb.IsPublishingWeb(web))
                    {
                        WriteWarning(string.Format("Web \"{0}\" is not a publishing web and will be skipped.", web.Url));
                        continue;
                    }
                    PublishingWeb pubWeb = PublishingWeb.GetPublishingWeb(web);


                    if (PageName == null || PageName.Length == 0)
                    {
                        foreach (PublishingPage page in pubWeb.GetPublishingPages())
                        {
                            publishingPages.Add(page);
                        }
                    }
                    else
                    {
                        foreach (string pageName in PageName)
                        {
                            string pageUrl = string.Format("{0}/{1}/{2}", web.Url.TrimEnd('/'), pubWeb.PagesListName, pageName.Trim('/'));

                            try
                            {
                                PublishingPage page = pubWeb.GetPublishingPage(pageUrl);
                                if (page != null)
                                {
                                    publishingPages.Add(page);
                                }
                                else
                                {
                                    WriteWarning("Could not locate the specified page: " + pageUrl);
                                }
                            }
                            catch (ArgumentException)
                            {
                                WriteWarning("Could not locate the specified page: " + pageUrl);
                            }
                        }
                    }
                }
                break;

            case "SPFile":
                foreach (SPFilePipeBind filePipe in Identity)
                {
                    SPFile file = filePipe.Read();
                    if (!PublishingWeb.IsPublishingWeb(file.Web))
                    {
                        WriteWarning(string.Format("Web \"{0}\" is not a publishing web and will be skipped.", file.Web.Url));
                        continue;
                    }

                    WriteVerbose("Getting publishing page from " + file.Url);
                    try
                    {
                        PublishingPage page = null;
                        if (file.Exists)
                        {
                            page = PublishingPage.GetPublishingPage(file.Item);
                        }

                        if (page != null)
                        {
                            publishingPages.Add(page);
                        }
                        else
                        {
                            WriteWarning("Could not locate the specified page: " + file.Url);
                        }
                    }
                    catch (ArgumentException)
                    {
                        WriteWarning("Could not locate the specified page: " + file.Url);
                    }
                }
                break;
            }

            foreach (PublishingPage page in publishingPages)
            {
                AssignmentCollection.Add(page.PublishingWeb.Web);
                AssignmentCollection.Add(page.PublishingWeb.Web.Site);
                WriteResult(page);
            }

            return(null);
        }
Esempio n. 12
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            _incident = (Utilites.Incident)Session["Incident"];
            _user     = (Utilites.User)Session["User"];

            this.btnPrint.Attributes.Add("onclick", "javascript: window.open('PrintScreen.aspx?rpt=IncidentReport&prtNum=" + this._incident.IncidentId + "');");
            problemTypeList.Attributes.Add("OnChange", "alert('NOTE:  If you are changing the problem type and this problem is not associated with your division please change to the correct Department and or Division below and click on the Reassign Call button. Thank you.')");


            if (!Page.IsPostBack)
            {
                BindData();
                lblIncidentNumber.Text     += _incident.IncidentId.ToString();
                lblDateSubmitted.Text      += _incident.OpenDate.ToString();
                txtAddress.Text             = _incident.Address;
                txtIncidentDescription.Text = _incident.IncidentDisc;
                lblLastUpdated.Text        += _incident.ModifyDate.ToString();
                councilDistList.Items.FindByValue(_incident.CouncilDist).Selected = true;
                this.lblInsertedBy.Text += _incident.InsertedBy;
                if (_incident.Openclose == "O")
                {
                    rbtnOpen.Checked       = true;
                    this.btnUpdate.Enabled = true;
                    Session["Status"]      = "O";
                }
                else if (_incident.Openclose == "C")
                {
                    rbtnClosed.Checked     = true;
                    this.btnUpdate.Enabled = false;
                    Session["Status"]      = "C";
                }
                if (_incident.HasCitizenBeenContacted == true)
                {
                    this.rbtnCityContactedYes.Checked = true;
                }
                else
                {
                    this.rbtnCityContactedNo.Checked = true;
                }

                if (_incident.RequstingClosure == true)
                {
                    this.rbtnYesClose.Checked = true;
                }
                else
                {
                    this.rbtnNoClose.Checked = true;
                }

                if (_incident.Contact == 1)
                {
                    rbtnYes.Checked = true;
                }
                else if (_incident.Contact == 0)
                {
                    rbtnNo.Checked = true;
                }
                if (_incident.CourtDate == System.DateTime.MinValue)
                {
                    txtCourtDate.Text = "";
                }
                else
                {
                    txtCourtDate.Text = _incident.CourtDate.ToShortDateString();
                }
                if (_incident.PendingDate == System.DateTime.MinValue)
                {
                    txtPendingDate.Text = "";
                }
                else
                {
                    txtPendingDate.Text = _incident.PendingDate.ToShortDateString();
                }



                problemTypeList.Items.FindByValue(Convert.ToString(_incident.ProblemTypeId)).Selected = true;

                foreach (Utilites.Citizen citizen in _incident.CitizenCollection)
                {
                    Session["citizen"]  = citizen;
                    citizenId           = citizen.CitizenId;
                    txtFirstName.Text   = citizen.FirstName;
                    txtLastName.Text    = citizen.LastName;
                    txtPhoneNumber.Text = citizen.PhoneNumber;
                    txtEmail.Text       = citizen.Email;
                }
            }
            Utilites.Assignment assignemnt = new Utilites.Assignment();
            assignemntCol = assignemnt.GetAllIncidentAssignments(this._incident.IncidentId);
            adminTabsPlaceHolder1.IncidentId           = this._incident.IncidentId;
            adminTabsPlaceHolder1.AssignmentCollection = assignemntCol;
            this.rbtnClosed.Enabled = false;
            this.rbtnOpen.Enabled   = false;
            if (this._user.IsUserCounciRole() || this._user.IsUserITAdminRole())
            {
                this.rbtnClosed.Enabled = true;
                this.rbtnOpen.Enabled   = true;
            }
        }
Esempio n. 13
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            incidentnumber = Convert.ToInt32(Session["IncidentNumber"]);
            this.btnPrint.Attributes.Add("onclick", "javascript: window.open('PrintScreen.aspx?rpt=IncidentReport&prtNum=" + incidentnumber + "');");
            problemTypeList.Attributes.Add("OnChange", "alert('NOTE:  If you are changing the problem type and this problem is not associated with your division please change to the correct Department and or Division below and click on the Reassign Call button. Thank you.')");
            //sm = new SecurityManager();
            //sm.AuthorizationProvider = "Authorization Provider";
            //sm.SecurityCacheProvider = "Caching Store Provider";
            //if(sm.IsUserInRole(User, Global.RoleITAdmin)) role = Global.RoleITAdmin;
            //else if(sm.IsUserInRole(User,Global.RoleCouncil)) role = Global.RoleCouncil;
            //else if(sm.IsUserInRole(User,Global.RoleCityManager)) role =Global.RoleCityManager;
            //else if (sm.IsUserInRole(User,Global.RoleDepartment)) role =Global.RoleDepartment;
            //else if (sm.IsUserInRole(User,Global.RoleDivision)) role =Global.RoleDivision;

            if (!Page.IsPostBack)
            {
                BindData();
                Utilites.Incident incident = new Utilites.Incident(incidentnumber);
                incident.GetIndividualIncident();
                lblIncidentNumber.Text     += incident.IncidentId.ToString();
                lblDateSubmitted.Text      += incident.OpenDate.ToString();
                txtAddress.Text             = incident.Address;
                txtIncidentDescription.Text = incident.IncidentDisc;
                lblLastUpdated.Text        += incident.ModifyDate.ToString();
                councilDistList.Items.FindByValue(incident.CouncilDist).Selected = true;
                this.lblInsertedBy.Text += incident.InsertedBy;
                if (incident.Openclose == "O")
                {
                    rbtnOpen.Checked       = true;
                    this.btnUpdate.Enabled = true;
                    Session["Status"]      = "O";
                }
                else if (incident.Openclose == "C")
                {
                    rbtnClosed.Checked     = true;
                    this.btnUpdate.Enabled = false;
                    Session["Status"]      = "C";
                }
                if (incident.HasCitizenBeenContacted == true)
                {
                    this.rbtnCityContactedYes.Checked = true;
                }
                else
                {
                    this.rbtnCityContactedNo.Checked = true;
                }

                if (incident.RequstingClosure == true)
                {
                    this.rbtnYesClose.Checked = true;
                }
                else
                {
                    this.rbtnNoClose.Checked = true;
                }

                if (incident.Contact == 1)
                {
                    rbtnYes.Checked = true;
                }
                else if (incident.Contact == 0)
                {
                    rbtnNo.Checked = true;
                }
                if (incident.CourtDate == System.DateTime.MinValue)
                {
                    txtCourtDate.Text = "";
                }
                else
                {
                    txtCourtDate.Text = incident.CourtDate.ToShortDateString();
                }
                if (incident.PendingDate == System.DateTime.MinValue)
                {
                    txtPendingDate.Text = "";
                }
                else
                {
                    txtPendingDate.Text = incident.PendingDate.ToShortDateString();
                }



                problemTypeList.Items.FindByValue(Convert.ToString(incident.ProblemTypeId)).Selected = true;

                foreach (Utilites.Citizen citizen in incident.CitizenCollection)
                {
                    Session["citizen"]  = citizen;
                    citizenId           = citizen.CitizenId;
                    txtFirstName.Text   = citizen.FirstName;
                    txtLastName.Text    = citizen.LastName;
                    txtPhoneNumber.Text = citizen.PhoneNumber;
                    txtEmail.Text       = citizen.Email;
                }
            }
            Utilites.Assignment assignemnt = new Utilites.Assignment();
            assignemntCol = assignemnt.GetAllIncidentAssignments(incidentnumber);
            adminTabsPlaceHolder1.IncidentId           = incidentnumber;
            adminTabsPlaceHolder1.AssignmentCollection = assignemntCol;
            this.rbtnClosed.Enabled = false;
            this.rbtnOpen.Enabled   = false;
            if (role == "Council" || role == "IT Admin")
            {
                this.rbtnClosed.Enabled = true;
                this.rbtnOpen.Enabled   = true;
            }
        }