Beispiel #1
0
        public IActionResult EditModel(string TempName, string TempTable, string TempType, string ModelOrgId, string JsonData, string ModelIndex)
        {
            string urlContentPath = @"\Content\" + ModelOrgId + @"\" + TempName + ".xml";
            var    modeltemp      = new ModelTempDto()
            {
                TempName    = TempName,
                TempTable   = TempTable,
                ModelOrgId  = ModelOrgId,
                TempType    = TempType,
                Id          = ModelIndex,
                ContentPath = urlContentPath
            };
            string urlPath = _hostEnvironment.WebRootPath;

            urlContentPath = urlPath + urlContentPath;
            List <ModelEntityDto> listDto = JsonConvert.DeserializeObject <List <ModelEntityDto> >(JsonData);

            OtherHelper.CreateListXml <ModelEntityDto>(urlContentPath, listDto);



            _tempService.Add(modeltemp);


            List <ModelEntityDto> list = OtherHelper.SerialierList <ModelEntityDto>(urlContentPath);

            return(Json(new JsonResult <string>
            {
                msg = "模板保存成功!", flag = true
            }));
        }
        public static async ETTask <T> Update <T>(this RedisEventSolverComponent self, T entity) where T : ComponentWithId
        {
            if (self.isDebug)
            {
                OtherHelper.LogCallStackMessage("Update");
            }

            var result = await self.cacheProxyComponent.UpdateById(entity);

            T returnData = default;

            if (result != default)
            {
                var msg = CacheHelper.ConvertRedisPublish2Message(entity.Id, IdGenerater.AppId);
                await self.redisPubClient.GetSubscriber().PublishAsync(self.channelUpdateKey, msg);

                // 保證底層Data的Reference一致
                self.Write(entity.Id, entity);
                returnData = (T)self.Data[entity.Id];
                // 觸發事件
                self.onRefresh?.Invoke(entity.Id);
                self.onUpdate?.Invoke(entity.Id);
            }
            return(returnData);
        }
        /// <summary>
        /// 取得使用者所有道具資料
        /// </summary>
        /// <param name="uid"></param>
        /// <returns></returns>
        public static async ETTask <RepeatedField <EquipmentInfo> > GetUserAllEquipmentInfo(long uid)
        {
            var list   = new RepeatedField <EquipmentInfo>();
            var listEq = new List <Equipment>();
            var result = await dbProxy.Query <Equipment>(entity => entity.uid == uid);

            for (int i = 0; i < result.Count; i++)
            {
                var equipment = (Equipment)result[i];
                if (TryGetEquipmentConfig(equipment.configId, out CharacterConfig config))
                {
                    if (config.IsStackEquipment())
                    {
                        var obj = OtherHelper.Search(listEq, entity => entity.configId == equipment.configId);
                        if (obj != null)
                        {
                            await _MergeEquipment(uid, obj, equipment);

                            continue;
                        }
                    }
                    list.Add(equipment.ToEquipmentInfo());
                    listEq.Add(equipment);
                }
            }
            return(list);
        }
        public WinScpEncodedParameter()
        {
            string[] s = { "%", " ", "+", "/", "@", "\"", ":", ";" };

            Transformation = val => OtherHelper.ReplaceU(s, val);
            Value          = string.Empty;
        }
        public static async ETTask <T> Create <T>(this RedisEventSolverComponent self, T entity) where T : ComponentWithId
        {
            if (self.isDebug)
            {
                OtherHelper.LogCallStackMessage("Create");
            }

            var result = await self.cacheProxyComponent.Create(entity);

            T returnData = default;

            if (result != default)
            {
                var msg = CacheHelper.ConvertRedisPublish2Message(entity.Id, IdGenerater.AppId);
                await self.redisPubClient.GetSubscriber().PublishAsync(self.channelCreateKey, msg);

                // 誰創的誰就是物件的擁有者
                // 如果是自己產生的事件循環自己管,即你用系統CreateWithId產生的有事件循環,自己new的沒有,都依自己傳來的entity怎麼生的
                self.Data[entity.Id] = entity;
                self.mineSet.Add(entity.Id);
                returnData = entity;
                // 觸發事件
                self.onRefresh?.Invoke(entity.Id);
                self.onCreate?.Invoke(entity.Id);
            }
            return(returnData);
        }
