Beispiel #1
0
        void m_Timer_Tick(object sender, EventArgs e)
        {
            if (StepCount == 0)
            {
                m_CanDown = false;
            }
            if (m_CanDown)
            {
                return;
            }


            Pos pos = Think();

            if (pos == m_InvalidPos)
            {
                return;
            }

            if (NextOne(pos.Row, pos.Col))
            {
                m_WaitWindow.Hide();
                m_CanDown = true;
            }
        }
Beispiel #2
0
		public static void LongOperation(this Control source, Action action)
		{
//			var progress = new ProgressWindow {LongAction = action};
//			return progress.ShowDialog(source) == DialogResult.OK;

			var wait = new WaitWindow();
			source.Enabled = false;
			try
			{
				source.UseWaitCursor = true;
				wait.Show(source);
				Application.DoEvents();
				action();
				Application.DoEvents();
			}
			finally
			{
				wait.Hide();
				source.UseWaitCursor = false;
				source.Enabled = true;
			}
		}
Beispiel #3
0
		private void menuItemReportExport_Click(object sender, EventArgs e)
		{
			
#if DEBUG && USE_TDISK
			var basePath = Path.Combine(@"T:\", Scenario.LastReportId.ToString());
#else
			var basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), Scenario.LastReportId.ToString());
#endif
			var reportFile = new FileInfo(basePath + ".doc");
			//var calcFile = new FileInfo(basePath + ".c.html");
			//var sourceDataFile = new FileInfo(basePath + ".s.html");

			if (!reportFile.Exists)
			{
				MessageBox.Show(this, "Для того, чтобы выгрузить отчет, последний должен быть сперва сгенерирован", "Модуль выгрузки данных", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1);
				return;
			}

			var fullPath = "";
			var ww = new WaitWindow();

			try
			{
				ww.Show(this);
				Func<IBranch, ScenarioNodeType> nodeType = b => b.GetValue("nodeType") == null
				                                                	? ScenarioNodeType.Default
				                                                	:
				                                                		(ScenarioNodeType) Enum.Parse(typeof (ScenarioNodeType), b.GetValue("nodeType").ContentString);
				var all = Scenario.Vault.GetBranchesRecursive().ToDictionary(b => b, nodeType);
				var forExport = all.Where(kvp => kvp.Value == ScenarioNodeType.ForExport).FirstOrDefault();

				Application.DoEvents();

				using (var repo = RepositoryEditor.Repository())
				{
					var now = DateTime.Now;
					var name = String.Format("{0:00}.{1:00}.{2:0000} {3:00}{4:00}{5:00}", now.Day, now.Month, now.Year, now.Hour, now.Minute, now.Second);
					var root = repo.GetOrCreateBranch("Для выгрузки");
					var receiver = root.GetOrCreateBranch(name);
					fullPath = receiver.VPath.Path;

					if (!TryCreateFileStreamForTempCopy(reportFile, x => receiver.CreateValue("Отчет.doc", x).SetTypeToken2("binary"))) return;

					if (forExport.Key != null)
					{
						var node = new ScenarioNode(forExport.Key);

						//#warning Review this: eval sessions now lock the vault for reading

#if VAULT_EVAL_1
                    using (_evalSession1 = new Esath.Eval.Ver1.EvalSession(Scenario.Vault, repo))
                    {
#endif

#if VAULT_EVAL_2
						using (_evalSession2 = new Esath.Eval.Ver2.EvalSession(Scenario.Vault, repo, null))
						{
#endif

#if VAULT_EVAL_3
                    using (_evalSession3 = new Esath.Eval.Ver3.EvalSession(Scenario.VaultCompiler, repo))
                    {
#endif

							var source = Regex.Replace(node.Template, StartUp.VFIELD_PATTERN, vpathEvaluator, RegexOptions.Compiled);
							source = "<html><head></head><body>" + source + "</body></html>";
							receiver.CreateValue("Расчетные Данные.html", new TempHtmlFile(source).Content).SetTypeToken2("binary");
						}
					}

					var buf = new StringBuilder(32*1024);
					buf.Append("<html><head></head><body>");
					buf.Append("<table border=1>");
					buf.Append("<tr><th>Имя</th><th>Значение</th><th>Ед Изм</th><th>Тип</th></tr>");
					foreach (var sourceValueDeclaration in Scenario.AllSourceValueDeclarations)
					{
						buf.AppendFormat("<tr><td>{0}</td><td>{1}</td><td>{2}</td><td>{3}</td></tr>",
						                 sourceValueDeclaration.Name,
						                 sourceValueDeclaration.Value,
						                 sourceValueDeclaration.MeasurementUnit == "" ? "&nbsp;" : sourceValueDeclaration.MeasurementUnit,
						                 sourceValueDeclaration.HumanType
							);
					}
					buf.Append("</table>");
					buf.Append("</body></html>");
					receiver.CreateValue("Исходные Данные.html", new TempHtmlFile(buf.ToString()).Content).SetTypeToken2("binary");

					repo.Save();
				}
			}
			finally
			{
				ww.Hide();
				ww = null;
				Application.DoEvents();
			}
			MessageBox.Show(this, string.Format("Данные текущего отчета успешно выгружены в ветвь Репозитория '{0}'", fullPath), "Модуль выгрузки данных", MessageBoxButtons.OK, MessageBoxIcon.Information);
		}