public void                     initAccess()
        {
            EAccess lAccess = EAccess.NO_ACCESS;

            if (mConnection.Connected)
            {
                switch (mMemoryType)
                {
                case EPLCMemoryType.M:  lAccess = EAccess.READ_WRITE;
                    break;

                case EPLCMemoryType.DB: lAccess = EAccess.READ_WRITE;
                    break;

                case EPLCMemoryType.I:  lAccess = EAccess.READ_WRITE;
                    break;

                case EPLCMemoryType.Q:  lAccess = EAccess.READ;
                    break;
                }
            }

            if (lAccess != mAccess)
            {
                mAccess = lAccess;
                raisePropertiesChanged();
            }
        }
        public void                     initAccess()
        {
            EAccess lAccess;

            if (mConnection.Connected)
            {
                if (mPublish)
                {
                    lAccess = EAccess.READ_WRITE;
                }
                else
                {
                    lAccess = EAccess.READ;
                }
            }
            else
            {
                lAccess = EAccess.NO_ACCESS;
            }

            if (mAccess != lAccess)
            {
                mAccess = lAccess;
                raisePropertiesChanged();
            }
        }
示例#3
0
        private CreatePostHelper SelectAccess(EAccess access)
        {
            appManager.App.Tap(appManager.CreatePostScreen.createPost_accessMode_textView);
            switch (access)
            {
            case EAccess.Public:
                if (OnAndroid)
                {
                    appManager.App.Tap(appManager.AlertScreens.button1_on_alert);
                }
                else
                {
                    appManager.App.Tap(appManager.CreatePostScreen.createPost_access_public_ios);
                    appManager.App.Tap(appManager.AlertScreens.ok_on_alert);
                }
                break;

            case EAccess.Private:
                if (OnAndroid)
                {
                    appManager.App.Tap(appManager.AlertScreens.button2_on_alert);
                }
                else
                {
                    appManager.App.Tap(appManager.CreatePostScreen.createPost_access_private_ios);
                    appManager.App.Tap(appManager.AlertScreens.ok_on_alert);
                }
                break;

            case EAccess.Cancel:
                appManager.App.Tap(appManager.AlertScreens.cancel_on_alert);
                break;
            }
            return(this);
        }
