Example #1
0
        public bool Open(XRegistry ZDef)
        {
            IsLoading = true;

            try
            {
                XParameter Param = ZDef.Parameter("Procedures");
                PM = new ProcManager(Param);
                NotifyChanged("ProcList");

                SetBanner();

                return(true);
            }
            catch (InvalidFIleException)
            {
                ProcManager.PanelMessage(ID, Res.RSTR("InvalidXML"), LogType.ERROR);
            }
            catch (Exception ex)
            {
                Logger.Log(ID, ex.Message, LogType.ERROR);
            }
            finally
            {
                IsLoading = false;
            }

            return(false);
        }
Example #2
0
        private async Task <bool> _RowAction(IGRRow _Row)
        {
            GRRow <BookDisplay> Row = (GRRow <BookDisplay>)_Row;

            BookInstruction Payload = ( BookInstruction )Row.Source.Payload;

            if (Payload != null)
            {
                // Save the book here
                Payload.SaveInfo();

                // Reload the BookDisplay as Entry might changed from SaveInfo
                Row.Source = new BookDisplay(Payload.Entry);
            }

            SpiderBook Item = await SpiderBook.CreateSAsync(Row.Source.Entry.ZoneId, Row.Source.Entry.ZItemId, Payload?.BookSpiderDef);

            Item.PropertyChanged += Item_PropertyChanged;

            XParameter Metadata = Item.PSettings.Parameter("METADATA") ?? new XParameter("METADATA");

            Metadata.SetValue(new XKey("payload", Row.Source.Entry.Meta[AppKeys.GLOBAL_SSID]));
            Item.PSettings.SetParameter(Metadata);

            if (!Item.ProcessSuccess && Item.CanProcess)
            {
                await ItemProcessor.ProcessLocal(Item);
            }

            Item.PropertyChanged -= Item_PropertyChanged;

            (( BookDisplayPageExt )Extension).OpenItem(_Row);

            return(true);
        }
Example #3
0
        private async void AddServer()
        {
            string SrvUri = ServiceUri.Text.Trim();

            if (string.IsNullOrEmpty(SrvUri))
            {
                return;
            }

            try
            {
                new Uri(SrvUri);
            }
            catch (Exception)
            {
                await Popups.ShowDialog(new MessageDialog( "Invalid Uri" ));

                return;
            }

            XParameter Param = new XParameter(SrvUri);

            Param.SetValue(new XKey("uri", 1));
            ServerReg.SetParameter(Param);
            ServerReg.Save();

            ServiceUri.Text = "";

            RefreshServers();
        }
 /// <summary>
 /// Default ctor
 /// </summary>
 public AstParameterVariable(XParameter parameter)
 {
     this.parameter = parameter;
     Name           = parameter.Name;
     Type           = parameter.ParameterType;
     IsGenerated    = false;
 }
Example #5
0
        public void UpdateTaskInterval(uint Minutes)
        {
            foreach (KeyValuePair <Guid, IBackgroundTaskRegistration> BTask in BackgroundTaskRegistration.AllTasks)
            {
                if (BTask.Value.Name == TASK_MAIN)
                {
                    BTask.Value.Unregister(false);
                    break;
                }
            }

#if DEBUG
            Minutes = Math.Max(15, Minutes);
#else
            Minutes = Math.Max(180, Minutes);
#endif
            XParameter IntParam = XReg.Parameter("Interval");
            XReg.SetParameter("Interval", new XKey("val", Minutes));
            XReg.Save();

            TimeTrigger           MinuteTrigger = new TimeTrigger(Minutes, false);
            BackgroundTaskBuilder Builder       = new BackgroundTaskBuilder();

            Builder.Name           = TASK_MAIN;
            Builder.TaskEntryPoint = ENTRY_POINT;
            Builder.SetTrigger(MinuteTrigger);
            Builder.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable));

            BackgroundTaskRegistration task = Builder.Register();
        }
Example #6
0
        public XInput(int paramsCount, int phasesCount)
        {
            parameters  = new XParameter[paramsCount];
            ParamsCount = paramsCount;
            PhasesCount = phasesCount;

            for (int i = 0; i < paramsCount; ++i)
            {
                parameters[i] = new XParameter(phasesCount);
            }
        }