Beispiel #6
0
        /// <summary>
        /// 构建登录信息
        /// </summary>
        /// <returns></returns>
        private JsonLogin CreateLogininfo(string s, string d)
        {
            //登录
            JsonLogin     Loginfo = new JsonLogin();
            JsonLoginHead LogHead = new JsonLoginHead();

            LogHead.serailNumber  = s;
            LogHead.funCode       = "011";
            LogHead.digitalDigest = d;// GetCa();
            LogHead.respCode      = "";
            LogHead.clientMAC     = OtherHelper.GetMac();
            LogHead.clientIP      = OtherHelper.GetIp();
            JsonLoginBody LogBody = new JsonLoginBody();

            LogBody.loginName = "cqyyypk";
            LogBody.password  = HashList("zzllyy_7788");
            //LogBody.password = HashList("123456");
            Loginfo.header = LogHead;
            List <JsonLoginBody> listbody = new List <JsonLoginBody>();

            listbody.Add(LogBody);
            JsonLoginrows LoginRows = new JsonLoginrows();

            LoginRows.rows = listbody;
            Loginfo.body   = LoginRows;

            return(Loginfo);
        }
Beispiel #7
0
        public async Task <IActionResult> GetXmlData(string id)
        {
            var temp = await _tempService.Find(id);

            string urlContendPath = _hostEnvironment.WebRootPath + temp.ContentPath;

            List <ModelEntityDto> list = OtherHelper.SerialierList <ModelEntityDto>(urlContendPath);

            return(Json(list));
        }
 public PuttyPasswordParameter()
 {
     Transformation = val => OtherHelper.ReplaceA(passs, passr, val);
     IsQuoted       = true;
     Name           = KnownParameters.Password;
     DisplayName    = "Пароль";
     CmdLineName    = "-pw";
     Delimiter      = " ";
     Value          = string.Empty;
 }
Beispiel #9
0
        public void Run()
        {
            string rdpPath = Environment.ExpandEnvironmentVariables(_connection.GetEffectiveAppPath());

            if (File.Exists(rdpPath))
            {
                var parameters = _connection.Parameters.Where(p => p.DisplayName != "Размер экрана").ToList();

                var outputFile        = OtherHelper.ReplaceU(f, _connection.Name) + ".rdp";
                var outputFolderParam = _connection.Parameters.FirstOrDefault(p => p.Name == "OutputFolder");
                if (outputFolderParam != null && !string.IsNullOrEmpty(outputFolderParam.Value))
                {
                    Directory.CreateDirectory(outputFolderParam.Value);
                    outputFile = Path.Combine(outputFolderParam.Value, outputFile);
                }

                TextWriter rdpFileWriter = new StreamWriter(path: outputFile);

                foreach (var p in parameters.Where(p => !(p is FolderPathConnectionParameter)))
                {
                    var line = p.GetCommandLine();
                    if (string.IsNullOrEmpty(line))
                    {
                        continue;
                    }
                    rdpFileWriter.Write(line);
                    var delimiter = p.NextParameterDelimiter ?? _connection.ParameterDelimiter;
                    rdpFileWriter.Write(delimiter);
                }

                var fullScreen = _connection.Parameters.FirstOrDefault(p => p.Name == "IsFullScreen") as SwitchConnectionParameter;
                if (fullScreen != null && !fullScreen.IsOn)
                {
                    var      size  = _connection.Parameters.FirstOrDefault(p => p.Name == "ScreenSize").Value;
                    string[] sizes = size.Split('x');

                    rdpFileWriter.WriteLine(sizes.Length == 2 ? "desktopwidth:i:" + sizes[0] : "");
                    rdpFileWriter.WriteLine(sizes.Length == 2 ? "desktopheight:i:" + sizes[1] : "");
                }

                rdpFileWriter.Close();

                Process myProc = new Process
                {
                    StartInfo =
                    {
                        FileName  = rdpPath,
                        Arguments = $"\"{outputFile}\"",
                    }
                };

                myProc.Start();
            }
        }
