Example #1
0
        /// <summary>
        /// Provides the changes performed by this statement
        /// </summary>
        /// <param name="context">The context on which the changes should be computed</param>
        /// <param name="changes">The list to fill with the changes</param>
        /// <param name="explanation">The explanatino to fill, if any</param>
        /// <param name="apply">Indicates that the changes should be applied immediately</param>
        public override void GetChanges(InterpretationContext context, ChangeList changes, ExplanationPart explanation, bool apply)
        {
            if (Call != null)
            {
                InterpretationContext ctxt      = getContext(context);
                Functions.Procedure   procedure = Call.getProcedure(ctxt);
                if (procedure != null)
                {
                    ExplanationPart part = new ExplanationPart(Root);
                    part.Message = procedure.FullName;
                    explanation.SubExplanations.Add(part);

                    int token = ctxt.LocalScope.PushContext();
                    foreach (KeyValuePair <Variables.Actual, Values.IValue> pair in Call.AssignParameterValues(context, procedure, true))
                    {
                        ctxt.LocalScope.setVariable(pair.Key, pair.Value);
                    }

                    foreach (Rules.Rule rule in Rules)
                    {
                        ApplyRule(rule, changes, ctxt, part);
                    }

                    ctxt.LocalScope.PopContext(token);
                }
                else
                {
                    AddError("Cannot determine the called procedure for " + ToString());
                }
            }
            else
            {
                AddError("Expression " + ToString() + " is not a valid procedure call");
            }
        }
Example #2
0
        /// <summary>
        ///     Applies a rule defined in a procedure
        /// </summary>
        /// <param name="rule"></param>
        /// <param name="changes"></param>
        /// <param name="ctxt"></param>
        /// <param name="explanation"></param>
        /// <param name="runner"></param>
        private void ApplyRule(Rule rule, ChangeList changes, InterpretationContext ctxt, ExplanationPart explanation,
                               Runner runner)
        {
            foreach (RuleCondition condition in rule.RuleConditions)
            {
                ExplanationPart conditionExplanation = ExplanationPart.CreateSubExplanation(explanation, condition);

                if (condition.EvaluatePreConditions(ctxt, conditionExplanation, runner))
                {
                    ExplanationPart.SetNamable(conditionExplanation, EfsSystem.Instance.BoolType.True);
                    foreach (Action action in condition.Actions)
                    {
                        action.GetChanges(ctxt, changes, conditionExplanation, true, runner);
                    }

                    foreach (Rule subRule in condition.SubRules)
                    {
                        ApplyRule(subRule, changes, ctxt, conditionExplanation, runner);
                    }
                    break;
                }
                else
                {
                    ExplanationPart.SetNamable(conditionExplanation, EfsSystem.Instance.BoolType.False);
                }
            }
        }
Example #3
0
        public static List <Change> RetrieveAllChanges(DriveService service, long?startChangeId)
        {
            List <Change> result = new List <Change>();

            ChangesResource.ListRequest request = service.Changes.List();
            request.IncludeDeleted = true;

            if (!String.IsNullOrEmpty(startChangeId.ToString()))
            {
                request.StartChangeId = startChangeId;
            }
            do
            {
                try
                {
                    ChangeList changes = request.Execute();
                    result.AddRange(changes.Items);
                    request.PageToken = changes.NextPageToken;
                }
                catch (Exception e)
                {
                    Console.WriteLine("An error occurred: " + e.Message);
                    request.PageToken = null;
                }
            } while (!String.IsNullOrEmpty(request.PageToken));
            return(result);
        }
Example #4
0
        /// <summary>
        ///     Compares the specified results.
        /// </summary>
        /// <param name="results">The results.</param>
        /// <param name="originalElement">The original element.</param>
        /// <param name="finalElement">The final element.</param>
        private void Compare(ChangeList results, ObjectGraphCapture.ValueElement originalElement, ObjectGraphCapture.ValueElement finalElement)
        {
            bool areEqual;

            if ((originalElement.Value == null) ^ (finalElement.Value == null))
            {
                areEqual = false;
            }
            else if ((originalElement.Value == null) && (finalElement.Value == null))
            {
                areEqual = true;
            }
            else
            {
// ReSharper disable once PossibleNullReferenceException
                areEqual = originalElement.Value.Equals(finalElement.Value);
            }
            if (!areEqual)
            {
                var diff = new ValueGraphChange
                {
                    Path         = originalElement.Path,
                    DeclaredType = originalElement.DeclaredType,
                    OldValue     = originalElement.Value,
                    NewValue     = finalElement.Value
                };
                results.Add(diff);
            }
        }
