Version 15 (modified by 11 years ago) ( diff ) | ,
---|
CoDBIS
Имплементација на апликацијата CoDBIS во ASP.Net
Во продолжение се дадени изворните кодови на страниците за регистрација, логирање, внесување лични информации, внесување активности и преглед на биографијата.
За регистрација на корисници
Register.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.AspNet.Membership.OpenAuth; namespace CoDBIS.Account { public partial class Register : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterUser.ContinueDestinationPageUrl = Request.QueryString["ReturnUrl"]; } protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, createPersistentCookie: false); string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (!OpenAuth.IsLocalUrl(continueUrl)) { continueUrl = "AddInfo.aspx"; } Response.Redirect(continueUrl); } } } Register.aspx <%@ Page Title="Register" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Register.aspx.cs" Inherits="CoDBIS.Account.Register" %> <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> <hgroup class="title"> <h1>Регистрирај се.</h1> <h2>Искористете ја формата подолу за да креирате нова корисничка сметка.</h2> </hgroup> <asp:CreateUserWizard runat="server" ID="RegisterUser" ViewStateMode="Disabled" OnCreatedUser="RegisterUser_CreatedUser" CompleteSuccessText="Вашата корисничка сметка е успешно креирана." DuplicateEmailErrorMessage="Е-маил адресата што ја внесовте е веќе во употреба. Ве молиме внесете друга е-меил адреса." DuplicateUserNameErrorMessage="Ве молиме внесете друго корисничко име." InvalidAnswerErrorMessage="Ве молиме внесете друг сигурносен одговор." InvalidEmailErrorMessage="Ве молиме внесете валидна е-меил адреса." InvalidPasswordErrorMessage="Должината на лозинката мора да е минимум: {0}. Потребни се алфа-нумерички карактери: {1}." InvalidQuestionErrorMessage="Ве молиме внесете друго сигурносно прашање." UnknownErrorMessage="Вашата корисничка сметка не е креирана. Ве молиме обидете се повторно."> <LayoutTemplate> <asp:PlaceHolder runat="server" ID="wizardStepPlaceholder" /> <asp:PlaceHolder runat="server" ID="navigationPlaceholder" /> </LayoutTemplate> <WizardSteps> <asp:CreateUserWizardStep runat="server" ID="RegisterUserWizardStep"> <ContentTemplate> <p class="message-info"> Лозинката мора да има повеќе од <%: Membership.MinRequiredPasswordLength %> карактери. </p> <p class="validation-summary-errors"> <asp:Literal runat="server" ID="ErrorMessage" /> </p> <fieldset> <legend>Registration Form</legend> <ol> <li> <asp:Label runat="server" AssociatedControlID="UserName">Корисничко име</asp:Label> <asp:TextBox runat="server" ID="UserName" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" CssClass="field-validation-error" ErrorMessage="Полето за корисничко име е задолжително." /> </li> <li> <asp:Label runat="server" AssociatedControlID="Email">Електронска адреса</asp:Label> <asp:TextBox runat="server" ID="Email" TextMode="Email" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="Email" CssClass="field-validation-error" ErrorMessage="Полето за електронска адреса е задолжително." /> </li> <li> <asp:Label runat="server" AssociatedControlID="Password">Лозинка</asp:Label> <asp:TextBox runat="server" ID="Password" TextMode="Password" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" CssClass="field-validation-error" ErrorMessage="Полето за лозинка е задолжително." /> </li> <li> <asp:Label runat="server" AssociatedControlID="ConfirmPassword">Потврди ја лозинката</asp:Label> <asp:TextBox runat="server" ID="ConfirmPassword" TextMode="Password" /> <asp:RequiredFieldValidator runat="server" ControlToValidate="ConfirmPassword" CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Полето за потврда на електронската адреса е задолжително." /> <asp:CompareValidator runat="server" ControlToCompare="Password" ControlToValidate="ConfirmPassword" CssClass="field-validation-error" Display="Dynamic" ErrorMessage="Лозинките не се совпаѓаат." /> </li> </ol> <asp:Button runat="server" CommandName="MoveNext" Text="Регистрирај се" /> </fieldset> </ContentTemplate> <CustomNavigationTemplate /> </asp:CreateUserWizardStep> </WizardSteps> </asp:CreateUserWizard> </asp:Content>
За логирање на корисници
Login.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.AspNet.Membership.OpenAuth; using System.Web.Security; namespace CoDBIS.Account { public partial class Login : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { RegisterHyperLink.NavigateUrl = "Register.aspx"; var returnUrl = HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); if (!String.IsNullOrEmpty(returnUrl)) { RegisterHyperLink.NavigateUrl += "?ReturnUrl=" + returnUrl; } } } } Login.aspx <%@ Page Title="Login" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="CoDBIS.Account.Login" %> <%@ Register Src="~/Account/OpenAuthProviders.ascx" TagPrefix="uc" TagName="OpenAuthProviders" %> <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> <hgroup class="title"> <h1>Најавете се.</h1> </hgroup> <section id="loginForm"> <h2>Искористете ги вашето корисничко име и лозинката за да се најавите на апликацијата.</h2> <asp:Login runat="server" DestinationPageUrl="~/Account/MyBiography.aspx" ViewStateMode="Disabled" RenderOuterTable="false" FailureText="Вашиот обид за најава е неуспешен. Ве молиме обидете се повторно." PasswordRequiredErrorMessage="Лозинката е задолжителна." UserNameRequiredErrorMessage="Корисничкото име е задолжително." RememberMeText="Запомни ме следниот пат." LoginButtonText="Најави се"> <LayoutTemplate> <p class="validation-summary-errors"> <asp:Literal runat="server" ID="FailureText" /> </p> <fieldset> <legend>Log in Form</legend> <ol> <li> <asp:Label runat="server" AssociatedControlID="UserName">Корисничко име</asp:Label> <asp:TextBox runat="server" ID="UserName"/> <asp:RequiredFieldValidator runat="server" ControlToValidate="UserName" CssClass="field-validation-error" ErrorMessage="Полето за корисничко име е задолжително." /> </li> <li> <asp:Label runat="server" AssociatedControlID="Password">Лозинка</asp:Label> <asp:TextBox runat="server" ID="Password" TextMode="Password"/> <asp:RequiredFieldValidator runat="server" ControlToValidate="Password" CssClass="field-validation-error" ErrorMessage="Полето за лозинка е задолжително." /> </li> <li> <asp:CheckBox runat="server" ID="RememberMe" /> <asp:Label runat="server" AssociatedControlID="RememberMe" CssClass="checkbox">Запомни ме?</asp:Label> </li> </ol> <asp:Button ID="btnLogin" runat="server" CommandName="Login" Text="Најави се"/> </fieldset> </LayoutTemplate> </asp:Login> <p> Ако немате корисничка сметка <asp:HyperLink runat="server" ID="RegisterHyperLink" ViewStateMode="Disabled">Регистрирајте се</asp:HyperLink> .</p> </section> </asp:Content>
Додавање лични податоци за корисникот
Addinfo.aspx.cs using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CoDBIS.Account { public partial class AddInfo : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string korisnik = User.Identity.Name; lblUserName.Text = korisnik; } protected void btnAdd_Click(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; SqlConnection conn = new SqlConnection(connString); conn.Open(); string updateCommand = "UPDATE [Users] SET [PlaceOfBirth]=@PlaceOfBirth, [Gender]=@Gender, [DateOfBirth]=@DateOfBirth, [Position]=@Position, [FirstNameLastName]=@FirstNameLastName, [Employer]=@Employer, [EducationLevel]=@EducationLevel, [EducationInstitution]=@EducationInstitution WHERE ([UserName]=@UserName)"; SqlCommand cmd = new SqlCommand(updateCommand, conn); cmd.Parameters.AddWithValue("@PlaceOfBirth", txtMesto.Text); cmd.Parameters.AddWithValue("@Gender", rblPol.SelectedValue.ToString()); cmd.Parameters.AddWithValue("@DateOfBirth", Convert.ToDateTime( txtDatum.Text)); cmd.Parameters.AddWithValue("@Position", txtPozicija.Text); cmd.Parameters.AddWithValue("@FirstNameLastName", txtImePrezime.Text); cmd.Parameters.AddWithValue("@Employer", txtVrabotenVo.Text); cmd.Parameters.AddWithValue("@EducationLevel", txtObrazovanie.Text); cmd.Parameters.AddWithValue("@EducationInstitution", txtInstitucija.Text); cmd.Parameters.AddWithValue("@UserName", lblUserName.Text); cmd.ExecuteNonQuery(); conn.Close(); lblMessage.Text = "Вашите податоци се успешно зачувани."; txtImePrezime.Text = ""; txtMesto.Text = ""; txtDatum.Text = ""; txtObrazovanie.Text = ""; txtInstitucija.Text = ""; txtVrabotenVo.Text = ""; txtPozicija.Text = ""; } protected void BirthCalendar_SelectionChanged(object sender, EventArgs e) { txtDatum.Text = BirthCalendar.SelectedDate.ToString("dd/MM/yyyy"); } } } Addinfo.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="AddInfo.aspx.cs" Inherits="CoDBIS.Account.AddInfo" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> <style type="text/css"> .auto-style1 { width: 100%; } .auto-style2 { width: 350px; } .auto-style3 { width: 150px; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server"> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> <h3>Дополнете ги следниве податоци за да ги комплетирате/ажурирате Вашите кориснички податоци или кликнете на копчето Продолжи ако сакате подоцна да ги внесете овие податоци:</h3> <asp:Label ID="lblUserName" runat="server" Text="" Visible="false"></asp:Label> <br /> <h3 class="message-success"> <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label></h3> <table class="auto-style1"> <tr> <td class="auto-style2"> <asp:Label ID="lblImePrezime" runat="server" Text="Име и презиме: "></asp:Label></td> <td class="auto-style3"> <asp:TextBox ID="txtImePrezime" runat="server"></asp:TextBox></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="lblPol" runat="server" Text="Пол: "></asp:Label> </td> <td class="auto-style3"> <asp:RadioButtonList ID="rblPol" runat="server" Height="50px" Width="139px"> <asp:ListItem Value="M" Selected="True">Машки</asp:ListItem> <asp:ListItem Value="F">Женски</asp:ListItem> </asp:RadioButtonList></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="lblMesto" runat="server" Text="Место на раѓање: "></asp:Label></td> <td class="auto-style3"> <asp:TextBox ID="txtMesto" runat="server"></asp:TextBox></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="lblDatum" runat="server" Text="Датум на раѓање: "></asp:Label></td> <td class="auto-style3"> <asp:TextBox ID="txtDatum" runat="server"></asp:TextBox> </td> <td> <asp:Calendar ID="BirthCalendar" runat="server" OnSelectionChanged="BirthCalendar_SelectionChanged"></asp:Calendar> </td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> <td> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="lblObrazovanie" runat="server" Text="Ниво на образование: "></asp:Label></td> <td class="auto-style3"> <asp:TextBox ID="txtObrazovanie" runat="server"></asp:TextBox></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="lblInstitucija" runat="server" Text="Име на образовната институција: "></asp:Label></td> <td class="auto-style3"> <asp:TextBox ID="txtInstitucija" runat="server"></asp:TextBox></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="lblVrabotenVo" runat="server" Text="Вработен во: "></asp:Label></td> <td class="auto-style3"> <asp:TextBox ID="txtVrabotenVo" runat="server"></asp:TextBox></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> </tr> <tr> <td class="auto-style2"> <asp:Label ID="lblPozicija" runat="server" Text="Работна позиција: "></asp:Label></td> <td class="auto-style3"> <asp:TextBox ID="txtPozicija" runat="server"></asp:TextBox></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> </td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> <asp:Button ID="btnAdd" runat="server" Text="Зачувај" OnClick="btnAdd_Click" /> </td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"></td> </tr> <tr> <td class="auto-style2"> </td> <td class="auto-style3"> <asp:Button ID="Button2" runat="server" PostBackUrl="~/Account/MyBiography.aspx" Text="Продолжи" /> </td> </tr> </table> <br /> <br /> </asp:Content>
Внес на нова активност за логираниот корисник и додавање на корисник кон веќе постоечка активност
Inserting.aspx.cs using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.SqlClient; using System.Linq; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; namespace CoDBIS.Account { public partial class Inserting : System.Web.UI.Page { string identity; protected void Page_Load(object sender, EventArgs e) { string korisnik = User.Identity.Name; lblUsername.Text = korisnik; string userId = Membership.GetUser().ProviderUserKey.ToString(); lblUserID.Text = userId; } protected void btnInsert_Click(object sender, EventArgs e) { string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; SqlConnection conn = new SqlConnection(connString); conn.Open(); string insertCommand1 = "insert into [Activities] (Name, Category, Place, Date) values (@Name, @Category, @Place, @Date)"; insertCommand1 += "; SELECT SCOPE_IDENTITY() ; "; SqlCommand cmd1 = new SqlCommand(insertCommand1, conn); cmd1.Parameters.AddWithValue("@Name", txtName.Text); cmd1.Parameters.AddWithValue("@Category", txtCategory.Text); cmd1.Parameters.AddWithValue("@Place", txtPlace.Text); cmd1.Parameters.AddWithValue("@Date", Convert.ToDateTime(txtDate.Text)); identity = cmd1.ExecuteScalar().ToString(); lblActivityID.Text = identity; string insertCommand2 = "insert into [UsersOnActivities] (NameOfRole, UserID, ActivityID) values (@NameOfRole, @UserID, @ActivityID)"; SqlCommand cmd2 = new SqlCommand(insertCommand2, conn); cmd2.Parameters.AddWithValue("@NameOfRole", txtRole.Text); cmd2.Parameters.AddWithValue("@UserID", lblUserID.Text); cmd2.Parameters.AddWithValue("@ActivityID", lblActivityID.Text); cmd2.ExecuteNonQuery(); conn.Close(); lblMessage.Text = "Активноста е успешно внесена во Вашата биографија."; txtName.Text = ""; txtCategory.Text = ""; txtPlace.Text = ""; txtDate.Text = ""; txtRole.Text = ""; } protected void btnShow_Click(object sender, EventArgs e) { gvMe.Visible = true; } protected void btnAddMe_Click(object sender, EventArgs e) { foreach (GridViewRow row in gvMe.Rows) { if (((CheckBox)row.FindControl("CheckBox1")).Checked) { int ActivityID = Convert.ToInt32(gvMe.DataKeys[row.RowIndex].Value); lblExistingActivity.Text = ActivityID.ToString(); string connString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; SqlConnection conn = new SqlConnection(connString); conn.Open(); string insertCommand3 = "insert into [UsersOnActivities] (NameOfRole, UserID, ActivityID) values (@NameOfRole, @UserID, @ActivityID)"; SqlCommand cmd3 = new SqlCommand(insertCommand3, conn); cmd3.Parameters.AddWithValue("@NameOfRole", txtRoleOnExisting.Text); cmd3.Parameters.AddWithValue("@UserID", lblUserID.Text); cmd3.Parameters.AddWithValue("@ActivityID", lblExistingActivity.Text); cmd3.ExecuteNonQuery(); conn.Close(); lblMessage.Text = "Успешно сте додадени на активноста."; } } } } } Inserting.aspx <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Inserting.aspx.cs" Inherits="CoDBIS.Account.Inserting" %> <asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server"> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="FeaturedContent" runat="server"> </asp:Content> <asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server"> <h3> <asp:Label ID="lblUsername" runat="server" Visible="false"></asp:Label> <asp:Label ID="lblActivityID" runat="server" Text="Label" Visible="false"></asp:Label> <asp:Label ID="lblUserID" runat="server" Text="Label" Visible="false"></asp:Label> </h3> <asp:PlaceHolder ID="PlaceHolder1" runat="server" Visible="true"> <h3>Додадете нова активност на која сте учествувале: </h3> <h3 class="message-success"><asp:Label ID="lblMessage" runat="server" Text=""></asp:Label></h3> <table class="auto-style1" border="0"> <tr> <td> <asp:Label ID="lblName" runat="server" Text="Име на активноста: "></asp:Label> </td> <td> <asp:TextBox ID="txtName" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:Label ID="lblCategory" runat="server" Text="Категорија: "></asp:Label> </td> <td> <asp:TextBox ID="txtCategory" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:Label ID="lblPlace" runat="server" Text="Место на одржување/објава: "></asp:Label> </td> <td> <asp:TextBox ID="txtPlace" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:Label ID="lblDate" runat="server" Text="Датум на одржување/објава: "></asp:Label> </td> <td> <asp:TextBox ID="txtDate" runat="server"></asp:TextBox> </td> </tr> <tr> <td><asp:Label ID="lblRole" runat="server" Text="Улога: "></asp:Label></td> <td> <asp:TextBox ID="txtRole" runat="server"></asp:TextBox> </td> </tr> <tr> <td> </td> <td> </td> </tr> <tr> <td> <asp:Button ID="btnInsert" runat="server" Text="Внеси" OnClick="btnInsert_Click"/> </td> <td></td> </tr> </table> <hr /> </asp:PlaceHolder> <asp:PlaceHolder ID="PlaceHolder2" runat="server" Visible="true"> <h3>Пребарајте веќе постоечки активности и приклучете се: </h3> <br /> Внеси име на активноста: <asp:TextBox ID="txtActivity" runat="server" ></asp:TextBox> <asp:Button ID="btnShow" runat="server" Text="Прикажи активности" OnClick="btnShow_Click"/><br /> <asp:Label ID="lblRoleOnExisting" runat="server" Text="Улога: "></asp:Label><asp:TextBox ID="txtRoleOnExisting" runat="server"></asp:TextBox> <asp:Label ID="lblExistingActivity" runat="server" Text="Label" Visible="false"></asp:Label> <asp:GridView ID="gvMe" EmptyDataText="Не постојат активности со тоа име." runat="server" AutoGenerateColumns="False" DataKeyNames="ActivityID" DataSourceID="SqlDataSource1" AllowPaging="True" AllowSorting="True" Visible="false" OnSelectedIndexChanged="btnAddMe_Click" CellPadding="4" ForeColor="#333333" GridLines="None"> <AlternatingRowStyle BackColor="White" ForeColor="#284775"></AlternatingRowStyle> <Columns> <asp:TemplateField HeaderText="Означи активност"> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Name" HeaderText="ИмеНаАктивноста " SortExpression="Name" InsertVisible="False" ReadOnly="True"></asp:BoundField> <asp:BoundField DataField="Category" HeaderText="Категорија " SortExpression="Category"></asp:BoundField> <asp:BoundField DataField="Place" HeaderText="МестоНаОбјаваОдржување " SortExpression="Place"></asp:BoundField> <asp:BoundField DataField="Date" HeaderText="ДатумНаОбјаваОдржување " SortExpression="Date"></asp:BoundField> </Columns> <EditRowStyle BackColor="#999999"></EditRowStyle> <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></FooterStyle> <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White"></HeaderStyle> <PagerStyle HorizontalAlign="Center" BackColor="#284775" ForeColor="White"></PagerStyle> <RowStyle BackColor="#F7F6F3" ForeColor="#333333"></RowStyle> <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333"></SelectedRowStyle> <SortedAscendingCellStyle BackColor="#E9E7E2"></SortedAscendingCellStyle> <SortedAscendingHeaderStyle BackColor="#506C8C"></SortedAscendingHeaderStyle> <SortedDescendingCellStyle BackColor="#FFFDF8"></SortedDescendingCellStyle> <SortedDescendingHeaderStyle BackColor="#6F8DAE"></SortedDescendingHeaderStyle> </asp:GridView> <asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString='<%$ ConnectionStrings:DefaultConnection %>' SelectCommand="SELECT [ActivityID], [Name], [Category], [Place], [Date] FROM [Activities] WHERE ([Name] = @Name)"> <SelectParameters> <asp:ControlParameter ControlID="txtActivity" PropertyName="Text" DefaultValue="Избери активност" Name="Name" Type="String"></asp:ControlParameter> </SelectParameters> </asp:SqlDataSource> <br /> <asp:Button ID="btnAddMe" runat="server" Text="Додади ме" OnClick="btnAddMe_Click"/><br /> </asp:PlaceHolder> <br /> </asp:Content>
Преглед на биографија за корисникот
MyBiography.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Microsoft.AspNet.Membership.OpenAuth; using System.Web.Security; using System.Data.SqlClient; using System.Configuration; using System.Data; namespace CoDBIS.Account { public partial class MyBiography : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string korisnik = User.Identity.Name; lblUsername.Text = korisnik; if (!User.Identity.IsAuthenticated) { Response.Redirect("Login.aspx"); } } } } MyBiography.aspx <%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="MyBiography.aspx.cs" Inherits="CoDBIS.Account.MyBiography" %> <asp:Content runat="server" ID="FeaturedContent" ContentPlaceHolderID="FeaturedContent"> <section class="featured"> <div class="content-wrapper"> <hgroup class="title"> <h1>Мојата биографија.</h1> <h2>На оваа страница можете да ги најдете сите информации поврзани со вашата биографија.</h2> </hgroup> </div> </section> </asp:Content> <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent"> <table class="auto-style1"> <tr> <td class="auto-style2"> <asp:Label ID="lblUsername" runat="server" Visible="false"></asp:Label> </td> <td style="text-align: center"> <asp:Button ID="Button1" runat="server" Text="Внеси нова активност" Width="220px" PostBackUrl="~/Account/Inserting.aspx" /> </td> </tr> </table> <h3>Лични податоци:</h3> <p> <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource2" CellPadding="3" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" GridLines="Vertical"> <EditItemTemplate> ИмеПрезиме: <asp:TextBox ID="ИмеПрезимеTextBox" runat="server" Text='<%# Bind("ИмеПрезиме") %>' /> <br /> ДатумНаРаѓање: <asp:TextBox ID="ДатумНаРаѓањеTextBox" runat="server" Text='<%# Bind("ДатумНаРаѓање") %>' /> <br /> МестоНаРаѓање: <asp:TextBox ID="МестоНаРаѓањеTextBox" runat="server" Text='<%# Bind("МестоНаРаѓање") %>' /> <br /> Пол: <asp:TextBox ID="ПолTextBox" runat="server" Text='<%# Bind("Пол") %>' /> <br /> КонтактЕмеил: <asp:TextBox ID="КонтактЕмеилTextBox" runat="server" Text='<%# Bind("КонтактЕмеил") %>' /> <br /> ИмеНаОбразовнаИнституција: <asp:TextBox ID="ИмеНаОбразовнаИнституцијаTextBox" runat="server" Text='<%# Bind("ИмеНаОбразовнаИнституција") %>' /> <br /> НивоНаОбразование: <asp:TextBox ID="НивоНаОбразованиеTextBox" runat="server" Text='<%# Bind("НивоНаОбразование") %>' /> <br /> ОстанатоОбразование: <asp:TextBox ID="ОстанатоОбразованиеTextBox" runat="server" Text='<%# Bind("ОстанатоОбразование") %>' /> <br /> ВработенВо: <asp:TextBox ID="ВработенВоTextBox" runat="server" Text='<%# Bind("ВработенВо") %>' /> <br /> РаботнаПозиција: <asp:TextBox ID="РаботнаПозицијаTextBox" runat="server" Text='<%# Bind("РаботнаПозиција") %>' /> <br /> <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update" Text="Update" /> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </EditItemTemplate> <EditRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" /> <FooterStyle BackColor="#CCCCCC" ForeColor="Black" /> <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" /> <InsertItemTemplate> ИмеПрезиме: <asp:TextBox ID="ИмеПрезимеTextBox" runat="server" Text='<%# Bind("ИмеПрезиме") %>' /> <br /> ДатумНаРаѓање: <asp:TextBox ID="ДатумНаРаѓањеTextBox" runat="server" Text='<%# Bind("ДатумНаРаѓање") %>' /> <br /> МестоНаРаѓање: <asp:TextBox ID="МестоНаРаѓањеTextBox" runat="server" Text='<%# Bind("МестоНаРаѓање") %>' /> <br /> Пол: <asp:TextBox ID="ПолTextBox" runat="server" Text='<%# Bind("Пол") %>' /> <br /> КонтактЕмеил: <asp:TextBox ID="КонтактЕмеилTextBox" runat="server" Text='<%# Bind("КонтактЕмеил") %>' /> <br /> ИмеНаОбразовнаИнституција: <asp:TextBox ID="ИмеНаОбразовнаИнституцијаTextBox" runat="server" Text='<%# Bind("ИмеНаОбразовнаИнституција") %>' /> <br /> НивоНаОбразование: <asp:TextBox ID="НивоНаОбразованиеTextBox" runat="server" Text='<%# Bind("НивоНаОбразование") %>' /> <br /> ОстанатоОбразование: <asp:TextBox ID="ОстанатоОбразованиеTextBox" runat="server" Text='<%# Bind("ОстанатоОбразование") %>' /> <br /> ВработенВо: <asp:TextBox ID="ВработенВоTextBox" runat="server" Text='<%# Bind("ВработенВо") %>' /> <br /> РаботнаПозиција: <asp:TextBox ID="РаботнаПозицијаTextBox" runat="server" Text='<%# Bind("РаботнаПозиција") %>' /> <br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert" /> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" /> </InsertItemTemplate> <ItemTemplate> ИмеПрезиме: <asp:Label ID="ИмеПрезимеLabel" runat="server" Text='<%# Bind("ИмеПрезиме") %>' /> <br /> ДатумНаРаѓање: <asp:Label ID="ДатумНаРаѓањеLabel" runat="server" Text='<%# Bind("ДатумНаРаѓање") %>' /> <br /> МестоНаРаѓање: <asp:Label ID="МестоНаРаѓањеLabel" runat="server" Text='<%# Bind("МестоНаРаѓање") %>' /> <br /> Пол: <asp:Label ID="ПолLabel" runat="server" Text='<%# Bind("Пол") %>' /> <br /> КонтактЕмеил: <asp:Label ID="КонтактЕмеилLabel" runat="server" Text='<%# Bind("КонтактЕмеил") %>' /> <br /> ИмеНаОбразовнаИнституција: <asp:Label ID="ИмеНаОбразовнаИнституцијаLabel" runat="server" Text='<%# Bind("ИмеНаОбразовнаИнституција") %>' /> <br /> НивоНаОбразование: <asp:Label ID="НивоНаОбразованиеLabel" runat="server" Text='<%# Bind("НивоНаОбразование") %>' /> <br /> ОстанатоОбразование: <asp:Label ID="ОстанатоОбразованиеLabel" runat="server" Text='<%# Bind("ОстанатоОбразование") %>' /> <br /> ВработенВо: <asp:Label ID="ВработенВоLabel" runat="server" Text='<%# Bind("ВработенВо") %>' /> <br /> РаботнаПозиција: <asp:Label ID="РаботнаПозицијаLabel" runat="server" Text='<%# Bind("РаботнаПозиција") %>' /> <br /> </ItemTemplate> <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" /> <RowStyle BackColor="#EEEEEE" ForeColor="Black" /> </asp:FormView> <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT Users.FirstNameLastName AS ИмеПрезиме, Users.DateOfBirth AS ДатумНаРаѓање, Users.PlaceOfBirth AS МестоНаРаѓање, Users.Gender AS Пол, Memberships.Email AS КонтактЕмеил, Users.EducationInstitution AS ИмеНаОбразовнаИнституција, Users.EducationLevel AS НивоНаОбразование, Users.OtherEducation AS ОстанатоОбразование, Users.Employer AS ВработенВо, Users.Position AS РаботнаПозиција FROM Users INNER JOIN Memberships ON Users.UserId = Memberships.UserId WHERE (Users.UserName = @UserName)"> <SelectParameters> <asp:ControlParameter ControlID="lblUsername" Name="UserName" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource> </p> <p> </p> <h3>Листа на активности:</h3> <p> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" SelectCommand="SELECT Activities.Name as ИмеНаАктивноста, Activities.Category as ТипКатегоријаНаАктивноста, Activities.Place as МестоНаОдржувањеОбјава, Activities.Date as Датум, UsersOnActivities.NameOfRole as Улога FROM Activities INNER JOIN UsersOnActivities ON Activities.ActivityID = UsersOnActivities.ActivityID INNER JOIN Users ON UsersOnActivities.UserID = Users.UserId and Users.UserName=@UserName"> <SelectParameters> <asp:ControlParameter ControlID="lblUsername" Name="UserName" PropertyName="Text" /> </SelectParameters> </asp:SqlDataSource> </p> <p hidden="hidden"> </p> <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" > <AlternatingItemTemplate> <span style="background-color: #FFF8DC;">ИмеНаАктивноста: <asp:Label ID="ИмеНаАктивностаLabel" runat="server" Text='<%# Eval("ИмеНаАктивноста") %>' /> <br /> ТипКатегоријаНаАктивноста: <asp:Label ID="ТипКатегоријаНаАктивностаLabel" runat="server" Text='<%# Eval("ТипКатегоријаНаАктивноста") %>' /> <br /> МестоНаОдржувањеОбјава: <asp:Label ID="МестоНаОдржувањеОбјаваLabel" runat="server" Text='<%# Eval("МестоНаОдржувањеОбјава") %>' /> <br /> Датум: <asp:Label ID="ДатумLabel" runat="server" Text='<%# Eval("Датум") %>' /> <br /> Улога: <asp:Label ID="УлогаLabel" runat="server" Text='<%# Eval("Улога") %>' /> <br /> <br /> </span> </AlternatingItemTemplate> <EditItemTemplate> <span style="background-color: #008A8C;color: #FFFFFF;">ИмеНаАктивноста: <asp:TextBox ID="ИмеНаАктивностаTextBox" runat="server" Text='<%# Bind("ИмеНаАктивноста") %>' /> <br /> ТипКатегоријаНаАктивноста: <asp:TextBox ID="ТипКатегоријаНаАктивностаTextBox" runat="server" Text='<%# Bind("ТипКатегоријаНаАктивноста") %>' /> <br /> МестоНаОдржувањеОбјава: <asp:TextBox ID="МестоНаОдржувањеОбјаваTextBox" runat="server" Text='<%# Bind("МестоНаОдржувањеОбјава") %>' /> <br /> Датум: <asp:TextBox ID="ДатумTextBox" runat="server" Text='<%# Bind("Датум") %>' /> <br /> Улога: <asp:TextBox ID="УлогаTextBox" runat="server" Text='<%# Bind("Улога") %>' /> <br /> <asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" /> <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" /> <br /> <br /> </span> </EditItemTemplate> <EmptyDataTemplate> <span>Листата со активности е празна.</span> </EmptyDataTemplate> <InsertItemTemplate> <span style="">ИмеНаАктивноста: <asp:TextBox ID="ИмеНаАктивностаTextBox" runat="server" Text='<%# Bind("ИмеНаАктивноста") %>' /> <br /> ТипКатегоријаНаАктивноста: <asp:TextBox ID="ТипКатегоријаНаАктивностаTextBox" runat="server" Text='<%# Bind("ТипКатегоријаНаАктивноста") %>' /> <br /> МестоНаОдржувањеОбјава: <asp:TextBox ID="МестоНаОдржувањеОбјаваTextBox" runat="server" Text='<%# Bind("МестоНаОдржувањеОбјава") %>' /> <br /> Датум: <asp:TextBox ID="ДатумTextBox" runat="server" Text='<%# Bind("Датум") %>' /> <br /> Улога: <asp:TextBox ID="УлогаTextBox" runat="server" Text='<%# Bind("Улога") %>' /> <br /> <asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" /> <asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" /> <br /> <br /> </span> </InsertItemTemplate> <ItemTemplate> <span style="background-color: #DCDCDC;color: #000000;">ИмеНаАктивноста: <asp:Label ID="ИмеНаАктивностаLabel" runat="server" Text='<%# Eval("ИмеНаАктивноста") %>' /> <br /> ТипКатегоријаНаАктивноста: <asp:Label ID="ТипКатегоријаНаАктивностаLabel" runat="server" Text='<%# Eval("ТипКатегоријаНаАктивноста") %>' /> <br /> МестоНаОдржувањеОбјава: <asp:Label ID="МестоНаОдржувањеОбјаваLabel" runat="server" Text='<%# Eval("МестоНаОдржувањеОбјава") %>' /> <br /> Датум: <asp:Label ID="ДатумLabel" runat="server" Text='<%# Eval("Датум") %>' /> <br /> Улога: <asp:Label ID="УлогаLabel" runat="server" Text='<%# Eval("Улога") %>' /> <br /> <br /> </span> </ItemTemplate> <LayoutTemplate> <div id="itemPlaceholderContainer" runat="server" style="font-family: Verdana, Arial, Helvetica, sans-serif;"> <span runat="server" id="itemPlaceholder" /> </div> <div style="text-align: center;background-color: #CCCCCC;font-family: Verdana, Arial, Helvetica, sans-serif;color: #000000;"> <asp:DataPager ID="DataPager1" runat="server"> <Fields> <asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" FirstPageText="Прва" /> <asp:NumericPagerField /> <asp:NextPreviousPagerField ButtonType="Button" ShowLastPageButton="True" ShowNextPageButton="False" ShowPreviousPageButton="False" LastPageText="Последна" /> </Fields> </asp:DataPager> </div> </LayoutTemplate> <SelectedItemTemplate> <span style="background-color: #008A8C;font-weight: bold;color: #FFFFFF;">ИмеНаАктивноста: <asp:Label ID="ИмеНаАктивностаLabel" runat="server" Text='<%# Eval("ИмеНаАктивноста") %>' /> <br /> ТипКатегоријаНаАктивноста: <asp:Label ID="ТипКатегоријаНаАктивностаLabel" runat="server" Text='<%# Eval("ТипКатегоријаНаАктивноста") %>' /> <br /> МестоНаОдржувањеОбјава: <asp:Label ID="МестоНаОдржувањеОбјаваLabel" runat="server" Text='<%# Eval("МестоНаОдржувањеОбјава") %>' /> <br /> Датум: <asp:Label ID="ДатумLabel" runat="server" Text='<%# Eval("Датум") %>' /> <br /> Улога: <asp:Label ID="УлогаLabel" runat="server" Text='<%# Eval("Улога") %>' /> <br /> <br /> </span> </SelectedItemTemplate> </asp:ListView> </asp:Content> <asp:Content ID="Content1" runat="server" contentplaceholderid="HeadContent"> <style type="text/css"> .auto-style1 { width: 100%; } .auto-style2 { width: 528px; } </style> </asp:Content>
Прототип на апликацијата направена со Naked Objects во ASP.Net
User.cs
using NakedObjects; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CoDBIS_NakedObjects { public class User { public override string ToString() { return Name; } [Hidden] public virtual int Id { get; set; } [StringLength (50)] public virtual string Name { get; set; } public virtual string Gender { get; set; } public virtual string PlaceOfBirth { get; set; } [Mask("d")] public virtual DateTime DateOfBirth { get; set; } public virtual string Email { get; set; } public virtual string Employer { get; set; } public virtual string Position { get; set; } public IDomainObjectContainer Container { set; protected get; } #region AddActivity (collection) private ICollection<AddUserOnActivity> _AddActivity = new List<AddUserOnActivity>(); public virtual ICollection<AddUserOnActivity> AddActivity { get { return _AddActivity; } set { _AddActivity = value; } } public void AddToAddActivity(AddUserOnActivity value) { if (!(_AddActivity.Contains(value))) { _AddActivity.Add(value); } } public void RemoveFromAddActivity(AddUserOnActivity value) { if (_AddActivity.Contains(value)) { _AddActivity.Remove(value); } } public IList<AddUserOnActivity> Choices0RemoveFromAddActivity() { return _AddActivity.ToList(); } #endregion public AddUserOnActivity CreateNewUserOnActivity() //CreateNewOrder od tip Order { var order = Container.NewTransientInstance<AddUserOnActivity>(); order.User = this; return order; } public AddUserOnActivity CreateNewAddUserOnActivity() { AddUserOnActivity obj = Container.NewTransientInstance<AddUserOnActivity>(); obj.User = this; return obj; } } }
Activity.cs
using NakedObjects; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CoDBIS_NakedObjects { public class Activity { public override string ToString() { return Name; } [Hidden] public virtual int Id { get; set; } [StringLength (50), Title] public virtual string Name { get; set; } public virtual string Place { get; set; } // [Title, Mask("d")] public virtual DateTime Date { get; set; } public virtual string Category { get; set; } } }
Activityhistory.cs
using NakedObjects; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CoDBIS_NakedObjects { public class ActivityHistory { public override string ToString() { return Role.ToString() + " на " + Activity; } [Hidden] public virtual int Id { get; set; } [Hidden] public virtual AddUserOnActivity AddUserOnActivity { get; set; } public virtual Activity Activity { get; set; } [DefaultValue("")] public virtual string Role { get; set; } } }
Adduseronactivity.cs
using NakedObjects; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CoDBIS_NakedObjects { public class AddUserOnActivity { public override string ToString() { return User.ToString(); } [Hidden] public virtual int Id { get; set; } [Disabled] public virtual User User { get; set; } #region History (collection) private ICollection<ActivityHistory> _History = new List<ActivityHistory>(); public virtual ICollection<ActivityHistory> History { get { return _History; } set { _History = value; } } public void AddToHistory(ActivityHistory value) { if (!(_History.Contains(value))) { _History.Add(value); } } public void RemoveFromHistory(ActivityHistory value) { if (_History.Contains(value)) { _History.Remove(value); } } public IList<ActivityHistory> Choices0RemoveFromHistory() { return _History.ToList(); } #endregion public IDomainObjectContainer Container { set; protected get; } public ActivityHistory AddToHistory() { var history = Container.NewTransientInstance<ActivityHistory>(); history.AddUserOnActivity = this; return history; } public ActivityHistory CreateNewActivityHistory() { ActivityHistory obj = Container.NewTransientInstance<ActivityHistory>(); obj.AddUserOnActivity = this; return obj; } } }
Mydbcontext.cs
using System; using System.Collections.Generic; using System.Data.Entity; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CoDBIS_NakedObjects { public class MyDbContext : DbContext { public MyDbContext(String name) : base(name) { } public MyDbContext() { } public DbSet<User> Users { get; set; } } }
Userrepository.cs
using NakedObjects; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CoDBIS_NakedObjects { [DisplayName("Users")] public class UserRepository { public IDomainObjectContainer Container { set; protected get; } public IQueryable<User> AllUsers() { return Container.Instances<User>(); } public User CreateNewUser() { User obj = Container.NewTransientInstance<User>(); //set up any parameters //Container.Persist(ref obj); return obj; } #region Find public User Find(string searchString) { var query = from obj in Container.Instances<User>() where obj.Name.ToUpper().Contains(searchString.ToUpper()) select obj; return query.FirstOrDefault(); //(If inheriting from AbsractFactoryAndRepository can use:) return SingleObjectWarnIfNoMatch(query); } #endregion } }
Activityrepository.cs
using NakedObjects; using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace CoDBIS_NakedObjects { [DisplayName("Activities")] public class ActivityRepository { public IDomainObjectContainer Container { set; protected get; } public IQueryable<Activity> AllActivitys() { return Container.Instances<Activity>(); } public Activity CreateNewActivity() { Activity obj = Container.NewTransientInstance<Activity>(); //set up any parameters //Container.Persist(ref obj); return obj; } #region Find public Activity Find(string name ) { var query = from obj in Container.Instances<Activity>() where obj.Name.ToUpper().Contains(name.ToUpper()) select obj; return query.FirstOrDefault(); //(If inheriting from AbsractFactoryAndRepository can use:) return SingleObjectWarnIfNoMatch(query); } #endregion } }
Runweb.cs
using CoDBIS_NakedObjects; using NakedObjects.Boot; using NakedObjects.Core.Context; using NakedObjects.Core.NakedObjectsSystem; using NakedObjects.EntityObjectStore; using NakedObjects.Services; using NakedObjects.Web.Mvc; using NakedObjects.Web.Mvc.Helpers; using System.Data.Entity; using System.Data.Entity.Infrastructure; namespace CoDBIS_MVC.App_Start { public class RunWeb : RunMvc { protected override NakedObjectsContext Context { get { return HttpContextContext.CreateInstance(); } } protected override IServicesInstaller MenuServices { get { return new ServicesInstaller( new UserRepository(), new ActivityRepository()); } } protected override IServicesInstaller ContributedActions { get { return new ServicesInstaller(); } } protected override IServicesInstaller SystemServices { get { return new ServicesInstaller(new SimpleEncryptDecrypt()); } } // example functions that gets types for AssociateTypes below //private static Type[] AdventureWorksTypes() { // var allTypes = AppDomain.CurrentDomain.GetAssemblies().Single(a => a.GetName().Name == "AdventureWorksModel").GetTypes(); // return allTypes.Where(t => t.BaseType == typeof(AWDomainObject) && !t.IsAbstract).ToArray(); //} // //private static Type[] CodeFirstTypes() { // return new[] {typeof(Class1), typeof(Class2)}; //} protected override IObjectPersistorInstaller Persistor { get { Database.DefaultConnectionFactory = new SqlCeConnectionFactory("System.Data.SqlServerCe.4.0"); //For in-memory database Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyDbContext>()); //Optional behaviour for CodeFirst var installer = new EntityPersistorInstaller(); //installer.UsingEdmxContext("Model").AssociateTypes(AdventureWorksTypes); // for Model/Database First installer.AddCodeFirstDbContextConstructor(() => new MyDbContext()); //For Code First return installer; } } public static void Run() { new RunWeb().Start(); } } }
Тестирање на апликацијата со Selenium IDE
Тестовите се експортирани како C#/NUnit/Web Driver.
Register.cs
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class Register { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheRegisterTest() { driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); driver.FindElement(By.Id("ctl10_registerLink")).Click(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("novstudent3"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("novstudent1@mail.com"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("novstudent"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("novstudent"); driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("Student Nov"); driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("New York"); driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("01-08-1990"); driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("BS"); driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("Proba"); driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("Proba"); driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("Proba"); driver.FindElement(By.Id("MainContent_btnAdd")).Click(); driver.FindElement(By.Id("MainContent_Button2")).Click(); driver.FindElement(By.Id("MainContent_Button1")).Click(); driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("rrr"); driver.FindElement(By.Id("MainContent_btnShow")).Click(); driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("uuu"); driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); driver.FindElement(By.LinkText("Мојата Биографија")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class LoginFieldValidation { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheLoginFieldValidationTest() { driver.Navigate().GoToUrl(baseURL + "/"); driver.FindElement(By.Id("ctl10_loginLink")).Click(); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("aaa"); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student12"); driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1233"); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
Registerfieldvalidation.cs
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class RegisterFieldValidation { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheRegisterFieldValidationTest() { driver.Navigate().GoToUrl(baseURL + "/"); driver.FindElement(By.Id("ctl10_registerLink")).Click(); driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abc"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("abc@mail.com"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcabc1"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcabc1"); driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcde"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("abcdefg1"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abvv"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("abcdefg1"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("abcdefg"); driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); driver.FindElement(By.LinkText("Мојата Биографија")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
Search.cs
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class Search { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheSearchTest() { driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); driver.FindElement(By.LinkText("Контакт")).Click(); driver.FindElement(By.Id("txtSearch")).Clear(); driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); driver.FindElement(By.Id("btnSearch")).Click(); driver.FindElement(By.LinkText("Почетна")).Click(); driver.FindElement(By.Id("txtSearch")).Clear(); driver.FindElement(By.Id("txtSearch")).SendKeys("IS"); driver.FindElement(By.Id("btnSearch")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
Changepassword.cs
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class ChangePassword { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheChangePasswordTest() { driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); driver.FindElement(By.Id("ctl10_loginLink")).Click(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); driver.FindElement(By.Id("ctl10_hpLink")).Click(); driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).Clear(); driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_CurrentPassword")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).Clear(); driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_NewPassword")).SendKeys("student1234"); driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).Clear(); driver.FindElement(By.Id("MainContent_ctl07_ChangePasswordContainerID_ConfirmNewPassword")).SendKeys("student1234"); driver.FindElement(By.Name("ctl00$MainContent$ctl07$ChangePasswordContainerID$ctl04")).Click(); driver.FindElement(By.LinkText("Одјави се")).Click(); driver.FindElement(By.Id("ctl10_loginLink")).Click(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); driver.FindElement(By.LinkText("Одјави се")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
Addinfo.cs
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class AddInfoLater { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheAddInfoLaterTest() { driver.Navigate().GoToUrl(baseURL + "/"); driver.FindElement(By.Id("ctl10_registerLink")).Click(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_UserName")).SendKeys("mojasmetka1"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Email")).SendKeys("adresa@mail.com"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_Password")).SendKeys("mojasmetka1"); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).Clear(); driver.FindElement(By.Id("MainContent_RegisterUser_CreateUserStepContainer_ConfirmPassword")).SendKeys("mojasmetka1"); driver.FindElement(By.Name("ctl00$MainContent$RegisterUser$CreateUserStepContainer$ctl09")).Click(); driver.FindElement(By.Id("MainContent_Button2")).Click(); driver.FindElement(By.LinkText("Мојата Биографија")).Click(); driver.FindElement(By.CssSelector("span.username")).Click(); driver.FindElement(By.Id("MainContent_txtImePrezime")).Clear(); driver.FindElement(By.Id("MainContent_txtImePrezime")).SendKeys("moja"); driver.FindElement(By.Id("MainContent_rblPol_1")).Click(); driver.FindElement(By.Id("MainContent_txtMesto")).Clear(); driver.FindElement(By.Id("MainContent_txtMesto")).SendKeys("ww"); driver.FindElement(By.Id("MainContent_txtDatum")).Clear(); driver.FindElement(By.Id("MainContent_txtDatum")).SendKeys("16.06.1989"); driver.FindElement(By.Id("MainContent_txtObrazovanie")).Clear(); driver.FindElement(By.Id("MainContent_txtObrazovanie")).SendKeys("ww"); driver.FindElement(By.Id("MainContent_txtInstitucija")).Clear(); driver.FindElement(By.Id("MainContent_txtInstitucija")).SendKeys("ww"); driver.FindElement(By.Id("MainContent_txtVrabotenVo")).Clear(); driver.FindElement(By.Id("MainContent_txtVrabotenVo")).SendKeys("ww"); driver.FindElement(By.Id("MainContent_txtPozicija")).Clear(); driver.FindElement(By.Id("MainContent_txtPozicija")).SendKeys("ww"); driver.FindElement(By.Id("MainContent_btnAdd")).Click(); driver.FindElement(By.LinkText("Мојата Биографија")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
Addnewactivity.cs
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class AddNewActivity { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheAddNewActivityTest() { driver.Navigate().GoToUrl(baseURL + "/Default.aspx"); driver.FindElement(By.Id("ctl10_loginLink")).Click(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student1234"); driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); driver.FindElement(By.Id("MainContent_Button1")).Click(); driver.FindElement(By.Id("MainContent_txtName")).Clear(); driver.FindElement(By.Id("MainContent_txtName")).SendKeys("nestonovo"); driver.FindElement(By.Id("MainContent_txtCategory")).Clear(); driver.FindElement(By.Id("MainContent_txtCategory")).SendKeys("/"); driver.FindElement(By.Id("MainContent_txtPlace")).Clear(); driver.FindElement(By.Id("MainContent_txtPlace")).SendKeys("Proba"); driver.FindElement(By.Id("MainContent_txtDate")).Clear(); driver.FindElement(By.Id("MainContent_txtDate")).SendKeys("11.11.2013"); driver.FindElement(By.Id("MainContent_txtRole")).Clear(); driver.FindElement(By.Id("MainContent_txtRole")).SendKeys("/"); driver.FindElement(By.Id("MainContent_btnInsert")).Click(); driver.FindElement(By.LinkText("Мојата Биографија")).Click(); driver.FindElement(By.LinkText("Одјави се")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
Addusertoexistingactivity.cs
using System; using System.Text; using System.Text.RegularExpressions; using System.Threading; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using OpenQA.Selenium.Support.UI; namespace SeleniumTests { [TestFixture] public class AddUserToExistingActivity { private IWebDriver driver; private StringBuilder verificationErrors; private string baseURL; private bool acceptNextAlert = true; [SetUp] public void SetupTest() { driver = new FirefoxDriver(); baseURL = "http://localhost:1400/"; verificationErrors = new StringBuilder(); } [TearDown] public void TeardownTest() { try { driver.Quit(); } catch (Exception) { // Ignore errors if unable to close the browser } Assert.AreEqual("", verificationErrors.ToString()); } [Test] public void TheAddUserToExistingActivityTest() { driver.Navigate().GoToUrl(baseURL + "/"); driver.FindElement(By.Id("ctl10_loginLink")).Click(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_UserName")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_Password")).Clear(); driver.FindElement(By.Id("MainContent_ctl00_Password")).SendKeys("student123"); driver.FindElement(By.Id("MainContent_ctl00_RememberMe")).Click(); driver.FindElement(By.Id("MainContent_ctl00_btnLogin")).Click(); driver.FindElement(By.Id("MainContent_Button1")).Click(); driver.FindElement(By.Id("MainContent_txtActivity")).Clear(); driver.FindElement(By.Id("MainContent_txtActivity")).SendKeys("nnnn"); driver.FindElement(By.Id("MainContent_btnShow")).Click(); driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).Clear(); driver.FindElement(By.Id("MainContent_txtRoleOnExisting")).SendKeys("mmm"); driver.FindElement(By.Id("MainContent_gvMe_CheckBox1_0")).Click(); driver.FindElement(By.Id("MainContent_btnAddMe")).Click(); driver.FindElement(By.LinkText("Мојата Биографија")).Click(); driver.FindElement(By.LinkText("2")).Click(); } private bool IsElementPresent(By by) { try { driver.FindElement(by); return true; } catch (NoSuchElementException) { return false; } } private bool IsAlertPresent() { try { driver.SwitchTo().Alert(); return true; } catch (NoAlertPresentException) { return false; } } private string CloseAlertAndGetItsText() { try { IAlert alert = driver.SwitchTo().Alert(); string alertText = alert.Text; if (acceptNextAlert) { alert.Accept(); } else { alert.Dismiss(); } return alertText; } finally { acceptNextAlert = true; } } } }
Кориснички случај: Внесување нова активност и приклучување кон веќе постоечка
Use Case: Внесување на активност и приклучување кон активност
Цел: Корисникот креира нова активност, се приклучува кон веќе постоечка, т.е се додава себеси и/или додава некој друг учесник.
Категорија: Примарна
Предуслов: Да се има одржано некаква активност (креирано некој труд, проект, семинар и сл.)
Пост услов при успех: Успешно внесен учесник на активност.
Пост услов при неуспех: Неуспешен внес на учесник на активност и обид за повторено внесување.
Актер: Главен уредник и регистрирани корисници.
Triggering Event: Корисникот да сака да внесе некаква активност или да се приклучи кон веќе постоечка или да додаде некој друг учесник.
Опис:
- Корисник креира нова активност, внесува име, место, датум и категорија за активноста, ја става улогата што ја имал во активноста и со клик на копче активноста се додава во неговата биографија.
- Ако ја има активноста во системот, се впишува името, по што се прикажува листа со активности кои ги содржат клучните зборови (од кои некоја е таа што се бара) и корисникот се приклучува во листата на учесници во таа активност.
- Ако при внес на нова активност, истата ја има во системот, а корисникот поради некоја причина не избере да се приклучи кон неа и продолжи да ја креира како нова, пред последната потврда за внес се проверуваат внесените параметри. Ако се поклопуваат повеќето, ќе врати порака дека има слична активност, па корисникот ќе може да избере дали да се приклучи. Ако се поклопуваат сите параметри главниот уредник може да го одбие креирањето на новата активност, за да се избегне повторување. (пр. активност нека биде напишана книга, со истите автори, истиот наслов, ист издавач, ама различно издание и година на издавање, што е всушност нова активност.)
Екстензии:
Еден корисник може да има повеќе улоги во одредена активност.
Кога корисник сака да додаде други учесници кои учествувале на активноста заедно со него, ако корисникот кој треба да се додаде го има во системот, при самото впишување на неговото име се нуди како избор и се додава, по што се чека тој учесник да потврди дека сака да се додаде на одредената активност. Ако го нема во системот се третира само како атрибут име и презиме.
Корисник може да се додава на активност (себеси или друг учесник), само ако ја има активноста, т.е. задолжително е прво да се креира активност, (корисникот може да го има или нема на системот) и тогаш се врши приклучување на учесници кон активности.
Attachments (6)
- AssemblyDependencies.jpg (487.1 KB ) - added by 11 years ago.
- Packages.jpg (128.9 KB ) - added by 11 years ago.
- ClassDiagram.jpg (475.6 KB ) - added by 11 years ago.
- ActivityDiagram.jpeg (59.4 KB ) - added by 11 years ago.
- UseCaseClassDiagram.jpeg (48.8 KB ) - added by 11 years ago.
- SequenceDiagram.jpeg (109.3 KB ) - added by 11 years ago.
Download all attachments as: .zip