public string GetLoginPassword(string emailAddress) { string script = ReadSQLScript("GetLoginPassword.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@EmailAddress", emailAddress) }; var ds = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); if (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 1) { string password = (string)ds.Tables[0].Rows[0]["PasswordHash"]; return(Cipher.Decrypt(password)); } return(string.Empty); //no login found }
public byte[] GetUnitFile(Guid unitDocumentId) { string script = ReadSQLScript("GetUnitFile.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@UnitDocumentId", unitDocumentId), }; var ds = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); if (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 1) { var val = ds.Tables[0].Rows[0]["DocumentData"]; return(ReadBinaryValue(val)); } return(null); }
public string UploadUnitDocument(DocumentCategoryType documentType, DateTime fileDate, int buildingId, string accountNumber, string filename, string title, byte[] data, string emailAddress) { if (string.IsNullOrWhiteSpace(title)) { title = "Correspondence "; } filename = Path.GetFileName(filename); filename = filename.Replace(" ", ""); //return a URL to the uploaded document Guid documentId = System.Guid.NewGuid(); if (title.Length > MAX_TITLE_LENGTH) { title = title.Substring(0, MAX_TITLE_LENGTH); } if (filename.Length > MAX_FILENAME_LENGTH) { filename = Path.GetFileNameWithoutExtension(filename).Substring(0, MAX_FILENAME_LENGTH - 4) + "." + Path.GetExtension(filename); } string script = ReadSQLScript("UploadUnitDocument.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@DocumentType", (int)documentType), new System.Data.SqlClient.SqlParameter("@BuildingId", buildingId), new System.Data.SqlClient.SqlParameter("@AccountNumber", accountNumber), new System.Data.SqlClient.SqlParameter("@Filename", filename), new System.Data.SqlClient.SqlParameter("@Description", title), new System.Data.SqlClient.SqlParameter("@FileDate", fileDate), new System.Data.SqlClient.SqlParameter("@DocumentId", documentId), new System.Data.SqlClient.SqlParameter("@Data", data), }; var result = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); documentId = (Guid)result.Tables[0].Rows[0]["Id"]; return(GetUnitDocumentLink(documentId, emailAddress)); }
public List <WebDocumentAccessLogItem> GetUnitFileAccessHistory(Guid unitDocumentId) { string script = ReadSQLScript("GetUnitFileAccesHistory.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@UnitDocumentId", unitDocumentId), }; var ds = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); List <WebDocumentAccessLogItem> result = new List <WebDocumentAccessLogItem>(); foreach (DataRow row in ds.Tables[0].Rows) { result.Add(new WebDocumentAccessLogItem(row)); } return(result); }
public List <FileDetail> BuildingDocumentList(int buildingId, bool activeOnly = true) { string script = ReadSQLScript("BuildingDocumentList.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@BuildingId", buildingId), new System.Data.SqlClient.SqlParameter("@ActiveOnly", activeOnly) }; var data = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); List <FileDetail> result = new List <FileDetail>(); foreach (DataRow row in data.Tables[0].Rows) { result.Add(new FileDetail(row)); } return(result); }
public List <string> GetLinkedUnits(int buildingId, string emailAddress) { List <string> accountNumbers = new List <string>(); string script = ReadSQLScript("GetLinkedUnits.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@EmailAddress", emailAddress), new System.Data.SqlClient.SqlParameter("@BuildingId", buildingId) }; var ds = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); if (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { accountNumbers.Add((string)row["AccountNumber"]); } } return(accountNumbers); }
public string UploadBuildingDocument(DocumentCategoryType documentType, DateTime fileDate, int buildingId, string description, string filename, byte[] fileData, string emailAddress) { filename = Path.GetFileName(filename); //return a URL to the uploaded document if (description.Length > MAX_TITLE_LENGTH) { description = description.Substring(0, MAX_TITLE_LENGTH); } if (filename.Length > MAX_FILENAME_LENGTH) { filename = Path.GetFileNameWithoutExtension(filename).Substring(0, MAX_FILENAME_LENGTH - 4) + "." + Path.GetExtension(filename); } Guid documentId = System.Guid.NewGuid(); string script = ReadSQLScript("UploadBuildingDocument.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@DocumentType", (int)documentType), new System.Data.SqlClient.SqlParameter("@BuildingId", buildingId), new System.Data.SqlClient.SqlParameter("@Filename", filename), new System.Data.SqlClient.SqlParameter("@Description", description), new System.Data.SqlClient.SqlParameter("@FileDate", fileDate), new System.Data.SqlClient.SqlParameter("@DocumentId", documentId), new System.Data.SqlClient.SqlParameter("@Data", fileData), }; var result = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); documentId = (Guid)result.Tables[0].Rows[0]["Id"]; return(GetBuildingDocumentLink(documentId, emailAddress)); }
public byte[] GetBuildingImage(int buildingId) { byte[] result = null; string script = ReadSQLScript("GetBuildingImage.sql"); var parameters = new List <System.Data.SqlClient.SqlParameter>() { new System.Data.SqlClient.SqlParameter("@BuildingId", buildingId) }; var ds = SQLUtilities.FetchData(_ClientProtalConnection, script, parameters); if (ds.Tables.Count == 1 && ds.Tables[0].Rows.Count == 1) { var val = ds.Tables[0].Rows[0]["BuildingImage"]; result = ReadBinaryValue(val); } if (result == null) { result = ReadDefaultImage(); } return(result); }