当前位置: 首页>>代码示例>>C#>>正文


C# TaskItem.SetFogbugzCaseId方法代码示例

本文整理汇总了C#中TaskItem.SetFogbugzCaseId方法的典型用法代码示例。如果您正苦于以下问题:C# TaskItem.SetFogbugzCaseId方法的具体用法?C# TaskItem.SetFogbugzCaseId怎么用?C# TaskItem.SetFogbugzCaseId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TaskItem的用法示例。


在下文中一共展示了TaskItem.SetFogbugzCaseId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: SyncTask

        public void SyncTask(Case fogbugzCase, TaskItem outlookTask)
        {
            try
            {
                //Associate the case and task
                outlookTask.SetFogbugzCaseId(fogbugzCase.CaseId);
                Log.DebugFormat("Setting task metadata case id to {0}", fogbugzCase.CaseId);

                var subjectWithCaseId = fogbugzCase.GetTitleWithCaseToken();

                var taskNewer = false;

                //Determine which is newer
                var taskLastModified = outlookTask.GetLastModifiedDate();
                if (taskLastModified != null && taskLastModified > fogbugzCase.LastUpdated)
                    taskNewer = true;

                Log.DebugFormat("Fogbugz case last update: {0}", fogbugzCase.LastUpdated);
                Log.DebugFormat("Outlook task last update: {0}", taskLastModified);

                if (taskNewer)
                {
                    Log.Debug("Task is newer than the fogbugz case");

                    fogbugzCase.PercentComplete = outlookTask.PercentComplete;
                    fogbugzCase.Subject = outlookTask.Subject;
                    if (outlookTask.DueDate != OutlookConnector.EmptyDate)
                    {
                        if (fogbugzCase.Due != null && fogbugzCase.Due.Value.Date == outlookTask.DueDate.Date)
                        {
                            //Don't update fogbugz in this case, because we'll only be dropping the time component.
                            //In other words, the fogbugz due date will be reset to midnight since Outlook doesn't store the time.
                        }
                        else
                        {
                            fogbugzCase.Due = outlookTask.DueDate;
                        }
                    }

                    //Not sure how to translate priorities back to fogbugz
                }
                else
                {
                    Log.Debug("Fogbugz case is newer than the task");

                    outlookTask.PercentComplete = fogbugzCase.PercentComplete;
                    outlookTask.Subject = subjectWithCaseId;

                    if (fogbugzCase.Due != null)
                    {
                        outlookTask.DueDate = fogbugzCase.Due.Value;

                        //Only populate the start date if there is a due date, otherwise
                        //the task will have a due date the same as the start (stupid)
                        outlookTask.StartDate = fogbugzCase.Opened;
                    }

                    if (fogbugzCase.Priority == 1 || fogbugzCase.Priority == 2)
                        outlookTask.Importance = OlImportance.olImportanceHigh;
                    else if (fogbugzCase.Priority == 4 || fogbugzCase.Priority == 5 || fogbugzCase.Priority == 6)
                        outlookTask.Importance = OlImportance.olImportanceLow;
                    else
                        outlookTask.Importance = OlImportance.olImportanceNormal;
                }

                var tokens = new List<KeyValuePair<string, string>>
                    {
                        //Note; tokens must be lower case
                        new KeyValuePair<string, string>("caseid", fogbugzCase.CaseId.ToString()),
                        new KeyValuePair<string, string>("emailsubject", Uri.EscapeUriString(subjectWithCaseId))
                    };

                outlookTask.RTFBody = Encoding.ASCII.GetBytes(GenerateTaskBody(tokens));
            }
            catch (Exception ex)
            {
                if(fogbugzCase != null)
                        Log.Info(fogbugzCase.ToString());
                if(outlookTask != null)
                        Log.Info(outlookTask.ToString());

                Log.Error("Error synchronizing tasks", ex);
                throw;
            }
        }
开发者ID:kingofzeal,项目名称:outlook-fogbugz,代码行数:85,代码来源:TaskSync.cs


注:本文中的TaskItem.SetFogbugzCaseId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。