Esempio n. 1
0
        public override void Initialize()
        {
            base.Initialize();

            Settings = new PersistentObject<BackpackSettings>(new BackpackSettings());
            Settings.SetFilePathAndLoad(Path.Combine(this.ModuleDataDir, "settings.xml"));
        }
Esempio n. 2
0
        public override void Initialize()
        {
            base.Initialize();
            Settings = new PersistentObject<GrangerSettings>(new GrangerSettings());
            Settings.SetFilePathAndLoad(Path.Combine(base.ModuleDataDir, "settings.xml"));

            //init database
            DBSchema.SetConnectionString(Path.Combine(this.ModuleDataDir, "grangerDB.s3db"));

            SQLiteHelper.CreateTableIfNotExists(DBSchema.HorsesSchema, DBSchema.HorsesTableName, DBSchema.ConnectionString);
            SQLiteHelper.ValidateTable(DBSchema.HorsesSchema, DBSchema.HorsesTableName, DBSchema.ConnectionString);

            SQLiteHelper.CreateTableIfNotExists(DBSchema.TraitValuesSchema, DBSchema.TraitValuesTableName, DBSchema.ConnectionString);
            SQLiteHelper.ValidateTable(DBSchema.TraitValuesSchema, DBSchema.TraitValuesTableName, DBSchema.ConnectionString);

            SQLiteHelper.CreateTableIfNotExists(DBSchema.HerdsSchema, DBSchema.HerdsTableName, DBSchema.ConnectionString);
            SQLiteHelper.ValidateTable(DBSchema.HerdsSchema, DBSchema.HerdsTableName, DBSchema.ConnectionString);

            Context = new GrangerContext(new SQLiteConnection(DBSchema.ConnectionString));

            GrangerUI = new FormGrangerMain(this, Settings, Context);

            LogFeedMan = new LogFeedManager(this, Context);
            LogFeedMan.UpdatePlayers(Settings.Value.CaptureForPlayers);
            GrangerUI.Granger_PlayerListChanged += GrangerUI_Granger_PlayerListChanged;
        }
Esempio n. 3
0
        public FormGrangerMain(ModuleGranger moduleGranger, PersistentObject<GrangerSettings> settings, GrangerContext context)
        {
            this.ParentModule = moduleGranger;
            this.Settings = settings;
            this.Context = context;

            InitializeComponent();

            RebuildValuePresets();
            RefreshValuator();
            RebuildAdvisors();
            RefreshAdvisor();

            ucGrangerHerdList1.Init(this, context);
            ucGrangerHorseList1.Init(this, context);
            ucGrangerTraitView1.Init(this, context);

            Context.OnTraitValuesModified += Context_OnTraitValuesModified;

            this.Size = Settings.Value.MainWindowSize;

            this.checkBoxCapturingEnabled.Checked = Settings.Value.LogCaptureEnabled;
            this.UpdateViewsVisibility();
            this.Update_textBoxCaptureForPlayers();

            _WindowInitCompleted = true;
        }
Esempio n. 4
0
        public SoundNotifier(ModuleSoundNotify parentModule, string player, string moduleDataDir)
        {
            this.ParentModule = parentModule;
            Player = player;
            thisNotifierDataDir = Path.Combine(moduleDataDir, player);
            if (!Directory.Exists(thisNotifierDataDir)) Directory.CreateDirectory(thisNotifierDataDir);

            Settings = new PersistentObject<NotifierSettings>(new NotifierSettings());
            Settings.FilePath = Path.Combine(thisNotifierDataDir, "settings.xml");
            if (!Settings.Load())
            {
                Settings.Save();
            }

            //create control for Module UI
            controlUI = new UControlSoundNotifyPlayerController();

            //create this notifier UI
            SoundManagerUI = new FormSoundNotifyConfig(this);

            UpdateMutedState();
            controlUI.label1.Text = player;
            controlUI.buttonMute.Click += ToggleMute;
            controlUI.buttonConfigure.Click += Configure;
            controlUI.buttonRemove.Click += Stop;

            InitPortedCode(Player);
            WurmLogs.SubscribeToLogFeed(this.Player, OnNewLogEvents);
        }
Esempio n. 5
0
 public RowObjectAdapter(PersistentObject obj, Selector columnNames)
     : base(obj.TableName, obj.Locator, obj.NewRow)
 {
     this.obj = obj;
     this.transaction = obj.Transaction;
     Bind(columnNames);
 }
