//[HttpGet] //public void GetToken(string APIKey, string Password) //{ // string IPAddress = HttpContext.Current.Request.UserHostAddress; // if (string.IsNullOrEmpty(APIKey)) // result = falseresult("UnAuthorized..."); // if (string.IsNullOrEmpty(Password)) // result = falseresult("Please provide Password..."); // if (string.IsNullOrEmpty(IPAddress)) // result = falseresult("Please provide IP Address..."); // //if (!CheckPassEnscrypt(Password, ref Password)) // //{ result = falseresult("UnAuthorized..."); } // else // { // Department_ExMapDao map = new Department_ExMapDao(); // try // { // OfficerToken _token = new OfficerToken(); // string newToken = Guid.NewGuid().ToString(); // var obj = map.FindByKeygen(APIKey).Where(o => o.Password == Encryption.Encrypt(Password)).FirstOrDefault(); // if (obj != null) // { // GetAuthToken(_token, APIKey, newToken, IPAddress); // //_token.Username = ""; // //_token.Org_id = obj.ID.ToString(); // _token.Org_name = obj.External_dept_Name; // _token.Office_name = obj.External_dept_Name; // SaveUtility.SaveTransactionLog(newToken, "GetToken", SaveUtility.TransStatus.Create, APIKey, IPAddress, "s"); //s: service // result = Trueresult(_token); // } // else // { // result = falseresult("Invalid Token and Password..."); // } // } // catch (Exception ex) // { // SaveUtility.logError(ex); // result = falseresult(ex.Message.ToString()); // } // finally // { // map = null; // } // } // HttpContext.Current.Response.ContentType = "application/json"; // HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result)); // HttpContext.Current.Response.End(); //} //[HttpPost] //public void GetToken([FromBody]string value) //{ // //string IPAddress = HttpContext.Current.Request.UserHostAddress; // //if (string.IsNullOrEmpty(APIKey)) // // result = falseresult("UnAuthorized..."); // //if (string.IsNullOrEmpty(Password)) // // result = falseresult("Please provide Password..."); // //if (string.IsNullOrEmpty(IPAddress)) // // result = falseresult("Please provide IP Address..."); // ////if (!CheckPassEnscrypt(Password, ref Password)) // ////{ result = falseresult("UnAuthorized..."); } // //else // //{ // // Department_ExMapDao map = new Department_ExMapDao(); // // try // // { // // OfficerToken _token = new OfficerToken(); // // string newToken = Guid.NewGuid().ToString(); // // var obj = map.FindByKeygen(APIKey).Where(o => o.Password == Encryption.Encrypt(Password)).FirstOrDefault(); // // if (obj != null) // // { // // GetAuthToken(_token, APIKey, newToken, IPAddress); // // //_token.Username = ""; // // //_token.Org_id = obj.ID.ToString(); // // _token.Org_name = obj.External_dept_Name; // // _token.Office_name = obj.External_dept_Name; // // SaveUtility.SaveTransactionLog(newToken, "GetToken", SaveUtility.TransStatus.Create, APIKey, IPAddress, "s"); //s: service // // result = Trueresult(_token); // // } // // else // // { // // result = falseresult("Invalid Token and Password..."); // // } // // } // // catch (Exception ex) // // { // // SaveUtility.logError(ex); // // result = falseresult(ex.Message.ToString()); // // } // // finally // // { // // map = null; // // } // //} // HttpContext.Current.Response.ContentType = "application/json"; // HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result)); // HttpContext.Current.Response.End(); //} #endregion // [WebMethod(Description = "Get Timeline Header เป็นเมธอดสำหรับใช้ดึงข้อมูล ที่เกียวข้องกับหน่วยงานนั้นๆ <br />" //+ "Skip: ลำดับข้อมูลที่ต้องการเริ่มต้น เช่น เริ่มแถวที่ 1 <br />" //+ "take: จำนวนข้อมูลที่ต้องการ เช่น 10 ,20 แถว<br />" //+ "IsCloseJob: สถานะเรืองร้องทุกข์ (null=ทั้งหมด ,0=กำลังดำเนินการ ,1=ยุติการดำเนินการ)")] public void GetTimelineHeader(string tokenId, int skip, int take, string IsCloseJob) { if (string.IsNullOrEmpty(tokenId)) { result = falseresult("UnAuthorized."); } string key = Encryption.Decrypt(tokenId); if (!IsValidateToken(key)) { result = falseresult("UnAuthorized."); } if (skip < 1) { skip = 1; } if (take < 1) { take = 20; } try { AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao(); var objToken = _authenMap.FindByKeygen(key).FirstOrDefault(); if (objToken != null) { var comList = ComplainData.GetComplainTimeLine(objToken.ApiKey, skip, take, 0, null); SaveUtility.SaveTransactionLog(objToken.ApiKey, "Get Time line Header", SaveUtility.TransStatus.Create, key, objToken.Owner_ip, "s"); //s: service result = Trueresult(comList); } else { result = falseresult("UnAuthorized."); } } catch (Exception ex) { SaveUtility.logError(ex); result = falseresult(ex.Message); } HttpContext.Current.Response.ContentType = "application/json"; HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result)); HttpContext.Current.Response.End(); }
private void _ReleaseToken(string tokenId) { if (string.IsNullOrEmpty(tokenId)) { result = falseresult("UnAuthorized..."); } // string key = Encryption.Decrypt(tokenId); //new key AuthenticateTokenMapDao _authenMap = new AuthenticateTokenMapDao(); if (!IsValidateToken(tokenId)) { result = falseresult("UnAuthorized."); } try { var objToken = _authenMap.FindByKeygen(TokenValid.Keygen).ToList(); if (objToken.Count() > 0) { //disable token foreach (var item in objToken) { item.Active = false; _authenMap.AddOrUpdate(item); _authenMap.CommitChange(); SaveUtility.SaveTransactionLog(item.Keygen, "Release Token", SaveUtility.TransStatus.Create, tokenId, item.Owner_ip, "s"); } } } catch (Exception ex) { SaveUtility.logError(ex); result = falseresult(ex.Message); } finally { _authenMap = null; } result = Trueresult("OK"); HttpContext.Current.Response.ContentType = "application/json"; HttpContext.Current.Response.Write(JsonConvert.SerializeObject(result)); HttpContext.Current.Response.End(); }