/// <summary> /// 执行job /// </summary> /// <param name="jobItem"></param> /// <returns></returns> public bool StartBackgroudJob(HttpJobItem jobItem) { try { if (string.IsNullOrEmpty(jobItem.Data)) { return(true); } using (var connection = JobStorage.Current.GetConnection()) { var hashKey = CodingUtil.MD5(jobItem.JobName + ".runtime"); using (var tran = connection.CreateWriteTransaction()) { tran.SetRangeInHash(hashKey, new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("Data", jobItem.Data) }); tran.Commit(); } } return(true); } catch (Exception ex) { Logger.ErrorException("HttpJobDispatcher.StartBackgroudJob", ex); return(false); } }
/// <summary> /// 保存全局配置 /// </summary> /// <param name="context"></param> /// <returns></returns> private async Task SaveGlobalSetting(DashboardContext context) { try { var content = await GetRequestBody <string>(context); if (string.IsNullOrEmpty(content)) { await context.Response.WriteAsync("err: json invaild"); return; } var jsonString = ConvertJsonString(content); if (string.IsNullOrEmpty(jsonString)) { await context.Response.WriteAsync($"err: invaild json !"); return; } File.WriteAllText(CodingUtil.HangfireHttpJobOptions.GlobalSettingJsonFilePath, jsonString); CodingUtil.GetGlobalAppsettings(); } catch (Exception e) { await context.Response.WriteAsync("err:" + e.Message); } }
/// <summary> /// 执行job /// </summary> /// <param name="context"></param> /// <returns></returns> public async Task StartBackgroudJob(DashboardContext context) { try { var jobItemBody = await GetRequestBody <HttpJobItem>(context); var jobItem = jobItemBody.Item1; if (jobItem == null || string.IsNullOrEmpty(jobItem.JobName)) { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; await context.Response.WriteAsync($"invalid request body:{jobItemBody.Item2}"); return; } if (string.IsNullOrEmpty(jobItem.Data)) { context.Response.StatusCode = (int)HttpStatusCode.NoContent; return; } using (var connection = JobStorage.Current.GetConnection()) { var hashKey = CodingUtil.MD5((!string.IsNullOrEmpty(jobItem.RecurringJobIdentifier)?jobItem.RecurringJobIdentifier:jobItem.JobName) + ".runtime"); using (var tran = connection.CreateWriteTransaction()) { tran.SetRangeInHash(hashKey, new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("Data", jobItem.Data) }); tran.Commit(); } } context.Response.StatusCode = (int)HttpStatusCode.NoContent; return; } catch (Exception ex) { Logger.ErrorException("HttpJobDispatcher.StartBackgroudJob", ex); context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; await context.Response.WriteAsync(ex.Message); } }
public async Task Dispatch(DashboardContext context) { var builder = new StringBuilder(); string DefaultTimeZone = CodingUtil.GetGlobalAppsetting <string>("DefaultTimeZone", null); bool EnableDingTalk = CodingUtil.GetGlobalAppsetting <bool>("EnableDingTalk", false); builder.Append(@"(function (hangFire) {") .Append("hangFire.httpjobConfig = {};") .AppendFormat("hangFire.httpjobConfig.DefaultTimeZone = '{0}';", DefaultTimeZone ?? _options.DefaultTimeZone) .AppendFormat("hangFire.httpjobConfig.DingtalkToken = '{0}';", _options?.DingTalkOption?.Token ?? "") .AppendFormat("hangFire.httpjobConfig.DingtalkPhones = '{0}';", _options?.DingTalkOption?.AtPhones ?? "") .AppendFormat("hangFire.httpjobConfig.DingtalkAtAll = '{0}';", _options?.DingTalkOption?.IsAtAll ?? false ? "true" : "false") .AppendFormat("hangFire.httpjobConfig.EnableDingTalk = '{0}';", EnableDingTalk ? "true": _options?.EnableDingTalk ?? false ? "true" : "false") .AppendFormat("hangFire.httpjobConfig.AddHttpJobButtonName = '{0}';", _options.AddHttpJobButtonName) .AppendFormat("hangFire.httpjobConfig.ExportJobsButtonName = '{0}';", _options.ExportJobsButtonName) .AppendFormat("hangFire.httpjobConfig.ImportJobsButtonName = '{0}';", _options.ImportJobsButtonName) .AppendFormat("hangFire.httpjobConfig.AddRecurringJobHttpJobButtonName = '{0}';", _options.AddRecurringJobHttpJobButtonName) .AppendFormat("hangFire.httpjobConfig.AddCronButtonName = '{0}';", _options.AddCronButtonName) .AppendFormat("hangFire.httpjobConfig.PauseJobButtonName = '{0}';", _options.PauseJobButtonName) .AppendFormat("hangFire.httpjobConfig.EditRecurringJobButtonName = '{0}';", _options.EditRecurringJobButtonName) .AppendFormat("hangFire.httpjobConfig.SearchPlaceholder = '{0}';", _options.SearchPlaceholder) .AppendFormat("hangFire.httpjobConfig.DashboardTitle = '{0}';", _options.DashboardTitle) .AppendFormat("hangFire.httpjobConfig.DashboardName = '{0}';", _options.DashboardName) .AppendFormat("hangFire.httpjobConfig.DashboardFooter = '{0}';", _options.DashboardFooter) .AppendFormat("hangFire.httpjobConfig.LogOutButtonName = '{0}';", _options.LogOutButtonName) .AppendFormat("hangFire.httpjobConfig.DefaultRecurringQueueName = '{0}';", _options.DefaultRecurringQueueName) .AppendFormat("hangFire.httpjobConfig.DefaultBackGroundJobQueueName = '{0}';", _options.DefaultBackGroundJobQueueName) .AppendFormat("hangFire.httpjobConfig.StartBackgroudJobButtonName = '{0}';", _options.StartBackgroudJobButtonName) .AppendFormat("hangFire.httpjobConfig.StopBackgroudJobButtonName = '{0}';", _options.StopBackgroudJobButtonName) .AppendFormat("hangFire.httpjobConfig.AgentJobDeatilButton = '{0}';", _options.AgentJobDeatilButton) .AppendFormat("hangFire.httpjobConfig.CloseButtonName = '{0}';", _options.CloseButtonName) .AppendFormat("hangFire.httpjobConfig.SubmitButtonName = '{0}';", _options.SubmitButtonName) .AppendFormat("hangFire.httpjobConfig.GlobalHttpTimeOut = {0};", _options.GlobalHttpTimeOut) .AppendFormat("hangFire.httpjobConfig.GlobalSetButtonName = '{0}';", _options.GobalSettingButtonName) .AppendFormat("hangFire.httpjobConfig.AddHttpJobUrl = '{0}/httpjob?op=backgroundjob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.AddCronUrl = '{0}/cron';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.AppUrl = '{0}';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.AddRecurringJobUrl = '{0}/httpjob?op=recurringjob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.GetRecurringJobUrl = '{0}/httpjob?op=GetRecurringJob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.EditRecurringJobUrl = '{0}/httpjob?op=EditRecurringJob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.ImportJobsUrl = '{0}/httpjob?op=ImportJobs';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.ExportJobsUrl = '{0}/httpjob?op=ExportJobs';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.GetGlobalSettingUrl = '{0}/httpjob?op=GetGlobalSetting';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.PostGlobalSettingUrl = '{0}/httpjob?op=SaveGlobalSetting';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.PauseJobUrl = '{0}/httpjob?op=PauseJob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.DeleteJobUrl = '{0}/httpjob?op=deljob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.AgentJobDeatilButtonUrl = '{0}/httpjob?op=getbackgroundjobdetail';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.StartBackgroudJobUrl = '{0}/httpjob?op=StartBackgroundJob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.StopBackgroudJobUrl = '{0}/httpjob?op=StopBackgroundJob';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.GetJobListUrl = '{0}/httpjob?op=GetJobList';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.GetAgentServerListUrl = '{0}/httpjob?op=getagentserver';", context.Request.PathBase) .AppendFormat("hangFire.httpjobConfig.IsReadonly = '{0}';", context.Request.PathBase.Contains("read")) .AppendFormat("hangFire.httpjobConfig.ShowTag = '{0}';", TagsServiceStorage.Current != null) .AppendFormat("hangFire.httpjobConfig.NeedAddNomalHttpJobButton = location.href.indexOf('{0}') >= 0;", context.Request.PathBase.Contains("read") ? "only-read" : _options.ScheduledEndPath) .AppendFormat("hangFire.httpjobConfig.NeedAddRecurringHttpJobButton = location.href.indexOf('/enqueued/')==-1 && location.href.indexOf('{0}') >= 0;", context.Request.PathBase.Contains("read") ? "only-read" : _options.RecurringEndPath) .AppendFormat("hangFire.httpjobConfig.NeedAddCronButton = location.href.indexOf('/enqueued/')==-1 && location.href.indexOf('{0}') >= 0;;", context.Request.PathBase.Contains("read") ? "only-read" : _options.RecurringEndPath) .AppendFormat("hangFire.httpjobConfig.NeedEditRecurringJobButton =location.href.indexOf('/enqueued/')==-1 && location.href.indexOf('{0}') >= 0;", context.Request.PathBase.Contains("read") ? "only-read" : _options.RecurringEndPath) .AppendFormat("hangFire.httpjobConfig.NeedExportJobsButton = location.href.indexOf('/enqueued/')==-1 && location.href.indexOf('{0}') >= 0;", context.Request.PathBase.Contains("read") ? "only-read" : _options.RecurringEndPath) .AppendFormat("hangFire.httpjobConfig.NeedImportJobsButton = location.href.indexOf('/enqueued/')==-1 && location.href.indexOf('{0}') >= 0;", context.Request.PathBase.Contains("read") ? "only-read" : _options.RecurringEndPath) .Append("})(window.Hangfire = window.Hangfire || {});") .AppendLine(); await context.Response.WriteAsync(builder.ToString()); }
/// <summary> /// Run HttpRequest /// </summary> /// <param name="item"></param> /// <param name="context"></param> /// <param name="logList"></param> /// <param name="parentJob"></param> /// <exception cref="HttpStatusCodeException"></exception> private static bool Run(HttpJobItem item, PerformContext context, List <string> logList, HttpJobItem parentJob = null) { CancellationTokenSource cancelToken = null; try { if (parentJob != null) { RunWithTry(() => context.SetTextColor(ConsoleTextColor.Green)); if (item.Timeout < 1) { item.Timeout = parentJob.Timeout; } if (item.Data.Contains("@parent@")) { item.Data = item.Data.Replace("@parent@", parentJob.Cron); } if (string.IsNullOrEmpty(item.BasicUserName)) { item.BasicUserName = parentJob.BasicUserName; } if (string.IsNullOrEmpty(item.BasicPassword)) { item.BasicPassword = parentJob.BasicPassword; } if (item.Headers == null || !item.Headers.Any()) { item.Headers = parentJob.Headers; } if (string.IsNullOrEmpty(item.QueueName)) { item.QueueName = parentJob.QueueName; } RunWithTry(() => context.WriteLine($"【{Strings.CallbackStart}】[{item.CallbackRoot}]")); item.JobName = item.CallbackRoot; } else { if (string.IsNullOrEmpty(item.CallbackRoot)) { item.CallbackRoot = item.JobName; } if (item.Timeout < 1) { item.Timeout = 5000; } RunWithTry(() => context.SetTextColor(ConsoleTextColor.Yellow)); } RunWithTry(() => context.WriteLine($"{Strings.JobStart}:{DateTime.Now:yyyy-MM-dd HH:mm:ss}")); logList.Add($"{Strings.JobStart}:{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); RunWithTry(() => context.WriteLine($"{Strings.JobName}:{item.JobName ?? string.Empty}|{Strings.QueuenName}:{(string.IsNullOrEmpty(item.QueueName) ? "DEFAULT" : item.QueueName)}")); logList.Add( $"{Strings.JobName}:{item.JobName ?? string.Empty}|{Strings.QueuenName}:{(string.IsNullOrEmpty(item.QueueName) ? "DEFAULT" : item.QueueName)}"); RunWithTry(() => context.WriteLine($"{Strings.JobParam}:【{JsonConvert.SerializeObject(item)}】")); logList.Add($"{Strings.JobParam}:【{JsonConvert.SerializeObject(item, Formatting.Indented)}】"); HttpClient client; //当前job指定如果开启了proxy 并且 有配置代理 那么就走代理 if (CodingUtil.TryGetGlobalProxy(out var globalProxy) && item.Headers != null && item.Headers.TryGetValue("proxy", out var enableCurrentJobProxy) && !string.IsNullOrEmpty(enableCurrentJobProxy) && enableCurrentJobProxy.ToLower().Equals("true")) { // per proxy per HttpClient client = HangfireHttpClientFactory.Instance.GetProxiedHttpClient(globalProxy); RunWithTry(() => context.WriteLine($"Use Proxy:{globalProxy}")); logList.Add($"Proxy:{globalProxy}"); } else { //per host per HttpClient client = HangfireHttpClientFactory.Instance.GetHttpClient(item.Url); } var httpMesage = PrepareHttpRequestMessage(item, context, parentJob); cancelToken = new CancellationTokenSource(TimeSpan.FromMilliseconds(item.Timeout)); var httpResponse = client.SendAsync(httpMesage, cancelToken.Token).ConfigureAwait(false).GetAwaiter().GetResult(); HttpContent content = httpResponse.Content; string result = content.ReadAsStringAsync().GetAwaiter().GetResult(); RunWithTry(() => context.WriteLine($"{Strings.ResponseCode}:{httpResponse.StatusCode}")); logList.Add($"{Strings.ResponseCode}:{httpResponse.StatusCode}"); RunWithTry(() => context.WriteLine($"{Strings.JobResult}:{result}")); logList.Add($"{Strings.JobResult}:{result}"); RunWithTry(() => context.WriteLine($"{Strings.JobEnd}:{DateTime.Now:yyyy-MM-dd HH:mm:ss}")); logList.Add($"{Strings.JobEnd}:{DateTime.Now:yyyy-MM-dd HH:mm:ss}"); //如果agent那边调度报错 if (!string.IsNullOrEmpty(item.AgentClass)) { if (CodingUtil.HangfireHttpJobOptions.EnableJobAgentErrorThrow && httpResponse.StatusCode == HttpStatusCode.InternalServerError) { throw new AgentJobException(item.AgentClass, result); } //jobagent的单例没有执行完重复调度的case是否要作为异常 if (!CodingUtil.IgnoreJobAgentSingletonMultExcuteError() && httpResponse.StatusCode == HttpStatusCode.NotImplemented) { throw new AgentJobException(item.AgentClass, result); } //jobagent的话 在header里面有一个agentServerId GetCurrentJobAgentServerId(httpResponse, item, context); } //检查HttpResponse StatusCode else if ((CodingUtil.HangfireHttpJobOptions.CheckHttpResponseStatusCode == null && (int)httpResponse.StatusCode < 400) || (CodingUtil.HangfireHttpJobOptions.CheckHttpResponseStatusCode?.Invoke(httpResponse.StatusCode, result) ?? true)) { RunWithTry(() => context.WriteLine($"{Strings.ResponseCode}:{httpResponse.StatusCode} ===> CheckResult: Ok ")); logList.Add($"{Strings.ResponseCode}:{httpResponse.StatusCode} ===> CheckResult: Ok "); } else { //错误的log都会在exception里面出 throw new HttpStatusCodeException(httpResponse.StatusCode, result); } //检查是否有设置EL表达式 可以自定义检查StatusCode 和 解析返回的参数值 if (!string.IsNullOrEmpty(item.CallbackEL)) { var elResult = InvokeSpringElCondition(item.CallbackEL, result, context, new Dictionary <string, object> { { "resultBody", result }, { "StatusCode", (int)httpResponse.StatusCode } }); if (!elResult) { //错误的log都会在exception里面出 throw new HttpStatusCodeException(item.CallbackEL, result); } RunWithTry(() => context.WriteLine($"【{Strings.CallbackELExcuteResult}:Ok 】" + item.CallbackEL)); } if (parentJob != null) { RunWithTry(() => context.WriteLine($"【{Strings.CallbackSuccess}】[{item.CallbackRoot}]")); } //到这里查看是否有 子Job if (item.Success != null) { item.Cron = result; //父job的执行结果 item.Success.CallbackRoot = item.CallbackRoot + ".Success"; return(Run(item.Success, context, logList, item)); } return(true); }
/// <summary> /// 停止或者暂停项目 /// </summary> /// <param name="jobname"></param> /// <returns></returns> public string PauseOrRestartJob(string jobname) { try { using (var connection = JobStorage.Current.GetConnection()) { Dictionary <string, string> dictionary = connection.GetAllEntriesFromHash("recurring-job:" + jobname); if (dictionary == null || dictionary.Count == 0) { return("not found recurring-job:" + jobname); } if (!dictionary.TryGetValue(nameof(Job), out var jobDetail)) { return("not found recurring-job:" + jobname); } var RecurringJob = InvocationData.DeserializePayload(jobDetail).DeserializeJob(); var job = CodingUtil.FromJson <HttpJobItem>(RecurringJob.Args.FirstOrDefault()?.ToString()); if (job == null) { return("fail parse recurring-job:" + jobname); } using (var tran = connection.CreateWriteTransaction()) { //拿到所有的设置 var conts = connection.GetAllItemsFromSet($"JobPauseOf:{jobname}"); //有就先清掉 foreach (var pair in conts) { tran.RemoveFromSet($"JobPauseOf:{jobname}", pair); } var cron = conts.FirstOrDefault(r => r.StartsWith("Cron:")); if (!string.IsNullOrEmpty(cron)) { cron = cron.Replace("Cron:", ""); } //如果包含有true 的 说明已经设置了 暂停 要把改成 启动 并且拿到 Cron 进行更新 if (conts.Contains("true")) { tran.AddToSet($"JobPauseOf:{jobname}", "false"); if (!string.IsNullOrEmpty(cron)) { job.Cron = cron; AddHttprecurringjob(job); } } else { tran.AddToSet($"JobPauseOf:{jobname}", "true"); tran.AddToSet($"JobPauseOf:{jobname}", "Cron:" + job.Cron); job.Cron = ""; AddHttprecurringjob(job); } tran.Commit(); } } return(string.Empty); } catch (Exception ex) { Logger.ErrorException("HttpJobDispatcher.PauseOrRestartJob", ex); return(ex.Message); } }
private bool SaveOptions(bool closeOptionsAfterSave) { if (enableProxySettingsCheckBox.Checked && (String.IsNullOrEmpty(usernameTextBox.Text) || String.IsNullOrEmpty(passwordTextBox.Text))) { WindowManager.ShowAlertBox(this, LanguageUtil.GetCurrentLanguageString("proxyWarning", Name)); return(false); } if (backupCustomFolderRadioButton.Checked && !Directory.Exists(backupCustomFolderTextBox.Text)) { WindowManager.ShowAlertBox(this, LanguageUtil.GetCurrentLanguageString("backupLocationWarning", Name)); return(false); } if (String.IsNullOrEmpty(backupExtensionTextBox.Text)) { WindowManager.ShowAlertBox(this, LanguageUtil.GetCurrentLanguageString("backupExtensionWarning", Name)); return(false); } TypeConverter tc = TypeDescriptor.GetConverter(typeof(Font)); int settingFolder = 0; if (lastUsedFolderRadioButton.Checked) { settingFolder = 1; } int backupExtensionPosition = 0; if (backupReplaceExtensionRadioButton.Checked) { backupExtensionPosition = 1; } int backupLocation = 0; if (backupCustomFolderRadioButton.Checked) { backupLocation = 1; } int searchReturn = 0; if (searchReturnRadioButton2.Checked) { searchReturn = 1; } int tabsSwitchType = 0; if (tabsSwitchModeMouseRadioButton.Checked) { tabsSwitchType = 1; } int periodicVersionCheck = 0; if (enableAutomaticUpdateCheckBox.Checked && frequencyAutomaticUpdateComboBox.SelectedIndex == 0) { periodicVersionCheck = 1; } else if (enableAutomaticUpdateCheckBox.Checked && frequencyAutomaticUpdateComboBox.SelectedIndex == 1) { periodicVersionCheck = 2; } String[] parameterNames = { "SettingFolder", "SpecificFolder", "OverrideFolderWithActiveFile", "MaxNumRecentFile", "MaxNumSearchHistory", "StayOnTopDisabled", "ToolbarInvisible", "StatusBarInvisible", "MinimizeOnTrayIconDisabled", "LookAndFeel", "Language", "ProxyEnabled", "ProxyHost", "ProxyPort", "UseDefaultBrowser", "CustomBrowserCommand", "SearchReplacePanelDisabled", "SearchCaseSensitive", "SearchLoopAtEOF", "SearchHighlightsResults", "SearchReturn", "WordWrapDisabled", "FontInUse", "FontInUseColorARGB", "BackgroundColorARGB", "HighlightURL", "InternalExplorerInvisible", "TabCloseButtonMode", "TabPosition", "TabOrientation", "TabMultiline", "DefaultEncoding", "Encoding", "LineNumbersVisible", "BackupEnabled", "BackupExtension", "BackupExtensionPosition", "BackupLocation", "BackupLocationCustom", "BackupIncremental", "SpacesInsteadTabs", "KeepInitialSpacesOnReturn", "KeepBulletListOnReturn", "ShowSplashScreen", "AutomaticSessionSave", "Translation", "TranslationUseSelect", "CheckLineNumber", "CheckLineNumberMax", "AutoFormatFiles", "AutoOpenHostsConfigurator", "ColorHostsConfigurator", "PeriodicVersionCheck", "ActiveJumpList", "EnableDropboxDelete", "RememberDropboxAccess", "IgnoreNullChar", "NoteModeTabs", "NoteModeSizeX", "NoteModeSizeY", "TabsSwitchType" }; String[] parameterValues = { settingFolder.ToString(), specificFolderTextBox.Text, folderOpenedFileCheckBox.Checked.ToString(), recentFilesNumberNumericUpDown.Value.ToString(), searchHistoryNumericUpDown.Value.ToString(), (!stayOnTopCheckBox.Checked).ToString(), (!toolbarCheckBox.Checked).ToString(), (!statusBarCheckBox.Checked).ToString(), (!minimizeOnTrayIconCheckBox.Checked).ToString(), renderModeComboBox.SelectedIndex.ToString(), languageComboBox.SelectedItem.ToString(), enableProxySettingsCheckBox.Checked.ToString(), proxyHostTextBox.Text, proxyPortNumericUpDown.Value.ToString(), defaultBrowserRadioButton.Checked.ToString(), customBrowserTextBox.Text, (!showSearchPanelCheckBox.Checked).ToString(), caseSensitiveCheckBox.Checked.ToString(), loopAtEOFCheckBox.Checked.ToString(), highlightsResultsCheckBox.Checked.ToString(), searchReturn.ToString(), (!wordWrapCheckBox.Checked).ToString(), tc.ConvertToString(TextFont), FontManager.SetARGBString(TextFontColor), FontManager.SetARGBString(TextBackgroundColor), urlsCheckBox.Checked.ToString(), (!internalExplorerCheckBox.Checked).ToString(), tabCloseButtonOnComboBox.SelectedIndex.ToString(), tabPositionComboBox.SelectedIndex.ToString(), tabOrientationComboBox.SelectedIndex.ToString(), tabMultilineCheckBox.Checked.ToString(), useExistingCheckBox.Checked.ToString(), defaultComboBox.SelectedIndex.ToString(), lineNumbersCheckBox.Checked.ToString(), createBackupCheckBox.Checked.ToString(), backupExtensionTextBox.Text, backupExtensionPosition.ToString(), backupLocation.ToString(), backupCustomFolderTextBox.Text, backupIncrementalCheckBox.Checked.ToString(), useSpacesInsteadTabsCheckBox.Checked.ToString(), keepInitialSpacesOnReturnCheckBox.Checked.ToString(), keepBulletListOnReturnCheckBox.Checked.ToString(), splashScreenCheckBox.Checked.ToString(), automaticSessionSaveCheckBox.Checked.ToString(), LanguageUtil.GetReallyShortCultureForGoogleTranslator(sourceImageComboBoxEdit.SelectedItem.ToString()) + "|" + LanguageUtil.GetReallyShortCultureForGoogleTranslator(destinationImageComboBoxEdit.SelectedItem.ToString()), useSelectedSettingsLanguageCheckBox.Checked.ToString(), hideLinesCheckBox.Checked.ToString(), hideLinesNumericUpDown.Value.ToString(), GetAutoFormatFilesString(), hostsConfiguratorCheckBox.Checked.ToString(), ColorUtil.GetColorFromTabInt(hostsConfiguratorTabColorComboBox.SelectedIndex).Name, periodicVersionCheck.ToString(), jumpListCheckBox.Checked.ToString(), dropboxDeleteCheckBox.Checked.ToString(), dropboxRememberCheckBox.Checked.ToString(), nullCharCheckBox.Checked.ToString(), noteModeTabsCheckBox.Checked.ToString(), noteModeSizeXNumericUpDown.Value.ToString(), noteModeSizeYNumericUpDown.Value.ToString(), tabsSwitchType.ToString() }; String[] passwordNames = { "ProxyUsername", "ProxyPassword", "ProxyDomain" }; String[] passwordValues = { usernameTextBox.Text, CodingUtil.EncodeString(passwordTextBox.Text), domainTextBox.Text }; OptionManager.SaveOptionsGroup(parameterNames, parameterValues, passwordNames, passwordValues); OptionManager.RefreshOwner(this, closeOptionsAfterSave, previousFont, TextFont, previousFontColor, TextFontColor, previousBackgroundColor, TextBackgroundColor, previousHighlightURL, previousLanguage, previousJumpListActivated); SetShellIntegration(); return(true); }
internal void InitializeForm() { Form1 form = (Form1)Owner; //Init InitializeComponent(); SetLanguage(); ControlUtil.SetContextMenuStrip(this, new[] { proxyHostTextBox, domainTextBox, passwordTextBox, usernameTextBox, customBrowserTextBox, specificFolderTextBox, backupExtensionTextBox, backupCustomFolderTextBox, searchHistoryNumericUpDown, hideLinesNumericUpDown, proxyPortNumericUpDown, recentFilesNumberNumericUpDown, noteModeSizeXNumericUpDown, (Control)noteModeSizeYNumericUpDown }); optionsTreeView.ExpandAll(); //Data OptionManager.SetListExtensions(this); String autoFormatFiles = ConfigUtil.GetStringParameter("AutoFormatFiles"); TextFont = ConfigUtil.GetFontParameter("FontInUse"); previousFont = TextFont; String[] argbFontColor = ConfigUtil.GetStringParameter("FontInUseColorARGB").Split(new[] { ';' }); TextFontColor = Color.FromArgb(Convert.ToInt32(argbFontColor[0]), Convert.ToInt32(argbFontColor[1]), Convert.ToInt32(argbFontColor[2]), Convert.ToInt32(argbFontColor[3])); previousFontColor = TextFontColor; String[] argbBackgroundColor = ConfigUtil.GetStringParameter("BackgroundColorARGB").Split(new[] { ';' }); TextBackgroundColor = Color.FromArgb(Convert.ToInt32(argbBackgroundColor[0]), Convert.ToInt32(argbBackgroundColor[1]), Convert.ToInt32(argbBackgroundColor[2]), Convert.ToInt32(argbBackgroundColor[3])); previousBackgroundColor = TextBackgroundColor; previousHighlightURL = ConfigUtil.GetBoolParameter("HighlightURL"); previousLanguage = ConfigUtil.GetStringParameter("Language"); //languageComboBox.SelectedItem.ToString(); List <PasswordObject> passwordList = PasswordUtil.GetStringParameters(new[] { "ProxyUsername", "ProxyPassword", "ProxyDomain" }); OptionManager.CheckProxyStatusEnabled(this); int periodicVersionCheck = ConfigUtil.GetIntParameter("PeriodicVersionCheck"); previousSendTo = ShellManager.ExistsSendToLink(); previousOpenWith = ShellManager.ExistsOpenWithLink(); previousJumpListActivated = ConfigUtil.GetBoolParameter("ActiveJumpList"); //Tab - File switch (ConfigUtil.GetIntParameter("SettingFolder")) { case 0: lastUsedFolderRadioButton.Checked = false; specificFolderRadioButton.Checked = true; break; case 1: lastUsedFolderRadioButton.Checked = true; specificFolderRadioButton.Checked = false; break; } specificFolderTextBox.Text = ConfigUtil.GetStringParameter("SpecificFolder"); folderOpenedFileCheckBox.Checked = ConfigUtil.GetBoolParameter("OverrideFolderWithActiveFile"); recentFilesNumberNumericUpDown.Value = ConfigUtil.GetIntParameter("MaxNumRecentFile"); //Tab - Encoding useExistingCheckBox.Checked = ConfigUtil.GetBoolParameter("DefaultEncoding"); defaultComboBox.SelectedIndex = ConfigUtil.GetIntParameter("Encoding"); //Tab - Opening htmlCheckBox.Checked = autoFormatFiles.Contains(".html"); xmlCheckBox.Checked = autoFormatFiles.Contains(".xml"); hostsConfiguratorCheckBox.Checked = ConfigUtil.GetBoolParameter("AutoOpenHostsConfigurator"); hostsConfiguratorTabColorComboBox.SelectedIndex = ColorUtil.GetIndexFromTabColor(ConfigUtil.GetColorParameter("ColorHostsConfigurator")); nullCharCheckBox.Checked = ConfigUtil.GetBoolParameter("IgnoreNullChar"); //Tab - Saving createBackupCheckBox.Checked = ConfigUtil.GetBoolParameter("BackupEnabled"); backupExtensionTextBox.Text = ConfigUtil.GetStringParameter("BackupExtension"); switch (ConfigUtil.GetIntParameter("BackupExtensionPosition")) { case 0: backupAddExtensionRadioButton.Checked = true; backupReplaceExtensionRadioButton.Checked = false; break; case 1: backupAddExtensionRadioButton.Checked = false; backupReplaceExtensionRadioButton.Checked = true; break; } backupIncrementalCheckBox.Checked = ConfigUtil.GetBoolParameter("BackupIncremental"); switch (ConfigUtil.GetIntParameter("BackupLocation")) { case 0: backupEditedFileRadioButton.Checked = true; backupCustomFolderRadioButton.Checked = false; break; case 1: backupEditedFileRadioButton.Checked = false; backupCustomFolderRadioButton.Checked = true; break; } backupCustomFolderTextBox.Text = ConfigUtil.GetStringParameter("BackupLocationCustom"); //Tab - Session automaticSessionSaveCheckBox.Checked = ConfigUtil.GetBoolParameter("AutomaticSessionSave"); //Tab - Search showSearchPanelCheckBox.Checked = !ConfigUtil.GetBoolParameter("SearchReplacePanelDisabled"); caseSensitiveCheckBox.Checked = ConfigUtil.GetBoolParameter("SearchCaseSensitive"); loopAtEOFCheckBox.Checked = ConfigUtil.GetBoolParameter("SearchLoopAtEOF"); searchHistoryNumericUpDown.Value = ConfigUtil.GetIntParameter("MaxNumSearchHistory"); highlightsResultsCheckBox.Checked = ConfigUtil.GetBoolParameter("SearchHighlightsResults"); switch (ConfigUtil.GetIntParameter("SearchReturn")) { case 0: searchReturnRadioButton1.Checked = true; searchReturnRadioButton2.Checked = false; break; case 1: searchReturnRadioButton1.Checked = false; searchReturnRadioButton2.Checked = true; break; } //Tab - Text wordWrapCheckBox.Checked = !ConfigUtil.GetBoolParameter("WordWrapDisabled"); fontLabel1.Text = StringUtil.CheckStringLengthEnd(ConfigUtil.GetStringParameter("FontInUse"), maxCharsFont); fontColorTextBox.BackColor = TextFontColor; backgroundColorTextBox.BackColor = TextBackgroundColor; urlsCheckBox.Checked = previousHighlightURL; useSpacesInsteadTabsCheckBox.Checked = ConfigUtil.GetBoolParameter("SpacesInsteadTabs"); keepInitialSpacesOnReturnCheckBox.Checked = ConfigUtil.GetBoolParameter("KeepInitialSpacesOnReturn"); keepBulletListOnReturnCheckBox.Checked = ConfigUtil.GetBoolParameter("KeepBulletListOnReturn"); //Tab - Language languageComboBox.EditValue = previousLanguage; sourceImageComboBoxEdit.EditValue = LanguageUtil.GetLongCultureForGoogleTranslator(ConfigUtil.GetStringParameter("Translation").Substring(0, 2)); destinationImageComboBoxEdit.EditValue = LanguageUtil.GetLongCultureForGoogleTranslator(ConfigUtil.GetStringParameter("Translation").Substring(3, 2)); useSelectedSettingsLanguageCheckBox.Checked = ConfigUtil.GetBoolParameter("TranslationUseSelect"); //Tab - Tab tabCloseButtonOnComboBox.SelectedIndex = ConfigUtil.GetIntParameter("TabCloseButtonMode"); tabPositionComboBox.SelectedIndex = ConfigUtil.GetIntParameter("TabPosition"); tabOrientationComboBox.SelectedIndex = ConfigUtil.GetIntParameter("TabOrientation"); tabMultilineCheckBox.Checked = ConfigUtil.GetBoolParameter("TabMultiline"); switch (ConfigUtil.GetIntParameter("TabsSwitchType")) { case 0: tabsSwitchModeKeyboardRadioButton.Checked = true; break; case 1: tabsSwitchModeMouseRadioButton.Checked = true; break; } //Tab - Note Mode noteModeTabsCheckBox.Checked = ConfigUtil.GetBoolParameter("NoteModeTabs"); noteModeSizeXNumericUpDown.Value = ConfigUtil.GetIntParameter("NoteModeSizeX"); noteModeSizeYNumericUpDown.Value = ConfigUtil.GetIntParameter("NoteModeSizeY"); //Tab - View stayOnTopCheckBox.Checked = !ConfigUtil.GetBoolParameter("StayOnTopDisabled"); if (form.WindowMode == Customs.CustomForm.WindowModeEnum.Fullscreen) { stayOnTopCheckBox.Enabled = false; } minimizeOnTrayIconCheckBox.Checked = !ConfigUtil.GetBoolParameter("MinimizeOnTrayIconDisabled"); splashScreenCheckBox.Checked = ConfigUtil.GetBoolParameter("ShowSplashScreen"); toolbarCheckBox.Checked = !ConfigUtil.GetBoolParameter("ToolbarInvisible"); statusBarCheckBox.Checked = !ConfigUtil.GetBoolParameter("StatusBarInvisible"); internalExplorerCheckBox.Checked = !ConfigUtil.GetBoolParameter("InternalExplorerInvisible"); lineNumbersCheckBox.Checked = ConfigUtil.GetBoolParameter("LineNumbersVisible"); hideLinesCheckBox.Checked = ConfigUtil.GetBoolParameter("CheckLineNumber"); hideLinesNumericUpDown.Value = ConfigUtil.GetIntParameter("CheckLineNumberMax"); hideLinesCheckBox.Enabled = lineNumbersCheckBox.Checked; hideLinesNumericUpDown.Enabled = hideLinesCheckBox.Checked && hideLinesCheckBox.Enabled; //Tab - Look & Feel renderModeComboBox.SelectedIndex = ConfigUtil.GetIntParameter("LookAndFeel"); //Tab - Internet enableProxySettingsCheckBox.Checked = ConfigUtil.GetBoolParameter("ProxyEnabled"); usernameTextBox.Text = (passwordList[0]).value; passwordTextBox.Text = CodingUtil.DecodeByte((passwordList[1]).value); domainTextBox.Text = (passwordList[2]).value; proxyHostTextBox.Text = ConfigUtil.GetStringParameter("ProxyHost"); proxyPortNumericUpDown.Value = ConfigUtil.GetIntParameter("ProxyPort"); defaultBrowserRadioButton.Checked = ConfigUtil.GetBoolParameter("UseDefaultBrowser"); customBrowserRadioButton.Checked = !ConfigUtil.GetBoolParameter("UseDefaultBrowser"); customBrowserTextBox.Text = ConfigUtil.GetStringParameter("CustomBrowserCommand"); //Tab - Updates switch (periodicVersionCheck) { case 0: enableAutomaticUpdateCheckBox.Checked = false; frequencyAutomaticUpdateComboBox.Enabled = false; break; case 1: case 2: enableAutomaticUpdateCheckBox.Checked = true; frequencyAutomaticUpdateComboBox.Enabled = true; frequencyAutomaticUpdateComboBox.SelectedIndex = periodicVersionCheck - 1; break; } lastCheckLabel.Text += " " + ConfigUtil.GetDateParameter("LastVersionCheck").ToString(LanguageUtil.GetShortDateTimeFormat()); //Tab - Dropbox dropboxRememberCheckBox.Checked = ConfigUtil.GetBoolParameter("RememberDropboxAccess"); dropboxDeleteCheckBox.Checked = ConfigUtil.GetBoolParameter("EnableDropboxDelete"); //Tab - Integration sendToCheckBox.Checked = previousSendTo; openWithCheckBox.Checked = previousOpenWith; jumpListCheckBox.Checked = previousJumpListActivated; }
private static void OnVerify(object state) { mDetectionTimer.Change(-1, -1); try { using (var connection = JobStorage.Current.GetConnection()) using (var lockStorage = connection.AcquireDistributedLock("JobAgentServer", TimeSpan.FromSeconds(30)))//防止多个server端竞争 { //拿到有上报的jobId集合 var jobIdList = connection.GetAllItemsFromSet(keyPrefix); if (!jobIdList.Any()) { return; } foreach (var jobId in jobIdList) { JobData jobData = connection.GetJobData(jobId); //拿到真正的运行结果 var hashKey = keyPrefix + jobId; var result = connection.GetAllEntriesFromHash(hashKey); using (var tran = connection.CreateWriteTransaction()) { //job已经不存在了 就直接删除set if (jobData == null) { tran.RemoveFromSet(keyPrefix, jobId); tran.Commit(); continue; } double totalMilliseconds = (DateTime.UtcNow - jobData.CreatedAt).TotalMilliseconds; long latency = (long)totalMilliseconds; //如果job存在 但是没有拿到hash数据 认为成功 if (result == null || !result.Any()) { tran.SetJobState(jobId, new SucceededState(jobId, latency, latency)); tran.RemoveFromSet(keyPrefix, jobId); tran.RemoveHash(hashKey); tran.Commit(); continue; } var resultOfAgent = result.First(); JobAgentResult resultData = CodingUtil.FromJson <JobAgentResult>(resultOfAgent.Value); //异常数据 认为成功 if (resultData == null) { tran.SetJobState(jobId, new SucceededState(jobId, latency, latency)); tran.RemoveFromSet(keyPrefix, jobId); tran.RemoveHash(hashKey); tran.Commit(); continue; } //jobagent实际上运行的时长 long.TryParse(resultOfAgent.Key, out var realTotalMilliseconds); if (realTotalMilliseconds < 1) { realTotalMilliseconds = latency; } var isSuccess = resultData.R == "ok"; tran.RemoveFromSet(keyPrefix, jobId); tran.RemoveHash(hashKey); // latency 代表的是 从开始调度 到 实际结束 总共的时长 // realTotalMilliseconds 代表的是 jobagent开始执行 到 实际结束的 总共的时长 if (isSuccess) { var currentState = connection.GetStateData(jobId); if (currentState != null && !string.IsNullOrEmpty(currentState.Name) && currentState.Name.Equals("Failed")) { tran.AddJobState(jobId, new SucceededState(null, latency, realTotalMilliseconds)); } else { new BackgroundJobClient().ChangeState(jobId, new SucceededState(null, latency, realTotalMilliseconds)); } } else { var jobItem = jobData.Job.Args.FirstOrDefault() as HttpJobItem; var ex = new AgentJobException(jobItem.AgentClass, resultData.E); new BackgroundJobClient().ChangeState(jobId, new FailedState(ex)); HttpJob.SendFail(jobId, jobItem, "AgentJobFail", ex); } //如果是stop上报过来的时候 记录这个job最后的执行id if (!string.IsNullOrEmpty(resultData.Action) && resultData.Action.Equals("stop") && !string.IsNullOrEmpty(resultData.RunId)) { var jobItem = jobData.Job.Args.FirstOrDefault() as HttpJobItem; var jobKeyName = $"recurring-job:{(!string.IsNullOrEmpty(jobItem.RecurringJobIdentifier) ? jobItem.RecurringJobIdentifier : jobItem.JobName)}"; tran.SetRangeInHash(jobKeyName, new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("LastJobId", resultData.RunId) }); } //出错的话 需要走通用的出错流程 tran.Commit(); } } } } catch (Exception e) { Logger.ErrorException("agent reporter fail", e); } finally { mDetectionTimer.Change(1000 * 2, 1000 * 2); } }
internal static bool InstallProcedure(Form1 form, ProgressBar installProgressBar, TextBox installTextBox, String culture) { try { String destinationPath = form.destinationPathTextBox.Text; bool onlySetPermissions = false; if (Directory.Exists(destinationPath)) { DirectoryInfo destinationDir = new DirectoryInfo(destinationPath); FileInfo[] destinationFiles = destinationDir.GetFiles(); if (destinationFiles.Length > 0) { bool alreadyExistsDtPad = SearchDtPadFiles(destinationFiles); String warningMessage = alreadyExistsDtPad ? "DestinationDirWithDtPad" : "DestinationDirWithFiles"; if (WindowManager.ShowWarningBox(form, LanguageUtil.GetCurrentLanguageString(warningMessage, className, culture), culture) != DialogResult.Yes) { installTextBox.Text = LanguageUtil.GetCurrentLanguageString("InstallInterrupted", className, culture); return(false); } if (alreadyExistsDtPad) { onlySetPermissions = true; } } } installProgressBar.Value = 0; installTextBox.Text = LanguageUtil.GetCurrentLanguageString("PreparingInstall", className, culture); form.Refresh(); //Directories installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("CreatingDir", className, culture); CreateDirAndSetPermissions(destinationPath); CreateDirAndSetPermissions(Path.Combine(destinationPath, "Guides")); CreateDirAndSetPermissions(Path.Combine(destinationPath, "Icons")); CreateDirAndSetPermissions(Path.Combine(destinationPath, "Icons\\JL")); CreateDirAndSetPermissions(Path.Combine(destinationPath, "Languages")); CreateDirAndSetPermissions(Path.Combine(destinationPath, "Logs")); CreateDirAndSetPermissions(Path.Combine(destinationPath, "SupportFiles")); CreateDirAndSetPermissions(Path.Combine(destinationPath, "InternetCache")); installProgressBar.PerformStep(); //Executables and libraries installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("ExtractingFile", className, culture); form.Refresh(); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DtPad.exe"), FileResource.DtPad_exe); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DtPadUpdater.exe"), FileResource.DtPadUpdater_exe); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DtHelp.exe"), FileResource.DtHelp_exe); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DtPadUninstaller.exe"), FileResource.DtPadUninstaller_exe); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DevExpress.Data.v12.1.dll"), FileResource.DevExpress_Data_v12_1_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DevExpress.Utils.v12.1.dll"), FileResource.DevExpress_Utils_v12_1_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DevExpress.XtraEditors.v12.1.dll"), FileResource.DevExpress_XtraEditors_v12_1_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "log4net.dll"), FileResource.log4net_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "ICSharpCode.SharpZipLib.dll"), FileResource.ICSharpCode_SharpZipLib_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DtControls.dll"), FileResource.DtControls_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "itextsharp.dll"), FileResource.itextsharp_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Be.Windows.Forms.HexBox.dll"), FileResource.Be_Windows_Forms_HexBox_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "XmlGridControl.dll"), FileResource.XmlGridControl_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "MonthCalendar.dll"), FileResource.MonthCalendar_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "AppLimit.CloudComputing.SharpBox.dll"), FileResource.AppLimit_CloudComputing_SharpBox_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Newtonsoft.Json.dll"), FileResource.Newtonsoft_Json_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Microsoft.WindowsAPICodePack.dll"), FileResource.Microsoft_WindowsAPICodePack_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Microsoft.WindowsAPICodePack.Shell.dll"), FileResource.Microsoft_WindowsAPICodePack_Shell_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Hunspellx86.dll"), FileResource.Hunspellx86_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Hunspellx64.dll"), FileResource.Hunspellx64_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "NHunspell.dll"), FileResource.NHunspell_dll); WriteFileAndSetPermissions(Path.Combine(destinationPath, "LumenWorks.Framework.IO.dll"), FileResource.LumenWorks_Framework_IO_dll); installProgressBar.PerformStep(); //Support files WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.fv"), FileResource.DtPad_exe_fv, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.ex"), FileResource.DtPad_exe_ex, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.no"), FileResource.DtPad_exe_no, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.rf"), FileResource.DtPad_exe_rf, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.rs"), FileResource.DtPad_exe_rs, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.rp"), FileResource.DtPad_exe_rp, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.sh"), FileResource.DtPad_exe_sh, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.to"), FileResource.DtPad_exe_to, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.tm"), FileResource.DtPad_exe_tm, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.cl"), FileResource.DtPad_exe_cl, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.sf"), FileResource.DtPad_exe_sf, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.ru"), FileResource.DtPad_exe_ru, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "SupportFiles\\DtPad.exe.pw"), FileResource.DtPad_exe_pw, onlySetPermissions); installProgressBar.PerformStep(); //Language files WriteFileAndSetPermissions(Path.Combine(destinationPath, "Languages\\en.resources"), FileResource.en_resources); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Languages\\it.resources"), FileResource.it_resources); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Languages\\fr.resources"), FileResource.fr_resources); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Languages\\es.resources"), FileResource.es_resources); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Languages\\ru.resources"), FileResource.ru_resources); installProgressBar.PerformStep(); //Guides //WriteFileAndSetPermissions(Path.Combine(destinationPath, "Guides\\DtPadGuide-en.dhg"), GuideResource.DtPadGuide_en_dhg); //WriteFileAndSetPermissions(Path.Combine(destinationPath, "Guides\\DtPadGuide-it.dhg"), GuideResource.DtPadGuide_it_dhg); installProgressBar.PerformStep(); //Icons and txts WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\DtPad.ico"), FileResource.DtPad_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\DtPadUpdater.ico"), FileResource.DtPadUpdater_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\DtHelp.ico"), FileResource.DtHelp_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\DtPadUninstaller.ico"), FileResource.DtPadUninstaller_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\Dt.ico"), FileResource.Dt_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\JL\\WebSite.ico"), FileResource.WebSite_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\JL\\NewTab.ico"), FileResource.NewTab_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\JL\\OpenFile.ico"), FileResource.OpenFile_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\JL\\OpenSession.ico"), FileResource.OpenSession_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\JL\\SearchInFiles.ico"), FileResource.SearchInFiles_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "Icons\\JL\\CheckNewVersion.ico"), FileResource.CheckNewVersion_ico); WriteFileAndSetPermissions(Path.Combine(destinationPath, "DtPad.exe.Config"), FileResource.DtPad_exe_config, onlySetPermissions); WriteFileAndSetPermissions(Path.Combine(destinationPath, "InternetCache\\Info.txt"), FileResource.Info_txt); WriteFileAndSetPermissions(Path.Combine(destinationPath, "License.txt"), FileResource.License_txt); installProgressBar.PerformStep(); //Shortcuts if (form.shortcutsCheckBox.Checked) { installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("CreatingShortcut", className, culture); form.Refresh(); SetShortcuts(destinationPath, culture); } installProgressBar.PerformStep(); //Associations if (form.sendToCheckBox.Checked) { installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("CreatingAssociation", className, culture); form.Refresh(); SetSendToAssociation(destinationPath, culture); } if (form.shellCheckBox.Checked) { installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("IntegratingShell", className, culture); form.Refresh(); if (!SetShellIntegration(destinationPath, culture)) { installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("IntegratingShellError", className, culture); } } installProgressBar.PerformStep(); //Settings (part 1) installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("UpdatingSetting", className, culture); form.Refresh(); ConfigUtil.UpdateParameter("ProxyEnabled", form.enableProxySettingsCheckBox.Checked.ToString(), destinationPath); ConfigUtil.UpdateParameter("StayOnTopDisabled", (!form.stayOnTopCheckBox.Checked).ToString(), destinationPath); ConfigUtil.UpdateParameter("MinimizeOnTrayIconDisabled", (!form.minimizeOnTrayIconCheckBox.Checked).ToString(), destinationPath); String[] passwordNames = { "ProxyUsername", "ProxyPassword", "ProxyDomain" }; String[] passwordValues = { form.usernameTextBox.Text, CodingUtil.EncodeString(form.passwordTextBox.Text), form.domainTextBox.Text }; PasswordUtil.UpdateParameters(passwordNames, passwordValues, destinationPath); installProgressBar.PerformStep(); //Settings (part 2) if (form.dotNetRadioButton.Checked) { ConfigUtil.UpdateParameter("LookAndFeel", "0", destinationPath); } else if (form.windowsRadioButton.Checked) { ConfigUtil.UpdateParameter("LookAndFeel", "1", destinationPath); } ConfigUtil.UpdateParameter("Language", LanguageUtil.GetLongCulture(form.languageComboBox), destinationPath); installProgressBar.PerformStep(); installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("InstallComplete", className, culture); installTextBox.Text += Environment.NewLine + Environment.NewLine + LanguageUtil.GetCurrentLanguageString("EndInfo", className, culture); return(true); } catch (Exception exception) { installProgressBar.Value = 0; installTextBox.Text += Environment.NewLine + LanguageUtil.GetCurrentLanguageString("Error1", className, culture) + Environment.NewLine + Environment.NewLine + LanguageUtil.GetCurrentLanguageString("Error2", className, culture); installTextBox.Text += Environment.NewLine + Environment.NewLine + LanguageUtil.GetCurrentLanguageString("Exception", className, culture) + " " + exception.Message; return(false); } }