Beispiel #10
0
        private void SearchLayer(ILayer pSubLayer, XmlLocator locator, string searchKey)
        {
            if (_searchCount > _context.Config.LocatorMaxCount)
            {
                return;
            }
            IQueryFilter  queryFilter = new QueryFilter();
            IFeatureClass pClass      = ((IFeatureLayer)pSubLayer).FeatureClass;
            string        likeStr     = WorkspaceHelper.GetSpecialCharacter(pClass as IDataset,
                                                                            esriSQLSpecialCharacters.esriSQL_WildcardManyMatch);

            if (!string.IsNullOrEmpty(searchKey))
            {
                queryFilter.WhereClause = BuildWhereClause(locator.SearchFields, searchKey, likeStr);
            }
            IFeatureCursor cursor   = pClass.Search(queryFilter, false);
            IFeature       pFeature = cursor.NextFeature();
            int            nameIdx  = GetFieldIdx(cursor, locator.NameField);
            int            addIdx   = GetFieldIdx(cursor, locator.AddressField);
            int            descIdx  = GetFieldIdx(cursor, locator.DescriptionField);
            int            telIdx   = GetFieldIdx(cursor, locator.TelephoneField);
            int            emailIdx = GetFieldIdx(cursor, locator.EmailField);
            int            phoIdx   = GetFieldIdx(cursor, locator.PhotoField);

            while (pFeature != null)
            {
                IGeometry pGeometry = pFeature.Shape;
                if (pGeometry.IsEmpty)
                {
                    pFeature = cursor.NextFeature();
                    continue;
                }

                DataRow row = _dataTable.NewRow();
                row["图层"] = pSubLayer.Name;
                row["序号"] = pFeature.OID;
                row["名称"] = nameIdx < 0 ? "" : pFeature.get_Value(nameIdx);
                row["地址"] = addIdx < 0 ? "" : pFeature.get_Value(addIdx);
                row["说明"] = descIdx < 0 ? "" : pFeature.get_Value(descIdx);
                row["电话"] = telIdx < 0 ? "" : pFeature.get_Value(telIdx);
                row["邮箱"] = emailIdx < 0 ? "" : pFeature.get_Value(emailIdx);
                row["要素"] = pFeature.Shape;
                row["照片"] = phoIdx < 0 ? null : pFeature.get_Value(phoIdx);
                _dataTable.Rows.Add(row);
                _searchCount++;
                if (_searchCount > _context.Config.LocatorMaxCount)
                {
                    break;
                }
                pFeature = cursor.NextFeature();
            }

            OtherHelper.ReleaseObject(cursor);
        }
Beispiel #11
0
 private void ListBox_Comment_RightTapped(object sender, RightTappedRoutedEventArgs e)
 {
     if (e.OriginalSource.GetType() == typeof(TextBlock))
     {
         OtherHelper.CopyTextToClipboard((e.OriginalSource as TextBlock).Text);
     }
     else if (e.OriginalSource.GetType() == typeof(Windows.UI.Xaml.Shapes.Rectangle))
     {
         OtherHelper.CopyTextToClipboard(((e.OriginalSource as Windows.UI.Xaml.Shapes.Rectangle).DataContext as CommentsItem).content);
     }
 }