Example #5
0
            public override void GetChanges(InterpretationContext context, ChangeList changes,
                                            ExplanationPart explanation, bool apply, Runner runner)
            {
                Change change = new Change(Variable, Variable.Value, Value);

                changes.Add(change, apply, runner);
            }
 public IniSection(string name)
 {
     _name = name;
     _keys = new ChangeList<IniKey>();
     _keys.OnChange += new EventHandler(_keys_OnChange);
     _isComment = false;
 }
 public void WriteCell(int x, int y, int val)
 {
     if (x >= 0 && x < Width && y >= 0 && y < Height)
     {
         ChangeList.Add(new Change(x, y, val));
     }
 }
        public void Change(SpaceList space, ChangeList change)
        {
            switch (space)
            {
            case SpaceList.打包机:
                Change(space, 0, "打包机故障", change, cSheBei.GetMachineIndexForAllError(space, 0));
                break;

            case SpaceList.冷凝器线体:
                Change(space, 0, "冷凝器线体通讯故障或设备故障", change, cSheBei.GetMachineIndexForAllError(space, 0));
                break;

            case SpaceList.折弯机:
                Change(space, 0, "折弯机通讯故障或设备故障", change, cSheBei.GetMachineIndexForAllError(space, 0));
                break;

            case SpaceList.物料网络:
                Change(space, 0, "物料网络故障", change, cSheBei.GetMachineIndexForAllError(space, 0));
                break;

            case SpaceList.绕膜机:
                Change(space, 0, "绕膜机故障", change, cSheBei.GetMachineIndexForAllError(space, 0));
                break;

            case SpaceList.注油机:
                Change(space, 0, "注油机通讯故障或设备故障", change, cSheBei.GetMachineIndexForAllError(space, 0));
                break;

            case SpaceList.线体:
                Change(space, 0, "线体故障", change, cSheBei.GetMachineIndexForAllError(space, 0));
                break;
            }
        }
        /// <summary>
        ///     Provides the changes performed by this statement
        /// </summary>
        /// <param name="context">The context on which the changes should be computed</param>
        /// <param name="changes">The list to fill with the changes</param>
        /// <param name="explanation">The explanatino to fill, if any</param>
        /// <param name="apply">Indicates that the changes should be applied immediately</param>
        /// <param name="runner"></param>
        public override void GetChanges(InterpretationContext context, ChangeList changes, ExplanationPart explanation,
                                        bool apply, Runner runner)
        {
            IVariable var = VariableIdentification.GetVariable(context);

            if (var != null)
            {
                IValue value = Expression.GetExpressionValue(context, explanation);
                if (value != null)
                {
                    value = value.RightSide(var, true, true);
                }

                Range      range      = var.Type as Range;
                Collection collection = var.Type as Collection;
                if (range != null && range.convert(value) == null)
                {
                    AddError("Value " + value + " is outside range", RuleChecksEnum.ExecutionFailed);
                }
                else if (collection != null && collection.convert(value) == null)
                {
                    AddError("Value " + value + " cannot be assigned to variable", RuleChecksEnum.ExecutionFailed);
                }
                else
                {
                    Change change = new Change(var, var.Value, value);
                    changes.Add(change, apply, runner);
                    ExplanationPart.CreateSubExplanation(explanation, Root, change);
                }
            }
            else
            {
                AddError("Cannot find variable " + VariableIdentification, RuleChecksEnum.ExecutionFailed);
            }
        }
Example #10
0
        public static void BuildDocument(BuildJsonConfig config, TemplateManager templateManager, string baseDirectory, string outputDirectory, string pluginDirectory, string templateDirectory)
        {
            IEnumerable <Assembly> assemblies;

            using (new LoggerPhaseScope("LoadPluginAssemblies", LogLevel.Verbose))
            {
                assemblies = LoadPluginAssemblies(pluginDirectory);
            }

            var postProcessorNames = config.PostProcessors.ToImmutableArray();
            var metadata           = config.GlobalMetadata?.ToImmutableDictionary();

            // For backward compatible, retain "_enableSearch" to globalMetadata though it's deprecated
            if (metadata != null && metadata.TryGetValue("_enableSearch", out object value))
            {
                var isSearchable = value as bool?;
                if (isSearchable.HasValue && isSearchable.Value && !postProcessorNames.Contains("ExtractSearchIndex"))
                {
                    postProcessorNames = postProcessorNames.Add("ExtractSearchIndex");
                }
            }

            ChangeList changeList = null;

            if (config.ChangesFile != null)
            {
                changeList = ChangeList.Parse(config.ChangesFile, config.BaseDirectory);
            }

            using (var builder = new DocumentBuilder(assemblies, postProcessorNames, templateManager?.GetTemplatesHash(), config.IntermediateFolder, changeList?.From, changeList?.To))
                using (new PerformanceScope("building documents", LogLevel.Info))
                {
                    builder.Build(ConfigToParameter(config, templateManager, changeList, baseDirectory, outputDirectory, templateDirectory).ToList(), outputDirectory);
                }
        }
Example #11
0
 void OnMoneyChanged(object sender, ChangeEventArgs args)
 {
     while (args != null)
     {
         object item = args.Item;
         if (item != null)
         {
             Type t = item.GetType();
             if (t != typeof(MyMoney))
             {
                 ChangeList list;
                 if (!changes.TryGetValue(t, out list))
                 {
                     list       = new ChangeList(t);
                     changes[t] = list;
                 }
                 list.Add(args);
             }
         }
         args = args.Next;
     }
     if (changes.Count > 0)
     {
         IsDirty = true;
     }
 }
Example #12
0
        /// <summary>
        /// To be "changed", a node must have the same name, but different values.
        /// </summary>
        private void AssertChanged(string propertyName, ChangeList <JsonNode> changeList)
        {
            JsonNode removed = null;
            JsonNode added   = null;

            for (int i = 0; i < changeList.Count; ++i)
            {
                var change = changeList[i];
                if (change.Value.Name != propertyName)
                {
                    continue;
                }
                switch (change.ChangeType)
                {
                case ChangeList <JsonNode> .ChangeType.Removed:
                    removed = change.Value;
                    break;

                case ChangeList <JsonNode> .ChangeType.Added:
                    added = change.Value;
                    break;
                }
            }

            XAssert.AreNotEqual(null, removed);
            XAssert.AreNotEqual(null, added);
            XAssert.AreNotEqual(removed, added);
        }