Example #7
0
        /// <summary>
        /// Implement the class now that all classes have been created
        /// </summary>
        protected override void CreateMembers(DexTargetPackage targetPackage)
        {
            // Build value ctor
            var module    = Compiler.Module;
            var isWide    = Type.GetEnumUnderlyingType().Resolve().IsWide();
            var enumType  = Compiler.GetDot42InternalType("Enum");
            var valueType = isWide ? module.TypeSystem.Long : module.TypeSystem.Int;

            // Build default ctor
            defaultCtor = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Constructor, "<init>", module.TypeSystem.Void);
            Class.Methods.Add(defaultCtor.GetDexMethod(Class, targetPackage));

            // Build Create method
            create = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Protected, "Create", enumType,
                                                       XParameter.Create("value", valueType));
            Class.Methods.Add(create.GetDexMethod(Class, targetPackage));
        }
Example #8
0
        private void SetGranted(string Id)
        {
            RequestsSource.Any(x =>
            {
                if (x.Id == Id)
                {
                    x.Granted = true;
                    return(true);
                }
                return(false);
            });

            XParameter XParam = XGrant.Parameter(BindItem.Id);

            XParam.SetParameter(new XParameter(Id));
            XGrant.SetParameter(XParam);
            XGrant.Save();
        }
Example #9
0
        public KeyboardController(string Name)
        {
            this.Name = Name;

            RegKeys = new List <Action>();
            KeyDesc = new Dictionary <string, List <string> >();

            XReg = new XRegistry("<help />", FileLinks.ROOT_SETTING + FileLinks.HELP);

            Settings = XReg.Parameter("Keyboard");
            if (Settings == null)
            {
                Settings = new XParameter("Keyboard");
            }

            AddCombo("Help", ShowHelp, VirtualKey.F1);
            AddCombo("Help", ShowHelp, VirtualKey.Shift, ( VirtualKey )191);
        }
Example #10
0
        private void RemoveServer(object sender, RoutedEventArgs e)
        {
            Button B = sender as Button;

            if (B == null)
            {
                return;
            }

            ServerChoice C     = B.DataContext as ServerChoice;
            XParameter   Param = new XParameter(C.Name);

            Param.SetValue(new XKey("disabled", true));
            ServerReg.SetParameter(Param);
            ServerReg.Save();

            RefreshServers();
        }
Example #11
0
        public void ClearTileStatus(string Id)
        {
            XParameter TileParam = XReg.Parameter(Id);

            if (TileParam == null)
            {
                return;
            }

            string TileId = TileParam.GetValue("tileId");

            try
            {
                TileUpdater Updater = TileUpdateManager.CreateTileUpdaterForSecondaryTile(TileId);
                Updater.Clear();
                Updater.EnableNotificationQueue(false);
            }
            catch (Exception) { }
        }
Example #12
0
        public async void CreateTileUpdateForBookSpider(string BookId, string TileId)
        {
            if (!CanBackground)
            {
                await Popups.ShowDialog(UIAliases.CreateDialog(
                                            "Background Task Manager"
                                            , "Backgorund Task is disabled. Unable to create tile update"));

                return;
            }

            XParameter BookParam = new XParameter(BookId);

            BookParam.SetValue(new XKey("tileId", TileId));
            BookParam.SetValue(new XKey("spider", true));

            XReg.SetParameter(BookParam);

            XReg.Save();
        }
Example #13
0
        /// <summary>
        /// Create the body of the valueOf(string) method.
        /// </summary>
        private AstBlock CreateValueOfBody(XSyntheticMethodDefinition method, XFieldDefinition enumInfoField, XTypeSystem typeSystem)
        {
            var internalEnumType     = Compiler.GetDot42InternalType("Enum");
            var internalEnumInfoType = Compiler.GetDot42InternalType("EnumInfo");
            var parseMethod          = new XMethodReference.Simple("Parse", true, internalEnumType, internalEnumInfoType,
                                                                   XParameter.Create("value", typeSystem.String),
                                                                   XParameter.Create("ignoreCase", typeSystem.Bool),
                                                                   XParameter.Create("throwIfNotFound", typeSystem.Bool));

            var ast = AstBlock.CreateOptimizedForTarget(
                new AstExpression(AstNode.NoSource, AstCode.Ret, null,
                                  new AstExpression(AstNode.NoSource, AstCode.SimpleCastclass, XType,
                                                    new AstExpression(AstNode.NoSource, AstCode.Call, parseMethod,
                                                                      new AstExpression(AstNode.NoSource, AstCode.Ldsfld, enumInfoField),
                                                                      new AstExpression(AstNode.NoSource, AstCode.Ldloc, method.AstParameters[0]),
                                                                      new AstExpression(AstNode.NoSource, AstCode.Ldc_I4, 0),
                                                                      new AstExpression(AstNode.NoSource, AstCode.Ldc_I4, 1)))));

            return(ast);
        }