Esempio n. 6
0
        PropertyInfo propertyInfo2; //fieldof(DPCollection<RoleDpo>)  or fieldof(xxxDpo)

        #endregion Fields

        #region Constructors

        public Mapping(PersistentObject dpo, PropertyInfo propertyInfo2)
        {
            this.association = Reflex.GetAssociationAttribute(propertyInfo2);

            if (association == null)
                return;

            this.dpoInstance = dpo;
            this.propertyInfo2 = propertyInfo2;

            Type dpoType2;            //typeof(RoleDpo)
            if (propertyInfo2.PropertyType.IsGenericType)
            {
                dpoType2 = PersistentObject.GetCollectionGenericType(propertyInfo2);

                if (this.association.TRelation == null)
                    mappingType = MappingType.One2Many;
                else
                    mappingType = MappingType.Many2Many;
            }
            else
            {
                dpoType2 = propertyInfo2.PropertyType;
                mappingType = MappingType.One2One;
            }

            this.propertyInfo1 = dpo.GetType().GetProperty(association.Column1);

            if (mappingType == MappingType.Many2Many)
            {
                this.clause1 = new SqlBuilder()
                    .SELECT.COLUMNS(association.Relation2)
                    .FROM(association.TRelation)
                    .WHERE(association.Relation1.ColumnName() == association.Column1.ParameterName());

                this.clause2 = new SqlBuilder()
                    .SELECT
                    .COLUMNS()
                    .FROM(dpoType2)
                    .WHERE(association.Relation2.ColumnName().IN(this.clause1));

            }
            else
            {
                SqlExpr where = association.Column2.ColumnName() == association.Column1.ParameterName();
                if (association.Filter != null)
                    where = where.AND(association.Filter);

                this.clause2 = new SqlBuilder()
                    .SELECT
                    .COLUMNS()
                    .FROM(dpoType2)
                    .WHERE(where);

                if(association.OrderBy != null)
                    this.clause2 = clause2.ORDER_BY(association.OrderBy);
            }
        }
Esempio n. 7
0
 public override void Initialize(PlayerTimersGroup parentGroup, string player, string timerId,
     WurmServer.ServerInfo.ServerGroup serverGroup, string compactId)
 {
     base.Initialize(parentGroup, player, timerId, serverGroup, compactId);
     Settings = new PersistentObject<JunkSaleTimerSettings>(new JunkSaleTimerSettings());
     Settings.SetFilePathAndLoad(SettingsSavePath);
     TimerDisplay.ShowSkill = true;
     VerifyMoneyAmountAgainstCd();
     UpdateMoneyCounter();
     InitCompleted = true;
 }
Esempio n. 8
0
        public override void Initialize()
        {
            base.Initialize();
            Settings = new PersistentObject<TriggersSettings>(new TriggersSettings());
            Settings.SetFilePathAndLoad(Path.Combine(this.ModuleDataDir, "settings.xml"));

            const string queueSoundModFileName = "QueueSoundMod.txt";
            LogQueueParseHelper.Build(
                Path.Combine(this.ModuleDataDir, queueSoundModFileName),
                Path.Combine(this.ModuleAssetDir, queueSoundModFileName));

            SoundBank.ChangeGlobalVolume(Settings.Value.GlobalVolume);
            MainUI = new FormTriggersMain(this);
            foreach (var name in Settings.Value.ActiveCharacterNames.ToArray())
            {
                AddManager(name);
            }

            if (!Settings.Value.SoundNotifyImportCompleted)
            {
                try
                {
                    var importer = new SoundTriggersImporter(this);
                    var executed = importer.Execute();
                    if (executed)
                    {
                        importer.RenameDir();
                        Settings.Value.SoundNotifyImportCompleted = true;
                        Settings.Save();
                        MainUI.Shown += (sender, args) =>
                                       {
                                           MessageBox.Show(
                                               "Existing Sound Triggers have been imported into new Triggers feature. " +
                                               "If there were any errors or imported triggers are incorrect, please post a bug report in forum thread. " +
                                               "Importing can be repeated if needed, nothing is lost.",
                                               "Wurm Assistant Sound Triggers Importer",
                                               MessageBoxButtons.OK,
                                               MessageBoxIcon.Asterisk);
                                           Application.Restart();
                                       };

                    }
                }
                catch (Exception exception)
                {
                    Logger.LogError("Unknown error while importing Sound Triggers", this, exception);
                    MessageBox.Show(
                        "There was an unforseen error while trying to import Sound Triggers settings to new Triggers. Please report this as soon as possible. Process can be repeated, nothing is lost!", 
                        "OH NOES!", 
                        MessageBoxButtons.OK, 
                        MessageBoxIcon.Error);
                }
            }
        }
Esempio n. 9
0
        protected internal ActionBase(Definition definition, PersistentObject parent, Query query = null)
        {
            this.definition = definition;
            Parent = parent;
            Query = query;

            Options = definition.Options;

            Command = new ActionCommand(async obj => await Service.Current.Hooks.OnActionCommand(this, obj), _ => CanExecute, this, "CanExecute");

            CanExecute = query == null;
        }