Example #13
0
        private void SaveChangeList()
        {
            using (ChangeList change = new ChangeList(true))
            {
                change.FromDate = FromDate;
                change.Todate   = ToDate;

                if (ChangeListID == 0)
                {
                    ChangeListID = change.Add();
                }

                change.Clear(ChangeListID);

                foreach (ChangeListToolstriptItem RmenuItem in contextMenuStrip1.Items)
                {
                    if (RmenuItem.asapuChangeListItem != null)
                    {
                        foreach (ChangeListItemBhikku bhikku in RmenuItem.asapuChangeListItem.bhikkuList)
                        {
                            change.AddBhikkuAsapuwa(ChangeListID, RmenuItem.asapuChangeListItem.asapuwaID, bhikku.bInfo.ID, bhikku.bInfo.Post, bhikku.bInfo.ChangeType);
                        }
                    }
                }
            }
        }
Example #14
0
        public async Task GetChangesAsync_ValidId_ReturnsValidResult(int id)
        {
            ITelevisionApi apiUnderTest = new TelevisionApi(_clientWithNoApiKey);

            ChangeList result = await apiUnderTest.GetChangesAsync(id, apiKey : _userApiKey);

            Assert.IsNotNull(result);
        }
Example #15
0
 private void LbDepartments_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     changing = ChangeDepartment;
     choosing = ChoosingDepartment;
     adding   = AddDepartment;
     removing = RemoveDepartment;
     choosing?.Invoke();
 }
Example #16
0
 private void UpdateChangeItemFinalizeAsapuwa(int asapuwaiD, bool isAdd)
 {
     using (ChangeList c = new ChangeList(true))
     {
         c.ID = ChangeListID;
         c.UpdateFinalizedAsapuList(string.Concat(",", asapuwaiD), isAdd);
     }
 }
Example #17
0
 private void LbEmployees_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     changing = ChangeEmployee;
     choosing = ChoosingEmployee;
     adding   = AddEmployee;
     removing = RemoveEmployee;
     choosing?.Invoke();
 }
Example #18
0
        /// <summary>
        ///     Provides the changes performed by this statement
        /// </summary>
        /// <param name="context">The context on which the changes should be computed</param>
        /// <param name="changes">The list to fill with the changes</param>
        /// <param name="explanation">The explanatino to fill, if any</param>
        /// <param name="apply">Indicates that the changes should be applied immediately</param>
        /// <param name="runner"></param>
        public override void GetChanges(InterpretationContext context, ChangeList changes, ExplanationPart explanation,
                                        bool apply, Runner runner)
        {
            IVariable variable = ListExpression.GetVariable(context);

            // ReSharper disable once ConditionIsAlwaysTrueOrFalse
            changes.Add(new InsertInListChange(context, this, variable, explanation), apply, runner);
        }
Example #19
0
        /// <summary>
        /// Display change information on the screen
        /// </summary>
        private static void DisplayChange()
        {
            // Call the calculate method change
            ChangeList = Transaction.CalculateChange();

            // Iterate through the list and display information
            ChangeList.ForEach(x => Factory.Output(x));
        }
Example #20
0
 void Awake()
 {
     instance = this;
     //引导页调用
     DownloadProp.Instance.AutoCheckUpdateLocalComponent();
     //引导页调用
     DownloadProp.Instance.UpdatePreview();
     rect = transform.GetComponent <ScrollRect>();
 }
Example #21
0
        private void ReloadhistryLabels()
        {
            histryGroup.Controls.Clear();

            using (ChangeList cLIst = new ChangeList(true))
            {
                AddChangeListHistry(cLIst.SelectAllList());
            }
        }
Example #22
0
        public async Task GetChangeListAsync_SpecificType_ReturnsChangeList()
        {
            IChangesApi apiUnderTest = new ChangesApi(_clientWithNoApiKey);

            ChangeList changeList = await apiUnderTest.GetChangeListAsync(ChangeType.TV, "26/07/2020", "25/07/2020", 1, _userApiKey);

            Assert.IsNotNull(changeList);
            Assert.IsNotEmpty(changeList.Results);
        }
        public void RegisterListen(UIManagerClass.ChildScreen screen, ChangeList change, Action function)
        {
            ListenerEntry newEntry;

            newEntry.Screen     = screen;
            newEntry.ChangeType = change;
            newEntry.Function   = function;
            Listeners.Add(newEntry);
        }
Example #24
0
        public void Tests()
        {
            var testPairs = new TestPair[]
            {
                new TestPair
                {
                    OldList = new List <int> {
                        6, 2, 4, 0
                    },
                    NewList = new List <int> {
                        0, 2, 3, 4, 1
                    }
                },
                new TestPair
                {
                    OldList = new List <int> {
                        1, 2, 3, 4, 1
                    },
                    NewList = new List <int> {
                        3, 4, 1, 2, 1, 3
                    }
                },
                new TestPair
                {
                    OldList = new List <int> {
                        9, 8, 7
                    },
                    NewList = new List <int> {
                        9, 1, 2, 6
                    }
                },
                new TestPair
                {
                    OldList = new List <int> {
                        3, 9, 8, 3, 9, 7, 9, 7, 0
                    },
                    NewList = new List <int> {
                        3, 3, 9, 9, 9, 1, 7, 2, 0, 6
                    }
                },
                new TestPair
                {
                    OldList = new List <int> {
                        1, 2
                    },
                    NewList = new List <int> {
                        3, 4, 5
                    }
                }
            };

            foreach (var test in testPairs)
            {
                var changeList = new ChangeList <int>(test.OldList, test.NewList);
                AssertValidChange(test.OldList, test.NewList, changeList);
            }
        }
    public void WriteCell(int x, int y, int val)
    {
        if (x >= 0 && x < Width && y >= 0 && y < Height)
        {
            PushPixel(new Pixel(x, y, val > 0 ? ColonyColor : EmptyColor));

            ChangeList.Add(new Change(x, y, val > 0 ? 1 : 0));
        }
    }
 public void Change(SpaceList space, int index, ChangeList change)
 {
     switch (space)
     {
     case SpaceList.工位屏:
         Change(space, 0, string.Format("{0}通讯故障", frmMain.mMain.AllCars.AllInfoStation[index].StationName), change, cSheBei.GetMachineIndexForAllError(space, index));
         break;
     }
 }
