Example #1
0
        private void RestoreList(string Name, IObservableList v, bool isLocalBackup = false)
        {
            try
            {
                v.Clear();
            }
            catch (Exception ex)
            {
                //This is Temporary fix- Inputvalues list throwing observable collection cannot be modified exception
                Reporter.ToLog(eLogLevel.DEBUG, "Clearing list values for restoring from back up", ex);
            }


            object Backuplist;
            bool   b;

            b = isLocalBackup ? mLocalBackupDic.TryGetValue(Name + "~List", out Backuplist) : mBackupDic.TryGetValue(Name + "~List", out Backuplist);

            if (b)
            {
                if (Backuplist != null)
                {
                    foreach (object o in ((IList)Backuplist))
                    {
                        v.Add(o);
                        RepositoryItemBase repoItem = o as RepositoryItemBase;
                        repoItem?.RestoreBackup(isLocalBackup);   // Drill down the restore
                    }

                    object item = null;
                    if (isLocalBackup)
                    {
                        mLocalBackupDic.TryRemove(Name + "~List", out item);
                    }
                    else
                    {
                        mBackupDic.TryRemove(Name + "~List", out item);
                    }
                }
                else
                {
                    v = null;
                }
            }
            else
            {
                // TODO: handle err
            }
        }
Example #2
0
        private void RestoreList(string Name, IObservableList v, bool isLocalBackup = false)
        {
            v.Clear();

            object Backuplist;
            bool   b;

            b = isLocalBackup ? mLocalBackupDic.TryGetValue(Name + "~List", out Backuplist) : mBackupDic.TryGetValue(Name + "~List", out Backuplist);

            if (b)
            {
                if (Backuplist != null)
                {
                    foreach (object o in ((IList)Backuplist))
                    {
                        v.Add(o);
                        RepositoryItemBase repoItem = o as RepositoryItemBase;
                        repoItem?.RestoreBackup(isLocalBackup);   // Drill down the restore
                    }

                    if (isLocalBackup)
                    {
                        mLocalBackupDic.Remove(Name + "~List");
                    }
                    else
                    {
                        mBackupDic.Remove(Name + "~List");
                    }
                }
                else
                {
                    v = null;
                }
            }
            else
            {
                // TODO: handle err
            }
        }