Esempio n. 10
0
        public PlayerTimersGroup(ModuleTimers parentModule, string player)
        {
            this.ParentModule = parentModule;
            if (player != null) this.Player = player;

            Settings = new PersistentObject<GroupSettings>(new GroupSettings());
            ThisGroupDir = Path.Combine(ParentModule.ModuleDataDir, Player);
            Settings.FilePath = Path.Combine(ThisGroupDir, "activeTimers.xml");
            if (!Settings.Load()) Settings.Save();

            LayoutControl = new UControlPlayerLayout(this);
            ParentModule.RegisterTimersGroup(LayoutControl);
            WurmLogs.SubscribeToLogFeed(Player, OnNewLogEvents);
            // init timers AT THE END of this async method
            // also may need to block adding/removing timers until this is done
            PerformAsyncInits(Settings.Value.LastServerGroupCheckup);
        }
Esempio n. 11
0
 public override void Initialize()
 {
     base.Initialize();
     Settings = new PersistentObject<TimersSettings>(new TimersSettings());
     Settings.FilePath = Path.Combine(this.ModuleDataDir, "settings.xml");
     if (!Settings.Load())
     {
         Settings.Save();
     }
     WurmTimerDescriptors.RemovedCustomTimer += WurmTimerDescriptors_RemovedCustomTimer;
     ModuleUI = new FormTimers(this);
     WurmTimerDescriptors.LoadCustomTimers(Path.Combine(this.ModuleDataDir, "customTimers.xml"));
     foreach (string player in Settings.Value.ActivePlayers)
     {
         AddNewPlayerGroup(player);
     }
 }
        public void TestAbstractPersistentObjectHasSamePersistenceId()
        {
            PersistentObject po1 = new PersistentObject
            {
                PersistenceId = null
            };
            PersistentObject po2 = new PersistentObject
            {
                PersistenceId = null
            };
            po1.HasSamePersistenceId(po2);
            po2.HasSamePersistenceId(po1);

            po1.PersistenceId = null;
            po2.PersistenceId = 1;
            po1.HasSamePersistenceId(po2);
            po2.HasSamePersistenceId(po1);

            po1.PersistenceId = 1;
            po2.PersistenceId = null;
            po1.HasSamePersistenceId(po2);
            po2.HasSamePersistenceId(po1);

            po1.PersistenceId = 1;
            po2.PersistenceId = 2;
            po1.HasSamePersistenceId(po2);
            po2.HasSamePersistenceId(po1);

            po1.PersistenceId = 2;
            po2.PersistenceId = 1;
            po1.HasSamePersistenceId(po2);
            po2.HasSamePersistenceId(po1);

            po1.PersistenceId = 1;
            po2.PersistenceId = 1;
            po1.HasSamePersistenceId(po2);
            po2.HasSamePersistenceId(po1);
        }
Esempio n. 13
0
        public void DeleteObject(PersistentObject obj)
        {
            ClassMap             clsMap = GetClassMap(obj.GetClassName());
            IDbCommand           cmd    = clsMap.GetDeleteSqlFor(obj);
            IPersistenceProvider rdb    = clsMap.PersistenceProvider.GetCopy();

            try
            {
                rdb.Open();
                if (rdb.DoCommand(clsMap.GetDeleteSqlFor(obj)) > 0)
                {
                    obj.IsPersistent = false;
                }
            }
            catch (Exception ex)
            {
                this.ErrorHandle(ex, obj);
            }
            finally
            {
                rdb.Close();
            }
        }
Esempio n. 14
0
        public override void OnSave(PersistentObject obj)
        {
            var informationTypeIdAttr  = obj["InformationTypeId"];
            var sensitivityLabelIdAttr = obj["SensitivityLabelId"];

            if (!CheckRules(obj))
            {
                return;
            }

            var entity = LoadEntity(obj);

            var sql = string.Format(entity.InformationTypeId == null ? setExtendedPropertiesFormat : updateExtendedPropertiesFormat, obj.Parent.ObjectId);
            var ids = obj.ObjectId.Split(';');
            var informationTypeId    = (string)informationTypeIdAttr ?? string.Empty;
            var informationTypeName  = informationTypeId.Length > 0 ? informationTypeIdAttr.Options.First(o => o.StartsWith(informationTypeId + "=")).Split('=')[1] : string.Empty;
            var sensitivityLabelId   = (string)sensitivityLabelIdAttr ?? string.Empty;
            var sensitivityLabelName = sensitivityLabelId.Length > 0 ? sensitivityLabelIdAttr.Options.First(o => o.StartsWith(sensitivityLabelId + "=")).Split('=')[1] : string.Empty;

            Context.Database.ExecuteSqlCommand(sql, ids[0], ids[1], ids[2], informationTypeId, informationTypeName, sensitivityLabelId, sensitivityLabelName);

            Manager.Current.QueueClientOperation(new RefreshOperation("ClassifyData.Database", obj.Parent.ObjectId));
        }