Example #27
0
    public void WriteCell(int x, int y, int val)
    {
        if (x >= 0 && x < Width && y >= 0 && y < Height)
        {
            PushPixel(new Pixel(x, y, ColorPalette[val]));

            ChangeList.Add(new Change(x, y, val));
        }
    }
Example #28
0
    public void WriteCell(int x, int y, int val)
    {
        if (x >= 0 && x < Width && y >= 0 && y < Height)
        {
            PushPixel(new Pixel(x, y, val >= 0 && val < MaxStates ? ColorPalette[val * Delta] : EmptyColor));

            ChangeList.Add(new Change(x, y, val));
        }
    }
Example #29
0
        public int AddDeleteChangeItem(int bhikkuChangeListID, int asapuwaID, int bhikkuID, DBCore.BhikkuPost post, DBCore.BhikkuChangeType changeType, bool isUpasampanna)
        {
            using (ChangeList change = new ChangeList(true))
            {
                saveHistrybtn.Enabled = true;

                if (ChangeListID == 0)
                {
                    change.FromDate = FromDate;
                    change.Todate   = ToDate;


                    ChangeListID = change.Add();
                }

                if (bhikkuChangeListID == 0)
                {
                    if (isUpasampanna)
                    {
                        upasampadaChangeCount++;
                    }
                    else
                    {
                        samaneraChangeCount++;
                    }

                    setSummaryCounts();

                    return(change.AddBhikkuAsapuwa(ChangeListID, asapuwaID, bhikkuID, post, changeType));
                }
                else
                {
                    // delete bhikku
                    if (asapuwaID == -1)
                    {
                        if (isUpasampanna)
                        {
                            upasampadaChangeCount--;
                        }
                        else
                        {
                            samaneraChangeCount--;
                        }

                        change.DeleteBhikkuAsapuwa(bhikkuChangeListID);
                        setSummaryCounts();
                        return(0);
                    }
                    else
                    {
                        change.UpdateBhikkuAsapuwa(bhikkuChangeListID, post, changeType);
                        return(bhikkuChangeListID);
                    }
                }
            }
        }
 public void NotifyChange(UIManagerClass.ChildScreen sender, ChangeList change)
 {
     foreach (ListenerEntry c in Listeners)
     {
         if (c.ChangeType == change && c.Screen != sender)
         {
             c.Function();
         }
     }
 }
Example #31
0
 /// <summary>
 /// Получает изменение в расписании.
 /// </summary>
 /// <param name="pairs">Список пар</param>
 /// <returns>Ответ от сервера.</returns>
 public HttpResponseMessage GetChanges(out ChangeList pairs)
 {
     using (var client = createClient(_accessToken))
     {
         var response = client.GetAsync(_appPath + "/api/Changes").Result;
         var result   = response.Content.ReadAsStringAsync().Result;
         pairs = JsonConvert.DeserializeObject <ChangeList>(result);
         return(response);
     }
 }
        /// <summary>
        /// Loads the repository from whatever backing data store is most appropriate
        /// </summary>
        public void Load()
        {
            var client = new RestClient(Config.DeltaApiRoot);
            var request = new RestRequest("Change", Method.GET);
            request.AddParameter("channel", SettingsRepository.PushChannelUri);

            client.ExecuteAsync(request, resp =>
                                             {
                                                 _repository = new ChangeList();
                                                 if (resp.StatusCode == HttpStatusCode.OK)
                                                 {
                                                     JArray jsonArray = JArray.Parse(resp.Content);
                                                     _repository.AddRange(from ch in jsonArray.AsJEnumerable()
                                                                          select CreateChangeEntity(ch));
                                                 }

                                                 if (LoadCompleted != null)
                                                     LoadCompleted(this, new EventArgs());
                                             });
        }
        /// <summary>
        /// Apply changes
        /// </summary>
        /// <param name="changeList"></param>
        public void ApplyChanges(ChangeList changeList)
        {
            // clear the log provider
            ChangeLogProvider.Clear();

            // separate out the changes
            var speakerChanges = changeList.SpeakerChanges;
            var sessionChanges = changeList.SessionChanges;

            // apply the changes
            ApplySpeakerChanges(speakerChanges);
            ApplySessionChanges(sessionChanges);

            // save the changes
            SpeakerRepository.SaveChanges();
            SessionRepository.SaveChanges();

            // indicate to the service that we are up to date (we will not work on the response to this)
            if (changeList.Count > 0)
            {
                int changeSet = changeList.Max(c => c.Changeset);
                UpdateClientChangesetToLatest(changeSet);
            }
        }
Example #34
0
		/// <summary>
		/// Get the ChangeListStatus for the provided changelist, can be Pending, Needswork, or Closable.
		/// Does not check if changelist stage is closed.
		/// </summary>
		/// <param name="changeList">Changelist whos status is of interest</param>
		/// <returns>ChangeListStatus enum</returns>
		private ChangeListStatus GetChangeListStatus(ChangeList changeList)
		{
			var sumbittedReviews = changeList.Reviews.Where(rv => rv.IsSubmitted);

			if (sumbittedReviews.Count() == 0 
				|| sumbittedReviews.All(rv => rv.OverallStatus == NonScoringComment || rv.OverallStatus == UnmarkedComment))
			{
				return ChangeListStatus.Pending;
			}

			if (IsChangeListNeedsWork(changeList))
			{
				return ChangeListStatus.NeedsWork;
			}

			// Must be closable
			return ChangeListStatus.Closable;
		}
