Example #1
0
 public static SVNModel AddModel(SVNModel m1, SVNModel m2)
 {
     m2.AddAdd(m1.Add);
     m2.AddDeleted(m1.Deleted);
     m2.AddModified(m1.Modified);
     return(m2);
 }
 public static SVNModel AddModel(SVNModel m1, SVNModel m2)
 {
     m2.AddAdd(m1.Add);
     m2.AddDeleted(m1.Deleted);            
     m2.AddModified(m1.Modified);
     return m2;
 }
        private void PublishTimeLine(SVNModel model, string name)
        {
            var title   = string.Format("{0} gained SVN Points!", name);
            var content = FormatModelContentToTimeline(model);

            TimeLine.PublishFeed(TimeLineIcon.Success, title, content);
        }
 public static SVNModel AddAction(string Action, SVNModel model)
 {
     switch (Action)
     {
         case "M":
             model.AddModified(1);
             break;
         case "A":
             model.AddAdd(1);
             break;
         case "D":
             model.AddDeleted(1);
             break;
         default:
             break;
     }
     return model;
 }
        private string FormatModelContentToTimeline(SVNModel model)
        {
            log.Info("Formating svn model to str");
            var builder = new StringBuilder();

            builder.AppendFormat("Gained {0} experience Points\n", (model.Modified + model.Add + model.Deleted));
            if (model.Add != 0)
            {
                builder.AppendFormat("Add {0} files\n", model.Add);
            }
            if (model.Deleted != 0)
            {
                builder.AppendFormat("Modified {0} files\n", model.Modified);
            }
            if (model.Modified != 0)
            {
                builder.AppendFormat("Deleted {0} files\n", model.Deleted);
            }
            return(builder.ToString());
        }
