Ejemplo n.º 1
0
 public virtual void Transition(BaseScreen transitionTo, ChangeType changeType)
 {
     Transitioning = true;
     TransitionTo = transitionTo;
     ChangeType = changeType;
     transitionTimer = TimeSpan.Zero;
 }
Ejemplo n.º 2
0
 void OnAppliedChange(ChangeType type, string newPath, string oldPath = null)
 {
     if (AppliedChange != null)
     {
         AppliedChange(this, new MyAppliedChangeEventArgs(type, newPath, oldPath));
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// This constructor is used when triggering a provider change
 /// </summary>
 /// <param name="providerId">Provider Id</param>
 /// <param name="aigSubscriberId">Subscriber Id</param>
 /// <param name="changeType">Change Type</param>
 /// <param name="isAttributeUpdate">Attribute update</param>
 /// <param name="isRateUpdate">Rate update</param>
 /// <param name="isFullUpdate">Full update</param>
 private ProviderChangeMessage(Guid providerId, Guid aigSubscriberId, ChangeType changeType, bool isAttributeUpdate, bool isRateUpdate, bool isFullUpdate)
     : base(providerId, aigSubscriberId, changeType)
 {
     IsAttributeUpdate = isAttributeUpdate;
     IsRateUpdate = isRateUpdate;
     IsFullUpdate = isFullUpdate;
 }
Ejemplo n.º 4
0
 public TableChanges(Table oldTable, Table newTable, ChangeType changeType)
 {
     this.OldTable = oldTable;
     this.NewTable = newTable;
     this.ChangeType = changeType;
     this.ColumnsChanged = new List<ColumnChanges>();
 }
Ejemplo n.º 5
0
		/// <summary>
		/// Initializes a new instance.
		/// </summary>
		internal ChangeEntry(ChangeType changeType, IUberMap map, object entity)
		{
			UberMap = map;
			ChangeType = changeType;
			Entity = entity;
			MetaEntity = MetaEntity.Locate(entity);
		}
 public PythonTypeChangedEventArgs(CodeContext context, SymbolId changed, ChangeType type, object previous, object newValue) {
     _context = context;
     _changed = changed;
     _type = type;
     _previous = previous;
     _newValue = newValue;
 }
Ejemplo n.º 7
0
 public virtual void Transition(ChangeType change, BaseGameState gameState)
 {
     Transitioning = true;
     changeType = change;
     TransitionTo = gameState;
     transitionTimer = TimeSpan.Zero;
 }
Ejemplo n.º 8
0
 public ChangeAction(ChangeType changeType, TranscriptionElement changedElement, TranscriptionIndex changeIndex, int changeAbsoluteIndex)
 {
     _changeType = changeType;
     _changedElement = changedElement;
     _changeTranscriptionIndex = changeIndex;
     _changeAbsoluteIndex = changeAbsoluteIndex;
 }
Ejemplo n.º 9
0
		private void AssertChange(string name, ChangeType change)
		{
			RootDetail r1 = ExtractAttribute(Subjects.One, name);
			RootDetail r2 = ExtractAttribute(Subjects.Two, name);

			Assert.AreEqual(change, r1.PerformCompare(r2));
		}
Ejemplo n.º 10
0
 public DiffPiece(string text, ChangeType type, int? position)
 {
     Text = text;
     Position = position;
     Type = type;
     SubPieces = new List<DiffPiece>();
 }
Ejemplo n.º 11
0
 public ChangeEvent(ChangeType type, UniqueId beforeId, UniqueId afterId, Instant versionInstant)
 {
     _type = type;
     _beforeId = beforeId;
     _afterId = afterId;
     _versionInstant = versionInstant;
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HistoryItem" /> class.
 /// </summary>
 /// <param name="strUser">User that performed the action</param>
 /// <param name="type">Type of action performed</param>
 /// <param name="strAdditional">Additional information about the action performed</param>
 /// <param name="dtTime">The time that the action occurred</param>
 public HistoryItem(string strUser, ChangeType type, string strAdditional, DateTime dtTime)
 {
     this.user = strUser;
     this.type = type;
     this.otherInfo = strAdditional;
     this.time = dtTime;
 }
Ejemplo n.º 13
0
 public HistoryItem(StreamReader sr)
 {
     this.user = sr.ReadLine();
     this.type = (ChangeType)Convert.ToInt32(sr.ReadLine());
     this.otherInfo = sr.ReadLine();
     this.time = new DateTime(Convert.ToInt64(sr.ReadLine()));
 }
Ejemplo n.º 14
0
 public static bool IsInOriginalDocument(ChangeType t)
 {
     switch (t)
     {
         case ChangeType.None:
         case ChangeType.Deletion:
         case ChangeType.MoveSource:
         case ChangeType.FormatChange:
         case ChangeType.Match:
         case ChangeType.ChangedText:
         case ChangeType.StyleChangeText:
             return true;
         case ChangeType.MoveDestination:
         case ChangeType.Insertion:
         case ChangeType.MovedDeletion:
         case ChangeType.CellInserted:
         case ChangeType.CellDeleted:
         case ChangeType.CellMerged:
         case ChangeType.CellIsPadding:
         case ChangeType.ChangeNumber:
         case ChangeType.Delimiter:
         case ChangeType.StyleChangedLabel:
         case ChangeType.Comment:
         case ChangeType.InsertedComment:
         case ChangeType.DeletedComment:
         case ChangeType.ChangedComment:
         default:
             return false;
     }
 }
Ejemplo n.º 15
0
 public static void HasChangeType(ChangeType type, params SyncAction[] objects)
 {
     foreach (var obj in objects)
     {
         Assert.Equal(type, obj.Type);
     }
 }
Ejemplo n.º 16
0
 public WpfLayerInfo( int priority, Action<DrawingContext> draw, DrawingVisual visual, ChangeType notifyOnChange )
 {
     NotifyOnChange = notifyOnChange;
     Priority = priority;
     Visual = visual;
     Draw = draw;
 }
Ejemplo n.º 17
0
 internal FileChange(string directory, string path, ChangeType type)
 {
     Debug.Assert(path != null);
     _directory = directory;
     _path = path;
     _chageType = type;
 }
Ejemplo n.º 18
0
 public Change(string resultRow)
 {
     string[] separated = resultRow.Split(' ');
     ChangeType = GetFromString(separated[0]);
     FullPath = separated[1];
     Name = Path.GetFileName(separated[1]);
 }
Ejemplo n.º 19
0
        protected virtual ExitCode ChangeSetting(IClientSettings clientSettings, SettingsLocation location, ChangeType changeType)
        {
            // Don't want to save defaults for options that apply directly to this command
            List<string> settingsToSkip = new List<string>();
            settingsToSkip.AddRange(StandardOptions.List);
            settingsToSkip.AddRange(StandardOptions.Add);
            settingsToSkip.AddRange(StandardOptions.Remove);

            foreach (var setting in this.Arguments.Options)
            {
                if (settingsToSkip.Contains(setting.Key, StringComparer.OrdinalIgnoreCase)) { continue; }
                bool success = false;
                switch (changeType)
                {
                    case ChangeType.Add:
                        this.Loggers[LoggerType.Status].Write(XTaskStrings.DefaultsSavingProgress, setting.Key);
                        success = clientSettings.SaveSetting(location, setting.Key, setting.Value);
                        break;
                    case ChangeType.Remove:
                        this.Loggers[LoggerType.Status].Write(XTaskStrings.DefaultsRemovingProgress, setting.Key);
                        success = clientSettings.RemoveSetting(location, setting.Key);
                        break;
                }

                this.Loggers[LoggerType.Status].WriteLine(success ? XTaskStrings.Succeeded : XTaskStrings.Failed);
            }

            return ExitCode.Success;
        }
Ejemplo n.º 20
0
 public virtual void Transition(ChangeType change, BaseGameState gameState = null)
 {
     ControlManager.AcceptInput = false;
     Transitioning = true;
     ChangeType = change;
     TransitionTo = gameState;
     TransitionTimer = TimeSpan.Zero;
 }
Ejemplo n.º 21
0
 protected void OnYardChanged(Lot lot, ChangeType type)
 {
     if (YardChanged != null)
     {
         YardChangedEventArgs args = new YardChangedEventArgs(lot, type);
         YardChanged(this, args);
     }
 }
Ejemplo n.º 22
0
        public void ConvertMapsToChangeTypeForKnonwStates(FileState fileState, ChangeType expected)
        {
            // Act
            ChangeType actual = HgRepository.Convert(fileState);

            // Assert
            Assert.Equal(expected, actual);
        }
Ejemplo n.º 23
0
 public Line(DiffPiece a, DiffPiece b, ChangeType type, int position)
 {
     AText = a.Text;
     BText = b.Text;
     Position = position + 1;
     Type = type;
     this.BackGroundColor = type == ChangeType.Modified ? "#D3D3D3" : "#fff";
 }
Ejemplo n.º 24
0
 private AggregationChange(ChangeType type, Entity entity, ICollection<PropertyAggregatorUpdate> updates, PropertyMetadata property = null, decimal newValue = default(decimal))
 {
     Type = type;
     Entity = entity;
     Updates = updates;
     Property = property;
     NewValue = newValue;
 }
 private void ProcessEvent(FileSystemEventArgs e, ChangeType changeType)
 {
     this.eventCallback(new FileEvent
     {
         changeType = (int)changeType,
         path = e.FullPath
     });
 }
Ejemplo n.º 26
0
        public HistoryChange(string historyName, ChangeType type)
        {
            if(String.IsNullOrWhiteSpace(historyName))
                throw new ArgumentNullException(historyName);

            HistoryName = historyName;
            Type = type;
        }
Ejemplo n.º 27
0
		protected override void ProcessChildChange(Type childType, ChangeType change)
		{
			base.ProcessChildChange(childType, change);

			if (_changeAllChildren != ChangeType.None)
			{
				_changeAllChildren = ChangeType.MembersChangedNonBreaking;
			}
		}
Ejemplo n.º 28
0
        public void TrackFailureLoadingChange(long changesetId, ChangeType changeType, string serverPath, string reason)
        {
            if (changesetId != _lastChangesetWithChangeError)
                WriteIntroForChangeset(changesetId);

            _sb.AppendLine("    " + reason + " for " + changeType + " of " + serverPath);

            _lastChangesetWithChangeError = changesetId;
        }
Ejemplo n.º 29
0
        private void WatcherChangeHandler(ChangeType type, string path)
        {
            var change = new Change(type, path);
            _rawHandler(change);

            if (!_patterns.Contains(Path.GetExtension(path)))
                return;
            _buffer.Push(change);
        }
Ejemplo n.º 30
0
		private void AssertChange(string from, string name, ChangeType change, DiffConfig config)
		{
			MemberDetail r1 = ExtractOperator(Subjects.One, from, name, config);
			MemberDetail r2 = ExtractOperator(Subjects.Two, from, name, config);

			Align(r1, r2);

			Assert.AreEqual(change, r2.PerformCompare(r1));
		}
Ejemplo n.º 31
0
 /// <summary>
 /// Creates and returns an instance of the LayerCollection.EventArgs class.
 /// </summary>
 /// <param name="changeType">Type of change that caused the event</param>
 /// <param name="objs">Collection of objects involved in the event</param>
 /// <returns>CollectionEx.EventArgs derived object</returns>
 protected override CollectionEx.EventArgs MakeEventArgs(ChangeType changeType, ICollection objs)
 {
     return(new LayerCollection.EventArgs(changeType, objs));
 }
Ejemplo n.º 32
0
        public void Confirm(string identifier, int itemId, int unitId, int manufacturerId, int accountId, decimal unitCost, decimal margin, decimal sellingPrice, int userId, ChangeType changeType)
        {
            TempLedger ledger = LedgerService.GetTempLedger(itemId, unitId, manufacturerId, accountId);

            if (ValidationService.ValidateLedger(ledger, unitCost, margin, sellingPrice))
            {
                JournalEntry = new HCMIS.Concrete.Models.JournalLite()
                {
                    Identifier   = identifier,
                    Description  = changeType.Description,
                    Margin       = margin,
                    UnitCost     = unitCost,
                    SellingPrice = sellingPrice,
                    UserID       = userId,
                    Ledger       = ledger
                };
                repository.JournalLites.Insert(JournalEntry);
                LedgerService.PostToLedger(ledger);
            }
        }
Ejemplo n.º 33
0
        /// @brief Inform user if there inconsistency in class name declared.
        /// If the class name isn't the same that in class declaration in code, show the user a message,
        /// and show the problem in code text box or class name text box.
        /// @version V15.03.26 - Added.
        private bool IsConsistent()
        {
            int start = 0, len = 0;

            //Test if there is inconsistency in class name product of the change in this control...
            if (DetectDiffClassName(instanceName.Text, codeEditorView.Text, ref start, ref len))
            {
                //...there is inconsistency
                string Problem = "";
                if ((instanceName.TextLength != 0) && (codeEditorView.TextLength != 0))
                {
                    switch (LastChange)
                    {
                    case ChangeType.none:
                        Problem = "Lasting problem: " + LastProblem;
                        break;

                    case ChangeType.code:
                        Problem     = "Class name not found in changed code class definition.";
                        LastProblem = Problem;
                        break;

                    case ChangeType.name:
                        Problem = "Class Name changed but not found in code class definition:\n" +
                                  "    \"class <name> : PluginBase\".";
                        LastProblem = Problem;
                        break;
                    }
                    MessageBox.Show(
                        "Problem detected: class name \"" + instanceName.Text +
                        "\" inconsistent with code.\n" + Problem,
                        "Plugin Editor - Validation.",
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Warning);

                    if ((LastChange == ChangeType.name) || (LastChange == ChangeType.code))
                    {
                        bool Selected = false;      //for detect if the pattern of class declaration was encountered
                        if (len != 0)
                        {
                            codeEditorView.SelectionStart  = start;
                            codeEditorView.SelectionLength = len;
                            Selected = true;        //signal that it was encountered
                        }
                        if (LastChange == ChangeType.name)
                        {
                            instanceName.SelectAll();
                            instanceName.Focus();
                        }
                        else
                        {
                            if (!Selected)                  //if not detected the pattern of class declararion
                            {
                                codeEditorView.SelectAll(); //select all
                            }
                            codeEditorView.Focus();
                        }
                    }
                }
                return(false);   //not consistent
            }
            else
            {
                LastChange = ChangeType.none;
                return(true);    //the class name definition is consistent
            }
        }
Ejemplo n.º 34
0
 public Change(ChangeType changeType, StorageAddress storageAddress, byte[] value)
 {
     StorageAddress = storageAddress;
     Value          = value;
     ChangeType     = changeType;
 }
Ejemplo n.º 35
0
 public ChangeItem(ChangeType type, DomainObject obj)
 {
     this.Object     = obj;
     this.ChangeType = type;
 }
 public DocumentsChangeEventArgs(ChangeType changeType, ICollection <ModifiedDocument <T> > documents, IRepository <T> repository)
 {
     ChangeType = changeType;
     Documents  = documents ?? new List <ModifiedDocument <T> >();
     Repository = repository;
 }
Ejemplo n.º 37
0
 public void Record(string identifier, int itemID, int unitID, int ManufacturerID, int AccountID, decimal UnitCost, decimal Margin, decimal SellingPrice, int UserID, ChangeType changeType)
 {
     JournalEntry = new HCMIS.Concrete.Models.JournalLite()
     {
         Identifier   = identifier,
         Description  = changeType.Description,
         Margin       = Margin,
         UnitCost     = UnitCost,
         SellingPrice = SellingPrice,
         UserID       = UserID,
         Ledger       = LedgerService.PostToTempLedger(itemID, unitID, ManufacturerID, AccountID, UnitCost, Margin, SellingPrice, changeType)
     };
     repository.JournalLites.Insert(JournalEntry);
 }
Ejemplo n.º 38
0
 public static bool HasFlag(ChangeType changeType, ChangeType flag)
 {
     return((changeType & flag) == flag);
 }
Ejemplo n.º 39
0
 protected override bool HasChanges(ChangeType changeFlags)
 {
     return(changeFlags != ChangeType.None);
 }
Ejemplo n.º 40
0
        protected override void SendDeltaChanges(IEnumerable <INetworkConnection> connections, ChangeType changeFlags)
        {
            using (MemoryStream memoryStream = new MemoryStream())
                using (BinaryWriter message = new BinaryWriter(memoryStream))
                {
                    ComponentBroadcasterService.WriteHeader(message, this);

                    message.Write((byte)changeFlags);

                    if (HasFlag(changeFlags, ChangeType.Properties))
                    {
                        message.Write(previousEnabled);
                    }

                    message.Flush();
                    var data = memoryStream.ToArray();
                    StateSynchronizationSceneManager.Instance.Send(connections, ref data);
                }
        }
Ejemplo n.º 41
0
 protected void PublishMessage(ChangeType changeType, T document)
 {
     PublishMessage(changeType, new[] { document });
 }
Ejemplo n.º 42
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangeType"/> class using the specified
 /// change <paramref name="category"/> and <paramref name="compatibility"/> level.
 /// </summary>
 /// <param name="changeType">
 /// The <see cref="ChangeType"/> indicating the type of the change.
 /// </param>
 /// <param name="category">
 /// The <see cref="ChangeCategory"/> indicating whether or not this is a breaking change.
 /// </param>
 /// <param name="compatibility">
 /// The <see cref="CompatibilityLevel"/> indicating whether this change breaks binary or
 /// source compatibility.
 /// </param>
 protected Change(ChangeType changeType, ChangeCategory category, CompatibilityLevel compatibility)
 {
     ChangeType    = changeType;
     Category      = category;
     Compatibility = compatibility;
 }
Ejemplo n.º 43
0
 /// <summary>
 /// Creates and returns an instance of the LayerCollection.EventArgs class.
 /// </summary>
 /// <param name="changeType">Type of change that caused the event</param>
 /// <param name="obj">Object involved in the event</param>
 /// <param name="index">Zero-based collection index at which the event occurred</param>
 /// <returns>CollectionEx.EventArgs derived object</returns>
 protected override CollectionEx.EventArgs MakeEventArgs(ChangeType changeType, object obj, int index)
 {
     return(new LayerCollection.EventArgs(changeType, obj, index));
 }
 public AIVChange(string ident, ChangeType type, string resourceFolder, bool checkedDefault = true)
     : base(ident, type, checkedDefault)
 {
     this.resourceFolder = "UnofficialCrusaderPatch." + resourceFolder;
 }
Ejemplo n.º 45
0
 public override void PrepareForRender(ChangeType changeType)
 {
     UpdateConstants();
 }
Ejemplo n.º 46
0
 public Change(ChangeType type, Address address, Account account)
 {
     ChangeType = type;
     Address    = address;
     Account    = account;
 }
Ejemplo n.º 47
0
        public bool NotifyRoommateChange(int lot_id, uint avatar_id, uint replace_id, ChangeType change)
        {
            var lot = GetLot(lot_id);

            if (lot == null)
            {
                return(false);
            }
            lot.Container.NotifyRoommateChange(avatar_id, replace_id, change);
            return(true);
        }
Ejemplo n.º 48
0
        /// <summary>
        /// 添加记录信息行 有事务
        /// </summary>
        /// <param name="id">标识列的值(条件列,可扩展)</param>
        /// <param name="columns">需要的列数组</param>
        /// <param name="changetype">操作的类型(删除或修改)</param>
        public void AddRecordtran(SqlTransaction tran, string id, string[] columns, ChangeType changetype)
        {
            StringBuilder sqlbuilder = new StringBuilder();

            sqlbuilder.Append("select ");
            if (columns.Length > 0)
            {
                for (int i = 0; i <= columns.Length - 2; i++)
                {
                    sqlbuilder.Append(columns[i]);
                    sqlbuilder.Append(",");
                }
                // 最后不要加逗点
                sqlbuilder.Append(columns[columns.Length - 1]);
            }
            else
            {
                sqlbuilder.Append(" * ");
            }

            sqlbuilder.Append(" from ");
            sqlbuilder.Append(_tablename);
            sqlbuilder.Append(" where ");
            sqlbuilder.Append(_identity);
            sqlbuilder.Append(" = ");
            sqlbuilder.Append("'");
            sqlbuilder.Append(id);
            sqlbuilder.Append("'");

            SqlCommand cmd = new SqlCommand(sqlbuilder.ToString(), tran.Connection);

            cmd.Transaction = tran;
            SqlDataReader reader = cmd.ExecuteReader();
            //SqlDataReader reader = DBHelper.ExecuteReader(sqlbuilder.ToString());

            string ss = sqlbuilder.ToString();

            ss = "";

            bool   isVisible  = false;
            string columnName = string.Empty;

            while (reader.Read())
            {
                // 添加列信息
                if (this.State == RemarkState.StartHeader)
                {
                    _remarkbuilder.Append("<tr align='center'>");

                    // 操作类型标题列
                    _remarkbuilder.Append("<th style='white-space:nowrap'>操作类型</th>");

                    for (int i = 0; i <= reader.FieldCount - 1; i++)
                    {
                        columnName = GetColumnName(reader.GetName(i));
                        //columnName = DsSystem.TableMap.Columns.GetColumnName(reader.GetName(i), out  isVisible);
                        //	if (!isVisible)
                        //	{
                        //		hashNoVisible .Add (i , i);
                        //		continue ;
                        //	}
                        // 添加字段名称记录信息
                        _remarkbuilder.Append("<th style='white-space:nowrap'>");
                        _remarkbuilder.Append(columnName); // 字段名称
                        _remarkbuilder.Append("</th>");
                    }
                    _remarkbuilder.Append("</tr>");

                    this.State = RemarkState.StartItem; // 改变状态
                }

                if (this.State == RemarkState.StartItem)
                {
                    // 添加记录行信息
                    _remarkbuilder.Append("<tr align='center'>");

                    // 操作类型列
                    _remarkbuilder.Append("<td style='white-space:nowrap'>");
                    _remarkbuilder.Append(Enum.GetName(changetype.GetType(), changetype)); // 字段名称
                    _remarkbuilder.Append("</td>");

                    for (int i = 0; i <= reader.FieldCount - 1; i++)
                    {
                        if (hashNoVisible.Contains(i))
                        {
                            continue;
                        }

                        _remarkbuilder.Append("<td style='white-space:nowrap'>");
                        if (hashDP.Contains(i))
                        {
                            _remarkbuilder.Append(reader[i] == null ? " &nbsp;" : decipher(reader[i].ToString().Trim(), hashDP[i].ToString().ToLower())); // 字段名称
                        }
                        else
                        {
                            _remarkbuilder.Append(reader[i] == null ? " &nbsp;" : reader[i].ToString().Trim()); // 字段名称
                        }
                        _remarkbuilder.Append("</td>");
                    }
                    _remarkbuilder.Append("</tr>");

                    this._item++; // 记录行加加
                }
            }

            reader.Close();
        }
Ejemplo n.º 49
0
        public List <Script> GetUpdateScripts()
        {
            UpdateFilterDataFromConfig();

            if (!Directory.Exists(SourceFolder))
            {
                Directory.CreateDirectory(SourceFolder);
            }

            DirectoryInfo d = new DirectoryInfo(SourceFolder);

            d.GetFiles(@"*.sql", SearchOption.TopDirectoryOnly)
            .ToList().ForEach(f =>
            {
                if (f.Name.Contains(@".UserDefinedFunction"))
                {
                    File.Move(f.FullName, f.DirectoryName + System.IO.Path.DirectorySeparatorChar + f.Name.Replace(@".UserDefinedFunction", ""));
                }
                if (f.Name.Contains(@".StoredProcedure"))
                {
                    File.Move(f.FullName, f.DirectoryName + System.IO.Path.DirectorySeparatorChar + f.Name.Replace(@".StoredProcedure", ""));
                }
            });

            Dictionary <string, Tuple <string, DateTime> > SourcesData = d.GetFiles(@"*.sql", SearchOption.TopDirectoryOnly)
                                                                         .OrderBy(f => f.LastWriteTime)
                                                                         .ToDictionary(f => f.Name, f => new Tuple <string, DateTime>(File.ReadAllText(f.FullName, GetEncoding(f.FullName)), f.LastWriteTime));

            foreach (var procedure in Procedures.Where(p => p.IsTrace))
            {
                if (!SourcesData.Keys.Contains(procedure.FullName + ".sql"))
                {
                    SourcesData.Add(procedure.FullName + ".sql", new Tuple <string, DateTime>("", DateTime.Now));
                }
            }

            foreach (var function in Functions.Where(f => f.IsTrace))
            {
                if (!SourcesData.Keys.Contains(function.FullName + ".sql"))
                {
                    SourcesData.Add(function.FullName + ".sql", new Tuple <string, DateTime>("", DateTime.Now));
                }
            }

            using (SqlConnection conn = new SqlConnection(GetConnectionString()))
            {
                conn.Open();
                var cmd = conn.CreateCommand();

                var(ОтслеживаемыеСхемы, ИгнорируемыеСхемы, ОтслеживаемыеОбъекты, ИгнорируемыеОбъекты) = GetFilters();

                List <string> @objects = SourcesData.Keys.ToList();

                if (ОтслеживаемыеОбъекты != null && ОтслеживаемыеОбъекты.Count > 0)
                {
                    @objects.AddRange(ОтслеживаемыеОбъекты.Select(o => o + ".sql").ToList());
                    @objects = @objects.Distinct().ToList();
                }

                cmd.CommandText = @"SELECT s.[name] + N'.' + o.[name] AS ObjectName, sm.[definition], o.[TYPE]," + Environment.NewLine
                                  + @"ISNULL(sm.uses_ansi_nulls, 0) AS uses_ansi_nulls," + Environment.NewLine
                                  + @"ISNULL(sm.uses_quoted_identifier, 0) AS uses_quoted_identifier" + Environment.NewLine
                                  + @"FROM   sys.sql_modules   AS sm" + Environment.NewLine
                                  + @"       JOIN sys.objects  AS o" + Environment.NewLine
                                  + @"            ON  o.[object_id] = sm.[object_id]" + Environment.NewLine
                                  + @"       JOIN sys.schemas  AS s" + Environment.NewLine
                                  + @"            ON  o.[schema_id] = s.[schema_id]" + Environment.NewLine
                                  + $"WHERE" + Environment.NewLine;

                string condition = "";

                if (@objects.Count > 0)
                {
                    condition = $"sm.object_id IN ({@objects.GetObjectIdString()})";
                }

                if (ОтслеживаемыеСхемы != null && ОтслеживаемыеСхемы.Count > 0)
                {
                    if (condition != "")
                    {
                        condition += Environment.NewLine;
                        condition += " OR ";
                    }
                    condition += $"s.[name] IN ({ОтслеживаемыеСхемы.GetObjectsList()})";
                }

                if (ИгнорируемыеОбъекты != null && ИгнорируемыеОбъекты.Count > 0)
                {
                    if (condition != "")
                    {
                        condition  = $@"({condition})" + Environment.NewLine;
                        condition += " AND ";
                    }
                    condition += $"sm.object_id NOT IN ({ИгнорируемыеОбъекты.Select(s => s + ".sql").ToList().GetObjectIdString()})";
                }

                cmd.CommandText += condition;

                List <Script> UpdateScripts = new List <Script>();

                using (SqlDataReader r = cmd.ExecuteReader())
                {
                    while (r.Read())
                    {
                        string FileName = ((string)r["ObjectName"]) + ".sql";

                        string objectType = objectTypeDescription((string)r["TYPE"]);

                        string TextFromDB = string.Empty;

                        if ((bool)r["uses_ansi_nulls"])
                        {
                            TextFromDB += @"SET ANSI_NULLS ON" + Environment.NewLine;
                            TextFromDB += @"GO" + Environment.NewLine;
                        }

                        if ((bool)r["uses_quoted_identifier"])
                        {
                            TextFromDB += @"SET QUOTED_IDENTIFIER ON" + Environment.NewLine;
                            TextFromDB += @"GO" + Environment.NewLine;
                        }

                        TextFromDB += (string)r["definition"];

                        string SourcesKey = SourcesData
                                            .Keys
                                            .Select(k => new { Value = k, Upper = k.ToUpper() })
                                            .SingleOrDefault(k => k.Upper == FileName.ToUpper())
                                            ?.Value;
                        string TextFromFile = (SourcesKey != null) ? SourcesData[SourcesKey].Item1 : null;

                        if ((TextFromFile == null) || (TextFromFile != TextFromDB))
                        {
                            ChangeType ChangeType = (TextFromFile == null) ? ChangeType.Новый : ChangeType.Изменённый;

                            UpdateScripts.Add(
                                new Script()
                            {
                                FileName    = FileName,
                                FullPath    = SourceFolder + FileName,
                                ScriptText  = TextFromDB,
                                ObjectType  = objectType,
                                ChangeState = ChangeType
                            });
                        }
                    }
                }

                Server server   = new Server(new ServerConnection(conn));
                var    dataBase = server.Databases.Cast <Database>().Single(db => db.Name.ToUpper() == Name.ToUpper());

                if (ОтслеживаемыеСхемы != null)
                {
                    var tbls = dataBase.Tables.Cast <object>().Cast <Table>().Where(t => ОтслеживаемыеСхемы.Contains(t.Schema)).ToList();

                    foreach (var tbl in tbls)
                    {
                        string fileName = $@"{tbl.Schema}.{tbl.Name}.sql";
                        string script   = "";
                        tbl.Script().Cast <string>().ToList().ForEach(l =>
                        {
                            if (l != "")
                            {
                                script += "GO" + Environment.NewLine;
                            }
                            script += l + Environment.NewLine;
                        });

                        string tableFileName = TableFolder + fileName;
                        if (File.Exists(tableFileName) && script == File.ReadAllText(tableFileName))
                        {
                            continue;
                        }

                        ChangeType ChangeType = !File.Exists(tableFileName) ? ChangeType.Новый : ChangeType.Изменённый;

                        Script tblScript = new Script()
                        {
                            FileName    = fileName,
                            FullPath    = TableFolder + fileName,
                            ScriptText  = script,
                            ObjectType  = @"Таблица",
                            ChangeState = ChangeType
                        };

                        if (ChangeType == ChangeType.Новый)
                        {
                            tblScript.Migration = MakeCreateTableMigration(server, tbl);
                        }

                        UpdateScripts.Add(tblScript);
                    }
                }

                return(UpdateScripts);
            }
        }
Ejemplo n.º 50
0
 /// @brief Update change state for instance name.
 /// When the text of the text box changes, marks the code as modified, to
 /// prevent unaverted loses at closure of the window.
 /// @param[in] sender Object who called this on event.
 /// @param[in] e `EventArgs` class with a list of argument to the event call.
 /// @version V15.03.26 - Added.
 private void instanceName_TextChanged(object sender, EventArgs e)
 {
     CodeChanged = true;
     LastChange  = ChangeType.name;
 }
Ejemplo n.º 51
0
 /// <summary>
 /// Construct EventArgs given a change type.
 /// </summary>
 /// <param name="changeType">Type of change that occurred</param>
 public EventArgs(ChangeType changeType) : base(changeType)
 {
     this.objs = new IVerb[1] {
         null
     };
 }