Example #35
0
 protected override void ClassClear()
 {
     base.ClassClear();
     _pendingArticleIds = new ChangeList<long>();
 }
Example #36
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="review"></param>
		/// <param name="change"></param>
		/// <param name="action"> If action is "confirm" we display Confirm/Cancel buttons. Otherwise it's
		///     "Back to the change list" link. </param>
		/// <param name="uniquefier"> Postfix to make button ids unique. Needs to be different for every invokation
		///     on the same table. </param>
		private void AddDisplayReviewControls(Review review, ChangeList change, string action, int uniquefier)
		{
			if ("confirm".EqualsIgnoreCase(action))
			{
				Table buttonTable = new Table();

				ActivePage.Add(("<b>Note:</b> After you submit the review, you will not be able to modify it, or any " +
					"comments within. All new comments will go into a separate review which will be appended to the " +
					"conversation.").As(HtmlTextWriterTag.P));

				Button confirm = new Button() { Text = "Confirm", CssClass = "button",  };
				confirm.Text = "Confirm";
				confirm.Click += new EventHandler(delegate(object sender, EventArgs e)
				{
					DataContext.SubmitReview(review.Id);
					Response.Redirect(Request.FilePath);	// reload the dashboard
				});

				Button cancel = new Button() { Text = "Cancel", CssClass = "button" };
				cancel.Text = "Cancel";
				cancel.Click += new EventHandler(delegate(object sender, EventArgs e)
				{
					Response.Redirect(Request.FilePath + "?cid=" + change.Id);
				});

				ActivePage.Add(new Panel() { CssClass = "CssButtonBar" }
					.Add(confirm)
					.Add(cancel)
					.As(HtmlTextWriterTag.P));
			}
			else
			{
				AddLink("Back to change " + change.CL, "?cid=" + change.Id);
			}
		}
Example #37
0
 protected override void ClassClear()
 {
     base.ClassClear();
     _pendingPostedPhotoIds = new ChangeList<long>();
 }
