protected void SaveButton_Click(object sender, EventArgs e) { // TODO: validate all fields. if (PasswordTextBox1.Text != PasswordTextBox2.Text) { return; } // Silly hack until we create a proper numeric-only textbox. decimal payRate = 0; Decimal.TryParse(PayrateTextBox.Text, out payRate); var user = new User(); user.Active = true; // If we're creating them, they are likely active. user.Email = EmailTextBox.Text; user.FirstName = FirstNameTextBox.Text; user.LastName = LastNameTextBox.Text; user.PayRate = payRate; user.Role = Sprocs.GetRoleType(RoleDropDown.SelectedValue); user.PayInterval = Sprocs.GetPayInterval(PayIntervalDropDown.SelectedValue); user.UserName = UserNameTextBox.Text; user.Account = Sprocs.GetUserAccount(CurrentSession.AspId); // it's the same account we're creating the user from. Sprocs.CreateUser(user, PasswordTextBox1.Text); Response.Redirect("/"); }
protected void Page_Load(object sender, EventArgs e) { // Check if we are already logged in. (see the redirect below) if (HttpContext.Current.User.Identity.IsAuthenticated) { // Get the user that is logged in. var user = Sprocs.GetUserByAspId(Membership.GetUser().ProviderUserKey.ToString()); Utils.JsonResponse(Response, true, new { username = user.UserName, userID = user.Id, accountName = user.Account.Name, accountID = user.Account.Id }); return; } else { Utils.JsonResponse(Response, false, new { error = "NOT_LOGGED_IN" }); } }
protected void SaveButton_Click(object sender, EventArgs e) { // Silly hack until we create a proper numeric-only textbox. int zipCode = 0; Int32.TryParse(ZipCodeTextBox.Text, out zipCode); // Create address. var adderess = new Adderess(); adderess.City = CityTextBox.Text; adderess.Country = CountryTextBox.Text; adderess.State = StateTextBox.Text; adderess.StreetAdderess = StreetAdderessTextBox.Text; adderess.Suite = SuiteTextBox.Text; adderess.ZipCode = zipCode; // Create company. var company = new Company(); company.Name = CompanyNameTextBox.Text; company.Adderess = adderess; company.Account = Sprocs.GetUserAccount(CurrentSession.AspId); // it's the same account we're creating the user from. Sprocs.CreateCompany(company); Response.Redirect("/"); }
protected void SaveButton_Click(object sender, EventArgs e) { // Nothing is validated. // Silly hack until we create a proper numeric-only textbox. int zipCode = 0, companyId = 0; Int32.TryParse(ZipCodeTextBox.Text, out zipCode); Int32.TryParse(CompanyDropDown.SelectedValue, out companyId); // Create address. var adderess = new Adderess(); adderess.City = CityTextBox.Text; adderess.Country = CountryTextBox.Text; adderess.State = StateTextBox.Text; adderess.StreetAdderess = StreetAdderessTextBox.Text; adderess.Suite = SuiteTextBox.Text; adderess.ZipCode = zipCode; // Create location. var location = new Location(); location.Adderess = adderess; location.Name = LocationNameTextBox.Text; location.Company = Sprocs.GetCompany(companyId); Sprocs.CreateLocation(location); Response.Redirect("/"); }
protected void Page_Load(object sender, EventArgs e) { var deviceId = Request["id"]; var serial = Request["serial"]; // Are we logged in? if (!HttpContext.Current.User.Identity.IsAuthenticated) { Utils.JsonResponse(Response, false, new { error = "NOT_LOGGED_IN" }); return; } // Do we have a device ID? if (deviceId == null) { Utils.JsonResponse(Response, false, new { error = "NO_DEVICE_SPECIFIED" }); return; } // Do we have a device ID? if (serial == null) { Utils.JsonResponse(Response, false, new { error = "NO_SERIAL_SPECIFIED" }); return; } // Is this a valid device? var device = Sprocs.GetDevice(deviceId); if (device == null) { Utils.JsonResponse(Response, false, new { error = "INVALID_DEVICE_ID" }); return; } if (!String.IsNullOrWhiteSpace(device.Serial)) { Utils.JsonResponse(Response, false, new { error = "DEVICE_ALREADY_REGISTERED" }); return; } Utils.JsonResponse(Response, Sprocs.RegisterDevice(device, serial)); }
private void PopulateControls() { // Populate dropdown controls. Sprocs.GetDeviceOwners().ForEach(owner => OwnerDropDown.Items.Add(owner)); Sprocs.GetUsers(CurrentSession.AccountId).ForEach(user => UserDropDown.Items.Add(new ListItem(user.UserName, user.Id.ToString()))); DeviceIdTextBox.Text = Guid.NewGuid().ToString(); }
public ApiNamespace GetOrCreateNamespace(int moduleId, string namespaceName) { var fullNamespace = ""; ApiNamespace crtNamespace = null; foreach (var segment in namespaceName.Split('.')) { fullNamespace = (fullNamespace + "." + segment).TrimStart('.'); crtNamespace = Sprocs.GetOrCreateNamespace(moduleId, crtNamespace == null ? 0 : crtNamespace.NamespaceId, fullNamespace, segment); } return(crtNamespace); }
private void PopulateControls() { // Populate dropdown controls. Sprocs.GetRoleTypes().ForEach(role => RoleDropDown.Items.Add(role)); Sprocs.GetPayIntervals().ForEach(interval => PayIntervalDropDown.Items.Add(interval)); // Add context menu items to master. var linkList = new List <KeyValuePair <string, string> >(); var master = Master as SiteMaster; linkList.Add(new KeyValuePair <string, string>("Add Device", "/devices/create")); master.UpdateContextMenu(linkList); }
protected void Page_Load(object sender, EventArgs e) { // Check if we are already logged in. (see the redirect below) if (HttpContext.Current.User.Identity.IsAuthenticated) { // Get the user that is logged in. var user = Sprocs.GetUserByAspId(Membership.GetUser().ProviderUserKey.ToString()); var devices = new List <object>(); var getUnregistered = (Request["unreg"] != null); foreach (var device in user.Devices) { // See if we're only asking for unregistured devices. If so, skip ones with a serial. if (getUnregistered && !String.IsNullOrEmpty(device.Serial)) { continue; } devices.Add(new { name = device.Name, id = device.UID, owner = Sprocs.GetDeviceOwner(device.Owner), serial = device.Serial }); } if (devices.Count > 0) { Utils.JsonResponse(Response, true, devices); } else { Utils.JsonResponse(Response, false, new { error = getUnregistered ? "NO_UNREGISTERED_DEVICES" : "NO_DEVICES" }); } return; } else { Utils.JsonResponse(Response, false, new { error = "NOT_LOGGED_IN" }); } }
protected void master_Page_PreLoad(object sender, EventArgs e) { if (!IsPostBack) { // Set Anti-XSRF token ViewState[AntiXsrfTokenKey] = Page.ViewStateUserKey; ViewState[AntiXsrfUserNameKey] = Context.User.Identity.Name ?? String.Empty; } else { // Validate the Anti-XSRF token if ((string)ViewState[AntiXsrfTokenKey] != _antiXsrfTokenValue || (string)ViewState[AntiXsrfUserNameKey] != (Context.User.Identity.Name ?? String.Empty)) { throw new InvalidOperationException("Validation of Anti-XSRF token failed."); } } // See if it's a new session. if (!CurrentSession.Active) { // Check if we are already logged in. If we are, get our real user name and account name. // (may want to change it to first/last name, though. if (HttpContext.Current.User.Identity.IsAuthenticated) { // Get the user that is logged in. var user = Sprocs.GetUserByAspId(Membership.GetUser().ProviderUserKey.ToString()); // If we have a valid user, create a new session object. if (user != null) { CurrentSession.Active = true; CurrentSession.AccountId = user.Account.Id; CurrentSession.AspId = user.ASPid; CurrentSession.DispalyName = String.Format("{0}, {1} {2}", user.Account.Name, user.FirstName, user.LastName); CurrentSession.UserId = user.Id; CurrentSession.Username = user.UserName; CurrentSession.UserRole = user.Role; } } else { CurrentSession.Active = false; } } }
public override void DoWork() { try { Progressing(); foreach (PortalInfo p in PortalController.Instance.GetPortals()) { var d = new System.IO.DirectoryInfo(p.HomeDirectoryMapPath + "\\Api"); if (d.Exists) { foreach (var sd in d.GetDirectories()) { int moduleId = -1; int.TryParse(sd.Name, out moduleId); if (moduleId > -1) { Log.AppendFormat("Found Module Dir {0}" + Environment.NewLine, moduleId); foreach (var f in sd.GetFiles("*.xml")) { Log.AppendFormat("Analyzing {0}" + Environment.NewLine, f.Name); var doc = new XmlApiDocumentation(f.FullName, moduleId); if (doc.IsValid) { doc.AddToModule(); Log.AppendFormat("Processed {0}" + Environment.NewLine, f.Name); } } Sprocs.UpdateDependencies(moduleId); Sprocs.UpdateReferences(moduleId); } } } } ScheduleHistoryItem.AddLogNote(Log.ToString().Replace(Environment.NewLine, "<br />")); ScheduleHistoryItem.Succeeded = true; } catch (Exception ex) { ScheduleHistoryItem.AddLogNote(Log.ToString() + Environment.NewLine + "Scheduled task failed: " + ex.Message + "(" + ex.StackTrace + ")" + Environment.NewLine + Log.ToString()); ScheduleHistoryItem.Succeeded = false; Errored(ref ex); Exceptions.LogException(ex); } }
/* * protected void EditIdButton_Click(object sender, EventArgs e) * { * DeviceIdTextBox.Enabled = true; * EditIdButton.Visible = false; * } */ protected void SaveButton_Click(object sender, EventArgs e) { int userID = 0; Int32.TryParse(UserDropDown.SelectedValue, out userID); var device = new Device(); device.Name = DeviceNameTextBox.Text; //device.Serial = SerialNumberTextBox.Text; device.UID = DeviceIdTextBox.Text; device.Owner = Sprocs.GetDeviceOwner(OwnerDropDown.SelectedValue); device.User = Sprocs.GetUserById(userID); Sprocs.CreateDevice(device); Response.Redirect("/"); }
private void PopulateControls() { // Add context menu items to master. var linkList = new List <KeyValuePair <string, string> >(); var master = Master as SiteMaster; foreach (var user in Sprocs.GetUsers(CurrentSession.AccountId)) { /* TODO: pretty URLs. * linkList.Add(new KeyValuePair<string, string>( * user.UserName, String.Format( * "/scheduling/view/{0}/{1}", CurrentSession.AccountId, user.Id))); */ linkList.Add(new KeyValuePair <string, string>( user.UserName, String.Format( "/scheduling/view?aid={0}&uid={1}", CurrentSession.AccountId, user.Id))); } master.UpdateContextMenu(linkList); }
// This entire method is a proof-of-concept. It will not work like this. private void ShowLocations(int userId) { var devices = Sprocs.GetUserDevices(userId); foreach (var device in devices) { var gridView = new GridView(); var dataTable = new DataTable(); gridView.RowDataBound += gridView_RowDataBound; dataTable.Columns.Add(new DataColumn("TimeStamp", typeof(string))); dataTable.Columns.Add(new DataColumn("Longitude", typeof(string))); dataTable.Columns.Add(new DataColumn("Latitude", typeof(string))); foreach (var logloc in device.LocationLogs) { DataRow dataRow = dataTable.NewRow(); dataRow["TimeStamp"] = Utils.FormatTimeStamp(logloc.TimeStamp); dataRow["Longitude"] = logloc.Longitude.ToString(); dataRow["Latitude"] = logloc.Latitude.ToString(); //Utils.LinkDataRow() dataTable.Rows.Add(dataRow); } gridView.DataSource = dataTable; gridView.DataBind(); if (devices.Count > 1) { var devicename = new Label(); devicename.Text = device.Name; viewScheduling.Controls.Add(devicename); } viewScheduling.Controls.Add(gridView); } }
private void PopulateControls() { // Populate dropdown controls. Sprocs.GetCompanies(CurrentSession.AccountId).ForEach(company => CompanyDropDown.Items.Add(new ListItem(company.Name, company.Id.ToString()))); }
protected void Page_Load(object sender, EventArgs e) { double longitude, latitude; var lng = Request["lng"]; // longitude var lat = Request["lat"]; // latitude var deviceId = Request["id"]; // device's GUID var serial = Request["serial"]; // devices's serial. // Are we logged in? if (!HttpContext.Current.User.Identity.IsAuthenticated) { Utils.JsonResponse(Response, false, new { error = "NOT_LOGGED_IN" }); return; } // Let's see if the coords seem valid. if (!Double.TryParse(lng, out longitude) || !Double.TryParse(lat, out latitude)) { Utils.JsonResponse(Response, false, new { error = "INVALID_COORDINATES" }); return; } // Do we have a device ID? if (deviceId == null) { Utils.JsonResponse(Response, false, new { error = "NO_DEVICE_SPECIFIED" }); return; } // Do we have a device serial? if (serial == null) { Utils.JsonResponse(Response, false, new { error = "NO_SERIAL_SPECIFIED" }); return; } // Is this a valid device? var device = Sprocs.GetDevice(deviceId); if (device == null) { Utils.JsonResponse(Response, false, new { error = "INVALID_DEVICE_ID" }); return; } // See if it is the registered device. if (String.IsNullOrWhiteSpace(device.Serial)) { Utils.JsonResponse(Response, false, new { error = "UREGISTERED_DEVICE" }); return; } // See if it is the correct device. if (device.Serial != serial) { Utils.JsonResponse(Response, false, new { error = "INVALID_DEVICE_SERIAL" }); return; } // Looks like we're OK to log it. var locatioonLog = new LocationLog(); locatioonLog.Device = device; locatioonLog.Latitude = latitude; locatioonLog.Longitude = longitude; locatioonLog.TimeStamp = DateTime.Now; Sprocs.CreateLocationLog(locatioonLog); Utils.JsonResponse(Response, true); }
/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { // credit: http://stackoverflow.com/a/263416/677735 unchecked // Overflow is fine, just wrap { var hash = 41; // Suitable nullity checks etc, of course :) if (Id != null) { hash = hash * 57 + Id.GetHashCode(); } if (Rid != null) { hash = hash * 57 + Rid.GetHashCode(); } if (Ts != null) { hash = hash * 57 + Ts.GetHashCode(); } if (Self != null) { hash = hash * 57 + Self.GetHashCode(); } if (Etag != null) { hash = hash * 57 + Etag.GetHashCode(); } if (Doc != null) { hash = hash * 57 + Doc.GetHashCode(); } if (Sprocs != null) { hash = hash * 57 + Sprocs.GetHashCode(); } if (Triggers != null) { hash = hash * 57 + Triggers.GetHashCode(); } if (Udfs != null) { hash = hash * 57 + Udfs.GetHashCode(); } if (Conflicts != null) { hash = hash * 57 + Conflicts.GetHashCode(); } if (IndexingPolicy != null) { hash = hash * 57 + IndexingPolicy.GetHashCode(); } return(hash); } }
/// <summary> /// Returns true if Collection instances are equal /// </summary> /// <param name="other">Instance of Collection to be compared</param> /// <returns>Boolean</returns> public bool Equals(Collection other) { // credit: http://stackoverflow.com/a/10454552/677735 if (other == null) { return(false); } return (( Id == other.Id || Id != null && Id.Equals(other.Id) ) && ( Rid == other.Rid || Rid != null && Rid.Equals(other.Rid) ) && ( Ts == other.Ts || Ts != null && Ts.Equals(other.Ts) ) && ( Self == other.Self || Self != null && Self.Equals(other.Self) ) && ( Etag == other.Etag || Etag != null && Etag.Equals(other.Etag) ) && ( Doc == other.Doc || Doc != null && Doc.Equals(other.Doc) ) && ( Sprocs == other.Sprocs || Sprocs != null && Sprocs.Equals(other.Sprocs) ) && ( Triggers == other.Triggers || Triggers != null && Triggers.Equals(other.Triggers) ) && ( Udfs == other.Udfs || Udfs != null && Udfs.Equals(other.Udfs) ) && ( Conflicts == other.Conflicts || Conflicts != null && Conflicts.Equals(other.Conflicts) ) && ( IndexingPolicy == other.IndexingPolicy || IndexingPolicy != null && IndexingPolicy.Equals(other.IndexingPolicy) )); }
protected void SaveButton_Click(object sender, EventArgs e) { // Very basic validation: // Check that the passwords match, make sure we have at least an account name. if (PasswordTextBox1.Text != PasswordTextBox2.Text || String.IsNullOrWhiteSpace(AccountNameTextBox.Text)) { return; } //TODO // Add validation of fields. // Create a phone number and email utils validator. // Add Phone number creation area. // Create items in following order: user, address, location, company, account. var user = new User(); user.Active = true; //first user must be active. user.Email = EmailTextBox.Text; user.FirstName = FirstNameTextBox.Text; user.LastName = LastNameTextBox.Text; user.Role = RoleTypes.Admin; //first user can ONLY be an admin. user.UserName = UserNameTextBox.Text; // Silly hack until we create a proper numeric-only textbox. int zipCode = 0; Int32.TryParse(ZipCodeTextBox.Text, out zipCode); // Create address. var adderess = new Adderess(); adderess.City = CityTextBox.Text; adderess.Country = CountryTextBox.Text; adderess.State = StateTextBox.Text; adderess.StreetAdderess = StreetAdderessTextBox.Text; adderess.Suite = SuiteTextBox.Text; adderess.ZipCode = zipCode; // Create location. var location = new Location(); location.Adderess = adderess; location.Name = String.IsNullOrWhiteSpace(LocationNameTextBox.Text) ? AccountNameTextBox.Text : LocationNameTextBox.Text; // Create company. var company = new Company(); company.Name = String.IsNullOrWhiteSpace(CompanyNameTextBox.Text) ? AccountNameTextBox.Text : CompanyNameTextBox.Text; company.Adderess = adderess; company.Locations.Add(location); // Create account. var account = new TimeTracks.Data.Account(); account.Companies.Add(company); account.Users.Add(user); account.Name = AccountNameTextBox.Text; account.WeekStart = Sprocs.GetDayOfWeek(WeekStartDropDown.SelectedValue); // Create the default account. Sprocs.CreateAccount(account, user, PasswordTextBox1.Text); Response.Redirect("/"); }
private void PopulateControls() { // Populate the day dropdown control. Sprocs.GetDaysOfWeek().ForEach(day => WeekStartDropDown.Items.Add(day)); }
public HttpResponseMessage Moderation() { return(Request.CreateResponse(HttpStatusCode.OK, Sprocs.GetModerationList(ApiBrowserModuleContext.ModuleContext.ModuleID))); }