private void ChangeLayout() { string name = AppTools.GetRoamingSetting(AppSettings.FeedLayoutType, "All"); if (name == "All") { FeedGridView.Visibility = Visibility.Visible; FeedListView.Visibility = Visibility.Collapsed; FeedGridView.ItemTemplate = FeedWaterfallItemTemplate; Waterfall.IsChecked = true; } else if (name == "Card") { FeedGridView.Visibility = Visibility.Visible; FeedListView.Visibility = Visibility.Collapsed; FeedGridView.ItemTemplate = FeedCardItemTemplate; Card.IsChecked = true; } else { FeedGridView.Visibility = Visibility.Collapsed; FeedListView.Visibility = Visibility.Visible; List.IsChecked = true; } }
private void LayoutMenuItem_Click(object sender, RoutedEventArgs e) { string name = (sender as ToggleMenuFlyoutItem).Name; switch (name) { case "Waterfall": // 由于迭代的问题,这里不好修改,就定为All了 name = "All"; Card.IsChecked = false; List.IsChecked = false; break; case "Card": Waterfall.IsChecked = false; List.IsChecked = false; break; case "List": Card.IsChecked = false; Waterfall.IsChecked = false; break; default: name = "All"; break; } string oldLayout = AppTools.GetRoamingSetting(CoreLib.Enums.AppSettings.FeedLayoutType, "All"); if (oldLayout != name) { AppTools.WriteRoamingSetting(AppSettings.FeedLayoutType, name); ChangeLayout(); } }
private async Task ValidateChannelLink() { var reg = new Regex(@"(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"); string link = ChannelLinkTextBox.Text.Trim(); if (string.IsNullOrEmpty(link)) { new PopupToast(AppTools.GetReswLanguage("Tip_FieldEmpty"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); } else { TryLinkButton.IsEnabled = false; LoadingRing.IsActive = true; if (!reg.IsMatch(link)) { var results = await FeedlyResult.GetFeedlyResultFromText(link); TryLinkButton.IsEnabled = true; LoadingRing.IsActive = false; if (results.Count > 0) { SearchResultContainer.Visibility = Visibility.Visible; FeedlyResults.Clear(); foreach (var item in results) { FeedlyResults.Add(item); } } else { SearchResultContainer.Visibility = Visibility.Collapsed; FeedlyResults.Clear(); new PopupToast(AppTools.GetReswLanguage("Tip_NoData"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); } } else { var channel = await AppTools.GetChannelFromUrl(link); if (channel != null && !string.IsNullOrEmpty(channel.Name)) { _sourceChannel = channel; LoadingRing.IsActive = false; TryLinkButton.IsEnabled = true; DetailContainer.Visibility = Visibility.Visible; if (string.IsNullOrEmpty(ChannelNameTextBox.Text) && string.IsNullOrEmpty(ChannelDescriptionTextBox.Text)) { ChannelNameTextBox.Text = channel.Name; ChannelDescriptionTextBox.Text = channel.Description; } } else { LoadingRing.IsActive = false; TryLinkButton.IsEnabled = true; new PopupToast(AppTools.GetReswLanguage("App_InvalidUrl"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); } } } }
/// <summary> /// 添加频道对话框 /// </summary> public AddChannelDialog() { this.InitializeComponent(); Title = AppTools.GetReswLanguage("Tip_AddChannel"); PrimaryButtonText = AppTools.GetReswLanguage("Tip_Confirm"); SecondaryButtonText = AppTools.GetReswLanguage("Tip_Cancel"); }
public static void UpdateCampaign(Model_Campaign parameters) { Model_Campaign ret = CampaignController.Update(parameters); AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON()); }
public static void UpdateTemplate(Model_Template parameters) { Model_Template ret = TemplateController.Update(parameters); AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON()); }
/// <summary> /// 完成对云端元数据的替换 /// </summary> /// <returns></returns> public async Task BackupDatabase() { bool isChanged = Convert.ToBoolean(AppTools.GetLocalSetting(AppSettings.IsDatabaseChanged, "False")); if (isChanged) { var localFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("ImgMeta.db", CreationCollisionOption.OpenIfExists); using (var localStream = await localFile.OpenReadAsync()) { var cloudDb = await _appFolder.StorageFolderPlatformService.CreateFileAsync("ImgMeta.db", CreationCollisionOption.ReplaceExisting, localStream); AppTools.WriteLocalSetting(AppSettings.IsDatabaseChanged, "False"); } TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0); string ChangeTime = Convert.ToInt32(ts.TotalSeconds).ToString(); var temp = await WriteTempFile("LastAsyncTime", ChangeTime); using (var stream = await temp.OpenReadAsync()) { await _appFolder.StorageFolderPlatformService.CreateFileAsync("LastAsyncTime", CreationCollisionOption.ReplaceExisting, stream); } AppTools.WriteLocalSetting(AppSettings.SyncTime, ChangeTime); } }
public static void CheckStatus() { bool success = true; string msg = "no"; bool Isprocess = false; string Total = "0"; string PerCent = "0"; SubScriberImportController.Lock.AcquireReaderLock(Timeout.Infinite); Isprocess = SubScriberImportController.Onprocess; PerCent = SubScriberImportController.PercentCompleted.ToString("0"); Total = SubScriberImportController.TotalCompleted.ToString(); SubScriberImportController.Lock.ReleaseReaderLock(); string res = (new BaseWebMethodAJax { success = success, msg = msg, IsOnprocess = Isprocess, PerCentCompleted = PerCent, Totalrecord = Total }).ObjectToJSON(); AppTools.SendResponse(HttpContext.Current.Response, res); }
/// <summary> /// (供外部调用)重新加载分组集合 /// </summary> public void GroupCollectionReInit() { isInit = false; var groups = App.Db.Groups; GroupCollection.Clear(); string selectId = AppTools.GetLocalSetting(AppSettings.SelectGroupIndex, ""); if (string.IsNullOrEmpty(selectId)) { selectId = groups.ToList()[0].GroupId; AppTools.WriteLocalSetting(AppSettings.SelectGroupIndex, selectId); } foreach (var item in groups) { GroupCollection.Add(item); } foreach (var item in GroupCollection) { if (item.GroupId == selectId) { GroupCombo.SelectedItem = item; } } isInit = true; }
public async void GetDataChannelApi() { try { if (ListUtils.MyChannelList.Count == 0) { await ApiRequest.GetChannelData(Activity, UserDetails.UserId); } var dataChannel = ListUtils.MyChannelList.FirstOrDefault(); if (dataChannel != null) { var name = AppTools.GetNameFinal(dataChannel); CollapsingToolbar.Title = name; ChannelNameText.Text = name; GlideImageLoader.LoadImage(Activity, dataChannel.Avatar, ImageChannel, ImageStyle.CircleCrop, ImagePlaceholders.Drawable); Glide.With(this).Load(dataChannel.Cover).Apply(new RequestOptions().FitCenter()).Into(ImageCoverChannel); if (dataChannel.Verified == "1") { ChannelVerifiedText.Visibility = ViewStates.Visible; } } } catch (Exception exception) { Console.WriteLine(exception); } }
/// <summary> /// 图片搜索 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void SearchImgBox_TextChanged(object sender, TextChangedEventArgs e) { // 根据输入内容搜索数据库内的图片名称 string text = SearchImgBox.Text.Trim(); SearchResultCollection.Clear(); if (string.IsNullOrEmpty(text)) { SearchPop.IsOpen = false; return; } var list = App.Db.Images.Where(p => AppTools.NormalString(p.ImageName).IndexOf(AppTools.NormalString(text)) != -1); if (list.Count() > 0) { foreach (var item in list) { SearchResultCollection.Add(item); } SearchPop.IsOpen = true; } else { SearchPop.IsOpen = false; } }
/// <summary> /// 组内历史图片记录 /// </summary> public void HistoryInit() { // 这里的显示就按时间正序 string groupId = AppTools.GetLocalSetting(AppSettings.SelectGroupIndex, ""); var imgs = App.Db.Images.Where(p => p.GroupId == groupId); if (imgs.Count() > 0) { HistoryImageCollection.Clear(); foreach (var item in imgs) { HistoryImageCollection.Add(item); } HistoryNoDataTipBlock.Visibility = Visibility.Collapsed; HistoryGridView.Visibility = Visibility.Visible; } else { HistoryNoDataTipBlock.Visibility = Visibility.Visible; HistoryGridView.Visibility = Visibility.Collapsed; } IsHistoryImageInit = true; AllInitCheck(); }
/// <summary> /// 分组加载 /// </summary> private async void GroupInit() { var group = App.Db.Groups; // 如果是第一次运行软件,则为其创建一个默认分组 if (group.Count() == 0) { int num = await App.OneDriveTools.AddGroupToDatabase(App.Db, new OneDriveImageGroup("Default")); if (num > 0) { GroupInit(); } } else { // 检查上一次选中的分组,如果没有,则默认选中第一个 GroupCollection.Clear(); string lastGroupId = AppTools.GetLocalSetting(AppSettings.SelectGroupIndex, ""); if (string.IsNullOrEmpty(lastGroupId)) { lastGroupId = group.First().GroupId; AppTools.WriteLocalSetting(AppSettings.SelectGroupIndex, lastGroupId); } foreach (var item in group) { GroupCollection.Add(item); if (item.GroupId == lastGroupId) { GroupCombo.SelectedItem = item; } } HistoryInit(); } }
private async void OneDriveInit() { try { UpdateLoadingRing.IsActive = true; // 检查OneDrive授权并获取应用文件夹 await App.OneDriveTools.OneDriveAuthorize(); // 检查云端数据库是否需要同步最新更改 bool isNoNeedSync = await App.OneDriveTools.CheckLastAsync(); if (!isNoNeedSync) { new PopupMaskTip(AppTools.GetReswLanguage("HaveUpdate")).Show(); App.Db.Dispose(); // 从别的客户端处修改了数据,那么本机进行数据同步 await App.OneDriveTools.SyncCloud(); App.Db = new ImageDbContext(); } UpdateLoadingRing.IsActive = false; } catch (Exception ex) { UpdateLoadingRing.IsActive = false; // 这里可能会出现授权失败的情况 if (ex.GetType() == typeof(UnauthorizedAccessException)) { } else { throw; } } }
public LoginPage() { this.InitializeComponent(); AppTools.SetTitleBarColorInit(App.Current.RequestedTheme == ApplicationTheme.Dark); ToolTipService.SetToolTip(OpenSourceButton, AppTools.GetReswLanguage("OpenSourceButton")); ToolTipService.SetToolTip(UseInfoButton, AppTools.GetReswLanguage("UseInfoButton")); }
public async static Task <string> Translate(string input, string appId, string key, string from = "zh", string to = "en") { string salt = "1435660288"; string tempSign = appId + input + salt + key; MD5 md5 = MD5.Create(); byte[] tempSignBytes = md5.ComputeHash(Encoding.UTF8.GetBytes(tempSign)); string sign = ""; for (int i = 0; i < tempSignBytes.Length; i++) { sign = sign + tempSignBytes[i].ToString("x2"); } string query = $"q={WebUtility.UrlEncode(input)}&from={from}&to={to}&appid={appId}&salt={salt}&sign={sign}"; string url = $"{_baseUrl}?{query}"; var translate = await AppTools.PostAsyncData(_baseUrl, query); var obj = JObject.Parse(translate); string result = ""; foreach (var trans_result in obj["trans_result"]) { result += trans_result?["dst"].ToString() + "\r\n"; } return(result.Trim()); }
public Model_Template model_InsertEmailEelement(Model_Template el) { int ret = 0; DateTime d = DatetimeHelper._UTCNow(); string filename = d.ToString("ddmmyyyyhhmmss") + ".jpg"; using (SqlConnection cn = new SqlConnection(this.ConnectionString)) { SqlCommand cmd = new SqlCommand(@"INSERT INTO Template (EID,CreatedDate,CreateBy,Title,Description,DemoPath,DemoFileName) VALUES(@EID,@CreatedDate,@CreateBy,@Title,@Description,@DemoPath,@DemoFileName) ; SET @TID = SCOPE_IDENTITY(); ", cn); cmd.Parameters.Add("@EID", SqlDbType.NVarChar).Value = el.EID; cmd.Parameters.Add("@CreatedDate", SqlDbType.SmallDateTime).Value = el.CreatedDate; cmd.Parameters.Add("@CreateBy", SqlDbType.NVarChar).Value = el.CreateBy; cmd.Parameters.Add("@Title", SqlDbType.NVarChar).Value = el.Title; cmd.Parameters.Add("@Description", SqlDbType.NVarChar).Value = el.Description; cmd.Parameters.Add("@DemoPath", SqlDbType.NVarChar).Value = AppTools.TemplateMockPath(); cmd.Parameters.Add("@DemoFileName", SqlDbType.NVarChar).Value = filename; cmd.Parameters.Add("@TID", SqlDbType.Int).Direction = ParameterDirection.Output; cn.Open(); if (ExecuteNonQuery(cmd) > 0) { ret = (int)cmd.Parameters["@TID"].Value; // string fullpath = AppTools.TemplateMockPath() + "test.png"; HtmlToImage.ConvertHtmlToImage(AppTools.TemplateMockPath(), filename, el.EL.html); } el.DemoPath = AppTools.TemplateMockPath(); el.DemoFileName = filename; el.TID = ret; } return(el); }
public static void GetAll_checkprocess(Model_Campaign parameters) { IList <Model_Campaign> ret = CampaignController.GetAllCampaignCP(parameters); AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON()); }
public override void Draw(BuildWindowConfig config) { var appManifest = AppTools.GetAppManifest; var appManifestAsset = AppTools.GetAppManifestAsset; EditorGUILayout.BeginVertical("Box"); { EditorGUIHelper.DrawTitle("Publishing Settings"); EditorGUILayout.LabelField( "The App Manifest is how we identify your experiences from other experiences"); _id = EditorGUILayout.IntField("ID", _id); _version = EditorGUILayout.IntField("Version", _version); GUILayout.FlexibleSpace(); EditorGUILayout.BeginHorizontal(); { appManifestAsset = (TextAsset)EditorGUILayout.ObjectField(appManifestAsset, typeof(TextAsset), true); if (GUILayout.Button("Update Manifest")) { if (EnsureManifestFolderExists()) { AppTools.CreateAppManifest(_id, _version); } EditorGUIUtility.PingObject(appManifestAsset); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } }
private void tick(object state) { AppTools.ExecuteBlockWithStandardExceptionHandling( () => { // We need to schedule the next tick even if there is an exception thrown in this one. Use try-finally instead of CallEveryMethod so we don't lose // exception stack traces. try { var now = DateTime.Now; if (AppTools.IsLiveInstallation && !ConfigurationStatics.MachineIsStandbyServer && new[] { lastHealthCheckDateAndTime, now }.Any(dt => dt.Date.IsBetweenDateTimes(lastHealthCheckDateAndTime, now))) { StandardLibraryMethods.SendHealthCheckEmail(WindowsServiceMethods.GetServiceInstalledName(service)); } lastHealthCheckDateAndTime = now; service.Tick(); } finally { try { timer.Change(tickInterval, Timeout.Infinite); } catch (ObjectDisposedException) { // This should not be necessary with the Timer.Dispose overload we are using, but see http://stackoverflow.com/q/12354883/35349. } } }); }
private void Page_Loaded(object sender, RoutedEventArgs e) { bool isJustUnread = Convert.ToBoolean(AppTools.GetLocalSetting(AppSettings.IsJustUnread, "False")); JustNoReadSwitch.IsOn = isJustUnread; _isInit = true; }
/// <summary> /// Call this from Application_End in your Global.asax.cs file. Besides this call, there should be no other code in the method. /// </summary> public static void CleanUpStatics() { if (!ewlInitialized) { return; } if (!AppTools.SecondaryInitFailed) { EwfApp.ExecuteWithBasicExceptionHandling( () => { if (appInitializer != null) { appInitializer.CleanUpStatics(); } }, false, false); } AppTools.CleanUp(); if (!EwfApp.FrameworkInitialized) { var waitHandle = new ManualResetEvent(false); initFailureUnloadTimer.Dispose(waitHandle); waitHandle.WaitOne(); } }
private async void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args) { args.Cancel = true; string name = ChannelNameTextBox.Text?.Trim(); string des = ChannelDescriptionTextBox.Text?.Trim(); string link = ChannelLinkTextBox.Text?.Trim(); var reg = new Regex(@"(https?|ftp|file)://[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]"); if (string.IsNullOrEmpty(name) || string.IsNullOrEmpty(des) || string.IsNullOrEmpty(link)) { new PopupToast(AppTools.GetReswLanguage("Tip_FieldEmpty"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); return; } else if (!reg.IsMatch(link)) { new PopupToast(AppTools.GetReswLanguage("Tip_FieldFormatError"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); return; } else { _sourceChannel.Name = name; _sourceChannel.Description = des; _sourceChannel.Link = link; var sourceCategory = MainPage.Current.CategoryListView.SelectedItem as Category; if (sourceCategory != null) { IsPrimaryButtonEnabled = false; PrimaryButtonText = AppTools.GetReswLanguage("Tip_Waiting"); foreach (var item in sourceCategory.Channels) { if (item.Id == _sourceChannel.Id) { item.Name = name; item.Description = des; item.Link = link; } } if (MainPage.Current.MainFrame.Content is Pages.ChannelDetailPage) { if (Pages.ChannelDetailPage.Current._sourceData.Id == _sourceChannel.Id) { Pages.ChannelDetailPage.Current.ChannelNameTextBlock.Text = name; Pages.ChannelDetailPage.Current.ChannelDescriptionTextBlock.Text = des; Pages.ChannelDetailPage.Current._sourceData.Name = name; Pages.ChannelDetailPage.Current._sourceData.Description = des; Pages.ChannelDetailPage.Current._sourceData.Link = link; } } new PopupToast(AppTools.GetReswLanguage("Tip_UpdateChannelSuccess")).ShowPopup(); Hide(); await IOTools.UpdateCategory(sourceCategory); } else { new PopupToast(AppTools.GetReswLanguage("Tip_NoCategorySelected"), AppTools.GetThemeSolidColorBrush(ColorType.ErrorColor)).ShowPopup(); return; } } }
public AuthKeyDialog() { this.InitializeComponent(); Title = AppTools.GetReswLanguage("AuthorizeTitle"); TipContentBlock.Text = AppTools.GetReswLanguage("AuthKeyTip"); PrimaryButtonText = AppTools.GetReswLanguage("Authorize"); CloseButtonText = AppTools.GetReswLanguage("Cancel"); }
public static void GetReportSectionItemAll(Model_ReportSectionItem parameters) { Model_ReportSectionItem pr = new Model_ReportSectionItem(); IList <Model_ReportSectionItem> ret = pr.GetListItem(parameters.ResultSectionID); AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON()); }
public static void GetReportSectionAll(Model_ReportSection parameters) { Model_ReportSection pr = new Model_ReportSection(); IList <Model_ReportSection> ret = pr.GetList(); AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON()); }
public static void JobFucntionScore(Model_JobFunctionListMap parameters) { Model_JobFunctionListMap cgroup = new Model_JobFunctionListMap(); List <Model_JobFunctionListMap> ret = cgroup.GetAll(parameters); AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON()); }
public static void JobFucntion(Model_Jobfunction parameters) { Model_Jobfunction cgroup = new Model_Jobfunction(); List <Model_Jobfunction> ret = cgroup.GetAll(); AppTools.SendResponse(HttpContext.Current.Response, ret.ObjectToJSON()); }
public void ShowWarning(string text, TimeIWindow time) { AppTools.RunOnUiThread(() => { CenterImageViewCross.SetImageFromResource("warning.svg"); ShowInternal(text, time); }); }
private void HideWebScrollSwitch_Toggled(object sender, RoutedEventArgs e) { if (!_isInit) { return; } AppTools.WriteLocalSetting(AppSettings.IsHideWebScroll, HideWebScrollSwitch.IsOn.ToString()); }