Example #14
0
        private async void ReloadRequests(SHTarget Target)
        {
            if (0 < LoadLevel)
            {
                return;
            }

            ReqTarget = Target;
            MarkLoading();
            HSLoader <SHRequest> CLoader = new HSLoader <SHRequest>(
                BindItem.Id
                , Target
                , (_Target, _Skip, _Limit, _Ids) => Shared.ShRequest.GetRequests(_Target, _Ids[0], _Skip, _Limit)
                );

            CLoader.ConvertResult = xs =>
            {
                XParameter XParam = XGrant.Parameter(BindItem.Id);
                if (XParam != null)
                {
                    foreach (SHRequest x in xs)
                    {
                        x.Granted = XParam.FindParameter(x.Id) != null;
                    }
                }
                return(xs.ToArray());
            };

            IList <SHRequest> FirstPage = await CLoader.NextPage();

            MarkNotLoading();

            RequestsSource = new Observables <SHRequest, SHRequest>(FirstPage);
            RequestsSource.ConnectLoader(CLoader);

            RequestsSource.LoadStart += (x, y) => MarkLoading();
            RequestsSource.LoadEnd   += (x, y) => MarkNotLoading();
            RequestList.ItemsSource   = RequestsSource;
        }
Example #15
0
        private void MigrateContentReaderLayout()
        {
            Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Layout_MainPage.xml");
            Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Layout_NavLPage.xml");
            Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Layout_StaffPicks.xml");
            Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "Deathblow.xml");
            Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "ReadingHistory.xml");
            Shared.Storage.DeleteFile(FileLinks.ROOT_SETTING + "LocalBookStorage.xml");
            Shared.Storage.DeleteFile(FileLinks.ROOT_WTEXT + "SpecialTopics.xml");
            Shared.Storage.DeleteFile(FileLinks.ROOT_WTEXT + "SpecialTopics.lat");
            Shared.Storage.DeleteFile(FileLinks.ROOT_WTEXT + "presslist.xml");

            XRegistry XReg = new XRegistry("<xml />", FileLinks.ROOT_SETTING + "Layout_BookInfoView.xml");

            GRConfig.System.TwitterConfirmed = XReg.Parameter("TwitterConfirmed")?.GetBool("val", false) == true;

            XParameter BgConf = XReg.Parameter("INFO_VIEW");

            if (BgConf != null)
            {
                GRConfig.BookInfoView.BgContext.BgType  = BgConf.GetValue("type");
                GRConfig.BookInfoView.BgContext.BgValue = BgConf.GetValue("value");
            }

            Shared.Storage.DeleteFile(XReg.Location);

            XReg = new XRegistry("<xml />", FileLinks.ROOT_SETTING + "Layout_ContentReader.xml");
            GRConfig.ContentReader.IsRightToLeft = XReg.Parameter("IsRightToLeft")?.GetBool("enable", false) == true;
            GRConfig.ContentReader.IsHorizontal  = XReg.Parameter("IsHorizontal")?.GetBool("enable", false) == true;

            BgConf = XReg.Parameter("CONTENT_READER");
            if (BgConf != null)
            {
                GRConfig.BookInfoView.BgContext.BgType  = BgConf.GetValue("type");
                GRConfig.BookInfoView.BgContext.BgValue = BgConf.GetValue("value");
            }

            Shared.Storage.DeleteFile(XReg.Location);
        }
Example #16
0
        public bool InsertBinaryIntoCell(byte[] binaryData, string sqlQuery, string argumentNameWithBinaryData, params XParameter[] args)
        {
            ClearError();

            var parameters = new XParameter[args.Length + 1];

            for (var i = 0; i < args.Length; i++)
            {
                parameters[i] = args[i];
            }
            parameters[args.Length] = new XParameter(argumentNameWithBinaryData, binaryData);

            try
            {
                return(Update(sqlQuery, parameters) >= (int)XResult.ChangesApplied);
            }
            catch (Exception ex)
            {
                RegisterError(ex.Message);
                return(false);
            }
        }
