瀏覽代碼

Resort Images from PV

master
George Williams 4 年之前
父節點
當前提交
76f15a5a2b

+ 12
- 0
UnivateProperties_API/Controllers/Timeshare/ResortController.cs 查看文件

25
         {
25
         {
26
             return new OkObjectResult(_Repo.GetResortsByRegion(regionCode));
26
             return new OkObjectResult(_Repo.GetResortsByRegion(regionCode));
27
         }
27
         }
28
+
29
+        [HttpGet("GetResortDescription/{code}")]
30
+        public IActionResult GetResortDescription(string code)
31
+        {
32
+            return new OkObjectResult(_Repo.GetResortDescription(code));
33
+        }
34
+
35
+        [HttpGet("GetResortImages/{code}")]
36
+        public IActionResult GetResortImages(string code)
37
+        {
38
+            return new OkObjectResult(_Repo.GetResortImages(code));
39
+        }
28
     }
40
     }
29
 }
41
 }

+ 3
- 0
UnivateProperties_API/Helpers/MyCommon.cs 查看文件

45
         }
45
         }
46
 
46
 
47
         public static string TenderUrl { get; set; }
47
         public static string TenderUrl { get; set; }
48
+        public static string Reservations { get; set; }
49
+        public static string ReservationsUserCode { get; set; }
50
+        public static string ReservationsPassword { get; set; }
48
 
51
 
49
         public static DateTime GetDateFromString(string value)
52
         public static DateTime GetDateFromString(string value)
50
         {
53
         {

+ 13
- 13
UnivateProperties_API/Repository/Properties/PropertyRepository.cs 查看文件

122
 
122
 
123
                             detailGroup.Values.Add(item);
123
                             detailGroup.Values.Add(item);
124
 
124
 
125
-                            if (!string.IsNullOrEmpty(val.Value) && (val.FieldName == "Erf Size" || val.FieldName == "Floor Size") && val.Value.EndsWith("2"))
126
-                            {
127
-                                item.Value = val.Value.Substring(0, val.Value.Length - 1) + "<sup>" + val.Value.Last() + "</sup>";
128
-                            }
129
-                            else
125
+                            //if (!string.IsNullOrEmpty(val.Value) && (val.FieldName == "Erf Size" || val.FieldName == "Floor Size") && val.Value.EndsWith("2"))
126
+                            //{
127
+                            //    item.Value = val.Value.Substring(0, val.Value.Length - 1) + "<sup>" + val.Value.Last() + "</sup>";
128
+                            //}
129
+                            //else
130
                                 item.Value = val.Value;
130
                                 item.Value = val.Value;
131
                         }
131
                         }
132
 
132
 
592
                     display.DisplayImage = ImageFormatter.ImageToBase64(display.DisplayImage);
592
                     display.DisplayImage = ImageFormatter.ImageToBase64(display.DisplayImage);
593
                 }
593
                 }
594
 
594
 
595
-                if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
596
-                {
597
-                    display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
598
-                }
595
+                //if (!string.IsNullOrEmpty(display.Area) && display.Area.EndsWith("2"))
596
+                //{
597
+                //    display.Area = display.Area.Substring(0, display.Area.Length - 1) + "<sup>" + display.Area.Last() + "</sup>";
598
+                //}
599
 
599
 
600
                 if (display.HasPendingOffer)
600
                 if (display.HasPendingOffer)
601
                     display.Available = "Offer Pending";
601
                     display.Available = "Offer Pending";
702
                              && f.FieldName == "Floor Size"
702
                              && f.FieldName == "Floor Size"
703
                              select u.Value).FirstOrDefault();
703
                              select u.Value).FirstOrDefault();
704
 
704
 
705
-                if (!string.IsNullOrEmpty(prop.Size) && prop.Size.EndsWith("2"))
706
-                {
707
-                    prop.Size = prop.Size.Substring(0, prop.Size.Length - 1) + "<sup>" + prop.Size.Last() + "</sup>";
708
-                }
705
+                //if (!string.IsNullOrEmpty(prop.Size) && prop.Size.EndsWith("2"))
706
+                //{
707
+                //    prop.Size = prop.Size.Substring(0, prop.Size.Length - 1) + "<sup>" + prop.Size.Last() + "</sup>";
708
+                //}
709
 
