public Issue BeforeUpdate(IssueEventArgs args)
        {
            if (args.Entity.GetResources().Count == 0)
            {
                return(args.Entity);
            }

            var project = args.Context.Projects.Get(args.Entity.ProjectId);

            if (project == null)
            {
                return(args.Entity);
            }

            List <IssueStatus> statuses = args.Context.Meta.StatusGet().FindAll(s => s.TemplateId == project.TemplateId).Where(s => !s.IsFinal).OrderBy(s => s.Sequence).ToList();

            if (statuses.Count <= 1)
            {
                return(args.Entity);
            }

            if (args.Previous.GetResources().Count == 0 && args.Previous.StatusId == statuses[0].Id)
            {
                args.Entity.StatusId = statuses[1].Id;

                return(args.Entity);
            }

            return(args.Entity);
        }
Ejemplo n.º 2
0
        public override void AfterCreate(IssueEventArgs args)
        {
            var data = GetConfig(args.Context);

            if (data == null || data.Value == null)
            {
                return;
            }

            string channel = GetProjectChannel(args.Entity.ProjectId, data.Value.ProjectChannels);

            if (channel == null || channel.Trim().Length == 0)
            {
                return;
            }

            QuickSlack.Send(data.Value.SlackAPIEndpoint, channel, string.Format("{0} created <{1}|{2} - {3}>"
                                                                                , args.User.Fullname, args.BuildIssueUrl(args.Entity), GetIssueKey(args), args.Entity.Title),
                            "more details attached",
                            "good",
                            new[] { new { title = "Description", value = StripHTML(args.Entity.Description), _short = false } },
                            StripHTML(args.Entity.Description));

            base.AfterCreate(args);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Selects the button according to default action.
        /// </summary>
        /// <param name="action">Default action.</param>
        private void SetDefaultActionButton(IssueEventArgs e)
        {
            switch (e.Reaction)
            {
            case FileTransferIssueReaction.Cancel: cancelBtn.Select(); break;

            case FileTransferIssueReaction.Fail: cancelBtn.Select(); break;

            case FileTransferIssueReaction.Skip: btnSkip.Select(); break;

            case FileTransferIssueReaction.Retry: retryBtn.Select(); break;

            case FileTransferIssueReaction.Rename: btnRename.Select(); break;

            case FileTransferIssueReaction.FollowLink: btnFollowLink.Select(); break;

            case FileTransferIssueReaction.Resume: btnResume.Select(); break;

            case FileTransferIssueReaction.Overwrite:
                switch (e.OverwriteCondition)
                {
                case FileOverwriteCondition.None: btnOverwrite.Select(); break;

                case FileOverwriteCondition.Older: btnOverwriteOlder.Select(); break;

                case FileOverwriteCondition.SizeDiffers: btnOverwriteDiffSize.Select(); break;

                case FileOverwriteCondition.ChecksumDiffers: btnOverwriteDiffChecksum.Select(); break;
                }
                break;
            }
        }
Ejemplo n.º 4
0
        public static string GetIssueKey(IssueEventArgs args)
        {
            var project = args.Context.Projects.Get(args.Entity.ProjectId);

            if (project == null)
            {
                return(string.Empty);
            }
            return(string.Concat(project.Code, '-', args.Entity.Id));
        }
Ejemplo n.º 5
0
        public Issue BeforeCreate(IssueEventArgs args)
        {
            var resources = args.Entity.GetResources();

            resources.RemoveAll(r => r == 0);

            args.Entity.AddWatchers(resources);

            args.Entity.AddWatcher(args.Entity.ReportedBy);

            return(args.Entity);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Before a task will be created, the description will be reformatted.
 /// </summary>
 /// <param name="args"></param>
 /// <returns></returns>
 public Issue BeforeCreate(IssueEventArgs args)
 {
     try
     {
         args.Entity.Description = FormatHtmlString(args.Entity.Description);
     }
     catch (Exception e)
     {
         int    issueID = args.Entity.Id;
         string message = string.Format("IssueID: {0}", issueID);
         GeminiApp.LogException(e, false, message);
     }
     return(args.Entity);
 }
Ejemplo n.º 7
0
        //出票通知处理
        void notify_OnIssue(object sender, IssueEventArgs args)
        {
            IStationOrderService       server = ObjectFactory.GetInstance <OrderService>();
            IList <PassengerTicketDto> PassengerTicketDtoList = new List <PassengerTicketDto>();

            foreach (string passengerName in args.TicketInfo.AllKeys)
            {
                PassengerTicketDtoList.Add(new PassengerTicketDto()
                {
                    Name         = passengerName,
                    TicketNumber = args.TicketInfo[passengerName]
                });
            }
            server.IssueTicket(args.OutOrderId, PassengerTicketDtoList, "");
        }
Ejemplo n.º 8
0
        public Issue BeforeUpdate(IssueEventArgs args)
        {
            var resources = args.Entity.GetResources();

            var watchers = args.Entity.GetWatchers();

            var missingResources = resources.FindAll(r => !watchers.Contains(r) && r != 0);

            if (missingResources.Count > 0)
            {
                args.Entity.AddWatchers(missingResources);
            }

            return(args.Entity);
        }
Ejemplo n.º 9
0
        public Issue BeforeUpdate(IssueEventArgs args)
        {
            // We have changed status
            if (args.Entity.StatusId != args.Previous.StatusId)
            {
                return(args.Entity);
            }

            var status = args.Context.Meta.StatusGet(args.Entity.StatusId);

            // Status not found? or not closed
            if (status == null || !status.IsFinal)
            {
                return(args.Entity);
            }

            // Set the status to open
            var project = args.Context.Projects.Get(args.Entity.ProjectId);

            if (project == null)
            {
                return(args.Entity);
            }

            var statuses = args.Context.Meta.StatusGet().FindAll(s => s.TemplateId == project.TemplateId);

            if (statuses.Count == 0)
            {
                return(args.Entity);
            }

            foreach (var s in statuses)
            {
                if (!s.IsFinal)
                {
                    args.Entity.StatusId = s.Id;
                    break;
                }
            }

            return(args.Entity);
        }
Ejemplo n.º 10
0
 public Issue BeforeWatcherAdd(IssueEventArgs args)
 {
     return(args.Entity);
 }
Ejemplo n.º 11
0
 public Issue BeforeClose(IssueEventArgs args)
 {
     return(args.Entity);
 }
Ejemplo n.º 12
0
 public Issue BeforeAssign(IssueEventArgs args)
 {
     return(args.Entity);
 }
Ejemplo n.º 13
0
 public Issue BeforeResolutionChange(IssueEventArgs args)
 {
     return(args.Entity);
 }
Ejemplo n.º 14
0
 public Issue BeforeStatusChange(IssueEventArgs args)
 {
     return(args.Entity);
 }
Ejemplo n.º 15
0
 public Issue BeforeDelete(IssueEventArgs args)
 {
     return(args.Entity);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// Shows the form as a modal dialog box.
        /// The form's buttons are shown according to possible actions taken from the given event argument.
        /// </summary>
        /// <param name="e">Event argument describing the type of a problem.</param>
        public void ShowModal(Control form, IssueEventArgs e)
        {
            if (e == null)
            {
                throw new ArgumentNullException("e");
            }

            // if the user chose to skip this problem type, skip it
            if (_skipProblemTypes.ContainsKey(e.IssueType))
            {
                if (e.IssueType == TransferIssueType.FileExists)
                {
                    e.Overwrite(_overwriteCondition);
                }
                else
                {
                    e.Skip();
                }
                return;
            }

            // if the problem is FileExists check, whether the user have chosen any default action already
            if (e.IssueType == TransferIssueType.FileExists)
            {
                // format the text according to action in progress (Downloading or Uploading)
                string messageFormat = "Overwrite file: {0}\n\t{1} Bytes, {2}\n\nwith file: {3}\n\t{4} Bytes, {5}";
                if (e.Action == FileTransferType.Downloading)
                {
                    lblMessage.Text = string.Format(messageFormat,
                                                    e.LocalPath, e.LocalItem.Length, e.LocalItem.LastWriteTime,
                                                    e.RemotePath, e.RemoteItem.Length, e.RemoteItem.LastWriteTime);
                }
                else
                {
                    lblMessage.Text = string.Format(messageFormat,
                                                    e.RemotePath, e.RemoteItem.Length, e.RemoteItem.LastWriteTime,
                                                    e.LocalPath, e.LocalItem.Length, e.LocalItem.LastWriteTime);
                }

                lblMessage.TextAlign = ContentAlignment.MiddleLeft;
                this.Text            = "Target file already exists";
            }
            else
            {
                lblMessage.Text      = e.Exception.Message;
                lblMessage.TextAlign = ContentAlignment.MiddleCenter;
            }

            // store the event arguments for later use at button click handler
            _arguments = e;

            // only enable buttons that represent a possible action
            cancelBtn.Enabled                = e.IsReactionPossible(FileTransferIssueReaction.Cancel);
            btnSkip.Enabled                  = e.IsReactionPossible(FileTransferIssueReaction.Skip);
            retryBtn.Enabled                 = e.IsReactionPossible(FileTransferIssueReaction.Retry);
            btnRename.Enabled                = e.IsReactionPossible(FileTransferIssueReaction.Rename);
            btnOverwrite.Enabled             = e.IsReactionPossible(FileTransferIssueReaction.Overwrite);
            btnOverwriteOlder.Enabled        = e.IsReactionPossible(FileTransferIssueReaction.Overwrite);
            btnOverwriteDiffSize.Enabled     = e.IsReactionPossible(FileTransferIssueReaction.Overwrite);
            btnOverwriteDiffChecksum.Enabled = e.IsOverwriteConditionPossible(FileOverwriteCondition.ChecksumDiffers);
            btnFollowLink.Enabled            = e.IsReactionPossible(FileTransferIssueReaction.FollowLink);
            btnResume.Enabled                = e.IsReactionPossible(FileTransferIssueReaction.Resume);

            // select default action button
            SetDefaultActionButton(e);

            ShowDialog(form);
        }