Esempio n. 15
0
        public Packing(Type dpoType)
        {
            this.dpoType = dpoType;
            instance = (PersistentObject)Activator.CreateInstance(this.dpoType);

            this.publicFields = dpoType.GetFields(BindingFlags.Public | BindingFlags.Instance);    //ignore public const fields

            Type baseType = typeof(BasePackage<>);
            baseType = baseType.MakeGenericType(dpoType);

            this.classBuilder = new CSharpBuilder()
            {
                nameSpace = dpoType.Assembly.GetName().Name + "." + Setting.DPO_PACKAGE_SUB_NAMESPACE,
            };

            this.classBuilder.AddUsing("System")
            .AddUsing("System.Data")
            .AddUsing("System.Text")
            .AddUsing("System.Collections.Generic")
            .AddUsing("Sys")
            .AddUsing("Sys.Data")
            .AddUsing("Sys.Data.Manager")
            .AddUsing(dpoType.Namespace);

            var clss = new Class(ClassName, new CodeBuilder.TypeInfo { type = baseType })
            {
                modifier = Modifier.Public
            };

            //constructor
            clss.Add(new Constructor(ClassName));

            this.pack = new Method("Pack") { modifier = Modifier.Protected | Modifier.Override };
            clss.Add(pack);

            classBuilder.AddClass(clss);
        }
Esempio n. 16
0
        private void BuildDTOAnyObjectProperties(PersistentObjectDTO dto, PersistentObject real, Type AttributeType)
        {
            Type dtoType     = dto.GetType();
            var  objectProps = from x in dtoType.GetProperties()
                               where x.IsDefined(AttributeType, false)
                               select x;

            foreach (var propDTO in objectProps)
            {
                // TODO: this just cuts an ID at the end.
                // In case more sophisticated logic is required, it should be possible to set name as a property of ObjectPropertyAttribute.
                var realPropName = propDTO.Name.Substring(0, propDTO.Name.Length - 2);
                var propReal     = real.GetType().GetProperty(realPropName);
                var obj          = propReal.GetValue(real, null) as PersistentObject;
                if (obj == null)
                {
                    propDTO.SetValue(dto, Guid.Empty, null);
                }
                else
                {
                    propDTO.SetValue(dto, obj.ID, null);
                }
            }
        }
        protected void RestoreDataAndResolveDependencies()
        {
            List <GameObject> goList           = new List <GameObject>();
            List <bool>       goActivationList = new List <bool>();

            for (int i = 0; i < Data.Length; ++i)
            {
                PersistentObject data = Data[i];
                long             id   = Identifiers[i];

                UnityObject obj = FromID <UnityObject>(id);
                if (obj == null)
                {
                    Debug.LogWarningFormat("objects does not have object with instance id {0} however PersistentData of type {1} is present", id, data.GetType());
                    continue;
                }

                data.WriteTo(obj);
                if (obj is GameObject)
                {
                    goList.Add((GameObject)obj);
                    PersistentGameObject goData = (PersistentGameObject)data;
                    goActivationList.Add(goData.ActiveSelf);
                }
            }

            for (int i = 0; i < goList.Count; ++i)
            {
                bool       activeSelf = goActivationList[i];
                GameObject go         = goList[i];
                if (go != null)
                {
                    go.SetActive(activeSelf);
                }
            }
        }
Esempio n. 18
0
        /// <inheritdoc />
        protected override void SaveNew(PersistentObject obj)
        {
            var newEntity = CreateNewEntity(obj);

            var parent = obj.Parent;

            if (parent != null)
            {
                SetParentRelation(obj, parent, newEntity, GetEntityType(obj));
            }

            UpdateEntity(obj, newEntity);

            if (CheckRules(obj, newEntity))
            {
                PersistToContext(obj, newEntity);

                PopulateAfterPersist(obj, newEntity);
            }
            else
            {
                throw new SaveFailedException();
            }
        }
Esempio n. 19
0
        public ValidationError Validate(PersistentObject dto)
        {
            ValidationError rootError = null;

            var simplePropertyErrors = ValidateSimpleProperties(dto);
            var collectionErrors     = ValidateObjectCollections(dto);

            if (simplePropertyErrors.Count > 0 || collectionErrors.Count > 0)
            {
                rootError = new ValidationError(
                    String.Format("Object (Type: '{0}', Id: '{1}') state is invalid.", dto.PersistentType.Name, dto.Id.ToString()));

                foreach (var error in simplePropertyErrors)
                {
                    rootError.AddErrorAsNested(error);
                }
                foreach (var error in collectionErrors)
                {
                    rootError.AddErrorAsNested(error);
                }
            }

            return(rootError);
        }