709
 
710
                 prop.UsageType = (dBContext.PropertyTypes.Find(p.PropertyTypeId).UsageType == PropertyUsageType.Residential ? "Residential" : "Commercial");
710
                 prop.UsageType = (dBContext.PropertyTypes.Find(p.PropertyTypeId).UsageType == PropertyUsageType.Residential ? "Residential" : "Commercial");
711
                 prop.SaleType = p.IsSale ? "Sale" : "Rental";
711
                 prop.SaleType = p.IsSale ? "Sale" : "Rental";

+ 82
- 3
UnivateProperties_API/Repository/Timeshare/IResortRepository.cs 查看文件

1
 using Newtonsoft.Json;
1
 using Newtonsoft.Json;
2
 using RestSharp;
2
 using RestSharp;
3
-using System;
4
 using System.Collections.Generic;
3
 using System.Collections.Generic;
4
+using System.Data;
5
+using System.IO;
5
 using System.Linq;
6
 using System.Linq;
6
-using System.Security.Cryptography;
7
-using System.Threading.Tasks;
8
 using UnivateProperties_API.Containers.Timeshare;
7
 using UnivateProperties_API.Containers.Timeshare;
9
 using UnivateProperties_API.Context;
8
 using UnivateProperties_API.Context;
10
 using UnivateProperties_API.Helpers;
9
 using UnivateProperties_API.Helpers;
14
     public interface IResortRepository
13
     public interface IResortRepository
15
     {
14
     {
16
         List<ResortDisplay> GetResortsByRegion(string regionCode);
15
         List<ResortDisplay> GetResortsByRegion(string regionCode);
16
+        string GetResortDescription(string resortCode);
17
+        List<string> GetResortImages(string resortCode);
17
     }
18
     }
18
 
19
 
19
     public class ResortRepository : IResortRepository
20
     public class ResortRepository : IResortRepository
25
             _dbContext = dbContext;
26
             _dbContext = dbContext;
26
         }
27
         }
27
 
28
 
29
+        public string GetResortDescription(string resortCode)
30
+        {
31
+            var client = new RestClient(MyCommon.Reservations)
32
+            {
33
+                Timeout = -1
34
+            };
35
+            var request = new RestRequest(Method.POST);
36
+            request.AddHeader("charset", "utf-8");
37
+            request.AddHeader("Content-Type", "text/xml");
38
+            request.AddHeader("Cookie", "ASP.NET_SessionId=bis4e2xtmqjdvh2wlqfolzbt");
39
+            request.AddParameter("text/xml"
40
+                , string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n  <soap:Body>\r\n    <GetResortDescription xmlns=\"http://localhost/\">\r\n      <UserCode>{0}</UserCode>\r\n      <Password>{1}</Password>\r\n      <ResortCode>{2}</ResortCode>\r\n    </GetResortDescription>\r\n  </soap:Body>\r\n</soap:Envelope>"
41
+                , MyCommon.ReservationsUserCode
42
+                , MyCommon.ReservationsPassword
43
+                , resortCode)
44
+                , ParameterType.RequestBody);
45
+            IRestResponse response = client.Execute(request);           
46
+
47
+            string description = "";
48
+            if (!string.IsNullOrEmpty(response.Content) && !response.Content.Contains("ERROR:"))
49
+            {
50
+                DataSet data = CreateDataSet(response.Content);
51
+                if (data.Tables.Count > 1)
52
+                {
53
+                    foreach (DataRow row in data.Tables["GetResortDescriptionResponse"].Rows)
54
+                        description = row[0].ToString();
55
+                }
56
+            }
57
+            return description;
58
+        }
59
+
60
+        public List<string> GetResortImages(string resortCode)
61
+        {
62
+            var client = new RestClient(MyCommon.Reservations)
63
+            {
64
+                Timeout = -1
65
+            };
66
+            var request = new RestRequest(Method.POST);
67
+            request.AddHeader("charset", "utf-8");
68
+            request.AddHeader("Content-Type", "text/xml");
69
+            request.AddHeader("Cookie", "ASP.NET_SessionId=bis4e2xtmqjdvh2wlqfolzbt");
70
+            request.AddParameter("text/xml"
71
+                , string.Format("<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n  <soap:Body>\r\n    <GetResortImages  xmlns=\"http://localhost/\">\r\n      <UserCode>{0}</UserCode>\r\n      <Password>{1}</Password>\r\n      <ResortCode>{2}</ResortCode>\r\n    </GetResortImages >\r\n  </soap:Body>\r\n</soap:Envelope>"
72
+                , MyCommon.ReservationsUserCode
73
+                , MyCommon.ReservationsPassword
74
+                , resortCode)
75
+                , ParameterType.RequestBody);
76
+            IRestResponse response = client.Execute(request);            
77
+
78
+            var images = new List<string>();
79
+            if (!string.IsNullOrEmpty(response.Content) && !response.Content.Contains("ERROR:"))
80
+            {
81
+                DataSet data = CreateDataSet(response.Content);
82
+                if (data.Tables.Count > 1)
83
+                {
84
+                    foreach (DataRow row in data.Tables["string"].Rows)
85
+                        images.Add(row[0].ToString());
86
+                }
87
+            }
88
+            return images;
89
+        }
90
+
91
+        public DataSet CreateDataSet(string data)
92
+        {
93
+            try
94
+            {
95
+                StringReader theReader = new StringReader(data);
96
+                DataSet theDataSet = new DataSet();
97
+                theDataSet.ReadXml(theReader);
98
+
99
+                return theDataSet;
100
+            }
101
+            catch
102
+            {
103
+                return null;
104
+            }
105
+        }
106
+
28
         public List<ResortDisplay> GetResortsByRegion(string regionCode)
