Example #1
0
        public List <NameClass> GetSortedNames(string[] unsortedNames)
        {
            try
            {
                List <NameClass> unsortedSplitNames = new List <NameClass>();

                //string[] unsortedNamesNew = new string[unsortedNames.Count()];
                //int i = 0;
                foreach (var name in unsortedNames)
                {
                    var splitNames = StringHelper.SplitString(name);
                    var lastName   = splitNames[splitNames.Length - 1];
                    var givenName  = name.Replace(" " + lastName, "");

                    //unsortedNamesNew[i++] = givenName + " " + lastName;

                    var nameClass = new NameClass {
                        GivenName = givenName, LastName = lastName
                    };

                    unsortedSplitNames.Add(nameClass);
                }



                var sortedNames = unsortedSplitNames.OrderBy(c => c.LastName).ThenBy(c => c.GivenName).ToList <NameClass>();

                return(sortedNames);
            }
            catch (Exception ex)
            {
                // logger here
                return(null);
            }
        }
        // reads <except> clause if if exists. Otherwise returns null.
        // This method skips any foreign elements.
        protected virtual NameClass ReadExceptName()
        {
            NameClass nc = null;

            if (ReadStartElement())
            {
                while (SkipForeignElements())
                {
                    if (reader.LocalName == "except")
                    {
                        if (nc != null)
                        {
                            // error: multiple except
                            ReportError(ERR_MULTIPLE_EXCEPT);
                        }
                        nc = ChoiceName();
                    }
                    else
                    {
                        // error: unexpected elements
                        ReportError(ERR_EXCEPT_EXPECTED, reader.Name);
                        reader.Skip();
                    }
                }
                ReadEndElement();
            }
            return(nc);         // return null if <except> was not found.
        }
        private void Button_Click_1(object sender, RoutedEventArgs e)//文件保存
        {
            NameClass nameClass = FileName.SelectedItem as NameClass;
            ListClass listClass = FileList.SelectedItem as ListClass;

            if (listClass == null)
            {
                System.Windows.MessageBox.Show("未选中版本。", "错误");
                return;
            }
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.Title            = "默认保存到系统桌面";
            sfd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
            sfd.FileName         = nameClass.fileName;
            string ex = sfd.FileName.Substring(sfd.FileName.LastIndexOf("."));

            sfd.Filter = "文件| *" + ex;
            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                try
                {
                    File.Copy(listClass.fileFullName, sfd.FileName);
                }
                catch
                {
                    System.Windows.MessageBox.Show("文件下载失败,该文件夹下已存在该文件!");
                }
            }
        }
Example #4
0
        // GET api/values
        public object Get(CCRequestModel request)
        {
            var name = new NameClass();

            name.name = "Bob";
            return(name);
        }
        // XmlReader is on a start tag. Parses it and returns the result.
        protected virtual NameClass ReadNameClass()
        {
            if (SkipForeignElements())
            {
                Trace.WriteLine("dispatching NC: " + reader.LocalName);

                NCReader ncreader = (NCReader)NCReaders[reader.LocalName];
                if (ncreader == null)
                {
                    // error: unknown element name
                    ReportError(ERR_NAMECLASS_EXPECTED, reader.Name);
                    reader.Skip();
                    return(new SimpleNameClass("foo", "bar"));                  // recover
                }

                Trace.Indent();
                NameClass nc = ncreader();              // dispatch the reader.
                Trace.Unindent();
                return(nc);
            }
            else
            {
                // there is no child element
                ReportError(ERR_MISSING_ATTRIBUTE, reader.Name, "name");
                return(AnyNameClass.theInstance);
            }
        }
        private List <NameClass> Read(string path)//文件列表读取
        {
            DirectoryInfo    di  = new DirectoryInfo(path);
            List <NameClass> tds = new List <NameClass>();

            if (di.Exists)                                          //检查文件夹是否存在
            {
                FileSystemInfo[] syslist = di.GetFileSystemInfos(); //获取文件夹系统信息
                foreach (FileSystemInfo items in syslist)           //对于每个子项
                {
                    if (items is FileInfo)
                    {
                        if (items.Name.Contains(App.r.Match(items.Name).ToString()) && App.r.Match(items.Name).ToString() != "")//如果包含成对的{},则
                        {
                            var xname = new NameClass()
                            {
                                fileName = items.Name.Replace(App.r.Match(items.Name).ToString(), "")
                            };
                            tds.Add(xname);
                        }
                        if (App.r.Match(items.Name).ToString() == "")
                        {
                            FileInfo fileInfo = new FileInfo(items.FullName);
                            fileInfo.MoveTo(App.workPath + "\\" + App.sex + "100" + App.eex + items.Name);
                        }
                    }
                }
            }
            //tds.Sort();
            var list_distinct = tds.GroupBy(c => c.fileName).Select(c => c.First()).ToList();//去重

            return(list_distinct);
        }
