public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(ProductID); sb.Append(';'); sb.Append(LicenseKey); sb.Append(';'); sb.Append(CustomerName); sb.Append(';'); sb.Append(ContactName); sb.Append(';'); sb.Append(Email); sb.Append(';'); sb.Append(Tel); sb.Append(';'); sb.Append(Address); sb.Append(';'); sb.Append(IPAddr.ToString()); sb.Append(';'); sb.Append(VersionName); sb.Append(';'); sb.Append(ExpiredDate.ToString("yyyy-MM-dd")); return(sb.ToString()); }
public static string GenerateToken(UserDTO usersDTO) { string hashuseremail = ""; string hashuserid = ""; string hashtenantid = ""; string hashusername = ""; string generateDAte = ""; string expiredDate = ""; string databasename = ""; string hashexpired = ""; string usersIds = ""; DateTime ExpiredDate; DateTime GeneratedDate; GeneratedDate = DateTime.Now; ExpiredDate = DateTime.Now.AddHours(1); hashuseremail = Convert.ToBase64String(Encoding.UTF8.GetBytes(usersDTO.UserEmail)); hashuserid = Convert.ToBase64String(Encoding.UTF8.GetBytes(usersDTO.Id.ToString())); hashtenantid = Convert.ToBase64String(Encoding.UTF8.GetBytes(usersDTO.TenantId.ToString())); hashusername = Convert.ToBase64String(Encoding.UTF8.GetBytes(usersDTO.UserName.ToString())); generateDAte = Convert.ToBase64String(Encoding.UTF8.GetBytes(GeneratedDate.ToString())); expiredDate = Convert.ToBase64String(Encoding.UTF8.GetBytes(ExpiredDate.ToString())); if (usersDTO.DatabaseName != null) { databasename = Convert.ToBase64String(Encoding.UTF8.GetBytes(usersDTO.DatabaseName.ToString())); } else { databasename = Convert.ToBase64String(Encoding.UTF8.GetBytes("NODATABASE")); } hashexpired = Convert.ToBase64String(Encoding.UTF8.GetBytes(ExpiredDate.ToString())); if (usersDTO.UsersIds != null) { usersIds = Convert.ToBase64String(Encoding.UTF8.GetBytes(usersDTO.UsersIds.ToString())); } else { usersIds = Convert.ToBase64String(Encoding.UTF8.GetBytes(usersDTO.UserId.ToString())); } return(Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Join(":", hashuseremail, hashuserid, hashtenantid, hashusername, generateDAte, expiredDate, databasename, usersIds)))); }
public string GetRequestParams(string additionAttribute = "") { StringBuilder sb = new StringBuilder(); //sb.AppendFormat("<InputValue ClientKey=\"{0}\" UserID=\"{1}\" />", CSession.CLIENT_KEY, CSession.UserID); sb.Append("<RequestParams "); sb.Append(additionAttribute); if (ID > 0) { sb.Append(string.Format(" ID=\"{0}\"", ID)); } sb.Append(string.Format(" RefNo=\"{0}\"", HtmlEncode(RefNo))); sb.Append(string.Format(" RefNumber=\"{0}\"", RefNumber)); sb.Append(string.Format(" RefType=\"{0}\"", RefType)); if (RefDate > new DateTime(1900, 01, 01)) { sb.Append(string.Format(" RefDate=\"{0}\"", RefDate.ToString("yyyy-MM-dd HH:mm:ss"))); } sb.Append(string.Format(" ObjectID=\"{0}\"", ObjectID)); sb.Append(string.Format(" ObjectName=\"{0}\"", HtmlEncode(ObjectName))); sb.Append(string.Format(" ObjectAddress=\"{0}\"", HtmlEncode(ObjectAddress))); sb.Append(string.Format(" ObjectEmail=\"{0}\"", HtmlEncode(ObjectEmail))); sb.Append(string.Format(" ContactName=\"{0}\"", HtmlEncode(ContactName))); sb.Append(string.Format(" AssetOwnerID=\"{0}\"", AssetOwnerID)); sb.Append(string.Format(" AssetOwnerName=\"{0}\"", HtmlEncode(AssetOwnerName))); sb.Append(string.Format(" AssetOwnerAddress=\"{0}\"", HtmlEncode(AssetOwnerAddress))); sb.Append(string.Format(" AssetType=\"{0}\"", AssetType)); sb.Append(string.Format(" AssetLicenseNumber=\"{0}\"", HtmlEncode(AssetLicenseNumber))); sb.Append(string.Format(" AssetNumberPlate=\"{0}\"", HtmlEncode(AssetNumberPlate))); sb.Append(string.Format(" ContractNo=\"{0}\"", HtmlEncode(ContractNo))); sb.Append(string.Format(" ContractType=\"{0}\"", ContractType)); sb.Append(string.Format(" ContractTypeName=\"{0}\"", ContractTypeName)); sb.Append(string.Format(" WebUserName=\"{0}\"", HtmlEncode(WebUserName))); if (WarranterID > 0) { sb.Append(string.Format(" WarranterID=\"{0}\"", WarranterID)); } sb.Append(string.Format(" WarranterCode=\"{0}\"", HtmlEncode(WarranterCode))); sb.Append(string.Format(" FileNumber=\"{0}\"", HtmlEncode(FileNumber))); if (WarranterID <= 0 && string.IsNullOrEmpty(WarranterCode) && WarranterList != null && WarranterList.Count > 0) { sb.Append(string.Format(" WarranterName=\"{0}\"", HtmlEncode(WarranterList[0].ObjectName))); sb.Append(string.Format(" WarranterAddress=\"{0}\"", HtmlEncode(WarranterList[0].ObjectAddress))); } else { sb.Append(string.Format(" WarranterName=\"{0}\"", HtmlEncode(WarranterName))); sb.Append(string.Format(" WarranterAddress=\"{0}\"", HtmlEncode(WarranterAddress))); } sb.Append(string.Format(" WarranterEmail=\"{0}\"", HtmlEncode(WarranterEmail))); sb.Append(string.Format(" RegisTransRefNo=\"{0}\"", HtmlEncode(RegisTransRefNo))); sb.Append(string.Format(" OldRefNo=\"{0}\"", HtmlEncode(OldRefNo))); sb.Append(string.Format(" OrgRefNo=\"{0}\"", HtmlEncode(OrgRefNo))); if (OldRefDate > new DateTime(1900, 01, 01)) { sb.Append(string.Format(" OldRefDate=\"{0}\"", OldRefDate.ToString("yyyy-MM-dd HH:mm:ss"))); } //sb.Append(string.Format(" OldRefDate=\"{0}\"", HtmlEncode(OldRefDate))); sb.Append(string.Format(" Type=\"{0}\"", Type)); sb.Append(string.Format(" TypeName=\"{0}\"", HtmlEncode(TypeName))); sb.Append(string.Format(" Description=\"{0}\"", HtmlEncode(Description))); if (RefType == 28) { sb.Append(string.Format(" Note=\"{0}\"", HtmlEncode(Note))); } else { sb.Append(string.Format(" Note=\"{0}\"", HtmlEncode(""))); } sb.Append(string.Format(" Status=\"{0}\"", HtmlEncode(Status.ToString()))); if (PrintDate > new DateTime(1900, 01, 01)) { sb.Append(string.Format(" PrintDate = \"{0}\"", PrintDate.ToString("yyyy-MM-dd HH:mm:ss"))); } if (ExpiredDate > new DateTime(1900, 01, 01)) { sb.Append(string.Format(" ExpiredDate = \"{0}\"", ExpiredDate.ToString("yyyy-MM-dd HH:mm:ss"))); } if (ReceiveDateTime > new DateTime(1900, 01, 01)) { sb.Append(string.Format(" ReceiveDateTime = \"{0}\"", ReceiveDateTime.ToString("yyyy-MM-dd HH:mm:ss"))); } sb.Append(string.Format(" NumPagesAttachment=\"{0}\"", NumPagesAttachment)); if (AssetPersonalCode != null) { sb.Append(string.Format(" AssetPersonalCode=\"{0}\"", HtmlEncode(AssetPersonalCode))); } if (AssetIDCardNo != null) { sb.Append(string.Format(" AssetIDCardNo=\"{0}\"", HtmlEncode(AssetIDCardNo))); } sb.Append(" >"); if (WarranterList != null) { for (int i = 0; i < WarranterList.Count; i++) { sb.Append("<Warranter "); if (WarranterList[i].ID > 0) { sb.Append(string.Format(" ID=\"{0}\"", WarranterList[i].ID)); } sb.Append(string.Format(" Code=\"{0}\"", HtmlEncode(WarranterList[i].ObjectCode))); sb.Append(string.Format(" Name=\"{0}\"", HtmlEncode(WarranterList[i].ObjectName))); sb.Append(string.Format(" Address=\"{0}\"", HtmlEncode(WarranterList[i].ObjectAddress))); sb.Append("/>"); } } if (AssetOwnnerList != null) { for (int i = 0; i < AssetOwnnerList.Count; i++) { sb.Append("<AssetOwnner "); if (AssetOwnnerList[i].ID > 0) { sb.Append(string.Format(" ID=\"{0}\"", AssetOwnnerList[i].ID)); } sb.Append(string.Format(" Code=\"{0}\"", HtmlEncode(AssetOwnnerList[i].ObjectCode))); sb.Append(string.Format(" Name=\"{0}\"", HtmlEncode(AssetOwnnerList[i].ObjectName))); sb.Append(string.Format(" Address=\"{0}\"", HtmlEncode(AssetOwnnerList[i].ObjectAddress))); sb.Append(string.Format(" IDCardNumber=\"{0}\"", HtmlEncode(AssetOwnnerList[i].ObjectIDCardNumber))); sb.Append("/>"); } } if (Assets != null) { for (int i = 0; i < Assets.Count; i++) { if (!string.IsNullOrEmpty(Assets[i].AssetLicenseNumber) || !string.IsNullOrEmpty(Assets[i].AssetDescription) || !string.IsNullOrEmpty(Assets[i].AssetNumberPlate)) { sb.Append("<Asset "); if (Assets[i].ID > 0) { sb.Append(string.Format(" ID=\"{0}\"", Assets[i].ID)); } sb.Append(string.Format(" Type=\"{0}\"", Assets[i].AssetType)); sb.Append(string.Format(" LicenseNumber=\"{0}\"", HtmlEncode(Assets[i].AssetLicenseNumber))); sb.Append(string.Format(" NumberPlate=\"{0}\"", HtmlEncode(Assets[i].AssetNumberPlate))); sb.Append(string.Format(" Description=\"{0}\"", HtmlEncode(Assets[i].AssetDescription))); sb.Append(string.Format(" AssetName=\"{0}\"", HtmlEncode(Assets[i].AssetName))); sb.Append(string.Format(" Selected=\"{0}\"", Assets[i].Selected?1:0)); sb.Append(string.Format(" RegisType=\"{0}\"", Assets[i].RegisType)); sb.Append(string.Format(" IsModify=\"{0}\"", Assets[i].IsModify?1:0)); sb.Append(string.Format(" ModifyNote=\"{0}\"", HtmlEncode(Assets[i].ModifyNote))); sb.Append("/>"); } } } sb.Append(" </RequestParams>"); return(sb.ToString()); }