Example #17
0
 /// <summary>
 /// Is my parameter type the same as the type of the other parameter?
 /// </summary>
 public bool IsSame(XParameter other)
 {
     /*if (Kind != other.Kind)
      *  return false;*/
     return(ParameterType.IsSame(other.ParameterType));
 }
Example #18
0
 /// <summary>
 /// Is my parameter type the same as the type of the other parameter?
 /// </summary>
 public bool IsSame(XParameter other)
 {
     /*if (Kind != other.Kind)
         return false;*/
     return ParameterType.IsSame(other.ParameterType);
 }
Example #19
0
        /// <summary>
        /// Create the body of the class ctor.
        /// </summary>
        private AstBlock CreateClassCtorBody(bool isWide, XFieldDefinition enumInfoField, XFieldDefinition defaultField, XMethodReference enumInfoCtor, XTypeReference valueType, XTypeSystem typeSystem)
        {
            var internalEnumType     = Compiler.GetDot42InternalType("Enum");
            var internalEnumInfoType = Compiler.GetDot42InternalType("EnumInfo");
            var valueToFieldMap      = new Dictionary <object, XFieldDefinition>();
            var ldc = isWide ? AstCode.Ldc_I8 : AstCode.Ldc_I4;

            var ast = AstBlock.CreateOptimizedForTarget(
                // Instantiate enum info field
                new AstExpression(AstNode.NoSource, AstCode.Stsfld, enumInfoField,
                                  new AstExpression(AstNode.NoSource, AstCode.Newobj, enumInfoCtor)));

            // Instantiate values for each field
            var ordinal = 0;

            foreach (var field in XType.Fields.Where(x => x.IsStatic && !(x is XSyntheticFieldDefinition)))
            {
                // Find dex field
                object value;
                if (!field.TryGetEnumValue(out value))
                {
                    throw new CompilerException(string.Format("Cannot get enum value from field {0}", field.FullName));
                }
                value = isWide ? (object)XConvert.ToLong(value) : (object)XConvert.ToInt(value);
                XFieldDefinition existingField;
                AstExpression    valueExpr;
                if (valueToFieldMap.TryGetValue(value, out existingField))
                {
                    // Re-use instance of existing field
                    valueExpr = new AstExpression(AstNode.NoSource, AstCode.Ldsfld, existingField);
                }
                else
                {
                    // Record
                    valueToFieldMap[value] = field;

                    // Call ctor
                    valueExpr = new AstExpression(AstNode.NoSource, AstCode.Newobj, ctor,
                                                  new AstExpression(AstNode.NoSource, AstCode.Ldstr, field.Name),
                                                  new AstExpression(AstNode.NoSource, AstCode.Ldc_I4, ordinal),
                                                  new AstExpression(AstNode.NoSource, ldc, value));
                }

                // Initialize static field
                ast.Body.Add(new AstExpression(AstNode.NoSource, AstCode.Stsfld, field, valueExpr));

                // Add to info
                var addMethod = new XMethodReference.Simple("Add", true, typeSystem.Void, internalEnumInfoType,
                                                            XParameter.Create("value", valueType),
                                                            XParameter.Create("instance", internalEnumType));
                ast.Body.Add(new AstExpression(AstNode.NoSource, AstCode.Call, addMethod,
                                               new AstExpression(AstNode.NoSource, AstCode.Ldsfld, enumInfoField),
                                               new AstExpression(AstNode.NoSource, ldc, value),
                                               new AstExpression(AstNode.NoSource, AstCode.Ldsfld, field)));

                // Increment ordinal
                ordinal++;
            }

            // Initialize default field
            var getValueMethod = new XMethodReference.Simple("GetValue", true, internalEnumType, internalEnumInfoType,
                                                             XParameter.Create("value", valueType));

            ast.Body.Add(new AstExpression(AstNode.NoSource, AstCode.Stsfld, defaultField,
                                           new AstExpression(AstNode.NoSource, AstCode.SimpleCastclass, XType,
                                                             new AstExpression(AstNode.NoSource, AstCode.Call, getValueMethod,
                                                                               new AstExpression(AstNode.NoSource, AstCode.Ldsfld, enumInfoField),
                                                                               new AstExpression(AstNode.NoSource, ldc, 0)))));

            // Return
            ast.Body.Add(new AstExpression(AstNode.NoSource, AstCode.Ret, null));
            return(ast);
        }