Example #6
0
        public static SVNModel AddAction(string Action, SVNModel model)
        {
            switch (Action)
            {
            case "M":
                model.AddModified(1);
                break;

            case "A":
                model.AddAdd(1);
                break;

            case "D":
                model.AddDeleted(1);
                break;

            default:
                break;
            }
            return(model);
        }
 public void AddModel(SVNModel model)
 {
     AddExperience(model.Add);
     AddExperience(model.Deleted);
     AddExperience(model.Modified);
 }
        public List<IUser> Read(string xmlPath)
        {
            log.InfoFormat("Reading svn : {0}", xmlPath);
            if (string.IsNullOrWhiteSpace(xmlPath))
            {
                throw new ArgumentNullException("xmlPath");
            }
            var result = new List<IUser>();
            try
            {
                var results = new Stack<IUser>();                
                var svnModel = new SVNModel();
                var doc = new XmlDocument();
                var xpath = string.Format("//logentry[@revision>'{0}']/paths/path", CurrentRevision);
                var xpathMaximumCurrentRevision = "/log/logentry/@revision[not(. < ../../logentry/@revision)][1]";
                var userDict = new Dictionary<string, IUser>();
                IUser user = null;
                doc.Load(xmlPath);
                CurrentRevision = Convert.ToInt32(doc.SelectNodes(xpathMaximumCurrentRevision)[0].Value) + 1;
                foreach (XmlNode node in doc.SelectNodes(xpath))
                {
                    var currentUser = node.ParentNode.ParentNode.SelectSingleNode("author").InnerText;
                    var currentDate = node.ParentNode.ParentNode.SelectSingleNode("date").InnerText;
                    log.DebugFormat("current user : {0}", currentUser);
                    log.DebugFormat("currnet date : {0}", currentDate);
                    if (userDict.Keys.Count > 0)
                    {
                        if (userDict.Keys.Contains(currentUser))
                        {
                            user = userDict[currentUser];
                        }
                        else
                        {
                            user = new DefaultUser(currentUser);
                            userDict.Add(currentUser, user);
                        }
                    }
                    else
                    {
                        user = new DefaultUser(currentUser);
                        userDict.Add(currentUser, user);
                    }



                    if (!(user.ExtensionPoint.Keys.Count > 0))
                    {
                        user.ExtensionPoint.Add("LanguageExtension", new LanguageBuilder());
                        user.ExtensionPoint.Add("SVNExtension", new SVNModel());
                    }

                    var action = node.Attributes["action"].Value;
                    var kind = node.InnerText;
                    var modelLanguage = LanguageBuilder.TransformPathToLanguageModel(kind);
                    ((LanguageBuilder)user.ExtensionPoint["LanguageExtension"]).AddLanguage(modelLanguage);

                    Infos.Add(SVNBuilder.AddInfo(action, currentUser,
                        DateTime.ParseExact(currentDate, "yyyy-MM-ddTHH:mm:ss.ffffffZ", CultureInfo.InstalledUICulture)));
                    user.ExtensionPoint["SVNExtension"] = SVNBuilder.AddAction(action, ((SVNModel)user.ExtensionPoint["SVNExtension"]));
                }

                
                foreach (var key in userDict.Keys)
                {
                    result.Add(userDict[key]);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("Message : {0}", ex.Message);
                log.ErrorFormat("StackTrace : {0}", ex.StackTrace);                
                return result;
            }
            return result;
        }
 private string FormatModelContentToTimeline(SVNModel model)
 {
     log.Info("Formating svn model to str");
     var builder = new StringBuilder();
     builder.AppendFormat("Gained {0} experience Points\n", (model.Modified + model.Add + model.Deleted));
     if (model.Add != 0)
     {
         builder.AppendFormat("Add {0} files\n", model.Add);
     }
     if (model.Deleted != 0)
     {
         builder.AppendFormat("Modified {0} files\n", model.Modified);
     }
     if (model.Modified != 0)
     {
         builder.AppendFormat("Deleted {0} files\n", model.Deleted);
     }            
     return builder.ToString();
 }
 private void PublishTimeLine(SVNModel model, string name)
 {
     var title = string.Format("{0} gained SVN Points!", name);
     var content = FormatModelContentToTimeline(model);
     TimeLine.PublishFeed(TimeLineIcon.Success, title, content);
 }
Example #11
0
 public void AddModel(SVNModel model)
 {
     AddExperience(model.Add);
     AddExperience(model.Deleted);
     AddExperience(model.Modified);
 }
Example #12
0
        public List <IUser> Read(string xmlPath)
        {
            log.InfoFormat("Reading svn : {0}", xmlPath);
            if (string.IsNullOrWhiteSpace(xmlPath))
            {
                throw new ArgumentNullException("xmlPath");
            }
            var result = new List <IUser>();

            try
            {
                var   results  = new Stack <IUser>();
                var   svnModel = new SVNModel();
                var   doc      = new XmlDocument();
                var   xpath    = string.Format("//logentry[@revision>'{0}']/paths/path", CurrentRevision);
                var   xpathMaximumCurrentRevision = "/log/logentry/@revision[not(. < ../../logentry/@revision)][1]";
                var   userDict = new Dictionary <string, IUser>();
                IUser user     = null;
                doc.Load(xmlPath);
                CurrentRevision = Convert.ToInt32(doc.SelectNodes(xpathMaximumCurrentRevision)[0].Value) + 1;
                foreach (XmlNode node in doc.SelectNodes(xpath))
                {
                    var currentUser = node.ParentNode.ParentNode.SelectSingleNode("author").InnerText;
                    var currentDate = node.ParentNode.ParentNode.SelectSingleNode("date").InnerText;
                    log.DebugFormat("current user : {0}", currentUser);
                    log.DebugFormat("currnet date : {0}", currentDate);
                    if (userDict.Keys.Count > 0)
                    {
                        if (userDict.Keys.Contains(currentUser))
                        {
                            user = userDict[currentUser];
                        }
                        else
                        {
                            user = new DefaultUser(currentUser);
                            userDict.Add(currentUser, user);
                        }
                    }
                    else
                    {
                        user = new DefaultUser(currentUser);
                        userDict.Add(currentUser, user);
                    }



                    if (!(user.ExtensionPoint.Keys.Count > 0))
                    {
                        user.ExtensionPoint.Add("LanguageExtension", new LanguageBuilder());
                        user.ExtensionPoint.Add("SVNExtension", new SVNModel());
                    }

                    var action        = node.Attributes["action"].Value;
                    var kind          = node.InnerText;
                    var modelLanguage = LanguageBuilder.TransformPathToLanguageModel(kind);
                    ((LanguageBuilder)user.ExtensionPoint["LanguageExtension"]).AddLanguage(modelLanguage);

                    Infos.Add(SVNBuilder.AddInfo(action, currentUser,
                                                 DateTime.ParseExact(currentDate, "yyyy-MM-ddTHH:mm:ss.ffffffZ", CultureInfo.InstalledUICulture)));
                    user.ExtensionPoint["SVNExtension"] = SVNBuilder.AddAction(action, ((SVNModel)user.ExtensionPoint["SVNExtension"]));
                }


                foreach (var key in userDict.Keys)
                {
                    result.Add(userDict[key]);
                }
            }
            catch (Exception ex)
            {
                log.ErrorFormat("Message : {0}", ex.Message);
                log.ErrorFormat("StackTrace : {0}", ex.StackTrace);
                return(result);
            }
            return(result);
        }