Example #38
0
        /// <summary>
        /// Main driver for the code review submission tool.
        /// </summary>
        /// <param name="context"> The database context. </param>
        /// <param name="sd"> Source control client. </param>
        /// <param name="sourceControlInstanceId"> The ID of source control instance to use.
        ///     This is an ID of a record in the database that is unique for a given CL namespace.</param>
        /// <param name="changeList"> CL. </param>
        /// <param name="reviewers"> The list of people to who to send the code review request. </param>
        /// <param name="invitees"> The list of people who are invited to participate in the code review
        /// (but need to positively acknowledge the invitation by choosing to review the code). </param>
        /// <param name="link"> Optionally, a link to a file or a web page to be displayed in CL page. </param>
        /// <param name="linkDescr"> An optional description of the said link. </param>
        /// <param name="description"> An optional description of the changelist, overrides any description
        ///                             from the source control tool. </param>
        /// <param name="bugTracker">The server for accessing bugs.</param>
        /// <param name="bugIds">List of bugs to associate with review page.</param>
        /// <param name="force"> If branched files are included, confirms the submission even if there
        /// are too many files. </param>
        /// <param name="includeBranchedFiles"> </param>
        /// <param name="preview">If true, do not commit changes.</param>
        private static void ProcessCodeReview(
            string databaseServer,
            ISourceControl sd,
            int sourceControlInstanceId,
            string changeList,
            List<string> reviewers,
            List<string> invitees,
            string link,
            string linkDescr,
            string description,
            IBugServer bugServer,
            List<string> bugIds,
            bool force,
            bool includeBranchedFiles,
            bool preview,
            string impersonateUserName)
        {
            Change change = sd.GetChange(changeList, includeBranchedFiles);
            if (change == null)
                return;

            changeList = change.ChangeListFriendlyName ?? changeList;

            if (change == null)
                return;

            if (includeBranchedFiles && !force)
            {
                int branchedFiles = 0;
                foreach (SourceControl.ChangeFile file in change.Files)
                {
                    if (file.IsText && (file.Action == SourceControl.ChangeFile.SourceControlAction.BRANCH ||
                        file.Action == SourceControl.ChangeFile.SourceControlAction.INTEGRATE))
                        ++branchedFiles;
                }

                if (branchedFiles > MaximumIntegratedFiles)
                {
                    Console.WriteLine("There are {0} branched/integrated files in this change.", branchedFiles);
                    Console.WriteLine("Including the full text of so many files in review may increase the size");
                    Console.WriteLine("of the review database considerably.");
                    Console.Write("Are you sure you want to proceed (Yes/No)? ");
                    string response = Console.ReadLine();
                    Console.WriteLine("NOTE: In the future you can override this check by specifying --force");
                    Console.WriteLine("on the command line.");
                    if (response[0] != 'y' && response[0] != 'Y')
                        return;
                }
            }

            if (!VerifyDiffIntegrity(change))
                return;

            CodeReviewDataContext context = new CodeReviewDataContext("Data Source=" + databaseServer +
                ";Initial Catalog=CodeReview;Integrated Security=True");

            var existingReviewQuery = from rv in context.ChangeLists
                                      where rv.CL == changeList && rv.SourceControlId == sourceControlInstanceId
                                      select rv;

            // is this a new review, or a refresh of an existing one?
            bool isNewReview = (existingReviewQuery.Count() == 0);

            int? changeId = null;
            if (description == null)
                description = change.Description;

            context.Connection.Open();
            using (context.Connection)
            using (context.Transaction = context.Connection.BeginTransaction(System.Data.IsolationLevel.Snapshot))
            {
                // This more like "GetOrAddChangeList", as it returns the id of any pre-existing changelist
                // matching 'changeList'.
                if (impersonateUserName == null)
                {
                    context.AddChangeList(
                        sourceControlInstanceId, change.SdClientName, changeList, description,
                        change.TimeStamp.ToUniversalTime(), ref changeId);
                }
                else
                {
                    var changeListDb = (from c in context.ChangeLists
                                        where c.SourceControlId == sourceControlInstanceId &&
                                              c.UserName == impersonateUserName &&
                                              c.UserClient == change.SdClientName &&
                                              c.CL == changeList
                                        select c).FirstOrDefault();

                    if (changeListDb == null)
                    {
                        changeListDb = new ChangeList()
                        {
                            SourceControlId = sourceControlInstanceId,
                            UserName = impersonateUserName,
                            UserClient = change.SdClientName,
                            CL = changeList,
                            Description = description,
                            TimeStamp = change.TimeStamp.ToUniversalTime(),
                            Stage = 0
                        };

                        context.ChangeLists.InsertOnSubmit(changeListDb);
                        context.SubmitChanges(); // Not actually submitted until transaction completes.
                    }

                    changeId = changeListDb.Id;
                }

                // Get the list of files corresponding to this changelist already on the server.
                var dbChangeFiles = (from fl in context.ChangeFiles
                                     where fl.ChangeListId == changeId && fl.IsActive
                                     select fl)
                                     .OrderBy(file => file.ServerFileName)
                                     .GetEnumerator();

                var inChangeFiles = (from fl in change.Files
                                     select fl)
                                     .OrderBy(file => file.ServerFileName)
                                     .GetEnumerator();

                bool dbChangeFilesValid = dbChangeFiles.MoveNext();
                bool inChangeFilesValid = inChangeFiles.MoveNext();

                // Uses bitwise OR to ensure that both MoveNext methods are invoked.
                FileExistsIn existsIn = FileExistsIn.Neither;
                while (dbChangeFilesValid || inChangeFilesValid)
                {
                    int comp;
                    if (!dbChangeFilesValid) // No more files in database
                        comp = 1;
                    else if (!inChangeFilesValid) // No more files in change list.
                        comp = -1;
                    else
                        comp = string.Compare(dbChangeFiles.Current.ServerFileName,
                                              inChangeFiles.Current.ServerFileName);

                    if (comp < 0) // We have a file in DB, but not in source control. Delete it from DB.
                    {
                        Console.WriteLine("File {0} has been dropped from the change list.",
                                          dbChangeFiles.Current.ServerFileName);
                        context.RemoveFile(dbChangeFiles.Current.Id);

                        dbChangeFilesValid = dbChangeFiles.MoveNext();
                        existsIn = FileExistsIn.Database;
                        continue;
                    }

                    SourceControl.ChangeFile file = inChangeFiles.Current;

                    int? fid = null;
                    if (comp > 0) // File in source control, but not in DB
                    {
                        Console.WriteLine("Adding file {0}", file.ServerFileName);
                        context.AddFile(changeId, file.LocalFileName, file.ServerFileName, ref fid);
                        existsIn = FileExistsIn.Change;
                    }
                    else // Both files are here. Need to check the versions.
                    {
                        fid = dbChangeFiles.Current.Id;
                        existsIn = FileExistsIn.Both;
                    }

                    bool haveBase = (from bv in context.FileVersions
                                     where bv.FileId == fid && bv.Revision == file.Revision && bv.IsRevisionBase
                                     select bv).Count() > 0;

                    var versionQuery = from fv in context.FileVersions
                                       where fv.FileId == fid && fv.Revision == file.Revision
                                       orderby fv.Id descending
                                       select fv;

                    var version = versionQuery.FirstOrDefault();
                    bool haveVersion = false;
                    if (version != null && version.Action == (int)file.Action &&
                        BodiesEqual(NormalizeLineEndings(file.Data), NormalizeLineEndings(version.Text)))
                        haveVersion = true;

                    int? vid = null;
                    if (!haveBase && file.IsText &&
                        (file.Action == SourceControl.ChangeFile.SourceControlAction.EDIT ||
                         (file.Action == SourceControl.ChangeFile.SourceControlAction.INTEGRATE &&
                          includeBranchedFiles)))
                    {
                        string fileBody;
                        DateTime? dateTime;
                        fileBody = sd.GetFile(
                            file.OriginalServerFileName == null ? file.ServerFileName : file.OriginalServerFileName,
                            file.Revision, out dateTime);
                        if (fileBody == null)
                        {
                            Console.WriteLine("ERROR: Could not retrieve {0}#{1}", file.ServerFileName, file.Revision);
                            return;
                        }

                        Console.WriteLine("Adding base revision for {0}#{1}", file.ServerFileName, file.Revision);
                        context.AddVersion(fid, file.Revision, (int)file.Action, dateTime, true, true, true, fileBody,
                            ref vid);
                    }
                    else
                    {
                        // Do this so we print the right thing.
                        haveBase = true;
                    }

                    if (!haveVersion)
                    {
                        if (file.Action == SourceControl.ChangeFile.SourceControlAction.DELETE)
                        {
                            context.AddVersion(
                                fid, file.Revision, (int)file.Action, null, file.IsText, false, false, null, ref vid);
                        }
                        else if ((file.Action == SourceControl.ChangeFile.SourceControlAction.RENAME) || !file.IsText)
                        {
                            context.AddVersion(fid, file.Revision, (int)file.Action, file.LastModifiedTime, file.IsText,
                                false, false, null, ref vid);
                        }
                        else if (file.Action == SourceControl.ChangeFile.SourceControlAction.ADD ||
                            file.Action == SourceControl.ChangeFile.SourceControlAction.BRANCH)
                        {
                            context.AddVersion(fid, file.Revision, (int)file.Action, file.LastModifiedTime, file.IsText,
                                true, false, file.Data, ref vid);
                        }
                        else if (file.Action == SourceControl.ChangeFile.SourceControlAction.EDIT ||
                            file.Action == SourceControl.ChangeFile.SourceControlAction.INTEGRATE)
                        {
                            context.AddVersion(fid, file.Revision, (int)file.Action, file.LastModifiedTime, file.IsText,
                                false, false, file.Data, ref vid);
                        }

                        string textFlag = file.IsText ? "text" : "binary";
                        string action;
                        switch (file.Action)
                        {
                            case SourceControl.ChangeFile.SourceControlAction.ADD:
                                action = "add";
                                break;

                            case SourceControl.ChangeFile.SourceControlAction.EDIT:
                                action = "edit";
                                break;

                            case SourceControl.ChangeFile.SourceControlAction.DELETE:
                                action = "delete";
                                break;

                            case SourceControl.ChangeFile.SourceControlAction.BRANCH:
                                action = "branch";
                                break;

                            case SourceControl.ChangeFile.SourceControlAction.INTEGRATE:
                                action = "integrate";
                                break;

                            case SourceControl.ChangeFile.SourceControlAction.RENAME:
                                action = "rename";
                                break;

                            default:
                                action = "unknown";
                                break;
                        }

                        if (version != null && vid == version.Id)
                        {
                            // The file was already there. This happens sometimes because SQL rountrip (to database
                            // and back) is not an identity: somtimes the non-graphical characters change depending
                            // on the database code page. But if the database has returned a number, and this number
                            // is the same as the previous version id, we know that the file has not really been added.
                            haveVersion = true;
                        }
                        else
                        {
                            Console.WriteLine("Added version for {0}#{1}({2}, {3})", file.ServerFileName, file.Revision,
                                textFlag, action);
                        }
                    }

                    if (haveBase && haveVersion)
                        Console.WriteLine("{0} already exists in the database.", file.ServerFileName);

                    if ((existsIn & FileExistsIn.Database) == FileExistsIn.Database)
                        dbChangeFilesValid = dbChangeFiles.MoveNext();
                    if ((existsIn & FileExistsIn.Change) == FileExistsIn.Change)
                        inChangeFilesValid = inChangeFiles.MoveNext();

                    existsIn = FileExistsIn.Neither;
                }

                foreach (string reviewer in reviewers)
                {
                    int? reviewId = null;
                    context.AddReviewer(reviewer, changeId.Value, ref reviewId);
                }

                foreach (string invitee in invitees)
                {
                    context.AddReviewRequest(changeId.Value, invitee);
                }

                if (link != null)
                {
                    int? attachmentId = null;
                    context.AddAttachment(changeId.Value, linkDescr, link, ref attachmentId);
                }

                if (preview)
                    context.Transaction.Rollback();
                else
                    context.Transaction.Commit();
            }

            var reviewSiteUrl = Environment.GetEnvironmentVariable("REVIEW_SITE_URL");
            if (reviewSiteUrl != null)
            {
                var reviewPage = reviewSiteUrl;
                if (!reviewPage.EndsWith("/"))
                    reviewPage += "/";
                reviewPage += @"default.aspx?cid=" + changeId.ToString();
                Console.WriteLine("Change {0} is ready for review, and may be viewed at", changeList);
                Console.WriteLine("   {0}", reviewPage);

                var allBugIds = Enumerable.Union(change.BugIds, bugIds);
                if (bugServer != null && allBugIds.Count() > 0)
                {
                    Console.WriteLine("Connecting to TFS Work Item Server");
                    if (bugServer.Connect())
                    {
                        foreach (var bugId in allBugIds)
                        {
                            var bug = bugServer.GetBug(bugId);
                            if (bug.AddLink(new Uri(reviewPage), null))
                                Console.WriteLine("Bug {0} has been linked to review page.", bugId);
                        }
                    }
                }
            }
            else
            {
                Console.WriteLine("Change {0} is ready for review.", changeList);
            if (isNewReview)
            {
                if (reviewers.Count == 0 && invitees.Count == 0)
                {
                    Console.WriteLine("Note: no reviewers specified. You can add them later using this utility.");
                }
                else
                {
                    Console.WriteLine("If the mail notifier is enabled, the reviewers will shortly receive mail");
                    Console.WriteLine("asking them to review your changes.");
                }
            }
            else
            {
                Console.WriteLine("Note: existing reviewers will not be immediately informed of this update.");
                Console.WriteLine("To ask them to re-review your updated changes, you can visit the review website");
                Console.WriteLine("and submit a response.");
            }
            }

            if (preview)
                Console.WriteLine("In preview mode -- no actual changes committed.");
        }
