Exemple #1
0
        /// <summary>
        /// 上传讨论组头像
        /// </summary>
        /// <param name="strFilePath"></param>
        /// <returns></returns>
        public static string UploadPicture(string strFilePath)
        {
            SendCutImageDto scid = new SendCutImageDto();

            scid.cmpcd        = GlobalVariable.CompanyCode;
            scid.seId         = "";
            scid.fileFileName = "";
            scid.file         = strFilePath;
            //TODO:AntSdk_Modify
            //DONE:AntSdk_Modify
            AntSdkSendFileInput fileInput = new AntSdkSendFileInput();

            fileInput.cmpcd    = GlobalVariable.CompanyCode;
            fileInput.seId     =
                fileInput.file = strFilePath;
            AntSdkFailOrSucessMessageDto failMessage = new AntSdkFailOrSucessMessageDto();

            failMessage.mtp     = (int)AntSdkMsgType.ChatMsgPicture;
            failMessage.content = "";
            //failMessage.sessionid = s_ctt.sessionId;
            DateTime dt = DateTime.Now;

            failMessage.lastDatetime = dt.ToString();
            fileInput.FailOrSucess   = failMessage;
            var    errCode    = 0;
            string errMsg     = string.Empty;
            var    fileOutput = AntSdkService.FileUpload(fileInput, ref errCode, ref errMsg);

            //ReturnCutImageDto dto = (new HttpService()).FileUpload<ReturnCutImageDto>(scid);
            if (fileOutput == null)
            {
                return(string.Empty);
            }
            else
            {
                return(fileOutput.dowmnloadUrl);
            }
        }
Exemple #2
0
        /// <summary>
        /// 保存用户信息
        /// </summary>
        /// <returns></returns>
        private void SaveUserInfo()
        {
            var    errCode = 0;
            string errMsg  = string.Empty;

            if (string.IsNullOrEmpty(HeadPic))
            {
                return;
            }
            AntSdkUpdateUserInput userInfoInput = new AntSdkUpdateUserInput();

            if (!HeadPic.StartsWith("pack://application:,,,/AntennaChat;Component/Images/198-头像.png"))
            {
                if (HeadPic != CurrentProfile.picture)
                {
                    SendCutImageDto scid = new SendCutImageDto();
                    scid.cmpcd        = GlobalVariable.CompanyCode;
                    scid.seId         = "";
                    scid.fileFileName = "";
                    scid.file         = HeadPic;
                    //TODO:AntSdk_Modify

                    AntSdkSendFileInput fileInput = new AntSdkSendFileInput();
                    fileInput.cmpcd    = GlobalVariable.CompanyCode;
                    fileInput.seId     =
                        fileInput.file = HeadPic;
                    AntSdkFailOrSucessMessageDto failMessage = new AntSdkFailOrSucessMessageDto();
                    failMessage.mtp     = (int)AntSdkMsgType.ChatMsgPicture;
                    failMessage.content = "";
                    //failMessage.sessionid = s_ctt.sessionId;
                    DateTime dt = DateTime.Now;
                    failMessage.lastDatetime = dt.ToString();
                    fileInput.FailOrSucess   = failMessage;
                    var fileOutput = AntSdkService.FileUpload(fileInput, ref errCode, ref errMsg);
                    //ReturnCutImageDto dto = (new HttpService()).FileUpload<ReturnCutImageDto>(scid);
                    if (fileOutput != null)
                    {
                        string url = fileOutput.dowmnloadUrl;
                        HeadPic = url;
                        AntSdkService.AntSdkCurrentUserInfo.picture = url;
                    }
                    else
                    {
                        LogHelper.WriteError("上传新头像失败:" + errMsg);
                        userInfoInput.picture = "";
                    }
                }
            }
            //TODO:AntSdk_Modify
            //DONE:AntSdk_Modify
            if (HeadPic.StartsWith("pack://application:,,,/AntennaChat;Component/Images/198-头像.png"))
            {
                userInfoInput.picture = "";
            }
            else
            {
                userInfoInput.picture = HeadPic;
            }
            userInfoInput.sex       = Sex;
            userInfoInput.signature = this.Signature;
            //userInfoInput.voiceMode = CurrentProfile.voiceMode;
            //userInfoInput.vibrateMode = CurrentProfile.vibrateMode;
            bool isResult = AntSdkService.AntSdkUpdateUser(userInfoInput, ref errCode, ref errMsg);

            if (!isResult)
            {
                LogHelper.WriteError("更新用户信息失败:" + errMsg);
            }
            else
            {
                AntSdkService.AntSdkCurrentUserInfo.signature = this.Signature;
                AntSdkService.AntSdkCurrentUserInfo.sex       = Sex;
            }
        }