107
         public List<ResortDisplay> GetResortsByRegion(string regionCode)
29
         {
108
         {
30
             var resorts = new List<ResortDisplay>();
109
             var resorts = new List<ResortDisplay>();

+ 3
- 0
UnivateProperties_API/Startup.cs 查看文件

59
             services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
59
             services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
60
             services.AddDbContext<DataContext>(o => o.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
60
             services.AddDbContext<DataContext>(o => o.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
61
             MyCommon.TenderUrl = Configuration.GetConnectionString("TenderConnection");
61
             MyCommon.TenderUrl = Configuration.GetConnectionString("TenderConnection");
62
+            MyCommon.Reservations = Configuration.GetConnectionString("ReservationsURL");
63
+            MyCommon.ReservationsUserCode = Configuration.GetConnectionString("ReservationsUserCode");
64
+            MyCommon.ReservationsPassword = Configuration.GetConnectionString("ReservationsPassword");
62
 
65
 
63
             var appSettingsSection = Configuration.GetSection("AppSettings");
66
             var appSettingsSection = Configuration.GetSection("AppSettings");
64
             services.Configure<AppSettings>(appSettingsSection);
67
             services.Configure<AppSettings>(appSettingsSection);

+ 4
- 1
UnivateProperties_API/appsettings.json 查看文件

10
   "AllowedHosts": "*",
10
   "AllowedHosts": "*",
11
   "ConnectionStrings": {
11
   "ConnectionStrings": {
12
     "DefaultConnection": "Data Source=localhost;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=Provision;Password=What123!;Pooling=false;",
12
     "DefaultConnection": "Data Source=localhost;Initial Catalog=UniVateDemo;Persist Security Info=True;User Id=Provision;Password=What123!;Pooling=false;",
13
-    "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N"
13
+    "TenderConnection": "http://www.unipoint-consoft.co.za/nph-srep.exe?cluvavail.sch&CLUB=LPA&RESORT=ALL&SUMMARY=N&HEAD=N",
14
+    "ReservationsURL": "http://localhost:49603/ReservationsWebservice.asmx",
15
+    "ReservationsUserCode": "GeorgeW",
16
+    "ReservationsPassword":  ""
14
   }
17
   }
15
 }
18
 }

Loading…
取消
儲存