Beispiel #12
0
        public BPNN(int inputLayerNum, int[] hiddenLayerNum, int outputLayersNum, double eta, double lastEta)
        {
            OtherHelper otherHelper = new OtherHelper();

            this.eta     = eta;
            this.lastEta = lastEta;
            i_input      = new double[inputLayerNum + 1];
            i_output     = new double[inputLayerNum + 1];
            h_input      = new double[hiddenLayerNum.Length][];
            h_output     = new double[hiddenLayerNum.Length][];
            h_weights    = new double[hiddenLayerNum.Length][, ];
            h_lastTheta  = new double[hiddenLayerNum.Length][, ];
            for (int i = 0; i < hiddenLayerNum.Length; i++)
            {
                h_input[i]  = new double[hiddenLayerNum[i] + 1];
                h_output[i] = new double[hiddenLayerNum[i] + 1];
                int row = 0;
                int col = 0;
                if (i == 0) //为零时时输入层
                {
                    row = inputLayerNum + 1;
                    col = hiddenLayerNum[i];
                }
                else
                {
                    row = hiddenLayerNum[i - 1] + 1;
                    col = hiddenLayerNum[i];
                }

                h_weights[i]   = new double[row, col];
                h_lastTheta[i] = new double[row, col];
                for (int j = 0; j < row; j++)
                {
                    for (int k = 0; k < col; k++)
                    {
                        h_weights[i][j, k]   = OtherHelper.getRandDouble(-200, 201);
                        h_lastTheta[i][j, k] = 0;
                    }
                }
            }
            o_input     = new double[outputLayersNum];
            o_output    = new double[outputLayersNum];
            o_weights   = new double[hiddenLayerNum[hiddenLayerNum.Length - 1] + 1, outputLayersNum];
            o_lastTheta = new double[hiddenLayerNum[hiddenLayerNum.Length - 1] + 1, outputLayersNum];
            for (int i = 0; i < o_weights.GetLength(0); i++)
            {
                for (int j = 0; j < o_weights.GetLength(1); j++)
                {
                    o_weights[i, j]   = OtherHelper.getRandDouble(-20, 20);
                    o_lastTheta[i, j] = 0;
                }
            }
        }
Beispiel #13
0
        /// <summary>
        /// 播放电台时使用修改底部播放条
        /// </summary>
        /// <param name="bitmapImage"></param>
        /// <param name="musicName"></param>
        /// <param name="artistName"></param>
        /// <param name="albumName"></param>
        /// <param name="maximum"></param>
        /// <param name="isStartPlaying"></param>
        async void ChangePlayBar(BitmapImage bitmapImage, string musicName, string artistName, string albumName, int maximum, bool isStartPlaying = true)
        {
            Image_playingAlbum.Source = bitmapImage;//修改专辑图片
            TextBlcok_musicName.Text  = musicName;
            TextBlcok_artistName.Text = artistName;
            TextBlcok_albumName.Text  = albumName;
            TextBlock_lengthTime.Text = await Task.Run(() => OtherHelper.GetDt(maximum));

            if (isStartPlaying)
            {
                SymbolIcon_stopOrPlay.Symbol = Symbol.Pause;
            }
        }