Esempio n. 20
0
        /// <inheritdoc />
        protected override TEntity LoadEntity(PersistentObject obj, bool forRefresh = false)
        {
            if (obj == null)
            {
                throw new ArgumentNullException("obj");
            }

            TEntity loadEntity;

            if (obj.IsNew && forRefresh)
            {
                loadEntity = CreateNewEntity(obj);
            }
            else
            {
                loadEntity = Context.GetEntity <TEntity>(obj);
            }

            if (loadEntity != null && forRefresh)
            {
                obj.PopulateObjectValues(loadEntity, Context, false);
            }
            return(loadEntity);
        }
Esempio n. 21
0
        /// <inheritdoc />
        public override void OnAddReference(PersistentObject parent, IEnumerable <TEntity> entities, Query query, QueryResultItem[] selectedItems)
        {
            // This method is called when a Query has defined the LookupSource and the end user uses the "Add" action to select items
            // Or when a developer uses the AddReference method on a Custom Action and the end user uses selects items

            string addAction;

            if (Parameters != null && Parameters.TryGetValue("AddAction", out addAction))
            {
                throw new FaultException(string.Format("DEV: Invalid custom AddReference call, you must override the OnAddReference method in the PersistentObject actions class ({0}Actions) and handle '{1}'.", query.PersistentObject.Type, addAction));
            }

            if (parent == null)
            {
                throw new FaultException(string.Format("DEV: Invalid AddReference call, if this is a custom implementation you must override the OnAddReference method in the PersistentObject actions class ({0}Actions).", query.PersistentObject.Type));
            }

            if (selectedItems != null)
            {
                var loadedParentEntity = Context.GetEntity(parent, true);
                entities.Run(e => loadedParentEntity.AddToChildCollection(e.GetType(), e, true, query.Source));
                PersistChanges();
            }
        }
Esempio n. 22
0
        public override void Initialize()
        {
            base.Initialize();
            Settings = new PersistentObject<SoundNotifySettings>(new SoundNotifySettings());
            Settings.FilePath = Path.Combine(this.ModuleDataDir, "settings.xml");
            if (!Settings.Load())
            {
                Settings.Save();
            }

            const string queueSoundModFileName = "QueueSoundMod.txt";
            LogQueueParseHelper.Build(
                Path.Combine(this.ModuleDataDir, queueSoundModFileName), 
                Path.Combine(this.ModuleAssetDir, queueSoundModFileName));

            SoundBank.ChangeGlobalVolume(Settings.Value.GlobalVolume);
            MainUI = new FormSoundNotifyMain(this);
            string[] activePlayers = Settings.Value.ActiveCharacterNames.ToArray();
            foreach (var name in activePlayers)
            {
                AddNotifier(name);
            }
            
        }
Esempio n. 23
0
 protected internal virtual void OnSessionUpdated(PersistentObject session)
 {
 }
Esempio n. 24
0
 protected internal virtual Task <int> OnRetryAction(string title, string message, string[] options, PersistentObject persistentObject)
 {
     return(Task.FromResult(-1));
 }
 public BookAuthorsBusinessObject()
 {
     persistent = new PersistentObject(mapped);
 }
Esempio n. 26
0
 public ShowHelp(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
 }
Esempio n. 27
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PersistentObject obj)
 {
     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
 }
Esempio n. 28
0
 public CancelSave(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
 }
Esempio n. 29
0
 internal virtual void OnOpen(PersistentObject po)
 {
 }
Esempio n. 30
0
 public virtual bool ParsePersistentObject(PersistentObject t)
 {
     t.Clear();
     t.NewLineAfter.Value = string.Empty;
     if (CurrentToken.Class == TokenClass.ServerTagStart && CurrentToken.ServerTagClass == ServerTagClass.PersistentObject) {
         t.StartToken.Read();
         if (CurrentToken.Class == TokenClass.Literal && CurrentToken.ServerTagClass == ServerTagClass.PersistentObject) {
             t.NameToken.Read();
             if (CurrentToken.Class == TokenClass.ServerTagEnd && CurrentToken.ServerTagClass == ServerTagClass.PersistentObjectName) {
                 t.NameEndToken.Read();
                 if (CurrentToken.Class == TokenClass.Literal && CurrentToken.ServerTagClass == ServerTagClass.PersistentObject) {
                     t.TextToken.Read();
                     if (CurrentToken.Class == TokenClass.ServerTagEnd) {
                         t.EndToken.Read();
                         t.NewLineAfter.ReadNewLineAfter();
                         return true;
                     } else {
                         Error("PersistentObject: End of server comment expected.");
                         return false;
                     }
                 } else {
                     Error("PersistenObejct: Name end tag expected.");
                     return false;
                 }
             } else {
                 Error("PersistentObject: Literal expected.");
                 return false;
             }
         } else {
             Error("PersistentObject: Literal expected.");
             return false;
         }
     } else {
         Error("PersistenObject: Start tag expected.");
         return false;
     }
 }
Esempio n. 31
0
 public CustomerBusinessObject(Session session)
 {
     persistent = new PersistentObject(session, mapped);
 }
