Exemplo n.º 1
0
        private static MyUpdates <DeviceFault> GetDeviceFaultsList(Dictionary <int, DeviceFault> devicesRemote, Dictionary <int, DeviceFault> devicesLocal)
        {
            var ret = new MyUpdates <DeviceFault>();

            foreach (var kv in devicesRemote)
            {
                var deviceRemote = kv.Value;
                if (devicesLocal.ContainsKey(kv.Key))
                {
                    //update?
                    var deviceLocal = devicesLocal[kv.Key];

                    if (deviceRemote.UpdateDate > deviceLocal.UpdateDate)
                    {
                        //update
                        ret.UpdateList.Add(deviceRemote);
                    }
                }
                else
                {
                    //add
                    ret.CreateList.Add(deviceRemote);
                }
            }

            return(ret);
        }
Exemplo n.º 2
0
        private static MyUpdates <User> GetUsersLists(Dictionary <int, User> usersRemote, Dictionary <int, User> usersLocal)
        {
            var ret = new MyUpdates <User>();

            foreach (var kv in usersRemote)
            {
                var userRemote = kv.Value;
                if (usersLocal.ContainsKey(kv.Key))
                {
                    //update?
                    var userLocal = usersLocal[kv.Key];

                    if (userRemote.UpdateDate > userLocal.UpdateDate || userRemote.IsAdmin != userLocal.IsAdmin)
                    {
                        //update
                        ret.UpdateList.Add(userRemote);
                    }
                }
                else
                {
                    //add
                    ret.CreateList.Add(userRemote);
                }
            }

            return(ret);
        }
Exemplo n.º 3
0
        private static MyUpdates <Device> GetDevicesLists(Dictionary <int, Device> devicesRemote, Dictionary <int, Device> devicesLocal)
        {
            var ret = new MyUpdates <Device>();

            foreach (var kv in devicesRemote)
            {
                var deviceRemote = kv.Value;
                if (devicesLocal.ContainsKey(kv.Key))
                {
                    //update?
                    var deviceLocal = devicesLocal[kv.Key];

                    var changed = deviceRemote.UpdateDate > deviceLocal.UpdateDate || deviceRemote.OpenTasksCount != deviceLocal.OpenTasksCount;

                    if (deviceRemote.LastChargeDate.HasValue && deviceLocal.LastChargeDate.HasValue)
                    {
                        changed = changed || deviceRemote.LastChargeDate.Value > deviceLocal.LastChargeDate.Value;
                    }
                    else
                    {
                        changed = changed || deviceRemote.LastChargeDate != deviceLocal.LastChargeDate;
                    }

                    if (deviceRemote.LastOperationDate.HasValue && deviceLocal.LastOperationDate.HasValue)
                    {
                        changed = changed || deviceRemote.LastOperationDate.Value > deviceLocal.LastOperationDate.Value;
                    }
                    else
                    {
                        changed = changed || deviceRemote.LastOperationDate != deviceLocal.LastOperationDate;
                    }

                    if (changed)
                    {
                        //update
                        ret.UpdateList.Add(deviceRemote);
                    }
                }
                else
                {
                    //add
                    ret.CreateList.Add(deviceRemote);
                }
            }

            return(ret);
        }