public virtual int Update(FileInfoSyncDto vm)
        {
            int count = 0;

            if (vm != null && vm.ServerId > 0)
            {
                using (var db = this.CreateDbContext())
                {
                    db.Configuration.AutoDetectChangesEnabled = true;
                    using (db.BeginTransaction(System.Data.IsolationLevel.Serializable))
                    {
                        var m = db.FileInfoSync.Where(q => q.ServerId == vm.ServerId).FirstOrDefault();
                        if (m == null)
                        {
                            m = new SyncInfo()
                            {
                                ServerId = vm.ServerId
                            };
                            db.FileInfoSync.Add(m);
                        }
                        m.SyncId         = vm.SyncId;
                        m.SyncKey        = vm.SyncKey;
                        m.SyncUpdateTime = DateTime.Now;
                        count           += db.SaveChanges();
                        db.Commit();
                        vm.SyncUpdateTime = m.SyncUpdateTime;
                    }
                }
            }

            return(count);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 删除Google Calendar Event
        /// </summary>
        private void DeleteGoogleCalendarEvent(GoogleCalendarEventSyncData calendarEventData, CalendarService googleCalendarService, Calendar defaultCalendar)
        {
            bool success = false;

            try
            {
                googleCalendarService.Events.Delete(defaultCalendar.Id, calendarEventData.Id).Fetch();
                _logger.InfoFormat("删除Google日历事件#{0}|{1}|{2}", calendarEventData.Id, calendarEventData.Subject, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("DeleteGoogleCalendarEvent has exception.", ex);
            }

            if (success)
            {
                //删除同步信息
                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId    = _account.ID;
                syncInfo.LocalDataId  = calendarEventData.SyncId;
                syncInfo.SyncDataId   = calendarEventData.Id;
                syncInfo.SyncDataType = calendarEventData.SyncType;
                DeleteSyncInfo(syncInfo);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除Google Contact
        /// </summary>
        private void DeleteGoogleContact(GoogleContactSyncData contactData, ContactsRequest contactRequest)
        {
            bool success = false;

            try
            {
                ReplaceContactEditUrl(contactData.Contact);
                contactRequest.Delete(contactData.Contact);
                _logger.InfoFormat("删除Google联系人#{0}|{1}|{2}", contactData.Id, contactData.Subject, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("DeleteGoogleContact has exception.", ex);
            }

            if (success)
            {
                //删除同步信息
                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId    = _account.ID;
                syncInfo.LocalDataId  = contactData.SyncId;
                syncInfo.SyncDataId   = contactData.Id;
                syncInfo.SyncDataType = contactData.SyncType;
                DeleteSyncInfo(syncInfo);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 删除Google Task
        /// </summary>
        private void DeleteGoogleTask(GoogleTaskSyncData taskData, TasksService googleTaskService, TaskList defaultTaskList)
        {
            bool success = false;

            try
            {
                googleTaskService.Tasks.Delete(defaultTaskList.Id, taskData.Id).Fetch();
                _logger.InfoFormat("删除Google任务#{0}|{1}|{2}", taskData.Id, taskData.Subject, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("DeleteGoogleTask has exception.", ex);
            }

            if (success)
            {
                //删除同步信息
                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId    = _account.ID;
                syncInfo.LocalDataId  = taskData.SyncId;
                syncInfo.SyncDataId   = taskData.Id;
                syncInfo.SyncDataType = taskData.SyncType;
                DeleteSyncInfo(syncInfo);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// 创建Google Calendar Event
        /// </summary>
        private void CreateGoogleCalendarEvent(GoogleCalendarEventSyncData calendarEventData, CalendarService googleCalendarService, Calendar defaultCalendar)
        {
            global::Google.Apis.Calendar.v3.Data.Event calendarEvent = null;
            bool success = false;

            try
            {
                //创建Google Calendar Event
                calendarEvent = googleCalendarService.Events.Insert(calendarEventData.GoogleCalendarEvent, defaultCalendar.Id).Fetch();
                _logger.InfoFormat("新增Google日历事件#{0}|{1}|{2}", calendarEvent.Id, calendarEvent.Summary, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("CreateGoogleCalendarEvent has exception.", ex);
            }

            if (success)
            {
                //更新任务最后更新时间,确保与Google Calendar Event的最后更新时间一致
                UpdateTaskLastUpdateTime(long.Parse(calendarEventData.SyncId), Rfc3339DateTime.Parse(calendarEvent.Updated).ToLocalTime());

                //创建同步信息
                if (defaultCalendar.Summary == GoogleSyncSettings.DefaultCalendarName)
                {
                    SyncInfo syncInfo = new SyncInfo();
                    syncInfo.AccountId    = _account.ID;
                    syncInfo.LocalDataId  = calendarEventData.SyncId;
                    syncInfo.SyncDataId   = calendarEvent.Id;
                    syncInfo.SyncDataType = calendarEventData.SyncType;
                    InsertSyncInfo(syncInfo);
                }
            }
        }
Exemplo n.º 6
0
        private static void ShowSyncResultStatistics(SyncInfo syncInfo, long elapsedMilliseconds)
        {
            if (syncInfo == null)
            {
                log.Info("Synchronization isn't started");
                return;
            }

            if (!syncInfo.NeedToSync)
            {
                log.Info("Already up-to-date");
                return;
            }

            if (syncInfo.FilesToDelete.Count > 0)
            {
                log.Info($"\r\nDeleted files count: {syncInfo.FilesToDelete.Count}", ConsoleColor.Red);
            }

            if (syncInfo.FilesToAdd.Count > 0)
            {
                log.Info($"\r\nAdded files count: {syncInfo.FilesToAdd.Count}", ConsoleColor.Green);
            }

            if (syncInfo.FilesToReplace.Count > 0)
            {
                log.Info($"\r\nReplaced files count: {syncInfo.FilesToReplace.Count}", ConsoleColor.Cyan);
            }

            var total = syncInfo.FilesToDelete.Count + syncInfo.FilesToAdd.Count + syncInfo.FilesToReplace.Count;

            log.Info($"\r\nTotal changed files count: {total}");
            log.Info($"\r\nSynchronization completed in {TimeSpan.FromMilliseconds(elapsedMilliseconds)}");
        }
Exemplo n.º 7
0
        /// <summary>
        /// 创建Google Task
        /// </summary>
        private void CreateGoogleTask(GoogleTaskSyncData taskData, TasksService googleTaskService, TaskList defaultTaskList)
        {
            global::Google.Apis.Tasks.v1.Data.Task googleTask = null;
            bool success = false;

            try
            {
                //创建Google Task
                googleTask = googleTaskService.Tasks.Insert(taskData.GoogleTask, defaultTaskList.Id).Fetch();
                _logger.InfoFormat("新增Google任务#{0}|{1}|{2}", googleTask.Id, googleTask.Title, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("CreateGoogleTask has exception.", ex);
            }

            if (success)
            {
                //更新任务最后更新时间,确保与Google Task的最后更新时间一致
                UpdateTaskLastUpdateTime(long.Parse(taskData.SyncId), Rfc3339DateTime.Parse(googleTask.Updated).ToLocalTime());

                //创建同步信息
                if (defaultTaskList.Title == GoogleSyncSettings.DefaultTaskListName)
                {
                    SyncInfo syncInfo = new SyncInfo();
                    syncInfo.AccountId    = _account.ID;
                    syncInfo.LocalDataId  = taskData.SyncId;
                    syncInfo.SyncDataId   = googleTask.Id;
                    syncInfo.SyncDataType = taskData.SyncType;
                    InsertSyncInfo(syncInfo);
                }
            }
        }
        public ICommand Create(SyncInfo info)
        {
            ICommand cmd;
            ulong    StationId = ulong.Parse(info.EQID);

            byte[] _content = MyLibrary.ConverUtil.StrToBytes(info.Content);
            // string CmdId = info.CommandID;
            string   CmdId = Config.CmdIdType == "16" ? (Convert.ToInt32(info.CommandID, 16)).ToString() : info.CommandID;
            DateTime PlatformTime;

            if (!DateTime.TryParse(info.Time, out PlatformTime))
            {
                PlatformTime = DateTime.Now;
            }
            switch (CmdId)
            {
            case "61443":
                cmd = new CeXie_61443(_content, StationId, PlatformTime);
                break;

            case "66":
                cmd = new CeXie_66(_content, StationId, PlatformTime);
                break;

            default:
                cmd = new IgnoreCommand();
                break;
            }
            return(cmd);
        }
Exemplo n.º 9
0
        public DateTime SetSyncVersion(string item, string version)
        {
            var syncItem = SyncInfo.Where(i => i.Item == item).FirstOrDefault();

            var now = DateTime.Now;

            if (syncItem == null)
            {
                syncItem = new SyncInfo()
                {
                    Item     = item,
                    Version  = version,
                    SyncTime = now
                };

                SyncInfo.Add(syncItem);
            }
            else
            {
                syncItem.Version  = version;
                syncItem.SyncTime = now;
            }

            return(now);
        }
Exemplo n.º 10
0
        private List <SyncInfo> FetchMachineData2(String IPAddress, bool GetAll)
        {
            int  MachineNo   = 1;
            bool IsConnected = axCZKEM1.Connect_Net(IPAddress, 4370);

            if (!IsConnected)
            {
                return(null);
            }
            List <SyncInfo> l = new List <SyncInfo>();
            SyncInfo        s = new SyncInfo();

            axCZKEM1.ReadAllUserID(MachineNo);                                                                                               //read all the user information to the memory
            axCZKEM1.ReadAllTemplate(MachineNo);                                                                                             //read all the users' fingerprint templates to the memory
            while (axCZKEM1.SSR_GetAllUserInfo(MachineNo, out s.EnrollNumber, out s.Name, out s.Password, out s.Privilege, out s.IsEnabled)) //get all the users' information from the memory
            {
                if (GetAll)
                {
                    axCZKEM1.GetUserTmpExStr(MachineNo, s.EnrollNumber, 0, out s.Flag, out s.TmpData, out s.TmpLength);//get the corresponding templates string and length from the memory
                }
                l.Add(s);
            }

            s.MachineNo   = MachineNo;
            s.FingerIndex = 0; // Default finger index
            return(l);
        }
Exemplo n.º 11
0
        public override SyncInfo Initialize(DatabaseInfo info)
        {
            if (info == null)
                throw new ArgumentNullException("info");

            var details = info.Details;

            string id;
            _client = OneDriveClient
                .ParsePath(details.Url, out id);

            _info = new SyncInfo
            {
                Path = id,
                Modified = details.Modified,
                HasLocalChanges = details.HasLocalChanges,
            };

            info.OpenDatabaseFile(x =>
            {
                using (var buffer = new MemoryStream())
                {
                    BufferEx.CopyStream(x, buffer);
                    _info.Database = buffer.ToArray();
                }
            });

            return _info;
        }
Exemplo n.º 12
0
        public override SyncInfo Initialize(DatabaseInfo info)
        {
            if (info == null)
                throw new ArgumentNullException("info");

            var details = info.Details;
            var url = new Uri(details.Url);
            _client = CreateClient(url.UserInfo);

            _info = new SyncInfo
            {
                Path = url.LocalPath,
                Modified = details.Modified,
                HasLocalChanges = details.HasLocalChanges,
            };

            info.OpenDatabaseFile(x =>
            {
                using (var buffer = new MemoryStream())
                {
                    BufferEx.CopyStream(x, buffer);
                    _info.Database = buffer.ToArray();
                }
            });

            return _info;
        }
Exemplo n.º 13
0
        public override SyncInfo Initialize(DatabaseInfo info)
        {
            if (info == null)
                throw new ArgumentNullException("info");

            var details = info.Details;
            var parts = details.Url.Split('\n');

            _client = new WebDavClient(
                parts[1], parts[2]);

            _info = new SyncInfo
            {
                Path = parts[0],
                Modified = details.Modified,
                HasLocalChanges = details.HasLocalChanges,
            };

            info.OpenDatabaseFile(x =>
            {
                using (var buffer = new MemoryStream())
                {
                    BufferEx.CopyStream(x, buffer);
                    _info.Database = buffer.ToArray();
                }
            });

            return _info;
        }
Exemplo n.º 14
0
        private static SyncInfo[] LoadSyncInfos(string directory)
        {
            string filePath;

            byte[]     buffer;
            SyncInfo[] syncInfos;

            filePath = Path.Combine(directory, ".aucomp");
            if (!File.Exists(filePath))
            {
                return(Array.Empty <SyncInfo>());
            }
            buffer = File.ReadAllBytes(filePath);
            if (buffer.Length < 4)
            {
                throw new InvalidDataException();
            }
            using (MemoryStream stream = new MemoryStream(buffer)) {
                int count;

                count     = stream.ReadByte() | stream.ReadByte() << 8 | stream.ReadByte() << 16 | stream.ReadByte() << 24;
                syncInfos = new SyncInfo[count];
                for (int i = 0; i < count; i++)
                {
                    syncInfos[i] = new SyncInfo(stream);
                }
            }
            return(syncInfos);
        }
Exemplo n.º 15
0
        public int Update(SyncInfo oParam)
        {
            string     sql = @"UPDATE Sys_Sync SET 
                            LastVersionTime=@LastVersionTime
                            WHERE SyncType=@SyncType";
            SqlCommand cmd = new SqlCommand(sql);

            SqlParameter paramSyncType        = new SqlParameter("@SyncType", SqlDbType.Int, 4);
            SqlParameter paramLastVersionTime = new SqlParameter("@LastVersionTime", SqlDbType.DateTime);

            if (oParam.SyncType != AppConst.IntNull)
            {
                paramSyncType.Value = oParam.SyncType;
            }
            else
            {
                paramSyncType.Value = System.DBNull.Value;
            }
            if (oParam.LastVersionTime != AppConst.DateTimeNull)
            {
                paramLastVersionTime.Value = oParam.LastVersionTime;
            }
            else
            {
                paramLastVersionTime.Value = System.DBNull.Value;
            }

            cmd.Parameters.Add(paramSyncType);
            cmd.Parameters.Add(paramLastVersionTime);

            return(SqlHelper.ExecuteNonQuery(cmd));
        }
Exemplo n.º 16
0
 private void UpdateOnline(SyncInfo s)
 {
     con.Open();
     //SqlCommand cmd = new SqlCommand("insert into Members values('" + s.MachineNo + "','" + @s.EnrollNumber + "', '" + @s.Name + "','6','" + @s.TmpData + "','" + @s.Privilege + "','" + @s.Password + "','" + @s.IsEnabled + "','" + @s.Flag + "','" + s.Sync + "','" + s.MachineSynced + "','" + s.FingerDataSynced + "','" + s.todelete + "')", con);
     //cmd.ExecuteNonQuery();
     con.Close();
 }
Exemplo n.º 17
0
        private SyncInfo GetSyncInfoBySyncDataId(int accountId, string syncDataId, SyncDataType syncDataType)
        {
            var sql = string.Format(
                "select AccountId,LocalDataId,SyncDataId,SyncDataType from Cooper_SyncInfo where AccountId={0} and SyncDataId='{1}' collate Chinese_PRC_CS_AI and SyncDataType={2}",
                accountId,
                syncDataId,
                (int)syncDataType);

            var query           = _sessionManager.OpenSession().CreateSQLQuery(sql);
            var objectArrayList = query.List();

            if (objectArrayList.Count > 0)
            {
                object[] objectArray = objectArrayList[0] as object[];

                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId    = int.Parse(objectArray[0].ToString());
                syncInfo.LocalDataId  = objectArray[1].ToString();
                syncInfo.SyncDataId   = objectArray[2].ToString();
                syncInfo.SyncDataType = int.Parse(objectArray[3].ToString());

                return(syncInfo);
            }

            return(null);
        }
Exemplo n.º 18
0
        public override SyncInfo Initialize(DatabaseInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            var details = info.Details;
            var url     = new Uri(details.Url);

            _client = CreateClient(url.UserInfo);

            _info = new SyncInfo
            {
                Path            = url.LocalPath,
                Modified        = details.Modified,
                HasLocalChanges = details.HasLocalChanges,
            };

            info.OpenDatabaseFile(x =>
            {
                using (var buffer = new MemoryStream())
                {
                    BufferEx.CopyStream(x, buffer);
                    _info.Database = buffer.ToArray();
                }
            });

            return(_info);
        }
Exemplo n.º 19
0
        public static void Update(DatabaseInfo info,
            Func<DatabaseInfo, bool> queryUpdate,
            Action<SyncCompleteInfo> report)
        {
            if (info == null) throw new ArgumentNullException("info");
            if (queryUpdate == null) throw new ArgumentNullException("queryUpdate");
            if (report == null) throw new ArgumentNullException("report");

            var details = info.Details;
            var url = new Uri(details.Url);
            var client = CreateClient(url.UserInfo);

            var syncInfo = new SyncInfo
            {
                Path = url.LocalPath,
                Modified = details.Modified,
                HasLocalChanges = details.HasLocalChanges,
            };

            info.OpenDatabaseFile(x =>
            {
                using (var buffer = new MemoryStream())
                {
                    BufferEx.CopyStream(x, buffer);
                    syncInfo.Database = buffer.ToArray();
                }
            });

            Synchronize(client, syncInfo, x =>
            {
                if (queryUpdate(info))
                    report(x);
            });
        }
Exemplo n.º 20
0
        public void Import()
        {
            if (!AppConfig.IsImportable)
            {
                throw new BizException("Is Importable is false");
            }

            string  sql = " select top 1 * from Sys_Sync ";
            DataSet ds  = SqlHelper.ExecuteDataSet(sql);

            if (Util.HasMoreRow(ds))
            {
                throw new BizException("the table Sync is not empty");
            }

            TransactionOptions options = new TransactionOptions();

            options.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted;
            options.Timeout        = TransactionManager.DefaultTimeout;

            using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required, options))
            {
                SortedList sl = AppEnum.GetSync();
                foreach (int syncType in sl.Keys)
                {
                    SyncInfo oInfo = new SyncInfo();
                    oInfo.SyncType        = syncType;
                    oInfo.LastVersionTime = DateTime.Now;

                    new SyncDac().Insert(oInfo);
                }

                scope.Complete();
            }
        }
Exemplo n.º 21
0
        public override SyncInfo Initialize(DatabaseInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            var details = info.Details;

            string id;

            _client = SkyDriveClient
                      .ParsePath(details.Url, out id);

            _info = new SyncInfo
            {
                Path            = id,
                Modified        = details.Modified,
                HasLocalChanges = details.HasLocalChanges,
            };

            info.OpenDatabaseFile(x =>
            {
                using (var buffer = new MemoryStream())
                {
                    BufferEx.CopyStream(x, buffer);
                    _info.Database = buffer.ToArray();
                }
            });

            return(_info);
        }
Exemplo n.º 22
0
        public override SyncInfo Initialize(DatabaseInfo info)
        {
            if (info == null)
            {
                throw new ArgumentNullException("info");
            }

            var details = info.Details;
            var parts   = details.Url.Split('\n');

            _client = new WebDavClient(
                parts[1], parts[2]);

            _info = new SyncInfo
            {
                Path            = parts[0],
                Modified        = details.Modified,
                HasLocalChanges = details.HasLocalChanges,
            };

            info.OpenDatabaseFile(x =>
            {
                using (var buffer = new MemoryStream())
                {
                    BufferEx.CopyStream(x, buffer);
                    _info.Database = buffer.ToArray();
                }
            });

            return(_info);
        }
Exemplo n.º 23
0
        public ICommand Create(SyncInfo info)
        {
            ICommand cmd;
            string   CmdId = Config.CmdIdType == "16" ? (Convert.ToInt32(info.CommandID, 16)).ToString() : info.CommandID;

            byte[] _content = null;
            string Content  = "";

            if (CmdId != "2_1")
            {
                _content = MyLibrary.ConverUtil.StrToBytes(info.Content.Trim().Replace(" ", ""));
            }
            else
            {
                Content = info.Content.Trim().Replace(" ", "");
            }

            ulong    StationId = ulong.Parse(info.EQID);
            DateTime PlatformTime;

            if (!DateTime.TryParse(info.Time, out PlatformTime))
            {
                PlatformTime = DateTime.Now;
            }
            switch (CmdId)
            {
            case "1":
                cmd = new YKGC_01(_content, StationId, PlatformTime);
                break;

            case "2":
                cmd = new YKGC_02(_content, StationId, PlatformTime);
                break;

            case "2_1":     //处理下发形成的Xml文件。
                cmd = new YKGC_02_01(Content, StationId, PlatformTime);
                break;

            case "64":
                cmd = new YKGC_64(_content, StationId, PlatformTime);
                break;

            case "121":
                cmd = new YKGC_121(_content, StationId, PlatformTime);
                break;

            //case "129":
            //    cmd = new YKGC_129(_content, StationId, PlatformTime);
            //    break;
            case "61446":
                cmd = new YKGC_61446(_content, StationId, PlatformTime);
                break;

            default:
                cmd = new IgnoreCommand();
                break;
            }
            return(cmd);
        }
Exemplo n.º 24
0
        private async Task <SyncInfo> GetSyncInfoAsync()
        {
            var bcinfo = await RpcClient.GetBlockchainInfoAsync();

            var pbcinfo = new SyncInfo(bcinfo);

            return(pbcinfo);
        }
Exemplo n.º 25
0
        public void SetDbLastVersion(int syncType)
        {
            SyncInfo oInfo = new SyncInfo();

            oInfo.SyncType        = syncType;
            oInfo.LastVersionTime = DateTime.Now;
            new SyncDac().Update(oInfo);
        }
Exemplo n.º 26
0
        private static void Main(string[] args)
        {
            Settings settings;

            SyncInfo[]      syncInfos;
            bool[]          exists;
            string[]        filePaths;
            List <SyncInfo> newSyncInfos;

            settings = CommandLine.Parse <Settings>(args);
            if (!Directory.Exists(settings.OutputDirectory))
            {
                Directory.CreateDirectory(settings.OutputDirectory);
            }
            syncInfos = LoadSyncInfos(settings.OutputDirectory);
            Array.Sort(syncInfos);
            exists       = new bool[syncInfos.Length];
            newSyncInfos = new List <SyncInfo>();
            filePaths    = Directory.EnumerateFiles(settings.InputDirectory, "*", SearchOption.AllDirectories).ToArray();
            foreach (string filePath in filePaths)
            {
                SyncInfo syncInfo;
                int      index;

                syncInfo = new SyncInfo(filePath, settings.InputDirectory);
                index    = Array.BinarySearch(syncInfos, syncInfo);
                if (index >= 0)
                {
                    exists[index] = true;
                    if (!syncInfos[index].EqualsExactly(syncInfo))
                    {
                        syncInfos[index] = syncInfo;
                        Console.WriteLine("已更新: " + syncInfo.RelativeFilePath);
                        Operate(settings, filePath, true);
                    }
                }
                else
                {
                    newSyncInfos.Add(syncInfo);
                    Console.WriteLine("新加入: " + syncInfo.RelativeFilePath);
                    Operate(settings, filePath, true);
                }
            }
            for (int i = 0; i < syncInfos.Length; i++)
            {
                if (exists[i])
                {
                    continue;
                }
                Console.WriteLine("已删除: " + syncInfos[i].RelativeFilePath);
                Operate(settings, syncInfos[i].RelativeFilePath, false);
            }
            syncInfos = Enumerable.Range(0, syncInfos.Length).Where(i => exists[i]).Select(i => syncInfos[i]).Concat(newSyncInfos).ToArray();
            Array.Sort(syncInfos);
            SaveSyncInfos(settings.OutputDirectory, syncInfos);
            Console.WriteLine("完成");
            Console.ReadKey(true);
        }
Exemplo n.º 27
0
        private static void O365_Item_Removed(SyncInfo Item)
        {
            lock (syncCache)
            {
                syncCache.RemoveAll(x => (x.O365ID == Item.O365ID));

                Program.LogLn("Item (" + Item.Type.ToString() + ") removed: " + Item.O365ID);
            }
        }
Exemplo n.º 28
0
        private void UpdateLastDownloadDate()
        {
            var context  = _persistenceContextFactory.CreateFor <SyncInfo>();
            var syncInfo = new SyncInfo {
                ObjectId = "x", LastSync = DateTimeOffset.UtcNow
            };

            context.Save(syncInfo);
        }
Exemplo n.º 29
0
        /// <summary>
        /// 删除一条同步信息
        /// </summary>
        protected void DeleteSyncInfo(SyncInfo syncInfo)
        {
            var session   = _sessionManager.OpenSession();
            var sqlFormat = "delete from Cooper_SyncInfo where AccountId={0} and LocalDataId='{1}' and SyncDataId='{2}' and SyncDataType={3}";
            var sql       = string.Format(sqlFormat, syncInfo.AccountId, syncInfo.LocalDataId, syncInfo.SyncDataId, syncInfo.SyncDataType);
            var query     = session.CreateSQLQuery(sql);

            query.ExecuteUpdate();
        }
Exemplo n.º 30
0
        private void button3_Click(object sender, EventArgs e)
        {
            bool     IsConnected = axCZKEM1.Connect_Net(txt_ipaddress.Text, 4370);
            SyncInfo s           = new SyncInfo();
            int      varify;
            byte     res;

            axCZKEM1.GetUserInfoEx(1, 11, out varify, out res);
        }
Exemplo n.º 31
0
        /// <summary>
        /// 插入一条同步信息
        /// </summary>
        protected void InsertSyncInfo(SyncInfo syncInfo)
        {
            var session   = _sessionManager.OpenSession();
            var sqlFormat = "insert into Cooper_SyncInfo (AccountId,LocalDataId,SyncDataId,SyncDataType) values ({0},'{1}','{2}',{3})";
            var sql       = string.Format(sqlFormat, syncInfo.AccountId, syncInfo.LocalDataId, syncInfo.SyncDataId, syncInfo.SyncDataType);
            var query     = session.CreateSQLQuery(sql);

            query.ExecuteUpdate();
        }
Exemplo n.º 32
0
        private void RecordLastSync()
        {
            var currentTime = GetCurrentTimeFunc();
            var syncInfo    = new SyncInfo {
                ObjectId = "x", LastSync = currentTime
            };
            var context = _persistenceContextFactory.CreateFor <SyncInfo>();

            context.Save(syncInfo);
        }
Exemplo n.º 33
0
        public S3HashStore(SyncTarget st)
        {
            parallelism = st?.parallelism ?? 1;
            this.st     = st;
            this.si     = null;

            this.s3h = (st?.profile).IsNullOrEmpty() ?
                       new S3Helper() :
                       new S3Helper(Extensions.Helper.GetAWSCredentials(st.profile));
        }
Exemplo n.º 34
0
		public override bool Synchronize(SyncInfo sync, FdoCache cache)
		{
			CheckDisposed();

			if (sync.msg == SyncMsg.ksyncUndoRedo || sync.msg == SyncMsg.ksyncFullRefresh)
			{
				OnMasterRefresh(null);
				return true;
			}
			return base.Synchronize (sync, cache);
		}
Exemplo n.º 35
0
        public override bool Synchronize(SyncInfo sync, FdoCache cache)
        {
            CheckDisposed();

            if (sync.msg == SyncMsg.ksyncUndoRedo || sync.msg == SyncMsg.ksyncFullRefresh)
            {
                OnMasterRefresh(null);
                return(true);
            }
            return(base.Synchronize(sync, cache));
        }
Exemplo n.º 36
0
        public void Sync()
        {
            SyncInfo syncInfo;
            lock(syncing) {
                if(!syncing.TryGetValue(TVDBID, out syncInfo)) {
                    syncing.Add(TVDBID, syncInfo = new SyncInfo { Lock = new object() });
                }
            }

            lock(syncInfo.Lock) {
                Sync(syncInfo);
            }
        }
Exemplo n.º 37
0
        public static TVDBSearchResult Search(string name)
        {
            SyncInfo info;
            lock(searching) {
                if(searching.TryGetValue(name, out info)) {
                    lock(info.Lock) {
                        return info.Result;
                    }
                } else {
                    searching.Add(name, info = new SyncInfo {
                        Lock = new object()
                    });
                }
            }

            lock(info.Lock) {
                var results = new TVDBRequest().Search(name);
                info.Result = results.FirstOrDefault();
                return info.Result;
            }
        }
Exemplo n.º 38
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Since we don't have a real database we don't have to synchronize between multiple
		/// dbs
		/// </summary>
		/// <param name="appGuid"></param>
		/// <param name="sync"></param>
		/// ------------------------------------------------------------------------------------
		public override void StoreSync(Guid appGuid, SyncInfo sync)
		{
			CheckDisposed();
		}
Exemplo n.º 39
0
        private SyncInfo GetSyncInfoBySyncDataId(int accountId, string syncDataId, SyncDataType syncDataType)
        {
            var sql = string.Format(
                "select AccountId,LocalDataId,SyncDataId,SyncDataType from Cooper_SyncInfo where AccountId={0} and SyncDataId='{1}' collate Chinese_PRC_CS_AI and SyncDataType={2}",
                accountId,
                syncDataId,
                (int)syncDataType);

            var query = _sessionManager.OpenSession().CreateSQLQuery(sql);
            var objectArrayList = query.List();

            if (objectArrayList.Count > 0)
            {
                object[] objectArray = objectArrayList[0] as object[];

                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId = int.Parse(objectArray[0].ToString());
                syncInfo.LocalDataId = objectArray[1].ToString();
                syncInfo.SyncDataId = objectArray[2].ToString();
                syncInfo.SyncDataType = int.Parse(objectArray[3].ToString());

                return syncInfo;
            }

            return null;
        }
Exemplo n.º 40
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Called when a window syncronizes it's views with DB changes (e.g. when an undo or
		/// redo command is issued).
		/// </summary>
		/// <param name="sync">syncronization information record</param>
		/// <returns>True if the sync message was handled; false, indicating that the
		/// application should refresh all windows. </returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool Synchronize(SyncInfo sync)
		{
			CheckDisposed();

			if (sync.msg == SyncMsg.ksyncStyle)
			{
				// force our stylesheet to resync (LT-7382).
				ResyncStylesheet();
				ResyncRootboxStyles();
				return true;
			}
			return false;
		}
Exemplo n.º 41
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Handle import sync messages.
		/// </summary>
		/// <param name="sync"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public override bool Synchronize(SyncInfo sync)
		{
			CheckDisposed();

			if (sync.msg == SyncMsg.ksyncStyle)
			{
				ParaStyleListHelper.IgnoreListRefresh = true;
				CharStyleListHelper.IgnoreListRefresh = true;

				ReSynchStyleSheet();
				// REVIEW: can we skip the rest of this, if we know that a ksynchUndoRedo will
				// do it for us later?
				RefreshAllViews();

				ParaStyleListHelper.IgnoreListRefresh = false;
				CharStyleListHelper.IgnoreListRefresh = false;
				InitStyleComboBox();
				return true;
			}
			else if (sync.msg == SyncMsg.ksyncUndoRedo)
			{
				ParaStyleListHelper.IgnoreListRefresh = true;
				CharStyleListHelper.IgnoreListRefresh = true;

				RefreshAllViews();

				ParaStyleListHelper.IgnoreListRefresh = false;
				CharStyleListHelper.IgnoreListRefresh = false;
				InitStyleComboBox();
				return true;
			}
			else if (sync.msg == SyncMsg.ksyncWs)
			{
				// Don't care -- do nothing
				return true;
			}
			else if (sync.msg == SyncMsg.ksyncScriptureDeleteBook ||
				sync.msg == SyncMsg.ksyncScriptureNewBook ||
				sync.msg == SyncMsg.ksyncScriptureImport)
			{
				// Full refresh will happen as a resynch of subsequent synch message, so
				// let's not waste time now.
				// RefreshAllViews();
				return true;
			}

			// Updating views in all windows. FwApp.App should never be null unless
			// running from a test.
			if (FwApp.App != null)
				return false; // causes a RefreshAllViews, and allows caller to notify its callers.

			RefreshAllViews(); // special case for testing.
			return true;
		}
Exemplo n.º 42
0
        /// <summary>
        /// 删除Google Contact
        /// </summary>
        private void DeleteGoogleContact(GoogleContactSyncData contactData, ContactsRequest contactRequest)
        {
            bool success = false;

            try
            {
                ReplaceContactEditUrl(contactData.Contact);
                contactRequest.Delete(contactData.Contact);
                _logger.InfoFormat("删除Google联系人#{0}|{1}|{2}", contactData.Id, contactData.Subject, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("DeleteGoogleContact has exception.", ex);
            }

            if (success)
            {
                //删除同步信息
                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId = _account.ID;
                syncInfo.LocalDataId = contactData.SyncId;
                syncInfo.SyncDataId = contactData.Id;
                syncInfo.SyncDataType = contactData.SyncType;
                DeleteSyncInfo(syncInfo);
            }
        }
Exemplo n.º 43
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Called just before a window syncronizes it's views with DB changes (e.g. when an
		/// undo or redo command is issued).
		/// </summary>
		/// <param name="sync">syncronization information record</param>
		/// ------------------------------------------------------------------------------------
		public virtual bool PreSynchronize(SyncInfo sync)
		{
			CheckDisposed();

			// TODO: Implement it. This is copied from TE.
			return true;
		}
Exemplo n.º 44
0
        /// <summary>
        /// 创建Google Contact
        /// </summary>
        private void CreateGoogleContact(GoogleContactSyncData contactData, ContactsRequest contactRequest, Group defaultContactGroup)
        {
            global::Google.Contacts.Contact contact = null;
            bool success = false;

            try
            {
                //设置联系人默认分组
                contactData.Contact.GroupMembership.Add(new GroupMembership() { HRef = defaultContactGroup.Id });
                //调用API新增联系人
                contact = contactRequest.Insert(new Uri(GoogleSyncSettings.ContactScope), contactData.Contact);
                _logger.InfoFormat("新增Google联系人#{0}|{1}|{2}", contact.Id, contactData.Subject, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("CreateGoogleContact has exception.", ex);
            }

            if (success)
            {
                //更新联系人最后更新时间,确保与Google Contact的最后更新时间一致
                UpdateContactLastUpdateTime(int.Parse(contactData.SyncId), contact.Updated.ToLocalTime());

                //创建同步信息
                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId = _account.ID;
                syncInfo.LocalDataId = contactData.SyncId;
                syncInfo.SyncDataId = contact.Id;
                syncInfo.SyncDataType = contactData.SyncType;
                InsertSyncInfo(syncInfo);
            }
        }
Exemplo n.º 45
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// <param name="sync"></param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public bool Synchronize(SyncInfo sync)
		{
			CheckDisposed();

			return false;
		}
Exemplo n.º 46
0
 private static void Synchronize(DropNetClient client,
     SyncInfo info, Action<SyncCompleteInfo> report)
 {
     client.GetMetaDataAsync(info.Path, meta =>
         OnFileMetaReady(client, info, meta, report),
         ex => report(new SyncCompleteInfo
         {
             Path = info.Path,
             Result = SyncResults.Failed,
         }));
 }
Exemplo n.º 47
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Called when a window syncronizes it's views with DB changes (e.g. when an undo or
		/// redo command is issued).
		/// </summary>
		/// <param name="sync">syncronization information record</param>
		/// <returns>true if successful (false results in RefreshAll)</returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool Synchronize(SyncInfo sync)
		{
			CheckDisposed();

			Debug.Assert(false, "Derived classes must implement this method.");
			return false;
		}
Exemplo n.º 48
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Cycle through the applications main windows and synchronize them with database
		/// changes.
		/// </summary>
		/// <param name="sync">synchronization information record</param>
		/// <param name="cache">database cache</param>
		/// <returns>false if a refreshall was performed or presync failed; this suppresses
		/// subsequent sync messages. True to continue processing.</returns>
		/// ------------------------------------------------------------------------------------
		public virtual bool Synchronize(SyncInfo sync, FdoCache cache)
		{
			CheckDisposed();

			if (m_suppressedCaches.ContainsKey(cache))
			{
				Queue<SyncInfo> messages = m_suppressedCaches[cache].Queue;
				if (!messages.Contains(sync))
					messages.Enqueue(sync);
				return true;
			}

			cache.StoreSync(SyncGuid, sync);

			if (sync.msg == SyncMsg.ksyncFullRefresh || sync.msg == SyncMsg.ksyncCustomField)
			{
				RefreshAllViews(cache);
				return false;
			}

			foreach (IFwMainWnd wnd in MainWindows)
			{
				if (wnd.Cache == cache && !wnd.PreSynchronize(sync))
					return false;
			}

			if (sync.msg == SyncMsg.ksyncWs)
			{
				// REVIEW TeTeam: AfLpInfo::Synchronize calls AfLpInfo::FullRefresh, which
				// clears the cache, loads the styles, loads ws and updates wsf, load project
				// basics, updates external link root, load overlays and refreshes possibility
				// lists. I don't think we need to do any of these here.
				RefreshAllViews(cache);
				return false;
			}
			else if (sync.msg == SyncMsg.ksyncPromoteEntry)
			{
				// Review: Write code here to deal with this case. Look at
				// AfLpInfo::Syncronize to see what's necessary.
				// This would be relevant to an application that uses subentries (like Data Notebook--
				// if it used FwApp).
			}
			else if (sync.msg == SyncMsg.ksyncSimpleEdit)
			{
				// Use the UpdatePropIfCached method to update anything that changed that we care about.
				// Todo: need to get Synchronize called for each new syncinfo in DB on window activate.
				IVwOleDbDa odd = cache.VwOleDbDaAccessor;
				int hvo = sync.hvo;
				int flid = sync.flid;
				FieldType iType = cache.GetFieldType(flid);

				switch(iType)
				{
					case FieldType.kcptMultiString:
					case FieldType.kcptMultiUnicode:
					case FieldType.kcptMultiBigString:
					case FieldType.kcptMultiBigUnicode:
						// Try all active WS to see if cached. (Pathologically, if some wss are used for both,
						// they will be updated twice.)
						foreach (int ws in cache.LangProject.VernWssRC.HvoArray)
							odd.UpdatePropIfCached(hvo, flid, (int)iType, ws);
						foreach (int ws in cache.LangProject.AnalysisWssRC.HvoArray)
							odd.UpdatePropIfCached(hvo, flid, (int)iType, ws);
						// This will usually prevent a double-update; pathologically, one might still happen
						// if the user ws is in the analysis or vernacular lists but is not the first analysis one.
						if (cache.DefaultUserWs != cache.DefaultAnalWs)
							odd.UpdatePropIfCached(hvo, flid, (int)iType, cache.DefaultUserWs);
						break;
					case 0:
						// This is very rare but possible.  Do nothing since kcptNull is not a real data
						// type, hence cannot have any data.
						break;
					default:
						odd.UpdatePropIfCached(hvo, flid, (int)iType, 0);
						break;
				}
				return true;
			}

			foreach (IFwMainWnd wnd in MainWindows)
			{
				if (wnd.Cache == cache && !wnd.Synchronize(sync))
				{
					// The window itself was not able to process the message successfully;
					// play safe and refresh everything
					RefreshAllViews(cache);
					return false;
				}
			}

			return true;
		}
Exemplo n.º 49
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Called just before a window syncronizes it's views with DB changes (e.g. when an
        /// undo or redo command is issued).
        /// </summary>
        /// <param name="sync">syncronization information record</param>
        /// ------------------------------------------------------------------------------------
        public override bool PreSynchronize(SyncInfo sync)
        {
            CheckDisposed();

            return false;
        }
Exemplo n.º 50
0
        /// <summary>
        /// 删除Google Task
        /// </summary>
        private void DeleteGoogleTask(GoogleTaskSyncData taskData, TasksService googleTaskService, TaskList defaultTaskList)
        {
            bool success = false;

            try
            {
                googleTaskService.Tasks.Delete(defaultTaskList.Id, taskData.Id).Fetch();
                _logger.InfoFormat("删除Google任务#{0}|{1}|{2}", taskData.Id, taskData.Subject, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("DeleteGoogleTask has exception.", ex);
            }

            if (success)
            {
                //删除同步信息
                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId = _account.ID;
                syncInfo.LocalDataId = taskData.SyncId;
                syncInfo.SyncDataId = taskData.Id;
                syncInfo.SyncDataType = taskData.SyncType;
                DeleteSyncInfo(syncInfo);
            }
        }
Exemplo n.º 51
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="SyncUndoAction"/> class.
		/// </summary>
		/// <param name="cache">The cache.</param>
		/// <param name="app">The application.</param>
		/// <param name="syncInfo">The sync info.</param>
		/// ------------------------------------------------------------------------------------
		public SyncUndoAction(FdoCache cache, IApp app, SyncInfo syncInfo)
		{
			m_fdoCache = cache;
			m_app = app;
			m_syncInfo = syncInfo;
		}
Exemplo n.º 52
0
 private static string DetermineTargetPath(string triggeredPath, SyncInfo syncInfo)
 {
     var destination = triggeredPath.Replace(syncInfo.Source, syncInfo.Target);
     return destination;
 }
Exemplo n.º 53
0
        private void Sync(SyncInfo syncInfo)
        {
            if(syncInfo.Complete) return;

            var tvdbSeries = new TVDBRequest().Series(TVDBID, true);
            Series series = null;

            using(var db = new EpisodeTrackerDBContext()) {
                var seriesQuery = db.Series
                    .Include(s => s.Episodes)
                    .Include(s => s.Aliases);

                series = seriesQuery.SingleOrDefault(s => s.TVDBID == tvdbSeries.ID);

                if(series == null) {
                    series = seriesQuery
                        .SingleOrDefault(s =>
                            s.Name == tvdbSeries.Name
                            || s.Name == Name
                            || s.Aliases.Any(a => a.Name == Name)
                        );
                }

                if(series == null) {
                    series = new Series {
                        Added = DateTime.Now
                    };
                    db.Series.Add(series);
                }

                series.TVDBID = tvdbSeries.ID;
                series.Name = tvdbSeries.Name;
                series.AirsDay = tvdbSeries.AirsDay;
                series.AirsTime = tvdbSeries.AirsTime;
                series.Status = tvdbSeries.Status;
                series.Overview = tvdbSeries.Overview;
                series.LengthMinutes = tvdbSeries.LengthMinutes;
                series.Rating = tvdbSeries.Rating;

                if(Name != null && !Name.Equals(series.Name, StringComparison.OrdinalIgnoreCase) && !db.SeriesAliases.Any(a => a.Name == Name)) {
                    series.Aliases.Add(new SeriesAlias { Name = Name });
                }

                series.Genres.Clear();
                GenresSync(series, tvdbSeries.Genres);

                series.Updated = DateTime.Now;

                foreach(var ep in tvdbSeries.Episodes) {
                    SyncEpisode(ep, series);
                }

                db.SaveChanges();
            }

            if(DownloadBanners || DownloadBannersAsync) {
                // Do this after saving so we can use the ID
                var syncBanners = SyncBannersAsync(series, tvdbSeries);
                if(!DownloadBannersAsync) syncBanners.Wait();
            }

            lock(syncing) {
                syncing.Remove(TVDBID);
            }

            syncInfo.Complete = true;
        }
Exemplo n.º 54
0
        /// <summary>
        /// 创建Google Calendar Event
        /// </summary>
        private void CreateGoogleCalendarEvent(GoogleCalendarEventSyncData calendarEventData, CalendarService googleCalendarService, Calendar defaultCalendar)
        {
            global::Google.Apis.Calendar.v3.Data.Event calendarEvent = null;
            bool success = false;

            try
            {
                //创建Google Calendar Event
                calendarEvent = googleCalendarService.Events.Insert(calendarEventData.GoogleCalendarEvent, defaultCalendar.Id).Fetch();
                _logger.InfoFormat("新增Google日历事件#{0}|{1}|{2}", calendarEvent.Id, calendarEvent.Summary, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("CreateGoogleCalendarEvent has exception.", ex);
            }

            if (success)
            {
                //更新任务最后更新时间,确保与Google Calendar Event的最后更新时间一致
                UpdateTaskLastUpdateTime(long.Parse(calendarEventData.SyncId), Rfc3339DateTime.Parse(calendarEvent.Updated).ToLocalTime());

                //创建同步信息
                if (defaultCalendar.Summary == GoogleSyncSettings.DefaultCalendarName)
                {
                    SyncInfo syncInfo = new SyncInfo();
                    syncInfo.AccountId = _account.ID;
                    syncInfo.LocalDataId = calendarEventData.SyncId;
                    syncInfo.SyncDataId = calendarEvent.Id;
                    syncInfo.SyncDataType = calendarEventData.SyncType;
                    InsertSyncInfo(syncInfo);
                }
            }
        }
Exemplo n.º 55
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Cycle through the applications main windows and synchronize them with database
		/// changes
		/// </summary>
		/// <param name="sync">synchronization information record</param>
		/// <param name="cache">database cache</param>
		/// <returns>
		/// false if a refreshall was performed or presync failed; this suppresses
		/// subsequent sync messages. True to continue processing.
		/// </returns>
		/// ------------------------------------------------------------------------------------
		public override bool Synchronize(SyncInfo sync, FdoCache cache)
		{
			m_syncs.Add(sync);
			m_cacheFromSynchronize = cache;
			return true;
		}
Exemplo n.º 56
0
        private static void OnFileMetaReady(
            DropNetClient client,
            SyncInfo info, MetaData meta,
            Action<SyncCompleteInfo> report)
        {
            // No change from server side
            if (meta.Modified == info.Modified)
            {
                if (!info.HasLocalChanges)
                {
                    report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Result = SyncResults.NoChange,
                    });

                    return;
                }

                // Has local change, upload to server
                client.UploadFileAsync(info.Path,
                    info.Database,
                    x => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Modified = x.Modified,
                        Result = SyncResults.Uploaded,
                    }),
                    x => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Result = SyncResults.Failed,
                    }));

                return;
            }

            // Has changes from server
            if (!info.HasLocalChanges)
            {
                // Database should be updated
                client.GetFileAsync(info.Path,
                    x => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Database = x.RawBytes,
                        Modified = meta.Modified,
                        Result = SyncResults.Downloaded,
                    }),
                    ex => report(new SyncCompleteInfo
                    {
                        Path = info.Path,
                        Result = SyncResults.Failed,
                    }));

                return;
            }

            // Conflict
            var path = GetNonConflictPath(info.Path);

            client.UploadFileAsync(path, info.Database,
                x => report(new SyncCompleteInfo
                {
                    Modified = x.Modified,
                    Path = client.GetUrl(path),
                    Result = SyncResults.Conflict,
                }),
                x => report(new SyncCompleteInfo
                {
                    Path = info.Path,
                    Result = SyncResults.Failed,
                }));
        }
Exemplo n.º 57
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Resume execution of synchronize messages. If there are any messages in the queue
		/// execute them now.
		/// </summary>
		/// <param name="cache">The cache whose synchronization messages that should no longer
		/// be ignored</param>
		/// ------------------------------------------------------------------------------------
		public void ResumeSynchronize(FdoCache cache)
		{
			CheckDisposed();

			if (!m_suppressedCaches.ContainsKey(cache))
				return;

			m_suppressedCaches[cache].Count--;
			if (m_suppressedCaches[cache].Count > 0)
				return;

			BeginUpdate(cache);
			Queue<SyncInfo> messages = m_suppressedCaches[cache].Queue;
			m_suppressedCaches.Remove(cache);

			bool fProcessUndoRedoAfter = false;
			SyncInfo savedUndoRedo = new SyncInfo(SyncMsg.ksyncNothing, 0, 0); //struct, not an obj; can't be a null
			foreach (SyncInfo synchInfo in messages)
			{
				if (synchInfo.msg == SyncMsg.ksyncUndoRedo)
				{
					// we must process this synch message after all the others
					fProcessUndoRedoAfter = true;
					savedUndoRedo = synchInfo;
					continue;
				}
				// Do the synch
				if (!Synchronize(synchInfo, cache))
				{
					fProcessUndoRedoAfter = false; // Refresh already done, final UndoRedo unnecessary
					break; // One resulted in Refresh everything, ignore other synch msgs.
				}
			}
			if (fProcessUndoRedoAfter)
				Synchronize(savedUndoRedo, cache);

			// NOTE: This code may present a race condition, because there is a slight
			// possibility that a sync message can come to the App at
			// this point and then get cleared from the syncMessages list and never get run.
			EndUpdate(cache);
		}
Exemplo n.º 58
0
        /// <summary>
        /// 删除Google Calendar Event
        /// </summary>
        private void DeleteGoogleCalendarEvent(GoogleCalendarEventSyncData calendarEventData, CalendarService googleCalendarService, Calendar defaultCalendar)
        {
            bool success = false;

            try
            {
                googleCalendarService.Events.Delete(defaultCalendar.Id, calendarEventData.Id).Fetch();
                _logger.InfoFormat("删除Google日历事件#{0}|{1}|{2}", calendarEventData.Id, calendarEventData.Subject, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("DeleteGoogleCalendarEvent has exception.", ex);
            }

            if (success)
            {
                //删除同步信息
                SyncInfo syncInfo = new SyncInfo();
                syncInfo.AccountId = _account.ID;
                syncInfo.LocalDataId = calendarEventData.SyncId;
                syncInfo.SyncDataId = calendarEventData.Id;
                syncInfo.SyncDataType = calendarEventData.SyncType;
                DeleteSyncInfo(syncInfo);
            }
        }
Exemplo n.º 59
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Called just before a window syncronizes it's views with DB changes (e.g. when an
		/// undo or redo command is issued).
		/// </summary>
		/// <param name="sync">syncronization information record</param>
		/// ------------------------------------------------------------------------------------
		public bool PreSynchronize(SyncInfo sync)
		{
			CheckDisposed();

			return true;
		}
Exemplo n.º 60
0
        /// <summary>
        /// 创建Google Task
        /// </summary>
        private void CreateGoogleTask(GoogleTaskSyncData taskData, TasksService googleTaskService, TaskList defaultTaskList)
        {
            global::Google.Apis.Tasks.v1.Data.Task googleTask = null;
            bool success = false;

            try
            {
                //创建Google Task
                googleTask = googleTaskService.Tasks.Insert(taskData.GoogleTask, defaultTaskList.Id).Fetch();
                _logger.InfoFormat("新增Google任务#{0}|{1}|{2}", googleTask.Id, googleTask.Title, _account.ID);
                success = true;
            }
            catch (Exception ex)
            {
                _logger.Error("CreateGoogleTask has exception.", ex);
            }

            if (success)
            {
                //更新任务最后更新时间,确保与Google Task的最后更新时间一致
                UpdateTaskLastUpdateTime(long.Parse(taskData.SyncId), Rfc3339DateTime.Parse(googleTask.Updated).ToLocalTime());

                //创建同步信息
                if (defaultTaskList.Title == GoogleSyncSettings.DefaultTaskListName)
                {
                    SyncInfo syncInfo = new SyncInfo();
                    syncInfo.AccountId = _account.ID;
                    syncInfo.LocalDataId = taskData.SyncId;
                    syncInfo.SyncDataId = googleTask.Id;
                    syncInfo.SyncDataType = taskData.SyncType;
                    InsertSyncInfo(syncInfo);
                }
            }
        }