Example #20
0
        /// <summary>
        /// Implement the class now that all classes have been created
        /// </summary>
        protected override void CreateMembers(DexTargetPackage targetPackage)
        {
            // Build value__ field
            var module             = Compiler.Module;
            var underlyingEnumType = Type.GetEnumUnderlyingType();
            var isWide             = underlyingEnumType.IsWide();
            var xValueType         = isWide ? module.TypeSystem.Long : module.TypeSystem.Int;
            var valueField         = XSyntheticFieldDefinition.Create(XType, XSyntheticFieldFlags.Protected, NameConstants.Enum.ValueFieldName, xValueType);

            Class.Fields.Add(valueField.GetDexField(Class, targetPackage));

            // Create normal members
            base.CreateMembers(targetPackage);

            // Build value ctor
            ctor = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Constructor | XSyntheticMethodFlags.Protected, "<init>", module.TypeSystem.Void,
                                                     XParameter.Create("name", module.TypeSystem.String),
                                                     XParameter.Create("ordinal", module.TypeSystem.Int),
                                                     XParameter.Create("value", xValueType));
            ctor.Body = CreateCtorBody(ctor);
            Class.Methods.Add(ctor.GetDexMethod(Class, targetPackage));

            // Build enumInfo field
            var internalEnumInfoType = Compiler.GetDot42InternalType("EnumInfo");
            var enumInfoField        = XSyntheticFieldDefinition.Create(XType, XSyntheticFieldFlags.Static, NameConstants.Enum.InfoFieldName, internalEnumInfoType /* enumInfoClassBuilder.Class*/);

            Class.Fields.Add(enumInfoField.GetDexField(Class, targetPackage));

            // Build default__ field
            var defaultField = XSyntheticFieldDefinition.Create(XType, XSyntheticFieldFlags.Static, NameConstants.Enum.DefaultFieldName, XType);

            Class.Fields.Add(defaultField.GetDexField(Class, targetPackage));

            // Build class ctor
            var classCtor = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Static | XSyntheticMethodFlags.Constructor | XSyntheticMethodFlags.Private, "<clinit>", module.TypeSystem.Void);

            classCtor.Body = CreateClassCtorBody(isWide, enumInfoField, defaultField, enumInfoClassBuilder.DefaultCtor, xValueType, module.TypeSystem);
            Class.Methods.Add(classCtor.GetDexMethod(Class, targetPackage));

            if (!isWide)
            {
                // Build IntValue method
                var intValue = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Virtual, "IntValue", module.TypeSystem.Int);
                intValue.Body = CreateIntOrLongValueBody();
                Class.Methods.Add(intValue.GetDexMethod(Class, targetPackage));
            }
            else
            {
                // Build LongValue method
                var longValue = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Virtual, "LongValue", module.TypeSystem.Long);
                longValue.Body = CreateIntOrLongValueBody();
                Class.Methods.Add(longValue.GetDexMethod(Class, targetPackage));
            }

            // Build values() method
            var valuesMethod = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Static, NameConstants.Enum.ValuesMethodName, new XArrayType(XType));

            valuesMethod.Body = CreateValuesBody();
            Class.Methods.Add(valuesMethod.GetDexMethod(Class, targetPackage));

            // Build valueOf(string) method
            var valueOfMethod = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Static, NameConstants.Enum.ValueOfMethodName, XType, XParameter.Create("name", module.TypeSystem.String));

            valueOfMethod.Body = CreateValueOfBody(valueOfMethod, module.TypeSystem);
            Class.Methods.Add(valueOfMethod.GetDexMethod(Class, targetPackage));

            // Build Unbox(object) method
            unboxMethod      = XSyntheticMethodDefinition.Create(XType, XSyntheticMethodFlags.Static, NameConstants.Enum.UnboxMethodName, XType, XParameter.Create("value", Compiler.Module.TypeSystem.Object));
            unboxMethod.Body = CreateUnboxBody(unboxMethod, isWide, Compiler);
            Class.Methods.Add(unboxMethod.GetDexMethod(Class, targetPackage));
        }
Example #21
0
 /// <summary>
 /// Reference to java.lang.String.equals(string)
 /// </summary>
 internal static XMethodReference StringEquals(XTypeSystem typeSystem)
 {
     return(new XMethodReference.Simple("equals", true, typeSystem.Bool, typeSystem.String, XParameter.Create("other", typeSystem.Object)));
 }
