public void RemoveWagonNullTest() { Administration admin = new Administration(); Wagon wagon = null; admin.Remove(wagon); }
public void AdministrationRule_Is_Not_Satisfied_When_Distance_To_SettlementCenter_Is_Greater_Than_40_Pixels() { IRoad road = _settlement.Roads.First(); var administration = new Administration() { Position = new Point(99, 51) }; var buildingPositions = road.GetPossibleBuildingPositions(new PossibleBuildingPositions(_settlement.Roads, _settlement.Fields)); buildingPositions.Remove(administration.Position); while (_settlement.Roads.SelectMany(g => g.Buildings).Count() < 120) { var position = buildingPositions[RandomProvider.Next(buildingPositions.Count)]; var building = new Residence { Position = position }; building.Road = road; _settlement.AddBuildingToRoad(road, building); } Assert.AreEqual(0, administration.CalculateFitness(new BuildingRule() { BuildingRoad = road, Fields = _settlement.Fields, Roads = _settlement.Roads, SettlementCenter = _settlement.SettlementCenter })); }
public MainForm(Administration administrationLogIn) { InitializeComponent(); administration = administrationLogIn; this.LoadMissions(); }
public ActionResult Delete(int?id, Administration collection) { Administration administration = new Administration(); try { if (id == null) { return(HttpNotFound()); } administration = db.Administrations.Find(id); if (administration == null) { return(HttpNotFound()); } db.Administrations.Remove(administration); db.SaveChanges(); return(RedirectToAction("Index")); } catch { return(View()); } }
public void AddNewWagonTest() { Administration admin = new Administration(); Wagon wagon = new Wagon(1, 20, 10); Assert.AreEqual(true, admin.Add(wagon)); }
public void RemoveNotExistinWagonTest() { Administration admin = new Administration(); Wagon wagon = new Wagon(1, 1, 1); Assert.AreEqual(false, admin.Remove(wagon)); }
private static void ChooseDate(Administration administration) { IncorrectInput(1, 7, "Enter the appropriate for you day(from 1 to 7):" + "\nConsider that buses only drive on odd days, while minivans only on even days", out int num); Console.WriteLine($"[{administration.ChooseDate(num)}]"); int time = 0; List <int> hours = administration.ChooseTime(); Console.WriteLine("There are such arrival times in choosen day:" + "\nYou can obtain 1) or 2)"); foreach (int i in hours) { Console.Write($"[{i}] \t"); } IncorrectInput(1, 2, "\nChoose one option", out int choice); switch (choice) { case 1: time = hours[0]; break; case 2: time = hours[1]; break; } Console.WriteLine($"You chose {time}"); administration.SetTime(time); }
public void Setup() { admin = new Administration(); animala = new Cat(13, new SimpleDate(9, 8, 1995), "Harry", ""); animalb = new Cat(13, new SimpleDate(9, 8, 1998), "Lerry", "Bites, Growls, Spits, does a lot of humping"); animalc = new Cat(16, new SimpleDate(9, 8, 2005), "Kit", "Bites"); }
private static void WatchTimetables(Administration administration) { Dictionary <string, List <int> > diction = new Dictionary <string, List <int> >(); using (var sr = new StreamReader("Hours.txt")) { while (!sr.EndOfStream) { string[] temp = sr.ReadLine().Split(); int temp1 = int.Parse(temp[1]); int temp2 = int.Parse(temp[2]); List <int> filedata = new List <int>(); filedata.Add(temp1); filedata.Add(temp2); diction.Add(temp[0], filedata); } } foreach (KeyValuePair <string, List <int> > keyValue in diction) { Console.Write(keyValue.Key + " \t"); foreach (var item in keyValue.Value) { Console.Write(item + " \t"); } Console.WriteLine(); } }
public Afspraken(Administration a, bool loadMeeting) { this.InitializeComponent(); administration = a; rtbInfo.Enabled = false; lblType.Text = loadMeeting ? "Afspraken:" : "Reviews"; containsMeetings = loadMeeting; if (loadMeeting) { //Load meetings foreach (string s in administration.GetMainAccountMeetings()) { rtbInfo.Text += s + Environment.NewLine + Environment.NewLine; } } else { //If the logged in user is a 'hulpverlener', he wants to see the reviews posted to his account //If the logged in user is a 'hulpbehoevende', he wants to see the reviews he posted to people bool isPoster = administration.MainAccountData(6) == "Hulpverlener" ? false : true; foreach (string s in administration.GetAccountReviews(isPoster)) { rtbInfo.Text += s + Environment.NewLine + Environment.NewLine; } } }
protected void btnSubmit_Click(object sender, EventArgs e) { Administration objAdmin = new Administration(); string strEmail = txtEmail.Text.Trim(); string strPwd = txtPwd.Text.Trim(); string CamperLoginID; int retValue; DataSet CamperCredentials; CamperCredentials = objAdmin.GetCamperCredentials(strEmail); if (CamperCredentials.Tables[0].Rows.Count > 0) { lblErr.Text = "UserID already exists"; } else { retValue = objAdmin.UserRegistration(strEmail, strPwd, out CamperLoginID); Session["CamperLoginID"] = CamperLoginID; Session["UsrID"] = null; // Redirect to the basic camper info page string strRedirURL; strRedirURL = ConfigurationManager.AppSettings["CamperBasicInfo"].ToString(); Server.Transfer(strRedirURL); } }
private static void HandleAction(uint user, uint target, Location targetLocation, params string[] args) { string lastSubmission = GetLocalString(user, "DELETE_CHARACTER_LAST_SUBMISSION"); bool isFirstSubmission = true; // Check for the last submission, if any. if (!string.IsNullOrWhiteSpace(lastSubmission)) { // Found one, parse it. DateTime dateTime = DateTime.Parse(lastSubmission); if (DateTime.UtcNow <= dateTime.AddSeconds(30)) { // Player submitted a second request within 30 seconds of the last one. // This is a confirmation they want to delete. isFirstSubmission = false; } } // Player hasn't submitted or time has elapsed if (isFirstSubmission) { SetLocalString(user, "DELETE_CHARACTER_LAST_SUBMISSION", DateTime.UtcNow.ToString(CultureInfo.InvariantCulture)); FloatingTextStringOnCreature("Please confirm your deletion by entering another \"/delete <CD Key>\" command within 30 seconds.", user, false); } else { var playerID = GetObjectUUID(user); var entity = DB.Get <Player>(playerID); entity.IsDeleted = true; DB.Set(playerID, entity); BootPC(user, "Your character has been deleted."); Administration.DeletePlayerCharacter(user, true); } }
public void TestListAliases() { Initialize(); var adminService = new Administration(); var results = adminService.ListAliases(new AuthenticatedData() { Username = "******", Password = "******" }, "Admin"); Assert.AreEqual(1, results.Count); // Try to log in with a non-existant alias. var clientService = new ClientService(); var loginResult = clientService.Login(new LoginData() { Username = "******", Password = "******", Alias = "Jerky", LobbyId = 1 }); Assert.AreEqual(LoginStatus.Authenticated, loginResult.Status); Assert.AreEqual("Admin", loginResult.AcceptedAlias, "Logging in with an invalid alias reverts back to the oldest available alias."); results = adminService.ListAliases(new AuthenticatedData() { Username = "******", Password = "******" }, "Admin"); Assert.AreEqual(1, results.Count); }
public async Task <IActionResult> Update([FromBody] Administration model, CancellationToken cancellationToken) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (model.NewVersion == null) { return(BadRequest(new ErrorMessage { Message = "Missing new version!" })); } if (model.NewVersion.Major != application.Version.Major) { return(BadRequest(new ErrorMessage { Message = "Cannot update to a different suite version!" })); } if (!serverUpdater.WatchdogPresent) { return(UnprocessableEntity(new ErrorMessage { Message = RestartNotSupportedException })); } return(await CheckReleasesAndApplyUpdate(model.NewVersion, cancellationToken).ConfigureAwait(false)); }
public string SaveAdministrationInfo(Administration administration) { try { connection.Open(); string message; queray = "Insert into administrationInfo_tbl Values('" + administration.Name + "','" + administration.Username + "','" + administration.Type + "','" + administration.Gender + "','" + administration.Note + "')"; command = new SqlCommand(queray, connection); int effectiveRow = command.ExecuteNonQuery(); if (effectiveRow != 0) { message = "Administration Insert Successful."; } else { message = "Sorry Please Tyr Again."; } connection.Close(); return(message); } catch (Exception exception) { throw new Exception(exception.Message); } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } }
public Administration GetAdministrationInfo(string username) { try { Administration administration = new Administration(); connection.Open(); queray = "Select * From administrationInfo_tbl where username=('" + username + "')"; command = new SqlCommand(queray, connection); int effectiveRow = command.ExecuteNonQuery(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read() == true) { administration.Name = reader[0].ToString(); administration.Username = reader[1].ToString(); administration.Type = reader[2].ToString(); administration.Gender = reader[3].ToString(); administration.Note = reader[4].ToString(); } connection.Close(); return(administration); } catch (Exception exception) { throw new Exception(exception.Message); } finally { if (connection.State == ConnectionState.Open) { connection.Close(); } } }
private void MergeAdministration(Administration originalAdministration, AdministrationRequest Administration) { originalAdministration.Address = Administration.Address; originalAdministration.CUIT = Administration.CUIT; originalAdministration.Name = Administration.Name; originalAdministration.StartDate = Administration.StartDate; }
public async Task <IActionResult> Update([FromBody] Administration model, CancellationToken cancellationToken) { if (model == null) { throw new ArgumentNullException(nameof(model)); } if (model.NewVersion == null) { return(BadRequest(new ErrorMessage(ErrorCode.ModelValidationFailure) { AdditionalData = "newVersion is required!" })); } if (model.NewVersion.Major != assemblyInformationProvider.Version.Major) { return(BadRequest(new ErrorMessage(ErrorCode.CannotChangeServerSuite))); } if (!serverUpdater.WatchdogPresent) { return(UnprocessableEntity(new ErrorMessage(ErrorCode.MissingHostWatchdog))); } return(await CheckReleasesAndApplyUpdate(model.NewVersion, cancellationToken).ConfigureAwait(false)); }
public void RemoveRouteNullTest() { Administration admin = new Administration(); Route route = null; admin.Remove(route); }
public void RemoveTrainNullTest() { Administration admin = new Administration(); Train train = null; admin.Remove(train); }
public void RemoveNotExistinTrainTest() { Administration admin = new Administration(); Train train = new Train(1, 1); Assert.AreEqual(false, admin.Remove(train)); }
public void RemoveStationWithoutNameTest() { Administration admin = new Administration(); Station station = new Station(""); admin.Remove(station); }
public void AddWagonNullTest() { Administration admin = new Administration(); Wagon wagon = null; admin.Add(wagon); }
public void RemoveNotExistinStationTest() { Administration admin = new Administration(); Station station1 = new Station("station1"); Assert.AreEqual(false, admin.Remove(station1)); }
public void AddNewStationTest() { Administration admin = new Administration(); Station station = new Station("station1"); Assert.AreEqual(station, admin.Add(station)); }
public void RemoveStationNullTest() { Administration admin = new Administration(); Station station = null; admin.Remove(station); }
public void AddNewRouteTest() { Administration admin = new Administration(); Route route = new Route(1); Assert.AreEqual(true, admin.Add(route)); }
public void AddStationEmptyStringTest() { Administration admin = new Administration(); Station station = new Station(""); admin.Add(station); }
public void AddRouteNullTest() { Administration admin = new Administration(); Route route = null; admin.Add(route); }
public DarkRidesDataGrid() { InitializeComponent(); DataContext = Administration.ListeDarkRides(); }
public ZombiesDataGrid() { InitializeComponent(); DataContext = Administration.ListeZombies(); }
public void RemoveNotExistinRouteTest() { Administration admin = new Administration(); Route route = new Route(1); Assert.AreEqual(false, admin.Remove(route)); }
public Registreren2(Form p, Administration a) { this.InitializeComponent(); this.previous = p; this.Administration = a; cbSkills.DataSource = a.AllSkillTypes(); this.cbSkills.SelectedIndex = 0; }
public AdminForm(Form p, Administration a) { this.InitializeComponent(); this.Administration = a; this.previous = p; // Select first index of lbRubrics this.lbTables.SelectedIndex = 0; }
public Registreren(Form p, Administration a) { this.InitializeComponent(); this.previous = p; this.Administration = a; this.cbRoles.SelectedIndex = 0; this.cbSex.SelectedIndex = 0; }
public UpdateProfile(Administration a) { InitializeComponent(); this.administration = a; tbAdress.Text = administration.MainAccountData(3); tbEmail.Text = administration.MainAccountData(8); tbName.Text = administration.MainAccountData(2); tbPhotoPath.Text = administration.MainAccountData(4); cbSex.SelectedItem = administration.MainAccountData(7); }
public MaakAfspraak(Administration a, int accIndex) { InitializeComponent(); this.administration = a; dtpTime.Format = DateTimePickerFormat.Custom; dtpTime.CustomFormat = "dd-MMM-yyyy HH:mm:s"; userID = Convert.ToInt32(administration.AccountData(accIndex, 1)); lblName.Text = username = administration.AccountData(accIndex, 2); }
public PlaatsHulpvraag(Form p, Administration a) { this.InitializeComponent(); this.previous = p; this.Administration = a; cbSkills.DataSource = Administration.AllSkillTypes(); this.cbSkills.SelectedIndex = 0; this.dtpDate.CustomFormat = "d MMMM yyyy - hh:mm:ss"; }
public PlaatsReview(Form p, Administration a, int userID, string username) { this.InitializeComponent(); this.administration = a; this.previous = p; this.userID = userID; this.username = username; changeStars(); cbHulpverlener.DataSource = administration.GetAccounts("Hulpverlener"); cbHulpverlener.Text = username; }
public object Create(object parent, object configContext, XmlNode section) { Administration a = new Administration(); a.TemplatePath = section.Attributes["templatePath"] != null ? section.Attributes["templatePath"].Value : a.TemplatePath; a.TemplateFileName = section.Attributes["templateFileName"] != null ? section.Attributes["templateFileName"].Value : a.TemplateFileName; if (section.Attributes["newStyle"] != null) { bool newStyle = false; bool.TryParse(section.Attributes["newStyle"].Value, out newStyle); a.NewStyle = newStyle; } return a; }
public HOPEForm(Administration administrationMain, HOPE hopeLoad) { InitializeComponent(); administration = administrationMain; hope = hopeLoad; if (hope != null) { LoadHope(); } this.LoadFunctions(); this.LoadBoats(); this.LoadMaterials(); }
public SINForm(Administration administrationMain, SIN sinLoad) { InitializeComponent(); administration = administrationMain; sin = sinLoad; if (sin != null) { this.LoadSin(); } this.LoadFunctions(); this.LoadBoats(); this.LoadMaterials(); }
public Inloggen(bool usbAdmin) { this.InitializeComponent(); this.Administration = new Administration(Application.StartupPath); //Clipboard.SetText(Administration.giveTestHash()); //if admin, continue to other screen with details if (usbAdmin) { AdminForm form = new AdminForm(this, this.Administration); form.Show(); this.Hide(); } }
public HoofdForm(Administration a) { this.InitializeComponent(); this.Administration = a; //Check if the user is a 'hulpverlener', which in that case, they should not be allowed to do as much as usual. if (this.Administration.MainAccountData(6) == "Hulpverlener") { tsbtnPlaceQuestion.Visible = false; tsbtnShowOwnRequests.Visible = false; } lblName.Text = a.MainAccountData(2); pbAvatar.ImageLocation = a.MainAccountData(4); }
/// <summary> /// Gets all pages in profile. /// </summary> /// <returns>List<Page></returns> public List<Page> GetAllPagesInProfile() { try { Administration admin = new Administration(); string requesturl = "https://" + _iFormConfig.iformserverurl + ".iformbuilder.com/exzact/api/profiles/" + _iFormConfig.profileid + "/pages"; WebResponse request = Utilities.GetRequest(requesturl, admin.GetAccessCode()); DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(iFormBuilderPages)); iFormBuilderPages access = (iFormBuilderPages)jsonSerializer.ReadObject(request.GetResponseStream()); return access.PAGES; } catch (Exception ex) { return null; } }
//Find the helpers by default public Zoeken(bool findV, Administration a) { this.InitializeComponent(); this.administration = a; lbUsers.DataSource = null; if (findV) { this.V = "Hulpverlener"; lbUsers.DataSource = administration.GetAccounts("Hulpverlener"); } else { this.V = "Hulpbehoevende"; lbUsers.DataSource = administration.GetAccounts("Hulpbehoevende"); } }
//load in either all the questions, or their own public HulpVragen(Form p, Administration a, bool all) { this.InitializeComponent(); this.Administration = a; this.previous = p; this.allLoaded = all; this.questionOpened = false; //Check if the user is a 'hulpverlener', which in that case, they should not be allowed to do as much as usual. if (this.Administration.MainAccountData(6) == "Hulpverlener") { btnNieuw.Enabled = false; } //load in questions lbHulpvragen.DataSource = Administration.GetQuestionNames(allLoaded); }
public Profiles(Administration a, int accIndex) { InitializeComponent(); this.administration = a; this.userIndex = accIndex; //Check if the user is a 'hulpverlener', which in that case, they should not be allowed to do as much as usual. if (this.administration.MainAccountData(6) == "Hulpverlener") { plaatsenToolStripMenuItem.Visible = false; } userID = Convert.ToInt32(administration.AccountData(accIndex, 1)); pbAvatar.ImageLocation = administration.AccountData(accIndex, 4); lblName.Text = username = administration.AccountData(accIndex, 2); lblRole.Text = administration.AccountData(accIndex, 6); }
protected void Page_Load(object sender, EventArgs e) { if ((Request.QueryString["led"]) == null) { if ((Request.UrlReferrer == null) || (!Request.UrlReferrer.AbsoluteUri.Contains("Register.aspx") && !Request.UrlReferrer.AbsoluteUri.Contains("Login.aspx") && !Request.UrlReferrer.AbsoluteUri.Contains("ChangePasswordSuccess.aspx") && !Request.UrlReferrer.AbsoluteUri.Contains("RecoverPassword.aspx"))) { if (Request.QueryString["logout"] != null) { //Session.Abandon(); FormsAuthentication.SignOut(); Response.Redirect("Login.aspx?led=1"); } if (Request.QueryString["egiftid"] != null) { string eGiftId = Request.QueryString["egiftid"]; Administration admin = new Administration(); CharityEvents Event = admin.GetEventByEgiftId(eGiftId); if (Event != null && Event.UserId == Guid.Empty) { Response.Redirect("Register.aspx?egiftid=" + eGiftId + "&ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]), false); return; } } if (Request.QueryString["PMC"] != null) { Response.Redirect("Register.aspx?PMC=yes&ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"])); } Response.Redirect("Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"])); } if (Request.QueryString["logout"] != null) { foreach (HttpCookie cookie in Request.Cookies) { cookie.Expires = DateTime.Now.AddDays(-1d); } Response.Redirect("Login.aspx"); } } RegisterHyperLink.NavigateUrl = "Register.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); ForgotPasswordHyperLink.NavigateUrl = "RecoverPassword.aspx?ReturnUrl=" + HttpUtility.UrlEncode(Request.QueryString["ReturnUrl"]); }
public bool Toss(Administration.ITeam caller) { var rnd = new Random(); return Convert.ToBoolean(rnd.Next(1)); }
/// <summary> /// Gets the page. /// </summary> /// <param name="page_id">The page_id.</param> /// <returns>Page</returns> public Page GetPage(long page_id) { try { Administration admin = new Administration(); string requesturl = "https://" + _iFormConfig.iformserverurl + ".iformbuilder.com/exzact/api/profiles/" + _iFormConfig.profileid + "/pages/" + page_id; WebResponse request = Utilities.GetRequest(requesturl, admin.GetAccessCode()); DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(iFormBuilderPage)); iFormBuilderPage access = (iFormBuilderPage)jsonSerializer.ReadObject(request.GetResponseStream()); if (access.PAGE.ID != 0) { Page page = (Page)access.PAGE; page.Elements = access.ELEMENTS; //Look for any subforms in the page foreach (Element ele in page.SubformElements) { page.Subforms.Add((Page)this.GetPage(ele.DATA_SIZE)); } return page; } return null; } catch (Exception ex) { return null; } }
protected void RegisterUser_CreatedUser(object sender, EventArgs e) { FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); if (Request.QueryString["PMC"] != null) { string eGiftId = ((TextBox)RegisterUserWizardStep.Controls[0].FindControl("PMCData").FindControl("EGIFTID")).Text; Administration admin = new Administration(); CharityEvents Event = admin.GetEventByEgiftId(eGiftId); if (Event != null && Event.UserId == Guid.Empty) { Response.Redirect("EGIFTIDRegister.aspx?egiftid=" + eGiftId); return; } } else if (Request.QueryString["Jimmy"] != null) { string eGiftId = ((TextBox)RegisterUserWizardStep.Controls[0].FindControl("JimmyData").FindControl("JimmyEgiftID")).Text; Administration admin = new Administration(); Response.Redirect("../Funds/EditFund.aspx?Jimmy=yes&egiftid=" + eGiftId); return; } else if (Request.QueryString["event"] != null) { string strEvent = Request.QueryString["event"].ToString(); Response.Redirect("../Funds/EditFund.aspx?event=" + strEvent); return; } string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/"; } Response.Redirect(continueUrl); }
public void ReloadModuleDataViewApplication() { Dictionary<string, ModuleDataView> dictionaryModule = new Dictionary<string, ModuleDataView>(); Administration adminClientRef = new Administration(); ICollection<AbstractSearch> searchCriteria = new List<AbstractSearch>(); List<ModuleDataView> list = adminClientRef.GetAllModule(searchCriteria, "", Constants.SORTING_ASC).ToList(); foreach (ModuleDataView key in list) { dictionaryModule.Add(key.ModuleSysName, key); } this.Application.Lock(); this.Application.Remove(Constants.APPLICATION_MODULES_LIST); this.Application.Add(Constants.APPLICATION_MODULES_LIST, dictionaryModule); this.Application.UnLock(); LogDebug("Modules was reloaded in application"); }
protected void JimmyFundIDAvailableValidator_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = true; if (Request.QueryString["Jimmy"] != null) { string eGiftId = ((TextBox)RegisterUserWizardStep.Controls[0].FindControl("JimmyData").FindControl("JimmyEgiftID")).Text; if (!string.IsNullOrEmpty(eGiftId.Trim())) { Administration admin = new Administration(); CharityEvents Event = admin.GetEventByEgiftId(eGiftId, "Jimmy"); if (Event != null) { args.IsValid = false; } } } }
static void Main() { var adm = new Administration(); var bits = new BitArray(25); }
/// <summary> /// HTTPs the post. /// </summary> /// <param name="uri">The URI.</param> /// <param name="parameters">The parameters.</param> /// <param name="postmethod">The postmethod.</param> /// <returns></returns> public static WebResponse HttpPost(string uri, string parameters,string accestoken ,PostType postmethod) { // parameters: name1=value1&name2=value2 WebRequest webRequest = WebRequest.Create(uri); webRequest.Method = postmethod.ToString(); if (postmethod != PostType.GET) { Stream os = null; try { // send the Post //Add the Access Code and the Parameter to the String Administration admin = new Administration(); string opts = "ACCESS_TOKEN=" + accestoken + "&VERSION=5.1"; if (parameters == null) parameters = opts; else parameters = string.Format("{0}&{1}", opts, parameters); webRequest.ContentType = "application/x-www-form-urlencoded"; byte[] bytes = Encoding.ASCII.GetBytes(parameters); webRequest.ContentLength = bytes.Length; //Count bytes to send webRequest.Method = postmethod.ToString(); os = webRequest.GetRequestStream(); os.Write(bytes, 0, bytes.Length); //Send it WebResponse webResponse = webRequest.GetResponse(); return webResponse; } catch (WebException ex) { //TODO: Handle Exception //MessageBox.Show(ex.Message, "HttpPost: Request error", // MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (os != null) { os.Close(); } } } return null; }
public static WebResponse JSONPost(string uri, string parameters, string accestoken, PostType postmethod) { // parameters: name1=value1&name2=value2 WebRequest webRequest = WebRequest.Create(uri); webRequest.Method = postmethod.ToString(); if (postmethod != PostType.GET) { Stream os = null; try { // send the Post //Add the Access Code and the Parameter to the String Administration admin = new Administration(); webRequest.ContentType = "application/json"; webRequest.Headers.Add(HttpRequestHeader.Authorization, string.Format("Bearer {0}", accestoken)); webRequest.Headers.Add("X-IFORM-API-REQUEST-ENCODING", "JSON"); webRequest.Headers.Add("X-IFORM-API-VERSION", "5.1"); using (var streamWriter = new StreamWriter(webRequest.GetRequestStream())) { streamWriter.Write(parameters); } WebResponse webResponse = webRequest.GetResponse(); return webResponse; } catch (WebException ex) { //TODO: Handle Exception //MessageBox.Show(ex.Message, "HttpPost: Request error", // MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (os != null) { os.Close(); } } } return null; }
protected void EGIFTIDAvailableValidator_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = true; if (Request.QueryString["PMC"] != null) { string eGiftId = ((TextBox)RegisterUserWizardStep.Controls[0].FindControl("PMCData").FindControl("EGIFTID")).Text; Administration admin = new Administration(); CharityEvents Event = admin.GetEventByEgiftId(eGiftId); if ((Event != null) && (Event.UserId != Guid.Empty)) { args.IsValid = false; } } }
protected void validate(object sender, EventArgs e) { int eventId = 0; if (Page.IsValid) { SqlConnection conn = null; try { // create and open a connection object conn = new SqlConnection(ConfigurationManager.ConnectionStrings["goodtwoDbConnectionString1"].ConnectionString); conn.Open(); eventId = 0; if (Request.QueryString["id"] != null) { int.TryParse(Request.QueryString["id"], out eventId); } else { Response.Redirect("NewFund.aspx"); } // 1. create a command object identifying // the stored procedure SqlCommand cmd = new SqlCommand("CharityEvent_TimeStampEvent", conn); // 2. set the command object so it knows // to execute a stored procedure cmd.CommandType = CommandType.StoredProcedure; DateTime now = DateTime.Now; // 4. add parameter to command, which // will be passed to the stored procedure cmd.Parameters.Add(new SqlParameter("@CharityEventId", eventId)); cmd.Parameters.Add(new SqlParameter("@EULATimeStamp", now)); // execute the command cmd.ExecuteNonQuery(); Administration admin = new Administration(); CharityEvents fund = admin.GetEventById(eventId); // TODO // JKovacik: Mail is not configured correctly as of 06/30/2011; deactivate to avoid timeout and address in next release //mailEvent(fund.UserName, //fund.Email, //fund.PhoneNumber, //fund.Title, //fund.CauseName, //fund.Logo, //fund.Photo, //fund.Video, //fund.Tagline, //fund.Body, //fund.WebSite, //fund.Goal, //fund.EndDate != null ? (DateTime)fund.EndDate : DateTime.MaxValue, //fund.State, //fund.City, //fund.PaymentName, //fund.PaymentAddress, //fund.UserId, eventId, now); } catch (Exception ex) { Response.Write(@"<script type='text/javascript' language='javascript'>alert('The following errors have occurred: \n" + ex.Message + " (" + ex.InnerException + "):" + ex.StackTrace + " .');</script>"); Session["ErrorMsg"] = (Session["ErrorMsg"] == null) ? ex.Message + " (InnerException: " + ex.InnerException + ")\n" : Session["ErrorMsg"].ToString() + ex.Message + " (InnerException: " + ex.InnerException + ")\n"; ErrHandler.WriteError(ex.Message + " (InnerException: " + ex.InnerException + ")"); } finally { if (conn != null) { conn.Close(); } Response.Redirect("Fund.aspx?id=" + eventId); } } }
protected void Page_Load(object sender, EventArgs e) { MemoryStream ms = new MemoryStream(); int productCounter = 0; //Build the query string EventId = 0; if (Request.QueryString["id"] != null) { int.TryParse(Request.QueryString["id"], out EventId); } else { Response.Redirect("NewFund.aspx"); } goodtooDraft.Products.xmldata selectedProducts = goodtooDraft.App_Code.Utils.GetProductSearchResults(goodtooDraft.App_Code.GoodTwoConstants.productFundField, EventId.ToString()); if (selectedProducts.Items != null) selectedProductsList = selectedProducts.Items.ToList<goodtooDraft.Products.xmldataProducts>(); else selectedProductsList = new List<goodtooDraft.Products.xmldataProducts>(); // Filter to only grab the product copies foreach (goodtooDraft.Products.xmldataProducts product in selectedProductsList) { if (((XmlNode[])(product.ProductCode))[0].InnerText.ToString().Contains("*")) selectedProductsListFiltered.Add(product); } selectedProductsList = selectedProductsListFiltered; Administration admin = new Administration(); CharityEvents fund = admin.GetEventById(EventId); string selectedState = fund.State; List<goodtooDraft.Products.xmldataProducts> productList; try { if (!String.IsNullOrEmpty(selectedState)) { productList = goodtooDraft.App_Code.Utils.GetRelevantProducts(selectedState, this.Page); } else { productList = goodtooDraft.App_Code.Utils.GetProductSearchResults(goodtooDraft.App_Code.GoodTwoConstants.productRegionField, goodtooDraft.App_Code.GoodTwoConstants.nationalRegionCode).Items.ToList<goodtooDraft.Products.xmldataProducts>(); } } catch (Exception ex) { ErrHandler.WriteError(ex.Message + " (InnerException: " + ex.InnerException + ")"); throw new Exception("Could not calculate event statistics.", ex); } HtmlTable checktable; if (productList.Count > 0) { PlaceHolder1.Visible = true; checktable = new HtmlTable(); PlaceHolder1.Controls.Add(checktable); foreach (goodtooDraft.Products.xmldataProducts product in productList) { //adding productID and the product object to Key/Value Dictionary... productsArray.Add(((XmlNode[])(product.ProductID))[0].InnerText, product); //making table for each product with an associated CheckBox... HtmlTableRow Row = new HtmlTableRow(); HtmlTableCell chkCell = RenderLogic.AddCheckBoxTableCell(Row); CheckBox chkbox = (CheckBox)chkCell.Controls[0]; if (RenderLogic.AddProductTableCell(Row, product, productList[0].Equals(product), this.Page, false) == null) continue; string clientID = ((XmlNode[])(product.ProductID))[0].InnerText; //Has this product added to the event already? If so..is it currently displaying?... chkbox.Checked = false; foreach (goodtooDraft.Products.xmldataProducts selectedProduct in selectedProductsList) { /*If the selectedProduct.ProductCode equals the (product.ProductCode(*???)) of the current product * and they currently have it displaying in their funds page (DoNotAllowBackOrders == "Y") * that means the user has already selected it so set chkbox.Checked = true */ if ((((XmlNode[])(selectedProduct.ProductCode))[0].InnerText.ToString().Equals((((XmlNode[])(product.ProductCode))[0].InnerText) + "*" + EventId.ToString()) && ((XmlNode[])(selectedProduct.DoNotAllowBackOrders))[0].InnerText.Equals("Y"))) { chkbox.Checked = true; productCounter++; } } chkbox.ID = "chk_" + clientID; productsDic.Add(((XmlNode[])(product.ProductID))[0].InnerText, chkbox); checktable.Controls.Add(Row); } } }