Пример #1
0
        /// <summary>
        /// Parses the given CPL into an AST.
        /// </summary>
        /// <param name="p_strCplCode">The CPL to convert.</param>
        /// <returns>The AST built from the given CPL.</returns>
        private ITree GenerateAst(string p_strCplCode)
        {
            ErrorTracker    ertErrors = new ErrorTracker();
            AntlrParserBase cpbParser = ParserFactory.CreateParser(p_strCplCode, ertErrors);
            ITree           astCPL    = cpbParser.Parse();

            if (ertErrors.HasErrors)
            {
                throw new ArgumentException("Invalid CPL:" + Environment.NewLine + ertErrors.ToString(), "p_strCplCode");
            }
            return(astCPL);
        }
Пример #2
0
        private void CreateSettingUpdater_FormClosing(object sender, FormClosingEventArgs e)
        {
            if ((e.CloseReason != CloseReason.UserClosing & e.CloseReason != CloseReason.None) ||
                this.DialogResult != DialogResult.OK)
            {
                return;
            }

            if (errorTracker.Count != 0)
            {
                Dialogs.ErrorF(this, errorTracker.ToString());
                e.Cancel = true;

                if (editLink != null)
                {
                    ItemsInSets.Add(editLink);
                }
                return;
            }

            DbTypeItem dbItem = (DbTypeItem)cmbDbConectionType.SelectedItem;

            int?taskId = null;
            int tid;

            if (int.TryParse(tbNumberTask.Text, out tid))
            {
                taskId = tid;
            }

            // формируем настройку для получения настроек
            TfsDbLink newLink = editLink ?? new TfsDbLink();

            newLink.Name                 = tbSettingName.Text;
            newLink.ServerUri            = new Uri(tbTfsProject.Text);
            newLink.ServerPathToSettings = tbSetFileServerFolder.Text + "/" + tbFileNameSet.Text;


            // Собираем и пакуем настройки накатки
            var newSet = new UpdateDbSetting();

            newSet.ServerPathScripts                 = tbFolderForScripts.Text;
            newSet.TypeConnectionFullName            = dbItem.ConType.ToString();
            newSet.AssemplyWithImplementDbConnection = dbItem.AssembyRawBytes;
            newSet.ConnectionStringModelDb           = tbConnectionString.Text;
            newSet.ScriptPartBeforeBodyWithTran      = tbPartBeforescript.Text.GetNullIfIsNullOrWhiteSpace();
            newSet.ScriptPartAfterBodyWithTran       = tbPartAfterScript.Text.GetNullIfIsNullOrWhiteSpace();
            newSet.ScriptUpdateVer = tbScriptUpdateVer.Text.GetNullIfIsNullOrWhiteSpace();
            newSet.FormatBinary    = new FormatBinaryData()
            {
                Prefix     = tbFormatBinPrefix.Text,
                FormatByte = tbFormatBinFormat.Text
            };

            var encodedSetting = newSet.SerializeAesEncrypt(newLink.ServerPathToSettings);

            string fileNameSet = tbFileNameSet.Text;

            try
            {
                using (var tfsbl = new TFSRoutineBL())
                {
                    var localFileSetPath = Path.Combine(tfsbl.Tempdir, fileNameSet);

                    tfsbl.VersionControl(new Uri(tbTfsProject.Text));
                    tfsbl.MapTempWorkspace(tbSetFileServerFolder.Text);

                    tfsbl.GetLastFile(fileNameSet);

                    var fileExist = File.Exists(localFileSetPath);

                    if (fileExist && !tfsbl.CheckOut(localFileSetPath))
                    {
                        throw new Exception("Извлечение настроек неуспешно. Повторите позже");
                    }

                    // блокируем от изменений
                    if (fileExist && !tfsbl.LockFile(fileNameSet))
                    {
                        throw new Exception("Производится сохранение настроек другим пользователем.");
                    }

                    // если есть - удаляем
                    if (fileExist)
                    {
                        File.Delete(localFileSetPath);
                    }

                    // записываем новый
                    File.WriteAllBytes(localFileSetPath, encodedSetting);

                    if (!fileExist)
                    {
                        tfsbl.AddFile(localFileSetPath);
                    }

                    List <int> linkedTask = new List <int>();
                    if (taskId.HasValue)
                    {
                        linkedTask.Add(taskId.Value);
                    }
                    tfsbl.CheckIn("Добавленение настроек версионности", linkedTask);
                }

                if (editLink == null)
                {
                    this.ItemsInSets.Add(newLink);
                }
            }
            catch (Exception ex)
            {
                String msg = ex.Expand();
                if (ex.GetType().Name == "TargetInvocationException" && ex.InnerException != null)
                {
                    msg = ex.InnerException.Message;
                }
                Dialogs.ErrorF(this, "Сохранение неуспешно" + Environment.NewLine + msg);
                e.Cancel = true;
            }
        }