public string UserDataSynchronization(string appType) { var Relation = JsonConvert.DeserializeObject <List <tbl_FriendRelation> >(_mysqlDB.GetFriendRelationList(_userService.UserId)); var CustomGroup = JsonConvert.DeserializeObject <List <tbl_FriendGroups> >(_mysqlDB.GetFriendGroupList(_userService.UserId)); if (CustomGroup == null) { CustomGroup = new List <tbl_FriendGroups>(); } CustomGroup.Add(new tbl_FriendGroups { GroupID = Guid.Empty.ToString(), GroupName = "陌生人", GroupCategory = 3, GroupType = 0, GroupImage = "DefaultImg/sytb/default12.png", GroupRemark = "陌生人", GroupUserID = _userService.UserId, GroupDate = DateTime.Now, }); var InitData = new { Data = new { //*用户版本号要大于变更中最后一个版本号 UserVersion = new { UserID = _userService.UserId, Version = 1000 }, UserDataDict = UserDataDict(), DeskTopIcon = DeskTopIcon(appType), FriendGroup = CustomGroup, FriendList = Relation }, Status = 200, Message = "用户数据初始化成功" }; var BaseDirectory = AppDomain.CurrentDomain.BaseDirectory; var FileDirectory = BaseDirectory + "UserData\\" + _userService.UserId; using (FileStream fs = new FileStream(FileDirectory, FileMode.OpenOrCreate)) { //获得字节数组 byte[] data = Encoding.Default.GetBytes(JsonConvert.SerializeObject(InitData)); //开始写入 fs.Write(data, 0, data.Length); //清空缓冲区、关闭流 fs.Flush(); } if (File.Exists(FileDirectory)) { //var cipherText = Request.Headers.GetValues("cipherText").ToList()[0]; //CipherText cipObject = JsonConvert.DeserializeObject<CipherText>(cipherText); new ZipHelper().ZipManyFilesOrDictorys ( new List <string>() { FileDirectory }, FileDirectory + ".zip", _userService.UserId ); File.Delete(FileDirectory); var FileByte = File.ReadAllBytes(FileDirectory + ".zip"); var config = CicadaFacade.Container.Resolve <IConfigurationDataRespository>(); return(config.Get("Cicada.FileSystem.UrlPrefix") + _fileService.Upload(FileByte, "zip")); } return(string.Empty); }