Esempio n. 32
0
 public BookPersistentNew(DatabaseServer server, string connectionString)
 {
     pojo = new PersistentObject(server, connectionString, bok);
 }
Esempio n. 33
0
        private PersistentObject pojo;// = new PersistentObject(bok);


        public BookPersistentNew()
        {
            pojo = new PersistentObject(bok);
        }
 /// <summary>
 /// Asserts if the persistent object passed in is derived from
 /// LogicLayerPersistentObject.
 /// </summary>
 /// <param name="persistentObject">The persistent object to test.</param>
 public static void AssertObjectType(PersistentObject persistentObject)
 {
     if (!(persistentObject is LogicLayerPersistentObject))
         throw new Exception("The current object of type '" + persistentObject.GetType().BaseType.Name + "' does not derive from LogicLayerPersistentObject");
 }
Esempio n. 35
0
 public Save(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
     IsVisible = CanExecute = true;
 }
Esempio n. 36
0
 internal virtual Query OnConstruct(Client client, JObject model, PersistentObject parent, bool asLookup)
 {
     return(new Query(client, model, parent, asLookup));
 }
Esempio n. 37
0
 protected internal virtual void OnConstruct(PersistentObject po)
 {
 }
Esempio n. 38
0
 public New(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
     var newOptions = query.PersistentObject.NewOptions;
     Options = !string.IsNullOrWhiteSpace(newOptions) ? newOptions.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).Select(o => o.Trim()).ToArray() : new string[0];
 }
Esempio n. 39
0
 public override void OnNew(PersistentObject obj, PersistentObject parent, Query query, Dictionary <string, string> parameters)
 {
     base.OnNew(obj, parent, query, parameters);
 }
Esempio n. 40
0
 public Filter(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
     definition.DisplayName = Service.Current.Messages["Search"];
     definition.IsPinned = false;
 }
Esempio n. 41
0
 protected internal QueryAction(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
     CanExecute = definition.SelectionRule(0);
 }
Esempio n. 42
0
        //defQueueSoundPlayer = new SB_SoundPlayer(Path.Combine(ParentModule.ModuleAssetDir, "defQueueSound.ogg"));
        //defQueueSoundPlayer.Load(volumeAdjust: false);

        public TriggerManager(ModuleTriggers parentModule, string player, string moduleDataDir)
        {
            this._parentModule = parentModule;
            Player = player;
            string thisNotifierDataDir = Path.Combine(moduleDataDir, player);
            if (!Directory.Exists(thisNotifierDataDir)) Directory.CreateDirectory(thisNotifierDataDir);

            Settings = new PersistentObject<NotifierSettings>(new NotifierSettings());
            Settings.SetFilePathAndLoad(Path.Combine(thisNotifierDataDir, "settings.xml"));

            //create control for Module UI
            _controlUi = new UcPlayerTriggersController();

            //create this notifier UI
            _triggersConfigUi = new FormTriggersConfig(this);

            UpdateMutedState();
            _controlUi.label1.Text = player;
            _controlUi.buttonMute.Click += ToggleMute;
            _controlUi.buttonConfigure.Click += Configure;
            _controlUi.buttonRemove.Click += Stop;

            WurmLogs.SubscribeToLogFeed(this.Player, OnNewLogEvents);
        }
Esempio n. 43
0
        public override void Initialize(PlayerTimersGroup parentGroup, string player, string timerId, ServerInfo.ServerGroup serverGroup, string compactId)
        {
            base.Initialize(parentGroup, player, timerId, serverGroup, compactId);
            //more inits
            TimerDisplay.SetCooldown(ShortMeditCooldown);
            //load settings
            Settings = new PersistentObject<MeditTimerSettings>(new MeditTimerSettings());
            Settings.FilePath = SettingsSavePath;
            if (!Settings.Load()) Settings.Save();

            SleepNotify = new SleepBonusNotify(Player, "Can turn off sleep bonus now");
            SleepNotify.Enabled = SleepBonusReminder;

            TimerDisplay.UpdateSkill(MeditationSkill);
            TimerDisplay.ShowSkill = Settings.Value.ShowMeditSkill;
            TimerDisplay.ShowMeditCount = Settings.Value.ShowMeditCount;

            MoreOptionsAvailable = true;
            PerformAsyncInits();
        }
Esempio n. 44
0
 public RefreshQuery(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
 }
Esempio n. 45
0
        /// <inheritdoc />
        protected override PersistentObjectAttributeWithReference GetParentAttributeForNew(PersistentObject obj, PersistentObject parent)
        {
            if (parent.IsNew)
            {
                return(null);
            }

            var refAttrs = obj.Attributes.OfType <PersistentObjectAttributeWithReference>().Where(a => a.Lookup.PersistentObject.Id == parent.Id).ToArray();

            return(refAttrs.Length == 1 ? refAttrs[0] : null);
        }
 public BookAuthorsBusinessObject(Session session)
 {
     persistent = new PersistentObject(session, mapped);
 }