Example #22
0
        private async Task <Book> MigrateBookSpider(string SRoot, string ZoneId, string ZItemId)
        {
            if (!Shared.Storage.FileExists(SRoot + "METADATA.xml"))
            {
                return(null);
            }

            XRegistry  MetaDefs  = new XRegistry("<metadata />", SRoot + "METADATA.xml");
            XParameter MetaParam = MetaDefs.Parameter("METADATA");

            BookInstruction BkInst = new BookInstruction(ZoneId, ZItemId);

            BkInst.Title                = MetaParam.GetValue("Title");
            BkInst.Info.Author          = MetaParam.GetValue("Author");
            BkInst.Info.Press           = MetaParam.GetValue("Press");
            BkInst.Info.LastUpdateDate  = MetaParam.GetValue("LastUpdateDate");
            BkInst.Info.TotalHitCount   = MetaParam.GetValue("TotalHitCount");
            BkInst.Info.DailyHitCount   = MetaParam.GetValue("TodayHitCount");
            BkInst.Info.PushCount       = MetaParam.GetValue("PushCount");
            BkInst.Info.FavCount        = MetaParam.GetValue("FavCount");
            BkInst.Info.Length          = MetaParam.GetValue("Length");
            BkInst.Info.LatestSection   = MetaParam.GetValue("LatestSection");
            BkInst.Info.LongDescription = MetaParam.GetValue("Intro");

            Book Entry = BkInst.Entry;
            await Shared.BooksDb.LoadCollectionAsync(Entry, x => x.Volumes, x => x.Index);

            Entry.Volumes.Clear();

            XRegistry TOCDefs = new XRegistry("<metadata />", SRoot + "/" + "toc.txt");

            int        vi       = 0;
            XParameter VolParam = TOCDefs.Parameter("VolInst" + vi);

            while (VolParam != null)
            {
                Volume Vol = new Volume()
                {
                    Book     = Entry,
                    Title    = VolParam.GetValue("Title"),
                    Index    = VolParam.GetSaveInt("Index"),
                    Chapters = new List <Chapter>()
                };

                Vol.Meta["ProcId"]           = VolParam.GetValue("ProcId");
                Vol.Meta[AppKeys.GLOBAL_VID] = Utils.Md5(Vol.Title);

                XParameter PParam = VolParam.Parameter("0");
                for (int p = 1; PParam != null; p++)
                {
                    Vol.Meta["P" + PParam.Id] = PParam.GetValue("Value");
                    PParam = VolParam.Parameter(p.ToString());
                }

                string MVolHash = Utils.Md5(Vol.Title);

                int        ei      = 0;
                XParameter ChParam = VolParam.Parameter("EpInst" + ei);
                while (ChParam != null)
                {
                    Chapter Ch = new Chapter()
                    {
                        Book   = Entry,
                        Volume = Vol,
                        Title  = ChParam.GetValue("Title"),
                        Index  = ChParam.GetSaveInt("Index")
                    };

                    Ch.Meta["ProcId"]           = ChParam.GetValue("ProcId");
                    Ch.Meta[AppKeys.GLOBAL_CID] = Utils.Md5(Ch.Title);

                    string MChHash = Utils.Md5(Ch.Title);

                    PParam = ChParam.Parameter("0");
                    for (int p = 1; PParam != null; p++)
                    {
                        Ch.Meta["P" + PParam.Id] = PParam.GetValue("Value");
                        PParam = ChParam.Parameter(p.ToString());
                    }

                    Vol.Chapters.Add(Ch);

                    string ChLocation = SRoot + MVolHash + "/" + MChHash + ".txt";
                    if (Shared.Storage.FileExists(ChLocation))
                    {
                        ChapterContent ChCont = new ChapterContent()
                        {
                            Chapter = Ch,
                        };
                        ChCont.Data.BytesValue = Shared.Storage.GetBytes(ChLocation);
                        Shared.BooksDb.ChapterContents.Add(ChCont);
                    }

                    ChParam = VolParam.Parameter("EpInst" + (++ei));
                }

                Entry.Volumes.Add(Vol);

                VolParam = TOCDefs.Parameter("VolInst" + (++vi));
            }

            SpiderBook SBk = await SpiderBook.CreateSAsync(ZoneId, ZItemId, MetaDefs.Parameter("Procedures"));

            // Preserve the process state
            XParameter ProcState = MetaDefs.Parameter("ProcessState");

            if (ProcState != null)
            {
                SBk.PSettings.SetParameter(ProcState);
            }

            SBk.PSettings.Save();
            return(Entry);
        }