Example #39
0
		/// <summary>
		/// Determine if the ChangeList has  Needs Work status. Should be run after checking in the changelist is Pending.
		/// A changelist needs work if one or more reviewers have commented 'NeedsWork' as their last comment. Non-scoring comments
		/// and UnmarkedComments do not count.
		/// </summary>
		/// <returns>True if the changelist meets the requirments of needs work, otherwise false</returns>
		private bool IsChangeListNeedsWork(ChangeList changeList)
		{
			foreach (var curReviewer in changeList.Reviewers)
			{
				var curReviewList = changeList.Reviews.Where(rv => rv.IsSubmitted 
						&& rv.UserName == curReviewer.ReviewerAlias 
						&& rv.OverallStatus != NonScoringComment && rv.OverallStatus != UnmarkedComment);

				if (curReviewList.Count() != 0 && curReviewList.Last().OverallStatus == NeedsWork)
				{
					return true;
				}
			}
			return false; // None of the reviews match 'needs work' case
		}
Example #40
0
 protected override void ClassClear()
 {
     base.ClassClear();
     _pendingPhotoIds = new ChangeList<long>();
     _pendingCategoryIds = new ChangeList<long>();
     _pendingAlternateCategoryIds = new ChangeList<long>();
     _blurbHasChanged = false;
     _tempText = null;
     _forceRefresh = false;
 }