Esempio n. 47
0
 /// <summary>
 /// Emits javascript to open the edit page in NEW (create) mode, but
 /// the edit page does not automatically create the object.
 /// <para>
 /// </para>
 /// NOTE: DO NOT pass in N=? as part of the querystring, as this will
 /// cause the new object passed in to be lost.
 /// </summary>
 /// <param name="page">The Page object.</param>
 /// <param name="newObject">The new PersistentObject created outside of the object panel.</param>
 /// <param name="additionalQueryString">Additional query strings to be
 /// appended to the end of the URL.</param>
 public static void OpenAddObjectPage(Page page, PersistentObject newObject, string additionalQueryString)
 {
     page.Session["::SessionObject::"] = newObject;
     OFunction function = OFunction.GetFunctionByObjectType(newObject.GetType().BaseType.Name);
     Window.Open(
         page.ResolveUrl(function.EditUrl) + "?ID=" +
         HttpUtility.UrlEncode(Security.Encrypt("NEW2:")) +
         "&TYPE=" + HttpUtility.UrlEncode(Security.Encrypt(newObject.GetType().BaseType.Name)) +
         "&" + additionalQueryString, "Simplism_Window");
 }
Esempio n. 48
0
 public Delete(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
 }
Esempio n. 49
0
 public void Add(PersistentObject dpo)
 {
     dpo.SetTransaction(this);
 }
 public BookAuthorsBusinessObject(DatabaseServer database, string connectionString)
 {
     persistent = new PersistentObject(database, connectionString, mapped);
 }
Esempio n. 51
0
 public BookPersistentNew(Session session)
 {
     pojo = new PersistentObject(session, bok);
 }
Esempio n. 52
0
 public override void Delete(PersistentObject obj)
 {
     // TODO Auto-generated method stub
 }
Esempio n. 53
0
 public CustomerBusinessObject(DatabaseServer database, string connectionString)
 {
     persistent = new PersistentObject(database, connectionString, mapped);
 }
Esempio n. 54
0
        public override void Create(PersistentObject obj)
        {
            string result = statementBuilder.CreateInsert(obj);

            Execute(result);
        }
Esempio n. 55
0
 public CustomerBusinessObject()
 {
     persistent = new PersistentObject(mapped);
 }
