Example #1
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode.Length != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (OppositeId.Length != 0)
            {
                hash ^= OppositeId.GetHashCode();
            }
            if (TimeToken.Length != 0)
            {
                hash ^= TimeToken.GetHashCode();
            }
            hash ^= lightStatus_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (OppositeId.Length != 0)
            {
                hash ^= OppositeId.GetHashCode();
            }
            if (ServerId != 0)
            {
                hash ^= ServerId.GetHashCode();
            }
            if (ResultCode != 0)
            {
                hash ^= ResultCode.GetHashCode();
            }
            if (TimeToken != 0UL)
            {
                hash ^= TimeToken.GetHashCode();
            }
            if (Memo.Length != 0)
            {
                hash ^= Memo.GetHashCode();
            }
            return(hash);
        }
Example #3
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode.Length != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (TimeToken.Length != 0)
            {
                hash ^= TimeToken.GetHashCode();
            }
            if (ResultCode != 0)
            {
                hash ^= ResultCode.GetHashCode();
            }
            if (ServerId != 0)
            {
                hash ^= ServerId.GetHashCode();
            }
            if (ServerIp.Length != 0)
            {
                hash ^= ServerIp.GetHashCode();
            }
            hash ^= lights_.GetHashCode();
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        public string CanApply(string type, string value, object context)
        {
            TimeToken token = new TimeToken(type, null, value, context);
            DateTime? date  = new TimeParser().Apply(new DateTime(2000, 1, 1), new[] { token });

            return(TestHelpers.GetRepresentation(date));
        }
Example #5
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode.Length != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (TimeToken.Length != 0)
            {
                hash ^= TimeToken.GetHashCode();
            }
            if (PhoneMac.Length != 0)
            {
                hash ^= PhoneMac.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #6
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (TimeToken.Length != 0)
            {
                hash ^= TimeToken.GetHashCode();
            }
            if (ResultCode != 0)
            {
                hash ^= ResultCode.GetHashCode();
            }
            if (ServerId != 0)
            {
                hash ^= ServerId.GetHashCode();
            }
            if (ServerIp.Length != 0)
            {
                hash ^= ServerIp.GetHashCode();
            }
            return(hash);
        }