示例#4
0
 internal static async Task <string?> Response(Bot bot, EAccess access, ulong steamID, string message, string[] args)
 {
     if (string.IsNullOrEmpty(message))
     {
         return(null);
     }
     return(args[0].ToUpperInvariant() switch {
         "BOOSTER" when args.Length > 2 => await ResponseBooster(access, steamID, args[1], args[2]).ConfigureAwait(false),
         "BOOSTER" => await ResponseBooster(bot, access, args[1]).ConfigureAwait(false),
         _ => null,
     });
        public IDataItem            createFromXML(IConnection aConnection, XmlTextReader aXMLTextReader)
        {
            Connection lConnection = (Connection)aConnection;
            var        lReader     = new XMLAttributeReader(aXMLTextReader);

            string  lAccessString = lReader.getAttribute <String>("Access", "READ_WRITE");
            EAccess lAccess       = (EAccess)Enum.Parse(typeof(EAccess), lAccessString);
            object  lValue        = XMLUtils.loadValueFromXML(aXMLTextReader);

            return(lConnection.addItem(lAccess, lValue));
        }
        public DataItem addItem(EAccess aItemAccess, object aValue)
        {
            DataItem lItem      = new DataItem();
                lItem.mConnection   = this;
                lItem.mAccess       = aItemAccess;
                lItem.mValue        = aValue;
                ConnectionState     += new EventHandler(lItem.onConnectionStateChanged);

                mNumberOfItems      = mNumberOfItems + 1;

                return lItem;
        }
示例#7
0
        public DataItem                                 addItem(EAccess aItemAccess, object aValue)
        {
            DataItem lItem = new DataItem();

            lItem.mConnection = this;
            lItem.mAccess     = aItemAccess;
            lItem.mValue      = aValue;
            ConnectionState  += new EventHandler(lItem.onConnectionStateChanged);

            mNumberOfItems = mNumberOfItems + 1;

            return(lItem);
        }
        public void                 setAccess(byte aAccess)
        {
            mAccessLevel = aAccess;
            switch (aAccess)
            {
            case AccessLevels.CurrentRead:          mAccess = EAccess.READ; break;

            case AccessLevels.CurrentWrite:         mAccess = EAccess.READ_WRITE; break;

            case AccessLevels.CurrentReadOrWrite:   mAccess = EAccess.READ_WRITE; break;

            default:                                mAccess = EAccess.NO_ACCESS; break;
            }
        }
示例#9
0
    // This method is called when unknown command is received (starting with CommandPrefix)
    // This allows you to recognize the command yourself and implement custom commands
    // Keep in mind that there is no guarantee what is the actual access of steamID, so you should do the appropriate access checking yourself
    // You can use either ASF's default functions for that, or implement your own logic as you please
    // Since ASF already had to do initial parsing in order to determine that the command is unknown, args[] are splitted using standard ASF delimiters
    // If by any chance you want to handle message in its raw format, you also have it available, although for usual ASF pattern you can most likely stick with args[] exclusively. The message has CommandPrefix already stripped for your convenience
    // If you do not recognize the command, just return null/empty and allow ASF to gracefully return "unknown command" to user on usual basis
    public async Task <string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0)
    {
        // In comparison with OnBotMessage(), we're using asynchronous CatAPI call here, so we declare our method as async and return the message as usual
        // Notice how we handle access here as well, it'll work only for FamilySharing+
        switch (args[0].ToUpperInvariant())
        {
        case "CAT" when access >= EAccess.FamilySharing:
            // Notice how we can decide whether to use bot's AWH WebBrowser or ASF's one. For Steam-related requests, AWH's one should always be used, for third-party requests like those it doesn't really matter
            // Still, it makes sense to pass AWH's one, so in case you get some errors or alike, you know from which bot instance they come from. It's similar to using Bot's ArchiLogger compared to ASF's one
            string?randomCatURL = await CatAPI.GetRandomCatURL(bot.ArchiWebHandler.WebBrowser).ConfigureAwait(false);

            return(!string.IsNullOrEmpty(randomCatURL) ? randomCatURL : "God damn it, we're out of cats, care to notify my master? Thanks!");

        default:
            return(null);
        }
    }
        public async Task <string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0)
        {
            if (access < EAccess.Master)
            {
                return(null);
            }

            return(args[0].ToUpperInvariant() switch {
                "TRANSFER#" when args.Length > 3 => await ResponseTransfer(access, steamID, args[1], args[2], Utilities.GetArgsAsText(args, 3, ",")).ConfigureAwait(false),
                "TRANSFER#" when args.Length > 2 => await ResponseTransfer(bot, access, args[1], args[2]).ConfigureAwait(false),
                "LOOT#" when args.Length > 2 => await ResponseLoot(access, steamID, args[1], Utilities.GetArgsAsText(args, 2, ",")).ConfigureAwait(false),
                "LOOT#" => await ResponseLoot(bot, access, args[1]).ConfigureAwait(false),
                "TRANSFERM" when args.Length > 3 => await ResponseTransfer(access, steamID, args[1], args[2], Utilities.GetArgsAsText(args, 3, ","), false).ConfigureAwait(false),
                "TRANSFERM" when args.Length > 2 => await ResponseTransfer(bot, access, args[1], args[2], false).ConfigureAwait(false),
                "LOOTM" when args.Length > 2 => await ResponseLoot(access, steamID, args[1], Utilities.GetArgsAsText(args, 2, ","), false).ConfigureAwait(false),
                "LOOTM" => await ResponseLoot(bot, access, args[1], false).ConfigureAwait(false),
                _ => null,
            });
        public void                 initAccess()
        {
            EAccess lAccess = EAccess.NO_ACCESS;

            if (mConnection.Connected)
            {
                if (mRegisterType == ERegisterType.COIL_BIT || mRegisterType == ERegisterType.HOLDING_REGISTER)
                {
                    lAccess = EAccess.READ_WRITE;
                }
                else
                {
                    lAccess = EAccess.READ;
                }
            }

            if (lAccess != mAccess)
            {
                mAccess = lAccess;
                raisePropertiesChanged();
            }
        }
示例#12
0
 /// <summary>
 /// Constructs a new instance.
 /// </summary>
 /// <param name="back">array for storing property values</param>
 /// <param name="indexFunc">index function, mapping keys to array indices</param>
 /// <param name="access">desired access privilege</param>
 public ArrayBackedPropMap(TValue[] back, Func <TKey, int> indexFunc, EAccess access = EAccess.ReadWrite)
 {
     _back      = back;
     _indexFunc = indexFunc;
     Access     = access;
 }
示例#13
0
 /// <summary>
 /// Creates a property map which is backed by an array.
 /// </summary>
 /// <typeparam name="TValue">type of element whose property is to be accessed</typeparam>
 /// <param name="array">array for storing property values</param>
 /// <param name="access">desired access privilege</param>
 public static IPropMap <int, TValue> CreateForArray <TValue>(TValue[] array, EAccess access)
 {
     return(new ArrayBackedPropMap <int, TValue>(array, i => i, access));
 }
示例#14
0
 /// <summary>
 /// Creates a property map which is backed by an array.
 /// </summary>
 /// <typeparam name="TKey">type of element whose property is to be accessed</typeparam>
 /// <typeparam name="TValue">type of the property value which is accessed</typeparam>
 /// <param name="array">array for storing property values</param>
 /// <param name="indexFunc">index function, mapping keys to array indices</param>
 /// <param name="access">desired access privilege</param>
 public static IPropMap <TKey, TValue> CreateForArray <TKey, TValue>(
     TValue[] array, Func <TKey, int> indexFunc, EAccess access = EAccess.ReadWrite)
 {
     return(new ArrayBackedPropMap <TKey, TValue>(array, indexFunc, access));
 }
示例#15
0
 public abstract void Mount(
     [ManagementProperty(CastAs = typeof(ushort), Name = "Access")]
     EAccess access,
     [ManagementProperty(Name = "NoDriveLetter")]
     bool noDriveLetter
     );
        public void initAccess()
        {
            EAccess lAccess = EAccess.NO_ACCESS;

            if (mConnection.Connected)
            {
                switch (mMemoryType)
                {
                    case EPLCMemoryType.M:  lAccess = EAccess.READ_WRITE;
                                            break;

                    case EPLCMemoryType.DB: lAccess = EAccess.READ_WRITE;
                                            break;

                    case EPLCMemoryType.I:  lAccess = EAccess.READ_WRITE;
                                            break;

                    case EPLCMemoryType.Q:  lAccess = EAccess.READ;
                                            break;
                }
            }

            if (lAccess != mAccess)
            {
                mAccess = lAccess;
                raisePropertiesChanged();
            }
        }
示例#17
0
        /// <summary>
        /// Checks whether the property map grants the requested access privilege and throws an exception if it doesn't.
        /// </summary>
        /// <param name="access">required access privilege</param>
        /// <exception cref="InvalidOperationException">if requested access privilege is not supported</exception>
        public static void RequireAccess <TThis, TValue>(this IPropMap <TThis, TValue> pmap, EAccess access)
        {
            bool granted;

            switch (pmap.Access)
            {
            case EAccess.NoAccess:
                granted = access == EAccess.NoAccess;
                break;

            case EAccess.ReadOnly:
                granted = access == EAccess.NoAccess || access == EAccess.ReadOnly;
                break;

            case EAccess.WriteOnly:
                granted = access == EAccess.NoAccess || access == EAccess.WriteOnly;
                break;

            case EAccess.ReadWrite:
                granted = true;
                break;

            default:
                throw new NotImplementedException();
            }
            if (!granted)
            {
                throw new InvalidOperationException("Need " + access.ToString() +
                                                    " access to a property map, but got only " + pmap.Access.ToString() + " access");
            }
        }
        public void initAccess()
        {
            EAccess lAccess = EAccess.NO_ACCESS;

            if (mConnection.Connected)
            {
                lAccess = EAccess.READ_WRITE;
            }

            if (lAccess != mAccess)
            {
                mAccess = lAccess;
                raisePropertiesChanged();
            }
        }
示例#19
0
 // Проверить нужен данныей метод или нет
 public CreatePostHelper SelectInformationForCreatePost(EBuySell buySellCancel, EForecastTime forecastTime, EAccess eAccess, string text)
 {
     SelectBuySell(buySellCancel);
     SelectTime(forecastTime);
     SelectAccess(eAccess);
     appManager.App.EnterText(appManager.CreatePostScreen.createPost_comment_editText, text);
     return(this);
 }
示例#20
0
 public async Task <string?> OnBotCommand(Bot bot, EAccess access, string message, string[] args, ulong steamID = 0) => await Commands.Response(bot, access, steamID, message, args).ConfigureAwait(false);
示例#21
0
 public void CreateInvalidPostWithoutTools(EBuySell buySellCancel, EForecastTime forecastTime, EAccess eAccess, string text)
 {
     appManager.NavigationHelper.GoToCreatePostOnNewsTab();
     appManager.CreatePostHelper.SelectInformationForCreatePost(buySellCancel, forecastTime, eAccess, text).
     CreatePostOnCreatePostScreen().
     ChekNoCreationsPosts();
 }