/// <summary> /// /// </summary> /// <param name="uID"></param> /// <param name="data"></param> /// <param name="mimeType"></param> /// <param name="recipientCount"></param> /// <returns></returns> public string UploadFile(string uID, string data, ushort mimeType, ushort recipientCount) { #region log user request and response /*********************************************** * To log user request ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Request ===> senderID : " + uID + ", fileData : " + data); } #endregion string result = null; if (!NeeoUtility.IsNullOrEmpty(uID) && Enum.IsDefined(typeof(MimeType), mimeType) && (recipientCount > 0 && recipientCount < 255) && !NeeoUtility.IsNullOrEmpty(data)) { NeeoUser sender = new NeeoUser(uID); try { File file = new File() { Data = data, FileOwner = uID, MediaType = MediaType.Image, MimeType = (MimeType)mimeType }; if (sender.UploadFile(file, FileClassfication.SharedFile, recipientCount)) { result = file.FileUrl; } #region log user request and response /*********************************************** * To log user response ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Response ===> " + result); } #endregion return(result); } catch (ApplicationException appExp) { NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)(Convert.ToInt32(appExp.Message))); } catch (Exception exp) { LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.Message, exp); NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.UnknownError); } } else { NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments); } return(null); }
/// <summary> /// Updates user information into the database and the profile picture. /// </summary> /// <param name="userID">A string containing phone number as user id.</param> /// <param name="name">A string containing the name of the user.</param> /// <param name="fileData">A base64 encoded string containing the file data.</param> /// <returns>true if information is successfully updated; otherwise, false.</returns> public bool UpdateUserInformation(string userID, string name, string fileData) { bool isCompletedSuccessfully = false; #region log user request and response /*********************************************** * To log user request and response ***********************************************/ if (_logRequestResponse) { LogManager.CurrentInstance.InfoLogger.LogInfo( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, "Request ===> userID : " + userID + ", name : " + name + ", fileData : " + fileData); } #endregion if (!NeeoUtility.IsNullOrEmpty(userID)) { if (name != null) { NeeoUser user = new NeeoUser(userID); try { using (TransactionScope scope = new TransactionScope()) { if (user.UpdateUsersDisplayName(name)) { if (!NeeoUtility.IsNullOrEmpty(fileData)) { File file = new File() { FileName = NeeoUtility.ConvertToFileName(userID), Data = fileData, FileOwner = userID, MediaType = MediaType.Image, MimeType = MimeType.Image_jpeg }; if (user.UploadFile(file, FileClassfication.Profile)) { isCompletedSuccessfully = true; scope.Complete(); } } else { isCompletedSuccessfully = true; scope.Complete(); } } else { NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidUser); } } return(isCompletedSuccessfully); } catch (ApplicationException appExp) { NeeoUtility.SetServiceResponseHeaders((CustomHttpStatusCode)(Convert.ToInt32(appExp.Message))); } catch (Exception exp) { LogManager.CurrentInstance.ErrorLogger.LogError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType, exp.Message, exp); NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.UnknownError); } return(isCompletedSuccessfully); } else { NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments); } } else { NeeoUtility.SetServiceResponseHeaders(CustomHttpStatusCode.InvalidArguments); } return(isCompletedSuccessfully); }