Example #7
0
		internal override void CheckConstraints () 
		{
			NameClass.CheckConstraints (false, false);

			foreach (RelaxngPattern p in Patterns)
				p.CheckConstraints ();
		}
        protected virtual NameClass ChoiceName()
        {
            NameClass nc = null;

            if (ReadStartElement())
            {
                while (SkipForeignElements())
                {
                    NameClass child = ReadNameClass();
                    if (nc == null)
                    {
                        nc = child;
                    }
                    else
                    {
                        nc = new ChoiceNameClass(nc, child);
                    }
                }
                ReadEndElement();
            }
            if (nc == null)
            {
                // error: no children
                ReportError(ERR_NO_CHILD_NAMECLASS);
                nc = new SimpleNameClass("foo", "bar");         // recover
            }
            return(nc);
        }
Example #9
0
		internal override void CheckConstraints () 
		{
			NameClass.CheckConstraints (false, false);

			if (p != null)
				p.CheckConstraints ();
		}
Example #10
0
        ////// GET api/values/5
        //public CCResponseModel Get(CCRequestModel request)
        //{
        //    return new CCResponseModel(5,"Testing", 'y', true);
        //}


        // POST api/values
        /// <summary>
        /// Post a request to the service and generate a response
        /// </summary>
        /// <param name="request">A string containing the request</param>
        /// <returns></returns>
        public object Post([FromBody] CCRequestModel request)
        {
            string response = "";

            try
            {
                //response.text = request.request;
                if (request.MsgId == 1)
                {
                    var name = new NameClass();
                    name.name = "Bob";

                    return(name);
                }
                if (request.MsgId == 2)
                {
                    var radarResult = JsonConvert.DeserializeObject <dynamic>(request.MsgData);

                    var myLocation    = radarResult.yourLocation;
                    var enemyLocation = radarResult.enemies[0].location;


                    var commandList = new List <CommandClass>();
                    var command     = new CommandClass();

                    if (Math.Abs(FindRotationalToEnemy(radarResult)) > 15)
                    {
                        BuildCommandList(ref commandList, (int)Commands.RotateLeft, 100);
                    }
                    else
                    {
                        BuildCommandList(ref commandList, (int)Commands.FireShell, 200);
                        BuildCommandList(ref commandList, (int)Commands.FireShell, 200);
                        BuildCommandList(ref commandList, (int)Commands.FireShell, 200);
                        //   BuildCommandList(ref commandList, (int)Commands.RotateRight, 200);
                        if (FindDistance(radarResult) > 20)
                        {
                            BuildCommandList(ref commandList, (int)Commands.MoveForward, 500);
                        }
                        else
                        {
                            BuildCommandList(ref commandList, (int)Commands.MoveBackwards, 600);
                        }
                    }
                    return(commandList);
                }
            }
            catch (Exception ex)
            {
                return(ex);
            }
            return(response);
        }
