Exemplo n.º 1
0
        /// <summary>
        /// 不包含parse field
        /// </summary>
        internal void Parse()
        {
            Dependents.Clear();
            Summarys.Clear();
            Fields.Clear();
            List <List <Line> > fields = ParseFieldLine(ParseMsgElement());

            foreach (List <Line> list in fields)
            {
                ProtoBufferField field = new ProtoBufferField(this, list);
                Fields.Add(field);
            }
        }
Exemplo n.º 2
0
        internal void Parse()
        {
            Summarys.Clear();
            List <Line> list = new List <Line>();

            foreach (Line line in Lines)
            {
                if (line.Content.StartsWith("//"))
                {
                    if (line.Content.Length > 2)
                    {
                        Summarys.Add(line.Content.Substring(2).Trim());
                    }
                }
                else
                {
                    list.Add(line);
                }
            }
            ParseInfos(list);

            foreach (ProtoBufferField field in Message.Fields)
            {
                if (Equals(field))
                {
                    continue;
                }
                if (field.FieldNumber == FieldNumber)
                {
                    throw new ProtoBufferException(string.Format("在文件名{0},message:{1},FieldNumber:{2}重复。{3}", Message.File.FileName, Message.Name, FieldNumber, list[0].ToString()));
                }
                if (Name.Equals(field.Name))
                {
                    throw new ProtoBufferException(string.Format("在文件名{0},message:{1},名称{2}重复,FieldNumber:{3}。{4}", Message.File.FileName, Message.Name, Name, FieldNumber, list[0].ToString()));
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 移除msg想关信息,只留下field相关信息
        /// </summary>
        /// <returns></returns>
        private List <Line> ParseMsgElement()
        {
            List <Line> lines = new List <Line>();

            bool hasBegin = false;

            foreach (Line line in Lines)
            {
                if (hasBegin)
                {
                    if (line.Content.StartsWith("}"))
                    {
                        hasBegin = false;
                    }
                    else
                    {
                        lines.Add(line);
                    }
                }
                else
                {
                    if (line.Content.StartsWith("//"))
                    {
                        if (line.Content.Length > 2)
                        {
                            Summarys.Add(line.Content.Substring(2).Trim());
                        }
                    }

                    if (line.Content.Contains("{"))
                    {
                        //msg type and begin
                        string[] strings = line.Content.Split(new string[] { " ", "{" }, StringSplitOptions.RemoveEmptyEntries);
                        if (strings.Length != 2)
                        {
                            throw new ProtoBufferException(string.Format("message 解析出错:{0}", line.ToString()));
                        }
                        if (strings[0].Equals("message"))
                        {
                            DataType = DataType.Class;
                            Name     = strings[1];
                            hasBegin = true;
                        }
                        else if (strings[0].Equals("enum"))
                        {
                            DataType = DataType.Enum;
                            Name     = strings[1];
                            hasBegin = true;
                        }
                        else
                        {
                            throw new ProtoBufferException(string.Format("message 解析出错:{0}", line.ToString()));
                        }

                        for (int i = 0; i < Name.Length; i++)
                        {
                            if (i == 0)
                            {
                                if (!Char.IsUpper(Name[i]))
                                {
                                    throw new ProtoBufferException(string.Format("Message命名不正确,第一个字母必须是大写。{0}", line.ToString()));
                                }
                            }
                            else
                            {
                                if (!Char.IsLetter(Name[i]))
                                {
                                    throw new ProtoBufferException(string.Format("Message命名不正确,出现了非字母字符。{0}", line.ToString()));
                                }
                            }
                        }
                    }
                }
            }

            if (hasBegin)
            {
                throw new ProtoBufferException("message 只有开头没有结尾");
            }
            return(lines);
        }
Exemplo n.º 4
0
        public async void RatingData()
        {
            try
            {
                //ma7taga job apllicantid sha8al
                Summarys = await summaryapi.Getjobsummary(URLConfig.Getjobsummary);

                if (Summarys == null || Summarys.Count == 0)
                {
                    return;
                }
                else
                {
                    Summarybind = Summarys.FirstOrDefault();
                    DataBind    = new List <JobDataModel>();
                    DataBind.Add(Summarybind);
                    foreach (var item in DataBind)
                    {
                        Location             = item.addressDescription + " / " + item.Distance + "MI";
                        Jobtitle             = item.jobTitle + " / " + item.JobRefrence;
                        item.AmPmPropsatrt   = item.startDate.ToString("hh:mm tt ");
                        item.AmPmPropend     = item.endDate.ToString("hh:mm tt");
                        item.hourpropend     = item.endDate.Hour.ToString();
                        item.startdatestring = item.daypropstart + item.monthpropstart;
                        item.enddatestring   = item.daypropend + item.monthpropend;
                        item.startTime       = item.AmPmPropsatrt;
                        item.endTime         = item.AmPmPropend;
                        item.monthpropstart  = item.startDate.ToString("MMM");
                        item.monthpropend    = item.endDate.ToString("MMM");
                        item.daypropstart    = item.startDate.Day.ToString();
                        item.daypropend      = item.endDate.Day.ToString();
                        item.hourpropsart    = item.startDate.Hour.ToString();
                        Jobtype        = item.JobType;
                        Date           = item.startdatestring + " - " + item.enddatestring + ", " + item.startTime + " - " + item.endTime;
                        Id             = item.JobId;
                        JobApplicantId = item.Id;
                        MinRate        = item.minHrRate;
                        if (item.HasParking == true)
                        {
                            Hasparking = "No";
                        }
                        else if (item.HasParking == false)
                        {
                            Hasparking = "Yes";
                        }
                        if (item.HasPublicTransportation == true)
                        {
                            Haspublictrasnportion = "Yes";
                        }
                        else if (item.HasPublicTransportation == false)
                        {
                            Haspublictrasnportion = "No";
                        }
                    }
                }

                int ratingemployee = Convert.ToInt32(Rater.Employee);

                var emptorateid = Summarys.FirstOrDefault().employerProfileId;
                Rating = await apirate.GetRatingQuestion(URLConfig.GetRatingQuestion, emptorateid);

                Label1 = Rating.Where(x => x.id == "1").FirstOrDefault().question;
                ID1    = Rating.Where(x => x.id == "1").FirstOrDefault().id;
                Label2 = Rating.Where(x => x.id == "2").FirstOrDefault().question;
                ID2    = Rating.Where(x => x.id == "2").FirstOrDefault().id;
                Label3 = Rating.Where(x => x.id == "3").FirstOrDefault().question;
                ID3    = Rating.Where(x => x.id == "3").FirstOrDefault().id;
                Label4 = Rating.Where(x => x.id == "4").FirstOrDefault().question;
                ID4    = Rating.Where(x => x.id == "4").FirstOrDefault().id;
                Label5 = Rating.Where(x => x.id == "5").FirstOrDefault().question;
                ID5    = Rating.Where(x => x.id == "5").FirstOrDefault().id;
                Label6 = Rating.Where(x => x.id == "11").FirstOrDefault().question;
                ID6    = Rating.Where(x => x.id == "11").FirstOrDefault().id;
            }
            catch (Exception ex)
            {
                var logged = new LoggedException.LoggedException("Error in ratingviewmodel", ex);
                await logged.LoggAPI();
            }
        }