Beispiel #14
0
        /// <summary>
        /// 获取歌词
        /// </summary>
        /// <param name="id">音乐id</param>
        /// <returns></returns>
        public static LyricRoot GetLyric(long id)
        {
            string result = Http.Get(ConfigService.ApiUri + @"/lyric?id=" + id);

            if (result == null || result.Equals(""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <LyricRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
Beispiel #15
0
        /// <summary>
        /// 获取我的歌单
        /// </summary>
        /// <returns></returns>
        public static MyPlaylistRoot GetMyPlaylist()
        {
            string result = Http.Get(ConfigService.ApiUri + @"/user/playlist?uid=" + ConfigService.Uid + "&limit=1000");

            if (result == null || result.Equals(""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <MyPlaylistRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
Beispiel #16
0
        /// <summary>
        /// 获取歌手所有(热门)专辑信息
        /// </summary>
        /// <param name="id">歌手id</param>
        /// <returns></returns>
        public static ArtistAllAlbumRoot GetArtistAllAlbums(long id)
        {
            string result = Http.Get(ConfigService.ApiUri + @"/artist/album?id=" + id + "&limit=1000");

            if (result == null || result.Equals(""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <ArtistAllAlbumRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
Beispiel #17
0
        //监控修改播放进度条
        private async void _mediaTimelineController_PositionChanged(MediaTimelineController sender, object args)
        {
            await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
            {
                isSliderChangedFromAuto = true;
                Slider_play.Value       = sender.Position.TotalSeconds;

                TextBlock_currentTime.Text = OtherHelper.GetDt((int)sender.Position.TotalSeconds);
                if ((Application.Current as App).playingPage != null)
                {
                    (Application.Current as App).playingPage.ChangeLyricPosition(sender.Position.TotalMilliseconds);
                }
            });
        }
Beispiel #18
0
        /// <summary>
        /// 电台评论
        /// </summary>
        /// <param name="id">节目id,即RadioSongItem,不是MainSong</param>
        /// <returns></returns>
        public static CommentRoot GetRadioComment(long id)
        {
            string result = Http.Get(ConfigService.ApiUri + @"/comment/dj?id=" + id + "&limit=100");

            if (result == null || result.Equals(""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <CommentRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
Beispiel #19
0
 private async void Button_Save_Click(object sender, RoutedEventArgs e)
 {
     if (TextBox_account.Text == "" || PasswordBox_password.Password == "" || TextBox_serverIP.Text == "")
     {
         NotifyPopup notifyPopup = new NotifyPopup("?");
         notifyPopup.Show();
         return;
     }
     ConfigService.ApiUri       = TextBox_serverIP.Text;
     ConfigService.PhoneOrEmail = TextBox_account.Text;
     ConfigService.Password     = OtherHelper.Encrypt(PasswordBox_password.Password);
     ConfigService.SaveConfig();
     await CoreApplication.RequestRestartAsync(String.Empty);
 }
Beispiel #20
0
        /// <summary>
        /// 搜索
        /// </summary>
        /// <param name="keyword">关键词</param>
        /// <param name="type">1: 单曲, 10: 专辑, 100: 歌手, 1000: 歌单</param>
        /// <returns></returns>
        public static SearchRoot SearchClound(string keyword, int type)
        {
            string result = Http.Get(ConfigService.ApiUri + @"/cloudsearch?keywords=" + keyword + "&type=" + type);

            if (result == null || result.Equals(""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <SearchRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
Beispiel #21
0
        /// <summary>
        /// 获取喜欢的歌曲
        /// </summary>
        /// <returns></returns>
        public static FavoriteSongsRoot GetFavoriteSongs()
        {
            string result = Http.Get(ConfigService.ApiUri + @"/likelist");

            if (result == null || result.Equals(""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <FavoriteSongsRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
Beispiel #22
0
        /// <summary>
        /// 获取我收藏的歌手
        /// </summary>
        /// <returns></returns>
        public static MyCollectionfArtistRoot GetMyCollectionOfArtist()
        {
            string result = Http.Get(ConfigService.ApiUri + @"/artist/sublist");

            if (result == null || result.Equals(""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <MyCollectionfArtistRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
        public void Run()
        {
            if (File.Exists(_connection.GetEffectiveAppPath()))
            {
                var hostParam = _connection.Parameters.First(p => p.Name == KnownParameters.Host);
                var portParam = _connection.Parameters.First(p => p.Name == KnownParameters.Port);


                var vncFilePath     = OtherHelper.ReplaceU(f, _connection.Name) + ".vnc";
                var vncOutPathParam = _connection.Parameters.First(p => p.Name == "OutputFolder");
                if (vncOutPathParam != null && !string.IsNullOrEmpty(vncOutPathParam.Value))
                {
                    Directory.CreateDirectory(vncOutPathParam.Value);
                    vncFilePath = Path.Combine(vncOutPathParam.Value, vncFilePath);
                }
                TextWriter vncFile = new StreamWriter(vncFilePath);

                vncFile.WriteLine("[Connection]");
                vncFile.WriteLine(hostParam.GetCommandLine());
                vncFile.WriteLine(portParam.GetCommandLine());

                var userParam = _connection.Parameters.First(p => p.Name == KnownParameters.User);
                vncFile.WriteLine(userParam.GetCommandLine());
                var passParam = _connection.Parameters.First(p => p.Name == KnownParameters.Password);
                vncFile.WriteLine(passParam.GetCommandLine());

                vncFile.WriteLine("[Options]");
                var fullScreenParam = _connection.Parameters.First(p => p.Name == "IsFullScreen");
                vncFile.WriteLine(fullScreenParam.GetCommandLine());

                var viewOnly = _connection.Parameters.First(p => p.Name == "ViewOnly");
                vncFile.WriteLine(viewOnly.GetCommandLine());

                vncFile.WriteLine(passParam.Value != "" && passParam.Value.Length > 8 ? "protocol3.3=1" : ""); // f****n vnc 4.0 auth

                vncFile.Close();

                Process myProc = new Process
                {
                    StartInfo =
                    {
                        FileName  = _connection.GetEffectiveAppPath(),
                        Arguments = "-config \"" + vncFilePath
                    }
                };

                myProc.Start();
            }
        }
        public IEnumerable <WeatherForecast> Get()
        {
            OtherHelper o = new OtherHelper();

            o.Sendmail("*****@*****.**", "Hello", "Message");
            var rng = new Random();

            return(Enumerable.Range(1, 5).Select(index => new WeatherForecast
            {
                Date = DateTime.Now.AddDays(index),
                TemperatureC = rng.Next(-20, 55),
                Summary = Summaries[rng.Next(Summaries.Length)]
            })
                   .ToArray());
        }
 static public void backup()
 {
     if (NetClouldMusicData == null)
     {
         throw new InvalidOperationException("备份失败,NetClouldMusicData 对象为空");
     }
     //Task.Run(() =>
     //{
     if (File.Exists(GlobalConfigClass.XML_CLOUDMUSIC_SAVEPATH))
     {
         File.Delete(GlobalConfigClass.XML_CLOUDMUSIC_SAVEPATH);
     }
     OtherHelper.WriteXMLSerializer(NetClouldMusicData, typeof(List <UserData>), GlobalConfigClass.XML_CLOUDMUSIC_SAVEPATH);
     // });
 }
        public static async ETTask <Room> CreateTeamRoom(this RoomComponent self, RoomInfo roomInfo, TeamRoomData teamRoomData)
        {
            Room room = ComponentFactory.CreateWithId <Room, RoomType>(IdGenerater.GenerateId(), RoomType.Team);

            room.SetData(roomInfo);
            room = await self.MemorySync.Create(room);

            room.AddComponent <RoomTeamComponent, TeamRoomData>(teamRoomData);
            room.AddComponent <RoomBlockComponent, Room>(room);
            var first = OtherHelper.Search(self.TeamList, r => r.Id == room.Id);

            if (first == null)
            {
                self.TeamList.Add(room);
            }
            return(room);
        }
        public static async ETTask <Room> CreateRoamingRoom(this RoomComponent self, RoomInfo roomInfo)
        {
            Room room = ComponentFactory.CreateWithId <Room, RoomType>(IdGenerater.GenerateId(), RoomType.Roaming);

            room.SetData(roomInfo);
            await self.MemorySync.Create(room);

            room.AddComponent <RoomRoamingComponent>();
            room.AddComponent <RoomBlockComponent, Room>(room);
            room.AddComponent <RoomNpcComponent>();
            var first = OtherHelper.Search(self.RoamingList, r => r.Id == room.Id);

            if (first == null)
            {
                self.RoamingList.Add(room);
                self.RoamingSettingDict.Add(roomInfo.RoadSettingId, room);
            }
            return(room);
        }
Beispiel #28
0
        /// <summary>
        /// 登录账号
        /// </summary>
        /// <returns></returns>
        public static LoginRoot LoginAccount()
        {
            try
            {
                if (Http.cookies != null && Http.cookies.GetCookies(new Uri(ConfigService.ApiUri + "/login")) != null && Http.cookies.GetCookies(new Uri(ConfigService.ApiUri + "/login")).Count != 0)//存在cookies,检查登陆状态
                {
                    var status = GetLoginStatus();
                    if (status != null && status.Data.account != null)
                    {
                        return(status.Data);
                    }
                }
            }
            catch (NullReferenceException)//上一次请求出错后记录了错误的cookie,再次读取会引发null错误
            {
                Http.cookies = null;
            }
            if (Http.cookies == null)
            {
                Http.cookies = new System.Net.CookieContainer();
            }
            string result = null;

            if (ConfigService.PhoneOrEmail.Contains('@'))
            {
                result = Http.Get(ConfigService.ApiUri + @"/login?email=" + ConfigService.PhoneOrEmail + "&md5_password="******"/login/cellphone?phone=" + ConfigService.PhoneOrEmail + "&md5_password="******""))
            {
                return(null);
            }
            try
            {
                return(JsonConvert.DeserializeObject <LoginRoot>(result));
            }
            catch (Exception er) { OtherHelper.ShowContentDialog(er.ToString()); return(null); }
        }
Beispiel #29
0
        async void ChangePlayBar(SongsItem song, BitmapImage bitmapImage, string musicName, string artistName, string albumName, int maximum, bool isStartPlaying = true)
        {
            Image_playingAlbum.Source = bitmapImage;//修改专辑图片
            TextBlcok_musicName.Text  = musicName;
            TextBlcok_artistName.Text = artistName;
            TextBlcok_albumName.Text  = albumName;
            TextBlock_lengthTime.Text = await Task.Run(() => OtherHelper.GetDt(maximum));

            if (isStartPlaying)
            {
                SymbolIcon_stopOrPlay.Symbol = Symbol.Pause;
            }
            if (song.isFavorite)
            {
                TextBlock_isOrnotFavorite.Text = "\xE00B";
            }
            else
            {
                TextBlock_isOrnotFavorite.Text = "\xE006";
            }
        }
        /// <summary>
        /// 刪除快取同步物件
        /// 盡量在函式的最後呼叫,怕Dispose先呼叫後,把刪除後一些後續動作要用到的欄位給初始化掉了
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="self"></param>
        /// <param name="id"></param>
        /// <returns></returns>
        public static async ETTask <bool> Delete <T>(this RedisEventSolverComponent self, long id) where T : ComponentWithId
        {
            if (self.isDebug)
            {
                OtherHelper.LogCallStackMessage("Delete");
            }

            var result = await self.cacheProxyComponent.QueryById <T>(id);

            var isSucc = false;

            if (result != default)
            {
                isSucc = await self.cacheProxyComponent.DeleteById <T>(id);

                if (isSucc)
                {
                    var msg   = CacheHelper.ConvertRedisPublish2Message(id, IdGenerater.AppId);
                    var count = await self.redisPubClient.GetSubscriber().PublishAsync(self.channelDeleteKey, msg);

                    self.onWillDelete?.Invoke(id);
                    if (self.Data.TryGetValue(id, out var component))
                    {
                        component.Dispose();
                        self.Data.Remove(id);
                        self.mineSet.Remove(id);
                    }
                    // 觸發事件
                    self.onRefresh?.Invoke(id);
                    self.onDelete?.Invoke(id);
                }
                else
                {
                    Log.Warning($"to delete cache is failed! object has deleted on {typeof(T).Name}[{id}]");
                }
            }

            return(isSucc);
        }