| @@ -0,0 +1,129 @@ | |||
| <% Option Explicit %> | |||
| <!--#include file="../../include_all.asp"--> | |||
| <!--#include file="../../ViewModels/ContactsViewModels.asp"--> | |||
| <% | |||
| Class ContactsController | |||
| Public Model | |||
| Public Sub Index | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Contacts" | |||
| set Model.Contacts = ContactsRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Contacts/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Search | |||
| dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Contacts" | |||
| set Model.Contacts = ContactsRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JURISCODE","%" & searchValue & "%","TownshipName","%" & searchValue & "%","CONTACT_NAME","%" & searchValue & "%","TownshipNum","%" & searchValue & "%","BUSINESS_ADDRESS","%" & searchValue & "%","TITLE","%" & searchValue & "%","BUSINESS_ADDRESS2","%" & searchValue & "%","BUSINESS_ADDRESS3","%" & searchValue & "%","MAILING_ADDRESS","%" & searchValue & "%","MAILING_ADDRESS2","%" & searchValue & "%","MAILING_ADDRESS3","%" & searchValue & "%","RESIDENTIAL_ADDRESS","%" & searchValue & "%","RESIDENTIAL_ADDRESS2","%" & searchValue & "%","PHONENUM1","%" & searchValue & "%","RESIDENTIAL_ADDRESS3","%" & searchValue & "%","FAXNUM","%" & searchValue & "%","PHONENUM2","%" & searchValue & "%","EMAIL","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Contacts/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Edit | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Edit_ViewModel_Class | |||
| set Model.Contacts = ContactsRepository.FindByID(id) | |||
| Model.Title = "Edit Contacts" | |||
| HTMLSecurity.SetAntiCSRFToken "ContactsEditForm" | |||
| %> <!--#include file="../../Views/Contacts/Edit.asp"--> <% | |||
| Flash.Success = "Contacts Updated." | |||
| End Sub | |||
| Public Sub EditPost | |||
| MVC.RequirePost | |||
| HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "ContactsEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) | |||
| dim ID : ID = Request.Form("Id") | |||
| dim model : set model = ContactsRepository.FindByID(ID) | |||
| set model = Automapper.AutoMap(Request.Form, model) | |||
| 'model.Validate | |||
| 'If model.Validator.HasErrors then | |||
| FormCache.SerializeForm "EditContacts", Request.Form | |||
| ' Flash.Errors = model.Validator.Errors | |||
| ' MVC.RedirectToActionExt "Edit", Array("Id",ID) | |||
| 'Else | |||
| ContactsRepository.Update model | |||
| FormCache.ClearForm "EditContacts" | |||
| Flash.Success = "Contacts updated." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Create | |||
| dim form_params : set form_params = FormCache.DeserializeForm("NewContacts") | |||
| If Not form_params Is Nothing then | |||
| set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class) | |||
| Else | |||
| set Model = new Create_ViewModel_Class | |||
| End If | |||
| HTMLSecurity.SetAntiCSRFToken "ContactsCreateForm" | |||
| %> <!--#include file="../../Views/Contacts/Create.asp"--> <% | |||
| End Sub | |||
| Public Sub CreatePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "ContactsCreateForm", Request.Form("nonce"), "Create" | |||
| dim new_Contacts_model : set new_Contacts_model = Automapper.AutoMap(Request.Form, new ContactsModel_Class) | |||
| 'new_Contacts_model.Validator.Validate | |||
| 'If new_Contacts_model.Validator.HasErrors then | |||
| ' FormCache.SerializeForm "NewContacts", Request.Form | |||
| ' Flash.Errors = new_Contacts_model.Validator.Errors | |||
| ' MVC.RedirectToAction "Create" | |||
| 'Else | |||
| ContactsRepository.AddNew new_Contacts_model | |||
| ' FormCache.ClearForm "NewContacts" | |||
| Flash.Success = "Contacts added." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Delete | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Delete_ViewModel_Class | |||
| set Model.Contacts = ContactsRepository.FindByID(id) | |||
| Model.Title = "Delete Contacts" | |||
| HTMLSecurity.SetAntiCSRFToken "ContactsDeleteForm" | |||
| %> <!--#include file="../../Views/Contacts/Delete.asp"--> <% | |||
| End Sub | |||
| Public Sub DeletePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "ContactsDeleteForm", Request.Form("nonce"), "Create" | |||
| dim id : id = Request.Form("Id") | |||
| ContactsRepository.Delete id | |||
| Flash.Success = "Contacts deleted." | |||
| MVC.RedirectToAction "Index" | |||
| End Sub | |||
| End Class | |||
| MVC.Dispatch | |||
| %> | |||
| @@ -0,0 +1,12 @@ | |||
| <% Option Explicit %> | |||
| <!--#include file="../../include_all.asp"--> | |||
| <% | |||
| Class HomeController | |||
| Public Sub Index | |||
| %> <!--#include file="../../Views/Home/Index.asp"--> <% | |||
| End Sub | |||
| End Class | |||
| MVC.Dispatch | |||
| %> | |||
| @@ -0,0 +1,155 @@ | |||
| <% Option Explicit %> | |||
| <!--#include file="../../include_all.asp"--> | |||
| <!--#include file="../../ViewModels/JurisdictionViewModels.asp"--> | |||
| <% | |||
| Class JurisdictionController | |||
| Public Model | |||
| Public Sub Index | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Jurisdiction" | |||
| set Model.Jurisdiction = JurisdictionRepository.FindPaged(empty, "JCode", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Jurisdiction/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Search | |||
| dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Jurisdiction" | |||
| set Model.Jurisdiction = JurisdictionRepository.SearchTablePaged(Array("JCode","%" & searchValue & "%","Name","%" & searchValue & "%","Mailing_Address","%" & searchValue & "%","CSZ","%" & searchValue & "%","IMB","%" & searchValue & "%","IMB_Digits","%" & searchValue & "%"),"JCode", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Jurisdiction/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Edit | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Edit_ViewModel_Class | |||
| set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id) | |||
| set Model.Contacts = ContactsRepository.Find(Array("JURISCODE = ?",id),empty) | |||
| Model.Title = "Edit Jurisdiction" | |||
| HTMLSecurity.SetAntiCSRFToken "JurisdictionEditForm" | |||
| %> <!--#include file="../../Views/Jurisdiction/Edit.asp"--> <% | |||
| Flash.Success = "Jurisdiction Updated." | |||
| End Sub | |||
| Public Sub EditPost | |||
| MVC.RequirePost | |||
| HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "JurisdictionEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) | |||
| dim JCode : JCode = Request.Form("Id") | |||
| dim model : set model = JurisdictionRepository.FindByJCode(JCode) | |||
| set model = Automapper.AutoMap(Request.Form, model) | |||
| 'model.Validate | |||
| 'If model.Validator.HasErrors then | |||
| FormCache.SerializeForm "EditJurisdiction", Request.Form | |||
| ' Flash.Errors = model.Validator.Errors | |||
| ' MVC.RedirectToActionExt "Edit", Array("Id",JCode) | |||
| 'Else | |||
| JurisdictionRepository.Update model | |||
| FormCache.ClearForm "EditJurisdiction" | |||
| Flash.Success = "Jurisdiction updated." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Create | |||
| dim form_params : set form_params = FormCache.DeserializeForm("NewJurisdiction") | |||
| If Not form_params Is Nothing then | |||
| set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class) | |||
| Else | |||
| set Model = new Create_ViewModel_Class | |||
| End If | |||
| HTMLSecurity.SetAntiCSRFToken "JurisdictionCreateForm" | |||
| %> <!--#include file="../../Views/Jurisdiction/Create.asp"--> <% | |||
| End Sub | |||
| Public Sub CreatePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "JurisdictionCreateForm", Request.Form("nonce"), "Create" | |||
| dim new_Jurisdiction_model : set new_Jurisdiction_model = Automapper.AutoMap(Request.Form, new JurisdictionModel_Class) | |||
| 'new_Jurisdiction_model.Validator.Validate | |||
| 'If new_Jurisdiction_model.Validator.HasErrors then | |||
| ' FormCache.SerializeForm "NewJurisdiction", Request.Form | |||
| ' Flash.Errors = new_Jurisdiction_model.Validator.Errors | |||
| ' MVC.RedirectToAction "Create" | |||
| 'Else | |||
| JurisdictionRepository.AddNew new_Jurisdiction_model | |||
| ' FormCache.ClearForm "NewJurisdiction" | |||
| Flash.Success = "Jurisdiction added." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Delete | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Delete_ViewModel_Class | |||
| set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id) | |||
| Model.Title = "Delete Jurisdiction" | |||
| HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm" | |||
| %> <!--#include file="../../Views/Jurisdiction/Delete.asp"--> <% | |||
| End Sub | |||
| Public Sub DeletePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "JurisdictionDeleteForm", Request.Form("nonce"), "Create" | |||
| dim id : id = Request.Form("Id") | |||
| JurisdictionRepository.Delete id | |||
| Flash.Success = "Jurisdiction deleted." | |||
| MVC.RedirectToAction "Index" | |||
| End Sub | |||
| Public Sub Createkit | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Delete_ViewModel_Class | |||
| set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id) | |||
| Model.Title = "Create Kit" | |||
| HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm" | |||
| %> <!--#include file="../../Views/Jurisdiction/createkit.asp"--> <% | |||
| End sub | |||
| Public Sub CreateKitPost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "CreateKitForm", Request.Form("nonce"), "Index" | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Delete_ViewModel_Class | |||
| set Model.Jurisdiction = JurisdictionRepository.FindByJCode(id) | |||
| Model.Title = "Create Kit" | |||
| HTMLSecurity.SetAntiCSRFToken "JurisdictionDeleteForm" | |||
| %> <!--#include file="../../Views/Jurisdiction/createkit.asp"--> <% | |||
| End sub | |||
| End Class | |||
| MVC.Dispatch | |||
| %> | |||
| @@ -0,0 +1,137 @@ | |||
| <% Option Explicit %> | |||
| <!--#include file="../../include_all.asp"--> | |||
| <!--#include file="../../ViewModels/KitViewModels.asp"--> | |||
| <% | |||
| Class KitController | |||
| Public Model | |||
| Public Sub Index | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Kit" | |||
| set Model.Kit = KitRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Kit/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Search | |||
| dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Kit" | |||
| set Model.Kit = KitRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","JobNumber","%" & searchValue & "%","Jcode","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Kit/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Edit | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Edit_ViewModel_Class | |||
| set Model.Kit = KitRepository.FindByID(id) | |||
| Model.Title = "Edit Kit" | |||
| HTMLSecurity.SetAntiCSRFToken "KitEditForm" | |||
| %> <!--#include file="../../Views/Kit/Edit.asp"--> <% | |||
| Flash.Success = "Kit Updated." | |||
| End Sub | |||
| Public Sub EditPost | |||
| MVC.RequirePost | |||
| HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) | |||
| dim ID : ID = Request.Form("Id") | |||
| dim model : set model = KitRepository.FindByID(ID) | |||
| set model = Automapper.AutoMap(Request.Form, model) | |||
| 'model.Validate | |||
| 'If model.Validator.HasErrors then | |||
| FormCache.SerializeForm "EditKit", Request.Form | |||
| ' Flash.Errors = model.Validator.Errors | |||
| ' MVC.RedirectToActionExt "Edit", Array("Id",ID) | |||
| 'Else | |||
| KitRepository.Update model | |||
| FormCache.ClearForm "EditKit" | |||
| Flash.Success = "Kit updated." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Create | |||
| dim form_params : set form_params = FormCache.DeserializeForm("NewKit") | |||
| dim ID : ID = Request.QueryString("Id") | |||
| dim model : set model = new Create_ViewModel_Class | |||
| model.Title = "Create Kit " | |||
| model.JCode = ID | |||
| dim ugh : set ugh = JurisdictionRepository.Find(Array("[JCode] = ?",ID),empty) | |||
| set model.Jurisdiction = ugh.pop() | |||
| 'If Not form_params Is Nothing then | |||
| ' set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class) | |||
| 'Else | |||
| ' set Model = new Create_ViewModel_Class | |||
| 'End If | |||
| HTMLSecurity.SetAntiCSRFToken "KitCreateForm" | |||
| %> <!--#include file="../../Views/Kit/Create.asp"--> <% | |||
| End Sub | |||
| Public Sub CreatePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitCreateForm", Request.Form("nonce"), "Create" | |||
| dim new_Kit_model : set new_Kit_model = Automapper.AutoMap(Request.Form, new KitModel_Class) | |||
| 'new_Kit_model.Validator.Validate | |||
| 'If new_Kit_model.Validator.HasErrors then | |||
| ' FormCache.SerializeForm "NewKit", Request.Form | |||
| ' Flash.Errors = new_Kit_model.Validator.Errors | |||
| ' MVC.RedirectToAction "Create" | |||
| 'Else | |||
| KitRepository.AddNew new_Kit_model | |||
| ' FormCache.ClearForm "NewKit" | |||
| Flash.Success = "Kit added." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Delete | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Delete_ViewModel_Class | |||
| set Model.Kit = KitRepository.FindByID(id) | |||
| Model.Title = "Delete Kit" | |||
| HTMLSecurity.SetAntiCSRFToken "KitDeleteForm" | |||
| %> <!--#include file="../../Views/Kit/Delete.asp"--> <% | |||
| End Sub | |||
| Public Sub DeletePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitDeleteForm", Request.Form("nonce"), "Create" | |||
| dim id : id = Request.Form("Id") | |||
| KitRepository.Delete id | |||
| Flash.Success = "Kit deleted." | |||
| MVC.RedirectToAction "Index" | |||
| End Sub | |||
| End Class | |||
| MVC.Dispatch | |||
| %> | |||
| @@ -0,0 +1,129 @@ | |||
| <% Option Explicit %> | |||
| <!--#include file="../../include_all.asp"--> | |||
| <!--#include file="../../ViewModels/KitLabelsViewModels.asp"--> | |||
| <% | |||
| Class KitLabelsController | |||
| Public Model | |||
| Public Sub Index | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "KitLabels" | |||
| set Model.KitLabels = KitLabelsRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/KitLabels/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Search | |||
| dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "KitLabels" | |||
| set Model.KitLabels = KitLabelsRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","KitId","%" & searchValue & "%","OutboundSerial","%" & searchValue & "%","InBoundSerial","%" & searchValue & "%","OutboundIMB","%" & searchValue & "%","InBoundIMB","%" & searchValue & "%","OutboundIMBDigits","%" & searchValue & "%","InBoundIMBDigits","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/KitLabels/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Edit | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Edit_ViewModel_Class | |||
| set Model.KitLabels = KitLabelsRepository.FindByID(id) | |||
| Model.Title = "Edit KitLabels" | |||
| HTMLSecurity.SetAntiCSRFToken "KitLabelsEditForm" | |||
| %> <!--#include file="../../Views/KitLabels/Edit.asp"--> <% | |||
| Flash.Success = "KitLabels Updated." | |||
| End Sub | |||
| Public Sub EditPost | |||
| MVC.RequirePost | |||
| HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "KitLabelsEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) | |||
| dim ID : ID = Request.Form("Id") | |||
| dim model : set model = KitLabelsRepository.FindByID(ID) | |||
| set model = Automapper.AutoMap(Request.Form, model) | |||
| 'model.Validate | |||
| 'If model.Validator.HasErrors then | |||
| FormCache.SerializeForm "EditKitLabels", Request.Form | |||
| ' Flash.Errors = model.Validator.Errors | |||
| ' MVC.RedirectToActionExt "Edit", Array("Id",ID) | |||
| 'Else | |||
| KitLabelsRepository.Update model | |||
| FormCache.ClearForm "EditKitLabels" | |||
| Flash.Success = "KitLabels updated." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Create | |||
| dim form_params : set form_params = FormCache.DeserializeForm("NewKitLabels") | |||
| If Not form_params Is Nothing then | |||
| set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class) | |||
| Else | |||
| set Model = new Create_ViewModel_Class | |||
| End If | |||
| HTMLSecurity.SetAntiCSRFToken "KitLabelsCreateForm" | |||
| %> <!--#include file="../../Views/KitLabels/Create.asp"--> <% | |||
| End Sub | |||
| Public Sub CreatePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitLabelsCreateForm", Request.Form("nonce"), "Create" | |||
| dim new_KitLabels_model : set new_KitLabels_model = Automapper.AutoMap(Request.Form, new KitLabelsModel_Class) | |||
| 'new_KitLabels_model.Validator.Validate | |||
| 'If new_KitLabels_model.Validator.HasErrors then | |||
| ' FormCache.SerializeForm "NewKitLabels", Request.Form | |||
| ' Flash.Errors = new_KitLabels_model.Validator.Errors | |||
| ' MVC.RedirectToAction "Create" | |||
| 'Else | |||
| KitLabelsRepository.AddNew new_KitLabels_model | |||
| ' FormCache.ClearForm "NewKitLabels" | |||
| Flash.Success = "KitLabels added." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Delete | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Delete_ViewModel_Class | |||
| set Model.KitLabels = KitLabelsRepository.FindByID(id) | |||
| Model.Title = "Delete KitLabels" | |||
| HTMLSecurity.SetAntiCSRFToken "KitLabelsDeleteForm" | |||
| %> <!--#include file="../../Views/KitLabels/Delete.asp"--> <% | |||
| End Sub | |||
| Public Sub DeletePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "KitLabelsDeleteForm", Request.Form("nonce"), "Create" | |||
| dim id : id = Request.Form("Id") | |||
| KitLabelsRepository.Delete id | |||
| Flash.Success = "KitLabels deleted." | |||
| MVC.RedirectToAction "Index" | |||
| End Sub | |||
| End Class | |||
| MVC.Dispatch | |||
| %> | |||
| @@ -0,0 +1,129 @@ | |||
| <% Option Explicit %> | |||
| <!--#include file="../../include_all.asp"--> | |||
| <!--#include file="../../ViewModels/SettingsViewModels.asp"--> | |||
| <% | |||
| Class SettingsController | |||
| Public Model | |||
| Public Sub Index | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Settings" | |||
| set Model.Settings = SettingsRepository.FindPaged(empty, "ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Settings/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Search | |||
| dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) | |||
| dim page_size : page_size = 10 | |||
| dim page_num : page_num = Choice(Len(Request.Querystring("page_num")) > 0, Request.Querystring("page_num"), 1) | |||
| dim page_count, record_count | |||
| set Model = new PagedIndex_ViewModel_Class | |||
| Model.Title = "Settings" | |||
| set Model.Settings = SettingsRepository.SearchTablePaged(Array("ID","%" & searchValue & "%","Name","%" & searchValue & "%","Value","%" & searchValue & "%"),"ID", page_size, page_num, page_count, record_count) | |||
| Model.CurrentPageNumber = page_num | |||
| Model.PageSize = page_size | |||
| Model.PageCount = page_count | |||
| Model.RecordCount = record_count | |||
| %> <!--#include file="../../Views/Settings/Index.asp"--> <% | |||
| End Sub | |||
| Public Sub Edit | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Edit_ViewModel_Class | |||
| set Model.Settings = SettingsRepository.FindByID(id) | |||
| Model.Title = "Edit Settings" | |||
| HTMLSecurity.SetAntiCSRFToken "SettingsEditForm" | |||
| %> <!--#include file="../../Views/Settings/Edit.asp"--> <% | |||
| Flash.Success = "Settings Updated." | |||
| End Sub | |||
| Public Sub EditPost | |||
| MVC.RequirePost | |||
| HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt "SettingsEditForm", Request.Form("nonce"), "Edit", Array("Id", Request.Form("Id")) | |||
| dim ID : ID = Request.Form("Id") | |||
| dim model : set model = SettingsRepository.FindByID(ID) | |||
| set model = Automapper.AutoMap(Request.Form, model) | |||
| 'model.Validate | |||
| 'If model.Validator.HasErrors then | |||
| FormCache.SerializeForm "EditSettings", Request.Form | |||
| ' Flash.Errors = model.Validator.Errors | |||
| ' MVC.RedirectToActionExt "Edit", Array("Id",ID) | |||
| 'Else | |||
| SettingsRepository.Update model | |||
| FormCache.ClearForm "EditSettings" | |||
| Flash.Success = "Settings updated." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Create | |||
| dim form_params : set form_params = FormCache.DeserializeForm("NewSettings") | |||
| If Not form_params Is Nothing then | |||
| set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class) | |||
| Else | |||
| set Model = new Create_ViewModel_Class | |||
| End If | |||
| HTMLSecurity.SetAntiCSRFToken "SettingsCreateForm" | |||
| %> <!--#include file="../../Views/Settings/Create.asp"--> <% | |||
| End Sub | |||
| Public Sub CreatePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "SettingsCreateForm", Request.Form("nonce"), "Create" | |||
| dim new_Settings_model : set new_Settings_model = Automapper.AutoMap(Request.Form, new SettingsModel_Class) | |||
| 'new_Settings_model.Validator.Validate | |||
| 'If new_Settings_model.Validator.HasErrors then | |||
| ' FormCache.SerializeForm "NewSettings", Request.Form | |||
| ' Flash.Errors = new_Settings_model.Validator.Errors | |||
| ' MVC.RedirectToAction "Create" | |||
| 'Else | |||
| SettingsRepository.AddNew new_Settings_model | |||
| ' FormCache.ClearForm "NewSettings" | |||
| Flash.Success = "Settings added." | |||
| MVC.RedirectToAction "Index" | |||
| 'End If | |||
| End Sub | |||
| Public Sub Delete | |||
| dim id : id = Request.QueryString("Id") | |||
| set Model = new Delete_ViewModel_Class | |||
| set Model.Settings = SettingsRepository.FindByID(id) | |||
| Model.Title = "Delete Settings" | |||
| HTMLSecurity.SetAntiCSRFToken "SettingsDeleteForm" | |||
| %> <!--#include file="../../Views/Settings/Delete.asp"--> <% | |||
| End Sub | |||
| Public Sub DeletePost | |||
| MVC.RequirePost | |||
| HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction "SettingsDeleteForm", Request.Form("nonce"), "Create" | |||
| dim id : id = Request.Form("Id") | |||
| SettingsRepository.Delete id | |||
| Flash.Success = "Settings deleted." | |||
| MVC.RedirectToAction "Index" | |||
| End Sub | |||
| End Class | |||
| MVC.Dispatch | |||
| %> | |||
| @@ -0,0 +1,29 @@ | |||
| <% | |||
| ' This class encapsulates database access into one location, isolating database details from the rest of the app. | |||
| ' Multiple databases can be handled in one of two ways: | |||
| ' | |||
| ' Option 1. Use a single DAL_Class instance with separate public properties for each database. | |||
| ' Ex: To access Orders use DAL.Orders and to access Employees use DAL.Employees. | |||
| ' | |||
| ' Option 2. Use a separate DAL_Class instance for each database. | |||
| ' Ex: | |||
| ' dim OrdersDAL : set OrdersDAL = new DAL_Class | |||
| ' OrdersDAL.ConnectionString = "..." <-- you would have to create this property to use this approach | |||
| ' | |||
| ' If you only access one database it is easier to just set the global DAL singleton to an instance of the | |||
| ' Database_Class and use it directly. See the example project for details. | |||
| '======================================================================================================================= | |||
| ' DATA ACCESS LAYER Class | |||
| '======================================================================================================================= | |||
| dim DAL__Singleton : set DAL__Singleton = Nothing | |||
| Function DAL() | |||
| If DAL__Singleton is Nothing then | |||
| set DAL__Singleton = new Database_Class | |||
| DAL__Singleton.Initialize "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata.mdb;" | |||
| End If | |||
| set DAL = DAL__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,302 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Contacts Model | |||
| '======================================================================================================================= | |||
| Class ContactsModel_Class | |||
| Public Validator | |||
| Public Class_Get_Properties | |||
| Public ID '90 | |||
| Public JURISCODE '106 | |||
| Public TownshipName '106 | |||
| Public CONTACT_NAME '106 | |||
| Public TownshipNum '106 | |||
| Public BUSINESS_ADDRESS '106 | |||
| Public TITLE '106 | |||
| Public BUSINESS_ADDRESS2 '106 | |||
| Public BUSINESS_ADDRESS3 '106 | |||
| Public MAILING_ADDRESS '106 | |||
| Public MAILING_ADDRESS2 '106 | |||
| Public MAILING_ADDRESS3 '106 | |||
| Public RESIDENTIAL_ADDRESS '106 | |||
| Public RESIDENTIAL_ADDRESS2 '106 | |||
| Public PHONENUM1 '106 | |||
| Public RESIDENTIAL_ADDRESS3 '106 | |||
| Public FAXNUM '122 | |||
| Public PHONENUM2 '106 | |||
| Public EMAIL '106 | |||
| Private Sub Class_Initialize | |||
| 'ValidateExitsts Me, "","" | |||
| Class_Get_Properties = Array("ID, JURISCODE, TownshipName, CONTACT_NAME, TownshipNum, BUSINESS_ADDRESS, TITLE, BUSINESS_ADDRESS2, BUSINESS_ADDRESS3, MAILING_ADDRESS, MAILING_ADDRESS2, MAILING_ADDRESS3, RESIDENTIAL_ADDRESS, RESIDENTIAL_ADDRESS2, PHONENUM1, RESIDENTIAL_ADDRESS3, FAXNUM, PHONENUM2, EMAIL") | |||
| End Sub | |||
| End CLass | |||
| '======================================================================================================================= | |||
| ' Contacts Repository | |||
| '======================================================================================================================= | |||
| Class ContactsRepository_Class | |||
| Public Function FindByID(ID) | |||
| dim sql : sql = "Select [ID], [JURISCODE], [TownshipName], [CONTACT_NAME], [TownshipNum], [BUSINESS_ADDRESS], [TITLE], [BUSINESS_ADDRESS2], [BUSINESS_ADDRESS3], [MAILING_ADDRESS], [MAILING_ADDRESS2], [MAILING_ADDRESS3], [RESIDENTIAL_ADDRESS], [RESIDENTIAL_ADDRESS2], [PHONENUM1], [RESIDENTIAL_ADDRESS3], [FAXNUM], [PHONENUM2], [EMAIL] FROM [Contacts] WHERE ID = ?" | |||
| dim rs : set rs = DAL.Query(sql,ID) | |||
| If rs.EOF then | |||
| Err.Raise 1, "ContactsRepository_Class", ContactsNotFoundException("ID", ID) | |||
| Else | |||
| set FindByID = Automapper.AutoMap(rs,"ContactsModel_Class") | |||
| End If | |||
| End Function | |||
| Public Function GetAll(orderBy) | |||
| set GetAll = Find(empty,orderBy) | |||
| End Function | |||
| Public Function Find(where_kvarray, order_string_or_array) | |||
| dim sql : sql = "Select [ID], [JURISCODE], [TownshipName], [CONTACT_NAME], [TownshipNum], [BUSINESS_ADDRESS], [TITLE], [BUSINESS_ADDRESS2], [BUSINESS_ADDRESS3], [MAILING_ADDRESS], [MAILING_ADDRESS2], [MAILING_ADDRESS3], [RESIDENTIAL_ADDRESS], [RESIDENTIAL_ADDRESS2], [PHONENUM1], [RESIDENTIAL_ADDRESS3], [FAXNUM], [PHONENUM2], [EMAIL] FROM [Contacts]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim rs : set rs = DAL.Query(sql, where_values) | |||
| set Find = ContactsList(rs) | |||
| Destroy rs | |||
| End Function | |||
| Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [JURISCODE], [TownshipName], [CONTACT_NAME], [TownshipNum], [BUSINESS_ADDRESS], [TITLE], [BUSINESS_ADDRESS2], [BUSINESS_ADDRESS3], [MAILING_ADDRESS], [MAILING_ADDRESS2], [MAILING_ADDRESS3], [RESIDENTIAL_ADDRESS], [RESIDENTIAL_ADDRESS2], [PHONENUM1], [RESIDENTIAL_ADDRESS3], [FAXNUM], [PHONENUM2], [EMAIL] FROM [Contacts]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set FindPaged = PagedContactsList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [JURISCODE], [TownshipName], [CONTACT_NAME], [TownshipNum], [BUSINESS_ADDRESS], [TITLE], [BUSINESS_ADDRESS2], [BUSINESS_ADDRESS3], [MAILING_ADDRESS], [MAILING_ADDRESS2], [MAILING_ADDRESS3], [RESIDENTIAL_ADDRESS], [RESIDENTIAL_ADDRESS2], [PHONENUM1], [RESIDENTIAL_ADDRESS3], [FAXNUM], [PHONENUM2], [EMAIL] FROM [Contacts]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " OR" | |||
| sql = sql & " " & where_keys(i) & " LIKE ?" | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & " ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set SearchTablePaged = PagedContactsList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Private Function PagedContactsList(rs, per_page) | |||
| dim list : set list = new LinkedList_Class | |||
| dim x : x =0 | |||
| Do While x < per_page and Not rs.EOF | |||
| list.Push Automapper.AutoMap(rs, new ContactsModel_Class) | |||
| x = x +1 | |||
| rs.MoveNext | |||
| Loop | |||
| set PagedContactsList = list | |||
| End Function | |||
| Private Function ContactsNotFoundException(ByVal field_name, ByVal field_val) | |||
| ContactsNotFoundException = "Contacts was not found with " & field_name & " of '" & field_val & "'." | |||
| End Function | |||
| Private Function ContactsList(rs) | |||
| dim list : set list = new LinkedList_Class | |||
| dim model | |||
| Do until rs.EOF | |||
| set model = new ContactsModel_Class | |||
| list.Push Automapper.AutoMap(rs, model) | |||
| rs.MoveNext | |||
| Loop | |||
| set ContactsList = list | |||
| End Function | |||
| Public Sub AddNew(ByRef model) | |||
| dim sql : sql = "INSERT INTO [Contacts] (" &_ | |||
| "[JURISCODE]," &_ | |||
| "[TownshipName]," &_ | |||
| "[CONTACT_NAME]," &_ | |||
| "[TownshipNum]," &_ | |||
| "[BUSINESS_ADDRESS]," &_ | |||
| "[TITLE]," &_ | |||
| "[BUSINESS_ADDRESS2]," &_ | |||
| "[BUSINESS_ADDRESS3]," &_ | |||
| "[MAILING_ADDRESS]," &_ | |||
| "[MAILING_ADDRESS2]," &_ | |||
| "[MAILING_ADDRESS3]," &_ | |||
| "[RESIDENTIAL_ADDRESS]," &_ | |||
| "[RESIDENTIAL_ADDRESS2]," &_ | |||
| "[PHONENUM1]," &_ | |||
| "[RESIDENTIAL_ADDRESS3]," &_ | |||
| "[FAXNUM]," &_ | |||
| "[PHONENUM2]," &_ | |||
| "[EMAIL])" &_ | |||
| "VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" | |||
| DAL.Execute sql, Array(model.JURISCODE, _ | |||
| model.TownshipName, _ | |||
| model.CONTACT_NAME, _ | |||
| model.TownshipNum, _ | |||
| model.BUSINESS_ADDRESS, _ | |||
| model.TITLE, _ | |||
| model.BUSINESS_ADDRESS2, _ | |||
| model.BUSINESS_ADDRESS3, _ | |||
| model.MAILING_ADDRESS, _ | |||
| model.MAILING_ADDRESS2, _ | |||
| model.MAILING_ADDRESS3, _ | |||
| model.RESIDENTIAL_ADDRESS, _ | |||
| model.RESIDENTIAL_ADDRESS2, _ | |||
| model.PHONENUM1, _ | |||
| model.RESIDENTIAL_ADDRESS3, _ | |||
| model.FAXNUM, _ | |||
| model.PHONENUM2, _ | |||
| model.EMAIL) | |||
| sql = "SELECT TOP 1 ID FROM [Contacts] ORDER BY ID DESC" | |||
| dim rs : set rs = DAL.Query(sql, empty) | |||
| model.ID = rs("ID") | |||
| Destroy rs | |||
| End Sub | |||
| Public Sub Update(model) | |||
| dim sql : sql = "UPDATE [Contacts] SET [JURISCODE] = ?," &_ | |||
| "[TownshipName] = ?," &_ | |||
| "[CONTACT_NAME] = ?," &_ | |||
| "[TownshipNum] = ?," &_ | |||
| "[BUSINESS_ADDRESS] = ?," &_ | |||
| "[TITLE] = ?," &_ | |||
| "[BUSINESS_ADDRESS2] = ?," &_ | |||
| "[BUSINESS_ADDRESS3] = ?," &_ | |||
| "[MAILING_ADDRESS] = ?," &_ | |||
| "[MAILING_ADDRESS2] = ?," &_ | |||
| "[MAILING_ADDRESS3] = ?," &_ | |||
| "[RESIDENTIAL_ADDRESS] = ?," &_ | |||
| "[RESIDENTIAL_ADDRESS2] = ?," &_ | |||
| "[PHONENUM1] = ?," &_ | |||
| "[RESIDENTIAL_ADDRESS3] = ?," &_ | |||
| "[FAXNUM] = ?," &_ | |||
| "[PHONENUM2] = ?," &_ | |||
| "[EMAIL] = ?" &_ | |||
| " WHERE [ID] = ?" | |||
| DAL.Execute sql, Array(model.JURISCODE, _ | |||
| model.TownshipName, _ | |||
| model.CONTACT_NAME, _ | |||
| model.TownshipNum, _ | |||
| model.BUSINESS_ADDRESS, _ | |||
| model.TITLE, _ | |||
| model.BUSINESS_ADDRESS2, _ | |||
| model.BUSINESS_ADDRESS3, _ | |||
| model.MAILING_ADDRESS, _ | |||
| model.MAILING_ADDRESS2, _ | |||
| model.MAILING_ADDRESS3, _ | |||
| model.RESIDENTIAL_ADDRESS, _ | |||
| model.RESIDENTIAL_ADDRESS2, _ | |||
| model.PHONENUM1, _ | |||
| model.RESIDENTIAL_ADDRESS3, _ | |||
| model.FAXNUM, _ | |||
| model.PHONENUM2, _ | |||
| model.EMAIL, _ | |||
| model.ID) | |||
| End Sub | |||
| Public Sub Delete(id) | |||
| dim sql : sql = "DELETE FROM [Contacts] WHERE [ID] = ?" | |||
| DAL.Execute sql, id | |||
| End Sub | |||
| End Class | |||
| dim ContactsRepository__Singleton | |||
| Function ContactsRepository() | |||
| If IsEmpty(ContactsRepository__Singleton) then | |||
| set ContactsRepository__Singleton = new ContactsRepository_Class | |||
| End If | |||
| set ContactsRepository = ContactsRepository__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,237 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Jurisdiction Model | |||
| '======================================================================================================================= | |||
| Class JurisdictionModel_Class | |||
| Public Validator | |||
| Public Class_Get_Properties | |||
| Public JCode '106 | |||
| Public Name '106 | |||
| Public Mailing_Address '106 | |||
| Public CSZ '106 | |||
| Public IMB '106 | |||
| Public IMB_Digits '106 | |||
| Private Sub Class_Initialize | |||
| 'ValidateExitsts Me, "","" | |||
| Class_Get_Properties = Array("JCode, Name, Mailing_Address, CSZ, IMB, IMB_Digits") | |||
| End Sub | |||
| End CLass | |||
| '======================================================================================================================= | |||
| ' Jurisdiction Repository | |||
| '======================================================================================================================= | |||
| Class JurisdictionRepository_Class | |||
| Public Function FindByJCode(JCode) | |||
| dim sql : sql = "Select [JCode], [Name], [Mailing_Address], [CSZ], [IMB], [IMB_Digits] FROM [Jurisdiction] WHERE JCode = ?" | |||
| dim rs : set rs = DAL.Query(sql,JCode) | |||
| If rs.EOF then | |||
| Err.Raise 1, "JurisdictionRepository_Class", JurisdictionNotFoundException("JCode", JCode) | |||
| Else | |||
| set FindByJCode = Automapper.AutoMap(rs,"JurisdictionModel_Class") | |||
| End If | |||
| End Function | |||
| Public Function GetAll(orderBy) | |||
| set GetAll = Find(empty,orderBy) | |||
| End Function | |||
| Public Function Find(where_kvarray, order_string_or_array) | |||
| dim sql : sql = "Select [JCode], [Name], [Mailing_Address], [CSZ], [IMB], [IMB_Digits] FROM [Jurisdiction]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim rs : set rs = DAL.Query(sql, where_values) | |||
| set Find = JurisdictionList(rs) | |||
| Destroy rs | |||
| End Function | |||
| Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [JCode], [Name], [Mailing_Address], [CSZ], [IMB], [IMB_Digits] FROM [Jurisdiction]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set FindPaged = PagedJurisdictionList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [JCode], [Name], [Mailing_Address], [CSZ], [IMB], [IMB_Digits] FROM [Jurisdiction]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " OR" | |||
| sql = sql & " " & where_keys(i) & " LIKE ?" | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & " ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set SearchTablePaged = PagedJurisdictionList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Private Function PagedJurisdictionList(rs, per_page) | |||
| dim list : set list = new LinkedList_Class | |||
| dim x : x =0 | |||
| Do While x < per_page and Not rs.EOF | |||
| list.Push Automapper.AutoMap(rs, new JurisdictionModel_Class) | |||
| x = x +1 | |||
| rs.MoveNext | |||
| Loop | |||
| set PagedJurisdictionList = list | |||
| End Function | |||
| Private Function JurisdictionNotFoundException(ByVal field_name, ByVal field_val) | |||
| JurisdictionNotFoundException = "Jurisdiction was not found with " & field_name & " of '" & field_val & "'." | |||
| End Function | |||
| Private Function JurisdictionList(rs) | |||
| dim list : set list = new LinkedList_Class | |||
| dim model | |||
| Do until rs.EOF | |||
| set model = new JurisdictionModel_Class | |||
| list.Push Automapper.AutoMap(rs, model) | |||
| rs.MoveNext | |||
| Loop | |||
| set JurisdictionList = list | |||
| End Function | |||
| Public Sub AddNew(ByRef model) | |||
| dim sql : sql = "INSERT INTO [Jurisdiction] (" &_ | |||
| "[Name]," &_ | |||
| "[Mailing_Address]," &_ | |||
| "[CSZ]," &_ | |||
| "[IMB]," &_ | |||
| "[IMB_Digits])" &_ | |||
| "VALUES (?,?,?,?,?)" | |||
| DAL.Execute sql, Array(model.Name, _ | |||
| model.Mailing_Address, _ | |||
| model.CSZ, _ | |||
| model.IMB, _ | |||
| model.IMB_Digits) | |||
| sql = "SELECT TOP 1 JCode FROM [Jurisdiction] ORDER BY JCode DESC" | |||
| dim rs : set rs = DAL.Query(sql, empty) | |||
| model.JCode = rs("JCode") | |||
| Destroy rs | |||
| End Sub | |||
| Public Sub Update(model) | |||
| dim sql : sql = "UPDATE [Jurisdiction] SET [Name] = ?," &_ | |||
| "[Mailing_Address] = ?," &_ | |||
| "[CSZ] = ?," &_ | |||
| "[IMB] = ?," &_ | |||
| "[IMB_Digits] = ?" &_ | |||
| " WHERE [JCode] = ?" | |||
| DAL.Execute sql, Array(model.Name, _ | |||
| model.Mailing_Address, _ | |||
| model.CSZ, _ | |||
| model.IMB, _ | |||
| model.IMB_Digits, _ | |||
| model.JCode) | |||
| End Sub | |||
| Public Sub Delete(id) | |||
| dim sql : sql = "DELETE FROM [Jurisdiction] WHERE [JCode] = ?" | |||
| DAL.Execute sql, id | |||
| End Sub | |||
| End Class | |||
| dim JurisdictionRepository__Singleton | |||
| Function JurisdictionRepository() | |||
| If IsEmpty(JurisdictionRepository__Singleton) then | |||
| set JurisdictionRepository__Singleton = new JurisdictionRepository_Class | |||
| End If | |||
| set JurisdictionRepository = JurisdictionRepository__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,247 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' KitLabels Model | |||
| '======================================================================================================================= | |||
| Class KitLabelsModel_Class | |||
| Public Validator | |||
| Public Class_Get_Properties | |||
| Public ID '90 | |||
| Public KitId '122 | |||
| Public OutboundSerial '106 | |||
| Public InBoundSerial '106 | |||
| Public OutboundIMB '106 | |||
| Public InBoundIMB '106 | |||
| Public OutboundIMBDigits '106 | |||
| Public InBoundIMBDigits '106 | |||
| Private Sub Class_Initialize | |||
| 'ValidateExitsts Me, "","" | |||
| Class_Get_Properties = Array("ID, KitId, OutboundSerial, InBoundSerial, OutboundIMB, InBoundIMB, OutboundIMBDigits, InBoundIMBDigits") | |||
| End Sub | |||
| End CLass | |||
| '======================================================================================================================= | |||
| ' KitLabels Repository | |||
| '======================================================================================================================= | |||
| Class KitLabelsRepository_Class | |||
| Public Function FindByID(ID) | |||
| dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels] WHERE ID = ?" | |||
| dim rs : set rs = DAL.Query(sql,ID) | |||
| If rs.EOF then | |||
| Err.Raise 1, "KitLabelsRepository_Class", KitLabelsNotFoundException("ID", ID) | |||
| Else | |||
| set FindByID = Automapper.AutoMap(rs,"KitLabelsModel_Class") | |||
| End If | |||
| End Function | |||
| Public Function GetAll(orderBy) | |||
| set GetAll = Find(empty,orderBy) | |||
| End Function | |||
| Public Function Find(where_kvarray, order_string_or_array) | |||
| dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim rs : set rs = DAL.Query(sql, where_values) | |||
| set Find = KitLabelsList(rs) | |||
| Destroy rs | |||
| End Function | |||
| Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set FindPaged = PagedKitLabelsList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [KitId], [OutboundSerial], [InBoundSerial], [OutboundIMB], [InBoundIMB], [OutboundIMBDigits], [InBoundIMBDigits] FROM [KitLabels]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " OR" | |||
| sql = sql & " " & where_keys(i) & " LIKE ?" | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & " ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set SearchTablePaged = PagedKitLabelsList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Private Function PagedKitLabelsList(rs, per_page) | |||
| dim list : set list = new LinkedList_Class | |||
| dim x : x =0 | |||
| Do While x < per_page and Not rs.EOF | |||
| list.Push Automapper.AutoMap(rs, new KitLabelsModel_Class) | |||
| x = x +1 | |||
| rs.MoveNext | |||
| Loop | |||
| set PagedKitLabelsList = list | |||
| End Function | |||
| Private Function KitLabelsNotFoundException(ByVal field_name, ByVal field_val) | |||
| KitLabelsNotFoundException = "KitLabels was not found with " & field_name & " of '" & field_val & "'." | |||
| End Function | |||
| Private Function KitLabelsList(rs) | |||
| dim list : set list = new LinkedList_Class | |||
| dim model | |||
| Do until rs.EOF | |||
| set model = new KitLabelsModel_Class | |||
| list.Push Automapper.AutoMap(rs, model) | |||
| rs.MoveNext | |||
| Loop | |||
| set KitLabelsList = list | |||
| End Function | |||
| Public Sub AddNew(ByRef model) | |||
| dim sql : sql = "INSERT INTO [KitLabels] (" &_ | |||
| "[KitId]," &_ | |||
| "[OutboundSerial]," &_ | |||
| "[InBoundSerial]," &_ | |||
| "[OutboundIMB]," &_ | |||
| "[InBoundIMB]," &_ | |||
| "[OutboundIMBDigits]," &_ | |||
| "[InBoundIMBDigits])" &_ | |||
| "VALUES (?,?,?,?,?,?,?)" | |||
| DAL.Execute sql, Array(model.KitId, _ | |||
| model.OutboundSerial, _ | |||
| model.InBoundSerial, _ | |||
| model.OutboundIMB, _ | |||
| model.InBoundIMB, _ | |||
| model.OutboundIMBDigits, _ | |||
| model.InBoundIMBDigits) | |||
| sql = "SELECT TOP 1 ID FROM [KitLabels] ORDER BY ID DESC" | |||
| dim rs : set rs = DAL.Query(sql, empty) | |||
| model.ID = rs("ID") | |||
| Destroy rs | |||
| End Sub | |||
| Public Sub Update(model) | |||
| dim sql : sql = "UPDATE [KitLabels] SET [KitId] = ?," &_ | |||
| "[OutboundSerial] = ?," &_ | |||
| "[InBoundSerial] = ?," &_ | |||
| "[OutboundIMB] = ?," &_ | |||
| "[InBoundIMB] = ?," &_ | |||
| "[OutboundIMBDigits] = ?," &_ | |||
| "[InBoundIMBDigits] = ?" &_ | |||
| " WHERE [ID] = ?" | |||
| DAL.Execute sql, Array(model.KitId, _ | |||
| model.OutboundSerial, _ | |||
| model.InBoundSerial, _ | |||
| model.OutboundIMB, _ | |||
| model.InBoundIMB, _ | |||
| model.OutboundIMBDigits, _ | |||
| model.InBoundIMBDigits, _ | |||
| model.ID) | |||
| End Sub | |||
| Public Sub Delete(id) | |||
| dim sql : sql = "DELETE FROM [KitLabels] WHERE [ID] = ?" | |||
| DAL.Execute sql, id | |||
| End Sub | |||
| End Class | |||
| dim KitLabelsRepository__Singleton | |||
| Function KitLabelsRepository() | |||
| If IsEmpty(KitLabelsRepository__Singleton) then | |||
| set KitLabelsRepository__Singleton = new KitLabelsRepository_Class | |||
| End If | |||
| set KitLabelsRepository = KitLabelsRepository__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,222 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Kit Model | |||
| '======================================================================================================================= | |||
| Class KitModel_Class | |||
| Public Validator | |||
| Public Class_Get_Properties | |||
| Public ID '90 | |||
| Public JobNumber '106 | |||
| Public Jcode '106 | |||
| Private Sub Class_Initialize | |||
| 'ValidateExitsts Me, "","" | |||
| Class_Get_Properties = Array("ID, JobNumber, Jcode") | |||
| End Sub | |||
| End CLass | |||
| '======================================================================================================================= | |||
| ' Kit Repository | |||
| '======================================================================================================================= | |||
| Class KitRepository_Class | |||
| Public Function FindByID(ID) | |||
| dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit] WHERE ID = ?" | |||
| dim rs : set rs = DAL.Query(sql,ID) | |||
| If rs.EOF then | |||
| Err.Raise 1, "KitRepository_Class", KitNotFoundException("ID", ID) | |||
| Else | |||
| set FindByID = Automapper.AutoMap(rs,"KitModel_Class") | |||
| End If | |||
| End Function | |||
| Public Function GetAll(orderBy) | |||
| set GetAll = Find(empty,orderBy) | |||
| End Function | |||
| Public Function Find(where_kvarray, order_string_or_array) | |||
| dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim rs : set rs = DAL.Query(sql, where_values) | |||
| set Find = KitList(rs) | |||
| Destroy rs | |||
| End Function | |||
| Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set FindPaged = PagedKitList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [JobNumber], [Jcode] FROM [Kit]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " OR" | |||
| sql = sql & " " & where_keys(i) & " LIKE ?" | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & " ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set SearchTablePaged = PagedKitList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Private Function PagedKitList(rs, per_page) | |||
| dim list : set list = new LinkedList_Class | |||
| dim x : x =0 | |||
| Do While x < per_page and Not rs.EOF | |||
| list.Push Automapper.AutoMap(rs, new KitModel_Class) | |||
| x = x +1 | |||
| rs.MoveNext | |||
| Loop | |||
| set PagedKitList = list | |||
| End Function | |||
| Private Function KitNotFoundException(ByVal field_name, ByVal field_val) | |||
| KitNotFoundException = "Kit was not found with " & field_name & " of '" & field_val & "'." | |||
| End Function | |||
| Private Function KitList(rs) | |||
| dim list : set list = new LinkedList_Class | |||
| dim model | |||
| Do until rs.EOF | |||
| set model = new KitModel_Class | |||
| list.Push Automapper.AutoMap(rs, model) | |||
| rs.MoveNext | |||
| Loop | |||
| set KitList = list | |||
| End Function | |||
| Public Sub AddNew(ByRef model) | |||
| dim sql : sql = "INSERT INTO [Kit] (" &_ | |||
| "[JobNumber]," &_ | |||
| "[Jcode])" &_ | |||
| "VALUES (?,?)" | |||
| DAL.Execute sql, Array(model.JobNumber, _ | |||
| model.Jcode) | |||
| sql = "SELECT TOP 1 ID FROM [Kit] ORDER BY ID DESC" | |||
| dim rs : set rs = DAL.Query(sql, empty) | |||
| model.ID = rs("ID") | |||
| Destroy rs | |||
| End Sub | |||
| Public Sub Update(model) | |||
| dim sql : sql = "UPDATE [Kit] SET [JobNumber] = ?," &_ | |||
| "[Jcode] = ?" &_ | |||
| " WHERE [ID] = ?" | |||
| DAL.Execute sql, Array(model.JobNumber, _ | |||
| model.Jcode, _ | |||
| model.ID) | |||
| End Sub | |||
| Public Sub Delete(id) | |||
| dim sql : sql = "DELETE FROM [Kit] WHERE [ID] = ?" | |||
| DAL.Execute sql, id | |||
| End Sub | |||
| End Class | |||
| dim KitRepository__Singleton | |||
| Function KitRepository() | |||
| If IsEmpty(KitRepository__Singleton) then | |||
| set KitRepository__Singleton = new KitRepository_Class | |||
| End If | |||
| set KitRepository = KitRepository__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,222 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Settings Model | |||
| '======================================================================================================================= | |||
| Class SettingsModel_Class | |||
| Public Validator | |||
| Public Class_Get_Properties | |||
| Public ID '90 | |||
| Public Name '106 | |||
| Public Value '106 | |||
| Private Sub Class_Initialize | |||
| 'ValidateExitsts Me, "","" | |||
| Class_Get_Properties = Array("ID, Name, Value") | |||
| End Sub | |||
| End CLass | |||
| '======================================================================================================================= | |||
| ' Settings Repository | |||
| '======================================================================================================================= | |||
| Class SettingsRepository_Class | |||
| Public Function FindByID(ID) | |||
| dim sql : sql = "Select [ID], [Name], [Value] FROM [Settings] WHERE ID = ?" | |||
| dim rs : set rs = DAL.Query(sql,ID) | |||
| If rs.EOF then | |||
| Err.Raise 1, "SettingsRepository_Class", SettingsNotFoundException("ID", ID) | |||
| Else | |||
| set FindByID = Automapper.AutoMap(rs,"SettingsModel_Class") | |||
| End If | |||
| End Function | |||
| Public Function GetAll(orderBy) | |||
| set GetAll = Find(empty,orderBy) | |||
| End Function | |||
| Public Function Find(where_kvarray, order_string_or_array) | |||
| dim sql : sql = "Select [ID], [Name], [Value] FROM [Settings]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim rs : set rs = DAL.Query(sql, where_values) | |||
| set Find = SettingsList(rs) | |||
| Destroy rs | |||
| End Function | |||
| Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [Name], [Value] FROM [Settings]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " AND " | |||
| sql = sql & " " & where_keys(i) & " " | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & "ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set FindPaged = PagedSettingsList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count) | |||
| dim sql : sql = "Select [ID], [Name], [Value] FROM [Settings]" | |||
| If Not IsEmpty(where_kvarray) then | |||
| sql = sql & " WHERE " | |||
| dim where_keys, where_values | |||
| KVUnzip where_kvarray, where_keys, where_values | |||
| dim i | |||
| For i = 0 to UBound(where_keys) | |||
| If i > 0 then sql = sql & " OR" | |||
| sql = sql & " " & where_keys(i) & " LIKE ?" | |||
| Next | |||
| End If | |||
| If Not IsEmpty(order_string_or_array) then | |||
| sql = sql & " ORDER BY " | |||
| If IsArray(order_string_or_array) then | |||
| dim order_array : order_array = order_string_or_array | |||
| For i = 0 to UBound(order_array) | |||
| If i > 0 then sql = sql & ", " | |||
| sql = sql & " " & order_array(i) | |||
| Next | |||
| Else | |||
| sql = sql & order_string_or_array & " " | |||
| End If | |||
| End If | |||
| dim list : set list = new LinkedList_Class | |||
| dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num) | |||
| If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then | |||
| rs.PageSize = per_page | |||
| rs.AbsolutePage = page_num | |||
| page_count = rs.PageCount | |||
| record_count = rs.RecordCount | |||
| End If | |||
| set SearchTablePaged = PagedSettingsList(rs, per_page) | |||
| Destroy rs | |||
| End Function | |||
| Private Function PagedSettingsList(rs, per_page) | |||
| dim list : set list = new LinkedList_Class | |||
| dim x : x =0 | |||
| Do While x < per_page and Not rs.EOF | |||
| list.Push Automapper.AutoMap(rs, new SettingsModel_Class) | |||
| x = x +1 | |||
| rs.MoveNext | |||
| Loop | |||
| set PagedSettingsList = list | |||
| End Function | |||
| Private Function SettingsNotFoundException(ByVal field_name, ByVal field_val) | |||
| SettingsNotFoundException = "Settings was not found with " & field_name & " of '" & field_val & "'." | |||
| End Function | |||
| Private Function SettingsList(rs) | |||
| dim list : set list = new LinkedList_Class | |||
| dim model | |||
| Do until rs.EOF | |||
| set model = new SettingsModel_Class | |||
| list.Push Automapper.AutoMap(rs, model) | |||
| rs.MoveNext | |||
| Loop | |||
| set SettingsList = list | |||
| End Function | |||
| Public Sub AddNew(ByRef model) | |||
| dim sql : sql = "INSERT INTO [Settings] (" &_ | |||
| "[Name]," &_ | |||
| "[Value])" &_ | |||
| "VALUES (?,?)" | |||
| DAL.Execute sql, Array(model.Name, _ | |||
| model.Value) | |||
| sql = "SELECT TOP 1 ID FROM [Settings] ORDER BY ID DESC" | |||
| dim rs : set rs = DAL.Query(sql, empty) | |||
| model.ID = rs("ID") | |||
| Destroy rs | |||
| End Sub | |||
| Public Sub Update(model) | |||
| dim sql : sql = "UPDATE [Settings] SET [Name] = ?," &_ | |||
| "[Value] = ?" &_ | |||
| " WHERE [ID] = ?" | |||
| DAL.Execute sql, Array(model.Name, _ | |||
| model.Value, _ | |||
| model.ID) | |||
| End Sub | |||
| Public Sub Delete(id) | |||
| dim sql : sql = "DELETE FROM [Settings] WHERE [ID] = ?" | |||
| DAL.Execute sql, id | |||
| End Sub | |||
| End Class | |||
| dim SettingsRepository__Singleton | |||
| Function SettingsRepository() | |||
| If IsEmpty(SettingsRepository__Singleton) then | |||
| set SettingsRepository__Singleton = new SettingsRepository_Class | |||
| End If | |||
| set SettingsRepository = SettingsRepository__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,716 @@ | |||
| Const IncludeDirectory = "F:\Development\VBS Includes\" | |||
| includeFile "adovbs" | |||
| includeFile "CLogger" | |||
| includeFile "Public_Functions" | |||
| includeFile "VBSEnvironment" | |||
| includeFile "Database_Class" | |||
| includeFile "lib.collections" | |||
| Dim props,fieldNamesArray | |||
| Dim oConn,fso,includedFile,rs | |||
| Dim fixedTableName,tableName | |||
| Dim PrimaryKeyDictionary | |||
| Set oConn = WScript.CreateObject("ADODB.Connection") | |||
| Set fso = WScript.CreateObject("Scripting.Filesystemobject") | |||
| oConn.ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\Development\Tracking_Kits\Data\webdata.mdb" | |||
| 'oConn.ConnectionString = "Provider=SQLOLEDB;Data Source=danielsubuntu,15789;Initial Catalog=northwind;User Id=sa;Password=SunBrightShine!;" | |||
| Init | |||
| fixedTableName = Replace(rs("TABLE_NAME")," ","_") | |||
| tableName = rs("TABLE_NAME") | |||
| Do While Not rs.EOF | |||
| fixedTableName = Replace(rs("TABLE_NAME")," ","_") | |||
| tableName = rs("TABLE_NAME") | |||
| 'If tableName <> "meta_migrations" Then | |||
| If tableName <> "meta_migrations" AND tableName = "KitLabels" Then | |||
| debug.WriteLine(tableName) | |||
| If Not fso.FolderExists(ScriptDirectory()& "Controllers\"& fixedTableName) Then fso.CreateFolder(ScriptDirectory()& "Controllers\"& fixedTableName) | |||
| If Not fso.FolderExists(ScriptDirectory()& "Controllers\") Then fso.CreateFolder(ScriptDirectory()& "Controllers\") | |||
| If Not fso.FolderExists(ScriptDirectory()& "Views\" & Replace(tableName," ","_")) Then fso.CreateFolder(ScriptDirectory()& "Views\" & Replace(tableName," ","_")) | |||
| Set file = fso.CreateTextFile(ScriptDirectory()& "DomainModels\" & fixedTableName & "Repository.asp",True) | |||
| includedFile.WriteLine("<!--#include file=""DomainModels/"& fixedTableName & "Repository.asp""-->") | |||
| file.WriteLine("<%") | |||
| file.WriteLine("'=======================================================================================================================") | |||
| file.WriteLine("' " & fixedTableName & " Model") | |||
| file.WriteLine("'=======================================================================================================================") | |||
| file.WriteLine("") | |||
| file.WriteLine("Class " & fixedTableName & "Model_Class") | |||
| file.WriteLine(" Public Validator") | |||
| file.WriteLine(" Public Class_Get_Properties") | |||
| file.WriteLine("") | |||
| InitFieldNameIterator ' This Sub is werid and needs to be looked at | |||
| fieldNamesArray = props.toArray() | |||
| file.WriteLine("") | |||
| file.WriteLine(" Private Sub Class_Initialize") | |||
| file.WriteLine(" 'ValidateExitsts Me, """",""""") | |||
| file.WriteLine(" Class_Get_Properties = Array(""" & Join (fieldNamesArray,", ") & """)") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine("End CLass") | |||
| file.WriteLine("") | |||
| file.WriteLine("'=======================================================================================================================") | |||
| file.WriteLine("' " & tableName & " Repository") | |||
| file.WriteLine("'=======================================================================================================================") | |||
| file.WriteLine("") | |||
| file.WriteLine("Class " & fixedTableName & "Repository_Class") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Function FindBy" & PrimaryKeyDictionary(tableName) & "("& PrimaryKeyDictionary(tableName) & ")") | |||
| file.WriteLine(" dim sql : sql = ""Select [" & Join (fieldNamesArray,"], [") & "] FROM [" & tableName & "] WHERE " & PrimaryKeyDictionary(tableName) & " = ?""") | |||
| file.WriteLine(" dim rs : set rs = DAL.Query(sql," & PrimaryKeyDictionary(tableName) & ")") | |||
| File.WriteLine(" If rs.EOF then") | |||
| File.WriteLine(" Err.Raise 1, """ & fixedTableName & "Repository_Class"", "& fixedTableName &"NotFoundException(""" & PrimaryKeyDictionary(tableName) &""", "& PrimaryKeyDictionary(tableName) & ")") | |||
| File.WriteLine(" Else") | |||
| File.WriteLine(" set FindBy" & PrimaryKeyDictionary(tableName) & " = Automapper.AutoMap(rs,""" & tableName & "Model_Class" & """)") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Function GetAll(orderBy)") | |||
| file.WriteLine(" set GetAll = Find(empty,orderBy)") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Function Find(where_kvarray, order_string_or_array)") | |||
| file.WriteLine(" dim sql : sql = ""Select [" & Join (fieldNamesArray,"], [") & "] FROM [" & tableName & "]""") | |||
| File.WriteLine("") | |||
| File.WriteLine(" If Not IsEmpty(where_kvarray) then") | |||
| File.WriteLine(" sql = sql & "" WHERE """) | |||
| File.WriteLine(" dim where_keys, where_values") | |||
| File.WriteLine(" KVUnzip where_kvarray, where_keys, where_values") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim i") | |||
| file.WriteLine(" For i = 0 to UBound(where_keys)") | |||
| file.WriteLine(" If i > 0 then sql = sql & "" AND """) | |||
| file.WriteLine(" sql = sql & "" "" & where_keys(i) & "" """) | |||
| file.WriteLine(" Next") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" If Not IsEmpty(order_string_or_array) then") | |||
| file.WriteLine(" sql = sql & ""ORDER BY """) | |||
| file.WriteLine(" If IsArray(order_string_or_array) then") | |||
| file.WriteLine(" dim order_array : order_array = order_string_or_array") | |||
| file.WriteLine(" For i = 0 to UBound(order_array)") | |||
| file.WriteLine(" If i > 0 then sql = sql & "", """) | |||
| file.WriteLine(" sql = sql & "" "" & order_array(i)") | |||
| file.WriteLine(" Next") | |||
| file.WriteLine(" Else") | |||
| file.WriteLine(" sql = sql & order_string_or_array & "" """) | |||
| file.WriteLine(" End If") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim rs : set rs = DAL.Query(sql, where_values)") | |||
| file.WriteLine(" set Find = " & fixedTableName & "List(rs)") | |||
| file.WriteLine(" Destroy rs") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Function FindPaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)") | |||
| file.WriteLine(" dim sql : sql = ""Select [" & Join (fieldNamesArray,"], [") & "] FROM [" & tableName & "]""") | |||
| File.WriteLine("") | |||
| File.WriteLine(" If Not IsEmpty(where_kvarray) then") | |||
| File.WriteLine(" sql = sql & "" WHERE """) | |||
| File.WriteLine(" dim where_keys, where_values") | |||
| File.WriteLine(" KVUnzip where_kvarray, where_keys, where_values") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim i") | |||
| file.WriteLine(" For i = 0 to UBound(where_keys)") | |||
| file.WriteLine(" If i > 0 then sql = sql & "" AND """) | |||
| file.WriteLine(" sql = sql & "" "" & where_keys(i) & "" """) | |||
| file.WriteLine(" Next") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" If Not IsEmpty(order_string_or_array) then") | |||
| file.WriteLine(" sql = sql & ""ORDER BY """) | |||
| file.WriteLine(" If IsArray(order_string_or_array) then") | |||
| file.WriteLine(" dim order_array : order_array = order_string_or_array") | |||
| file.WriteLine(" For i = 0 to UBound(order_array)") | |||
| file.WriteLine(" If i > 0 then sql = sql & "", """) | |||
| file.WriteLine(" sql = sql & "" "" & order_array(i)") | |||
| file.WriteLine(" Next") | |||
| file.WriteLine(" Else") | |||
| file.WriteLine(" sql = sql & order_string_or_array & "" """) | |||
| file.WriteLine(" End If") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim list : set list = new LinkedList_Class") | |||
| file.WriteLine(" dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)") | |||
| file.WriteLine("") | |||
| file.WriteLine(" If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then") | |||
| file.WriteLine(" rs.PageSize = per_page") | |||
| file.WriteLine(" rs.AbsolutePage = page_num") | |||
| file.WriteLine(" page_count = rs.PageCount") | |||
| file.WriteLine(" record_count = rs.RecordCount") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" set FindPaged = Paged"& fixedTableName & "List(rs, per_page)") | |||
| file.WriteLine(" Destroy rs") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Function SearchTablePaged(where_kvarray, order_string_or_array, per_page, page_num, ByRef page_count, ByRef record_count)") | |||
| file.WriteLine(" dim sql : sql = ""Select [" & Join (fieldNamesArray,"], [") & "] FROM [" & tableName & "]""") | |||
| File.WriteLine("") | |||
| File.WriteLine(" If Not IsEmpty(where_kvarray) then") | |||
| File.WriteLine(" sql = sql & "" WHERE """) | |||
| File.WriteLine(" dim where_keys, where_values") | |||
| File.WriteLine(" KVUnzip where_kvarray, where_keys, where_values") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim i") | |||
| file.WriteLine(" For i = 0 to UBound(where_keys)") | |||
| file.WriteLine(" If i > 0 then sql = sql & "" OR""") | |||
| file.WriteLine(" sql = sql & "" "" & where_keys(i) & "" LIKE ?""") | |||
| file.WriteLine(" Next") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" If Not IsEmpty(order_string_or_array) then") | |||
| file.WriteLine(" sql = sql & "" ORDER BY """) | |||
| file.WriteLine(" If IsArray(order_string_or_array) then") | |||
| file.WriteLine(" dim order_array : order_array = order_string_or_array") | |||
| file.WriteLine(" For i = 0 to UBound(order_array)") | |||
| file.WriteLine(" If i > 0 then sql = sql & "", """) | |||
| file.WriteLine(" sql = sql & "" "" & order_array(i)") | |||
| file.WriteLine(" Next") | |||
| file.WriteLine(" Else") | |||
| file.WriteLine(" sql = sql & order_string_or_array & "" """) | |||
| file.WriteLine(" End If") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim list : set list = new LinkedList_Class") | |||
| file.WriteLine(" dim rs : set rs = DAL.PagedQuery(sql, where_values, per_page, page_num)") | |||
| file.WriteLine("") | |||
| file.WriteLine(" If Not rs.EOF and Not (IsEmpty(per_page) and IsEmpty(page_num) and IsEmpty(page_count) and IsEmpty(record_count)) then") | |||
| file.WriteLine(" rs.PageSize = per_page") | |||
| file.WriteLine(" rs.AbsolutePage = page_num") | |||
| file.WriteLine(" page_count = rs.PageCount") | |||
| file.WriteLine(" record_count = rs.RecordCount") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" set SearchTablePaged = Paged"& fixedTableName & "List(rs, per_page)") | |||
| file.WriteLine(" Destroy rs") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Private Function Paged"& fixedTableName & "List(rs, per_page)") | |||
| file.WriteLine(" dim list : set list = new LinkedList_Class") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim x : x =0") | |||
| file.WriteLine(" Do While x < per_page and Not rs.EOF") | |||
| file.WriteLine(" list.Push Automapper.AutoMap(rs, new " & fixedTableName & "Model_Class" & ")") | |||
| file.WriteLine(" x = x +1") | |||
| file.WriteLine(" rs.MoveNext") | |||
| file.WriteLine(" Loop") | |||
| file.WriteLine(" set Paged"& fixedTableName & "List = list") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Private Function " & fixedTableName &"NotFoundException(ByVal field_name, ByVal field_val)") | |||
| file.WriteLine(" "& fixedTableName & "NotFoundException = """ & fixedTableName & " was not found with "" & field_name & "" of '"" & field_val & ""'.""") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Private Function " & fixedTableName & "List(rs)") | |||
| file.WriteLine(" dim list : set list = new LinkedList_Class") | |||
| file.WriteLine(" dim model") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Do until rs.EOF") | |||
| file.WriteLine(" set model = new " & fixedTableName & "Model_Class") | |||
| file.WriteLine(" list.Push Automapper.AutoMap(rs, model)") | |||
| file.WriteLine(" rs.MoveNext") | |||
| file.WriteLine(" Loop") | |||
| file.WriteLine(" set " & fixedTableName & "List = list") | |||
| file.WriteLine(" End Function") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub AddNew(ByRef model)") | |||
| file.WriteLine(" dim sql : sql = ""INSERT INTO ["& fixedTableName & "] ("" &_") | |||
| For Fields = 1 To UBound(fieldNamesArray)-1 | |||
| file.WriteLine(" ""[" & fieldNamesArray(Fields) & "],"" &_") | |||
| Next | |||
| file.WriteLine(" ""[" & fieldNamesArray(UBound(fieldNamesArray)) & "])"" &_") | |||
| file.Write(" ""VALUES (?") | |||
| For Fields = 1 To UBound(fieldNamesArray)-1 | |||
| file.Write(",?") | |||
| Next | |||
| file.Write(")""" & VbCrLf) | |||
| file.WriteLine(" DAL.Execute sql, Array(model." & fieldNamesArray(1) & ", _") | |||
| For Fields = 2 To UBound(fieldNamesArray) -1 | |||
| file.WriteLine(" model." & fieldNamesArray(Fields) & ", _") | |||
| Next | |||
| file.WriteLine(" model." & fieldNamesArray(UBound(fieldNamesArray)) & ")") | |||
| file.WriteLine(" sql = ""SELECT TOP 1 " & PrimaryKeyDictionary(tableName) & " FROM [" & fixedTableName & "] ORDER BY "& PrimaryKeyDictionary(tableName) & " DESC""") | |||
| file.WriteLine(" dim rs : set rs = DAL.Query(sql, empty)") | |||
| file.WriteLine(" model." & PrimaryKeyDictionary(tableName) & " = rs(""" & PrimaryKeyDictionary(tableName) & """)") | |||
| file.WriteLine(" Destroy rs") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub Update(model)") | |||
| file.WriteLine(" dim sql : sql = ""UPDATE ["& fixedTableName & "] SET [" & fieldNamesArray(1) & "] = ?,"" &_") | |||
| For Fields = 2 To UBound(fieldNamesArray) - 1 | |||
| file.WriteLine(" ""[" & fieldNamesArray(Fields) & "] = ?,"" &_") | |||
| Next | |||
| file.Write (" ""[" & fieldNamesArray(UBound(fieldNamesArray)) & "] = ?"" &_" & VbCrLf) | |||
| file.WriteLine(" "" WHERE ["& PrimaryKeyDictionary(tableName) & "] = ?""") | |||
| file.WriteLine("") | |||
| file.WriteLine(" DAL.Execute sql, Array(model." & fieldNamesArray(1) & ", _") | |||
| For Fields = 2 To UBound(fieldNamesArray) | |||
| file.WriteLine(" model." & fieldNamesArray(Fields) & ", _") | |||
| Next | |||
| file.Write(" model." & PrimaryKeyDictionary(tableName) & ")" & VbCrLf) | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub Delete(id)") | |||
| file.WriteLine(" dim sql : sql = ""DELETE FROM ["& fixedTableName & "] WHERE ["& PrimaryKeyDictionary(tableName) & "] = ?""") | |||
| file.WriteLine(" DAL.Execute sql, id") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("End Class") | |||
| file.WriteLine("") | |||
| File.WriteLine("dim " & fixedTableName & "Repository__Singleton") | |||
| File.WriteLine("Function " & fixedTableName & "Repository()") | |||
| File.WriteLine(" If IsEmpty(" & fixedTableName & "Repository__Singleton) then") | |||
| file.WriteLine(" set " & fixedTableName & "Repository__Singleton = new " & fixedTableName & "Repository_Class") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine(" set " & fixedTableName & "Repository = " & fixedTableName & "Repository__Singleton") | |||
| file.WriteLine("End Function") | |||
| file.WriteLine("%>") | |||
| file.Close | |||
| Set file = fso.CreateTextFile(ScriptDirectory()& "ViewModels\" & fixedTableName & "ViewModels.asp",True) | |||
| file.WriteLine("<%") | |||
| file.WriteLine("Class PagedIndex_ViewModel_Class") | |||
| file.WriteLine(" Public Title") | |||
| file.WriteLine(" Public " & fixedTableName) | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public CurrentPageNumber") | |||
| file.WriteLine(" Public PageSize") | |||
| file.WriteLine(" Public PageCount") | |||
| file.WriteLine(" Public RecordCount") | |||
| file.WriteLine("End Class") | |||
| file.WriteLine("") | |||
| file.WriteLine("Class Edit_ViewModel_Class") | |||
| file.WriteLine(" Public Title") | |||
| file.WriteLine(" Public " & fixedTableName) | |||
| file.WriteLine("") | |||
| file.WriteLine("End Class") | |||
| file.WriteLine("") | |||
| file.WriteLine("Class Create_ViewModel_Class") | |||
| For Each fieldName In fieldNamesArray | |||
| If Not fieldName = PrimaryKeyDictionary(tableName) then | |||
| file.WriteLine(" Public " & fieldName) | |||
| End If | |||
| Next | |||
| file.WriteLine("End Class") | |||
| file.WriteLine("") | |||
| file.WriteLine("Class Delete_ViewModel_Class") | |||
| file.WriteLine(" Public Title") | |||
| file.WriteLine(" Public " & fixedTableName ) | |||
| file.WriteLine("End Class") | |||
| file.WriteLine("") | |||
| file.WriteLine("%>") | |||
| file.Close | |||
| Set file = fso.CreateTextFile(ScriptDirectory()& "Controllers\" & fixedTableName & "\" & fixedTableName & "Controller.asp",True) | |||
| file.WriteLine("<% Option Explicit %>") | |||
| file.WriteLine("<!--#include file=""../../include_all.asp""-->") | |||
| file.WriteLine("<!--#include file=""../../ViewModels/" & fixedTableName & "ViewModels.asp""-->") | |||
| file.WriteLine("<%") | |||
| file.WriteLine("Class " & fixedTableName & "Controller") | |||
| file.WriteLine(" Public Model") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub Index") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim page_size : page_size = 10") | |||
| file.WriteLine(" dim page_num : page_num = Choice(Len(Request.Querystring(""page_num"")) > 0, Request.Querystring(""page_num""), 1)") | |||
| file.WriteLine(" dim page_count, record_count") | |||
| file.WriteLine(" set Model = new PagedIndex_ViewModel_Class") | |||
| file.WriteLine(" Model.Title = """ & tableName & """") | |||
| file.WriteLine(" set Model." & fixedTableName & " = " & fixedTableName & "Repository.FindPaged(empty, """ & PrimaryKeyDictionary(tableName) & """, page_size, page_num, page_count, record_count)") | |||
| file.WriteLine(" Model.CurrentPageNumber = page_num") | |||
| file.WriteLine(" Model.PageSize = page_size") | |||
| file.WriteLine(" Model.PageCount = page_count") | |||
| file.WriteLine(" Model.RecordCount = record_count") | |||
| file.WriteLine(" %> <!--#include file=""../../Views/" & fixedTableName & "/Index.asp""--> <%") | |||
| file.WriteLine("") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine(" Public Sub Search") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim searchValue:searchValue = Choice(Request.Form.Count = 0,Request.QueryString(""q""),Request.Form(""q""))") | |||
| file.WriteLine(" dim page_size : page_size = 10") | |||
| file.WriteLine(" dim page_num : page_num = Choice(Len(Request.Querystring(""page_num"")) > 0, Request.Querystring(""page_num""), 1)") | |||
| file.WriteLine(" dim page_count, record_count") | |||
| file.WriteLine(" set Model = new PagedIndex_ViewModel_Class") | |||
| file.WriteLine(" Model.Title = """ & tableName & """") | |||
| file.WriteLine(" set Model." & fixedTableName & " = " & fixedTableName & "Repository.SearchTablePaged(Array(""" & Join (fieldNamesArray,""",""%"" & searchValue & ""%"",""") & """,""%"" & searchValue & ""%""),""" & PrimaryKeyDictionary(tableName) & """, page_size, page_num, page_count, record_count)") | |||
| file.WriteLine(" Model.CurrentPageNumber = page_num") | |||
| file.WriteLine(" Model.PageSize = page_size") | |||
| file.WriteLine(" Model.PageCount = page_count") | |||
| file.WriteLine(" Model.RecordCount = record_count") | |||
| file.WriteLine(" %> <!--#include file=""../../Views/" & fixedTableName & "/Index.asp""--> <%") | |||
| file.WriteLine("") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub Edit") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim id : id = Request.QueryString(""Id"")") | |||
| file.WriteLine(" set Model = new Edit_ViewModel_Class") | |||
| file.WriteLine(" set Model." & fixedTableName & " = " & fixedTableName & "Repository.FindBy" & PrimaryKeyDictionary(tableName) & "(id)") | |||
| file.WriteLine(" Model.Title = ""Edit " & fixedTableName & """") | |||
| file.WriteLine(" HTMLSecurity.SetAntiCSRFToken """ & fixedTableName & "EditForm""") | |||
| file.WriteLine(" %> <!--#include file=""../../Views/"& fixedTableName &"/Edit.asp""--> <%") | |||
| file.WriteLine(" Flash.Success = """ & fixedTableName & " " & id & " Updated.""") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub EditPost") | |||
| file.WriteLine(" MVC.RequirePost") | |||
| File.WriteLine(" HTMLSecurity.OnInvalidAntiCsrfTokenRedirectToActionExt """ & fixedTableName & "EditForm"", Request.Form(""nonce""), ""Edit"", Array(""Id"", Request.Form(""Id""))") | |||
| File.WriteLine(" dim " & PrimaryKeyDictionary(tableName) & " : " & PrimaryKeyDictionary(tableName) & " = Request.Form(""Id"")") | |||
| File.WriteLine(" dim model : set model = " & fixedTableName & "Repository.FindBy" & PrimaryKeyDictionary(tableName) & "(" & PrimaryKeyDictionary(tableName) & ")") | |||
| File.WriteLine(" set model = Automapper.AutoMap(Request.Form, model)") | |||
| File.WriteLine(" 'model.Validate") | |||
| File.WriteLine(" 'If model.Validator.HasErrors then") | |||
| File.WriteLine(" FormCache.SerializeForm ""Edit" & fixedTableName & """, Request.Form") | |||
| File.WriteLine(" ' Flash.Errors = model.Validator.Errors") | |||
| File.WriteLine(" ' MVC.RedirectToActionExt ""Edit"", Array(""Id""," & PrimaryKeyDictionary(tableName) & ")") | |||
| File.WriteLine(" 'Else") | |||
| File.WriteLine(" " & fixedTableName & "Repository.Update model") | |||
| File.WriteLine(" FormCache.ClearForm ""Edit" & fixedTableName & """") | |||
| File.WriteLine(" Flash.Success = """ & fixedTableName & " updated.""") | |||
| File.WriteLine(" MVC.RedirectToAction ""Index""") | |||
| File.WriteLine(" 'End If") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub Create") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim form_params : set form_params = FormCache.DeserializeForm(""New" & fixedTableName & """)") | |||
| file.WriteLine(" If Not form_params Is Nothing then") | |||
| file.WriteLine(" set Model = Automapper.AutoMap(form_params, New Create_ViewModel_Class)") | |||
| file.WriteLine(" Else") | |||
| file.WriteLine(" set Model = new Create_ViewModel_Class") | |||
| file.WriteLine(" End If") | |||
| file.WriteLine("") | |||
| file.WriteLine(" HTMLSecurity.SetAntiCSRFToken """ & fixedTableName & "CreateForm""") | |||
| file.WriteLine("") | |||
| file.WriteLine(" %> <!--#include file=""../../Views/" & fixedTableName & "/Create.asp""--> <%") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub CreatePost") | |||
| file.WriteLine("") | |||
| file.WriteLine(" MVC.RequirePost") | |||
| file.WriteLine(" HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction """ & fixedTableName & "CreateForm"", Request.Form(""nonce""), ""Create""") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim new_" & fixedTableName & "_model : set new_" & fixedTableName & "_model = Automapper.AutoMap(Request.Form, new " & fixedTableName & "Model_Class)") | |||
| file.WriteLine("") | |||
| file.WriteLine(" 'new_" & fixedTableName & "_model.Validator.Validate") | |||
| file.WriteLine("") | |||
| file.WriteLine(" 'If new_" & fixedTableName & "_model.Validator.HasErrors then") | |||
| file.WriteLine(" ' FormCache.SerializeForm ""New" & fixedTableName & """, Request.Form") | |||
| file.WriteLine(" ' Flash.Errors = new_" & fixedTableName & "_model.Validator.Errors") | |||
| file.WriteLine(" ' MVC.RedirectToAction ""Create""") | |||
| file.WriteLine(" 'Else") | |||
| file.WriteLine(" " & fixedTableName & "Repository.AddNew new_" & fixedTableName & "_model") | |||
| File.WriteLine(" ' FormCache.ClearForm ""New" & fixedTableName & """") | |||
| File.WriteLine(" Flash.Success = """ & fixedTableName & " added.""") | |||
| File.WriteLine(" MVC.RedirectToAction ""Index""") | |||
| File.WriteLine(" 'End If") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub Delete") | |||
| file.WriteLine(" dim id : id = Request.QueryString(""Id"")") | |||
| file.WriteLine(" set Model = new Delete_ViewModel_Class") | |||
| file.WriteLine(" set Model." & fixedTableName & " = " & fixedTableName & "Repository.FindBy" & PrimaryKeyDictionary(tableName) & "(id)") | |||
| file.WriteLine(" Model.Title = ""Delete " & fixedTableName & """") | |||
| file.WriteLine("") | |||
| file.WriteLine(" HTMLSecurity.SetAntiCSRFToken """ & fixedTableName & "DeleteForm""") | |||
| file.WriteLine("") | |||
| file.WriteLine(" %> <!--#include file=""../../Views/" & fixedTableName & "/Delete.asp""--> <%") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Public Sub DeletePost") | |||
| file.WriteLine(" MVC.RequirePost") | |||
| file.WriteLine(" HtmlSecurity.OnInvalidAntiCSRFTokenRedirectToAction """ & fixedTableName & "DeleteForm"", Request.Form(""nonce""), ""Create""") | |||
| file.WriteLine("") | |||
| file.WriteLine(" dim id : id = Request.Form(""Id"")") | |||
| file.WriteLine(" " & fixedTableName & "Repository.Delete id") | |||
| file.WriteLine("") | |||
| file.WriteLine(" Flash.Success = """ & fixedTableName & " deleted.""") | |||
| file.WriteLine(" MVC.RedirectToAction ""Index""") | |||
| file.WriteLine(" End Sub") | |||
| file.WriteLine("") | |||
| file.WriteLine("End Class") | |||
| file.WriteLine("MVC.Dispatch") | |||
| file.WriteLine("%>") | |||
| file.Close | |||
| Set file = fso.CreateTextFile(ScriptDirectory()& "Views\" & fixedTableName & "\edit.asp",True) | |||
| file.WriteLine("<h2><%= H(Model.Title) %></h2>") | |||
| file.WriteLine("<%= HTML.FormTag("""& tableName & """, ""EditPost"", empty, empty) %>") | |||
| file.WriteLine(" <%= HTML.Hidden(""nonce"", HTMLSecurity.GetAntiCSRFToken(""" & fixedTableName & "EditForm"")) %>") | |||
| file.WriteLine(" <%= HTML.Hidden(""Id"", Model." & fixedTableName & "." & PrimaryKeyDictionary(tableName) & ") %>") | |||
| For Each field In fieldNamesArray | |||
| If Not field = PrimaryKeyDictionary(tableName) then | |||
| file.WriteLine(" <div class=""row"">") | |||
| file.WriteLine(" <div class=""col-md-4"">") | |||
| file.WriteLine(" <div class=""form-group"">") | |||
| file.WriteLine(" <label for=""" & field & """>" & field & "</label>") | |||
| file.WriteLine(" <%= HTML.TextboxExt(""" & field & """, Model." & fixedTableName & "." & field & ", Array(""class"", ""form-control"")) %>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" </div>") | |||
| End if | |||
| Next | |||
| file.WriteLine("<hr />") | |||
| file.WriteLine("<div class=""form-group"">") | |||
| file.WriteLine(" <% = HTML.Button(""submit"", ""<i class='glyphicon glyphicon-ok'></i> Save"", ""btn-primary"") %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='glyphicon glyphicon-remove'></i> Delete"", """ & fixedTableName & """, ""Delete"", Array(""id"", Model." & fixedTableName & "." & PrimaryKeyDictionary(tableName) & "), Array(""class"", ""btn btn-danger"")) %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""Cancel"", """ & fixedTableName & """, ""Index"", empty, Array(""class"", ""btn btn-default"")) %>") | |||
| file.WriteLine("</div>") | |||
| file.WriteLine("</form>") | |||
| file.Close | |||
| Set file = fso.CreateTextFile(ScriptDirectory()& "Views\" & fixedTableName & "\index.asp",True) | |||
| file.WriteLine("<h2><%= H(Model.Title) %></h2>") | |||
| file.WriteLine("<div class=""row"">") | |||
| file.WriteLine(" <div class=""col-md-8 col-sm-8 col-xs-12"">") | |||
| file.WriteLine(" <%= H(Model.RecordCount) %> " & tableName & " found. Showing <%= H(Model.PageSize) %> records per page.") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='bi bi-plus-square-fill'></i> New"",""" & fixedTableName & """, ""Create"", empty, Array(""class"", ""btn btn-xs btn-primary"")) %>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" <div class=""col-md-4 col-sm-4 col-xs-12"">") | |||
| file.WriteLine("") | |||
| file.WriteLine(" <%= HTML.FormTag(""" & fixedTableName & """, ""Search"", empty, empty) %>") | |||
| file.WriteLine("") | |||
| file.WriteLine(" <div class=""col-md-10 col-sm-10 col-xs-12"">") | |||
| file.WriteLine(" <label class=""sr-only"" for=""search"">Search</label>") | |||
| file.WriteLine(" <div class=""input-group"">") | |||
| file.WriteLine(" <input type=""text"" class=""form-control input-search"" value='<%= Choice(Request.Form.Count = 0,Request.QueryString(""q""),Request.Form(""q"")) %>' name=""q"" id=""search"" placeholder=""Search"">") | |||
| file.WriteLine(" <span class=""input-group-addon group-icon""><span class=""glyphicon glyphicon-eye-open""></span>") | |||
| file.WriteLine(" <button type=""submit"" class=""btn btn-success""><i class=""bi bi-search""></i>Search</buttton>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine("") | |||
| file.WriteLine(" </form>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine("</div>") | |||
| file.WriteLine("<table id=""" & fixedTableName & """ class=""table table-striped"">") | |||
| file.WriteLine(" <thead>") | |||
| file.WriteLine(" <tr>") | |||
| file.WriteLine(" <th></th>") | |||
| For Each field In fieldNamesArray | |||
| file.WriteLine(" <th style=""text-align: left"">" & field & "</th>") | |||
| Next | |||
| file.WriteLine(" <th></th>") | |||
| file.WriteLine(" </tr>") | |||
| file.WriteLine(" </thead>") | |||
| file.WriteLine("<tbody>") | |||
| file.WriteLine(" <% dim it : set it = Model." & fixedTableName & ".Iterator %>") | |||
| file.WriteLine(" <% dim " & fixedTableName & " %>") | |||
| file.WriteLine(" <% While it.HasNext %>") | |||
| file.WriteLine(" <% set " & fixedTableName & " = it.GetNext() %>") | |||
| file.WriteLine(" <tr>") | |||
| file.WriteLine(" <td>") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='bi bi-search'></i>"", """& fixedTableName &""", ""Edit"", Array(""Id"", " & fixedTableName & "." & PrimaryKeyDictionary(tableName) & "), Array(""class"", ""btn btn-primary"")) %>") | |||
| file.WriteLine(" </td>") | |||
| For Each field In fieldNamesArray | |||
| file.WriteLine(" <td><% = H(" & fixedTableName & "." & field &") %></td>") | |||
| Next | |||
| file.WriteLine("</tr>") | |||
| file.WriteLine(" <% Wend %>") | |||
| file.WriteLine(" </tbody>") | |||
| file.WriteLine("</table>") | |||
| file.WriteLine(" <div>") | |||
| file.WriteLine(" <% If Model.CurrentPageNumber <> 1 then %>") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i>"", MVC.ControllerName, MVC.ActionName, Array(""page_num"", 1,""q"", Choice(Request.Form.Count = 0,Request.QueryString(""q""),Request.Form(""q""))), Array(""class"", ""btn btn-default"")) %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='bi bi-chevron-left'></i>"", MVC.ControllerName, MVC.ActionName, Array(""page_num"", Model.CurrentPageNumber - 1,""q"", Choice(Request.Form.Count = 0,Request.QueryString(""q""),Request.Form(""q""))), Array(""class"", ""btn btn-default"")) %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <% Else %>") | |||
| file.WriteLine(" <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i></a>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i></a>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <% End If %>") | |||
| file.WriteLine(" <% If CInt(Model.CurrentPageNumber) < CInt(Model.PageCount) then %>") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='bi bi-chevron-right'></i>"", MVC.ControllerName, MVC.ActionName, Array(""page_num"", Model.CurrentPageNumber + 1,""q"", Choice(Request.Form.Count = 0,Request.QueryString(""q""),Request.Form(""q""))), Array(""class"", ""btn btn-default"")) %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i>"", MVC.ControllerName, MVC.ActionName, Array(""page_num"", Model.PageCount,""q"", Choice(Request.Form.Count = 0,Request.QueryString(""q""),Request.Form(""q""))), Array(""class"", ""btn btn-default"")) %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <% Else %>") | |||
| file.WriteLine(" <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i></a>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i></a>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine("<% End If %>") | |||
| file.WriteLine("</div>") | |||
| file.WriteLine("</div>") | |||
| file.Close | |||
| Set file = fso.CreateTextFile(ScriptDirectory()& "Views\" & fixedTableName & "\create.asp",True) | |||
| file.WriteLine("<h2>Create " & fixedTableName &"</h2>") | |||
| file.WriteLine("") | |||
| file.WriteLine("<%= HTML.FormTag(""" & fixedTableName &""", ""CreatePost"", empty, empty) %>") | |||
| file.WriteLine("<%= HTML.Hidden(""nonce"", HTMLSecurity.GetAntiCSRFToken("""& fixedTableName & "CreateForm"")) %>") | |||
| file.WriteLine("<hr />") | |||
| file.WriteLine("") | |||
| file.WriteLine("<div class=""form-group"">") | |||
| For Each field In fieldNamesArray | |||
| If Not field = PrimaryKeyDictionary(tableName) then | |||
| file.WriteLine(" <div class=""row"">") | |||
| file.WriteLine(" <div class=""col-md-4"">") | |||
| file.WriteLine(" <div class=""form-group"">") | |||
| file.WriteLine(" <label for=""" & field & """>" & field & "</label>") | |||
| file.WriteLine(" <%= HTML.TextboxExt(""" & field & """, Model." & field & ", Array(""class"", ""form-control"")) %>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" </div>") | |||
| End if | |||
| Next | |||
| file.WriteLine(" <%= HTML.Button(""submit"", ""<i class='glyphicon glyphicon-ok'></i> Create"", ""btn-primary"") %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""<i class='glyphicon glyphicon-remove'></i> Cancel"", """ & fixedTableName & """, ""Index"", empty, Array(""class"", ""btn btn-default"")) %>") | |||
| file.WriteLine("</div>") | |||
| file.WriteLine("") | |||
| file.WriteLine("</form>") | |||
| file.Close | |||
| Set file = fso.CreateTextFile(ScriptDirectory()& "Views\" & fixedTableName & "\delete.asp",True) | |||
| file.WriteLine("<h2><%= H(Model.Title) %></h2>") | |||
| file.WriteLine("") | |||
| file.WriteLine("<p class=""alert alert-danger"">Are you sure you want to delete this " & fixedTableName & "?</p>") | |||
| file.WriteLine("") | |||
| file.WriteLine("<%= HTML.FormTag(""" & fixedTableName & """, ""DeletePost"", empty, Array(""class"", ""form-horizontal"")) %>") | |||
| file.WriteLine("<%= HTML.Hidden(""nonce"", HTMLSecurity.GetAntiCSRFToken(""" & fixedTableName & "DeleteForm"")) %>") | |||
| file.WriteLine("<%= HTML.Hidden(""Id"", Model." & fixedTableName & "." & PrimaryKeyDictionary(tableName) & ") %>") | |||
| file.WriteLine("<div class=""col-md-10"">") | |||
| file.WriteLine("<div class=""form-group"">") | |||
| file.WriteLine(" <%= HTML.Button(""submit"", ""<i class='glyphicon glyphicon-remove'></i> Confirm Delete"", ""btn-danger"") %>") | |||
| file.WriteLine(" ") | |||
| file.WriteLine(" <%= HTML.LinkToExt(""Cancel"", """ & fixedTableName & """, ""Index"", empty, Array(""class"", ""btn btn-success"")) %>") | |||
| For Each field In fieldNamesArray | |||
| If Not field = PrimaryKeyDictionary(tableName) Then | |||
| file.WriteLine(" <div class=""row"">") | |||
| file.WriteLine(" <div class=""col-md-4"">") | |||
| file.WriteLine(" <div class=""form-group"">") | |||
| file.WriteLine(" <label for=""" & field & """>" & field & "</label>") | |||
| file.WriteLine(" <%= HTML.TextboxExt(""" & field & """, Model." & fixedTableName & "." & field & ", Array(""class"", ""form-control"")) %>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine(" </div>") | |||
| End If | |||
| Next | |||
| file.WriteLine(" </div>") | |||
| file.WriteLine("</div>") | |||
| file.WriteLine("</form>") | |||
| file.Close | |||
| Set objFile = fso.OpenTextFile(ScriptDirectory() & "Views\Shared\layout.header.asp",1) | |||
| headerHtml = objFile.ReadAll() | |||
| objFile.Close | |||
| dropDownLinks = "<li role=""presentation"" class=""dropdown"">" &_ | |||
| " <a class=""dropdown-toggle"" data-toggle=""dropdown"" href=""#"" role=""button"" aria-haspopup=""true"" aria-expanded=""false"">" &_ | |||
| " Dropdown <span class=""caret""></span></a>" &_ | |||
| "" | |||
| If InStr(headerHtml,"<li class=""nav-item""><%= Html.LinkTOExt(""" & tableName & """,""" & fixedTableName & """,""Index"",empty,Array(""Class"",""nav-link"")) %></li>") = 0 then | |||
| newHeaderHtml = Replace(headerHtml,"<!--nav bar placeholder-->"," <li class=""nav-item""><%= Html.LinkTOExt(""" & tableName & """,""" & fixedTableName & """,""Index"",empty,Array(""Class"",""nav-link"")) %></li>" & vbCrLf & "<!--nav bar placeholder-->") | |||
| Set objFile = fso.OpenTextFile(ScriptDirectory() & "Views\Shared\layout.header.asp",2) | |||
| objFile.WriteLine newHeaderHtml | |||
| End If | |||
| objFile.Close | |||
| props.Clear | |||
| rs.MoveNext | |||
| Else | |||
| rs.MoveNext | |||
| End if | |||
| Loop | |||
| includedFile.Close | |||
| WScript.Quit | |||
| Sub includeFile(fSpec) | |||
| executeGlobal CreateObject("Scripting.FileSystemObject").openTextFile(IncludeDirectory & fSpec & ".vbs").readAll() | |||
| End Sub | |||
| Function PrimaryKeysFromADOConnectionToDictionary(ADOConn) | |||
| Dim rstSchema | |||
| Dim returnDictionary | |||
| If TypeName(ADOConn) = "Connection" Then | |||
| Set rstSchema = oConn.OpenSchema(adSchemaPrimaryKeys) | |||
| Set rstableNames = oConn.OpenSchema(20,Array(Empty, Empty, Empty, "Table")) | |||
| Set returnDictionary = WScript.CreateObject("scripting.dictionary") | |||
| While Not rstSchema.EOF | |||
| If returnDictionary.Exists(rstSchema.Fields("TABLE_NAME").Value) = false Then | |||
| returnDictionary.Add rstSchema.Fields("TABLE_NAME").Value,rstSchema.Fields("COLUMN_NAME").Value | |||
| End If | |||
| rstSchema.MoveNext | |||
| Wend | |||
| rstSchema.Close | |||
| End If | |||
| Set PrimaryKeysFromADOConnectionToDictionary = returnDictionary | |||
| End Function | |||
| Sub Init | |||
| MsgBox(oConn.State) | |||
| If oConn.State = 0 Then | |||
| oConn.Open() | |||
| 'End If | |||
| Set PrimaryKeyDictionary = PrimaryKeysFromADOConnectionToDictionary(oConn) | |||
| If Not fso.FolderExists(ScriptDirectory()& "DomainModels\") Then fso.CreateFolder(ScriptDirectory()& "DomainModels\") | |||
| If Not fso.FolderExists(ScriptDirectory()& "ViewModels\") Then fso.CreateFolder(ScriptDirectory()& "ViewModels\") | |||
| If Not fso.FolderExists(ScriptDirectory()& "Controllers\") Then fso.CreateFolder(ScriptDirectory()& "Controllers\") | |||
| If Not fso.FolderExists(ScriptDirectory()& "Views\") Then fso.CreateFolder(ScriptDirectory()& "Views\") | |||
| Set includedFile = fso.CreateTextFile(ScriptDirectory()& "include_all.asp",True) | |||
| includedFile.WriteLine("<!--#include file=""../MVC/lib.all.asp""-->") | |||
| includedFile.WriteLine("<!--#include file=""DAL/lib.DAL.asp""-->") | |||
| includedFile.WriteLine("<!--#include file=""app.Config.asp""-->") | |||
| Set rs = oConn.OpenSchema(20,Array(Empty, Empty, Empty, "Table")) | |||
| End If | |||
| End Sub | |||
| Sub InitFieldNameIterator | |||
| Dim cmd | |||
| Set cmd = WScript.CreateObject("ADODB.COMMAND") | |||
| cmd.ActiveConnection = oConn | |||
| cmd.CommandText = "Select * From [" & tableName & "]" | |||
| Set FieldsRs = cmd.Execute() | |||
| Set fields = FieldsRs.Fields | |||
| Set props = New Stack | |||
| For Each Field In FieldsRs.Fields | |||
| props.Push(Field.Name) | |||
| file.WriteLine (" Public " & Field.Name & " '" & Field.Attributes) | |||
| Next | |||
| FieldsRs.Close | |||
| If Not PrimaryKeyDictionary.Exists(tableName) Then | |||
| PrimaryKeyDictionary.Add tableName,props.ToArray()(0) | |||
| End If | |||
| End Sub | |||
| @@ -0,0 +1,44 @@ | |||
| <% | |||
| Class PagedIndex_ViewModel_Class | |||
| Public Title | |||
| Public Contacts | |||
| Public CurrentPageNumber | |||
| Public PageSize | |||
| Public PageCount | |||
| Public RecordCount | |||
| End Class | |||
| Class Edit_ViewModel_Class | |||
| Public Title | |||
| Public Contacts | |||
| End Class | |||
| Class Create_ViewModel_Class | |||
| Public JURISCODE | |||
| Public TownshipName | |||
| Public CONTACT_NAME | |||
| Public TownshipNum | |||
| Public BUSINESS_ADDRESS | |||
| Public TITLE | |||
| Public BUSINESS_ADDRESS2 | |||
| Public BUSINESS_ADDRESS3 | |||
| Public MAILING_ADDRESS | |||
| Public MAILING_ADDRESS2 | |||
| Public MAILING_ADDRESS3 | |||
| Public RESIDENTIAL_ADDRESS | |||
| Public RESIDENTIAL_ADDRESS2 | |||
| Public PHONENUM1 | |||
| Public RESIDENTIAL_ADDRESS3 | |||
| Public FAXNUM | |||
| Public PHONENUM2 | |||
| Public EMAIL | |||
| End Class | |||
| Class Delete_ViewModel_Class | |||
| Public Title | |||
| Public Contacts | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,32 @@ | |||
| <% | |||
| Class PagedIndex_ViewModel_Class | |||
| Public Title | |||
| Public Jurisdiction | |||
| Public CurrentPageNumber | |||
| Public PageSize | |||
| Public PageCount | |||
| Public RecordCount | |||
| End Class | |||
| Class Edit_ViewModel_Class | |||
| Public Title | |||
| Public Jurisdiction | |||
| Public Contacts | |||
| End Class | |||
| Class Create_ViewModel_Class | |||
| Public Name | |||
| Public Mailing_Address | |||
| Public CSZ | |||
| Public IMB | |||
| Public IMB_Digits | |||
| End Class | |||
| Class Delete_ViewModel_Class | |||
| Public Title | |||
| Public Jurisdiction | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,33 @@ | |||
| <% | |||
| Class PagedIndex_ViewModel_Class | |||
| Public Title | |||
| Public KitLabels | |||
| Public CurrentPageNumber | |||
| Public PageSize | |||
| Public PageCount | |||
| Public RecordCount | |||
| End Class | |||
| Class Edit_ViewModel_Class | |||
| Public Title | |||
| Public KitLabels | |||
| End Class | |||
| Class Create_ViewModel_Class | |||
| Public KitId | |||
| Public OutboundSerial | |||
| Public InBoundSerial | |||
| Public OutboundIMB | |||
| Public InBoundIMB | |||
| Public OutboundIMBDigits | |||
| Public InBoundIMBDigits | |||
| End Class | |||
| Class Delete_ViewModel_Class | |||
| Public Title | |||
| Public KitLabels | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,31 @@ | |||
| <% | |||
| Class PagedIndex_ViewModel_Class | |||
| Public Title | |||
| Public Kit | |||
| Public CurrentPageNumber | |||
| Public PageSize | |||
| Public PageCount | |||
| Public RecordCount | |||
| End Class | |||
| Class Edit_ViewModel_Class | |||
| Public Title | |||
| Public Kit | |||
| End Class | |||
| Class Create_ViewModel_Class | |||
| Public Title | |||
| Public JobNumber | |||
| Public Jcode | |||
| Public Amount | |||
| Public Jurisdiction | |||
| End Class | |||
| Class Delete_ViewModel_Class | |||
| Public Title | |||
| Public Kit | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,28 @@ | |||
| <% | |||
| Class PagedIndex_ViewModel_Class | |||
| Public Title | |||
| Public Settings | |||
| Public CurrentPageNumber | |||
| Public PageSize | |||
| Public PageCount | |||
| Public RecordCount | |||
| End Class | |||
| Class Edit_ViewModel_Class | |||
| Public Title | |||
| Public Settings | |||
| End Class | |||
| Class Create_ViewModel_Class | |||
| Public Name | |||
| Public Value | |||
| End Class | |||
| Class Delete_ViewModel_Class | |||
| Public Title | |||
| Public Settings | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,157 @@ | |||
| <h2>Create Contacts</h2> | |||
| <%= HTML.FormTag("Contacts", "CreatePost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("ContactsCreateForm")) %> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="JURISCODE">JURISCODE</label> | |||
| <%= HTML.TextboxExt("JURISCODE", Model.JURISCODE, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TownshipName">TownshipName</label> | |||
| <%= HTML.TextboxExt("TownshipName", Model.TownshipName, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="CONTACT_NAME">CONTACT_NAME</label> | |||
| <%= HTML.TextboxExt("CONTACT_NAME", Model.CONTACT_NAME, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TownshipNum">TownshipNum</label> | |||
| <%= HTML.TextboxExt("TownshipNum", Model.TownshipNum, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS">BUSINESS_ADDRESS</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS", Model.BUSINESS_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TITLE">TITLE</label> | |||
| <%= HTML.TextboxExt("TITLE", Model.TITLE, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS2">BUSINESS_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS2", Model.BUSINESS_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS3">BUSINESS_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS3", Model.BUSINESS_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS">MAILING_ADDRESS</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS", Model.MAILING_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS2">MAILING_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS2", Model.MAILING_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS3">MAILING_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS3", Model.MAILING_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS">RESIDENTIAL_ADDRESS</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS", Model.RESIDENTIAL_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS2">RESIDENTIAL_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS2", Model.RESIDENTIAL_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="PHONENUM1">PHONENUM1</label> | |||
| <%= HTML.TextboxExt("PHONENUM1", Model.PHONENUM1, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS3">RESIDENTIAL_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS3", Model.RESIDENTIAL_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="FAXNUM">FAXNUM</label> | |||
| <%= HTML.TextboxExt("FAXNUM", Model.FAXNUM, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="PHONENUM2">PHONENUM2</label> | |||
| <%= HTML.TextboxExt("PHONENUM2", Model.PHONENUM2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="EMAIL">EMAIL</label> | |||
| <%= HTML.TextboxExt("EMAIL", Model.EMAIL, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Create", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Cancel", "Contacts", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,159 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <p class="alert alert-danger">Are you sure you want to delete this Contacts?</p> | |||
| <%= HTML.FormTag("Contacts", "DeletePost", empty, Array("class", "form-horizontal")) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("ContactsDeleteForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Contacts.ID) %> | |||
| <div class="col-md-10"> | |||
| <div class="form-group"> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-remove'></i> Confirm Delete", "btn-danger") %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Contacts", "Index", empty, Array("class", "btn btn-success")) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="JURISCODE">JURISCODE</label> | |||
| <%= HTML.TextboxExt("JURISCODE", Model.Contacts.JURISCODE, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TownshipName">TownshipName</label> | |||
| <%= HTML.TextboxExt("TownshipName", Model.Contacts.TownshipName, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="CONTACT_NAME">CONTACT_NAME</label> | |||
| <%= HTML.TextboxExt("CONTACT_NAME", Model.Contacts.CONTACT_NAME, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TownshipNum">TownshipNum</label> | |||
| <%= HTML.TextboxExt("TownshipNum", Model.Contacts.TownshipNum, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS">BUSINESS_ADDRESS</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS", Model.Contacts.BUSINESS_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TITLE">TITLE</label> | |||
| <%= HTML.TextboxExt("TITLE", Model.Contacts.TITLE, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS2">BUSINESS_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS2", Model.Contacts.BUSINESS_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS3">BUSINESS_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS3", Model.Contacts.BUSINESS_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS">MAILING_ADDRESS</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS", Model.Contacts.MAILING_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS2">MAILING_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS2", Model.Contacts.MAILING_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS3">MAILING_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS3", Model.Contacts.MAILING_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS">RESIDENTIAL_ADDRESS</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS", Model.Contacts.RESIDENTIAL_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS2">RESIDENTIAL_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS2", Model.Contacts.RESIDENTIAL_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="PHONENUM1">PHONENUM1</label> | |||
| <%= HTML.TextboxExt("PHONENUM1", Model.Contacts.PHONENUM1, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS3">RESIDENTIAL_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS3", Model.Contacts.RESIDENTIAL_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="FAXNUM">FAXNUM</label> | |||
| <%= HTML.TextboxExt("FAXNUM", Model.Contacts.FAXNUM, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="PHONENUM2">PHONENUM2</label> | |||
| <%= HTML.TextboxExt("PHONENUM2", Model.Contacts.PHONENUM2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="EMAIL">EMAIL</label> | |||
| <%= HTML.TextboxExt("EMAIL", Model.Contacts.EMAIL, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,157 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <%= HTML.FormTag("Contacts", "EditPost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("ContactsEditForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Contacts.ID) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="JURISCODE">JURISCODE</label> | |||
| <%= HTML.TextboxExt("JURISCODE", Model.Contacts.JURISCODE, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TownshipName">TownshipName</label> | |||
| <%= HTML.TextboxExt("TownshipName", Model.Contacts.TownshipName, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="CONTACT_NAME">CONTACT_NAME</label> | |||
| <%= HTML.TextboxExt("CONTACT_NAME", Model.Contacts.CONTACT_NAME, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TownshipNum">TownshipNum</label> | |||
| <%= HTML.TextboxExt("TownshipNum", Model.Contacts.TownshipNum, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS">BUSINESS_ADDRESS</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS", Model.Contacts.BUSINESS_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="TITLE">TITLE</label> | |||
| <%= HTML.TextboxExt("TITLE", Model.Contacts.TITLE, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS2">BUSINESS_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS2", Model.Contacts.BUSINESS_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="BUSINESS_ADDRESS3">BUSINESS_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("BUSINESS_ADDRESS3", Model.Contacts.BUSINESS_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS">MAILING_ADDRESS</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS", Model.Contacts.MAILING_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS2">MAILING_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS2", Model.Contacts.MAILING_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="MAILING_ADDRESS3">MAILING_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("MAILING_ADDRESS3", Model.Contacts.MAILING_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS">RESIDENTIAL_ADDRESS</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS", Model.Contacts.RESIDENTIAL_ADDRESS, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS2">RESIDENTIAL_ADDRESS2</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS2", Model.Contacts.RESIDENTIAL_ADDRESS2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="PHONENUM1">PHONENUM1</label> | |||
| <%= HTML.TextboxExt("PHONENUM1", Model.Contacts.PHONENUM1, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="RESIDENTIAL_ADDRESS3">RESIDENTIAL_ADDRESS3</label> | |||
| <%= HTML.TextboxExt("RESIDENTIAL_ADDRESS3", Model.Contacts.RESIDENTIAL_ADDRESS3, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="FAXNUM">FAXNUM</label> | |||
| <%= HTML.TextboxExt("FAXNUM", Model.Contacts.FAXNUM, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="PHONENUM2">PHONENUM2</label> | |||
| <%= HTML.TextboxExt("PHONENUM2", Model.Contacts.PHONENUM2, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="EMAIL">EMAIL</label> | |||
| <%= HTML.TextboxExt("EMAIL", Model.Contacts.EMAIL, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <% = HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Save", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Delete", "Contacts", "Delete", Array("id", Model.Contacts.ID), Array("class", "btn btn-danger")) %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Contacts", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,105 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <div class="row"> | |||
| <div class="col-md-8 col-sm-8 col-xs-12"> | |||
| <%= H(Model.RecordCount) %> Contacts found. Showing <%= H(Model.PageSize) %> records per page. | |||
| <%= HTML.LinkToExt("<i class='bi bi-plus-square-fill'></i> New","Contacts", "Create", empty, Array("class", "btn btn-xs btn-primary")) %> | |||
| </div> | |||
| <div class="col-md-4 col-sm-4 col-xs-12"> | |||
| <%= HTML.FormTag("Contacts", "Search", empty, empty) %> | |||
| <div class="col-md-10 col-sm-10 col-xs-12"> | |||
| <label class="sr-only" for="search">Search</label> | |||
| <div class="input-group"> | |||
| <input type="text" class="form-control input-search" value='<%= Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) %>' name="q" id="search" placeholder="Search"> | |||
| <span class="input-group-addon group-icon"><span class="glyphicon glyphicon-eye-open"></span> | |||
| <button type="submit" class="btn btn-success"><i class="bi bi-search"></i>Search</buttton> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <table id="Contacts" class="table table-striped"> | |||
| <thead> | |||
| <tr> | |||
| <th></th> | |||
| <th style="text-align: left">ID</th> | |||
| <th style="text-align: left">JURISCODE</th> | |||
| <th style="text-align: left">TownshipName</th> | |||
| <th style="text-align: left">CONTACT_NAME</th> | |||
| <th style="text-align: left">TownshipNum</th> | |||
| <th style="text-align: left">BUSINESS_ADDRESS</th> | |||
| <th style="text-align: left">TITLE</th> | |||
| <th style="text-align: left">BUSINESS_ADDRESS2</th> | |||
| <th style="text-align: left">BUSINESS_ADDRESS3</th> | |||
| <th style="text-align: left">MAILING_ADDRESS</th> | |||
| <th style="text-align: left">MAILING_ADDRESS2</th> | |||
| <th style="text-align: left">MAILING_ADDRESS3</th> | |||
| <th style="text-align: left">RESIDENTIAL_ADDRESS</th> | |||
| <th style="text-align: left">RESIDENTIAL_ADDRESS2</th> | |||
| <th style="text-align: left">PHONENUM1</th> | |||
| <th style="text-align: left">RESIDENTIAL_ADDRESS3</th> | |||
| <th style="text-align: left">FAXNUM</th> | |||
| <th style="text-align: left">PHONENUM2</th> | |||
| <th style="text-align: left">EMAIL</th> | |||
| <th></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <% dim it : set it = Model.Contacts.Iterator %> | |||
| <% dim Contacts %> | |||
| <% While it.HasNext %> | |||
| <% set Contacts = it.GetNext() %> | |||
| <tr> | |||
| <td> | |||
| <%= HTML.LinkToExt("<i class='bi bi-search'></i>", "Contacts", "Edit", Array("Id", Contacts.ID), Array("class", "btn btn-primary")) %> | |||
| </td> | |||
| <td><% = H(Contacts.ID) %></td> | |||
| <td><% = H(Contacts.JURISCODE) %></td> | |||
| <td><% = H(Contacts.TownshipName) %></td> | |||
| <td><% = H(Contacts.CONTACT_NAME) %></td> | |||
| <td><% = H(Contacts.TownshipNum) %></td> | |||
| <td><% = H(Contacts.BUSINESS_ADDRESS) %></td> | |||
| <td><% = H(Contacts.TITLE) %></td> | |||
| <td><% = H(Contacts.BUSINESS_ADDRESS2) %></td> | |||
| <td><% = H(Contacts.BUSINESS_ADDRESS3) %></td> | |||
| <td><% = H(Contacts.MAILING_ADDRESS) %></td> | |||
| <td><% = H(Contacts.MAILING_ADDRESS2) %></td> | |||
| <td><% = H(Contacts.MAILING_ADDRESS3) %></td> | |||
| <td><% = H(Contacts.RESIDENTIAL_ADDRESS) %></td> | |||
| <td><% = H(Contacts.RESIDENTIAL_ADDRESS2) %></td> | |||
| <td><% = H(Contacts.PHONENUM1) %></td> | |||
| <td><% = H(Contacts.RESIDENTIAL_ADDRESS3) %></td> | |||
| <td><% = H(Contacts.FAXNUM) %></td> | |||
| <td><% = H(Contacts.PHONENUM2) %></td> | |||
| <td><% = H(Contacts.EMAIL) %></td> | |||
| </tr> | |||
| <% Wend %> | |||
| </tbody> | |||
| </table> | |||
| <div> | |||
| <% If Model.CurrentPageNumber <> 1 then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber - 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <% End If %> | |||
| <% If CInt(Model.CurrentPageNumber) < CInt(Model.PageCount) then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber + 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.PageCount,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <% End If %> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,10 @@ | |||
| | |||
| <h1><%= siteTitle %></h1> | |||
| <div class="row"> | |||
| <div class="col-md-4" style="background-color: #eee;"> | |||
| Left Column | |||
| </div> | |||
| <div class="col-md-8"> | |||
| Right Column | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,53 @@ | |||
| <h2>Create Jurisdiction</h2> | |||
| <%= HTML.FormTag("Jurisdiction", "CreatePost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("JurisdictionCreateForm")) %> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Name">Name</label> | |||
| <%= HTML.TextboxExt("Name", Model.Name, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Mailing_Address">Mailing_Address</label> | |||
| <%= HTML.TextboxExt("Mailing_Address", Model.Mailing_Address, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="CSZ">CSZ</label> | |||
| <%= HTML.TextboxExt("CSZ", Model.CSZ, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="IMB">IMB</label> | |||
| <%= HTML.TextboxExt("IMB", Model.IMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="IMB_Digits">IMB_Digits</label> | |||
| <%= HTML.TextboxExt("IMB_Digits", Model.IMB_Digits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Create", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Cancel", "Jurisdiction", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,5 @@ | |||
| <h2><%= H(Model.Title) %> For <%=H(Model.Jurisdiction.Name) %></h2> | |||
| <%= HTML.FormTag("Jurisdiction", "EditPost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("CreateKitForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Jurisdiction.JCode) %> | |||
| </form> | |||
| @@ -0,0 +1,55 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <p class="alert alert-danger">Are you sure you want to delete this Jurisdiction?</p> | |||
| <%= HTML.FormTag("Jurisdiction", "DeletePost", empty, Array("class", "form-horizontal")) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("JurisdictionDeleteForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Jurisdiction.JCode) %> | |||
| <div class="col-md-10"> | |||
| <div class="form-group"> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-remove'></i> Confirm Delete", "btn-danger") %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Jurisdiction", "Index", empty, Array("class", "btn btn-success")) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Name">Name</label> | |||
| <%= HTML.TextboxExt("Name", Model.Jurisdiction.Name, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Mailing_Address">Mailing_Address</label> | |||
| <%= HTML.TextboxExt("Mailing_Address", Model.Jurisdiction.Mailing_Address, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="CSZ">CSZ</label> | |||
| <%= HTML.TextboxExt("CSZ", Model.Jurisdiction.CSZ, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="IMB">IMB</label> | |||
| <%= HTML.TextboxExt("IMB", Model.Jurisdiction.IMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="IMB_Digits">IMB_Digits</label> | |||
| <%= HTML.TextboxExt("IMB_Digits", Model.Jurisdiction.IMB_Digits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,54 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <%= HTML.FormTag("Jurisdiction", "EditPost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("JurisdictionEditForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Jurisdiction.JCode) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Name">Name</label> | |||
| <%= HTML.TextboxExt("Name", Model.Jurisdiction.Name, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Mailing_Address">Mailing_Address</label> | |||
| <%= HTML.TextboxExt("Mailing_Address", Model.Jurisdiction.Mailing_Address, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="CSZ">CSZ</label> | |||
| <%= HTML.TextboxExt("CSZ", Model.Jurisdiction.CSZ, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="IMB">IMB</label> | |||
| <%= HTML.TextboxExt("IMB", Model.Jurisdiction.IMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="IMB_Digits">IMB_Digits</label> | |||
| <%= HTML.TextboxExt("IMB_Digits", Model.Jurisdiction.IMB_Digits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <!--#include file="../../Views/Jurisdiction/partial.Jurisdiction.Contacts.asp"--> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <% = HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Save", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Delete", "Jurisdiction", "Delete", Array("id", Model.Jurisdiction.JCode), Array("class", "btn btn-danger")) %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Jurisdiction", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,82 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <div class="row"> | |||
| <div class="col-md-8 col-sm-8 col-xs-12"> | |||
| <%= H(Model.RecordCount) %> Jurisdiction found. Showing <%= H(Model.PageSize) %> records per page. | |||
| <%= HTML.LinkToExt("<i class='bi bi-plus-square-fill'></i> New","Jurisdiction", "Create", empty, Array("class", "btn btn-xs btn-primary")) %> | |||
| </div> | |||
| <div class="col-md-4 col-sm-4 col-xs-12"> | |||
| <%= HTML.FormTag("Jurisdiction", "Search", empty, empty) %> | |||
| <div class="col-md-10 col-sm-10 col-xs-12"> | |||
| <label class="sr-only" for="search">Search</label> | |||
| <div class="input-group"> | |||
| <input type="text" class="form-control input-search" value='<%= Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) %>' name="q" id="search" placeholder="Search"> | |||
| <span class="input-group-addon group-icon"><span class="glyphicon glyphicon-eye-open"></span> | |||
| <button type="submit" class="btn btn-success"><i class="bi bi-search"></i>Search</buttton> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <table id="Jurisdiction" class="table table-striped"> | |||
| <thead> | |||
| <tr> | |||
| <th></th> | |||
| <th style="text-align: left">JCode</th> | |||
| <th style="text-align: left">Name</th> | |||
| <th style="text-align: left">Mailing_Address</th> | |||
| <th style="text-align: left">CSZ</th> | |||
| <th style="text-align: left">IMB</th> | |||
| <th style="text-align: left">IMB_Digits</th> | |||
| <th></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <% dim it : set it = Model.Jurisdiction.Iterator %> | |||
| <% dim Jurisdiction %> | |||
| <% While it.HasNext %> | |||
| <% set Jurisdiction = it.GetNext() %> | |||
| <tr> | |||
| <td> | |||
| <%= HTML.LinkToExt("<i class='bi bi-search'></i>", "Jurisdiction", "Edit", Array("Id", Jurisdiction.JCode), Array("class", "btn btn-primary")) %> | |||
| </td> | |||
| <td><% = H(Jurisdiction.JCode) %></td> | |||
| <td><% = H(Jurisdiction.Name) %></td> | |||
| <td><% = H(Jurisdiction.Mailing_Address) %></td> | |||
| <td><% = H(Jurisdiction.CSZ) %></td> | |||
| <td><% = H(Jurisdiction.IMB) %></td> | |||
| <td><% = H(Jurisdiction.IMB_Digits) %></td> | |||
| <td> | |||
| <%= HTML.LinkToExt("<i class='bi bi-search'></i>", "Kit", "create", Array("Id", Jurisdiction.JCode), Array("class", "btn btn-primary")) %> | |||
| </td> | |||
| </tr> | |||
| <% Wend %> | |||
| </tbody> | |||
| </table> | |||
| <div> | |||
| <% If Model.CurrentPageNumber <> 1 then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber - 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <% End If %> | |||
| <% If CInt(Model.CurrentPageNumber) < CInt(Model.PageCount) then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber + 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.PageCount,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <% End If %> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,60 @@ | |||
| </div> | |||
| <table id="Contacts" class="table table-striped"> | |||
| <thead> | |||
| <tr> | |||
| <th></th> | |||
| <th style="text-align: left">ID</th> | |||
| <th style="text-align: left">JURISCODE</th> | |||
| <th style="text-align: left">TownshipName</th> | |||
| <th style="text-align: left">CONTACT_NAME</th> | |||
| <th style="text-align: left">TownshipNum</th> | |||
| <th style="text-align: left">BUSINESS_ADDRESS</th> | |||
| <th style="text-align: left">TITLE</th> | |||
| <th style="text-align: left">BUSINESS_ADDRESS2</th> | |||
| <th style="text-align: left">BUSINESS_ADDRESS3</th> | |||
| <th style="text-align: left">MAILING_ADDRESS</th> | |||
| <th style="text-align: left">MAILING_ADDRESS2</th> | |||
| <th style="text-align: left">MAILING_ADDRESS3</th> | |||
| <th style="text-align: left">RESIDENTIAL_ADDRESS</th> | |||
| <th style="text-align: left">RESIDENTIAL_ADDRESS2</th> | |||
| <th style="text-align: left">PHONENUM1</th> | |||
| <th style="text-align: left">RESIDENTIAL_ADDRESS3</th> | |||
| <th style="text-align: left">FAXNUM</th> | |||
| <th style="text-align: left">PHONENUM2</th> | |||
| <th style="text-align: left">EMAIL</th> | |||
| <th></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <% dim it : set it = Model.Contacts.Iterator %> | |||
| <% dim Contacts %> | |||
| <% While it.HasNext %> | |||
| <% set Contacts = it.GetNext() %> | |||
| <tr> | |||
| <td> | |||
| <%= HTML.LinkToExt("<i class='bi bi-search'></i>", "Contacts", "Edit", Array("Id", Contacts.ID), Array("class", "btn btn-primary")) %> | |||
| </td> | |||
| <td><% = H(Contacts.ID) %></td> | |||
| <td><% = H(Contacts.JURISCODE) %></td> | |||
| <td><% = H(Contacts.TownshipName) %></td> | |||
| <td><% = H(Contacts.CONTACT_NAME) %></td> | |||
| <td><% = H(Contacts.TownshipNum) %></td> | |||
| <td><% = H(Contacts.BUSINESS_ADDRESS) %></td> | |||
| <td><% = H(Contacts.TITLE) %></td> | |||
| <td><% = H(Contacts.BUSINESS_ADDRESS2) %></td> | |||
| <td><% = H(Contacts.BUSINESS_ADDRESS3) %></td> | |||
| <td><% = H(Contacts.MAILING_ADDRESS) %></td> | |||
| <td><% = H(Contacts.MAILING_ADDRESS2) %></td> | |||
| <td><% = H(Contacts.MAILING_ADDRESS3) %></td> | |||
| <td><% = H(Contacts.RESIDENTIAL_ADDRESS) %></td> | |||
| <td><% = H(Contacts.RESIDENTIAL_ADDRESS2) %></td> | |||
| <td><% = H(Contacts.PHONENUM1) %></td> | |||
| <td><% = H(Contacts.RESIDENTIAL_ADDRESS3) %></td> | |||
| <td><% = H(Contacts.FAXNUM) %></td> | |||
| <td><% = H(Contacts.PHONENUM2) %></td> | |||
| <td><% = H(Contacts.EMAIL) %></td> | |||
| </tr> | |||
| <% Wend %> | |||
| </tbody> | |||
| </table> | |||
| <div> | |||
| @@ -0,0 +1,38 @@ | |||
| <h2><%= H(Model.Title) %> For <%=H(Model.Jurisdiction.Name) %></h2> | |||
| <%= HTML.FormTag("Kit", "CreatePost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitCreateForm")) %> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="JobNumber">JobNumber</label> | |||
| <%= HTML.TextboxExt("JobNumber", Model.JobNumber, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Jcode">Jcode</label> | |||
| <%= HTML.TextboxExt("Jcode", Model.Jcode, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Amount">Jcode</label> | |||
| <%= HTML.TextboxExt("Amount", Model.Jcode, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <p></p> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Create", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Cancel", "Kit", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,31 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <p class="alert alert-danger">Are you sure you want to delete this Kit?</p> | |||
| <%= HTML.FormTag("Kit", "DeletePost", empty, Array("class", "form-horizontal")) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitDeleteForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Kit.ID) %> | |||
| <div class="col-md-10"> | |||
| <div class="form-group"> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-remove'></i> Confirm Delete", "btn-danger") %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Kit", "Index", empty, Array("class", "btn btn-success")) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="JobNumber">JobNumber</label> | |||
| <%= HTML.TextboxExt("JobNumber", Model.Kit.JobNumber, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Jcode">Jcode</label> | |||
| <%= HTML.TextboxExt("Jcode", Model.Kit.Jcode, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,29 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <%= HTML.FormTag("Kit", "EditPost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitEditForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Kit.ID) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="JobNumber">JobNumber</label> | |||
| <%= HTML.TextboxExt("JobNumber", Model.Kit.JobNumber, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Jcode">Jcode</label> | |||
| <%= HTML.TextboxExt("Jcode", Model.Kit.Jcode, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <% = HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Save", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Delete", "Kit", "Delete", Array("id", Model.Kit.ID), Array("class", "btn btn-danger")) %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Kit", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,73 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <div class="row"> | |||
| <div class="col-md-8 col-sm-8 col-xs-12"> | |||
| <%= H(Model.RecordCount) %> Kit found. Showing <%= H(Model.PageSize) %> records per page. | |||
| <%= HTML.LinkToExt("<i class='bi bi-plus-square-fill'></i> New","Kit", "Create", empty, Array("class", "btn btn-xs btn-primary")) %> | |||
| </div> | |||
| <div class="col-md-4 col-sm-4 col-xs-12"> | |||
| <%= HTML.FormTag("Kit", "Search", empty, empty) %> | |||
| <div class="col-md-10 col-sm-10 col-xs-12"> | |||
| <label class="sr-only" for="search">Search</label> | |||
| <div class="input-group"> | |||
| <input type="text" class="form-control input-search" value='<%= Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) %>' name="q" id="search" placeholder="Search"> | |||
| <span class="input-group-addon group-icon"><span class="glyphicon glyphicon-eye-open"></span> | |||
| <button type="submit" class="btn btn-success"><i class="bi bi-search"></i>Search</buttton> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <table id="Kit" class="table table-striped"> | |||
| <thead> | |||
| <tr> | |||
| <th></th> | |||
| <th style="text-align: left">ID</th> | |||
| <th style="text-align: left">JobNumber</th> | |||
| <th style="text-align: left">Jcode</th> | |||
| <th></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <% dim it : set it = Model.Kit.Iterator %> | |||
| <% dim Kit %> | |||
| <% While it.HasNext %> | |||
| <% set Kit = it.GetNext() %> | |||
| <tr> | |||
| <td> | |||
| <%= HTML.LinkToExt("<i class='bi bi-search'></i>", "Kit", "Edit", Array("Id", Kit.ID), Array("class", "btn btn-primary")) %> | |||
| </td> | |||
| <td><% = H(Kit.ID) %></td> | |||
| <td><% = H(Kit.JobNumber) %></td> | |||
| <td><% = H(Kit.Jcode) %></td> | |||
| </tr> | |||
| <% Wend %> | |||
| </tbody> | |||
| </table> | |||
| <div> | |||
| <% If Model.CurrentPageNumber <> 1 then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber - 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <% End If %> | |||
| <% If CInt(Model.CurrentPageNumber) < CInt(Model.PageCount) then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber + 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.PageCount,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <% End If %> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,69 @@ | |||
| <h2>Create KitLabels</h2> | |||
| <%= HTML.FormTag("KitLabels", "CreatePost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitLabelsCreateForm")) %> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="KitId">KitId</label> | |||
| <%= HTML.TextboxExt("KitId", Model.KitId, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundSerial">OutboundSerial</label> | |||
| <%= HTML.TextboxExt("OutboundSerial", Model.OutboundSerial, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundSerial">InBoundSerial</label> | |||
| <%= HTML.TextboxExt("InBoundSerial", Model.InBoundSerial, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundIMB">OutboundIMB</label> | |||
| <%= HTML.TextboxExt("OutboundIMB", Model.OutboundIMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundIMB">InBoundIMB</label> | |||
| <%= HTML.TextboxExt("InBoundIMB", Model.InBoundIMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundIMBDigits">OutboundIMBDigits</label> | |||
| <%= HTML.TextboxExt("OutboundIMBDigits", Model.OutboundIMBDigits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundIMBDigits">InBoundIMBDigits</label> | |||
| <%= HTML.TextboxExt("InBoundIMBDigits", Model.InBoundIMBDigits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Create", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Cancel", "KitLabels", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,71 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <p class="alert alert-danger">Are you sure you want to delete this KitLabels?</p> | |||
| <%= HTML.FormTag("KitLabels", "DeletePost", empty, Array("class", "form-horizontal")) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitLabelsDeleteForm")) %> | |||
| <%= HTML.Hidden("Id", Model.KitLabels.ID) %> | |||
| <div class="col-md-10"> | |||
| <div class="form-group"> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-remove'></i> Confirm Delete", "btn-danger") %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "KitLabels", "Index", empty, Array("class", "btn btn-success")) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="KitId">KitId</label> | |||
| <%= HTML.TextboxExt("KitId", Model.KitLabels.KitId, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundSerial">OutboundSerial</label> | |||
| <%= HTML.TextboxExt("OutboundSerial", Model.KitLabels.OutboundSerial, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundSerial">InBoundSerial</label> | |||
| <%= HTML.TextboxExt("InBoundSerial", Model.KitLabels.InBoundSerial, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundIMB">OutboundIMB</label> | |||
| <%= HTML.TextboxExt("OutboundIMB", Model.KitLabels.OutboundIMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundIMB">InBoundIMB</label> | |||
| <%= HTML.TextboxExt("InBoundIMB", Model.KitLabels.InBoundIMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundIMBDigits">OutboundIMBDigits</label> | |||
| <%= HTML.TextboxExt("OutboundIMBDigits", Model.KitLabels.OutboundIMBDigits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundIMBDigits">InBoundIMBDigits</label> | |||
| <%= HTML.TextboxExt("InBoundIMBDigits", Model.KitLabels.InBoundIMBDigits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,69 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <%= HTML.FormTag("KitLabels", "EditPost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("KitLabelsEditForm")) %> | |||
| <%= HTML.Hidden("Id", Model.KitLabels.ID) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="KitId">KitId</label> | |||
| <%= HTML.TextboxExt("KitId", Model.KitLabels.KitId, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundSerial">OutboundSerial</label> | |||
| <%= HTML.TextboxExt("OutboundSerial", Model.KitLabels.OutboundSerial, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundSerial">InBoundSerial</label> | |||
| <%= HTML.TextboxExt("InBoundSerial", Model.KitLabels.InBoundSerial, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundIMB">OutboundIMB</label> | |||
| <%= HTML.TextboxExt("OutboundIMB", Model.KitLabels.OutboundIMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundIMB">InBoundIMB</label> | |||
| <%= HTML.TextboxExt("InBoundIMB", Model.KitLabels.InBoundIMB, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="OutboundIMBDigits">OutboundIMBDigits</label> | |||
| <%= HTML.TextboxExt("OutboundIMBDigits", Model.KitLabels.OutboundIMBDigits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="InBoundIMBDigits">InBoundIMBDigits</label> | |||
| <%= HTML.TextboxExt("InBoundIMBDigits", Model.KitLabels.InBoundIMBDigits, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <% = HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Save", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Delete", "KitLabels", "Delete", Array("id", Model.KitLabels.ID), Array("class", "btn btn-danger")) %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "KitLabels", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,83 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <div class="row"> | |||
| <div class="col-md-8 col-sm-8 col-xs-12"> | |||
| <%= H(Model.RecordCount) %> KitLabels found. Showing <%= H(Model.PageSize) %> records per page. | |||
| <%= HTML.LinkToExt("<i class='bi bi-plus-square-fill'></i> New","KitLabels", "Create", empty, Array("class", "btn btn-xs btn-primary")) %> | |||
| </div> | |||
| <div class="col-md-4 col-sm-4 col-xs-12"> | |||
| <%= HTML.FormTag("KitLabels", "Search", empty, empty) %> | |||
| <div class="col-md-10 col-sm-10 col-xs-12"> | |||
| <label class="sr-only" for="search">Search</label> | |||
| <div class="input-group"> | |||
| <input type="text" class="form-control input-search" value='<%= Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) %>' name="q" id="search" placeholder="Search"> | |||
| <span class="input-group-addon group-icon"><span class="glyphicon glyphicon-eye-open"></span> | |||
| <button type="submit" class="btn btn-success"><i class="bi bi-search"></i>Search</buttton> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <table id="KitLabels" class="table table-striped"> | |||
| <thead> | |||
| <tr> | |||
| <th></th> | |||
| <th style="text-align: left">ID</th> | |||
| <th style="text-align: left">KitId</th> | |||
| <th style="text-align: left">OutboundSerial</th> | |||
| <th style="text-align: left">InBoundSerial</th> | |||
| <th style="text-align: left">OutboundIMB</th> | |||
| <th style="text-align: left">InBoundIMB</th> | |||
| <th style="text-align: left">OutboundIMBDigits</th> | |||
| <th style="text-align: left">InBoundIMBDigits</th> | |||
| <th></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <% dim it : set it = Model.KitLabels.Iterator %> | |||
| <% dim KitLabels %> | |||
| <% While it.HasNext %> | |||
| <% set KitLabels = it.GetNext() %> | |||
| <tr> | |||
| <td> | |||
| <%= HTML.LinkToExt("<i class='bi bi-search'></i>", "KitLabels", "Edit", Array("Id", KitLabels.ID), Array("class", "btn btn-primary")) %> | |||
| </td> | |||
| <td><% = H(KitLabels.ID) %></td> | |||
| <td><% = H(KitLabels.KitId) %></td> | |||
| <td><% = H(KitLabels.OutboundSerial) %></td> | |||
| <td><% = H(KitLabels.InBoundSerial) %></td> | |||
| <td><% = H(KitLabels.OutboundIMB) %></td> | |||
| <td><% = H(KitLabels.InBoundIMB) %></td> | |||
| <td><% = H(KitLabels.OutboundIMBDigits) %></td> | |||
| <td><% = H(KitLabels.InBoundIMBDigits) %></td> | |||
| </tr> | |||
| <% Wend %> | |||
| </tbody> | |||
| </table> | |||
| <div> | |||
| <% If Model.CurrentPageNumber <> 1 then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber - 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <% End If %> | |||
| <% If CInt(Model.CurrentPageNumber) < CInt(Model.PageCount) then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber + 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.PageCount,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <% End If %> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,29 @@ | |||
| <h2>Create Settings</h2> | |||
| <%= HTML.FormTag("Settings", "CreatePost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("SettingsCreateForm")) %> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Name">Name</label> | |||
| <%= HTML.TextboxExt("Name", Model.Name, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Value">Value</label> | |||
| <%= HTML.TextboxExt("Value", Model.Value, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Create", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Cancel", "Settings", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,31 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <p class="alert alert-danger">Are you sure you want to delete this Settings?</p> | |||
| <%= HTML.FormTag("Settings", "DeletePost", empty, Array("class", "form-horizontal")) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("SettingsDeleteForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Settings.ID) %> | |||
| <div class="col-md-10"> | |||
| <div class="form-group"> | |||
| <%= HTML.Button("submit", "<i class='glyphicon glyphicon-remove'></i> Confirm Delete", "btn-danger") %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Settings", "Index", empty, Array("class", "btn btn-success")) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Name">Name</label> | |||
| <%= HTML.TextboxExt("Name", Model.Settings.Name, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Value">Value</label> | |||
| <%= HTML.TextboxExt("Value", Model.Settings.Value, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,29 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <%= HTML.FormTag("Settings", "EditPost", empty, empty) %> | |||
| <%= HTML.Hidden("nonce", HTMLSecurity.GetAntiCSRFToken("SettingsEditForm")) %> | |||
| <%= HTML.Hidden("Id", Model.Settings.ID) %> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Name">Name</label> | |||
| <%= HTML.TextboxExt("Name", Model.Settings.Name, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <div class="row"> | |||
| <div class="col-md-4"> | |||
| <div class="form-group"> | |||
| <label for="Value">Value</label> | |||
| <%= HTML.TextboxExt("Value", Model.Settings.Value, Array("class", "form-control")) %> | |||
| </div> | |||
| </div> | |||
| </div> | |||
| <hr /> | |||
| <div class="form-group"> | |||
| <% = HTML.Button("submit", "<i class='glyphicon glyphicon-ok'></i> Save", "btn-primary") %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='glyphicon glyphicon-remove'></i> Delete", "Settings", "Delete", Array("id", Model.Settings.ID), Array("class", "btn btn-danger")) %> | |||
| | |||
| <%= HTML.LinkToExt("Cancel", "Settings", "Index", empty, Array("class", "btn btn-default")) %> | |||
| </div> | |||
| </form> | |||
| @@ -0,0 +1,73 @@ | |||
| <h2><%= H(Model.Title) %></h2> | |||
| <div class="row"> | |||
| <div class="col-md-8 col-sm-8 col-xs-12"> | |||
| <%= H(Model.RecordCount) %> Settings found. Showing <%= H(Model.PageSize) %> records per page. | |||
| <%= HTML.LinkToExt("<i class='bi bi-plus-square-fill'></i> New","Settings", "Create", empty, Array("class", "btn btn-xs btn-primary")) %> | |||
| </div> | |||
| <div class="col-md-4 col-sm-4 col-xs-12"> | |||
| <%= HTML.FormTag("Settings", "Search", empty, empty) %> | |||
| <div class="col-md-10 col-sm-10 col-xs-12"> | |||
| <label class="sr-only" for="search">Search</label> | |||
| <div class="input-group"> | |||
| <input type="text" class="form-control input-search" value='<%= Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q")) %>' name="q" id="search" placeholder="Search"> | |||
| <span class="input-group-addon group-icon"><span class="glyphicon glyphicon-eye-open"></span> | |||
| <button type="submit" class="btn btn-success"><i class="bi bi-search"></i>Search</buttton> | |||
| </div> | |||
| </div> | |||
| </form> | |||
| </div> | |||
| </div> | |||
| <table id="Settings" class="table table-striped"> | |||
| <thead> | |||
| <tr> | |||
| <th></th> | |||
| <th style="text-align: left">ID</th> | |||
| <th style="text-align: left">Name</th> | |||
| <th style="text-align: left">Value</th> | |||
| <th></th> | |||
| </tr> | |||
| </thead> | |||
| <tbody> | |||
| <% dim it : set it = Model.Settings.Iterator %> | |||
| <% dim Settings %> | |||
| <% While it.HasNext %> | |||
| <% set Settings = it.GetNext() %> | |||
| <tr> | |||
| <td> | |||
| <%= HTML.LinkToExt("<i class='bi bi-search'></i>", "Settings", "Edit", Array("Id", Settings.ID), Array("class", "btn btn-primary")) %> | |||
| </td> | |||
| <td><% = H(Settings.ID) %></td> | |||
| <td><% = H(Settings.Name) %></td> | |||
| <td><% = H(Settings.Value) %></td> | |||
| </tr> | |||
| <% Wend %> | |||
| </tbody> | |||
| </table> | |||
| <div> | |||
| <% If Model.CurrentPageNumber <> 1 then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-left'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber - 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-left'></i></a> | |||
| | |||
| <% End If %> | |||
| <% If CInt(Model.CurrentPageNumber) < CInt(Model.PageCount) then %> | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.CurrentPageNumber + 1,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <%= HTML.LinkToExt("<i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i>", MVC.ControllerName, MVC.ActionName, Array("page_num", Model.PageCount,"q", Choice(Request.Form.Count = 0,Request.QueryString("q"),Request.Form("q"))), Array("class", "btn btn-default")) %> | |||
| | |||
| <% Else %> | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <a class='btn btn-default disabled'><i class='bi bi-chevron-right'></i></a> | |||
| | |||
| <% End If %> | |||
| </div> | |||
| </div> | |||
| @@ -0,0 +1,10 @@ | |||
| </div><!-- /.container --> | |||
| <!-- Bootstrap core JavaScript | |||
| ================================================== --> | |||
| <!-- Placed at the end of the document so the pages load faster --> | |||
| <%= HTML.JSTag(jqueryJs) %> | |||
| <%= HTML.JSTag(appBootStrapJs) %> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,38 @@ | |||
| | |||
| <!DOCTYPE html> | |||
| <html lang="en"> | |||
| <head> | |||
| <meta charset="utf-8"> | |||
| <meta http-equiv="X-UA-Compatible" content="IE=edge"> | |||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |||
| <title><%= siteTitle %></title> | |||
| <!-- Latest compiled and minified CSS --> | |||
| <%= HTML.StylesheetTag(appCss) %> | |||
| <%= HTML.StylesheetTag(iconsCss) %> | |||
| </head> | |||
| <body> | |||
| <ul class="nav"> | |||
| <li class="nav-item"><%= Html.LinkTOExt("Jurisdiction","Jurisdiction","Index",empty,Array("Class","nav-link")) %></li> | |||
| <li class="nav-item"><%= Html.LinkTOExt("Contacts","Contacts","Index",empty,Array("Class","nav-link")) %></li> | |||
| <li class="nav-item"><%= Html.LinkTOExt("Settings","Settings","Index",empty,Array("Class","nav-link")) %></li> | |||
| <li class="nav-item"><%= Html.LinkTOExt("Kit","Kit","Index",empty,Array("Class","nav-link")) %></li> | |||
| <li class="nav-item"><%= Html.LinkTOExt("KitLabels","KitLabels","Index",empty,Array("Class","nav-link")) %></li> | |||
| <!--nav bar placeholder--> | |||
| </ul> | |||
| <div class="container" style="margin-top: 50px"> | |||
| <% | |||
| 'Flash.ShowErrorsIfPresent | |||
| 'Flash.ShowSuccessIfPresent | |||
| %> | |||
| @@ -0,0 +1,14 @@ | |||
| <% | |||
| dim appCss, appJs, appBootStrapJs, jqueryJs, siteTitle, iconsCss | |||
| Routes.Initialize "/App/" | |||
| siteTitle = "Clerks and Jurisdictions" | |||
| iconsCss = "https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" | |||
| appCss = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" | |||
| appBootStrapJs = "https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js' integrity='sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM' crossorigin='anonymous" | |||
| jqueryJs = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js' integrity='sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==' crossorigin='anonymous' referrerpolicy='no-referrer" | |||
| '======================================================================================================================= | |||
| ' Set Global Variables Here | |||
| '======================================================================================================================= | |||
| %> | |||
| @@ -0,0 +1,8 @@ | |||
| <!--#include file="../MVC/lib.all.asp"--> | |||
| <!--#include file="DAL/lib.DAL.asp"--> | |||
| <!--#include file="app.Config.asp"--> | |||
| <!--#include file="DomainModels/ContactsRepository.asp"--> | |||
| <!--#include file="DomainModels/JurisdictionRepository.asp"--> | |||
| <!--#include file="DomainModels/KitRepository.asp"--> | |||
| <!--#include file="DomainModels/KitLabelsRepository.asp"--> | |||
| <!--#include file="DomainModels/SettingsRepository.asp"--> | |||
| @@ -0,0 +1,2 @@ | |||
| create table meta_migrations (version int not null); | |||
| insert into meta_migrations (version) values (0); | |||
| @@ -0,0 +1,15 @@ | |||
| <% | |||
| Class Migration_XX_ | |||
| Public Migration | |||
| Public Sub Up | |||
| Migration.Do "" | |||
| End Sub | |||
| Public Sub Down | |||
| Migration.Do "" | |||
| End Sub | |||
| End Class | |||
| Migrations.Add "Migration_XX_" | |||
| %> | |||
| @@ -0,0 +1,15 @@ | |||
| <% | |||
| Class Example_01_Create_Example_Table | |||
| Public Migration | |||
| Public Sub Up | |||
| Migration.Do "create table Example_Table (id int not null, name varchar(100) not null)" | |||
| End Sub | |||
| Public Sub Down | |||
| Migration.Do "drop table Example_Table" | |||
| End Sub | |||
| End Class | |||
| Migrations.Add "Example_01_Create_Example_Table" | |||
| %> | |||
| @@ -0,0 +1,18 @@ | |||
| <% | |||
| Class Example_02_Insert_Records_To_Example_Table | |||
| Public Migration | |||
| Public Sub Up | |||
| dim i | |||
| For i = 1 to 100 | |||
| Migration.Do "INSERT INTO Example_Table (id, name) VALUES (" & i & ", 'Name " & i & "');" | |||
| Next | |||
| End Sub | |||
| Public Sub Down | |||
| Migration.Do "DELETE FROM Example_Table WHERE id >= 1 and id <= 100" | |||
| End Sub | |||
| End Class | |||
| Migrations.Add "Example_02_Insert_Records_To_Example_Table" | |||
| %> | |||
| @@ -0,0 +1,18 @@ | |||
| <% | |||
| Class Example_03_Insert_More_Records_To_Example_Table | |||
| Public Migration | |||
| Public Sub Up | |||
| dim i | |||
| For i = 101 to 200 | |||
| Migration.Do "INSERT INTO Example_Table (id, name) VALUES (" & i & ", 'ANOTHER Name " & i & "');" | |||
| Next | |||
| End Sub | |||
| Public Sub Down | |||
| Migration.Do "DELETE FROM Example_Table WHERE id >= 101 and id <= 200" | |||
| End Sub | |||
| End Class | |||
| Migrations.Add "Example_03_Insert_More_Records_To_Example_Table" | |||
| %> | |||
| @@ -0,0 +1,26 @@ | |||
| <% | |||
| Class Migration_03_Create_Settings_Table | |||
| Public Migration | |||
| Public Sub Up | |||
| Migration.Do "CREATE TABLE [Settings] (" &_ | |||
| "[ID] COUNTER," &_ | |||
| "[Name] VARCHAR(255)," &_ | |||
| "[Value] VARCHAR(255)" &_ | |||
| ");" | |||
| Migration.Do "CREATE UNIQUE INDEX [ID] ON [Settings]( [ID] ) WITH PRIMARY;" | |||
| Migration.Do "INSERT INTO Settings ([Name],[Value]) VALUES ('MailingID', '202248');" | |||
| Migration.Do "INSERT INTO Settings ([Name],[Value]) VALUES ('SerialNumberStart','2000000');" | |||
| Migration.Do "INSERT INTO Settings ([Name],[Value]) VALUES ('SerialNumberEnd','5000000');" | |||
| Migration.Do "INSERT INTO Settings ([Name],[Value]) Values ('SerialOffset','2000000');" | |||
| End Sub | |||
| Public Sub Down | |||
| Migration.Do "DROP TABLE [Settings]" | |||
| End Sub | |||
| End Class | |||
| Migrations.Add "Migration_03_Create_Settings_Table" | |||
| %> | |||
| @@ -0,0 +1,19 @@ | |||
| <% | |||
| Class Migration_04_Create_Kit_Table | |||
| Public Migration | |||
| Public Sub Up | |||
| Migration.Do "CREATE TABLE [Kit] (" &_ | |||
| "[ID] COUNTER," &_ | |||
| "[JobNumber] VARCHAR(255)," &_ | |||
| "[Jcode] VARCHAR(255)" &_ | |||
| ");" | |||
| Migration.Do "CREATE UNIQUE INDEX [ID] ON [Kit]( [ID] ) WITH PRIMARY;" | |||
| End Sub | |||
| Public Sub Down | |||
| Migration.Do "DROP TABLE [Kit]" | |||
| End Sub | |||
| End Class | |||
| Migrations.Add "Migration_04_Create_Kit_Table" | |||
| %> | |||
| @@ -0,0 +1,24 @@ | |||
| <% | |||
| Class Migration_05_Create_Kit_Labels_Table | |||
| Public Migration | |||
| Public Sub Up | |||
| Migration.Do "CREATE TABLE [KitLabels] (" &_ | |||
| "[ID] COUNTER," &_ | |||
| "[KitId] NUMBER," &_ | |||
| "[OutboundSerial] VARCHAR(255)," &_ | |||
| "[InBoundSerial] VARCHAR(255)," &_ | |||
| "[OutboundIMB] VARCHAR(255)," &_ | |||
| "[InBoundIMB] VARCHAR(255)," &_ | |||
| "[OutboundIMBDigits] VARCHAR(255)," &_ | |||
| "[InBoundIMBDigits] VARCHAR(255)" &_ | |||
| ");" | |||
| Migration.Do "CREATE UNIQUE INDEX [ID] ON [KitLabels]( [ID] ) WITH PRIMARY;" | |||
| End Sub | |||
| Public Sub Down | |||
| Migration.Do "DROP TABLE [KKitLabels]" | |||
| End Sub | |||
| End Class | |||
| Migrations.Add "Migration_05_Create_Kit_Labels_Table" | |||
| %> | |||
| @@ -0,0 +1,276 @@ | |||
| <% | |||
| 'Represents a single migration (either up or down) | |||
| Class Migration_Class | |||
| Private m_name | |||
| Private m_migration_instance | |||
| Private m_sql_array | |||
| Private m_sql_array_size | |||
| Private m_connection | |||
| Private m_has_errors | |||
| Public Tracing 'bool | |||
| Public Property Get Name | |||
| Name = m_name | |||
| End Property | |||
| Public Property Get Migration | |||
| set Migration = m_migration_instance | |||
| End Property | |||
| Public Property Set Migration(obj) | |||
| set m_migration_instance = obj | |||
| End Property | |||
| Public Property Get HasErrors | |||
| HasErrors = m_has_errors | |||
| End Property | |||
| Private Sub Class_Initialize | |||
| m_sql_array = array() | |||
| redim m_sql_array(-1) | |||
| m_has_errors = false | |||
| End Sub | |||
| Public Sub Initialize(name, migration_instance, connection) | |||
| m_name = name | |||
| set m_migration_instance = migration_instance | |||
| set m_migration_instance.Migration = Me 'how circular can we get? ... | |||
| set m_connection = connection | |||
| End Sub | |||
| Private Sub Class_Terminate | |||
| 'm_connection.Close | |||
| 'set m_connection = Nothing | |||
| End Sub | |||
| Public Sub [Do](sql) | |||
| dim new_size : new_size = ubound(m_sql_array) + 1 | |||
| redim preserve m_sql_array(new_size) | |||
| m_sql_array(new_size) = sql | |||
| 'put "Added command: " & sql | |||
| End Sub | |||
| Public Sub Irreversible | |||
| Err.Raise 1, "Migration_Class:Irreversible", "Migration cannot proceed because this migration is irreversible." | |||
| End Sub | |||
| Public Sub DownDataWarning | |||
| put "Migration can be downversioned but data changes cannot take place due to the nature of the Up migration in this set." | |||
| End Sub | |||
| Public Function Query(sql) | |||
| put "Query: " & sql | |||
| set Query = m_connection.Execute(sql) | |||
| End Function | |||
| Public Sub DoUp | |||
| Migration.Up | |||
| ShowCommands | |||
| ExecuteCommands | |||
| End Sub | |||
| Public Sub DoDown | |||
| Migration.Down | |||
| ShowCommands | |||
| ExecuteCommands | |||
| End Sub | |||
| Private Sub ShowCommands | |||
| put "" | |||
| put "Commands:" | |||
| dim i : i = 0 | |||
| For i = 0 to ubound(m_sql_array) | |||
| put " Command: " & m_sql_array(i) | |||
| Next | |||
| put "" | |||
| End Sub | |||
| Private Sub ExecuteCommands | |||
| dim i : i = 0 | |||
| dim sql | |||
| m_connection.BeginTrans 'wrap entire process in transaction, rollback If error encountered on any statement | |||
| For i = 0 to ubound(m_sql_array) | |||
| sql = m_sql_array(i) | |||
| If not m_has_errors then 'avoid further processing If errors exist | |||
| On Error Resume Next | |||
| put "Executing: " & sql | |||
| m_connection.Execute sql | |||
| If Err.Number <> 0 then 'something went wrong, rollback the transaction and display an error | |||
| m_has_errors = true | |||
| m_connection.RollbackTrans | |||
| put_error "Error during migration: " & Err.Description | |||
| put_error "SQL: " & sql | |||
| exit sub | |||
| End If | |||
| On Error Goto 0 | |||
| End If | |||
| Next | |||
| m_connection.CommitTrans 'surprisingly no errors were encountered, so commit the entire transaction | |||
| End Sub | |||
| 'force font color dIfference | |||
| Private Sub put(s) | |||
| If Me.Tracing then response.write "<div style='color: #999'>" & s & "</div>" | |||
| End Sub | |||
| End Class | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Represents the collection of migrations to be performed | |||
| Class Migrations_Class | |||
| Private m_migrations_array ' 1-based to match migration naming scheme, ignore the first element | |||
| Private m_migrations_array_size | |||
| Private m_version | |||
| Private m_connection | |||
| Private m_connection_string | |||
| Private m_has_errors | |||
| Public Tracing 'bool | |||
| Private Sub Class_Initialize | |||
| m_migrations_array = array() | |||
| m_migrations_array_size = 0 ' 1-based, ignore the first element | |||
| redim m_migrations_array(m_migrations_array_size) | |||
| m_has_errors = false | |||
| End Sub | |||
| Private Sub Class_Terminate | |||
| On Error Resume Next | |||
| m_connection.Close | |||
| set m_connection = Nothing | |||
| On Error Goto 0 | |||
| End Sub | |||
| 'force font color dIfference | |||
| Private Sub put(s) | |||
| If Me.Tracing then response.write "<div style='color: #999'>" & s & "</div>" | |||
| End Sub | |||
| Public Sub Initialize(connection_string) | |||
| m_connection_string = connection_string | |||
| set m_connection = Server.CreateObject("ADODB.Connection") | |||
| m_connection.Open m_connection_string | |||
| put "Initialized: " & typename(m_connection) | |||
| End Sub | |||
| Public Sub Add(name) | |||
| m_migrations_array_size = m_migrations_array_size + 1 | |||
| redim preserve m_migrations_array(m_migrations_array_size) | |||
| dim M : set M = new Migration_Class | |||
| dim migration_instance : set migration_instance = eval("new " & name) | |||
| M.Initialize name, migration_instance, m_connection | |||
| M.Tracing = Me.Tracing | |||
| set m_migrations_array(m_migrations_array_size) = M | |||
| End Sub | |||
| Public Sub MigrateUp | |||
| MigrateUpTo m_migrations_array_size | |||
| End Sub | |||
| Public Sub MigrateUpBy(num) | |||
| MigrateUpTo Version + num | |||
| End Sub | |||
| Public Sub MigrateUpTo(requested_version) | |||
| requested_version = CInt(requested_version) | |||
| put "Migrating Up To Version " & requested_version | |||
| dim M, class_name | |||
| If Version >= requested_version then | |||
| put_error "DB already at higher version than requested up migration." | |||
| ElseIf requested_version > m_migrations_array_size then | |||
| put_error "Requested version exceeds available migrations. Only " & m_migrations_array_size & " migrations are available." | |||
| Else | |||
| While (NextVersion <= requested_version) and (not m_has_errors) | |||
| set M = m_migrations_array(NextVersion) | |||
| put "" | |||
| put "<b>Up: " & M.name & "</b>" | |||
| M.DoUp | |||
| m_has_errors = M.HasErrors | |||
| If not m_has_errors then IncrementVersion | |||
| Wend | |||
| End If | |||
| End Sub | |||
| Public Sub MigrateDown | |||
| MigrateDownTo 0 | |||
| End Sub | |||
| Public Sub MigrateDownBy(num) | |||
| MigrateDownTo Version - num | |||
| End Sub | |||
| Public Sub MigrateDownTo(requested_version) | |||
| requested_version = CInt(requested_version) | |||
| put "Migrating Down To Version: " & requested_version | |||
| dim M, class_name | |||
| If requested_version < 0 then | |||
| put_error "Cannot migrate down to a version less than 0." | |||
| ElseIf requested_version > Version then | |||
| put_error "Cannot migrate down to a version higher than the current version." | |||
| ElseIf requested_version = Version then | |||
| put_error "Cannot migrate down to the current version, already there." | |||
| Else | |||
| While (Version > requested_version) and (not m_has_errors) | |||
| set M = m_migrations_array(Version) | |||
| put "" | |||
| put "<b>Down: " & M.Name & "</b>" | |||
| M.DoDown | |||
| m_has_errors = M.HasErrors | |||
| If not m_has_errors then DecrementVersion | |||
| Wend | |||
| End If | |||
| End Sub | |||
| Public Property Get Version | |||
| If IsEmpty(m_version) then | |||
| m_version = GetDBVersion() | |||
| End If | |||
| Version = m_version | |||
| End Property | |||
| Private Property Let Version(val) | |||
| m_version = val | |||
| m_connection.Execute "update meta_migrations set version = " & m_version | |||
| End Property | |||
| Public Property Get NextVersion | |||
| NextVersion = Version + 1 | |||
| End Property | |||
| Private Function GetDBVersion() | |||
| dim rs : set rs = m_connection.Execute("select version from meta_migrations") | |||
| If rs.BOF or rs.EOF then | |||
| GetDBVersion = NULL | |||
| Else | |||
| GetDBVersion = rs("version") | |||
| End If | |||
| rs.Close | |||
| set rs = Nothing | |||
| End Function | |||
| Private Sub IncrementVersion | |||
| If not m_has_errors then Version = Version + 1 | |||
| End Sub | |||
| Private Sub DecrementVersion | |||
| If not m_has_errors then Version = Version - 1 | |||
| End Sub | |||
| End Class | |||
| dim Migrations_Class__Singleton | |||
| Function Migrations() | |||
| If IsEmpty(Migrations_Class__Singleton) then set Migrations_Class__Singleton = new Migrations_Class | |||
| set Migrations = Migrations_Class__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,115 @@ | |||
| <% | |||
| Option Explicit | |||
| Sub put(v) | |||
| response.write v & "<br>" | |||
| End Sub | |||
| Sub put_ | |||
| put "" | |||
| End Sub | |||
| Sub put_error(s) | |||
| put "<span style='color: red; font-weight: bold;'>" & s & "</span>" | |||
| End Sub | |||
| %> | |||
| <!--#include file="../../MVC/lib.all.asp"--> | |||
| <!--#include file="../../App/DAL/lib.DAL.asp"--> | |||
| <!--#include file="lib.Migrations.asp"--> | |||
| <% | |||
| 'Have to initialize Migrations_Class before including any actual migrations, because they each automatically append themselves to the Migrations class for convenience. | |||
| 'TODO: This can be refactored by not having the individual migration files auto-add themselves, but then this file must manually add each one using a slightly dIfferent | |||
| ' naming convention, i.e. given include file 01_Create_Users.asp the command would be Migrations.Add "Migration_01_Create_Users" or such. At least this way is automated. | |||
| Migrations.Initialize "Provider=Microsoft.Jet.OLEDB.4.0;Jet OLEDB:Engine Type=5;Data Source=" & Request.ServerVariables("APPL_PHYSICAL_PATH") & "Data\webdata.mdb;" | |||
| Migrations.Tracing = false | |||
| %> | |||
| <!--#include file="Migration_01_Create_Jurisdiction_Table.asp"--> | |||
| <!--#include file="Migration_02_Create_Contact_Table.asp"--> | |||
| <!--#include file="Migration_03_Create_Settings_Table.asp"--> | |||
| <!--#include file="Migration_04_Create_Kit_Table.asp"--> | |||
| <!--#include file="Migration_05_Create_Kit_Labels_Table.asp"--> | |||
| <% | |||
| Sub HandleMigration | |||
| putl "<b>Starting Version: " & Migrations.Version & "</b>" | |||
| If Request.Form("mode") = "direct" then | |||
| If Request.Form("direction") = "Up" then | |||
| If Len(Request.Form("to")) > 0 then | |||
| Migrations.MigrateUpTo(Request.Form("to")) | |||
| Else | |||
| Migrations.MigrateUp | |||
| End If | |||
| ElseIf Request.Form("direction") = "Down" then | |||
| If Len(Request.Form("to")) > 0 then | |||
| Migrations.MigrateDownTo(Request.Form("to")) | |||
| Else | |||
| Migrations.MigrateDown | |||
| End If | |||
| End If | |||
| ElseIf Request.Form("mode") = "up_one" then | |||
| Migrations.MigrateUpBy 1 | |||
| ElseIf Request.Form("mode") = "down_one" then | |||
| Migrations.MigrateDownBy 1 | |||
| End If | |||
| putl "<b style='color: darkgreen'>Final Version: " & Migrations.Version & "</b>" | |||
| End Sub | |||
| Sub ShowForm | |||
| %> | |||
| <form action="migrate.asp" method="POST"> | |||
| <input type="hidden" name="mode" value="direct"> | |||
| <p> | |||
| <b>Direction: </b> | |||
| <select name="direction"> | |||
| <option value="Up">Up</option> | |||
| <option value="Down">Down</option> | |||
| </select> | |||
| | |||
| <b>To: </b> | |||
| <input type="text" size="5" name="to"> | |||
| | |||
| <input type="Submit" value="Migrate!"> | |||
| </p> | |||
| </form> | |||
| <form action="migrate.asp" method="POST" style="display: inline"> | |||
| <input type="hidden" name="mode" value="up_one"> | |||
| <input type="Submit" value="Up 1"> | |||
| </form> | |||
| <form action="migrate.asp" method="POST"> | |||
| <input type="hidden" name="mode" value="down_one"> | |||
| <input type="Submit" value="Down 1"> | |||
| </form> | |||
| <hr> | |||
| <% | |||
| End Sub | |||
| Sub Main | |||
| ShowForm | |||
| If Len(Request.Form("mode")) > 0 then | |||
| HandleMigration | |||
| Else | |||
| putl "<b>Version: " & Migrations.Version & "</b>" | |||
| End If | |||
| End Sub | |||
| %> | |||
| <!doctype html> | |||
| <html> | |||
| <head> | |||
| <style> | |||
| body { font-family: calibri; } | |||
| </style> | |||
| </head> | |||
| <body> | |||
| <% Main %> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,83 @@ | |||
| <% | |||
| Option Explicit | |||
| Sub Main | |||
| ShowFileList | |||
| If Len(Request.Form("filename")) > 0 then | |||
| ShowDocs | |||
| End If | |||
| End Sub | |||
| Sub ShowFileList | |||
| %> | |||
| <h1>Select File</h1> | |||
| <form action="docs.asp" method="POST"> | |||
| <select name="filename"> | |||
| <% | |||
| dim fso : set fso = Server.CreateObject("Scripting.FileSystemObject") | |||
| dim files : set files = fso.GetFolder(Server.MapPath(".")).Files | |||
| dim file | |||
| For Each file in files | |||
| If fso.GetExtensionName(file.Path) = "asp" and file.Name <> "docs.asp" and InStr(file.Name, "_old") = 0 then | |||
| response.write "<option value='" & file.Name & "'>" & file.Name & "</option>" | |||
| End If | |||
| Next | |||
| %> | |||
| </select> | |||
| <input type="submit" value="Get Docs"> | |||
| </form> | |||
| <hr> | |||
| <% | |||
| End Sub | |||
| Sub ShowDocs | |||
| dim fso : set fso = Server.CreateObject("Scripting.FileSystemObject") | |||
| dim path : path = fso.GetFolder(Server.MapPath(".")).Path | |||
| dim file : set file = fso.OpenTextFile(path & "\" & Request.Form("filename")) | |||
| dim re : set re = new RegExp | |||
| With re | |||
| .Pattern = "Public Property|Public Sub|Public Function" | |||
| .Global = true | |||
| .IgnoreCase = true | |||
| End With | |||
| dim line, matches, result | |||
| Do Until file.AtEndOfStream | |||
| line = file.ReadLine() | |||
| set matches = re.Execute(line) | |||
| If matches.Count > 0 then | |||
| result = line | |||
| result = Replace(result, "Public Property", "<span class='subdued'>Property</span>") | |||
| result = Replace(result, "Public Sub", "<span class='subdued'>Sub</span>") | |||
| result = Replace(result, "Public Function", "<span class='subdued'>Function</span>") | |||
| response.write "<p>" & result & "</p>" | |||
| End If | |||
| Loop | |||
| End Sub | |||
| %> | |||
| <!doctype html> | |||
| <html> | |||
| <head> | |||
| <style> | |||
| body { font-family: calibri; } | |||
| p { font-weight: bold; } | |||
| .subdued { font-weight: normal; color: #999; } | |||
| </style> | |||
| </head> | |||
| <body> | |||
| <% Call Main %> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,160 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' AUTOMAPPER CLASS | |||
| '======================================================================================================================= | |||
| 'Side Effects: Since src and target are passed ByRef to reduce unnecessary copying, if src is a recordset then the | |||
| ' current record pointer is modified using src.MoveFirst and src.MoveNext. The end result is the current | |||
| ' record pointer ends the operation at src.EOF. | |||
| Class Automapper_Class | |||
| Private m_src | |||
| Private m_target | |||
| Private m_statements | |||
| Private m_statements_count | |||
| Private Property Get Src : set Src = m_src : End Property | |||
| Private Property Get Target : set Target = m_target : End Property | |||
| Private Sub Class_Initialize | |||
| m_statements = Array() | |||
| m_statements_count = 0 | |||
| redim m_statements(m_statements_count) | |||
| End Sub | |||
| Private Sub ResetState | |||
| m_statements_count = 0 | |||
| redim m_statements(m_statements_count) | |||
| set m_src = Nothing | |||
| set m_target = Nothing | |||
| End Sub | |||
| 'Maps all rs or object fields to corresponding fields in the specified class. | |||
| Public Function AutoMap(src_obj, target_obj) | |||
| Set AutoMap = FlexMap(src_obj, target_obj, empty) | |||
| End Function | |||
| 'Only maps fields specified in the field_names array (array of strings). | |||
| 'If field_names is empty, attempts to map all fields from the passed rs or object. | |||
| Public Function FlexMap(src_obj, target_obj, field_names) | |||
| Set FlexMap = DynMap(src_obj, target_obj, field_names, empty) | |||
| End Function | |||
| 'Only maps fields specified in the field_names array (array of strings). | |||
| 'If field_names is empty then src MUST be a recordset as it attempts to map all fields from the recordset. | |||
| 'Since there is no reflection in vbscript, there is no way around this short of pseudo-reflection. | |||
| Public Function DynMap(src_obj, target_obj, field_names, exprs) | |||
| SetSource src_obj | |||
| SetTarget target_obj | |||
| dim field_name | |||
| dim field_idx 'loop counter | |||
| if IsEmpty(field_names) then 'map everything | |||
| if typename(src_obj) = "Recordset" then | |||
| for field_idx = 0 to src_obj.Fields.Count - 1 | |||
| field_name = src_obj.Fields.Item(field_idx).Name | |||
| 'AddStatement field_name | |||
| AddStatement BuildStatement(field_name) | |||
| next | |||
| elseif InStr(typename(src_obj), "Dictionary") > 0 then 'enables Scripting.Dictionary and IRequestDictionary for Request.Querystring and Request.Form | |||
| for each field_name in src_obj | |||
| AddStatement BuildStatement(field_name) | |||
| next | |||
| elseif not IsEmpty(src_obj.Class_Get_Properties) then | |||
| dim props : props = src_obj.Class_Get_Properties | |||
| for field_idx = 0 to ubound(props) | |||
| field_name = props(field_idx) | |||
| 'AddStatement field_name | |||
| AddStatement BuildStatement(field_name) | |||
| next | |||
| else 'some invalid type of object | |||
| Err.Raise 9, "Automapper.DynMap", "Cannot automatically map this source object. Expected recordset or object implementing Class_Get_Properties reflection, got: " & typename(src_obj) | |||
| end if | |||
| else 'map only specified fields | |||
| for field_idx = lbound(field_names) to ubound(field_names) | |||
| field_name = field_names(field_idx) | |||
| 'AddStatement field_name | |||
| AddStatement BuildStatement(field_name) | |||
| next | |||
| end if | |||
| dim exprs_idx | |||
| if not IsEmpty(exprs) then | |||
| if typename(exprs) = "Variant()" then | |||
| for exprs_idx = lbound(exprs) to ubound(exprs) | |||
| 'field_name = exprs(exprs_idx) | |||
| 'AddStatement field_name | |||
| AddStatement exprs(exprs_idx) | |||
| next | |||
| else 'assume string or string-like default value | |||
| AddStatement exprs | |||
| end if | |||
| end if | |||
| 'Can't pre-join the statements because if one fails the rest of them fail too... :( | |||
| 'dim joined_statements : joined_statements = Join(m_statements, " : ") | |||
| 'put joined_statements | |||
| 'suspend errors to prevent failing when attempting to map a field that does not exist in the class | |||
| on error resume next | |||
| dim stmt_idx | |||
| for stmt_idx = 0 to ubound(m_statements) | |||
| Execute m_statements(stmt_idx) | |||
| next | |||
| on error goto 0 | |||
| set DynMap = m_target | |||
| ResetState | |||
| End Function | |||
| Private Sub SetSource(ByVal src_obj) | |||
| set m_src = src_obj | |||
| End Sub | |||
| Private Sub SetTarget(ByVal target_obj) | |||
| if typename(target_obj) = "String" then | |||
| set m_target = eval("new " & target_obj) | |||
| else | |||
| set m_target = target_obj | |||
| end if | |||
| End Sub | |||
| 'Builds a statement and adds it to the internal statements array | |||
| Private Sub AddStatement(ByVal stmt) | |||
| redim preserve m_statements(m_statements_count + 1) | |||
| m_statements(m_statements_count) = stmt | |||
| m_statements_count = m_statements_count + 1 | |||
| End Sub | |||
| Private Function BuildStatement(ByVal field_name) | |||
| dim result | |||
| if typename(m_src) = "Recordset" or InStr(typename(m_src), "Dictionary") > 0 then | |||
| result = "m_target." & field_name & " = m_src(""" & field_name & """)" | |||
| else | |||
| 'Funky magic... | |||
| 'If src.field_name is an object, ensure the set statement is used | |||
| if IsObject(eval("m_src." & field_name)) then | |||
| result = "set " | |||
| else | |||
| 'result = "m_target." & field_name & " = m_src." & field_name | |||
| end if | |||
| result = result & " m_target." & field_name & " = m_src." & field_name | |||
| end if | |||
| BuildStatement = result | |||
| End Function | |||
| End Class | |||
| Function Automapper() | |||
| Set Automapper = new Automapper_Class | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,57 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Bootstrap Helper - Provides some convenience methods for Bootstrap use | |||
| '======================================================================================================================= | |||
| Class Bootstrap_Helper_Class | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Forms | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Creates .control-label for Bootstrap styling | |||
| Public Function ControlLabel(name, for_name) | |||
| ControlLabel = HTML.LabelExt(name, for_name, Array("class", "control-label")) | |||
| End Function | |||
| Public Function Control(label_text, control_name, controls_html) | |||
| Control = "<div class='control-group'>" & ControlLabel(label_text, control_name) & "<div class='controls'>" & controls_html & "</div></div>" | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Modals | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Function ModalLinkTo(link_text, controller_name, action_name, modal_name, html_class_attrib) | |||
| ModalLinkTo = ModalLinkToExt(link_text, controller_name, action_name, params_array, modal_name, html_class_attrib, empty) | |||
| End Function | |||
| Public Function ModalLinkToExt(link_text, controller_name, action_name, params_array, modal_name, html_class_attrib, html_attribs_array) | |||
| ModalLinkToExt = "<a href='" & Server.HTMLEncode(Routes.UrlTo(controller_name, action_name, params_array)) & "'" &_ | |||
| " class='" & html_class_attrib & " modal-link' data-modal='" & modal_name & "' " &_ | |||
| HTML.HtmlAttribs(html_attribs_array) & ">" & link_text & "</a>" | |||
| End Function | |||
| 'Generates the jQuery handler for the modal dialogs | |||
| Public Function ModalHandlerScript() | |||
| dim s | |||
| s = " <script type='text/javascript'> " & vbCR &_ | |||
| " // when a .modal-link is clicked, display the href target in the popup modal " & vbCR &_ | |||
| " $(function() { " & vbCR &_ | |||
| " $('a.modal-link').click(function(event) { " & vbCR &_ | |||
| " event.preventDefault(); " & vbCR &_ | |||
| " var modalName = $(this).attr('data-modal'); " & vbCR &_ | |||
| " $('#' + modalName).removeData('modal').modal( { remote: $(this).attr('href') } ); " & vbCR &_ | |||
| " }); " & vbCR &_ | |||
| " }); " & vbCR &_ | |||
| " </script> " | |||
| ModalHandlerScript = s | |||
| End Function | |||
| End Class | |||
| dim Bootstrap_Helper_Class__Singleton | |||
| Function Bootstrap() | |||
| If IsEmpty(Bootstrap_Helper_Class__Singleton) then set Bootstrap_Helper_Class__Singleton = new Bootstrap_Helper_Class | |||
| set Bootstrap = Bootstrap_Helper_Class__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,740 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' KVArray | |||
| ' Relatively painless implementation of key/value pair arrays without requiring a full Scripting.Dictionary COM instance. | |||
| ' A KVArray is a standard array where element i is the key and element i+1 is the value. Loops must step by 2. | |||
| '======================================================================================================================= | |||
| 'given a KVArray and key index, returns the key and value | |||
| 'pre: kv_array has at least key_idx and key_idx + 1 values | |||
| 'post: key and val are populated | |||
| Sub KeyVal(kv_array, key_idx, ByRef key, ByRef val) | |||
| if (key_idx + 1 > ubound(kv_array)) then err.raise 1, "KeyVal", "expected key_idx < " & ubound(kv_array) - 1 & ", got: " & key_idx | |||
| key = kv_array(key_idx) | |||
| val = kv_array(key_idx + 1) | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Given a KVArray, a key and a value, appends the key and value to the end of the KVArray | |||
| Sub KVAppend(ByRef kv_array, key, val) | |||
| dim i : i = ubound(kv_array) | |||
| redim preserve kv_array(i + 2) | |||
| kv_array(i + 1) = key | |||
| kv_array(i + 2) = val | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| 'Given a KVArray and two variants, populates the first variant with all keys and the second variant with all values. | |||
| 'If | |||
| 'Pre: kv_array has at least key_idx and key_idx + 1 values | |||
| 'Post: key_array contains all keys in kvarray. | |||
| ' val_array contains all values in kvarray. | |||
| ' key_array and val_array values are in corresponding order, i.e. key_array(i) corresponds to val_array(i). | |||
| Sub KVUnzip(kv_array, key_array, val_array) | |||
| dim kv_array_size : kv_array_size = ubound(kv_array) | |||
| dim num_pairs : num_pairs = (kv_array_size + 1) / 2 | |||
| dim result_array_size : result_array_size = num_pairs - 1 | |||
| 'Extend existing key_array or create new array to hold the keys | |||
| If IsArray(key_array) then | |||
| redim preserve key_array(ubound(key_array) + result_array_size) | |||
| Else | |||
| key_array = Array() | |||
| redim key_array(result_array_size) | |||
| End If | |||
| 'Extend existing val array or create new array to hold the values | |||
| If IsArray(val_array) then | |||
| redim preserve val_array(ubound(val_array) + result_array_size) | |||
| Else | |||
| val_array = Array() | |||
| redim val_array(num_pairs - 1) | |||
| End If | |||
| 'Unzip the KVArray into the two output arrays | |||
| dim i, key, val | |||
| dim key_val_arrays_idx : key_val_arrays_idx = 0 ' used to sync loading the key_array and val_array | |||
| For i = 0 to ubound(kv_array) step 2 | |||
| KeyVal kv_array, i, key, val | |||
| key_array(key_val_arrays_idx) = key | |||
| val_array(key_val_arrays_idx) = val | |||
| key_val_arrays_idx = key_val_arrays_idx + 1 ' increment by 1 because loop goes to next pair in kv_array | |||
| Next | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Given a KVArray, dumps it to the screen. Useful for debugging purposes. | |||
| Sub DumpKVArray(kv_array) | |||
| dim i, key, val | |||
| For i = 0 to ubound(kv_array) step 2 | |||
| KeyVal kv_array, i, key, val | |||
| put key & " => " & val & "<br>" | |||
| Next | |||
| End Sub | |||
| '======================================================================================================================= | |||
| ' Pair Class | |||
| ' Holds a pair of values, i.e. a key value pair, recordset field name/value pair, etc. | |||
| ' Similar to the C++ STL std::pair class. Useful for some iteration and the like. | |||
| ' | |||
| ' This was an interesting idea but so far has not really been used, oh well...... | |||
| '======================================================================================================================= | |||
| Class Pair_Class | |||
| Private m_first, m_second | |||
| Public Property Get First : First = m_first : End Property | |||
| Public Property Get [Second] : [Second] = m_second : End Property | |||
| Public Default Property Get TO_String | |||
| TO_String = First & " " & [Second] | |||
| End Property | |||
| Public Sub Initialize(ByVal firstval, ByVal secondval) | |||
| Assign m_first, firstval | |||
| Assign m_second, secondval | |||
| End Sub | |||
| 'Swaps the two values | |||
| Public Sub Swap | |||
| dim tmp | |||
| Assign tmp, m_second | |||
| Assign m_second, m_first | |||
| Assign m_first, tmp | |||
| End Sub | |||
| End Class | |||
| Function MakePair(ByVal firstval, ByVal secondval) | |||
| dim P : set P = new Pair_Class | |||
| P.Initialize firstval, secondval | |||
| set MakePair = P | |||
| End Function | |||
| '======================================================================================================================= | |||
| ' Linked List - From the Tolerable lib | |||
| '======================================================================================================================= | |||
| ' This is just here for reference | |||
| Class Iterator_Class | |||
| Public Function HasNext() | |||
| End Function | |||
| Public Function PeekNext() | |||
| End Function | |||
| Public Function GetNext() | |||
| End Function | |||
| Public Function HasPrev() | |||
| End Function | |||
| Public Function PeekPrev() | |||
| End Function | |||
| Public Function GetPrev() | |||
| End Function | |||
| End Class | |||
| Class Enumerator_Source_Iterator_Class | |||
| Private m_iter | |||
| Public Sub Initialize(ByVal iter) | |||
| Set m_iter = iter | |||
| End Sub | |||
| Private Sub Class_Terminate() | |||
| Set m_iter = Nothing | |||
| End Sub | |||
| Public Sub GetNext(ByRef retval, ByRef successful) | |||
| If m_iter.HasNext Then | |||
| Assign retval, m_iter.GetNext | |||
| successful = True | |||
| Else | |||
| successful = False | |||
| End If | |||
| End Sub | |||
| End Class | |||
| Public Function En_Iterator(ByVal iter) | |||
| Dim retval | |||
| Set retval = New Enumerator_Source_Iterator_Class | |||
| retval.Initialize iter | |||
| Set En_Iterator = Enumerator(retval) | |||
| End Function | |||
| Class LinkedList_Node_Class | |||
| Public m_prev | |||
| Public m_next | |||
| Public m_value | |||
| Private Sub Class_Initialize() | |||
| Set m_prev = Nothing | |||
| Set m_next = Nothing | |||
| End Sub | |||
| Private Sub Class_Terminate() | |||
| Set m_prev = Nothing | |||
| Set m_next = Nothing | |||
| Set m_value = Nothing | |||
| End Sub | |||
| Public Sub SetValue(ByVal value) | |||
| Assign m_value, value | |||
| End Sub | |||
| End Class | |||
| Class Iterator_LinkedList_Class | |||
| Private m_left | |||
| Private m_right | |||
| Public Sub Initialize(ByVal r) | |||
| Set m_left = Nothing | |||
| Set m_right = r | |||
| End Sub | |||
| Private Sub Class_Terminate() | |||
| Set m_Left = Nothing | |||
| Set m_Right = Nothing | |||
| End Sub | |||
| Public Function HasNext() | |||
| HasNext = Not(m_right Is Nothing) | |||
| End Function | |||
| Public Function PeekNext() | |||
| Assign PeekNext, m_right.m_value | |||
| End Function | |||
| Public Function GetNext() | |||
| Assign GetNext, m_right.m_value | |||
| Set m_left = m_right | |||
| Set m_right = m_right.m_next | |||
| End Function | |||
| Public Function HasPrev() | |||
| HasPrev = Not(m_left Is Nothing) | |||
| End Function | |||
| Public Function PeekPrev() | |||
| Assign PeekPrev, m_left.m_value | |||
| End Function | |||
| Public Function GetPrev() | |||
| Assign GetPrev, m_left.m_value | |||
| Set m_right = m_left | |||
| Set m_left = m_left.m_prev | |||
| End Function | |||
| End Class | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Class LinkedList_Class | |||
| Private m_first | |||
| Private m_last | |||
| Private m_size | |||
| Private Sub Class_Initialize() | |||
| Me.Reset | |||
| End Sub | |||
| Private Sub Class_Terminate() | |||
| Me.Reset | |||
| End Sub | |||
| Public Function Clear() | |||
| Set m_first = Nothing | |||
| Set m_last = Nothing | |||
| m_size = 0 | |||
| Set Clear = Me | |||
| End Function | |||
| Private Function NewNode(ByVal value) | |||
| Dim retval | |||
| Set retval = New LinkedList_Node_Class | |||
| retval.SetValue value | |||
| Set NewNode = retval | |||
| End Function | |||
| Public Sub Reset() | |||
| Set m_first = Nothing | |||
| Set m_last = Nothing | |||
| m_size = 0 | |||
| End Sub | |||
| Public Function IsEmpty() | |||
| IsEmpty = (m_last Is Nothing) | |||
| End Function | |||
| Public Property Get Count | |||
| Count = m_size | |||
| End Property | |||
| 'I just like .Size better than .Count sometimes, sue me | |||
| Public Property Get Size | |||
| Size = m_size | |||
| End Property | |||
| Public Function Iterator() | |||
| Dim retval | |||
| Set retval = New Iterator_LinkedList_Class | |||
| retval.Initialize m_first | |||
| Set Iterator = retval | |||
| End Function | |||
| Public Function Push(ByVal value) | |||
| Dim temp | |||
| Set temp = NewNode(value) | |||
| If Me.IsEmpty Then | |||
| Set m_first = temp | |||
| Set m_last = temp | |||
| Else | |||
| Set temp.m_prev = m_last | |||
| Set m_last.m_next = temp | |||
| Set m_last = temp | |||
| End If | |||
| m_size = m_size + 1 | |||
| Set Push = Me | |||
| End Function | |||
| Public Function Peek() | |||
| ' TODO: Error handling | |||
| Assign Peek, m_last.m_value | |||
| End Function | |||
| ' Alias for Peek | |||
| Public Function Back() | |||
| ' TODO: Error handling | |||
| Assign Back, m_last.m_value | |||
| End Function | |||
| Public Function Pop() | |||
| Dim temp | |||
| ' TODO: Error Handling | |||
| Assign Pop, m_last.m_value | |||
| Set temp = m_last | |||
| Set m_last = temp.m_prev | |||
| Set temp.m_prev = Nothing | |||
| If m_last Is Nothing Then | |||
| Set m_first = Nothing | |||
| Else | |||
| Set m_last.m_next = Nothing | |||
| End If | |||
| m_size = m_size - 1 | |||
| End Function | |||
| Public Function Unshift(ByVal value) | |||
| Dim temp | |||
| Set temp = NewNode(value) | |||
| If Me.IsEmpty Then | |||
| Set m_first = temp | |||
| Set m_last = temp | |||
| Else | |||
| Set temp.m_next = m_first | |||
| Set m_first.m_prev = temp | |||
| Set m_first = temp | |||
| End If | |||
| m_size = m_size + 1 | |||
| Set Unshift = Me | |||
| End Function | |||
| ' Alias for Peek | |||
| Public Function Front() | |||
| ' TODO: Error handling | |||
| Assign Front, m_first.m_value | |||
| End Function | |||
| Public Function Shift() | |||
| Dim temp | |||
| ' TODO: Error Handling | |||
| Assign Shift, m_first.m_value | |||
| Set temp = m_first | |||
| Set m_first = temp.m_next | |||
| Set temp.m_next = Nothing | |||
| If m_first Is Nothing Then | |||
| Set m_last = Nothing | |||
| Else | |||
| Set m_first.m_prev = Nothing | |||
| End If | |||
| m_size = m_size - 1 | |||
| End Function | |||
| Public Function TO_Array() | |||
| Dim i, iter | |||
| ReDim retval(Me.Count - 1) | |||
| i = 0 | |||
| Set iter = Me.Iterator | |||
| While iter.HasNext | |||
| retval(i) = iter.GetNext | |||
| i = i + 1 | |||
| Wend | |||
| TO_Array = retval | |||
| End Function | |||
| Public Function TO_En() | |||
| Set TO_En = En_Iterator(Iterator) | |||
| End Function | |||
| End Class | |||
| '======================================================================================================================= | |||
| ' Dynamic Array - From the Tolerable lib | |||
| '======================================================================================================================= | |||
| Class DynamicArray_Class | |||
| Private m_data | |||
| Private m_size | |||
| Public Sub Initialize(ByVal d, ByVal s) | |||
| m_data = d | |||
| m_size = s | |||
| End Sub | |||
| Private Sub Class_Terminate() | |||
| Set m_data = Nothing | |||
| End Sub | |||
| Public Property Get Capacity | |||
| Capacity = UBOUND(m_data) + 1 | |||
| End Property | |||
| Public Property Get Count | |||
| Count = m_size | |||
| End Property | |||
| ' Alias for Count | |||
| Public Property Get Size | |||
| Size = m_size | |||
| End Property | |||
| Public Function IsEmpty() | |||
| IsEmpty = (m_size = 0) | |||
| End Function | |||
| Public Function Clear() | |||
| m_size = 0 | |||
| Set Clear = Me | |||
| End Function | |||
| Private Sub Grow | |||
| ' TODO: There's probably a better way to | |||
| ' do this. Doubling might be excessive | |||
| ReDim Preserve m_data(UBOUND(m_data) * 2) | |||
| End Sub | |||
| Public Function Push(ByVal val) | |||
| If m_size >= UBOUND(m_data) Then | |||
| Grow | |||
| End If | |||
| Assign m_data(m_size), val | |||
| m_size = m_size + 1 | |||
| Set Push = Me | |||
| End Function | |||
| ' Look at the last element | |||
| Public Function Peek() | |||
| Assign Peek, m_data(m_size - 1) | |||
| End Function | |||
| ' Look at the last element and | |||
| ' pop it off of the list | |||
| Public Function Pop() | |||
| Assign Pop, m_data(m_size - 1) | |||
| m_size = m_size - 1 | |||
| End Function | |||
| ' If pseudo_index < 0, then we assume we're counting | |||
| ' from the back of the Array. | |||
| Private Function CalculateIndex(ByVal pseudo_index) | |||
| If pseudo_index >= 0 Then | |||
| CalculateIndex = pseudo_index | |||
| Else | |||
| CalculateIndex = m_size + pseudo_index | |||
| End If | |||
| End Function | |||
| Public Default Function Item(ByVal i) | |||
| Assign Item, m_data(CalculateIndex(i)) | |||
| End Function | |||
| ' This does not treat negative indices as wrap-around. | |||
| ' Thus, it is slightly faster. | |||
| Public Function FastItem(ByVal i) | |||
| Assign FastItem, m_data(i) | |||
| End Function | |||
| Public Function Slice(ByVal s, ByVal e) | |||
| s = CalculateIndex(s) | |||
| e = CalculateIndex(e) | |||
| If e < s Then | |||
| Set Slice = DynamicArray() | |||
| Else | |||
| ReDim retval(e - s) | |||
| Dim i, j | |||
| j = 0 | |||
| For i = s to e | |||
| Assign retval(j), m_data(i) | |||
| j = j + 1 | |||
| Next | |||
| Set Slice = DynamicArray1(retval) | |||
| End If | |||
| End Function | |||
| Public Function Iterator() | |||
| Dim retval | |||
| Set retval = New Iterator_DynamicArray_Class | |||
| retval.Initialize Me | |||
| Set Iterator = retval | |||
| End Function | |||
| Public Function TO_En() | |||
| Set TO_En = En_Iterator(Me.Iterator) | |||
| End Function | |||
| Public Function TO_Array() | |||
| Dim i | |||
| ReDim retval(m_size - 1) | |||
| For i = 0 to UBOUND(retval) | |||
| Assign retval(i), m_data(i) | |||
| Next | |||
| TO_Array = retval | |||
| End Function | |||
| End Class | |||
| Public Function DynamicArray() | |||
| ReDim data(3) | |||
| Set DynamicArray = DynamicArray2(data, 0) | |||
| End Function | |||
| Public Function DynamicArray1(ByVal data) | |||
| Set DynamicArray1 = DynamicArray2(data, UBOUND(data) + 1) | |||
| End Function | |||
| Private Function DynamicArray2(ByVal data, ByVal size) | |||
| Dim retval | |||
| Set retval = New DynamicArray_Class | |||
| retval.Initialize data, size | |||
| Set DynamicArray2 = retval | |||
| End Function | |||
| Class Iterator_DynamicArray_Class | |||
| Private m_dynamic_array | |||
| Private m_index | |||
| Public Sub Initialize(ByVal dynamic_array) | |||
| Set m_dynamic_array = dynamic_array | |||
| m_index = 0 | |||
| End Sub | |||
| Private Sub Class_Terminate | |||
| Set m_dynamic_array = Nothing | |||
| End Sub | |||
| Public Function HasNext() | |||
| HasNext = (m_index < m_dynamic_array.Size) | |||
| End Function | |||
| Public Function PeekNext() | |||
| Assign PeekNext, m_dynamic_array.FastItem(m_index) | |||
| End Function | |||
| Public Function GetNext() | |||
| Assign GetNext, m_dynamic_array.FastItem(m_index) | |||
| m_index = m_index + 1 | |||
| End Function | |||
| Public Function HasPrev() | |||
| HasPrev = (m_index > 0) | |||
| End Function | |||
| Public Function PeekPrev() | |||
| Assign PeekPrev, m_dynamic_array.FastItem(m_index - 1) | |||
| End Function | |||
| Public Function GetPrev() | |||
| Assign GetPrev, m_dynamic_array.FastItem(m_index - 1) | |||
| m_index = m_index - 1 | |||
| End Function | |||
| End Class | |||
| '======================================================================================================================= | |||
| ' Other Iterators | |||
| '======================================================================================================================= | |||
| '!!! EXPERIMENTAL !!! May not be very useful, oh well... | |||
| Class Iterator_Recordset_Class | |||
| Private m_rs | |||
| Private m_record_count | |||
| Private m_current_index | |||
| Private m_field_names 'cached array | |||
| Public Sub Initialize(ByVal rs) | |||
| Set m_rs = rs | |||
| m_rs.MoveFirst | |||
| m_rs.MovePrevious | |||
| m_record_count = rs.RecordCount | |||
| m_current_index = 0 | |||
| 'cache field names | |||
| m_field_names = array() | |||
| redim m_field_names(m_rs.Fields.Count) | |||
| dim field | |||
| dim i : i = 0 | |||
| for each field in m_rs.Fields | |||
| m_field_names(i) = field.Name | |||
| next | |||
| End Sub | |||
| Private Sub Class_Terminate | |||
| Set m_rs = Nothing | |||
| End Sub | |||
| Public Function HasNext() | |||
| HasNext = (m_current_index < m_record_count) | |||
| put "m_current_index := " & m_current_index | |||
| put "m_record_count := " & m_record_count | |||
| End Function | |||
| Public Function PeekNext | |||
| if HasNext then | |||
| m_rs.MoveNext | |||
| Assign PeekNext, GetPairs | |||
| m_rs.MovePrevious | |||
| else | |||
| set PeekNext = Nothing | |||
| end if | |||
| End Function | |||
| Private Function GetPairs | |||
| End Function | |||
| Public Function GetNext | |||
| if m_current_index < m_record_count then | |||
| Assign GetNext, m_rs | |||
| m_rs.MoveNext | |||
| m_current_index = m_current_index + 1 | |||
| else | |||
| set GetNext = Nothing | |||
| end if | |||
| End Function | |||
| Public Function HasPrev() | |||
| if m_rs.BOF then | |||
| HasPrev = false | |||
| else | |||
| m_rs.MovePrevious | |||
| HasPrev = Choice(m_rs.BOF, false, true) | |||
| m_rs.MoveNext | |||
| end if | |||
| End Function | |||
| Public Function PeekPrev | |||
| m_rs.MovePrevious | |||
| if m_rs.BOF then | |||
| set PeekPrev = Nothing | |||
| else | |||
| Assign PeekPrev, m_rs | |||
| end if | |||
| m_rs.MoveNext | |||
| End Function | |||
| Public Function GetPrev | |||
| m_rs.MovePrevious | |||
| if m_rs.BOF then | |||
| set GetPrev = Nothing | |||
| else | |||
| Assign GetPrev, m_rs | |||
| end if | |||
| End Function | |||
| End Class | |||
| Class Iterator_Dictionary_Class | |||
| Private m_dic | |||
| Private m_keys 'array | |||
| Private m_idx 'current array index | |||
| Private m_keys_ubound 'cached ubound(m_keys) | |||
| Public Sub Initialize(ByVal dic) | |||
| set m_dic = dic | |||
| m_keys = m_dic.Keys() | |||
| m_idx = -1 | |||
| m_keys_ubound = ubound(m_keys) | |||
| End Sub | |||
| Private Sub Class_Terminate | |||
| set m_dic = Nothing | |||
| End Sub | |||
| Public Function HasNext() | |||
| HasNext = (m_idx < m_keys_ubound) | |||
| End Function | |||
| Public Function PeekNext() | |||
| Assign PeekNext, m_dic(m_keys(m_idx + 1)) | |||
| End Function | |||
| Public Function GetNext() | |||
| Assign GetNext, m_dic(m_keys(m_idx + 1)) | |||
| m_idx = m_idx + 1 | |||
| End Function | |||
| Public Function HasPrev() | |||
| HasPrev = (m_idx > 0) | |||
| End Function | |||
| Public Function PeekPrev() | |||
| Assign PeekPrev, m_dic(m_keys(m_idx - 1)) | |||
| End Function | |||
| Public Function GetPrev() | |||
| Assign GetPrev, m_dic(m_keys(m_idx - 1)) | |||
| m_idx = m_idx - 1 | |||
| End Function | |||
| End Class | |||
| '======================================================================================================================= | |||
| ' Iterator Factory | |||
| '======================================================================================================================= | |||
| 'Returns the appropriate iterator for the passed-in collection. Errors if unknown collection. | |||
| Function IteratorFor(col) | |||
| dim result | |||
| select case typename(col) | |||
| case "LinkedList_Class" : set result = new Iterator_LinkedList_Class | |||
| case "Dictionary" : set result = new Iterator_Dictionary_Class | |||
| case "Recordset" : set result = new Iterator_Recordset_Class | |||
| end select | |||
| result.Initialize col | |||
| set IteratorFor = result | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,95 @@ | |||
| <% | |||
| Class Database_Class | |||
| Private m_connection | |||
| Private m_connection_string | |||
| Private m_trace_enabled | |||
| Public Sub set_trace(bool) : m_trace_enabled = bool : End Sub | |||
| Public Property Get is_trace_enabled : is_trace_enabled = m_trace_enabled : End Property | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Initialize(connection_string) | |||
| m_connection_string = connection_string | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Function Query(sql, params) | |||
| dim cmd : set cmd = server.createobject("adodb.command") | |||
| set cmd.ActiveConnection = Connection | |||
| cmd.CommandText = sql | |||
| dim rs | |||
| If IsArray(params) then | |||
| set rs = cmd.Execute(, params) | |||
| ElseIf Not IsEmpty(params) then ' one parameter | |||
| set rs = cmd.Execute(, Array(params)) | |||
| Else | |||
| set rs = cmd.Execute() | |||
| End If | |||
| set Query = rs | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Function PagedQuery(sql, params, per_page, page_num) | |||
| dim cmd : set cmd = server.createobject("adodb.command") | |||
| set cmd.ActiveConnection = Connection | |||
| cmd.CommandText = sql | |||
| cmd.CommandType = 1 'adCmdText | |||
| cmd.ActiveConnection.CursorLocation = 3 'adUseClient | |||
| dim rs | |||
| If IsArray(params) then | |||
| set rs = cmd.Execute(, params) | |||
| ElseIf Not IsEmpty(params) then ' one parameter | |||
| set rs = cmd.Execute(, Array(params)) | |||
| Else | |||
| set rs = cmd.Execute() | |||
| End If | |||
| If Not rs.EOF then | |||
| rs.PageSize = 1 | |||
| rs.CacheSize = 1 | |||
| rs.AbsolutePage = 1 | |||
| End If | |||
| set PagedQuery = rs | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub [Execute](sql, params) | |||
| me.query sql, params | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub BeginTransaction | |||
| Connection.BeginTrans | |||
| End Sub | |||
| Public Sub RollbackTransaction | |||
| Connection.RollbackTrans | |||
| End Sub | |||
| Public Sub CommitTransaction | |||
| Connection.CommitTrans | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Private Methods | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Private Sub Class_terminate | |||
| Destroy m_connection | |||
| End Sub | |||
| Private Function Connection | |||
| if not isobject(m_connection) then | |||
| set m_connection = Server.CreateObject("adodb.connection") | |||
| m_connection.open m_connection_string | |||
| end if | |||
| set Connection = m_connection | |||
| End Function | |||
| end Class | |||
| %> | |||
| @@ -0,0 +1,202 @@ | |||
| <% | |||
| Class EnumerableHelper_Class | |||
| Private m_list | |||
| Public Sub Init(list) | |||
| set m_list = list | |||
| End Sub | |||
| Public Sub Class_Terminate | |||
| set m_list = Nothing | |||
| End Sub | |||
| Public Default Function Data() | |||
| set Data = m_list | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Convenience wrappers | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Function Count() | |||
| Count = m_list.Count() | |||
| End Function | |||
| Public Function First() | |||
| Assign First, m_list.Front() | |||
| End Function | |||
| Public Function Last() | |||
| Assign Last, m_list.Back() | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Methods that return a single value | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'true if all elements of the list satisfy the condition | |||
| Public Function All(condition) | |||
| dim item_, all_matched : all_matched = true | |||
| dim it : set it = m_list.Iterator | |||
| Do While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| If "String" = typename(condition) then | |||
| If Not eval(condition) then | |||
| all_matched = false | |||
| End If | |||
| Else | |||
| If Not condition(item_) then | |||
| all_matched = false | |||
| End If | |||
| End If | |||
| If Not all_matched then Exit Do | |||
| Loop | |||
| All = all_matched | |||
| End Function | |||
| 'true if any element of the list satisfies the condition | |||
| Public Function Any(condition) | |||
| Any = Not All("Not " & condition) | |||
| End Function | |||
| Public Function Max(expr) | |||
| dim V_, item_, maxval | |||
| dim it : set it = m_list.Iterator | |||
| If "String" = typename(expr) then | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| Assign V_, eval(expr) | |||
| If V_ > maxval then maxval = V_ | |||
| Wend | |||
| Else | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| Assign V_, expr(item_) | |||
| If V_ > maxval then maxval = V_ | |||
| Wend | |||
| End If | |||
| Max = maxval | |||
| End Function | |||
| Public Function Min(expr) | |||
| dim V_, item_, minval | |||
| dim it : set it = m_list.Iterator | |||
| If "String" = typename(expr) then | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| If IsEmpty(minval) then ' empty is always less than everything so set it on first pass | |||
| Assign minval, item_ | |||
| End If | |||
| Assign V_, eval(expr) | |||
| If V_ < minval then minval = V_ | |||
| Wend | |||
| Else | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| If IsEmpty(minval) then | |||
| Assign minval, item_ | |||
| End If | |||
| V_ = expr(item_) | |||
| If V_ < minval then minval = V_ | |||
| Wend | |||
| End If | |||
| Min = minval | |||
| End Function | |||
| Public Function Sum(expr) | |||
| dim V_, item_ | |||
| dim it : set it = m_list.Iterator | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| execute "V_ = V_ + " & expr | |||
| Wend | |||
| Sum = V_ | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Methods that return a new instance of this class | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'returns a list that results from running lambda_or_proc once for every element in the list | |||
| Public Function Map(lambda_or_proc) | |||
| dim list2 : set list2 = new LinkedList_Class | |||
| dim it : set it = m_list.Iterator | |||
| dim item_ | |||
| If "String" = typename(lambda_or_proc) then | |||
| dim V_ | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| execute lambda_or_proc | |||
| list2.Push V_ | |||
| Wend | |||
| Else | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| list2.Push lambda_or_proc(item_) | |||
| Wend | |||
| End If | |||
| set Map = Enumerable(list2) | |||
| End Function | |||
| 'alias to match IEnumerable for convenience | |||
| Public Function [Select](lambda_or_proc) | |||
| set [Select] = Map(lambda_or_proc) | |||
| End Function | |||
| 'returns list containing first n items | |||
| Public Function Take(n) | |||
| dim list2 : set list2 = new LinkedList_Class | |||
| dim it : set it = m_list.Iterator | |||
| dim i : i = 1 | |||
| While it.HasNext And i <= n | |||
| list2.Push it.GetNext() | |||
| i = i + 1 | |||
| Wend | |||
| set Take = Enumerable(list2) | |||
| End Function | |||
| 'returns list containing elements as long as the condition is true, and skips the remaining elements | |||
| Public Function TakeWhile(condition) | |||
| dim list2 : set list2 = new LinkedList_Class | |||
| dim item_, V_, bln | |||
| dim it : set it = m_list.Iterator | |||
| Do While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| If "String" = typename(condition) then | |||
| 'execute condition | |||
| If Not eval(condition) then Exit Do | |||
| Else | |||
| If Not condition(item_) then Exit Do | |||
| End If | |||
| list2.Push item_ | |||
| Loop | |||
| set TakeWhile = Enumerable(list2) | |||
| End Function | |||
| 'returns a list containing only elements that satisfy the condition | |||
| Public Function Where(condition) | |||
| dim list2 : set list2 = new LinkedList_Class | |||
| dim it : set it = m_list.Iterator | |||
| dim item_ | |||
| While it.HasNext | |||
| Assign item_, it.GetNext() | |||
| If "String" = typename(condition) then | |||
| If eval(condition) then list2.Push item_ | |||
| Else | |||
| If condition(item_) then list2.Push item_ | |||
| End If | |||
| Wend | |||
| set Where = Enumerable(list2) | |||
| End Function | |||
| End Class | |||
| Function Enumerable(list) | |||
| dim E : set E = new EnumerableHelper_Class | |||
| E.Init list | |||
| set Enumerable = E | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,118 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Flash Message Class | |||
| '======================================================================================================================= | |||
| Class Flash_Class | |||
| Private m_errors_key | |||
| Private m_success_key | |||
| Private Sub Class_Initialize | |||
| m_errors_key = "mvc.flash.errors_array" | |||
| m_success_key = "mvc.flash.success_message" | |||
| End Sub | |||
| 'helper methods to avoid if..then statements in views | |||
| Public Sub ShowErrorsIfPresent | |||
| if HasErrors then ShowErrors | |||
| End Sub | |||
| Public Sub ShowSuccessIfPresent | |||
| if HasSuccess then ShowSuccess | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Errors | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Property Get HasErrors | |||
| HasErrors = (Not IsEmpty(Session(m_errors_key))) | |||
| End Property | |||
| Public Property Get Errors | |||
| Errors = Session(m_errors_key) | |||
| End Property | |||
| Public Property Let Errors(ary) | |||
| Session(m_errors_key) = ary | |||
| End Property | |||
| Public Sub AddError(msg) | |||
| dim ary | |||
| if IsEmpty(Session(m_errors_key)) then | |||
| ary = Array() | |||
| redim ary(-1) | |||
| else | |||
| ary = Session(m_errors_key) | |||
| end if | |||
| redim preserve ary(ubound(ary) + 1) | |||
| ary(ubound(ary)) = msg | |||
| Session(m_errors_key) = ary | |||
| End Sub | |||
| 'Public Sub ShowErrors | |||
| ' ClearErrors | |||
| 'End Sub | |||
| Public Sub ShowErrors | |||
| if HasErrors then | |||
| %> | |||
| <div class="alert alert-error"> | |||
| <button type="button" class="close" data-dismiss="alert">×</button> | |||
| <h4>Error!</h4> | |||
| <ul> | |||
| <% | |||
| dim ary, i | |||
| ary = Errors | |||
| for i = 0 to ubound(ary) | |||
| put "<li>" | |||
| put H(ary(i)) | |||
| put "</li>" | |||
| next | |||
| %> | |||
| </ul> | |||
| </div> | |||
| <% | |||
| ClearErrors | |||
| end if | |||
| End Sub | |||
| Public Sub ClearErrors | |||
| Session.Contents.Remove(m_errors_key) | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Success | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Property Get HasSuccess | |||
| HasSuccess = (Not IsEmpty(Session(m_success_key))) | |||
| End Property | |||
| Public Property Get Success | |||
| Success = Session(m_success_key) | |||
| End Property | |||
| Public Property Let Success(msg) | |||
| Session(m_success_key) = msg | |||
| End Property | |||
| Public Sub ShowSuccess | |||
| if HasSuccess then | |||
| %> | |||
| <div class="alert alert-success"> | |||
| <button type="button" class="close" data-dismiss="alert">×</button> | |||
| <%= H(Success) %> | |||
| </div> | |||
| <% | |||
| ClearSuccess | |||
| end if | |||
| End Sub | |||
| Public Sub ClearSuccess | |||
| Session.Contents.Remove(m_success_key) | |||
| End Sub | |||
| End Class | |||
| Function Flash() | |||
| set Flash = new Flash_Class | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,67 @@ | |||
| <% | |||
| Class FormCache_Class | |||
| 'given a form name and IRequestDictionary params (request.form) object, caches form values | |||
| Public Sub SerializeForm(form_name, params) | |||
| dim form_key, form_val, serialized_key | |||
| For Each form_key in params | |||
| form_val = params(form_key) | |||
| serialized_key = CachedFormKeyName(form_name, form_key) | |||
| 'put "serialize<br>" | |||
| 'put "--form_key := " & form_key & "<br>" | |||
| 'put "--form_val := " & form_val & "<br>" | |||
| 'put "--serialized_key := " & serialized_key & "<br>" | |||
| Session(serialized_key) = form_val | |||
| Next | |||
| End Sub | |||
| 'given a form name, returns a dict with the form's stored values | |||
| Public Function DeserializeForm(form_name) | |||
| dim dict : set dict = Nothing | |||
| dim serialized_key, serialized_val, form_key, form_val | |||
| For Each serialized_key in Session.Contents | |||
| 'put "serialized_key: " & serialized_key & "<br>" | |||
| If InStr(serialized_key, "mvc.form." & form_name) > 0 then | |||
| 'put "--match" & "<br>" | |||
| If dict Is Nothing then | |||
| set dict = Server.CreateObject("Scripting.Dictionary") | |||
| 'put "dict created<br>" | |||
| End If | |||
| form_val = Session(serialized_key) | |||
| form_key = Replace(serialized_key, "mvc.form." & form_name & ".", "") | |||
| dict(form_key) = form_val | |||
| 'Session.Contents.Remove serialized_key | |||
| 'put "--serialized_val: " & serialized_val & "<br>" | |||
| 'put "--form_val: " & form_val & "<br>" | |||
| End If | |||
| Next | |||
| set DeserializeForm = dict | |||
| End Function | |||
| 'given a form name, clears the keys for that form | |||
| Public Sub ClearForm(form_name) | |||
| dim key | |||
| For Each key in Session.Contents | |||
| If InStr(key, CachedFormKeyName(form_name, key)) > 0 then | |||
| Session.Contents.Remove key | |||
| End If | |||
| Next | |||
| End Sub | |||
| Private Function CachedFormKeyName(form_name, key) | |||
| CachedFormKeyName = "mvc.form." & form_name & "." & key | |||
| End Function | |||
| End Class | |||
| dim FormCache__Singleton | |||
| Function FormCache() | |||
| if IsEmpty(FormCache__Singleton) then | |||
| set FormCache__Singleton = new FormCache_Class | |||
| end if | |||
| set FormCache = FormCache__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,260 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' HTML HELPER | |||
| '======================================================================================================================= | |||
| Class HTML_Helper_Class | |||
| 'Duplicate of Routes.NoCacheToken, copied to avoid extra lookup into the Routes object for such a trivial function. | |||
| 'Allows caller to reference HTML.NoCacheToken in cases where it seems to feel right. | |||
| Public Property Get NoCacheToken | |||
| NoCacheToken = Timer() * 100 | |||
| End Property | |||
| 'Ensures safe output | |||
| Public Function Encode(ByVal value) | |||
| If Not IsEmpty(value) and Not IsNull(value) then | |||
| Encode = Server.HtmlEncode(value) | |||
| End If | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'LinkTo and its relatives DO NOT HTMLEncode the link_text! This allows use of HTML within the link, especially | |||
| 'useful for Bootstrap icons and the like. | |||
| ' | |||
| 'Bottom Line: If you need to HTMLEncode the link text YOU MUST DO IT YOURSELF! The H() method makes this easy! | |||
| Public Function LinkTo(link_text, controller_name, action_name) | |||
| LinkTo = LinkToExt(link_text, controller_name, action_name, empty, empty) | |||
| End Function | |||
| Public Function LinkToExt(link_text, controller_name, action_name, params_array, attribs_array) | |||
| LinkToExt = "<a href='" & Encode(Routes.UrlTo(controller_name, action_name, params_array)) & "'" &_ | |||
| HtmlAttribs(attribs_array) & ">" & link_text & "</a>" & vbCR | |||
| End Function | |||
| Public Function LinkToIf(condition, link_text, controller_name, action_name) | |||
| if condition then | |||
| LinkToIf = LinkToExt(link_text, controller_name, action_name, empty, empty) | |||
| end if | |||
| End Function | |||
| Public Function LinkToExtIf(condition, link_text, controller_name, action_name, params_array, attribs_array) | |||
| if condition then | |||
| LinkToExtIf = LinkToExt(link_text, controller_name, action_name, params_array, attribs_array) | |||
| end if | |||
| End Function | |||
| Public Function LinkToUnless(condition, link_text, controller_name, action_name) | |||
| if not condition then | |||
| LinkToIf = LinkToExt(link_text, controller_name, action_name, empty, empty) | |||
| end if | |||
| End Function | |||
| Public Function LinkToExtUnless(condition, link_text, controller_name, action_name, params_array, attribs_array) | |||
| if not condition then | |||
| LinkToExtUnless = LinkToExt(link_text, controller_name, action_name, params_array, attribs_array) | |||
| end if | |||
| End Function | |||
| '' | |||
| ' Creates a form button and a hidden form to enforce POST submissions. Params are in hidden fields. | |||
| '' | |||
| 'Public Function PostButtonLinkTo(controller_name, action_name, params) | |||
| ' dim id : id = "post_button__" & controller_name & action_name | |||
| ' dim s | |||
| ' s = "<form id='" & id & "' action='" & Routes.UrlTo(controller_name, action_name, empty) & "' method='POST'>" | |||
| ' dim i, key, val | |||
| ' for i = 0 to ubound(params) step 2 | |||
| ' KeyVal params, i, key, val | |||
| ' s = s & "<input type='hidden' name='" & key & "' value='" & val & "'>" | |||
| ' next | |||
| ' s = s & "<input type='submit' value='>>'>" | |||
| ' s = s & "</form>" | |||
| ' PostButtonLinkTo = s | |||
| 'End Function | |||
| Public Function PostButtonTo(button_contents, controller_name, action_name, form_fields) | |||
| PostButtonTo = PostButtonToExt(button_contents, controller_name, action_name, form_fields, empty) | |||
| End Function | |||
| Public Function PostButtonToExt(button_contents, controller_name, action_name, form_fields, url_params) | |||
| dim s : s = "<form action='" & Routes.UrlTo(controller_name, action_name, url_params) & "' method='POST' style='margin: 0;'>" | |||
| dim i, key, val | |||
| for i = 0 to ubound(form_fields) step 2 | |||
| KeyVal form_fields, i, key, val | |||
| s = s & HTML.Hidden(key, val) | |||
| next | |||
| s = s & HTML.SubmitButton(button_contents) | |||
| s = s & "</form>" & vbCR | |||
| PostButtonToExt = s | |||
| End Function | |||
| Public Function AppStylesheetTag | |||
| AppStylesheetTag = StylesheetTag(Routes.StylesheetsURL & "App.css") | |||
| End Function | |||
| Public Function ControllerStylesheetTag | |||
| ControllerStylesheetTag = StylesheetTag(Routes.StylesheetsUrl & MVC.ControllerName & "Controller.css") | |||
| End Function | |||
| Public Function StylesheetTag(url) | |||
| StylesheetTag = "<link rel='stylesheet' href='" & Encode(url) & "?" & Year(now) & Month(now) & Day(now) & Hour(now) & Minute(now) & Second(now) & "'>" & vbCR | |||
| End Function | |||
| Public Function JSTag(url) | |||
| JSTag = "<script type='text/javascript' src='" & Encode(url) & "'></script>" & vbCR | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Form Helpers | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Function FormTag(controller_name, action_name, route_attribs, form_attribs) | |||
| FormTag = "<form action='" & Routes.UrlTo(controller_name, action_name, route_attribs) & "' method='POST' " & HtmlAttribs(form_attribs) & ">" & vbCR | |||
| End Function | |||
| Public Function Label(name, for_name) | |||
| Label = LabelExt(name, for_name, empty) | |||
| End Function | |||
| Public Function LabelExt(name, for_name, attribs) | |||
| LabelExt = "<label for='" & Encode(for_name) & "' " & HtmlAttribs(attribs) & ">" & Encode(name) & "</label>" & vbCR | |||
| End Function | |||
| Public Function Hidden(id, value) | |||
| Hidden = HiddenExt(id, value, empty) | |||
| End Function | |||
| Public Function HiddenExt(id, value, attribs) | |||
| HiddenExt = "<input type='hidden' id='" & Encode(id) & "' name='" & Encode(id) & "' value='" & Encode(value) & "' " & HtmlAttribs(attribs) & " >" & vbCR | |||
| End Function | |||
| Public Function TextBox(id, value) | |||
| TextBox = TextBoxExt(id, value, empty) | |||
| End Function | |||
| Public Function TextBoxExt(id, value, attribs) | |||
| TextBoxExt = "<input type='text' id='" & Encode(id) & "' name='" & Encode(id) & "' value='" & Encode(value) & "' " & HtmlAttribs(attribs) & " >" & vbCR | |||
| End Function | |||
| Public Function TextArea(id, value, rows, cols) | |||
| TextArea = TextAreaExt(id, value, rows, cols, empty) | |||
| End Function | |||
| Public Function TextAreaExt(id, value, rows, cols, attribs) | |||
| TextAreaExt = "<textarea id='" & Encode(id) & "' name='" & Encode(id) & "' cols='" & Encode(cols) & "' rows='" & Encode(rows) & "' " & HtmlAttribs(attribs) & " >" &_ | |||
| Encode(value) & "</textarea>" & vbCR | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'If list is a recordset then option_value_field and option_text_field are required. | |||
| 'If list is an array the method assumes it is a KVArray and those parameters are ignored. | |||
| Public Function DropDownList(id, selected_value, list, option_value_field, option_text_field) | |||
| DropDownList = DropDownListExt(id, selected_value, list, option_value_field, option_text_field, empty) | |||
| End Function | |||
| Public Function DropDownListExt(id, selected_value, list, option_value_field, option_text_field, attribs) | |||
| If IsNull(selected_value) then | |||
| selected_value = "" | |||
| Else | |||
| selected_value = CStr(selected_value) | |||
| End If | |||
| dim item, options, opt_val, opt_txt | |||
| options = "<option value=''>" ' first value is "non-selected" blank state | |||
| select case typename(list) | |||
| case "Recordset" | |||
| do until list.EOF | |||
| If IsNull(list(option_value_field)) then | |||
| opt_val = "" | |||
| Else | |||
| opt_val = CStr(list(option_value_field)) | |||
| End If | |||
| opt_txt = list(option_text_field) | |||
| If Not IsNull(opt_val) And Not IsEmpty(opt_val) then | |||
| options = options & "<option value='" & Encode(opt_val) & "' " & Choice((CStr(opt_val) = CStr(selected_value)), "selected='selected'", "") & ">" & Encode(opt_txt) & "</option>" & vbCR | |||
| End If | |||
| list.MoveNext | |||
| loop | |||
| case "Variant()" 'assumes KVArray | |||
| dim i | |||
| for i = 0 to ubound(list) step 2 | |||
| KeyVal list, i, opt_val, opt_txt | |||
| options = options & "<option value='" & Encode(opt_val) & "' " & Choice((CStr(opt_val) = CStr(selected_value)), "selected='selected'", "") & ">" & Encode(opt_txt) & "</option>" & vbCR | |||
| next | |||
| end select | |||
| DropDownListExt = "<select id='" & Encode(id) & "' name='" & Encode(id) & "' " & HtmlAttribs(attribs) & " >" & vbCR & options & "</select>" & vbCR | |||
| End Function | |||
| Public Function Checkbox(id, value) | |||
| Checkbox = CheckboxExt(id, value, empty) | |||
| End Function | |||
| Public Function CheckboxExt(id, value, attribs) | |||
| CheckBoxExt = "<input type='checkbox' id='" & Encode(id) & "' name='" & Encode(id) & "' " & Choice( (value = 1) or (value = true) or (LCase(value) = "true") or (LCase(value) = "on"), "checked='checked'", "") & " " & HtmlAttribs(attribs) & ">" & vbCR | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Button text IS NOT ENCODED! As with LinkTo, this allows use of Bootstrap icons and other arbitrary HTML in the | |||
| 'button. If you need to HTMLEncode the text you MUST do it yourself! | |||
| Public Function SubmitButton(text) | |||
| SubmitButton = "<button type='submit' class='btn'>" & text & "</button>" & vbCR | |||
| End Function | |||
| Public Function Button(button_type, text, class_name) | |||
| Button = "<button type='" & Encode(button_type) & "' class='btn " & Encode(class_name) & "'>" & text & "</button>" & vbCR | |||
| End Function | |||
| Public Function ButtonExt(button_type, text, attribs_array) | |||
| ButtonExt = "<button type='" & Encode(button_type) & "' " & HtmlAttribs(attribs_array) & ">" & text & "</button>" & vbCR | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Function Tag(Tag_name, attribs_array) | |||
| Tag = "<" & Encode(tag_name) & " " & HtmlAttribs(attribs_array) & ">" | |||
| End Function | |||
| Public Function Tag_(Tag_name) | |||
| Tag_ = "</" & Encode(tag_name) & ">" | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Function HtmlAttribs(attribs) | |||
| dim result : result = "" | |||
| if not IsEmpty(attribs) then | |||
| if IsArray(attribs) then | |||
| dim idx | |||
| for idx = lbound(attribs) to ubound(attribs) step 2 | |||
| result = result & " " & HtmlAttrib(attribs, idx) & " " | |||
| next | |||
| else ' assume string or string-like default value | |||
| result = attribs | |||
| end if | |||
| end if | |||
| HtmlAttribs = result | |||
| End Function | |||
| Public Function HtmlAttrib(attribs_array, key_idx) | |||
| dim key, val | |||
| KeyVal attribs_array, key_idx, key, val | |||
| HtmlAttrib = Encode(key) & "='" & Encode(val) & "'" | |||
| End Function | |||
| End Class | |||
| dim HTML_Helper__Singleton : set HTML_Helper__Singleton = Nothing | |||
| Function HTML() | |||
| if HTML_Helper__Singleton Is Nothing then | |||
| set HTML_Helper__Singleton = new HTML_Helper_Class | |||
| End if | |||
| set HTML = HTML_Helper__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,77 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' HTML SECURITY HELPER | |||
| '======================================================================================================================= | |||
| Class HTML_Security_Helper_Class | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Uses Scriptlet.TypeLib to generate a GUID. There may be a better/faster way than this to generate a nonce. | |||
| Public Function Nonce() | |||
| dim TL : set TL = CreateObject("Scriptlet.TypeLib") | |||
| Nonce = Left(CStr(TL.Guid), 38) 'avoids issue w/ strings appended after this token not being displayed on screen, MSFT bug | |||
| set TL = Nothing | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Name is probably the combined ControllerName and ActionName of the form generator by convention | |||
| Public Sub SetAntiCSRFToken(name) | |||
| Session(name & ".anti_csrf_token") = Nonce() | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Returns the CSRF token nonce from the session corresponding to the passed name | |||
| Public Function GetAntiCSRFToken(name) | |||
| dim token : token = Session(name & ".anti_csrf_token") | |||
| If Len(token) = 0 then | |||
| SetAntiCSRFToken name | |||
| End If | |||
| GetAntiCSRFToken = token | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Removes the current CSRF token nonce for the passed name | |||
| Public Sub ClearAntiCSRFToken(name) | |||
| Session.Contents.Remove(name & ".anti_csrf_token") | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Returns true if passed nonce matches the stored CSRF token nonce for the specified name, false if not | |||
| Public Function IsValidAntiCSRFToken(name, nonce) | |||
| IsValidAntiCSRFToken = (GetAntiCSRFToken(name) = nonce) | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'If an invalid CSRF nonce is passed, sets the flash and redirects using the appropriate MVC.Redirect* method. | |||
| 'If a valid CSRF nonce is passed, clears it from the cache to reset the state to the beginning. | |||
| Public Sub OnInvalidAntiCSRFTokenRedirectToAction(token_name, token, action_name) | |||
| OnInvalidAntiCSRFTokenRedirectToExt token_name, token, MVC.ControllerName, action_name, empty | |||
| End Sub | |||
| Public Sub OnInvalidAntiCSRFTokenRedirectToActionExt(token_name, token, action_name, params) | |||
| OnInvalidAntiCSRFTokenRedirectToExt token_name, token, MVC.ControllerName, action_name, params | |||
| End Sub | |||
| Public Sub OnInvalidAntiCSRFTokenRedirectTo(token_name, token, controller_name, action_name) | |||
| OnInvalidAntiCSRFTokenRedirectToExt token_name, token, controller_name, action_name | |||
| End Sub | |||
| Public Sub OnInvalidAntiCSRFTokenRedirectToExt(token_name, token, controller_name, action_name, params) | |||
| If IsValidAntiCSRFToken(token_name, token) then | |||
| ClearAntiCSRFToken token_name | |||
| Else | |||
| ClearAntiCSRFToken token_name | |||
| Flash.AddError "Invalid form state. Please try again." | |||
| MVC.RedirectToExt controller_name, action_name, params | |||
| End If | |||
| End Sub | |||
| End Class | |||
| dim HTML_Security_Helper__Singleton | |||
| Function HTMLSecurity() | |||
| If IsEmpty(HTML_Security_Helper__Singleton) Then | |||
| set HTML_Security_Helper__Singleton = new HTML_Security_Helper_Class | |||
| End If | |||
| set HTMLSecurity = HTML_Security_Helper__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,361 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' IO Helpers | |||
| '======================================================================================================================= | |||
| Sub put(v) | |||
| Select Case typename(v) | |||
| Case "LinkedList_Class" : response.write join(v.TO_Array, ", ") | |||
| Case "DynamicArray_Class" : response.write JoinList(v) | |||
| Case "Variant()" : response.write join(v, ", ") | |||
| Case else : response.write v | |||
| End Select | |||
| End Sub | |||
| Sub put_ | |||
| put "<br>" | |||
| End Sub | |||
| Sub putl(v) | |||
| put v | |||
| put_ | |||
| End Sub | |||
| 'accepts anything that can have an iterator, including lists, arrays, and recordsets | |||
| Sub putlist(col, prefix, suffix) | |||
| dim it : set it = IteratorFor(col) | |||
| Do While it.HasNext | |||
| put prefix & it.GetNext & suffix | |||
| Loop | |||
| End Sub | |||
| 'same as join() for arrays, but for any arbitrary collection | |||
| Function JoinList(col) | |||
| dim s : s = "" | |||
| dim it : set it = IteratorFor(col) | |||
| Do While it.HasNext | |||
| s = s & ", " | |||
| Loop | |||
| JoinList = Left(s, Len(s) - 2) | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Wrapper for Server.HTMLEncode() -- makes it easier on the eyes when reading the HTML code | |||
| Function H(s) | |||
| If Not IsEmpty(s) and Not IsNull(s) then | |||
| H = Server.HTMLEncode(s) | |||
| Else | |||
| H = "" | |||
| End If | |||
| End Function | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| 'allows tracing of output on demand without interfering with layout | |||
| Sub trace(s) | |||
| comment s | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| 'outputs an HTML comment, useful for tracing etc | |||
| Sub Comment(text) | |||
| response.write vbcrlf & vbcrlf & "<!--" & vbcrlf & H(text) & vbcrlf & "-->" & vbcrlf & vbcrlf | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| 'pseudo-design-by-contract capability, allows strong-typing of methods and views | |||
| Sub ExpectType(obj_type, obj) | |||
| if typename(obj) <> obj_type then Err.Raise 1, "lib.Helpers:ExpectType", "View expected object of type '" & obj_type & "' but received type '" & typename(obj) & "'." | |||
| End Sub | |||
| '======================================================================================================================= | |||
| ' Dump* functions for dumping variables, objects, lists, etc for debugging purposes | |||
| '======================================================================================================================= | |||
| Class DataDumper_Class | |||
| Public Sub Dump(V) | |||
| put "<pre>" | |||
| DumpIt V | |||
| put "</pre>" | |||
| End Sub | |||
| Private m_indent | |||
| Private Sub Indent | |||
| m_indent = m_indent + 1 | |||
| 'putl "INDENT: " & m_indent | |||
| 'puti m_indent | |||
| 'put_ | |||
| End Sub | |||
| Private Sub Dedent | |||
| m_indent = m_indent - 1 | |||
| 'putl "INDENT: " & m_indent | |||
| End Sub | |||
| Private Sub Class_Initialize | |||
| m_indent = -1 'first indent takes it to 0 | |||
| End Sub | |||
| 'prepends indents | |||
| Private Sub puti(v) | |||
| put Spaces(m_indent) & v | |||
| End Sub | |||
| Private Sub DumpIt(V) | |||
| If Typename(V) = "LinkedList_Class" then | |||
| DumpList V | |||
| ElseIf Instr(Typename(V), "_Class") > 0 then | |||
| DumpClass V | |||
| ElseIf Typename(V) = "Variant()" then | |||
| DumpArray V | |||
| ElseIf Typename(V) = "Recordset" then | |||
| DumpRecordset V | |||
| Else | |||
| put "«" & H(V) & "»" | |||
| End If | |||
| End Sub | |||
| Private Sub DumpList(V) | |||
| Indent | |||
| dim it : set it = V.Iterator | |||
| dim item | |||
| dim i : i = 1 | |||
| put_ | |||
| puti "[List:" & vbCR | |||
| While it.HasNext | |||
| Indent | |||
| set item = it.GetNext() | |||
| puti i & " => " | |||
| DumpIt item | |||
| put_ | |||
| Dedent | |||
| i = i + 1 | |||
| Wend | |||
| puti "]" | |||
| Dedent | |||
| End Sub | |||
| Private Sub DumpArray(V) | |||
| Indent | |||
| dim i | |||
| put_ | |||
| puti "[Array:" & vbCR | |||
| Indent | |||
| For i = 0 to UBound(V) | |||
| puti i & " => " | |||
| DumpIt V(i) | |||
| put_ | |||
| Next | |||
| Dedent | |||
| puti "]" | |||
| Dedent | |||
| End Sub | |||
| Private Sub DumpClass(C) | |||
| Indent | |||
| dim i | |||
| put_ | |||
| puti "{" & Typename(C) & ": " & vbCR | |||
| Indent | |||
| On Error Resume Next | |||
| If Ubound(C.Class_Get_Properties) > 0 then | |||
| dim property_name, the_property | |||
| For i = 0 to UBound(C.Class_Get_Properties) | |||
| property_name = C.Class_Get_Properties(i) | |||
| Execute "Assign the_property, C." & C.Class_Get_Properties(i) | |||
| 'put "property_name: " & property_name & " (" & typename(the_property) & ")" & vbCR | |||
| If typename(the_property) = "LinkedList_Class" then | |||
| puti " " & property_name & " : LinkedList_Class => " | |||
| DumpList(the_property) | |||
| ElseIf InStr(typename(the_property), "_Class") then | |||
| puti " " & property_name & " : " & typename(the_property) & " => " | |||
| DumpClass(the_property) | |||
| Else | |||
| puti " " & property_name & " : " & typename(the_property) & " => " '& Eval("C." & property_name) | |||
| DumpIt(the_property) | |||
| If i <> UBound(C.Class_Get_Properties) then put ", " | |||
| put vbCR | |||
| End If | |||
| Next | |||
| Else | |||
| End If | |||
| On Error Goto 0 | |||
| Dedent | |||
| puti "}" & vbCR & vbCR | |||
| Dedent | |||
| End Sub | |||
| Sub DumpRecordset(R) | |||
| Indent | |||
| dim field | |||
| put "<table border='1' cellpadding='5' >" | |||
| put "<tr style='background-color: #333; color: white'>" | |||
| For each field in R.Fields | |||
| put "<th>" & field.Name & "</th>" | |||
| Next | |||
| put "</tr>" | |||
| Do until R.EOF | |||
| put "<tr style='background-color: white'>" | |||
| For each field in R.Fields | |||
| put "<td>" & H(R(field.Name)) & "</td>" | |||
| Next | |||
| put "</tr>" | |||
| R.MoveNext | |||
| Loop | |||
| put "</table>" | |||
| Dedent | |||
| End Sub | |||
| Private Function Spaces(num) | |||
| dim s : s = "" | |||
| dim i | |||
| For i = 1 to num | |||
| s = s & " " | |||
| Next | |||
| Spaces = s | |||
| End Function | |||
| End Class | |||
| dim DataDumper_Class__Singleton | |||
| Sub Dump(V) | |||
| If IsEmpty(DataDumper_Class__Singleton) then | |||
| set DataDumper_Class__Singleton = new DataDumper_Class | |||
| End If | |||
| DataDumper_Class__Singleton.Dump V | |||
| End Sub | |||
| '======================================================================================================================= | |||
| ' Strings | |||
| '======================================================================================================================= | |||
| 'Capitalizes first word of the_string, leaves rest as-is | |||
| Function Capitalize(the_string) | |||
| Capitalize = ucase(left(the_string, 1)) & mid(the_string, 2) | |||
| End Function | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Function Wrap(s, prefix, suffix) | |||
| Wrap = prefix & s & suffix | |||
| End Function | |||
| '======================================================================================================================= | |||
| ' Logic (i.e. decisions, searches, etc) | |||
| '======================================================================================================================= | |||
| 'TODO: Expand this to accept arbitrary sets, e.g. string, recordset, dictionary, list, etc. | |||
| Function Contains(data, value) | |||
| Contains = false | |||
| dim idx | |||
| select case typename(data) | |||
| case "String" | |||
| Contains = Choice(instr(data, value) > 0, true, false) | |||
| case "Variant()" | |||
| for idx = lbound(data) to ubound(data) | |||
| if value = data(idx) then | |||
| Contains = true | |||
| exit for | |||
| end if | |||
| next | |||
| case else | |||
| Err.Raise 9, "mvc.helpers#Contains", "Unexpected type 'data', received: " & typename(data) | |||
| end select | |||
| End Function | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| 'Boolean type checkers | |||
| 'Don't forget IsArray is built-in! | |||
| Function IsString(value) | |||
| IsString = Choice(typename(value) = "String", true, false) | |||
| End Function | |||
| Function IsDict(value) | |||
| IsDict = Choice(typename(value) = "Dictionary", true, false) | |||
| End Function | |||
| Function IsRecordset(value) | |||
| IsRecordset = Choice(typename(value) = "Recordset", true, false) | |||
| End Function | |||
| Function IsLinkedList(value) | |||
| IsLinkedList = Choice(typename(value) = "LinkedList_Class", true, false) | |||
| End Function | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Sub Destroy(o) | |||
| if isobject(o) then | |||
| if not o is nothing then | |||
| on error resume next | |||
| o.close | |||
| on error goto 0 | |||
| set o = nothing | |||
| end if | |||
| end if | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Sub Quit | |||
| response.end | |||
| End Sub | |||
| Sub Die(msg) | |||
| put "<span style='color: #f00'>" & msg & "</span>" | |||
| Quit | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Sub DumpSession | |||
| put "SESSION" & "<br>" | |||
| dim session_item | |||
| for each session_item in session.contents | |||
| put "<b>" & session_item & "</b> : " & session.contents(session_item) & "<br>" | |||
| next | |||
| End Sub | |||
| '======================================================================================================================= | |||
| ' Adapted from Tolerable library | |||
| '======================================================================================================================= | |||
| ' This subroutine allows us to ignore the difference | |||
| ' between object and primitive assignments. This is | |||
| ' essential for many parts of the engine. | |||
| Public Sub Assign(ByRef var, ByVal val) | |||
| If IsObject(val) Then | |||
| Set var = val | |||
| Else | |||
| var = val | |||
| End If | |||
| End Sub | |||
| ' This is similar to the ? : operator of other languages. | |||
| ' Unfortunately, both the if_true and if_false "branches" | |||
| ' will be evalauted before the condition is even checked. So, | |||
| ' you'll only want to use this for simple expressions. | |||
| Public Function Choice(ByVal cond, ByVal if_true, ByVal if_false) | |||
| If cond Then | |||
| Assign Choice, if_true | |||
| Else | |||
| Assign Choice, if_false | |||
| End If | |||
| End Function | |||
| ' Allows single-quotes to be used in place of double-quotes. | |||
| ' Basically, this is a cheap trick that can make it easier | |||
| ' to specify Lambdas. | |||
| Public Function Q(ByVal input) | |||
| Q = Replace(input, "'", """") | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,168 @@ | |||
| <% | |||
| Response.ExpiresAbsolute = "2000-01-01" | |||
| Response.AddHeader "pragma", "no-cache" | |||
| Response.AddHeader "cache-control", "private, no-cache, must-revalidate" | |||
| '======================================================================================================================= | |||
| ' MVC Dispatcher | |||
| '======================================================================================================================= | |||
| Class MVC_Dispatcher_Class | |||
| Private m_controller_name | |||
| Private m_action_name | |||
| Private m_default_action_name | |||
| Private m_action_params | |||
| Private m_controller_instance | |||
| Private m_is_partial | |||
| Private Sub Class_initialize | |||
| m_default_action_name = "Index" | |||
| SetControllerActionNames | |||
| 'SetActionParams | |||
| End Sub | |||
| Public Property Get ControllerName | |||
| ControllerName = m_controller_name | |||
| end Property | |||
| Public Property Get ActionName | |||
| ActionName = m_action_name | |||
| end Property | |||
| Public Property Get IsPartial | |||
| IsPartial = m_is_partial | |||
| End Property | |||
| 'Public Property Get ActionParams | |||
| ' if IsEmpty(m_action_params) then set m_action_params = Server.CreateObject("Scripting.Dictionary") | |||
| ' set ActionParams = m_action_params | |||
| 'end Property | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Instantiates the controller and executes the requested action on the controller. | |||
| Public Sub Dispatch | |||
| dim class_name : class_name = m_controller_name & "Controller" | |||
| 'set the global controller reference | |||
| executeglobal "dim Controller : set Controller = new " & class_name | |||
| If Request.Querystring("_P").Count = 1 then ' = 1 Or Request.Querystring("_P") = "true" then | |||
| m_is_partial = true | |||
| Else | |||
| m_is_partial = false | |||
| End If | |||
| If Not IsPartial then | |||
| %> | |||
| <!--#include file="../App/Views/Shared/layout.header.asp"--> | |||
| <% | |||
| End If | |||
| ExecuteAction ActionName | |||
| If Not IsPartial then | |||
| %> | |||
| <!--#include file="../App/Views/Shared/layout.footer.asp"--> | |||
| <% | |||
| End If | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Executes the requested action on the current already-instantiated controller | |||
| Private Sub ExecuteAction(action_name) | |||
| ' no longer want to pass Request.Form as a parameter to actions -- allows actions to be called any way, more flexibility | |||
| Execute "Controller." & action_name | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' Ensures an action request comes in via HTTP POST only. Raises error if not. | |||
| Public Sub RequirePost | |||
| If Request.Form.Count = 0 Then Err.Raise 1, "MVC_Helper_Class:RequirePost", "Action only responds to POST requests." | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub RedirectTo(controller_name, action_name) | |||
| RedirectToExt controller_name, action_name, empty | |||
| End Sub | |||
| ' Redirects the browser to the specified action on the specified controller with the specified querystring parameters. | |||
| ' params is a KVArray of querystring parameters. | |||
| Public Sub RedirectToExt(controller_name, action_name, params) | |||
| Response.Redirect Routes.UrlTo(controller_name, action_name, params) | |||
| End Sub | |||
| ' Shortcut for RedirectToActionExt that does not require passing a parameters argument. | |||
| Public Sub RedirectToAction(ByVal action_name) | |||
| RedirectToActionExt action_name, empty | |||
| End Sub | |||
| ' Redirects the browser to the specified action in the current controller, passing the included parameters. | |||
| ' params is a KVArray of querystring parameters. | |||
| Public Sub RedirectToActionExt(ByVal action_name, ByVal params) | |||
| RedirectToExt ControllerName, action_name, params | |||
| End Sub | |||
| ' Redirects to the specified action using a form POST. | |||
| Public Sub RedirectToActionPOST(action_name) | |||
| RedirectToActionExtPOST action_name, empty | |||
| End Sub | |||
| ' Redirects to the specified action name on the current controller using a form post | |||
| Public Sub RedirectToActionExtPOST(action_name, params) | |||
| put "<form id='mvc_redirect_to_action_post' action='" & Routes.UrlTo(ControllerName, action_name, empty) & "' method='POST'>" | |||
| put "<input type='hidden' name='mvc_redirect_to_action_post_flag' value='1'>" | |||
| if Not IsEmpty(params) then | |||
| dim i, key, val | |||
| for i = 0 to ubound(params) step 2 | |||
| KeyVal params, i, key, val | |||
| put "<input type='hidden' name='" & key & "' value='" & val & "'>" | |||
| next | |||
| end if | |||
| put "</form>" | |||
| put "<script type='text/javascript'>" | |||
| put "$('#mvc_redirect_to_action_post').submit();" | |||
| put "</script>" | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' PRIVATE | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Private Sub SetControllerActionNames | |||
| dim full_path : full_path = request.servervariables("path_info") | |||
| dim part_path : part_path = split(full_path, Routes.ControllersUrl)(1) | |||
| dim part_path_split : part_path_split = split(part_path, "/") | |||
| m_controller_name = part_path_split(0) | |||
| m_action_name = Choice(request("_A") <> "", request("_A"), m_default_action_name) | |||
| End Sub | |||
| ' This is deprecated to avoid creating a Dictionary object with every request. | |||
| ' Hasn't been used in forever anyway. | |||
| 'Private Sub SetActionParams | |||
| ' dim key, val | |||
| ' 'set m_action_params = Server.CreateObject("scripting.dictionary") | |||
| ' for each key in request.querystring | |||
| ' val = request.querystring(key) | |||
| ' 'ignore service keys | |||
| ' if instr(1, "_A", key, 1) = 0 then | |||
| ' ActionParams.add key, CStr(val) | |||
| ' end if | |||
| ' next | |||
| 'End Sub | |||
| end Class | |||
| dim MVC_Dispatcher_Class__Singleton | |||
| Function MVC() | |||
| if IsEmpty(MVC_Dispatcher_Class__Singleton) then | |||
| set MVC_Dispatcher_Class__Singleton = new MVC_Dispatcher_Class | |||
| end if | |||
| set MVC = MVC_Dispatcher_Class__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,84 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' ROUTING HELPER | |||
| '======================================================================================================================= | |||
| Class Route_Helper_Class | |||
| Public Property Get NoCacheToken | |||
| NoCacheToken = Timer() * 100 | |||
| End Property | |||
| Public Sub Initialize(app_url) | |||
| m_app_url = app_url | |||
| m_content_url = m_app_url & "Content/" | |||
| m_stylesheets_url = m_content_url & "Styles/" | |||
| m_controllers_url = m_app_url & "Controllers/" | |||
| End Sub | |||
| Public Property Get AppURL | |||
| AppURL = m_app_url | |||
| end Property | |||
| Public Property Get ContentURL | |||
| ContentURL = m_content_url | |||
| end Property | |||
| Public Property Get ControllersURL | |||
| ControllersUrl = m_controllers_url | |||
| end Property | |||
| Public Property Get StylesheetsURL | |||
| StylesheetsURL = m_stylesheets_url | |||
| end Property | |||
| '' | |||
| ' Generates a URL to the specified controller + action combo, with querystring parameters appended if included. | |||
| ' | |||
| ' @param controller_name String name of the controller | |||
| ' @param action_name String name of the controller action | |||
| ' @param params_array KV Array key/value pair array, to be converted to &key1=val1&key2=val2&...&keyn=valn | |||
| ' @returns | |||
| '' | |||
| Public Function UrlTo(controller_name, action_name, params_array) | |||
| dim qs : qs = TO_Querystring(params_array) | |||
| if len(qs) > 0 then qs = "&" & qs | |||
| UrlTo = Me.ControllersURL & controller_name & "/" & controller_name & "Controller.asp?_A=" & action_name & qs & "&_NC=" & NoCacheToken | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' PRIVATE | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Private m_app_url | |||
| Private m_content_url | |||
| Private m_stylesheets_url | |||
| Private m_controllers_url | |||
| Private Function TO_Querystring(the_array) | |||
| dim result : result = "" | |||
| if not isempty(the_array) then | |||
| dim idx | |||
| for idx = lbound(the_array) to ubound(the_array) step 2 | |||
| result = result & GetParam(the_array, idx) | |||
| 'append & between parameters, but not on the last parameter | |||
| if not (idx = ubound(the_array) - 1) then result = result & "&" | |||
| next | |||
| end if | |||
| TO_Querystring = result | |||
| End Function | |||
| Private Function GetParam(params_array, key_idx) | |||
| dim key, val | |||
| KeyVal params_array, key_idx, key, val | |||
| GetParam = key & "=" & val | |||
| End Function | |||
| end class | |||
| dim Route_Helper__Singleton : set Route_Helper__Singleton = Nothing | |||
| Function Routes() | |||
| if Route_Helper__Singleton is Nothing then | |||
| set Route_Helper__Singleton = new Route_Helper_Class | |||
| end if | |||
| set Routes = Route_Helper__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,73 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' StringBuilder Class | |||
| '======================================================================================================================= | |||
| Class StringBuilder_Class | |||
| dim m_array | |||
| dim m_array_size | |||
| dim m_cur_pos | |||
| Private Sub Class_Initialize | |||
| m_array = Array | |||
| m_array_size = 100 | |||
| redim m_array(m_array_size) | |||
| m_cur_pos = -1 | |||
| End Sub | |||
| Private Sub Extend | |||
| m_array_size = m_array_size + 100 | |||
| redim preserve m_array(m_array_size) | |||
| End Sub | |||
| Public Sub Add(s) | |||
| m_cur_pos = m_cur_pos + 1 | |||
| m_array(m_cur_pos) = s | |||
| if m_cur_pos = m_array_size then Extend | |||
| End Sub | |||
| Public Function [Get](delim) | |||
| 'have to create a new array containing only the slots actually used, otherwise Join() happily adds delim | |||
| 'for *every* slot even the unused ones... | |||
| dim new_array : new_array = Array() | |||
| redim new_array(m_cur_pos) | |||
| dim i | |||
| for i = 0 to m_cur_pos | |||
| new_array(i) = m_array(i) | |||
| next | |||
| [Get] = Join(new_array, delim) | |||
| End Function | |||
| Public Default Property Get TO_String | |||
| TO_String = Join(m_array, "") | |||
| End Property | |||
| End Class | |||
| Function StringBuilder() | |||
| set StringBuilder = new StringBuilder_Class | |||
| End Function | |||
| '======================================================================================================================= | |||
| ' Misc | |||
| '======================================================================================================================= | |||
| Function Excerpt(text, length) | |||
| Excerpt = Left(text, length) & " ..." | |||
| End Function | |||
| Function IsBlank(text) | |||
| If IsObject(text) then | |||
| If text Is Nothing then | |||
| IsBlank = true | |||
| Else | |||
| IsBlank = false | |||
| End If | |||
| Else | |||
| If IsEmpty(text) or IsNull(text) or Len(text) = 0 then | |||
| IsBlank = true | |||
| Else | |||
| IsBlank = false | |||
| End If | |||
| End If | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,250 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Validation Classes | |||
| '======================================================================================================================= | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| ' Exists Validation | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Class ExistsValidation_Class | |||
| Private m_instance | |||
| Private m_field_name | |||
| Private m_message | |||
| Private m_ok | |||
| Public Function Initialize(instance, field_name, message) | |||
| set m_instance = instance | |||
| m_field_name = field_name | |||
| m_message = message | |||
| m_ok = true | |||
| set Initialize = Me | |||
| End Function | |||
| Public Sub Check | |||
| If Len(eval("m_instance." & m_field_name)) = 0 then | |||
| m_ok = false | |||
| End If | |||
| End Sub | |||
| Public Property Get OK | |||
| OK = m_ok | |||
| End Property | |||
| Public Property Get Message | |||
| Message = m_message | |||
| End Property | |||
| End Class | |||
| Sub ValidateExists(instance, field_name, message) | |||
| if not IsObject(instance.Validator) then set instance.Validator = new Validator_Class | |||
| instance.Validator.AddValidation new ExistsValidation_Class.Initialize(instance, field_name, message) | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| ' Minimum Length Validation | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Class MinLengthValidation_Class | |||
| Private m_instance | |||
| Private m_field_name | |||
| Private m_size | |||
| Private m_message | |||
| Private m_ok | |||
| Public Function Initialize(instance, field_name, size, message) | |||
| set m_instance = instance | |||
| m_field_name = field_name | |||
| m_size = size | |||
| m_message = message | |||
| m_ok = true | |||
| set Initialize = Me | |||
| End Function | |||
| Public Sub Check | |||
| If Len(eval("m_instance." & m_field_name)) < m_size then m_ok = false | |||
| End Sub | |||
| Public Property Get OK | |||
| OK = m_ok | |||
| End Property | |||
| Public Property Get Message | |||
| Message = m_message | |||
| End Property | |||
| End Class | |||
| Sub ValidateMinLength(instance, field_name, size, message) | |||
| if not IsObject(instance.Validator) then set instance.Validator = new Validator_Class | |||
| instance.Validator.AddValidation new MinLengthValidation_Class.Initialize(instance, field_name, size, message) | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| ' Max Length Validation | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Class MaxLengthValidation_Class | |||
| Private m_instance | |||
| Private m_field_name | |||
| Private m_size | |||
| Private m_message | |||
| Private m_ok | |||
| Public Function Initialize(instance, field_name, size, message) | |||
| set m_instance = instance | |||
| m_field_name = field_name | |||
| m_size = size | |||
| m_message = message | |||
| m_ok = true | |||
| set Initialize = Me | |||
| End Function | |||
| Public Sub Check | |||
| If Len(eval("m_instance." & m_field_name)) > m_size then m_ok = false | |||
| End Sub | |||
| Public Property Get OK | |||
| OK = m_ok | |||
| End Property | |||
| Public Property Get Message | |||
| Message = m_message | |||
| End Property | |||
| End Class | |||
| Sub ValidateMaxLength(instance, field_name, size, message) | |||
| if not IsObject(instance.Validator) then set instance.Validator = new Validator_Class | |||
| instance.Validator.AddValidation new MaxLengthValidation_Class.Initialize(instance, field_name, size, message) | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| ' Numeric Validation | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Class NumericValidation_Class | |||
| Private m_instance | |||
| Private m_field_name | |||
| Private m_message | |||
| Private m_ok | |||
| Public Function Initialize(instance, field_name, message) | |||
| set m_instance = instance | |||
| m_field_name = field_name | |||
| m_message = message | |||
| m_ok = true | |||
| set Initialize = Me | |||
| End Function | |||
| Public Sub Check | |||
| If Not IsNumeric(eval("m_instance." & m_field_name)) then m_ok = false | |||
| End Sub | |||
| Public Property Get OK | |||
| OK = m_ok | |||
| End Property | |||
| Public Property Get Message | |||
| Message = m_message | |||
| End Property | |||
| End Class | |||
| Sub ValidateNumeric(instance, field_name, message) | |||
| if not IsObject(instance.Validator) then set instance.Validator = new Validator_Class | |||
| instance.Validator.AddValidation new NumericValidation_Class.Initialize(instance, field_name, message) | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| ' Regular Expression Pattern Validation | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Class PatternValidation_Class | |||
| Private m_instance | |||
| Private m_field_name | |||
| Private m_pattern | |||
| Private m_message | |||
| Private m_ok | |||
| Public Function Initialize(instance, field_name, pattern, message) | |||
| set m_instance = instance | |||
| m_field_name = field_name | |||
| m_pattern = pattern | |||
| m_message = message | |||
| m_ok = true | |||
| set Initialize = Me | |||
| End Function | |||
| Public Sub Check | |||
| dim re : set re = new RegExp | |||
| With re | |||
| .Pattern = m_pattern | |||
| .Global = true | |||
| .IgnoreCase = true | |||
| End With | |||
| dim matches : set matches = re.Execute(eval("m_instance." & m_field_name)) | |||
| if matches.Count = 0 then | |||
| m_ok = false | |||
| end if | |||
| End Sub | |||
| Public Property Get OK | |||
| OK = m_ok | |||
| End Property | |||
| Public Property Get Message | |||
| Message = m_message | |||
| End Property | |||
| End Class | |||
| Sub ValidatePattern(instance, field_name, pattern, message) | |||
| if not IsObject(instance.Validator) then set instance.Validator = new Validator_Class | |||
| instance.Validator.AddValidation new PatternValidation_Class.Initialize(instance, field_name, pattern, message) | |||
| End Sub | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| ' Validator Class | |||
| ' This class is not intended to be used directly. Models should use the Validate* subs instead. | |||
| '----------------------------------------------------------------------------------------------------------------------- | |||
| Class Validator_Class | |||
| Private m_validations | |||
| Private m_errors | |||
| Private Sub Class_Initialize | |||
| m_validations = Array() | |||
| redim m_validations(-1) | |||
| m_errors = Array() | |||
| redim m_errors(-1) | |||
| End Sub | |||
| Public Property Get Errors | |||
| Errors = m_errors | |||
| End Property | |||
| Public Sub AddValidation(validation) | |||
| dim n : n = ubound(m_validations) + 1 | |||
| redim preserve m_validations(n) | |||
| set m_validations(n) = validation | |||
| End Sub | |||
| Public Sub Validate | |||
| dim n : n = ubound(m_validations) | |||
| dim i, V | |||
| for i = 0 to n | |||
| set V = m_validations(i) | |||
| V.Check | |||
| if not V.OK then | |||
| AddError V.Message | |||
| end if | |||
| next | |||
| End Sub | |||
| Public Property Get HasErrors | |||
| HasErrors = (ubound(m_errors) > -1) | |||
| End Property | |||
| 'Public to allow other errors to be added by the controller for circumstances not accounted for by the validators | |||
| Public Sub AddError(msg) | |||
| redim preserve m_errors(ubound(m_errors) + 1) | |||
| m_errors(ubound(m_errors)) = msg | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,15 @@ | |||
| <!--#include file="lib.Strings.asp"--> | |||
| <!--#include file="lib.HTMLSecurity.asp"--> | |||
| <!--#include file="lib.HTML.asp"--> | |||
| <!--#include file="lib.Collections.asp"--> | |||
| <!--#include file="lib.Routes.asp"--> | |||
| <!--#include file="lib.MVC.asp"--> | |||
| <!--#include file="lib.Automapper.asp"--> | |||
| <!--#include file="lib.Data.asp"--> | |||
| <!--#include file="lib.Helpers.asp"--> | |||
| <!--#include file="lib.Validations.asp"--> | |||
| <!--#include file="lib.Flash.asp"--> | |||
| <!--#include file="lib.Bootstrap.asp"--> | |||
| <!--#include file="lib.Enumerable.asp"--> | |||
| <!--#include file="lib.FormCache.asp"--> | |||
| <!--#include file="lib.json.asp"--> | |||
| @@ -0,0 +1,281 @@ | |||
| <% | |||
| 'January 2021 - Version 1.1 by Gerrit van Kuipers | |||
| Class aspJSON | |||
| Public data | |||
| Private p_JSONstring | |||
| Private aj_in_string, aj_in_escape, aj_i_tmp, aj_char_tmp, aj_s_tmp, aj_line_tmp, aj_line, aj_lines, aj_currentlevel, aj_currentkey, aj_currentvalue, aj_newlabel, aj_XmlHttp, aj_RegExp, aj_colonfound | |||
| Private Sub Class_Initialize() | |||
| Set data = Collection() | |||
| Set aj_RegExp = New regexp | |||
| aj_RegExp.Pattern = "\s{0,}(\S{1}[\s,\S]*\S{1})\s{0,}" | |||
| aj_RegExp.Global = False | |||
| aj_RegExp.IgnoreCase = True | |||
| aj_RegExp.Multiline = True | |||
| End Sub | |||
| Private Sub Class_Terminate() | |||
| Set data = Nothing | |||
| Set aj_RegExp = Nothing | |||
| End Sub | |||
| Public Sub loadJSON(inputsource) | |||
| inputsource = aj_MultilineTrim(inputsource) | |||
| If Len(inputsource) = 0 Then Err.Raise 1, "loadJSON Error", "No data to load." | |||
| Select Case Left(inputsource, 1) | |||
| Case "{", "[" | |||
| Case Else | |||
| Set aj_XmlHttp = Server.CreateObject("Msxml2.ServerXMLHTTP") | |||
| aj_XmlHttp.open "POST", inputsource, False | |||
| aj_XmlHttp.setRequestHeader "Content-Type", "text/json" | |||
| aj_XmlHttp.setRequestHeader "CharSet", "UTF-8" | |||
| aj_XmlHttp.Send | |||
| inputsource = aj_XmlHttp.responseText | |||
| Set aj_XmlHttp = Nothing | |||
| End Select | |||
| p_JSONstring = CleanUpJSONstring(inputsource) | |||
| aj_lines = Split(p_JSONstring, Chr(13) & Chr(10)) | |||
| Dim level(99) | |||
| aj_currentlevel = 1 | |||
| Set level(aj_currentlevel) = data | |||
| For Each aj_line In aj_lines | |||
| aj_currentkey = "" | |||
| aj_currentvalue = "" | |||
| If Instr(aj_line, ":") > 0 Then | |||
| aj_in_string = False | |||
| aj_in_escape = False | |||
| aj_colonfound = False | |||
| For aj_i_tmp = 1 To Len(aj_line) | |||
| If aj_in_escape Then | |||
| aj_in_escape = False | |||
| Else | |||
| Select Case Mid(aj_line, aj_i_tmp, 1) | |||
| Case """" | |||
| aj_in_string = Not aj_in_string | |||
| Case ":" | |||
| If Not aj_in_escape And Not aj_in_string Then | |||
| aj_currentkey = Left(aj_line, aj_i_tmp - 1) | |||
| aj_currentvalue = Mid(aj_line, aj_i_tmp + 1) | |||
| aj_colonfound = True | |||
| Exit For | |||
| End If | |||
| Case "\" | |||
| aj_in_escape = True | |||
| End Select | |||
| End If | |||
| Next | |||
| if aj_colonfound then | |||
| aj_currentkey = aj_Strip(aj_JSONDecode(aj_currentkey), """") | |||
| If Not level(aj_currentlevel).exists(aj_currentkey) Then level(aj_currentlevel).Add aj_currentkey, "" | |||
| end if | |||
| End If | |||
| If right(aj_line,1) = "{" Or right(aj_line,1) = "[" Then | |||
| If Len(aj_currentkey) = 0 Then aj_currentkey = level(aj_currentlevel).Count | |||
| Set level(aj_currentlevel).Item(aj_currentkey) = Collection() | |||
| Set level(aj_currentlevel + 1) = level(aj_currentlevel).Item(aj_currentkey) | |||
| aj_currentlevel = aj_currentlevel + 1 | |||
| aj_currentkey = "" | |||
| ElseIf right(aj_line,1) = "}" Or right(aj_line,1) = "]" or right(aj_line,2) = "}," Or right(aj_line,2) = "]," Then | |||
| aj_currentlevel = aj_currentlevel - 1 | |||
| ElseIf Len(Trim(aj_line)) > 0 Then | |||
| If Len(aj_currentvalue) = 0 Then aj_currentvalue = aj_line | |||
| aj_currentvalue = getJSONValue(aj_currentvalue) | |||
| If Len(aj_currentkey) = 0 Then aj_currentkey = level(aj_currentlevel).Count | |||
| level(aj_currentlevel).Item(aj_currentkey) = aj_currentvalue | |||
| End If | |||
| Next | |||
| End Sub | |||
| Public Function Collection() | |||
| Set Collection = Server.CreateObject("Scripting.Dictionary") | |||
| End Function | |||
| Public Function AddToCollection(dictobj) | |||
| If TypeName(dictobj) <> "Dictionary" Then Err.Raise 1, "AddToCollection Error", "Not a collection." | |||
| aj_newlabel = dictobj.Count | |||
| dictobj.Add aj_newlabel, Collection() | |||
| Set AddToCollection = dictobj.item(aj_newlabel) | |||
| end function | |||
| Private Function CleanUpJSONstring(aj_originalstring) | |||
| aj_originalstring = Replace(aj_originalstring, Chr(13) & Chr(10), "") | |||
| aj_originalstring = Mid(aj_originalstring, 2, Len(aj_originalstring) - 2) | |||
| aj_in_string = False : aj_in_escape = False : aj_s_tmp = "" | |||
| For aj_i_tmp = 1 To Len(aj_originalstring) | |||
| aj_char_tmp = Mid(aj_originalstring, aj_i_tmp, 1) | |||
| If aj_in_escape Then | |||
| aj_in_escape = False | |||
| aj_s_tmp = aj_s_tmp & aj_char_tmp | |||
| Else | |||
| Select Case aj_char_tmp | |||
| Case "\" : aj_s_tmp = aj_s_tmp & aj_char_tmp : aj_in_escape = True | |||
| Case """" : aj_s_tmp = aj_s_tmp & aj_char_tmp : aj_in_string = Not aj_in_string | |||
| Case "{", "[" | |||
| aj_s_tmp = aj_s_tmp & aj_char_tmp & aj_InlineIf(aj_in_string, "", Chr(13) & Chr(10)) | |||
| Case "}", "]" | |||
| aj_s_tmp = aj_s_tmp & aj_InlineIf(aj_in_string, "", Chr(13) & Chr(10)) & aj_char_tmp | |||
| Case "," : aj_s_tmp = aj_s_tmp & aj_char_tmp & aj_InlineIf(aj_in_string, "", Chr(13) & Chr(10)) | |||
| Case Else : aj_s_tmp = aj_s_tmp & aj_char_tmp | |||
| End Select | |||
| End If | |||
| Next | |||
| CleanUpJSONstring = "" | |||
| aj_s_tmp = Split(aj_s_tmp, Chr(13) & Chr(10)) | |||
| For Each aj_line_tmp In aj_s_tmp | |||
| aj_line_tmp = Replace(Replace(aj_line_tmp, Chr(10), ""), Chr(13), "") | |||
| CleanUpJSONstring = CleanUpJSONstring & aj_Trim(aj_line_tmp) & Chr(13) & Chr(10) | |||
| Next | |||
| End Function | |||
| Private Function getJSONValue(ByVal val) | |||
| val = Trim(val) | |||
| If Left(val,1) = ":" Then val = Mid(val, 2) | |||
| If Right(val,1) = "," Then val = Left(val, Len(val) - 1) | |||
| val = Trim(val) | |||
| Select Case val | |||
| Case "true" : getJSONValue = True | |||
| Case "false" : getJSONValue = False | |||
| Case "null" : getJSONValue = Null | |||
| Case Else | |||
| If (Instr(val, """") = 0) Then | |||
| If IsNumeric(val) Then | |||
| getJSONValue = aj_ReadNumericValue(val) | |||
| Else | |||
| getJSONValue = val | |||
| End If | |||
| Else | |||
| If Left(val,1) = """" Then val = Mid(val, 2) | |||
| If Right(val,1) = """" Then val = Left(val, Len(val) - 1) | |||
| getJSONValue = aj_JSONDecode(Trim(val)) | |||
| End If | |||
| End Select | |||
| End Function | |||
| Private JSONoutput_level | |||
| Public Function JSONoutput() | |||
| Dim wrap_dicttype, aj_label | |||
| JSONoutput_level = 1 | |||
| wrap_dicttype = "[]" | |||
| For Each aj_label In data | |||
| If Not aj_IsInt(aj_label) Then wrap_dicttype = "{}" | |||
| Next | |||
| JSONoutput = Left(wrap_dicttype, 1) & Chr(13) & Chr(10) & GetDict(data) & Right(wrap_dicttype, 1) | |||
| End Function | |||
| Private Function GetDict(objDict) | |||
| Dim aj_item, aj_keyvals, aj_label, aj_dicttype | |||
| For Each aj_item In objDict | |||
| Select Case TypeName(objDict.Item(aj_item)) | |||
| Case "Dictionary" | |||
| GetDict = GetDict & Space(JSONoutput_level * 4) | |||
| aj_dicttype = "[]" | |||
| For Each aj_label In objDict.Item(aj_item).Keys | |||
| If Not aj_IsInt(aj_label) Then aj_dicttype = "{}" | |||
| Next | |||
| If aj_IsInt(aj_item) Then | |||
| GetDict = GetDict & (Left(aj_dicttype,1) & Chr(13) & Chr(10)) | |||
| Else | |||
| GetDict = GetDict & ("""" & aj_JSONEncode(aj_item) & """" & ": " & Left(aj_dicttype,1) & Chr(13) & Chr(10)) | |||
| End If | |||
| JSONoutput_level = JSONoutput_level + 1 | |||
| aj_keyvals = objDict.Keys | |||
| GetDict = GetDict & (GetSubDict(objDict.Item(aj_item)) & Space(JSONoutput_level * 4) & Right(aj_dicttype,1) & aj_InlineIf(aj_item = aj_keyvals(objDict.Count - 1),"" , ",") & Chr(13) & Chr(10)) | |||
| Case Else | |||
| aj_keyvals = objDict.Keys | |||
| GetDict = GetDict & (Space(JSONoutput_level * 4) & aj_InlineIf(aj_IsInt(aj_item), "", """" & aj_JSONEncode(aj_item) & """: ") & WriteValue(objDict.Item(aj_item)) & aj_InlineIf(aj_item = aj_keyvals(objDict.Count - 1),"" , ",") & Chr(13) & Chr(10)) | |||
| End Select | |||
| Next | |||
| End Function | |||
| Private Function aj_IsInt(val) | |||
| aj_IsInt = (TypeName(val) = "Integer" Or TypeName(val) = "Long") | |||
| End Function | |||
| Private Function GetSubDict(objSubDict) | |||
| GetSubDict = GetDict(objSubDict) | |||
| JSONoutput_level= JSONoutput_level -1 | |||
| End Function | |||
| Private Function WriteValue(ByVal val) | |||
| Select Case TypeName(val) | |||
| Case "Double", "Integer", "Long": WriteValue = replace(val, ",", ".") | |||
| Case "Null" : WriteValue = "null" | |||
| Case "Boolean" : WriteValue = aj_InlineIf(val, "true", "false") | |||
| Case Else : WriteValue = """" & aj_JSONEncode(val) & """" | |||
| End Select | |||
| End Function | |||
| Private Function aj_JSONEncode(ByVal val) | |||
| val = Replace(val, "\", "\\") | |||
| val = Replace(val, """", "\""") | |||
| 'val = Replace(val, "/", "\/") | |||
| val = Replace(val, Chr(8), "\b") | |||
| val = Replace(val, Chr(12), "\f") | |||
| val = Replace(val, Chr(10), "\n") | |||
| val = Replace(val, Chr(13), "\r") | |||
| val = Replace(val, Chr(9), "\t") | |||
| aj_JSONEncode = Trim(val) | |||
| End Function | |||
| Private Function aj_JSONDecode(ByVal val) | |||
| val = Replace(val, "\""", """") | |||
| val = Replace(val, "\\", "\") | |||
| val = Replace(val, "\/", "/") | |||
| val = Replace(val, "\b", Chr(8)) | |||
| val = Replace(val, "\f", Chr(12)) | |||
| val = Replace(val, "\n", Chr(10)) | |||
| val = Replace(val, "\r", Chr(13)) | |||
| val = Replace(val, "\t", Chr(9)) | |||
| aj_JSONDecode = Trim(val) | |||
| End Function | |||
| Private Function aj_InlineIf(condition, returntrue, returnfalse) | |||
| If condition Then aj_InlineIf = returntrue Else aj_InlineIf = returnfalse | |||
| End Function | |||
| Private Function aj_Strip(ByVal val, stripper) | |||
| If Left(val, 1) = stripper Then val = Mid(val, 2) | |||
| If Right(val, 1) = stripper Then val = Left(val, Len(val) - 1) | |||
| aj_Strip = val | |||
| End Function | |||
| Private Function aj_MultilineTrim(TextData) | |||
| aj_MultilineTrim = aj_RegExp.Replace(TextData, "$1") | |||
| End Function | |||
| Private Function aj_Trim(val) | |||
| aj_Trim = Trim(val) | |||
| Do While Left(aj_Trim, 1) = Chr(9) : aj_Trim = Mid(aj_Trim, 2) : Loop | |||
| Do While Right(aj_Trim, 1) = Chr(9) : aj_Trim = Left(aj_Trim, Len(aj_Trim) - 1) : Loop | |||
| aj_Trim = Trim(aj_Trim) | |||
| End Function | |||
| Private Function aj_ReadNumericValue(ByVal val) | |||
| If Instr(val, ".") > 0 Then | |||
| numdecimals = Len(val) - Instr(val, ".") | |||
| val = Clng(Replace(val, ".", "")) | |||
| val = val / (10 ^ numdecimals) | |||
| aj_ReadNumericValue = val | |||
| Else | |||
| aj_ReadNumericValue = Clng(val) | |||
| End If | |||
| End Function | |||
| End Class | |||
| dim json_Class__Singleton | |||
| Function json() | |||
| if IsEmpty(json_Class__Singleton) then | |||
| set json_Class__Singleton = new aspJSON | |||
| end if | |||
| set json = json_Class__Singleton | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,38 @@ | |||
| <% | |||
| Class TCTest | |||
| Public Function TestCaseNames() | |||
| TestCaseNames = Array("test", "test2", "test3") | |||
| End Function | |||
| Public Sub SetUp() | |||
| 'Response.Write("SetUp<br>") | |||
| End Sub | |||
| Public Sub TearDown() | |||
| 'Response.Write("TearDown<br>") | |||
| End Sub | |||
| Public Sub test(oTestResult) | |||
| 'Response.Write("test<br>") | |||
| 'Err.Raise 5, "hello", "error" | |||
| End Sub | |||
| Public Sub test2(oTestResult) | |||
| 'Response.Write("test2<br>") | |||
| oTestResult.Assert False, "Assert False!" | |||
| oTestResult.AssertEquals 4, 4, "4 = 4, Should not fail!" | |||
| oTestResult.AssertEquals 4, 5, "4 != 5, Should fail!" | |||
| oTestResult.AssertNotEquals 5, 5, "AssertNotEquals(5, = 5) should fail!" | |||
| oTestResult.AssertExists new TestResult, "new TestResult Should not fail!" | |||
| oTestResult.AssertExists Nothing, "Nothing: Should not exist!" | |||
| oTestResult.AssertExists 4, "4 Should exist?!" | |||
| End Sub | |||
| Public Sub test3(oTestResult) | |||
| oTestResult.Assert True, "Success" | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,12 @@ | |||
| <% | |||
| Option Explicit | |||
| %> | |||
| <!-- #include file="../include/ASPUnitRunner.asp"--> | |||
| <!-- #include file="TCTest.asp"--> | |||
| <% | |||
| Dim oRunner | |||
| Set oRunner = New UnitRunner | |||
| oRunner.AddTestContainer New TCTest | |||
| oRunner.Display() | |||
| %> | |||
| @@ -0,0 +1,335 @@ | |||
| <% | |||
| '******************************************************************** | |||
| ' Name: ASPUnit.asp | |||
| ' | |||
| ' Purpose: Contains the main ASPUnit classes | |||
| '******************************************************************** | |||
| Class TestSuite | |||
| Private m_oTestCases | |||
| Private Sub Class_Initialize() | |||
| Set m_oTestCases = Server.CreateObject("Scripting.Dictionary") | |||
| End Sub | |||
| Private Sub Class_Terminate() | |||
| Set m_oTestCases = Nothing | |||
| End Sub | |||
| Public Sub AddTestCase(oTestContainer, sTestMethod) | |||
| Dim oTestCase | |||
| Set oTestCase = New TestCase | |||
| Set oTestCase.TestContainer = oTestContainer | |||
| oTestCase.TestMethod = sTestMethod | |||
| m_oTestCases.Add oTestCase, oTestCase | |||
| End Sub | |||
| Public Sub AddAllTestCases(oTestContainer) | |||
| Dim oTestCase, sTestMethod | |||
| For Each sTestMethod In oTestContainer.TestCaseNames() | |||
| AddTestCase oTestContainer, sTestMethod | |||
| Next | |||
| End Sub | |||
| Public Function Count() | |||
| Count = m_oTestCases.Count | |||
| End Function | |||
| Public Sub Run(oTestResult) | |||
| Dim oTestCase | |||
| For Each oTestCase In m_oTestCases.Items | |||
| oTestCase.Run oTestResult | |||
| Next | |||
| End Sub | |||
| End Class | |||
| Class TestCase | |||
| Private m_oTestContainer | |||
| Private m_sTestMethod | |||
| Public Property Get TestContainer() | |||
| Set TestContainer = m_oTestContainer | |||
| End Property | |||
| Public Property Set TestContainer(oTestContainer) | |||
| Set m_oTestContainer = oTestContainer | |||
| End Property | |||
| Public Property Get TestMethod() | |||
| TestMethod = m_sTestMethod | |||
| End Property | |||
| Public Property Let TestMethod(sTestMethod) | |||
| m_sTestMethod = sTestMethod | |||
| End Property | |||
| Public Sub Run(oTestResult) | |||
| Dim iOldFailureCount | |||
| Dim iOldErrorCount | |||
| iOldFailureCount = oTestResult.Failures.Count | |||
| iOldErrorCount = oTestResult.Errors.Count | |||
| On Error Resume Next | |||
| oTestResult.StartTest Me | |||
| m_oTestContainer.SetUp() | |||
| If (Err.Number <> 0) Then | |||
| oTestResult.AddError Err | |||
| Else | |||
| ' Response.Write("m_oTestContainer." & m_sTestMethod & "(oTestResult)<br>") | |||
| Execute("m_oTestContainer." & m_sTestMethod & "(oTestResult)") | |||
| If (Err.Number <> 0) Then | |||
| ' Response.Write(Err.Description & "<br>") | |||
| oTestResult.AddError Err | |||
| End If | |||
| End If | |||
| Err.Clear() | |||
| m_oTestContainer.TearDown() | |||
| If (Err.Number <> 0) Then | |||
| oTestResult.AddError Err | |||
| End If | |||
| 'Log success if no failures or errors occurred | |||
| If oTestResult.Failures.Count = iOldFailureCount And oTestResult.Errors.Count = iOldErrorCount Then | |||
| oTestResult.AddSuccess | |||
| End If | |||
| oTestResult.EndTest | |||
| On Error Goto 0 | |||
| End Sub | |||
| End Class | |||
| Class TestResult | |||
| Private m_dicErrors | |||
| Private m_dicFailures | |||
| Private m_dicSuccesses | |||
| Private m_dicObservers | |||
| Private m_iRunTests | |||
| Private m_oCurrentTestCase | |||
| Private Sub Class_Initialize | |||
| Set m_dicErrors = Server.CreateObject("Scripting.Dictionary") | |||
| Set m_dicFailures = Server.CreateObject("Scripting.Dictionary") | |||
| Set m_dicSuccesses = Server.CreateObject("Scripting.Dictionary") | |||
| Set m_dicObservers = Server.CreateObject("Scripting.Dictionary") | |||
| m_iRunTests = 0 | |||
| End Sub | |||
| Private Sub Class_Terminate | |||
| Set m_dicErrors = Nothing | |||
| Set m_dicFailures = Nothing | |||
| Set m_dicSuccesses = Nothing | |||
| Set m_dicObservers = Nothing | |||
| Set m_oCurrentTestCase = Nothing | |||
| End Sub | |||
| Public Property Get Errors() | |||
| Set Errors = m_dicErrors | |||
| End Property | |||
| Public Property Get Failures() | |||
| Set Failures = m_dicFailures | |||
| End Property | |||
| Public Property Get Successes() | |||
| Set Successes = m_dicSuccesses | |||
| End Property | |||
| Public Property Get RunTests() | |||
| RunTests = m_iRunTests | |||
| End Property | |||
| Public Sub StartTest(oTestCase) | |||
| Set m_oCurrentTestCase = oTestCase | |||
| Dim oObserver | |||
| For Each oObserver In m_dicObservers.Items | |||
| oObserver.OnStartTest | |||
| Next | |||
| End Sub | |||
| Public Sub EndTest() | |||
| m_iRunTests = m_iRunTests + 1 | |||
| Dim oObserver | |||
| For Each oObserver In m_dicObservers.Items | |||
| oObserver.OnEndTest | |||
| Next | |||
| End Sub | |||
| Public Sub AddObserver(oObserver) | |||
| m_dicObservers.Add oOserver, oObserver | |||
| End Sub | |||
| Public Function AddError(oError) | |||
| Dim oTestError | |||
| Set oTestError = New TestError | |||
| oTestError.Initialize m_oCurrentTestCase, oError.Number, oError.Source, oError.Description | |||
| m_dicErrors.Add oTestError, oTestError | |||
| Dim oObserver | |||
| For Each oObserver In m_dicObservers.Items | |||
| oObserver.OnError | |||
| Next | |||
| Set AddError = oTestError | |||
| End Function | |||
| Public Function AddFailure(sMessage) | |||
| Dim oTestError | |||
| Set oTestError = New TestError | |||
| oTestError.Initialize m_oCurrentTestCase, 0, " ", sMessage | |||
| m_dicFailures.Add oTestError, oTestError | |||
| Dim oObserver | |||
| For Each oObserver In m_dicObservers.Items | |||
| oObserver.OnFailure | |||
| Next | |||
| Set AddFailure = oTestError | |||
| End Function | |||
| Public Function AddSuccess | |||
| Dim oTestError | |||
| Set oTestError = New TestError | |||
| oTestError.Initialize m_oCurrentTestCase, 0, " ", "Test completed without failures" | |||
| m_dicSuccesses.Add oTestError, oTestError | |||
| Dim oObserver | |||
| For Each oObserver In m_dicObservers.Items | |||
| oObserver.OnSuccess | |||
| Next | |||
| End Function | |||
| Public Sub Assert(bCondition, sMessage) | |||
| If Not bCondition Then | |||
| AddFailure sMessage | |||
| End If | |||
| End Sub | |||
| Public Sub AssertEquals(vExpected, vActual, sMessage) | |||
| If vExpected <> vActual Then | |||
| AddFailure NotEqualsMessage(sMessage, vExpected, vActual) | |||
| End If | |||
| End Sub | |||
| 'Build a message about a failed equality check | |||
| Function NotEqualsMessage(sMessage, vExpected, vActual) | |||
| 'NotEqualsMessage = sMessage & " expected: " & CStr(vExpected) & " but was: " & CStr(vActual) | |||
| NotEqualsMessage = sMessage & "<br>" &_ | |||
| "<table><tr><th class='expected'>Expected</th><td class='expected'><span class='left-delim'>(" & typename(vExpected) & ") [</span>" & CStr(vExpected) & "<span class='right-delim'>]</span></td></tr><tr><th class='actual'>Actual</th><td class='actual'><span class='left-delim'>(" & typename(vActual) & ") [</span>" & CStr(vActual) & "<span class='right-delim'>]</span></td></tr></table>" | |||
| End Function | |||
| Public Sub AssertNotEquals(vExpected, vActual, sMessage) | |||
| If vExpected = vActual Then | |||
| AddFailure sMessage & " expected: " & CStr(vExpected) & " and actual: " & CStr(vActual) & " should not be equal." | |||
| End If | |||
| End Sub | |||
| Public Sub AssertExists(vVariable, sMessage) | |||
| If IsObject(vVariable) Then | |||
| If (vVariable Is Nothing) Then | |||
| AddFailure sMessage & " - Variable of type " & TypeName(vVariable) & " is Nothing." | |||
| End If | |||
| ElseIf IsEmpty(vVariable) Then | |||
| AddFailure sMessage & " - Variable " & TypeName(vVariable) & " is Empty (Uninitialized)." | |||
| End If | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' CUSTOM ASSERTIONS | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub AssertFalse(bCondition, sMessage) | |||
| If bCondition then | |||
| AddFailure sMessage | |||
| End If | |||
| End Sub | |||
| Public Sub AssertEqual(vExpected, vActual, sMessage) | |||
| AssertEquals vExpected, vActual, sMessage | |||
| End Sub | |||
| Public Sub AssertNotEqual(vExpected, vActual, sMessage) | |||
| AssertNotEqual vExpected, vActual, sMessage | |||
| End Sub | |||
| Public Sub AssertNotExists(vVariable, sMessage) | |||
| If IsObject(vVariable) then | |||
| If (vVariable Is Not Nothing) then | |||
| AddFailure sMessage & " - Variable of type " & TypeName(vVariable) & " should be Nothing." | |||
| End If | |||
| ElseIf Not IsEmpty(vVariable) then | |||
| AddFailure sMessage & " - Variable " & TypeName(vVariable) & " should be Empty (Uninitialized)." | |||
| End If | |||
| End Sub | |||
| 'Ensures (obj1 Is obj2) = true | |||
| Public Sub AssertSame(obj1, obj2, sMessage) | |||
| Assert (obj1 Is obj2), sMessage | |||
| End Sub | |||
| 'Ensures (obj1 Is obj2) = false | |||
| Public Sub AssertDifferent(obj1, obj2, sMessage) | |||
| Assert (not (obj1 Is obj2)), sMessage | |||
| End Sub | |||
| 'Forces a test failure | |||
| Public Sub Fail(sMessage) | |||
| AddFailure "Forced Failure: " & sMessage | |||
| End Sub | |||
| 'Flags a test as needing implementation, otherwise an empty test will silently pass | |||
| Public Sub NotImplemented | |||
| AddFailure "Test not implemented." | |||
| End Sub | |||
| Public Sub AssertType(sTypeName, vVariable, sMessage) | |||
| AssertEqual sTypeName, typename(vVariable), sMessage | |||
| End Sub | |||
| End Class | |||
| Class TestError | |||
| Private m_oTestCase | |||
| Private m_lErrNumber | |||
| Private m_sSource | |||
| Private m_sDescription | |||
| Public Sub Initialize(oTestCase, lErrNumber, sSource, sDescription) | |||
| Set m_oTestCase = oTestCase | |||
| m_lErrNumber = lErrNumber | |||
| m_sSource = sSource | |||
| m_sDescription = sDescription | |||
| End Sub | |||
| Public Property Get TestCase | |||
| Set TestCase = m_oTestCase | |||
| End Property | |||
| Public Property Get ErrNumber | |||
| ErrNumber = m_lErrNumber | |||
| End Property | |||
| Public Property Get Source | |||
| Source = m_sSource | |||
| End Property | |||
| Public Property Get Description | |||
| Description = m_sDescription | |||
| End Property | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,68 @@ | |||
| /* | |||
| .warning | |||
| { | |||
| BACKGROUND-COLOR: gold | |||
| } | |||
| .error | |||
| { | |||
| BACKGROUND-COLOR: indianred | |||
| } | |||
| .success | |||
| { | |||
| BACKGROUND-COLOR: #33cc33 | |||
| } | |||
| BODY | |||
| { | |||
| FONT-SIZE: 10px | |||
| FONT-FAMILY: Verdana; | |||
| BACKGROUND-COLOR: lightskyblue | |||
| } | |||
| TABLE | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| FORM | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| SELECT | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| INPUT | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| */ | |||
| /*---------------------------------------------------------------------------------------------------------------------- | |||
| CUSTOMIZATIONS | |||
| ----------------------------------------------------------------------------------------------------------------------*/ | |||
| body { padding: 20px; font-family: calibri; font-size: 14pt; color: #333; background-color: #fcfcfc; } | |||
| table.Form { width: auto; } | |||
| table.Form th, | |||
| table.Form td { padding-right: 20px; } | |||
| table.Form input.Submit { height: 40px; } | |||
| table.Results { width: 98%; } | |||
| table.Results th, | |||
| table.Results td { padding: 5px; vertical-align: top; } | |||
| table.Results th.expected, | |||
| table.Results th.actual { text-align: right; color: #c00; } | |||
| table.Results td.expected, | |||
| table.Results td.actual { font-family: consolas; } | |||
| table.Results span.left-delim, | |||
| table.Results span.right-delim { font-weight: bold; color: #c00; } | |||
| .warning { background-color: #feedab; color: #333; } | |||
| .error { background-color: #ffb3b3; color: darkred; } | |||
| .success { background-color: #dbf0b8; color: darkgreen; } | |||
| @@ -0,0 +1,58 @@ | |||
| /* | |||
| .warning | |||
| { | |||
| BACKGROUND-COLOR: gold | |||
| } | |||
| .error | |||
| { | |||
| BACKGROUND-COLOR: indianred | |||
| } | |||
| .success | |||
| { | |||
| BACKGROUND-COLOR: #33cc33 | |||
| } | |||
| BODY | |||
| { | |||
| FONT-SIZE: 10px | |||
| FONT-FAMILY: Verdana; | |||
| BACKGROUND-COLOR: lightskyblue | |||
| } | |||
| TABLE | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| FORM | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| SELECT | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| INPUT | |||
| { | |||
| FONT-SIZE: 10px | |||
| } | |||
| */ | |||
| /*---------------------------------------------------------------------------------------------------------------------- | |||
| CUSTOMIZATIONS | |||
| ----------------------------------------------------------------------------------------------------------------------*/ | |||
| body { padding: 20px; font-family: calibri; font-size: 14pt; color: #333; background-color: #fcfcfc; } | |||
| table.Form { width: auto; } | |||
| table.Form th, | |||
| table.Form td { padding-right: 20px; } | |||
| table.Form input.Submit { height: 40px; } | |||
| table.Results { width: 98%; } | |||
| table.Results th, | |||
| table.Results td { padding: 5px; } | |||
| .warning { background-color: #feedab; color: #333; } | |||
| .error { background-color: #ffb3b3; color: darkred; } | |||
| .success { background-color: #dbf0b8; color: darkgreen; } | |||
| @@ -0,0 +1,273 @@ | |||
| <% | |||
| '******************************************************************** | |||
| ' Name: ASPUnitRunner.asp | |||
| ' | |||
| ' Purpose: Contains the UnitRunner class which is used to render the unit testing UI | |||
| '******************************************************************** | |||
| '******************************************************************** | |||
| ' Include Files | |||
| '******************************************************************** | |||
| %> | |||
| <!-- #include file="ASPUnit.asp"--> | |||
| <% | |||
| Const ALL_TESTCONTAINERS = "All Test Containers" | |||
| Const ALL_TESTCASES = "All Test Cases" | |||
| Const FRAME_PARAMETER = "UnitRunner" | |||
| Const FRAME_SELECTOR = "selector" | |||
| Const FRAME_RESULTS = "results" | |||
| Const STYLESHEET = "aspunit/include/ASPUnit.css" | |||
| Const SCRIPTFILE = "aspunit/include/ASPUnitRunner.js" | |||
| Class UnitRunner | |||
| Private m_dicTestContainer | |||
| Private Sub Class_Initialize() | |||
| Set m_dicTestContainer = CreateObject("Scripting.Dictionary") | |||
| End Sub | |||
| Public Sub AddTestContainer(oTestContainer) | |||
| m_dicTestContainer.Add TypeName(oTestContainer), oTestContainer | |||
| End Sub | |||
| Public Function Display() | |||
| If (Request.QueryString(FRAME_PARAMETER) = FRAME_SELECTOR) Then | |||
| DisplaySelector | |||
| ElseIf (Request.QueryString(FRAME_PARAMETER) = FRAME_RESULTS) Then | |||
| DisplayResults | |||
| Else | |||
| ShowFrameSet | |||
| End if | |||
| End Function | |||
| '******************************************************************** | |||
| ' Frameset | |||
| '******************************************************************** | |||
| Private Function ShowFrameSet() | |||
| %> | |||
| <HTML> | |||
| <HEAD> | |||
| <TITLE>ASPUnit Test Runner</TITLE> | |||
| </HEAD> | |||
| <FRAMESET ROWS="70, *" BORDER=0 FRAMEBORDER=0 FRAMESPACING=0> | |||
| <FRAME NAME="<% = FRAME_SELECTOR %>" src="<% = GetSelectorFrameSrc %>" marginwidth="0" marginheight="0" scrolling="auto" border=0 frameborder=0 noresize> | |||
| <FRAME NAME="<% = FRAME_RESULTS %>" src="<% = GetResultsFrameSrc %>" marginwidth="0" marginheight="0" scrolling="auto" border=0 frameborder=0 noresize> | |||
| </FRAMESET> | |||
| <% | |||
| End Function | |||
| Private Function GetSelectorFrameSrc() | |||
| GetSelectorFrameSrc = Request.ServerVariables("SCRIPT_NAME") & "?" & FRAME_PARAMETER & "=" & FRAME_SELECTOR | |||
| End Function | |||
| Private Function GetResultsFrameSrc() | |||
| GetResultsFrameSrc = Request.ServerVariables("SCRIPT_NAME") & "?" & FRAME_PARAMETER & "=" & FRAME_RESULTS | |||
| End Function | |||
| '******************************************************************** | |||
| ' Selector Frame | |||
| '******************************************************************** | |||
| Private Function DisplaySelector() | |||
| %> | |||
| <HTML> | |||
| <HEAD> | |||
| <LINK REL="stylesheet" HREF="<% = STYLESHEET %>" MEDIA="screen" TYPE="text/css"> | |||
| <SCRIPT> | |||
| function ComboBoxUpdate(strSelectorFrameSrc, strSelectorFrameName) | |||
| { | |||
| document.frmSelector.action = strSelectorFrameSrc; | |||
| document.frmSelector.target = strSelectorFrameName; | |||
| document.frmSelector.submit(); | |||
| } | |||
| </SCRIPT> | |||
| </HEAD> | |||
| <BODY> | |||
| <FORM NAME="frmSelector" ACTION="<% = GetResultsFrameSrc %>" TARGET="<% = FRAME_RESULTS %>" METHOD=POST> | |||
| <TABLE class='Form'> | |||
| <TR> | |||
| <TD> | |||
| <INPUT TYPE="Submit" NAME="cmdRun" class="Submit" VALUE="Run Tests"> | |||
| </TD> | |||
| <TD ALIGN="right">Test:</TD> | |||
| <TD> | |||
| <SELECT NAME="cboTestContainers" OnChange="ComboBoxUpdate('<% = GetSelectorFrameSrc %>', '<% = FRAME_SELECTOR %>');"> | |||
| <OPTION><% = ALL_TESTCONTAINERS %> | |||
| <% | |||
| AddTestContainers | |||
| %> | |||
| </SELECT> | |||
| </TD> | |||
| <TD ALIGN="right">Test Method:</TD> | |||
| <TD> | |||
| <SELECT NAME="cboTestCases"> | |||
| <OPTION><% = ALL_TESTCASES %> | |||
| <% | |||
| AddTestMethods | |||
| %> | |||
| </SELECT> | |||
| <TD> | |||
| <INPUT TYPE="checkbox" NAME="chkShowSuccess"> Show Passing Tests</INPUT> | |||
| </TD> | |||
| </TD> | |||
| </TR> | |||
| </TABLE> | |||
| </FORM> | |||
| </BODY> | |||
| </HTML> | |||
| <% | |||
| End Function | |||
| Private Function AddTestContainers() | |||
| Dim oTestContainer, sTestContainer | |||
| For Each oTestContainer In m_dicTestContainer.Items() | |||
| sTestContainer = TypeName(oTestContainer) | |||
| If (sTestContainer = Request.Form("cboTestContainers")) Then | |||
| Response.Write("<OPTION SELECTED>" & sTestContainer) | |||
| Else | |||
| Response.Write("<OPTION>" & sTestContainer) | |||
| End If | |||
| Next | |||
| End Function | |||
| Private Function AddTestMethods() | |||
| Dim oTestContainer, sContainer, sTestMethod | |||
| If (Request.Form("cboTestContainers") <> ALL_TESTCONTAINERS And Request.Form("cboTestContainers") <> "") Then | |||
| sContainer = CStr(Request.Form("cboTestContainers")) | |||
| Set oTestContainer = m_dicTestContainer.Item(sContainer) | |||
| For Each sTestMethod In oTestContainer.TestCaseNames() | |||
| Response.Write("<OPTION>" & sTestMethod) | |||
| Next | |||
| End If | |||
| End Function | |||
| Private Function TestName(oResult) | |||
| If (oResult.TestCase Is Nothing) Then | |||
| TestName = "" | |||
| Else | |||
| TestName = TypeName(oResult.TestCase.TestContainer) & "." & oResult.TestCase.TestMethod | |||
| End If | |||
| End Function | |||
| '******************************************************************** | |||
| ' Results Frame | |||
| '******************************************************************** | |||
| Private Function DisplayResults() | |||
| %> | |||
| <HTML> | |||
| <HEAD> | |||
| <LINK REL="stylesheet" HREF="<% = STYLESHEET %>" MEDIA="screen" TYPE="text/css"> | |||
| </HEAD> | |||
| <BODY> | |||
| <% | |||
| Dim oTestResult, oTestSuite | |||
| Set oTestResult = New TestResult | |||
| ' Create TestSuite | |||
| Set oTestSuite = BuildTestSuite() | |||
| ' Run Tests | |||
| oTestSuite.Run oTestResult | |||
| ' Display Results | |||
| DisplayResultsTable oTestResult | |||
| %> | |||
| </BODY> | |||
| </HTML> | |||
| <% | |||
| End Function | |||
| Private Function BuildTestSuite() | |||
| Dim oTestSuite, oTestContainer, sContainer | |||
| Set oTestSuite = New TestSuite | |||
| If (Request.Form("cmdRun") <> "") Then | |||
| If (Request.Form("cboTestContainers") = ALL_TESTCONTAINERS) Then | |||
| For Each oTestContainer In m_dicTestContainer.Items() | |||
| If Not(oTestContainer Is Nothing) Then | |||
| oTestSuite.AddAllTestCases oTestContainer | |||
| End If | |||
| Next | |||
| Else | |||
| sContainer = CStr(Request.Form("cboTestContainers")) | |||
| Set oTestContainer = m_dicTestContainer.Item(sContainer) | |||
| Dim sTestMethod | |||
| sTestMethod = Request.Form("cboTestCases") | |||
| If (sTestMethod = ALL_TESTCASES) Then | |||
| oTestSuite.AddAllTestCases oTestContainer | |||
| Else | |||
| oTestSuite.AddTestCase oTestContainer, sTestMethod | |||
| End If | |||
| End If | |||
| End If | |||
| Set BuildTestSuite = oTestSuite | |||
| End Function | |||
| Private Function DisplayResultsTable(oTestResult) | |||
| %> | |||
| <TABLE BORDER="1" class='Results'> | |||
| <TR><TH WIDTH="10%" class="Type">Type</TH><TH WIDTH="20%" class="Test">Test</TH><TH WIDTH="70%" class="Desc">Description</TH></TR> | |||
| <% | |||
| If Not(oTestResult Is Nothing) Then | |||
| Dim oResult | |||
| If (Request.Form("chkShowSuccess") <> "") Then | |||
| For Each oResult in oTestResult.Successes | |||
| Response.Write(" <TR CLASS=""success""><TD class='Type'>Success</TD><TD class='Test'>" & TestName(oResult) & "</TD><TD class='Desc'>" & oResult.Source & oResult.Description & "</TD></TR>") | |||
| Next | |||
| End If | |||
| For Each oResult In oTestResult.Errors | |||
| Response.Write(" <TR CLASS=""error""><TD class='Type'>Error</TD><TD class='Test'>" & TestName(oResult) & "</TD><TD class='Desc'>" & oResult.Source & " (" & Trim(oResult.ErrNumber) & "): " & oResult.Description & "</TD></TR>") | |||
| Next | |||
| For Each oResult In oTestResult.Failures | |||
| Response.Write(" <TR CLASS=""warning""><TD class='Type'>Failure</TD><TD class='Test'>" & TestName(oResult) & "</TD><TD class='Desc'>" & oResult.Description & "</TD></TR>") | |||
| Next | |||
| Response.Write " <TR><TD ALIGN=""center"" COLSPAN=3 class='" & ResultRowClass(oTestResult) & "'>" & "Tests: " & oTestResult.RunTests & ", Errors: " & oTestResult.Errors.Count & ", Failures: " & oTestResult.Failures.Count & "</TD></TR>" | |||
| End If | |||
| %> | |||
| </TABLE> | |||
| <% | |||
| End Function | |||
| Private Function ResultRowClass(oTestResult) | |||
| if oTestResult.Errors.Count > 0 then | |||
| ResultRowClass = "error" | |||
| elseif oTestResult.Failures.Count > 0 then | |||
| ResultRowClass = "warning" | |||
| elseif oTestResult.Successes.Count > 0 then | |||
| ResultRowClass = "success" | |||
| end if | |||
| End Function | |||
| Public Sub OnStartTest() | |||
| End Sub | |||
| Public Sub OnEndTest() | |||
| End Sub | |||
| Public Sub OnError() | |||
| End Sub | |||
| Public Sub OnFailure() | |||
| End Sub | |||
| Public Sub OnSuccess() | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,6 @@ | |||
| function ComboBoxUpdate(strSelectorFrameSrc, strSelectorFrameName) | |||
| { | |||
| document.frmSelector.action = strSelectorFrameSrc; | |||
| document.frmSelector.target = strSelectorFrameName; | |||
| document.frmSelector.submit(); | |||
| } | |||
| @@ -0,0 +1,43 @@ | |||
| <html> | |||
| <head> | |||
| <title>ASPUnit: an ASP Unit Testing Framework</title> | |||
| </head> | |||
| <body> | |||
| <a name="top"></a> | |||
| <h1>ASPUnit 0.9.2</h1> | |||
| <h2>Introduction</h2> | |||
| ASPUnit is a unit testing framework based on the architecture of | |||
| <a href="http://www.junit.org">JUnit</a>, the current open source | |||
| <i>de facto</i> standard for unit testing. ASPUnit is a web-based port of | |||
| <a href="http://comunit.sourceforge.net">COMUnit</a> using Active Server Pages. | |||
| It is a VBScript implementation that has been tested to run on top of Microsoft | |||
| Internet Information Server 5.0 or 5.1. | |||
| <h2>Demonstration</h2> | |||
| Try out the <a href="http://www32.brinkster.com/aspunit/TestASPUnit/TestASPUnit.asp">ASPUnit demonstration</a>. | |||
| <h2>Download</h2> | |||
| Download <a href="http://sourceforge.net/project/showfiles.php?group_id=32444">ASPUnit 0.9.2</a>. | |||
| <h2>Feedback</h2> | |||
| Questions? Comments? Suggestions? Feel free to send us an email about it: | |||
| <a href="mailto:aspunit-developer@lists.sourceforge.net">aspunit-developer@lists.sourceforge.net</a> | |||
| <h2>Contributors:</h2> | |||
| <ul> | |||
| <li>Bernard Vander Beken</li> | |||
| <li>Tamara L. Cravit</li> | |||
| <li>Stephane Lussier (sl@fecondcarcan.com)</li> | |||
| <li>Richard Quinn</li> | |||
| </ul> | |||
| <h2>Links</h2> | |||
| <ul> | |||
| <li><a href="http://comunit.sourceforge.net">COMUnit</a>: a unit testing framework for COM components | |||
| <li><A href="http://www.xprogramming.com">www.xprogramming.com</A>: download source for all xUnits | |||
| <li><a href="http://www.junit.org">www.junit.org</a>: home of the original JUnit | |||
| </ul> | |||
| </body> | |||
| </html> | |||
| @@ -0,0 +1,127 @@ | |||
| <% | |||
| Class Test_AutoMap_Class | |||
| Public SomeString, SomeInt, SomeDate | |||
| Public Property Get Class_Get_Properties : Class_Get_Properties = Array("SomeString", "SomeInt", "SomeDate") : End Property | |||
| End Class | |||
| Class AutoMap_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Test_From_Recordset_To_Existing_Class_Instance", _ | |||
| "Test_From_Recordset_To_New_Class_Instance", _ | |||
| "Test_From_Class_Instance_To_Existing_Class_Instance", _ | |||
| "Test_From_Class_Instance_To_New_Class_Instance") | |||
| End Function | |||
| Private Sub Destroy(o) | |||
| on error resume next | |||
| o.close | |||
| on error goto 0 | |||
| set o = nothing | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_Existing_Class_Instance(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim target : set target = new Test_Automap_Class | |||
| dim result : set result = Automapper().Automap(src, target) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_New_Class_Instance(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", 200, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim result : set result = Automapper().Automap(src, "Test_Automap_Class") | |||
| T.AssertEqual "Test_AutoMap_Class", typename(result), "AutoMap should have returned an instance of Test_AutoMap_Class." | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_Existing_Class_Instance(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_Automap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim target : set target = new Test_Automap_Class | |||
| dim result : set result = Automapper().Automap(src, target) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_New_Class_Instance(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_Automap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim result : set result = Automapper().Automap(src, "Test_Automap_Class") | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,281 @@ | |||
| <% | |||
| Class Test_DynMap_Class | |||
| Public SomeString, SomeInt, SomeDate | |||
| Public Property Get Class_Get_Properties : Class_Get_Properties = Array("SomeString", "SomeInt", "SomeDate") : End Property | |||
| End Class | |||
| Class DynMap_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Test_From_Recordset_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Recordset_To_Existing_Class_Instance_Maps_Only_Specified_Fields", _ | |||
| "Test_From_Recordset_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Recordset_To_New_Class_Instance_Maps_Only_Specified_Fields", _ | |||
| "Test_From_Class_Instance_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Class_Instance_To_Existing_Class_Instance_Maps_Only_Specified_Fields", _ | |||
| "Test_From_Class_Instance_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Class_Instance_To_New_Class_Instance_Maps_Only_Specified_Fields", _ | |||
| "Test_From_Class_Instance_To_Existing_Class_Instance_Maps_One_Expression", _ | |||
| "Test_From_Class_Instance_To_Existing_Class_Instance_Maps_Multiple_Expressions") | |||
| End Function | |||
| Private Sub Destroy(o) | |||
| on error resume next | |||
| o.close | |||
| on error goto 0 | |||
| set o = nothing | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim target : set target = new Test_DynMap_Class | |||
| dim result : set result = Automapper().DynMap(src, target, empty, empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_Existing_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim target : set target = new Test_DynMap_Class | |||
| target.SomeInt = 54321 | |||
| dim result : set result = Automapper().DynMap(src, target, array("SomeString", "SomeDate"), empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 54321, result.SomeInt, "SomeInt should have been left untouched, but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim result : set result = Automapper().DynMap(src, "Test_DynMap_Class", empty, empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_New_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim result : set result = Automapper().DynMap(src, "Test_DynMap_Class", array("SomeString", "SomeDate"), empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertNotExists result.SomeInt, "SomeInt should have been left uninitialized, but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_DynMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim target : set target = new Test_DynMap_Class | |||
| dim result : set result = Automapper.DynMap(src, target, empty, empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_Existing_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_DynMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim target : set target = new Test_DynMap_Class | |||
| target.SomeInt = 54321 | |||
| dim result : set result = Automapper.DynMap(src, target, array("SomeString", "SomeDate"), empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 54321, result.SomeInt, "SomeInt should have been left alone but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_DynMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim result : set result = Automapper.DynMap(src, "Test_DynMap_Class", empty, empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_New_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_DynMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim result : set result = Automapper.DynMap(src, "Test_DynMap_Class", array("SomeString", "SomeDate"), empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertNotExists result.SomeInt, "SomeInt should have been left uninitialized, but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_Existing_Class_Instance_Maps_One_Expression(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_DynMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim target : set target = new Test_DynMap_Class | |||
| dim result : set result = Automapper.DynMap(src, target, empty, "target.SomeString = ucase(src.SomeString)") | |||
| T.AssertEqual "SOME STRING HERE", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_Existing_Class_Instance_Maps_Multiple_Expressions(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_DynMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim target : set target = new Test_DynMap_Class | |||
| dim result : set result = Automapper.DynMap(src, target, empty, _ | |||
| array("target.SomeString = ucase(src.SomeString)", _ | |||
| "target.SomeInt = src.SomeInt * 2", _ | |||
| "target.SomeDate = Year(src.SomeDate)")) | |||
| T.AssertEqual "SOME STRING HERE", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual (12345 * 2), result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual Year(dtm), result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,236 @@ | |||
| <% | |||
| Class Test_FlexMap_Class | |||
| Public SomeString, SomeInt, SomeDate | |||
| Public Property Get Class_Get_Properties : Class_Get_Properties = Array("SomeString", "SomeInt", "SomeDate") : End Property | |||
| End Class | |||
| Class FlexMap_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Test_From_Recordset_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Recordset_To_Existing_Class_Instance_Maps_Only_Specified_Fields", _ | |||
| "Test_From_Recordset_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Recordset_To_New_Class_Instance_Maps_Only_Specified_Fields", _ | |||
| "Test_From_Class_Instance_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Class_Instance_To_Existing_Class_Instance_Maps_Only_Specified_Fields", _ | |||
| "Test_From_Class_Instance_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields", _ | |||
| "Test_From_Class_Instance_To_New_Class_Instance_Maps_Only_Specified_Fields") | |||
| End Function | |||
| Private Sub Destroy(o) | |||
| on error resume next | |||
| o.close | |||
| on error goto 0 | |||
| set o = nothing | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim target : set target = new Test_FlexMap_Class | |||
| dim result : set result = Automapper().FlexMap(src, target, empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_Existing_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim target : set target = new Test_FlexMap_Class | |||
| target.SomeInt = 54321 | |||
| dim result : set result = Automapper().FlexMap(src, target, array("SomeString", "SomeDate")) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 54321, result.SomeInt, "SomeInt should have been left untouched, but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim result : set result = Automapper().FlexMap(src, "Test_FlexMap_Class", empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Recordset_To_New_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim src : set src = Server.CreateObject("ADODB.Recordset") | |||
| with src.Fields | |||
| .Append "SomeString", adVarChar, 100 | |||
| .Append "SomeInt", adInteger | |||
| .Append "SomeDate", adDate | |||
| end with | |||
| dim dtm : dtm = Now | |||
| src.Open | |||
| src.AddNew | |||
| src("SomeString") = "Some string here" | |||
| src("SomeInt") = 12345 | |||
| src("SomeDate") = dtm | |||
| src.Update | |||
| src.MoveFirst | |||
| dim result : set result = Automapper().FlexMap(src, "Test_FlexMap_Class", array("SomeString", "SomeDate")) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertNotExists result.SomeInt, "SomeInt should have been left uninitialized, but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_Existing_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_FlexMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim target : set target = new Test_FlexMap_Class | |||
| dim result : set result = Automapper.FlexMap(src, target, empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_Existing_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_FlexMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim target : set target = new Test_FlexMap_Class | |||
| target.SomeInt = 54321 | |||
| dim result : set result = Automapper.FlexMap(src, target, array("SomeString", "SomeDate")) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| 'T.AssertNotExists result.SomeInt, "SomeInt should have been left uninitialized, but was mapped anyway." | |||
| T.AssertEqual 54321, result.SomeInt, "SomeInt should have been left alone but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy target | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_New_Class_Instance_With_Empty_Fields_Array_Maps_All_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_FlexMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim result : set result = Automapper.FlexMap(src, "Test_FlexMap_Class", empty) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertEqual 12345, result.SomeInt, "Failed to map SomeInt." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_From_Class_Instance_To_New_Class_Instance_Maps_Only_Specified_Fields(T) | |||
| dim dtm : dtm = Now | |||
| dim src : set src = new Test_FlexMap_Class | |||
| src.SomeString = "Some string here" | |||
| src.SomeInt = 12345 | |||
| src.SomeDate = dtm | |||
| dim result : set result = Automapper.FlexMap(src, "Test_FlexMap_Class", array("SomeString", "SomeDate")) | |||
| T.AssertEqual "Some string here", result.SomeString, "Failed to map SomeString." | |||
| T.AssertNotExists result.SomeInt, "SomeInt should have been left uninitialized, but was mapped anyway." | |||
| T.AssertEqual dtm, result.SomeDate, "Failed to map SomeDate." | |||
| Destroy src | |||
| Destroy result | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,24 @@ | |||
| <% | |||
| '======================================================================================================================= | |||
| ' Automapper Function Test Cases | |||
| '======================================================================================================================= | |||
| Class Automapper_Function_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Test_Automap_Function_Returns_Instance", "Test_Automap_Function_Returns_New_Instance") | |||
| End Function | |||
| Public Sub Test_Automap_Function_Returns_Instance(T) | |||
| T.AssertEquals "Automapper_Class", typename(Automapper()), "Function Automapper() should return a new instance of Automapper_Class" | |||
| End Sub | |||
| Public Sub Test_Automap_Function_Returns_New_Instance(T) | |||
| dim a : set a = Automapper() | |||
| dim b : set b = Automapper() | |||
| T.AssertFalse (a is b), "Automapper() function should return distinct instances of the Automapper_Class" | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,349 @@ | |||
| <% | |||
| Class EnumerableHelper_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Test_Enumerable_Function_Returns_EnumerableHelper_Instance", _ | |||
| "Test_Map_Returns_EnumerableHelper_Instance", _ | |||
| "Test_Map_Lambda", _ | |||
| "Test_Map_Proc", _ | |||
| "Test_Max_Lambda", _ | |||
| "Test_Max_Proc", _ | |||
| "Test_Min_Lambda", _ | |||
| "Test_Min_Proc", _ | |||
| "Test_Take", _ | |||
| "Test_TakeWhile_Lambda", _ | |||
| "Test_TakeWhile_Proc", _ | |||
| "Test_Sum", _ | |||
| "Test_All", _ | |||
| "Test_Any", _ | |||
| "Test_Where_Lambda", _ | |||
| "Test_Where_Proc", _ | |||
| "Test_Count", _ | |||
| "Test_First", _ | |||
| "Test_Last", _ | |||
| "Test_Chained") | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Enumerable_Function_Returns_EnumerableHelper_Instance(T) | |||
| dim list : set list = new LinkedList_Class | |||
| dim E : set E = Enumerable(list) | |||
| T.Assert typename(E) = "EnumerableHelper_Class", "did not return correct instance" | |||
| T.Assert typename(E.Data) = "LinkedList_Class", "Data() is of type " & typename(E.Data) | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Map_Returns_EnumerableHelper_Instance(T) | |||
| dim list : set list = new LinkedList_Class | |||
| dim E : set E = Enumerable(list).Map("") | |||
| T.Assert typename(E) = "EnumerableHelper_Class", "returned type " & typename(E) | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Map_Lambda(T) | |||
| dim list : set list = OrderedList(10) | |||
| dim E : set E = Enumerable(list).Map("dim x : x = item_ + 1 : V_ = x") | |||
| T.Assert 10 = E.Data.Count, "count: " & E.Data.Count | |||
| dim A : A = list.To_Array() | |||
| dim B : B = E.Data.To_Array() | |||
| T.Assert UBound(A) = UBound(B), "A = " & UBound(A) & ", B = " & UBound(B) | |||
| dim i | |||
| For i = 0 to UBound(A) | |||
| T.Assert B(i) = A(i) + 1, "B(" & i & ") = " & B(i) & ", A(" & i & ") = " & A(i) | |||
| Next | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Map_Proc(T) | |||
| dim list : set list = OrderedList(10) | |||
| dim E : set E = Enumerable(list).Map(GetRef("AddOne")) | |||
| T.Assert 10 = E.Data.Count, "count: " & E.Data.Count | |||
| dim A : A = list.To_Array() | |||
| dim B : B = E.Data.To_Array() | |||
| T.Assert UBound(A) = UBound(B), "A = " & UBound(A) & ", B = " & UBound(B) | |||
| dim i | |||
| For i = 0 to UBound(A) | |||
| T.Assert B(i) = A(i) + 1, "B(" & i & ") = " & B(i) & ", A(" & i & ") = " & A(i) | |||
| Next | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Max_Lambda(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim val : val = Enumerable(list).Max("len(item_)") | |||
| T.Assert 7 = val, "val = " & val | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Max_Proc(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim val : val = Enumerable(list).Max(GetRef("GetLength")) | |||
| T.Assert 7 = val, "val = " & val | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Min_Lambda(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim val : val = Enumerable(list).Min("len(item_)") | |||
| T.Assert 3 = val, "val = " & val | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Min_Proc(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim val : val = Enumerable(list).Min(GetRef("GetLength")) | |||
| T.Assert 3 = val, "val = " & val | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Take(T) | |||
| dim list : set list = OrderedList(3) | |||
| dim firstTwo : set firstTwo = Enumerable(list).Take(2) | |||
| T.Assert typename(firstTwo) = "EnumerableHelper_Class", "typename = " & typename(firstTwo) | |||
| dim L : set L = firstTwo.Data | |||
| T.AssertEqual 2, L.Count, "Count = " & L.Count | |||
| T.AssertEqual 1, L.Front, "Front = " & L.Front | |||
| T.AssertEqual 2, L.Back, "Back = " & L.Back | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_TakeWhile_Lambda(T) | |||
| dim list : set list = OrderedList(5) | |||
| dim firstTwo : set firstTwo = Enumerable(list).TakeWhile("item_ < 3") | |||
| T.Assert typename(firstTwo) = "EnumerableHelper_Class", "typename = " & typename(firstTwo) | |||
| dim L : set L = firstTwo.Data | |||
| T.AssertEqual 2, L.Count, "Count = " & L.Count | |||
| T.AssertEqual 1, L.Front, "Front = " & L.Front | |||
| T.AssertEqual 2, L.Back, "Back = " & L.Back | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_TakeWhile_Proc(T) | |||
| dim list : set list = OrderedList(5) | |||
| dim firstTwo : set firstTwo = Enumerable(list).TakeWhile(GetRef("IsLessThanThree")) | |||
| T.Assert typename(firstTwo) = "EnumerableHelper_Class", "typename = " & typename(firstTwo) | |||
| dim L : set L = firstTwo.Data | |||
| T.AssertEqual 2, L.Count, "Count = " & L.Count | |||
| T.AssertEqual 1, L.Front, "Front = " & L.Front | |||
| T.AssertEqual 2, L.Back, "Back = " & L.Back | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Sum(T) | |||
| dim list : set list = OrderedList(5) | |||
| dim val : val = Enumerable(list).Sum("item_") | |||
| T.AssertEqual val, 15, "simple: val = " & val | |||
| val = Enumerable(list).Sum("item_ * item_") | |||
| T.AssertEqual val, 55, "squares: val = " & val | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_All(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim val | |||
| val = Enumerable(list).All("len(item_) >= 3") | |||
| T.Assert val, "Len >= 3: val = " & val | |||
| val = Enumerable(list).All("len(item_) = 3") | |||
| T.AssertFalse val, "Len = 3: val = " & val | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Any(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim val | |||
| val = Enumerable(list).Any("len(item_) >= 3") | |||
| T.Assert val, "Len >= 3: val = " & val | |||
| val = Enumerable(list).Any("len(item_) < 3") | |||
| T.AssertFalse val, "Len < 3: val = " & val | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Where_Lambda(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim list2 | |||
| set list2 = Enumerable(list).Where("len(item_) > 4") | |||
| T.AssertEqual 2, list2.Data.Count, "list2.Count = " & list2.Data.Count | |||
| T.AssertEqual "Alice", list2.Data.Front(), "list2.Data.Front = " & list2.Data.Front() | |||
| T.AssertEqual "Charlie", list2.Data.Back(), "list2.Data.Front = " & list2.Data.Back() | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Where_Proc(T) | |||
| dim list : set list = new LinkedList_Class | |||
| list.Push "Alice" | |||
| list.Push "Bob" | |||
| list.Push "Charlie" | |||
| list.Push "Doug" | |||
| dim E : set E = Enumerable(list).Where(GetRef("IsMoreThanFourChars")) | |||
| T.AssertEqual 2, E.Data.Count, "E.Count = " & E.Data.Count | |||
| T.AssertEqual "Alice", E.Data.Front(), "E.Data.Front = " & E.Data.Front() | |||
| T.AssertEqual "Charlie", E.Data.Back(), "E.Data.Front = " & E.Data.Back() | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Count(T) | |||
| dim list : set list = OrderedList(10) | |||
| dim E : set E = Enumerable(list) | |||
| T.AssertEqual 10, E.Count(), empty | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_First(T) | |||
| dim list : set list = OrderedList(10) | |||
| dim E : set E = Enumerable(list) | |||
| T.AssertEqual 1, E.First(), empty | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Last(T) | |||
| dim list : set list = OrderedList(10) | |||
| dim E : set E = Enumerable(list) | |||
| T.AssertEqual 10, E.Last(), empty | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Chained(T) | |||
| dim list : set list = OrderedList(10) | |||
| dim it, item | |||
| dim A : set A = Enumerable(list).Take(5).Where("item_ mod 2 <> 0") | |||
| T.AssertEqual 3, A.Data.Count, "A.Count = " & A.Data.Count | |||
| set it = A.Data.Iterator | |||
| item = it.GetNext() | |||
| T.AssertEqual 1, item, "A 1st item = " & item | |||
| item = it.GetNext() | |||
| T.AssertEqual 3, item, "A 2nd item = " & item | |||
| item = it.GetNext() | |||
| T.AssertEqual 5, item, "A 3rd item = " & item | |||
| dim B : set B = Enumerable(list).Take(5).Select("V_ = item_ * item_") | |||
| T.AssertEqual 5, B.Data.Count, "B.Count = " & B.Data.Count | |||
| set it = B.Data.Iterator | |||
| item = it.GetNext() | |||
| T.AssertEqual 1, item, "B 1st item = " & item | |||
| item = it.GetNext() | |||
| T.AssertEqual 4, item, "B 2nd item = " & item | |||
| item = it.GetNext() | |||
| T.AssertEqual 9, item, "B 3rd item = " & item | |||
| item = it.GetNext() | |||
| T.AssertEqual 16, item, "B 4th item = " & item | |||
| item = it.GetNext() | |||
| T.AssertEqual 25, item, "B 5th item = " & item | |||
| dim list2 : set list2 = new LinkedList_Class | |||
| list2.Push "Alice" | |||
| list2.Push "Bob" | |||
| list2.Push "Charlie" | |||
| list2.Push "Doug" | |||
| list2.Push "Edward" | |||
| list2.Push "Franklin" | |||
| list2.Push "George" | |||
| list2.Push "Hal" | |||
| list2.Push "Isaac" | |||
| list2.Push "Jeremy" | |||
| dim C : C = Enumerable(list2) _ | |||
| .Where("len(item_) > 5") _ | |||
| .Map("set V_ = new ChainedExample_Class : V_.Data = item_ : V_.Length = len(item_)") _ | |||
| .Max("item_.Length") | |||
| T.AssertEqual 8, C, "C" | |||
| End Sub | |||
| End Class | |||
| Class ChainedExample_Class | |||
| Public Data | |||
| Public Length | |||
| End Class | |||
| Function OrderedList(maxnum) | |||
| dim list : set list = new LinkedList_Class | |||
| dim i | |||
| For i = 1 to maxnum | |||
| list.Push i | |||
| Next | |||
| set OrderedList = list | |||
| End Function | |||
| Function AddOne(x) | |||
| AddOne = x + 1 | |||
| End Function | |||
| Function GetLength(s) | |||
| GetLength = Len(s) | |||
| End Function | |||
| Function IsLessThanThree(x) | |||
| IsLessThanThree = x < 3 | |||
| End Function | |||
| Function IsMoreThanFourChars(s) | |||
| IsMoreThanFourChars = Len(s) > 4 | |||
| End Function | |||
| %> | |||
| @@ -0,0 +1,16 @@ | |||
| <% | |||
| Class HtmlHelper_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Public Sub DropDownList_Should_Handle_Recordsets") | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub DropDownList_Should_Handle_Recordsets(T) | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,261 @@ | |||
| <% | |||
| Const SMALL_SIZE = 10 | |||
| Const MEDIUM_SIZE = 100 | |||
| Const LARGE_SIZE = 1000 | |||
| Const EXTREME_SIZE = 10000 | |||
| Class Performance_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Private m_output | |||
| Private Sub Out(s) | |||
| m_output = m_output & s | |||
| End Sub | |||
| Private Sub OutLn(s) | |||
| Out s & "<br>" | |||
| End Sub | |||
| Private Sub Class_Initialize | |||
| m_output = "" | |||
| OutLn "<table width='30%'>" | |||
| End Sub | |||
| Private Sub Class_Terminate | |||
| Out "</table>" | |||
| response.write m_output | |||
| End Sub | |||
| Private Sub Header(s) | |||
| Out "<tr><th colspan='2'><h1>" & s & "</h1></th></tr>" | |||
| Out "<tr><th style='text-align: left'>Name</th><th style='text-align: left'>Duration</th></tr>" | |||
| End Sub | |||
| Private Sub Blank | |||
| Out "<tr><td> </td></tr>" | |||
| End Sub | |||
| Private Sub Profile(name, size, start, finish) | |||
| Out "<tr><td>" & name & " (" & size & " nodes)</td><td>" & Round(finish - start, 2) * 1000 & "ms</td></tr>" | |||
| End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Test_LinkedList", "Test_DynamicArray", "Test_ArrayList") | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'Linked List Performance Tests | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_LinkedList(T) | |||
| Header "LinkedList_Class" | |||
| LL_Push SMALL_SIZE | |||
| LL_Get SMALL_SIZE | |||
| LL_Remove SMALL_SIZE | |||
| Blank | |||
| LL_Push MEDIUM_SIZE | |||
| LL_Get MEDIUM_SIZE | |||
| LL_Remove MEDIUM_SIZE | |||
| Blank | |||
| LL_Push LARGE_SIZE | |||
| LL_Get LARGE_SIZE | |||
| LL_Remove LARGE_SIZE | |||
| Blank | |||
| LL_Push EXTREME_SIZE | |||
| LL_Get EXTREME_SIZE | |||
| LL_Remove EXTREME_SIZE | |||
| End Sub | |||
| Private Sub LL_Push(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = new LinkedList_Class | |||
| dim i | |||
| start = Timer | |||
| for i = 1 to num_nodes | |||
| list.Push i | |||
| next | |||
| finish = Timer | |||
| Profile "Add all nodes", num_nodes, start, finish | |||
| End Sub | |||
| Private Sub LL_Get(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = new LinkedList_Class | |||
| dim i | |||
| start = Timer | |||
| dim it : set it = list.Iterator | |||
| while it.HasNext | |||
| it.GetNext | |||
| wend | |||
| finish = Timer | |||
| Profile "Get all nodes", num_nodes, start, finish | |||
| End Sub | |||
| Private Sub LL_Remove(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = new LinkedList_Class | |||
| dim i | |||
| start = Timer | |||
| while list.Count > 0 | |||
| list.Pop | |||
| wend | |||
| finish = Timer | |||
| Profile "Remove all nodes", num_nodes, start, finish | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| 'ArrayList Performance Tests | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_ArrayList(T) | |||
| Header ".NET ArrayList" | |||
| AL_Add SMALL_SIZE | |||
| AL_Get SMALL_SIZE | |||
| AL_Remove SMALL_SIZE | |||
| Blank | |||
| AL_Add MEDIUM_SIZE | |||
| AL_Get MEDIUM_SIZE | |||
| AL_Remove MEDIUM_SIZE | |||
| Blank | |||
| AL_Add LARGE_SIZE | |||
| AL_Get LARGE_SIZE | |||
| AL_Remove LARGE_SIZE | |||
| Blank | |||
| AL_Add EXTREME_SIZE | |||
| AL_Get EXTREME_SIZE | |||
| AL_Remove EXTREME_SIZE | |||
| End Sub | |||
| Private Sub AL_Add(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = Server.CreateObject("System.Collections.ArrayList") | |||
| dim i | |||
| start = Timer | |||
| for i = 1 to num_nodes | |||
| list.Add i | |||
| next | |||
| finish = Timer | |||
| Profile "Add all nodes", num_nodes, start, finish | |||
| End Sub | |||
| Private Sub AL_Get(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = Server.CreateObject("System.Collections.ArrayList") | |||
| dim i | |||
| start = Timer | |||
| dim elt | |||
| for each elt in list | |||
| 'nop | |||
| next | |||
| finish = Timer | |||
| Profile "Get all nodes", num_nodes, start, finish | |||
| End Sub | |||
| Private Sub AL_Remove(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = Server.CreateObject("System.Collections.ArrayList") | |||
| dim i | |||
| start = Timer | |||
| list.RemoveRange 0, list.Count | |||
| finish = Timer | |||
| Profile "Remove all nodes", num_nodes, start, finish | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| ' DynamicArray Tests | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_DynamicArray(T) | |||
| Header "DynamicArray_Class" | |||
| DA_Push SMALL_SIZE | |||
| DA_Get SMALL_SIZE | |||
| DA_Pop SMALL_SIZE | |||
| Blank | |||
| 'DA_Push MEDIUM_SIZE | |||
| 'DA_Get MEDIUM_SIZE | |||
| 'DA_Pop MEDIUM_SIZE | |||
| ' | |||
| 'Blank | |||
| ' | |||
| 'DA_Push LARGE_SIZE | |||
| 'DA_Get LARGE_SIZE | |||
| 'DA_Pop LARGE_SIZE | |||
| ' | |||
| 'Blank | |||
| ' | |||
| 'DA_Push EXTREME_SIZE | |||
| 'DA_Get EXTREME_SIZE | |||
| 'DA_Pop EXTREME_SIZE | |||
| End Sub | |||
| Private Sub DA_Push(num_nodes) | |||
| dim start, finish | |||
| 'dim arr : arr = array() | |||
| 'redim arr(100) | |||
| 'dim list : set list = DynamicArray(arr) | |||
| dim list : set list = DynamicArray() | |||
| dim i | |||
| start = Timer | |||
| for i = 1 to num_nodes | |||
| list.Push i | |||
| next | |||
| finish = Timer | |||
| Profile "Add all nodes", num_nodes, start, finish | |||
| End Sub | |||
| Private Sub DA_Get(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = new DynamicArray_Class | |||
| dim arr : arr = array() | |||
| list.Initialize arr, 100 | |||
| dim i | |||
| start = Timer | |||
| dim it : set it = list.Iterator | |||
| while it.HasNext | |||
| it.GetNext | |||
| wend | |||
| finish = Timer | |||
| Profile "Get all nodes", num_nodes, start, finish | |||
| End Sub | |||
| Private Sub DA_Pop(num_nodes) | |||
| dim start, finish | |||
| dim list : set list = new DynamicArray_Class | |||
| dim arr : arr = array() | |||
| list.Initialize arr, 100 | |||
| dim i | |||
| start = Timer | |||
| while list.Count > 0 | |||
| list.Pop | |||
| wend | |||
| finish = Timer | |||
| Profile "Remove all nodes", num_nodes, start, finish | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,60 @@ | |||
| <% | |||
| Class StringBuilder_Tests | |||
| Public Sub Setup : End Sub | |||
| Public Sub Teardown : End Sub | |||
| Public Function TestCaseNames | |||
| TestCaseNames = Array("Test_Initialized_Object_Should_Be_Empty", _ | |||
| "Test_StringBuilder_Function_Should_Return_Initialized_Object", _ | |||
| "Test_Default_Property_Should_Be_String", _ | |||
| "Test_Default_String_Should_Not_Have_Spaces_Between_Entries", _ | |||
| "Test_Join_Should_Allow_Custom_Delimiter_Between_Entries") | |||
| End Function | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Initialized_Object_Should_Be_Empty(T) | |||
| dim SB : set SB = new StringBuilder_Class | |||
| T.AssertEqual "", SB.TO_String, "Initialized object does not have an empty string." | |||
| set SB = Nothing | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_StringBuilder_Function_Should_Return_Initialized_Object(T) | |||
| dim SB : set SB = new StringBuilder_Class | |||
| T.AssertEqual "", SB.TO_String, "StringBuilder() function did not return initialized object." | |||
| set SB = Nothing | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Default_Property_Should_Be_String(T) | |||
| dim SB : set SB = StringBuilder() | |||
| T.AssertType "String", typename( (SB) ), "Object should default to string output." | |||
| set SB = Nothing | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Default_String_Should_Not_Have_Spaces_Between_Entries(T) | |||
| dim SB : set SB = StringBuilder() | |||
| SB.Add "foo" | |||
| SB.Add "bar" | |||
| SB.Add "baz" | |||
| T.AssertEqual "foobarbaz", SB.TO_String, "Default string should not have spaces between entries." | |||
| set SB = Nothing | |||
| End Sub | |||
| '--------------------------------------------------------------------------------------------------------------------- | |||
| Public Sub Test_Join_Should_Allow_Custom_Delimiter_Between_Entries(T) | |||
| dim SB : set SB = StringBuilder() | |||
| SB.Add "foo" | |||
| SB.Add "bar" | |||
| SB.Add "baz" | |||
| T.AssertEqual "foo bar baz", SB.Get(" "), "Get() should allow a space between entries." | |||
| T.AssertEqual "foo---bar---baz", SB.Get("---"), "Get() should allow --- between entries." | |||
| T.AssertEqual "foo" & Chr(27) & "bar" & Chr(27) & "baz", SB.Get(Chr(27)), "Get() should allow non-standard ASCII character between entries." | |||
| set SB = Nothing | |||
| End Sub | |||
| End Class | |||
| %> | |||
| @@ -0,0 +1,30 @@ | |||
| <% | |||
| Option Explicit | |||
| %> | |||
| <!--#include file="../MVC/lib.all.asp"--> | |||
| <!--#include file="ASPUnit/include/ASPUnitRunner.asp"--> | |||
| <!--#include file="TestCase_Automapper_Function.asp"--> | |||
| <!--#include file="TestCase_Automapper_AutoMap.asp"--> | |||
| <!--#include file="TestCase_Automapper_FlexMap.asp"--> | |||
| <!--#include file="TestCase_Automapper_DynMap.asp"--> | |||
| <!--#include file="TestCase_StringBuilder.asp"--> | |||
| <!--#include file="TestCase_HtmlHelperDropdownLists.asp"--> | |||
| <% | |||
| 'Used in some of the test case classes included into this file. | |||
| 'Could remove and just use inline numbers in the classes and comment what they mean when called. | |||
| 'Ref: http://www.w3schools.com/ado/ado_datatypes.asp | |||
| dim adVarChar : adVarChar = CInt(200) | |||
| dim adInteger : adInteger = CInt(3) | |||
| dim adBoolean : adBoolean = CInt(11) | |||
| dim adDate : adDate = CInt(7) | |||
| dim Runner : set Runner = new UnitRunner | |||
| Runner.AddTestContainer new Automapper_Function_Tests | |||
| Runner.AddTestContainer new AutoMap_Tests | |||
| Runner.AddTestContainer new FlexMap_Tests | |||
| Runner.AddTestContainer new DynMap_Tests | |||
| Runner.AddTestContainer new StringBuilder_Tests | |||
| Runner.Display | |||
| %> | |||
| @@ -0,0 +1,26 @@ | |||
| <% | |||
| Option Explicit | |||
| %> | |||
| <!--#include file="../MVC/lib.Automapper.asp"--> | |||
| <!--#include file="ASPUnit/include/ASPUnitRunner.asp"--> | |||
| <!--#include file="TestCase_Automapper_Function.asp"--> | |||
| <!--#include file="TestCase_Automapper_AutoMap.asp"--> | |||
| <!--#include file="TestCase_Automapper_FlexMap.asp"--> | |||
| <!--#include file="TestCase_Automapper_DynMap.asp"--> | |||
| <% | |||
| 'Used in each of the test case classes included into this file | |||
| 'could remove and just use inline numbers in the classes and comment what they mean when called | |||
| 'Ref: http://www.w3schools.com/ado/ado_datatypes.asp | |||
| dim adVarChar : adVarChar = CInt(200) | |||
| dim adInteger : adInteger = CInt(3) | |||
| dim adBoolean : adBoolean = CInt(11) | |||
| dim adDate : adDate = CInt(7) | |||
| dim Runner : set Runner = new UnitRunner | |||
| Runner.AddTestContainer new Automapper_Function_Tests | |||
| Runner.AddTestContainer new AutoMap_Tests | |||
| Runner.AddTestContainer new FlexMap_Tests | |||
| Runner.AddTestContainer new DynMap_Tests | |||
| Runner.Display | |||
| %> | |||
| @@ -0,0 +1,12 @@ | |||
| <% | |||
| Option Explicit | |||
| %> | |||
| <!--#include file="../MVC/lib.all.asp"--> | |||
| <!--#include file="ASPUnit/include/ASPUnitRunner.asp"--> | |||
| <!--#include file="TestCase_EnumerableHelper.asp"--> | |||
| <% | |||
| dim Runner | |||
| set Runner = new UnitRunner | |||
| Runner.AddTestContainer new EnumerableHelper_Tests | |||
| Runner.Display | |||
| %> | |||
| @@ -0,0 +1,12 @@ | |||
| <% | |||
| Option Explicit | |||
| %> | |||
| <!--#include file="../MVC/lib.Strings.asp"--> | |||
| <!--#include file="ASPUnit/include/ASPUnitRunner.asp"--> | |||
| <!--#include file="TestCase_HtmlHelperDropdownLists.asp"--> | |||
| <% | |||
| dim Runner | |||
| set Runner = new UnitRunner | |||
| Runner.AddTestContainer new HtmlHelper_Tests | |||
| Runner.Display | |||
| %> | |||
| @@ -0,0 +1,12 @@ | |||
| <% | |||
| Option Explicit | |||
| %> | |||
| <!--#include file="../MVC/lib.all.asp"--> | |||
| <!--#include file="ASPUnit/include/ASPUnitRunner.asp"--> | |||
| <!--#include file="TestCase_Performance.asp"--> | |||
| <% | |||
| dim Runner | |||
| set Runner = new UnitRunner | |||
| Runner.AddTestContainer new Performance_Tests | |||
| Runner.Display | |||
| %> | |||
| @@ -0,0 +1,12 @@ | |||
| <% | |||
| Option Explicit | |||
| %> | |||
| <!--#include file="../MVC/lib.Strings.asp"--> | |||
| <!--#include file="ASPUnit/include/ASPUnitRunner.asp"--> | |||
| <!--#include file="TestCase_StringBuilder.asp"--> | |||
| <% | |||
| dim Runner | |||
| set Runner = new UnitRunner | |||
| Runner.AddTestContainer new StringBuilder_Tests | |||
| Runner.Display | |||
| %> | |||
| @@ -0,0 +1,3 @@ | |||
| <% Response.Redirect "App/Controllers/Jurisdiction/JurisdictionController.asp" %> | |||
| @@ -0,0 +1,10 @@ | |||
| <?xml version="1.0" encoding="UTF-8"?> | |||
| <configuration> | |||
| <system.webServer> | |||
| <defaultDocument> | |||
| <files> | |||
| <add value="index.asp" /> | |||
| </files> | |||
| </defaultDocument> | |||
| </system.webServer> | |||
| </configuration> | |||
Powered by TurnKey Linux.