Example #7
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode.Length != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (TimeToken.Length != 0)
            {
                hash ^= TimeToken.GetHashCode();
            }
            if (LightNo.Length != 0)
            {
                hash ^= LightNo.GetHashCode();
            }
            if (WaringCode.Length != 0)
            {
                hash ^= WaringCode.GetHashCode();
            }
            if (WaringDesc.Length != 0)
            {
                hash ^= WaringDesc.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #8
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode.Length != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (OppositeId.Length != 0)
            {
                hash ^= OppositeId.GetHashCode();
            }
            if (TimeToken.Length != 0)
            {
                hash ^= TimeToken.GetHashCode();
            }
            if (ServerId != 0)
            {
                hash ^= ServerId.GetHashCode();
            }
            if (Value != 0)
            {
                hash ^= Value.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
        /// <summary>Apply a relative time token to the a UTC date for 2000-01-01 using a new <see cref="ArithmeticTimePlugin"/> instance, and return a string representation of the resulting date.</summary>
        /// <param name="value">The relative time multiplier.</param>
        /// <param name="unit">The relative time unit.</param>
        protected string TryApply(int value, RelativeTimeUnit unit)
        {
            DateTime  date   = new DateTime(2000, 1, 1);
            TimeToken token  = new TimeToken(ArithmeticTimePlugin.Key, null, value.ToString(CultureInfo.InvariantCulture), unit);
            DateTime? result = new ArithmeticTimePlugin().TryApply(token, date);

            return(TestHelpers.GetRepresentation(result));
        }
Example #10
0
        public void EvalParseTime(RCRunner runner, RCClosure closure, RCString left, RCString right)
        {
            RCArray <RCTimeScalar> result = new RCArray <RCTimeScalar> ();

            for (int i = 0; i < right.Count; ++i)
            {
                result.Write(TimeToken.ParseTime(right[i], left.ToArray(), smartType: false));
            }
            runner.Yield(closure, new RCTime(result));
        }
Example #11
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (CmdCode.Length != 0)
            {
                hash ^= CmdCode.GetHashCode();
            }
            if (Identity.Length != 0)
            {
                hash ^= Identity.GetHashCode();
            }
            if (TimeToken.Length != 0)
            {
                hash ^= TimeToken.GetHashCode();
            }
            if (Iccid.Length != 0)
            {
                hash ^= Iccid.GetHashCode();
            }
            if (ImeiType.Length != 0)
            {
                hash ^= ImeiType.GetHashCode();
            }
            if (ImeiVersion.Length != 0)
            {
                hash ^= ImeiVersion.GetHashCode();
            }
            if (Lng != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Lng);
            }
            if (Lat != 0D)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseDoubleEqualityComparer.GetHashCode(Lat);
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Example #12
0
        /// <summary>Apply a natural time token to a date value.</summary>
        /// <param name="token">The natural time token to apply.</param>
        /// <param name="date">The date value to apply the token to.</param>
        /// <returns>Returns the modified date, or <c>null</c> if the token is not supported.</returns>
        public DateTime?TryApply(TimeToken token, DateTime date)
        {
            // parse token
            if (token.Parser != ArithmeticTimePlugin.Key || !(token.Context is RelativeTimeUnit))
            {
                return(null);
            }
            RelativeTimeUnit unit = (RelativeTimeUnit)token.Context;
            int value             = int.Parse(token.Value);

            // apply
            switch (unit)
            {
            case RelativeTimeUnit.Seconds:
                return(date.AddSeconds(value));

            case RelativeTimeUnit.Minutes:
                return(date.AddMinutes(value));

            case RelativeTimeUnit.Hours:
                return(date.AddHours(value));

            case RelativeTimeUnit.Days:
                return(date.AddDays(value));

            case RelativeTimeUnit.Weeks:
                return(date.AddDays(value * 7));

            case RelativeTimeUnit.Fortnights:
                return(date.AddDays(value * 14));

            case RelativeTimeUnit.Months:
                return(date.AddMonths(value));

            case RelativeTimeUnit.Years:
                return(date.AddYears(value));

            default:
                throw new FormatException(String.Format("Invalid arithmetic time unit: {0}", unit));
            }
        }
Example #13
0
        public static TimeToken GetToken(string SearchString)
        {
            TimeToken token = new TimeToken();

            token.Name  = "";
            token.Token = "none";
            token.When  = 0;

            List <TimeToken> ReferenceTokens = new List <TimeToken>();

            ReferenceTokens.Add(new TimeToken()
            {
                Name  = "today",
                Token = "day",
                When  = 0
            }
                                );
            ReferenceTokens.Add(new TimeToken()
            {
                Name  = "yesterday",
                Token = "day",
                When  = -1
            }
                                );

            ReferenceTokens.Add(new TimeToken()
            {
                Name  = "this week",
                Token = "week",
                When  = 0
            }
                                );
            ReferenceTokens.Add(new TimeToken()
            {
                Name  = "last week",
                Token = "week",
                When  = -1
            }
                                );

            ReferenceTokens.Add(new TimeToken()
            {
                Name  = "this month",
                Token = "month",
                When  = 0
            }
                                );
            ReferenceTokens.Add(new TimeToken()
            {
                Name  = "last month",
                Token = "month",
                When  = -1
            }
                                );


            bool nPeriodsAgo = false;

            string[] items = SearchString.Split(' ');
            if (items.Length == 3)
            {
                int  n;
                bool isNumeric = int.TryParse(items[0], out n);
                if (isNumeric)
                {
                    token = new TimeToken()
                    {
                        Name  = SearchString,
                        Token = items[1].Replace("s", ""), // no plural
                        When  = items[2] == "ago" ? -n : n
                    };
                    nPeriodsAgo = true;
                }
            }
            if (!nPeriodsAgo)
            {
                token = ReferenceTokens.Where(i => i.Name == SearchString).FirstOrDefault();
                if (token == null)
                {
                    token = new TimeToken()
                    {
                        Name  = "",
                        Token = "none",
                        When  = 0
                    };
                }
            }

            return(token);
        }
Example #14
0
        public static Work GetData(string searchFor)
        {
            Work work = new Work()
            {
                caption   = "Work in progress",
                headers   = new string[] { "Id", "Description", "Begin", "End", "Reference", "Branch", "Planned", "Duration", "Done", "Status" },
                types     = new string[] { "number", "string", "datetime", "datetime", "string", "string", "number", "number", "boolean", "string" },
                props     = new string[] { "Id", "Description", "Begin", "End", "Reference", "Branch", "Planned", "Duration", "Done", "Status" },
                appraisal = getStatusList()
            };

            using (var dbContext = new QuickToDosEntities())
            {
                IQueryable <toDo> query;
                if (searchFor.Length == 0)
                {
                    query = dbContext.toDos.Where(x => x.DontShow != true);
                    query = query.OrderByDescending(x => x.Id).Take(12);
                }
                else
                {
                    TimeToken result = GetToken(searchFor);
                    if (result.Token == "none")
                    {
                        List <int?> Ids      = new List <int?>();
                        var         NoteList = dbContext.Notes.Where(x => x.Body.Contains(searchFor) && x.Concern == "work").ToList();
                        foreach (var note in NoteList)
                        {
                            Ids.Add(note.ConcernId);
                        }

                        query = dbContext.toDos.Where(x => x.DontShow != true &&
                                                      (
                                                          x.Branch.Contains(searchFor) ||
                                                          x.Notes.Contains(searchFor) ||
                                                          x.Reference.Contains(searchFor) ||
                                                          Ids.Contains(x.Id)
                                                      ));
                    }
                    else
                    {
                        //Name = "last week",
                        //Token = "week",
                        //When = -1
                        DateTime start  = DateTime.Now;
                        DateTime finish = DateTime.Now;
                        if (result.Token == "day")
                        {
                            start  = DateTime.Today.AddDays(result.When);
                            finish = start.AddDays(1).AddSeconds(-1);
                        }
                        else if (result.Token == "week") // to be continued
                        {
                            var day = (int)start.DayOfWeek;
                            if (day == 0)
                            {
                                day = 7;
                            }
                            var delta = 1 - day + result.When * 7;
                            start  = DateTime.Today.AddDays(delta);
                            finish = start.AddDays(7).AddSeconds(-1);
                        }
                        else if (result.Token == "month") // to be continued
                        {
                            var day   = start.Day;        // day in month
                            var delta = 1 - day;
                            start = DateTime.Today.AddMonths(result.When).AddDays(delta);

                            delta  = delta + 6;
                            finish = start.AddMonths(1).AddDays(-1);
                        }


                        query = dbContext.toDos.Where(x => x.DontShow != true && (x.Begin >= start && x.Begin <= finish));
                    }
                }
                work.data = query.Select(x => new DataForJobs
                {
                    Id            = x.Id,
                    Description   = x.Description,
                    Begin         = x.Begin,
                    End           = x.End,
                    Reference     = x.Reference,
                    Duration      = x.Duration,
                    Done          = x.Done,
                    Notes         = x.Notes,
                    Planned       = x.Planned,
                    Branch        = x.Branch == null ? "" : x.Branch,
                    Appraisal     = x.Status,
                    AppraisalNote = x.Status_Note == null ? "" : x.Status_Note,
                    ExtNotes      = dbContext.Notes.Where(y => y.ConcernId == x.Id && y.Concern == "work").OrderByDescending(y => y.Id).ToList(),
                    TimeChunks    = x.Breaks.Where(y => y.ToDoId == x.Id)
                                    .Select(y => new TimeChunkInfo
                    {
                        Id    = y.Id,
                        Begin = y.Start,
                        End   = y.End
                    }).ToList()
                }).ToList();
            }
            foreach (DataForJobs job in work.data)
            {
                job.Files = getFiles(job.Id, "work");

                if (job.End != null)
                {
                    job.Status = job.Appraisal_Str;
                }
                else
                {
                    var item = job.TimeChunks.FirstOrDefault(i => i.End == null);
                    if (item != null)
                    {
                        job.Status = "Running";
                    }
                    else
                    {
                        job.Status = "Pending";
                    }
                }
            }

            work.data = work.data.OrderByDescending(x => x.Id).ToList();

            return(work);
        }