Esempio n. 56
0
 public BulkEdit(Definition definition, PersistentObject parent, Query query)
     : base(definition, parent, query)
 {
     IsVisible = false;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ResourceOperations"/> class.
 /// </summary>
 /// <param name="server">The server.</param>
 /// <param name="connectionString">The connection string.</param>
 /// <param name="res">The res.</param>
 /// <param name="persistentObject">The persistent object.</param>
 internal ResourceOperations(DatabaseServer server, string connectionString, Resources res, PersistentObject persistentObject)
 {
     this.server           = server;
     this.connectionString = connectionString;
     this.res        = res;
     this.persistent = persistentObject;
 }
        protected override object WriteToImpl(object obj)
        {
            ClearReferencesCache();

            Scene scene = (Scene)obj;

            if (Descriptors == null && Data == null)
            {
                DestroyGameObjects(scene);
                return(obj);
            }

            if (Descriptors == null && Data != null || Data != null && Descriptors == null)
            {
                throw new ArgumentException("data is corrupted", "scene");
            }

            if (Descriptors.Length == 0)
            {
                DestroyGameObjects(scene);
                return(obj);
            }

            if (Identifiers == null || Identifiers.Length != Data.Length)
            {
                throw new ArgumentException("data is corrupted", "scene");
            }

            DestroyGameObjects(scene);
            Dictionary <int, UnityObject> idToUnityObj = new Dictionary <int, UnityObject>();

            for (int i = 0; i < Descriptors.Length; ++i)
            {
                PersistentDescriptor descriptor = Descriptors[i];
                if (descriptor != null)
                {
                    CreateGameObjectWithComponents(m_typeMap, descriptor, idToUnityObj, null);
                }
            }


            UnityObject[] assetInstances = null;
            if (AssetIdentifiers != null)
            {
                IUnityObjectFactory factory = IOC.Resolve <IUnityObjectFactory>();
                assetInstances = new UnityObject[AssetIdentifiers.Length];
                for (int i = 0; i < AssetIdentifiers.Length; ++i)
                {
                    PersistentObject asset = Assets[i];

                    Type uoType = m_typeMap.ToUnityType(asset.GetType());
                    if (uoType != null)
                    {
                        if (factory.CanCreateInstance(uoType, asset))
                        {
                            UnityObject assetInstance = factory.CreateInstance(uoType, asset);
                            if (assetInstance != null)
                            {
                                assetInstances[i] = assetInstance;
                                idToUnityObj.Add(AssetIdentifiers[i], assetInstance);
                            }
                        }
                        else
                        {
                            Debug.LogWarning("Unable to create object of type " + uoType.ToString());
                        }
                    }
                    else
                    {
                        Debug.LogWarning("Unable to resolve unity type for " + asset.GetType().FullName);
                    }
                }
            }

            m_assetDB.RegisterSceneObjects(idToUnityObj);

            if (assetInstances != null)
            {
                for (int i = 0; i < AssetIdentifiers.Length; ++i)
                {
                    UnityObject assetInstance = assetInstances[i];
                    if (assetInstance != null)
                    {
                        PersistentObject asset = Assets[i];
                        asset.WriteTo(assetInstance);
                    }
                }
            }

            RestoreDataAndResolveDependencies();
            m_assetDB.UnregisterSceneObjects();

            ClearReferencesCache();

            return(scene);
        }
Esempio n. 59
0
 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(PersistentObject obj)
 {
     return((obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr);
 }
        protected override void ReadFromImpl(object obj)
        {
            ClearReferencesCache();

            Scene scene = (Scene)obj;

            GameObject[] rootGameObjects;
            if (scene.IsValid())
            {
                rootGameObjects = scene.GetRootGameObjects();
            }
            else
            {
                rootGameObjects = new GameObject[0];
            }

            List <PersistentObject>     data            = new List <PersistentObject>();
            List <long>                 identifiers     = new List <long>();
            List <PersistentDescriptor> descriptors     = new List <PersistentDescriptor>(rootGameObjects.Length);
            GetDepsFromContext          getSceneDepsCtx = new GetDepsFromContext();

            for (int i = 0; i < rootGameObjects.Length; ++i)
            {
                GameObject           rootGO     = rootGameObjects[i];
                PersistentDescriptor descriptor = CreateDescriptorAndData(rootGO, data, identifiers, getSceneDepsCtx);
                if (descriptor != null)
                {
                    descriptors.Add(descriptor);
                }
            }

            HashSet <object> allDeps = getSceneDepsCtx.Dependencies;

            Queue <UnityObject> depsQueue = new Queue <UnityObject>(allDeps.OfType <UnityObject>());

            List <PersistentObject> assets = new List <PersistentObject>();
            List <int> assetIdentifiers    = new List <int>();

            GetDepsFromContext getDepsCtx = new GetDepsFromContext();

            while (depsQueue.Count > 0)
            {
                UnityObject uo = depsQueue.Dequeue();
                if (!uo)
                {
                    continue;
                }


                Type persistentType = m_typeMap.ToPersistentType(uo.GetType());
                if (persistentType != null)
                {
                    getDepsCtx.Clear();

                    try
                    {
                        PersistentObject persistentObject = (PersistentObject)Activator.CreateInstance(persistentType);
                        if (!(uo is GameObject) && !(uo is Component))
                        {
                            if (!m_assetDB.IsMapped(uo))
                            {
                                if (uo is Texture2D)
                                {
                                    Texture2D texture = (Texture2D)uo;
                                    if (texture.isReadable)  //
                                    {
                                        persistentObject.ReadFrom(uo);
                                        assets.Add(persistentObject);
                                        assetIdentifiers.Add(uo.GetInstanceID());
                                        persistentObject.GetDepsFrom(uo, getDepsCtx);
                                    }
                                }
                                else
                                {
                                    persistentObject.ReadFrom(uo);
                                    assets.Add(persistentObject);
                                    assetIdentifiers.Add(uo.GetInstanceID());
                                    persistentObject.GetDepsFrom(uo, getDepsCtx);
                                }
                            }
                            else
                            {
                                persistentObject.GetDepsFrom(uo, getDepsCtx);
                            }
                        }
                        else
                        {
                            persistentObject.GetDepsFrom(uo, getDepsCtx);
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(e.ToString());
                    }

                    foreach (UnityObject dep in getDepsCtx.Dependencies)
                    {
                        if (!allDeps.Contains(dep))
                        {
                            allDeps.Add(dep);
                            depsQueue.Enqueue(dep);
                        }
                    }
                }
            }

            List <UnityObject> externalDeps = new List <UnityObject>(allDeps.OfType <UnityObject>());

            for (int i = externalDeps.Count - 1; i >= 0; i--)
            {
                if (!m_assetDB.IsMapped(externalDeps[i]))
                {
                    externalDeps.RemoveAt(i);
                }
            }

            Descriptors  = descriptors.ToArray();
            Identifiers  = identifiers.ToArray();
            Data         = data.ToArray();
            Dependencies = externalDeps.Select(uo => m_assetDB.ToID(uo)).ToArray();

            Assets           = assets.ToArray();
            AssetIdentifiers = assetIdentifiers.ToArray();

            ClearReferencesCache();
        }