Example #41
0
        private Dictionary<string, ChangeList> DeserializeChangeMap(MgBinaryDeserializer d)
        {
            Dictionary<string, ChangeList> changes = new Dictionary<string, ChangeList>();
            int changeListCount = d.ReadInt32();
            while (changeListCount-- > 0)
            {
                bool isLayer = d.ReadByte() > 0;
                string objid = d.ReadString();

                ChangeList c = null;
                if (!changes.ContainsKey(objid))
                {
                    c = new ChangeList(objid, isLayer);
                    changes.Add(c.ObjectId, c);
                }
                else
                {
                    c = changes[objid];
                }

                int changeCount = d.ReadInt32();
                while (changeCount-- > 0)
                {
                    //Split up to avoid dependency on argument evaluation order
                    int ctype = d.ReadInt32();
                    c.Changes.Add(new Change((Change.ChangeType)ctype, d.ReadString()));
                }

            }
            return changes;
        }
Example #42
0
        //This mirrors the unmanaged implementation of MgMapBase
        //Turns out the 2.x implementation didn't track these map element changes
        internal void TrackChange(string objectId, bool isLayer, Change.ChangeType type, string param)
        {
            if (_disableChangeTracking)
                return;

            ChangeList changes = null;
            if (!m_changeList.ContainsKey(objectId))
            {
                changes = new ChangeList(objectId, isLayer);
                m_changeList.Add(objectId, changes);

            }
            changes = m_changeList[objectId];

            var change = new Change(type, param);
            changes.Changes.Add(change);

            Debug.WriteLine("Tracked change for " + (isLayer ? "Layer " : "Group ") + objectId + " (type: " + type + ", value: " + param + ")");

            this.IsDirty = true;
        }
Example #43
0
 public IniFile()
 {
     _sections = new ChangeList<IniSection>();
     _sections.OnChange += new EventHandler(_sections_OnChange);
 }
Example #44
0
		/// <summary>
		/// Populates one row of data with the details of the passed change list.
		/// Used when displaying the list of change lists in review. Called for both
		/// the CLs where the user is the reviewer, as well as the reviewee.
		/// </summary>
		/// <param name="changeList"> The change list to process. </param>
		private TableRow GetReviewRow(ChangeList changeList, bool includeUserName, bool includeCloseButton = false)
		{
			TableRow row = new TableRow();
			if (changeList.Stage != 0)
				row.AppendCSSClass("Closed");

			// Added by CBOBO
			if (!includeUserName && includeCloseButton)
			{
				if (changeList.Stage == 2) // 2 = Closed
				{
					LiteralControl literalControl = new LiteralControl("Closed");
					TableCell cell = new TableCell();
					cell.Controls.Add(literalControl);
					cell.Width = 60;
					row.Cells.Add(cell);
				}
				else
				{
					switch(GetChangeListStatus(changeList))
					{
						case ChangeListStatus.Pending:
							row.Cells
								.Add(new TableCell() { CssClass = "Pending" }
								.Add("Pending".As(HtmlTextWriterTag.Span)));
							break;
						case ChangeListStatus.NeedsWork:
							row.Cells
								.Add(new TableCell() { CssClass = "NeedsWork" }
								.Add("Needs Work".As(HtmlTextWriterTag.Span)));
							break;
						case ChangeListStatus.Closable:
							HyperLink closeBtn = new HyperLink();
							closeBtn.NavigateUrl = Request.FilePath + "?cid=" + changeList.Id + "&action=close";
							closeBtn.Text = "[Close]";
							TableCell cell = new TableCell();
							cell.Controls.Add(closeBtn);
							cell.Width = 60;
							row.Cells.Add(cell);
							break;
					}
				}
			}
			// End Added by CBOBO

			// Time stamp
			row.Cells.Add(new TableCell() { CssClass = "ShortDate" }
				.Add(changeList.TimeStamp.ToShortDateString().As(HtmlTextWriterTag.Span)));

			// Author
			if (includeUserName)
			{
				row.Cells.Add(new TableCell() { CssClass = "Author" }
					.Add(changeList.UserName.As(HtmlTextWriterTag.Span)));
			}

			// Change list ID
			row.Cells.Add(new TableCell() { CssClass = "ChangeListName" }
				.Add(new HyperLink()
					{
						NavigateUrl = Request.FilePath + "?cid=" + changeList.Id,
						Text = Server.HtmlEncode(changeList.CL)
					}.As(HtmlTextWriterTag.Div)));

			// Description
			row.Cells.Add(new TableCell() { CssClass = "Description" }
				.Add(Server.HtmlEncode(changeList.Description).As(HtmlTextWriterTag.Span)));

			return row;
		}