Example #11
0
        public void WhereObjectMethodParameterless()
        {
            Scheduling.RunTask(() =>
            {
                var nameInstance = new NameClass();

                var persons = Objects <Person>().Where(p => p.Name == nameInstance.GetName()).ToList();

                Assert.Equal(1, persons.Count);
                Assert.Equal("Anton", persons.First().Name);
            }).Wait();
        }
        protected virtual Expression Element()
        {
            bool      isEmpty;
            NameClass nc = ReadNameClassOrNameAttr(false, out isEmpty);

            if (isEmpty)
            {
                ReportError(ERR_EXPRESSION_EXPECTED);
                return(Expression.NotAllowed);
            }
            Expression contents = ReadChildExps(new ExpCombinator(Builder.CreateSequence));

            return(new ElementExp(nc, contents));
        }
        private void Button_Click(object sender, RoutedEventArgs e)//文件删除
        {
            NameClass nameClass = FileName.SelectedItem as NameClass;
            ListClass listClass = FileList.SelectedItem as ListClass;

            if (nameClass == null)
            {
                return;
            }
            if (listClass == null)
            {
                System.Windows.MessageBox.Show("未选中版本。", "删除错误。", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            FileDel(listClass.fileFullName, nameClass.fileName, listClass.fileVersion);
        }
        private void FileList_Drop(object sender, System.Windows.DragEventArgs e)//添加版本
        {
            string fileNam = ((Array)e.Data.GetData(System.Windows.DataFormats.FileDrop)).GetValue(0).ToString();

            try
            {
                NameClass nameClass = FileName.SelectedItem as NameClass;
                if (nameClass == null)
                {
                    MainWindow.ReName(fileNam, "", true);
                    Rfs_Click(null, null);
                }
                else
                {
                    MessageBoxResult result = System.Windows.MessageBox.Show("你确认将" + "\n" + "->文件:" + fileNam + "," + "\n" + "->添" +
                                                                             "加到:" + nameClass.fileName + "\n" + "的新版本吗?", "添加文件版本" +
                                                                             "确认框", MessageBoxButton.OKCancel);
                    if (result == MessageBoxResult.OK)
                    {
                        FileAsk fileAsk = new FileAsk(fileNam);
                        if (fileAsk.ShowDialog() == true)
                        {
                            if (fileAsk.Fmsg == 100)
                            {
                                MainWindow.OP_ReName(fileNam, nameClass.fileName, false, 100);
                                Rfs_Click(null, null);
                            }
                            if (fileAsk.Fmsg == 10)
                            {
                                MainWindow.OP_ReName(fileNam, nameClass.fileName, false, 10);
                                Rfs_Click(null, null);
                            }
                            if (fileAsk.Fmsg == 1)
                            {
                                MainWindow.OP_ReName(fileNam, nameClass.fileName, false, 1);
                                Rfs_Click(null, null);
                            }
                        }
                    }
                }
            }
            catch (Exception r)
            {
                System.Windows.MessageBox.Show("文件复制失败,请尝试重命名文件或重启软件。" + r.ToString(), "来自:文件版本管理");
            }
        }
        protected virtual Expression Attribute()
        {
            bool       isEmpty;
            NameClass  nc       = ReadNameClassOrNameAttr(true, out isEmpty);
            Expression contents = Expression.Text;

            if (!isEmpty)
            {
                if (SkipForeignElements())
                {
                    contents = ReadChildExps(new ExpCombinator(Builder.CreateSequence));
                }
                else
                {
                    // no child pattern. defaults to <text/>
                    ReadEndElement();
                }
            }
            return(new AttributeExp(nc, contents));
        }
        private void FileName_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            NameClass nameClass = FileName.SelectedItem as NameClass;

            if (nameClass == null)
            {
                FileList.ItemsSource = null;
                return;
            }
            List <ListClass> x        = ReRead(App.workPath, nameClass.fileName.ToString());
            ICollectionView  dataView = CollectionViewSource.GetDefaultView(x);

            dataView.SortDescriptions.Clear();
            SortDescription sd = new SortDescription("fileVersion", ListSortDirection.Descending);

            dataView.SortDescriptions.Add(sd);
            FileList.ItemsSource   = dataView;
            FileList.SelectedIndex = 0;
            msg.Content            = "该文件共有“" + x.Count + "”个版本。";
            FileList.Focus();
        }
 private void Button_Click_5(object sender, RoutedEventArgs e)//重命名
 {
     try
     {
         NameClass nameClass = FileName.SelectedItem as NameClass;
         Input     input     = new Input(nameClass.fileName);
         if (input.ShowDialog() == true)
         {
             string order = input.Tmsg;
             if (nameClass.fileName == order)
             {
                 return;
             }
             if (order.Contains("{第") || order.Contains("版}"))
             {
                 System.Windows.MessageBox.Show("与已知文件版本识别符冲突,请重新命名!");
                 return;
             }
             ;
             List <ListClass> x = ReRead(App.workPath, nameClass.fileName.ToString()) as List <ListClass>;
             foreach (ListClass listClass in x)
             {
                 string s       = (App.r.Match(listClass.fileFullName.Substring(listClass.fileFullName.LastIndexOf("\\") + 1)).ToString()); //版本号
                 string oldpath = listClass.fileFullName;
                 string newpath = listClass.fileFullName.Replace(s, "").Replace(nameClass.fileName, order);                                 //截取原来的名字
                 string ex      = order.Substring(order.LastIndexOf("."));
                 string newName = newpath.Replace(ex, "") + s + ex;                                                                         //新文件名
                 File.Move(oldpath, newName);
             }
             Rfs_Click(null, null);
         }
     }
     catch (Exception r)
     {
         System.Windows.MessageBox.Show("文件重命名失败" + "\n" +
                                        "请尝试重启软件。" + r.ToString(), "文件重命名");
     }
 }
Example #18
0
        public Name(XElement name)
        {
            _name = name;
            XAttribute isNull    = name.Attribute("IsNull");
            XAttribute nameClass = name.Attribute("Class");

            if (isNull == null && nameClass != null)
            {
                switch (nameClass.Value)
                {
                case "NameSingle":
                    _nameClass = NameClass.NameSingle;
                    break;

                case "NameTriple":
                    _nameClass = NameClass.NameTriple;
                    break;
                }
            }
            else
            {
                _nameClass = NameClass.Null;
            }
        }
 public AnyNameClass( NameClass except )
 {
     this.except = except;
 }
 public ChoiceNameClass( NameClass nc1, NameClass nc2 )
 {
     this.nc1=nc1;
     this.nc2=nc2;
 }
Example #21
0
 public NsNameClass(string uri, NameClass except)
 {
     this.uri    = uri;
     this.except = except;
 }
 public NsNameClass( string uri, NameClass except )
 {
     this.uri = uri;
     this.except = except;
 }
Example #23
0
 protected internal ElementExp(NameClass name, Expression contentModel)
     : base(name, contentModel, HASH_ELEMENT)
 {
 }
Example #24
0
 public AnyNameClass(NameClass except)
 {
     this.except = except;
 }
Example #25
0
 internal XmlItemExp(NameClass nc, Expression contentModel, int opCode)
     : base(contentModel, opCode, false)
 {
     this.Name = nc;
 }
Example #26
0
 protected internal AttributeExp(NameClass name, Expression contentModel)
     : base(name, contentModel, HASH_ATTRIBUTE)
 {
 }
Example #27
0
        public static void BeforeLogLineRead(bool isImport, Advanced_Combat_Tracker.LogLineEventArgs logInfo)
        {
            string l = logInfo.logLine;

            try
            {
                DateTime timestamp = ParseLogDateTime(l);

                char[]   dt       = { '\t' };
                string[] logParts = l.Split(dt);
                int      flag     = Convert.ToInt32(logParts[2], 16);
                if (flag > 7)
                {
                    return;
                }

                l = logParts[7];

                Match m;

                // open
                m = regex_open.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    encounter = target;
                    Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, encounter, encounter);
                    // DQX_ACT_Plugin.LogParserMessage("Open: "+target);
                    NameClass.Clear();
                    return;
                }

                // close
                m = regex_close.Match(l);
                if (m.Success)
                {
                    // Advanced_Combat_Tracker.ActGlobals.oFormActMain.ChangeZone("test");
                    Advanced_Combat_Tracker.ActGlobals.oFormActMain.EndCombat(true);
                    // DQX_ACT_Plugin.LogParserMessage("Close: ");
                    return;
                }

                // action
                if (!l.StartsWith(" →"))
                {
                    m = regex_action.Match(l);
                    if (m.Success)
                    {
                        actor  = m.Groups["actor"].Success ? DecodeString(m.Groups["actor"].Value) : "";
                        action = m.Groups["action"].Success ? DecodeString(m.Groups["action"].Value) : "";
                        if (!NameClass.ContainsKey(actor))
                        {
                            if (SkillClass.ContainsKey(action))
                            {
                                NameClass.Add(actor, SkillClass[action]);
                            }
                        }
                        return;
                    }
                    m = regex_action2.Match(l);
                    if (m.Success)
                    {
                        actor  = "不明";
                        action = m.Groups["action"].Success ? DecodeString(m.Groups["action"].Value) : "";
                        return;
                    }

                    // death
                    m = regex_dead2.Match(l);
                    if (m.Success)
                    {
                        string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                            false,
                            "",
                            "不明",
                            "Death",
                            Advanced_Combat_Tracker.Dnum.Death,
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            target,
                            "");
                        return;
                    }
                    return;
                }

                if (!Advanced_Combat_Tracker.ActGlobals.oFormActMain.InCombat)
                {
                    return;
                }

                // crit
                m = regex_crit.Match(l);
                if (m.Success)
                {
                    isCritical = true;
                    return;
                }

                // damage
                m = regex_hit.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";

                    // if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        MasterSwing ms = new MasterSwing(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.NonMelee,
                            isCritical,
                            "",
                            new Advanced_Combat_Tracker.Dnum(int.Parse(m.Groups["damage"].Value, System.Globalization.NumberStyles.AllowThousands)),
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            action,
                            actor,
                            "",
                            target);

                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(ms);

                        var e = false;
                        foreach (var a in Allies)
                        {
                            if (a.Name == ms.Attacker)
                            {
                                e = true;
                                break;
                            }
                        }
                        if (ms.Attacker == encounter)
                        {
                            e = true;
                        }
                        if (!e)
                        {
                            CombatantData cd = ms.ParentEncounter.GetCombatant(ms.Attacker);
                            Allies.Add(cd);
                        }
                        ms.ParentEncounter.SetAllies(Allies);
                    }

                    isCritical = false;
                    return;
                }

                // miss
                m = regex_miss.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";

                    //          if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.NonMelee,
                            isCritical,
                            "",
                            actor,
                            action,
                            Advanced_Combat_Tracker.Dnum.Miss,
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            target,
                            "");
                    }
                    isCritical = false;
                    return;
                }

                // heal
                m = regex_heal.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";

                    //          if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        MasterSwing ms = new MasterSwing(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                            isCritical,
                            "",
                            new Advanced_Combat_Tracker.Dnum(int.Parse(m.Groups["damage"].Value, System.Globalization.NumberStyles.AllowThousands)),
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            action,
                            actor,
                            "",
                            target);

                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(ms);

                        var e = false;
                        foreach (var a in Allies)
                        {
                            if (a.Name == ms.Attacker)
                            {
                                e = true;
                                break;
                            }
                        }
                        if (ms.Attacker == encounter)
                        {
                            e = true;
                        }
                        if (!e)
                        {
                            CombatantData cd = ms.ParentEncounter.GetCombatant(ms.Attacker);
                            Allies.Add(cd);
                        }
                        ms.ParentEncounter.SetAllies(Allies);
                    }

                    isCritical = false;
                    return;
                }

                // death
                m = regex_dead.Match(l);
                if (m.Success)
                {
                    string target = m.Groups["target"].Success ? DecodeString(m.Groups["target"].Value) : "";
                    //          if (Advanced_Combat_Tracker.ActGlobals.oFormActMain.SetEncounter(timestamp, actor, encounter))
                    {
                        Advanced_Combat_Tracker.ActGlobals.oFormActMain.AddCombatAction(
                            (int)Advanced_Combat_Tracker.SwingTypeEnum.Healing,
                            isCritical,
                            "",
                            actor,
                            "Death",
                            Advanced_Combat_Tracker.Dnum.Death,
                            timestamp,
                            Advanced_Combat_Tracker.ActGlobals.oFormActMain.GlobalTimeSorter,
                            target,
                            "");
                    }
                    isCritical = false;
                    return;
                }
            }
            catch (Exception ex)
            {
                string exception = ex.ToString().Replace(Environment.NewLine, " ");
                if (ex.InnerException != null)
                {
                    exception += " " + ex.InnerException.ToString().Replace(Environment.NewLine, " ");
                }

                DQX_ACT_Plugin.LogParserMessage("Error [LogParse.BeforeLogLineRead] " + exception + " " + logInfo.logLine);
            }

            // For debugging
            // if (!string.IsNullOrWhiteSpace(l))
            //   DQX_ACT_Plugin.LogParserMessage("Unhandled Line: " + logInfo.logLine);
        }
Example #28
0
 public int CreateProject(NameClass Name)
 {
     return(dataManager.CreateProject(Name.Name));
 }
Example #29
0
 public ChoiceNameClass(NameClass nc1, NameClass nc2)
 {
     this.nc1 = nc1;
     this.nc2 = nc2;
 }