Exemplo n.º 1
0
 /// <summary>
 /// Erzeugt eine exakte Kopie eines Senders.
 /// </summary>
 /// <param name="other">Der zu kopierende Sender.</param>
 public Station( Station other )
     : base( other )
 {
     // Copy over
     IsEncrypted = other.IsEncrypted;
     SourceType = other.SourceType;
     IsService = other.IsService;
     Provider = other.Provider;
     Name = other.Name;
 }
Exemplo n.º 2
0
        /// <summary>
        /// The return source type.
        /// </summary>
        /// <param name="sourceTypeId">
        /// The source type id.
        /// </param>
        /// <returns>
        /// The <see cref="ISourceType"/>.
        /// </returns>
        public static ISourceType ReturnSourceType(Guid sourceTypeId)
        {
            if (SourceTypes == null || !SourceTypes.Any())
            {
                return(null);
            }

            //var test = SourceTypes.Where(d => d.Metadata["ValueMetaData"].ToString().ToLower() == sourceTypeId.ToString().ToLower());

            return(SourceTypes.FirstOrDefault(
                       d => d.Metadata["ValueMetaData"].ToString().ToLower() == sourceTypeId.ToString().ToLower()).Value);
        }
Exemplo n.º 3
0
        [OutputCache(NoStore = true, Duration = 0)] // do not cache generator calls
        public ContentResult GetByAlias(
            string displayAlias,
            SourceTypes sourceType    = SourceTypes.ContentItem,
            ResultTarget resultTarget = ResultTarget.Contents,
            string mfilter            = "",
            int page                = 1,
            int pageSize            = 10,
            bool tinyResponse       = true,
            bool minified           = false,
            bool realformat         = false,
            int deeplevel           = 10,
            string complexBehaviour = "")
        {
            //   Logger.Error("inizio"+DateTime.Now.ToString());
            IContent item = null;

            if (displayAlias.ToLower() == "user+info" || displayAlias.ToLower() == "user info")
            {
                // The call to this generator method is generally anonymous, but we still want to send out the json reflecting the structure of a user
                // so it can be mapped.
                // We are sending out the admin user, but this may end up being a security concern in some cases so:
                // TODO: figure out a way to not be sending out admin information here, since this call is anonymous.

                item = _orchardServices.ContentManager.Get(2);
            }
            else
            {
                var autoroutePart = _orchardServices.ContentManager.Query <AutoroutePart, AutoroutePartRecord>()
                                    .ForVersion(VersionOptions.Published)
                                    .Where(w => w.DisplayAlias == displayAlias).List().SingleOrDefault();

                if (autoroutePart != null && autoroutePart.ContentItem != null)
                {
                    item = autoroutePart.ContentItem;
                }
                else
                {
                    new HttpException(404, ("Not found"));
                    return(null);
                }
            }
            ContentResult cr = (ContentResult)GetContent(item, sourceType, resultTarget, mfilter, page, pageSize, tinyResponse, minified, realformat, deeplevel, complexBehaviour.Split(','));

            //    Logger.Error("Fine:"+DateTime.Now.ToString());

            if (_orchardServices.WorkContext.CurrentSite.As <WebServiceSettingsPart>().LogWebservice)
            {
                Logger.Error(cr.Content.ToString());
            }
            return(cr);
        }
Exemplo n.º 4
0
        public SearchForEntryForm(MySqlConnectionStringBuilder connectionString, string startEntryString, SourceTypes sourceTypeToSearchFor)
        {
            InitializeComponent();

            this.connectionString = connectionString;
            this.sourceTypeToSearchFor = sourceTypeToSearchFor;
            textBoxCriteria.Text = startEntryString;

            MinimumSize = new Size(Width, Height);
            MaximumSize = new Size(Width, Height + 800);

            if (sourceTypeToSearchFor != SourceTypes.SourceTypeAreaTrigger)
            {
                listViewEntryResults.Columns.Add("Entry/guid", 70, HorizontalAlignment.Right);
                listViewEntryResults.Columns.Add("Name", 260, HorizontalAlignment.Left);
            }

            listViewEntryResults.ColumnClick += listViewEntryResults_ColumnClick;
            listViewEntryResults.Anchor = AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Top | AnchorStyles.Left;

            _cts = new CancellationTokenSource();

            switch (sourceTypeToSearchFor)
            {
                case SourceTypes.SourceTypeCreature:
                    comboBoxSearchType.SelectedIndex = 0; //! Creature entry
                    FillListViewWithMySqlQuery("SELECT entry, name FROM creature_template ORDER BY entry LIMIT 1000");
                    break;
                case SourceTypes.SourceTypeGameobject:
                    comboBoxSearchType.SelectedIndex = 3; //! Gameobject entry
                    FillListViewWithMySqlQuery("SELECT entry, name FROM gameobject_template ORDER BY entry LIMIT 1000");
                    break;
                case SourceTypes.SourceTypeAreaTrigger:
                    comboBoxSearchType.SelectedIndex = 6; //! NYI
                    listViewEntryResults.Columns.Add("Id", 53, HorizontalAlignment.Right);
                    listViewEntryResults.Columns.Add("Mapid", 52, HorizontalAlignment.Left);
                    listViewEntryResults.Columns.Add("X", 75, HorizontalAlignment.Left);
                    listViewEntryResults.Columns.Add("Y", 75, HorizontalAlignment.Left);
                    listViewEntryResults.Columns.Add("Z", 75, HorizontalAlignment.Left);
                    FillListViewWithAreaTriggers(String.Empty, String.Empty, true);
                    break;
                case SourceTypes.SourceTypeScriptedActionlist:
                    checkBoxHasAiName.Enabled = false;
                    comboBoxSearchType.SelectedIndex = 8; //! Actionlist entry
                    //! We don't list 1000 actionlists like all other source types because we can't get the entry/name combination
                    //! of several sources (considering the actionlist can be called from _ANY_ source_type (including actionlists
                    //! itself). It's simply not worth the time.
                    break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Преобразовать enum в пользовательский вид. Можно было сделать через атрибуты самого enum.
        /// </summary>
        public static string ToGUIString(this SourceTypes sourceType)
        {
            switch (sourceType)
            {
            case SourceTypes.File:
                return("Файл");

            case SourceTypes.DataBase:
                return("БД");

            default:
                throw new InvalidEnumArgumentException("Invalid enum value: " + sourceType);
            }
        }
Exemplo n.º 6
0
        private IDataProvider GetProvider(SourceTypes type)
        {
            switch (type)
            {
            case SourceTypes.File:
                return(fileProvider);

            case SourceTypes.DataBase:
                return(sqlProvider);

            default:
                throw new InvalidEnumArgumentException();
            }
        }
 public StateScrapeInfo(string state, string abbreviation, SourceTypes sourceType, string source, string expression)
 {
     State             = state;
     StateAbbreviation = abbreviation;
     SourceType        = sourceType;
     Source            = source;
     if (string.IsNullOrEmpty(expression) == false)
     {
         try
         {
             ExpressionObject = (Expression)JsonSerializer.Deserialize <Expression>(expression, null);
         }
         catch { }
     }
 }
Exemplo n.º 8
0
        public async Task <string> GetObjectNameByIdOrGuidAndSourceType(SourceTypes sourceType, int idOrGuid)
        {
            switch (sourceType)
            {
            case SourceTypes.SourceTypeCreature:
                return(idOrGuid < 0 ? await GetCreatureNameByGuid(-idOrGuid) : await GetCreatureNameById(idOrGuid));

            case SourceTypes.SourceTypeGameobject:
                return(idOrGuid < 0 ? await GetGameobjectNameByGuid(-idOrGuid) : await GetGameobjectNameById(idOrGuid));

            case SourceTypes.SourceTypeAreaTrigger:
                return("Areatrigger");
            }

            return(String.Empty);
        }
Exemplo n.º 9
0
        public SearchForEntryForm(string startEntryString, SourceTypes sourceTypeToSearchFor)
        {
            InitializeComponent();

            this.sourceTypeToSearchFor = sourceTypeToSearchFor;
            textBoxCriteria.Text       = startEntryString;

            MinimumSize = new Size(Width, Height);
            MaximumSize = new Size(Width, Height + 800);

            if (sourceTypeToSearchFor != SourceTypes.SourceTypeAreaTrigger)
            {
                listViewEntryResults.Columns.Add("Entry/guid", 70, HorizontalAlignment.Right);
                listViewEntryResults.Columns.Add("Name", 260, HorizontalAlignment.Left);
            }
        }
Exemplo n.º 10
0
        private void SetSourceTypeToBox(SourceTypes sourceType)
        {
            switch (sourceType)
            {
            case SourceTypes.Embedded:
                comboBoxSourceType.SelectedItem = "Embedded";
                break;

            case SourceTypes.External:
                comboBoxSourceType.SelectedItem = "External";
                break;

            case SourceTypes.Local:
                comboBoxSourceType.SelectedItem = "Local";
                break;
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Customize this section to load from a file to increase portability
        /// </summary>
        private void InitializeConnectionAlias()
        {
            EnvironmentVars a = new EnvironmentVars(true);

            ServerName = Properties.Settings.Default.ServerNameSQL;
#if DEBUG
            //ServerName = "(local)\\SQLEXPRESS";
            ServerName = "BHUPENDRA-PC";
#endif

            DatabaseName = Properties.Settings.Default.DatabaseName;
            //UserName = "******";
            //Password = "******";
            UserName    = "******";
            Password    = "******";
            _dataSource = SourceTypes.SqlServer;
        }
Exemplo n.º 12
0
        public virtual bool TypeIsMappedAsTransformedType(Type type)
        {
            if (type == null)
            {
                throw new ArgumentNullException(nameof(type));
            }

            if (type.IsEnum)
            {
                return(false);
            }

            var typeIsMappedAsTransformedType = SourceTypes.Contains(type) ||
                                                TypeIsAnonymousOrGrouping(type);

            return(typeIsMappedAsTransformedType);
        }
Exemplo n.º 13
0
        public SearchForEntryForm(string startEntryString, SourceTypes sourceTypeToSearchFor)
        {
            InitializeComponent();

            this.sourceTypeToSearchFor = sourceTypeToSearchFor;
            textBoxCriteria.Text = startEntryString;

            MinimumSize = new Size(Width, Height);
            MaximumSize = new Size(Width, Height + 800);

            if (sourceTypeToSearchFor != SourceTypes.SourceTypeAreaTrigger)
            {
                listViewEntryResults.Columns.Add("Entry/guid", 70, HorizontalAlignment.Right);
                listViewEntryResults.Columns.Add("Name", 260, HorizontalAlignment.Left);
            }

        }
Exemplo n.º 14
0
        public string GetDefaultCommentForSourceType(SourceTypes sourceType)
        {
            switch (sourceType)
            {
            case SourceTypes.SourceTypeCreature:
                return("Npc - Event - Action (phase) (dungeon difficulty)");

            case SourceTypes.SourceTypeGameobject:
                return("Gameobject - Event - Action (phase) (dungeon difficulty)");

            case SourceTypes.SourceTypeAreaTrigger:
                return("Areatrigger - Event - Action (phase) (dungeon difficulty)");

            case SourceTypes.SourceTypeScriptedActionlist:
                return("Source - Event - Action (phase) (dungeon difficulty)");
            }

            return(String.Empty);
        }
        /// <summary>
        /// Get Ranges based on menu
        /// </summary>
        /// <param name="st">SourceType</param>
        void GetRanges(SourceTypes st)
        {
            this.CurrentSourceType = st;

            try
            {
                switch (st)
                {
                case SourceTypes.Document:
                    UpdateTextRanges(this.TextPattern.DocumentRange());
                    break;

                case SourceTypes.Selection:
                    UpdateTextRanges(this.TextPattern.GetSelection());
                    break;

                case SourceTypes.Visible:
                    UpdateTextRanges(this.TextPattern.GetVisibleRanges());
                    break;

                case SourceTypes.Caret:
                    int isActive;
                    UpdateTextRanges(this.TextPattern2.GetCaretRange(out isActive));
                    break;

                case SourceTypes.Listed:
                    UpdateRangesList(this.CustomList);
                    break;

                default:
                    MessageDialog.Show(Properties.Resources.TextPatternExplorerDialog_GetRanges_This_option_is_not_supported_yet);
                    break;
                }
            }
#pragma warning disable CA1031 // Do not catch general exception types
            catch (Exception ex)
            {
                ex.ReportException();
                MessageDialog.Show(string.Format(CultureInfo.InvariantCulture, Properties.Resources.TextPatternExplorerDialog_GetRanges_Failed_to_retrieve_range_s____0, ex.Message));
            }
#pragma warning restore CA1031 // Do not catch general exception types
        }
Exemplo n.º 16
0
        private string GetSourceTypeString(SourceTypes sourceType)
        {
            switch (sourceType)
            {
            case SourceTypes.SourceTypeCreature:
                return("Creature");

            case SourceTypes.SourceTypeGameobject:
                return("Gameobject");

            case SourceTypes.SourceTypeAreaTrigger:
                return("Areatrigger");

            case SourceTypes.SourceTypeScriptedActionlist:
                return("Actionlist");

            default:
                return("Unknown");
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// instance of <see cref="ParameterConfig"/>
        /// </summary>
        /// <param name="name"><see cref="Name"/></param>
        /// <param name="tsource"><see cref="Tsource"/></param>
        /// <param name="ttarget"><see cref="Ttarget"/></param>
        /// <param name="offset"><see cref="Offset"/></param>
        /// <param name="length"><see cref="Length"/></param>
        /// <param name="scalar"><see cref="Scalar"/></param>
        /// <param name="unit"><see cref="Unit"/></param>
        /// <param name="label"><see cref="Label"/></param>
        /// <param name="detail"><see cref="Detail"/></param>
        /// <param name="isRevFlag"><see cref="IsRevFlag"/></param>
        public ParameterConfig(
            string name, SourceTypes tsource, TargetTypes ttarget,
            byte offset, byte length, double scalar = 1,
            string unit = "-", string label = "", string detail = "", bool isRevFlag = false)
        {
            Name = name;

            Tsource = tsource;
            Ttarget = ttarget;

            Offset = offset;
            Length = length;
            Scalar = scalar;

            Label  = label;
            Unit   = unit;
            Detail = detail;

            IsRevFlag = isRevFlag;
        }
Exemplo n.º 18
0
 private string FromType(SourceTypes sourceTypes)
 {
     if (sourceTypes.IsAxis())
     {
         return("axis");
     }
     if (sourceTypes == SourceTypes.Button)
     {
         return("button");
     }
     if (sourceTypes == SourceTypes.Dpad)
     {
         return("dpad");
     }
     if (sourceTypes == SourceTypes.Slider)
     {
         return("slider");
     }
     return(null);
 }
        private void DrawTriggerField(
            Rect pos,
            SerializedProperty trigger,
            SourceTypes sourceType,
            int row)
        {
            var disable = sourceType == SourceTypes.Trigger;

            EditorGUI.BeginDisabledGroup(disable);

            EditorGUI.PropertyField(
                new Rect(
                    pos.x + pos.width * 0.5f + 3,
                    pos.y + row * (PropHeight + PropMargin),
                    pos.width * 0.5f,
                    16),
                trigger,
                new GUIContent(
                    "Trigger",
                    "If the animator param. is a trigger. Every change of " +
                    "source property will trigger the animator param."));

            EditorGUI.EndDisabledGroup();
        }
Exemplo n.º 20
0
        public string AddSources(List<Guid> records, List<Guid> sources,SourceTypes sourceTypes)
        {
            if (!_security.IsValidEdit()) throw new SecurityException("Missing edit permission");

            if (sources.IsNullOrBelowMinSize(1))
            {
                throw new InvalidDataException("Invalid number of supplied sources");
            }

            switch (sourceTypes)
            {
                case SourceTypes.Person:
                    records.ForEach(p => _smDal.WritePersonSources2(p, sources, _security.UserId()));
                    break;
                case SourceTypes.Marriage:
                    records.ForEach(p => _smDal.WriteMarriageSources(p, sources, _security.UserId()));
                    break;

                default:
                    throw new ArgumentOutOfRangeException("sourceTypes");
            }

            return "";
        }
Exemplo n.º 21
0
        static string GetSource(byte[] packet, SourceTypes source, byte offset, byte length)
        {
            switch (source)
            {
            case SourceTypes.UInt8: return(packet[offset].ToString());

            case SourceTypes.UInt16: return(BitConverter.ToUInt16(packet, offset).ToString());

            case SourceTypes.UInt32: return(BitConverter.ToUInt32(packet, offset).ToString());

            case SourceTypes.Int8: return(((sbyte)packet[offset]).ToString());

            case SourceTypes.Int16: return(BitConverter.ToInt16(packet, offset).ToString());

            case SourceTypes.Int32: return(BitConverter.ToInt32(packet, offset).ToString());

            case SourceTypes.Float: return(BitConverter.ToSingle(packet, offset).ToString());

            case SourceTypes.Double: return(BitConverter.ToDouble(packet, offset).ToString());

            /* string */
            default: return(BitConverter.ToString(packet, offset, length).ToString());
            }
        }
Exemplo n.º 22
0
 public static bool IsAxis(this SourceTypes type)
 {
     return(SourceTypes.Axis.HasFlag(type) && type != SourceTypes.None);
 }
Exemplo n.º 23
0
        public string GetDefaultCommentForSourceType(SourceTypes sourceType)
        {
            switch (sourceType)
            {
                case SourceTypes.SourceTypeCreature:
                    return "Npc - Event - Action (phase) (dungeon difficulty)";
                case SourceTypes.SourceTypeGameobject:
                    return "Gameobject - Event - Action (phase) (dungeon difficulty)";
                case SourceTypes.SourceTypeAreaTrigger:
                    return "Areatrigger - Event - Action (phase) (dungeon difficulty)";
                case SourceTypes.SourceTypeScriptedActionlist:
                    return "Source - Event - Action (phase) (dungeon difficulty)";
            }

            return String.Empty;
        }
Exemplo n.º 24
0
 private void SetSourceTypeToFont(SourceTypes sourceType)
 {
     var currentSource = _myDataSourceSources.Current as FontSource;
     if (currentSource != null)
     {
         currentSource.Type = sourceType;
         _myDataSourceFonts.ResetCurrentItem();
     }
 }
Exemplo n.º 25
0
        public override void Parse(string[] data)
        {
            int index = 1;

            this.Id = data[index++];
            int.TryParse(data[index++], out this.SourceId);
            this.Time = DateTime.Parse(data[index++]);
            double x = 0;

            double.TryParse(data[index++], out x);
            double y = 0;

            double.TryParse(data[index++], out y);
            this.Shape = new GeoPointShape(x, y);
            double.TryParse(data[index++], out this.SOG);
            double.TryParse(data[index++], out this.COG);
            bool.TryParse(data[index++], out this.Lost);
            int.TryParse(data[index++], out this.RateOfTurn);
            double.TryParse(data[index++], out this.Orientation);
            double.TryParse(data[index++], out this.Length);
            double.TryParse(data[index++], out this.Breadth);
            double.TryParse(data[index++], out this.Altitude);
            this.NavStatus     = (NavStatuses)Enum.Parse(typeof(NavStatuses), data[index++]);
            this.UpdSensorType = (UpdSensor)Enum.Parse(typeof(UpdSensor), data[index++]);
            bool.TryParse(data[index++], out this.ATONOffPos);
            this.StaticId   = data[index++];
            this.SourceName = data[index++];
            this.Source     = (SourceTypes)Enum.Parse(typeof(SourceTypes), data[index++]);
            //this.Callsign = data[index++];
            this.Callsign = EncodeStr.Decode(data[index++]);
            //this.ShipName = data[index++];
            this.ShipName   = EncodeStr.Decode(data[index++]);
            this.ObjectType = (ObjectTypes)Enum.Parse(typeof(ObjectTypes), data[index++]);
            this.ShipType   = (ShipTypes)Enum.Parse(typeof(ShipTypes), data[index++]);
            int.TryParse(data[index++], out this.IMO);
            int.TryParse(data[index++], out this.MMSI);
            this.ATONType = (ATONTypes)Enum.Parse(typeof(ATONTypes), data[index++]);
            this.ATONName = data[index++];
            int.TryParse(data[index++], out this.AntPosDistFromFront);
            int.TryParse(data[index++], out this.AntPosDistFromLeft);
            this.NatLangShipName = data[index++];
            this.PortOfRegistry  = data[index++];
            this.CountryFlag     = data[index++];
            double.TryParse(data[index++], out this.MaxAirDraught);
            double.TryParse(data[index++], out this.MaxDraught);
            bool.TryParse(data[index++], out this.DeepWaterVesselind);
            this.VoyageId  = data[index++];
            this.CargoType = (CargoTypes)Enum.Parse(typeof(CargoTypes), data[index++]);
            //this.Destination = data[index++];
            this.Destination = EncodeStr.Decode(data[index++]);
            DateTime.TryParse(data[index++], out this.ETA);
            DateTime.TryParse(data[index++], out this.ATA);
            double.TryParse(data[index++], out this.AirDraught);
            double.TryParse(data[index++], out this.Draught);
            if (index < data.Length)
            {
                this.GID = data[index++];
            }
            if (index < data.Length)
            {
                this.FID = data[index++];
            }
        }
Exemplo n.º 26
0
 public RawInputSource(IInputDevice inputDevice, string name, SourceTypes type, int usage, Func <Dictionary <Usage, DataValue>, double?> getNewValue) : base(inputDevice, name, type, usage)
 {
     this.getNewValue = getNewValue;
 }
Exemplo n.º 27
0
        public TrackTags(int music, SourceTypes type)
        {
            onRefreshTags = () => { };

            TagsInfo = new TAG_INFO();
            Pictures = new List<TCoverArtData>();

            bool GetTags = (type == SourceTypes.Http)
                ? BassTags.BASS_TAG_GetFromURL(music, TagsInfo)
                : BassTags.BASS_TAG_GetFromFile(music, TagsInfo);

            TagsLoadOrRefresh();
            LoadCurrentCovers();

            HTags = TagsLib.TagsLibrary_Create();

            MainPicture = (Pictures.Count > 0)
                ? PicFromMem.GetBitmapImageFromMemPtr(Pictures[0].Data,Pictures[0].DataSize)
                : null;

            switch (TagsInfo.channelinfo.ctype)
            {
                case BASSChannelType.BASS_CTYPE_MUSIC_IT:
                    FileExtension = "it";
                    break;
                case BASSChannelType.BASS_CTYPE_MUSIC_MO3:
                    FileExtension = "mo3";
                    break;
                case BASSChannelType.BASS_CTYPE_MUSIC_MOD:
                    FileExtension = "mod";
                    break;
                case BASSChannelType.BASS_CTYPE_MUSIC_MTM:
                    FileExtension = "mtm";
                    break;
                case BASSChannelType.BASS_CTYPE_MUSIC_S3M:
                    FileExtension = "s3m";
                    break;
                case BASSChannelType.BASS_CTYPE_MUSIC_XM:
                    FileExtension = "xm";
                    break;
                case BASSChannelType.BASS_CTYPE_RECORD:
                    FileExtension = "HRECORD";
                    break;
                case BASSChannelType.BASS_CTYPE_SAMPLE:
                    FileExtension = "HCHANNEL";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM:
                    FileExtension = "HSTREAM";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_AAC:
                    FileExtension = "aac";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_AC3:
                    FileExtension = "ac3";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_ADX:
                    FileExtension = "adx";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_AIFF:
                    FileExtension = "aiff";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_ALAC:
                    FileExtension = "alac";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_APE:
                    FileExtension = "ape";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_CA:
                    FileExtension = "caf";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_CD:
                    FileExtension = "cda";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_FLAC:
                    FileExtension = "flac";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_FLAC_OGG:
                    FileExtension = "flac";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_MIDI:
                    FileExtension = "midi";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_MIXER:
                    FileExtension = "mixer";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_MP1:
                    FileExtension = "mp1";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_MP2:
                    FileExtension = "mp2";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_MP3:
                    FileExtension = "mp3";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_MP4:
                    FileExtension = "mp4";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_MPC:
                    FileExtension = "mpc";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_OFR:
                    FileExtension = "ofr";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_OGG:
                    FileExtension = "ogg";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_SPLIT:
                    FileExtension = "split";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_SPX:
                    FileExtension = "spx";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_TTA:
                    FileExtension = "tta";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_VIDEO:
                    FileExtension = "video";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WAV:
                    FileExtension = "wav";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WAV_FLOAT:
                    FileExtension = "wav";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WAV_PCM:
                    FileExtension = "wav";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WINAMP:
                    FileExtension = "Winamp";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WMA:
                    FileExtension = "wma";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WMA_MP3:
                    FileExtension = "wma";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WV:
                    FileExtension = "wv";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WV_H:
                    FileExtension = "wv";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WV_L:
                    FileExtension = "wv";
                    break;
                case BASSChannelType.BASS_CTYPE_STREAM_WV_LH:
                    FileExtension = "wv";
                    break;
                case BASSChannelType.BASS_CTYPE_UNKNOWN:
                    FileExtension = "unknown";
                    break;

            }
        }
Exemplo n.º 28
0
 private void SetSourceTypeToBox(SourceTypes sourceType)
 {
     switch (sourceType)
     {
         case SourceTypes.Embedded:
             comboBoxSourceType.SelectedItem = "Embedded";
             break;
         case SourceTypes.External:
             comboBoxSourceType.SelectedItem = "External";
             break;
         case SourceTypes.Local:
             comboBoxSourceType.SelectedItem = "Local";
             break;
     }
 }
Exemplo n.º 29
0
        private ActionResult GetContent(
            IContent content,
            SourceTypes sourceType    = SourceTypes.ContentItem,
            ResultTarget resultTarget = ResultTarget.Contents,
            string fieldspartsFilter  = "",
            int page                  = 1,
            int pageSize              = 10,
            bool tinyResponse         = true,
            bool minified             = false,
            bool realformat           = false,
            int deeplevel             = 10,
            string[] complexBehaviour = null)
        {
            var result = new ContentResult {
                ContentType = "application/json"
            };
            var jsonString = "{}";

            var      _filterContentFieldsParts = fieldspartsFilter.ToLower().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            XElement dump;
            XElement projectionDump = null;
            // il dump dell'oggetto principale non filtra per field
            ObjectDumper dumper = new ObjectDumper(deeplevel, null, false, tinyResponse, complexBehaviour);
            var          sb     = new StringBuilder();

            // verifico se l'oggetto è soggetto all'accettazione delle policies
            var policy = content.As <Policy.Models.PolicyPart>();

            if (policy != null)
            {
                if ((String.IsNullOrWhiteSpace(_orchardServices.WorkContext.HttpContext.Request.QueryString["v"]))) // E' soggetto a privacy, quindi faccio sempre il redirect se manca il parametro in querystring v=
                {
                    if (policy.HasPendingPolicies ?? false)                                                         // se ha delle pending policies deve restituire le policy text, legate al contenuto, quindi non deve mai servire cache
                    {
                        var redirectUrl = String.Format("{0}{1}v={2}", _orchardServices.WorkContext.HttpContext.Request.RawUrl, (_orchardServices.WorkContext.HttpContext.Request.RawUrl.Contains("?") ? "&" : "?"), Guid.NewGuid());
                        _orchardServices.WorkContext.HttpContext.Response.Redirect(redirectUrl, true);
                    }
                    else    // se NON ha delle pending policies deve restituire un url non cacheato (quindi aggiungo v=),
                    {
                        var redirectUrl = String.Format("{0}{1}v={2}", _orchardServices.WorkContext.HttpContext.Request.RawUrl, (_orchardServices.WorkContext.HttpContext.Request.RawUrl.Contains("?") ? "&" : "?"), "cached-content");
                        _orchardServices.WorkContext.HttpContext.Response.Redirect(redirectUrl, true);
                        //_orchardServices.WorkContext.HttpContext.Response.Redirect(redirectUrl, true);
                    }
                    return(null); // in entrambi i casi ritorno null come risultato della current request
                }
            }
            if (policy != null && (policy.HasPendingPolicies ?? false))   // Se l'oggetto ha delle pending policies allora devo serivre la lista delle pending policies
            //policy.PendingPolicies
            {
                sb.Insert(0, "{");
                sb.AppendFormat("\"n\": \"{0}\"", "Model");
                sb.AppendFormat(", \"v\": \"{0}\"", "VirtualContent");
                sb.Append(", \"m\": [{");
                sb.AppendFormat("\"n\": \"{0}\"", "VirtualId"); // Unused property for mobile mapper needs
                sb.AppendFormat(", \"v\": \"{0}\"", "0");
                sb.Append("}]");

                sb.Append(", \"l\":[");

                int i = 0;
                sb.Append("{");
                sb.AppendFormat("\"n\": \"{0}\"", "PendingPolicies");
                sb.AppendFormat(", \"v\": \"{0}\"", "ContentItem[]");
                sb.Append(", \"m\": [");

                foreach (var item in policy.PendingPolicies)
                {
                    if (i > 0)
                    {
                        sb.Append(",");
                    }
                    sb.Append("{");
                    dumper         = new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour);
                    projectionDump = dumper.Dump(item, String.Format("[{0}]", i));
                    JsonConverter.ConvertToJSon(projectionDump, sb, minified, realformat);
                    sb.Append("}");
                    i++;
                }
                sb.Append("]");
                sb.Append("}");

                sb.Append("]"); // l : [
                sb.Append("}");
            }
            else     // Se l'oggetto NON ha delle pending policies allora posso servire l'oggetto stesso
            // Doing a IContentManager.Get here should ensure that the handlers that populate lazyfields
            // are executed, and all data in ContentParts and ContentField is initialized as it should.
            {
                content = _orchardServices.ContentManager.Get(content.Id, VersionOptions.Published);

                dump = dumper.Dump(content, "Model");

                JsonConverter.ConvertToJSon(dump, sb, minified, realformat);
                sb.Insert(0, "{");
                sb.Append(", \"l\":[");
                // Dopo avere convertito il contentItem in JSON aggiungo i Json delle eventuali liste

                var dumperContext = new DumperServiceContext(
                    content,
                    () =>
                    new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour),
                    (_xElement, _stringBuilder) =>
                    JsonConverter.ConvertToJSon(_xElement, _stringBuilder, minified, realformat),
                    resultTarget,
                    page, pageSize);
                foreach (var dumperService in _dumperServices)
                {
                    dumperService.DumpList(dumperContext);
                }
                sb.Append(string.Join(",", dumperContext.ContentLists));

                sb.Append("]"); // l : [
                sb.Append("}");
            }
            jsonString     = sb.ToString().Replace("\t", " ");
            result.Content = jsonString;
            return(result);
        }
Exemplo n.º 30
0
 public string GetSourceTypeString(SourceTypes sourceType)
 {
     switch (sourceType)
     {
         case SourceTypes.SourceTypeCreature:
             return "Creature";
         case SourceTypes.SourceTypeGameobject:
             return "Gameobject";
         case SourceTypes.SourceTypeAreaTrigger:
             return "Areatrigger";
         case SourceTypes.SourceTypeScriptedActionlist:
             return "Actionlist";
         default:
             return "Unknown";
     }
 }
Exemplo n.º 31
0
        public async Task <List <EntryOrGuidAndSourceType> > GetTimedActionlistsOrEntries(SmartScript smartScript, SourceTypes sourceType)
        {
            List <EntryOrGuidAndSourceType> timedActionListOrEntries = new List <EntryOrGuidAndSourceType>();

            if (sourceType == SourceTypes.SourceTypeScriptedActionlist)
            {
                List <SmartScript> smartScriptsCallingActionlist = await worldDatabase.GetSmartScriptsCallingActionLists();

                if (smartScriptsCallingActionlist != null)
                {
                    foreach (SmartScript _smartScript in smartScriptsCallingActionlist)
                    {
                        switch ((SmartAction)_smartScript.action_type)
                        {
                        case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                        case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                            if (_smartScript.action_param1 == smartScript.entryorguid ||
                                _smartScript.action_param2 == smartScript.entryorguid ||
                                _smartScript.action_param3 == smartScript.entryorguid ||
                                _smartScript.action_param4 == smartScript.entryorguid ||
                                _smartScript.action_param5 == smartScript.entryorguid ||
                                _smartScript.action_param6 == smartScript.entryorguid)
                            {
                                timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(_smartScript.entryorguid, (SourceTypes)_smartScript.source_type));
                            }

                            break;

                        case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                            for (int param = _smartScript.action_param1; param <= _smartScript.action_param2; ++param)
                            {
                                EntryOrGuidAndSourceType entryOrGuidAndSourceType = new EntryOrGuidAndSourceType(param, (SourceTypes)_smartScript.source_type);

                                if (param == smartScript.entryorguid && !timedActionListOrEntries.Contains(entryOrGuidAndSourceType))
                                {
                                    timedActionListOrEntries.Add(entryOrGuidAndSourceType);
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
            }
            else
            {
                switch ((SmartAction)smartScript.action_type)
                {
                case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                    timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param1, SourceTypes.SourceTypeScriptedActionlist));
                    break;

                case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                    timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param1, SourceTypes.SourceTypeScriptedActionlist));
                    timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param2, SourceTypes.SourceTypeScriptedActionlist));

                    if (smartScript.action_param3 > 0)
                    {
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param3, SourceTypes.SourceTypeScriptedActionlist));
                    }

                    if (smartScript.action_param4 > 0)
                    {
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param4, SourceTypes.SourceTypeScriptedActionlist));
                    }

                    if (smartScript.action_param5 > 0)
                    {
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param5, SourceTypes.SourceTypeScriptedActionlist));
                    }

                    if (smartScript.action_param6 > 0)
                    {
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param6, SourceTypes.SourceTypeScriptedActionlist));
                    }

                    break;

                case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                    for (int param = smartScript.action_param1; param <= smartScript.action_param2; ++param)
                    {
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(param, SourceTypes.SourceTypeScriptedActionlist));
                    }

                    break;
                }
            }

            return(timedActionListOrEntries);
        }
Exemplo n.º 32
0
 public EntryOrGuidAndSourceType(int _entryOrGuid, SourceTypes _sourceType)
 {
     entryOrGuid = _entryOrGuid; sourceType = _sourceType;
 }
Exemplo n.º 33
0
        public SearchForEntryForm(MySqlConnectionStringBuilder connectionString, string startEntryString, SourceTypes sourceTypeToSearchFor)
        {
            InitializeComponent();

            this.connectionString      = connectionString;
            this.sourceTypeToSearchFor = sourceTypeToSearchFor;
            textBoxCriteria.Text       = startEntryString;
        }
Exemplo n.º 34
0
        internal SourceTypes AllVisibleSourceTypes(OCL.User AccessingUser)
        {
            try
            {
                string sSQL = "Select Id FROM tblSourceType";
                //bool CheckScene = false;
                if(!AccessingUser.mvarIsSuperUser)
                {
                    return new SourceTypes();
                }

                SourceTypes X = new SourceTypes();
                DataSet DS = RF.GetDataSet(sSQL);
                DataTable DT = DS.Tables[0];

                foreach(DataRow R in DT.Rows)
                {
                    SourceType Ro = GetSourceType(Convert.ToInt32((object)R[0]));
                    if(Ro != null)
                    {
                        X.Add(Ro);
                    }
                }
                DT.Dispose();
                return X;
            }
            catch(Exception Err)
            {
                throw new ApplicationException(Err.Message);
            }
        }
Exemplo n.º 35
0
        private async Task<bool> SelectAndFillListViewByEntryAndSource(string entryOrGuid, SourceTypes sourceType, bool showError = true)
        {
            try
            {
                List<SmartScript> smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(XConverter.ToInt32(entryOrGuid), (int)sourceType);

                if (smartScripts == null)
                {
                    if (showError)
                    {
                        string message = String.Format("The entryorguid '{0}' could not be found in the SmartAI (smart_scripts) table for the given source type ({1})!", entryOrGuid, GetSourceTypeString(sourceType));
                        smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScriptsWithoutSourceType(XConverter.ToInt32(entryOrGuid), (int)sourceType);

                        if (smartScripts != null)
                        {
                            message += "\n\nA script was found with this entry using sourcetype " + smartScripts[0].source_type + " (" + GetSourceTypeString((SourceTypes)smartScripts[0].source_type) + "). Do you wish to load this instead?";

                            if (MessageBox.Show(message, "No scripts found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes)
                            {
                                textBoxEntryOrGuid.Text = smartScripts[0].entryorguid.ToString();
                                comboBoxSourceType.SelectedIndex = GetIndexBySourceType((SourceTypes)smartScripts[0].source_type);
                                TryToLoadScript(true);
                            }
                        }
                        else
                            MessageBox.Show(message, "No scripts found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    SetPictureBoxLoadScriptEnabled(true);
                    return false;
                }

                for (int i = 0; i < smartScripts.Count; ++i)
                {
                    ListViewItem listViewItem = new ListViewItem();
                    listViewItem.Text = smartScripts[i].entryorguid.ToString();
                    listViewItem.SubItems.Add(smartScripts[i].source_type.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].id.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].link.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_type.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_phase_mask.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_chance.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_flags.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_param1.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_param2.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_param3.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].event_param4.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].action_type.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].action_param1.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].action_param2.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].action_param3.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].action_param4.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].action_param5.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].action_param6.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_type.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_param1.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_param2.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_param3.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_x.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_y.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_z.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].target_o.ToString());
                    listViewItem.SubItems.Add(smartScripts[i].comment);
                    listViewSmartScripts.Items.Add(listViewItem);

                    if (i == smartScripts.Count - 1 && originalEntryOrGuidAndSourceType.sourceType == SourceTypes.SourceTypeScriptedActionlist)
                    {
                        if (checkBoxListActionlistsOrEntries.Checked)
                        {
                            TimedActionListOrEntries timedActionListOrEntries = await SAI_Editor_Manager.Instance.GetTimedActionlistsOrEntries(smartScripts[i], sourceType);

                            if (timedActionListOrEntries.sourceTypeOfEntry != SourceTypes.SourceTypeScriptedActionlist)
                                foreach (string scriptEntry in timedActionListOrEntries.entries)
                                    await SelectAndFillListViewByEntryAndSource(scriptEntry, timedActionListOrEntries.sourceTypeOfEntry);
                        }
                    }

                    if (checkBoxListActionlistsOrEntries.Checked && sourceType == originalEntryOrGuidAndSourceType.sourceType && originalEntryOrGuidAndSourceType.sourceType != SourceTypes.SourceTypeScriptedActionlist)
                    {
                        TimedActionListOrEntries timedActionListOrEntries = await SAI_Editor_Manager.Instance.GetTimedActionlistsOrEntries(smartScripts[i], sourceType);

                        foreach (string scriptEntry in timedActionListOrEntries.entries)
                            await SelectAndFillListViewByEntryAndSource(scriptEntry, timedActionListOrEntries.sourceTypeOfEntry);
                    }
                }

                foreach (ColumnHeader header in listViewSmartScripts.Columns)
                    header.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            catch (Exception ex)
            {
                if (showError)
                    MessageBox.Show(ex.Message, "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);

                SetPictureBoxLoadScriptEnabled(true);
                return false;
            }

            SetPictureBoxLoadScriptEnabled(true);
            return true;
        }
Exemplo n.º 36
0
        public async Task<TimedActionListOrEntries> GetTimedActionlistsOrEntries(SmartScript smartScript, SourceTypes sourceType)
        {
            TimedActionListOrEntries timedActionListOrEntries = new TimedActionListOrEntries();
            timedActionListOrEntries.entries = new List<string>();
            timedActionListOrEntries.sourceTypeOfEntry = SourceTypes.SourceTypeScriptedActionlist;

            if (sourceType == SourceTypes.SourceTypeScriptedActionlist)
            {
                List<SmartScript> smartScriptsCallingActionlist = await worldDatabase.GetSmartScriptsCallingActionLists();

                if (smartScriptsCallingActionlist != null)
                {
                    foreach (SmartScript _smartScript in smartScriptsCallingActionlist)
                    {
                        switch ((SmartAction)_smartScript.action_type)
                        {
                            case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                            case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                                if (_smartScript.action_param1 == smartScript.entryorguid ||
                                    _smartScript.action_param2 == smartScript.entryorguid ||
                                    _smartScript.action_param3 == smartScript.entryorguid ||
                                    _smartScript.action_param4 == smartScript.entryorguid ||
                                    _smartScript.action_param5 == smartScript.entryorguid ||
                                    _smartScript.action_param6 == smartScript.entryorguid)
                                {
                                    timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                    timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                                }

                                break;
                            case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                                for (int i = _smartScript.action_param1; i <= _smartScript.action_param2; ++i)
                                {
                                    if (i == smartScript.entryorguid && !timedActionListOrEntries.entries.Contains(i.ToString()))
                                    {
                                        timedActionListOrEntries.entries.Add(_smartScript.entryorguid.ToString());
                                        timedActionListOrEntries.sourceTypeOfEntry = (SourceTypes)_smartScript.source_type;
                                        break;
                                    }
                                }
                                break;
                        }
                    }
                }
            }
            else
            {
                switch ((SmartAction)smartScript.action_type)
                {
                    case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                        timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                        timedActionListOrEntries.entries.Add(smartScript.action_param1.ToString());
                        timedActionListOrEntries.entries.Add(smartScript.action_param2.ToString());

                        if (smartScript.action_param3 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param3.ToString());

                        if (smartScript.action_param4 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param4.ToString());

                        if (smartScript.action_param5 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param5.ToString());

                        if (smartScript.action_param6 > 0)
                            timedActionListOrEntries.entries.Add(smartScript.action_param6.ToString());

                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                        for (int i = smartScript.action_param1; i <= smartScript.action_param2; ++i)
                            timedActionListOrEntries.entries.Add(i.ToString());
                        break;
                }
            }

            return timedActionListOrEntries;
        }
Exemplo n.º 37
0
 public int GetIndexBySourceType(SourceTypes sourceType)
 {
     switch (sourceType)
     {
         case SourceTypes.SourceTypeCreature:
         case SourceTypes.SourceTypeGameobject:
         case SourceTypes.SourceTypeAreaTrigger:
             return (int)sourceType;
         case SourceTypes.SourceTypeScriptedActionlist:
             return 3;
         default:
             return -1;
     }
 }
Exemplo n.º 38
0
 /// <summary>设置翻译来源</summary>
 /// <param name="type"></param>
 /// <param name="args"></param>
 /// <returns></returns>
 public Trans SetSourceType(string type, string extstr)
 {
     Source = SourceTypes.Get(type, extstr);
     return(this);
 }
Exemplo n.º 39
0
        /// <summary>
        ///  Set a config file or a database table as the source of reference data.
        /// </summary>
        /// <param name="sourceType"></param>
        public static void SetSource(SourceTypes sourceType)
        {
            _sourceType = sourceType;

            // Determine whether the Config file is used or the Database connection.

            _settings = new NameValueCollection();

            switch (sourceType)
            {
                case SourceTypes.ConfigFile:
                    foreach (var setting in _configurationRepository.AllEntries().Keys)
                    {
                        _settings.Set(setting.ToString(), _configurationRepository.GetConfigurationValue<string>(setting.ToString()));
                    }
                    SourceIsSet = true;
                    break;
                case SourceTypes.DatabaseKeyValue:
                    foreach(DataRow dr in _databaseSettings.Rows)
                    {
                        _settings.Set(dr["Key"].ToString(), dr["Value"].ToString());
                    }
                    SourceIsSet = true;
                    break;
                case SourceTypes.DatabaseDefaultHeader:
                    foreach(DataColumn dc in _databaseSettings.Columns)
                    {
                        _settings.Set(dc.ColumnName.ToString(), _databaseSettings.Rows[0][dc.ColumnName].ToString());
                    }
                    SourceIsSet = true;
                    break;
            }
        }
Exemplo n.º 40
0
        public async void TryToLoadScript(int entryorguid = -1, SourceTypes sourceType = SourceTypes.SourceTypeNone, bool showErrorIfNoneFound = true, bool promptCreateIfNoneFound = false)
        {
            if (!pictureBoxLoadScript.Enabled || !Settings.Default.UseWorldDatabase)
                return;

            listViewSmartScripts.ReplaceSmartScripts(new List<SmartScript>());
            ResetFieldsToDefault();

            if (String.IsNullOrEmpty(textBoxEntryOrGuid.Text))
                return;

            buttonGenerateSql.Enabled = false;
            menuItemGenerateSql.Enabled = false;
            pictureBoxLoadScript.Enabled = false;
            pictureBoxCreateScript.Enabled = false;
            lastSmartScriptIdOfScript = 0;

            if (entryorguid != -1 && sourceType != SourceTypes.SourceTypeNone)
            {
                originalEntryOrGuidAndSourceType.entryOrGuid = entryorguid;
                originalEntryOrGuidAndSourceType.sourceType = sourceType;
                textBoxEntryOrGuid.Text = entryorguid.ToString();
                comboBoxSourceType.SelectedIndex = GetIndexBySourceType(sourceType);
            }
            else
            {
                try
                {
                    originalEntryOrGuidAndSourceType.entryOrGuid = Int32.Parse(textBoxEntryOrGuid.Text);
                }
                catch (OverflowException)
                {
                    MessageBox.Show("The entryorguid is either too big or too small.", "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                catch (FormatException)
                {
                    MessageBox.Show("The entryorguid field does not contain a valid number.", "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                originalEntryOrGuidAndSourceType.sourceType = GetSourceTypeByIndex();
            }

            List<SmartScript> smartScripts = await GetSmartScriptsForEntryAndSourceType(originalEntryOrGuidAndSourceType.entryOrGuid.ToString(), originalEntryOrGuidAndSourceType.sourceType, showErrorIfNoneFound, promptCreateIfNoneFound);
            listViewSmartScripts.ReplaceSmartScripts(smartScripts);
            checkBoxListActionlistsOrEntries.Text = originalEntryOrGuidAndSourceType.sourceType == SourceTypes.SourceTypeScriptedActionlist ? "List entries too" : "List actionlists too";

            buttonNewLine.Enabled = false;
            SetGenerateCommentsEnabled(listViewSmartScripts.Items.Count > 0 && Settings.Default.UseWorldDatabase);
            HandleShowBasicInfo();

            if (listViewSmartScripts.Items.Count > 0)
            {
                SortListView(SortOrder.Ascending, 1);
                listViewSmartScripts.Items[0].Selected = true;
                listViewSmartScripts.Select(); //! Sets the focus on the listview

                if (checkBoxListActionlistsOrEntries.Enabled && checkBoxListActionlistsOrEntries.Checked)
                {
                    foreach (ListViewItem item in listViewSmartScripts.Items)
                        if (item.Text == originalEntryOrGuidAndSourceType.entryOrGuid.ToString())
                            lastSmartScriptIdOfScript = XConverter.ToInt32(item.SubItems[2].Text);
                }
                else
                    lastSmartScriptIdOfScript = XConverter.ToInt32(listViewSmartScripts.Items[listViewSmartScripts.Items.Count - 1].SubItems[2].Text);
            }

            buttonNewLine.Enabled = textBoxEntryOrGuid.Text.Length > 0;
            buttonGenerateSql.Enabled = listViewSmartScripts.Items.Count > 0;
            menuItemGenerateSql.Enabled = listViewSmartScripts.Items.Count > 0;
            pictureBoxCreateScript.Enabled = textBoxEntryOrGuid.Text.Length > 0;
        }
Exemplo n.º 41
0
 public EntryOrGuidAndSourceType(int _entryOrGuid, SourceTypes _sourceType) { entryOrGuid = _entryOrGuid; sourceType = _sourceType; }
Exemplo n.º 42
0
 public DirectInputSource(IInputDevice inputDevice, string name, SourceTypes type, int offset, Func <JoystickState, double> valueGetter) : base(inputDevice, name, type, offset)
 {
     this.valueGetter = valueGetter;
 }
Exemplo n.º 43
0
        private string GetTemplateTableBySourceType(SourceTypes sourceType)
        {
            switch (sourceType)
            {
                case SourceTypes.SourceTypeCreature:
                    return "creature_template";
                case SourceTypes.SourceTypeGameobject:
                    return "gameobject_template";
            }

            return "<unknown template table>";
        }
Exemplo n.º 44
0
        public void ReadXml(XmlReader reader)
        {
            reader.MoveToContent();
            string typeAttribute = reader.GetAttribute(TypeAttributeName);
            if (string.IsNullOrEmpty(typeAttribute))
            {
                throw new InvalidDataException("Type attribute can't be empty");
            }
            SourceTypes type;
            if (!Enum.TryParse(typeAttribute, true, out type))
            {
                throw new InvalidDataException(string.Format("Invalid type value: {0}", typeAttribute));
            }
            Type = type;

            string formatAttribute = reader.GetAttribute(FormatAttributeName);
            if (string.IsNullOrEmpty(formatAttribute))
            {
                throw new InvalidDataException("Format attribute can't be empty");
            }
            FontFormat format;
            if (!Enum.TryParse(formatAttribute, true, out format))
            {
                throw new InvalidDataException(string.Format("Invalid format value: {0}", formatAttribute));
            }
            Format = format;

            while (!reader.EOF)
            {
                if (reader.IsStartElement())
                {
                    switch (reader.Name)
                    {
                        case LocationElementName:
                            Location = reader.ReadElementContentAsString();
                            continue;
                    }
                }
                reader.Read();
            }
        }
Exemplo n.º 45
0
 private string GetSourceTypeString(SourceTypes sourceType)
 {
     switch (sourceType)
     {
         case SourceTypes.SourceTypeCreature:
             return "creature";
         case SourceTypes.SourceTypeGameobject:
             return "gameobject";
         case SourceTypes.SourceTypeAreaTrigger:
             return "areatrigger";
         case SourceTypes.SourceTypeScriptedActionlist:
             return "actionlist";
         default:
             return "unknown";
     }
 }
        private ActionResult GetContent(IContent content, SourceTypes sourceType = SourceTypes.ContentItem, ResultTarget resultTarget = ResultTarget.Contents, string fieldspartsFilter = "", int page = 1, int pageSize = 10, bool tinyResponse = true, bool minified = false, bool realformat = false, int deeplevel = 10, string[] complexBehaviour = null)
        {
            var result = new ContentResult {
                ContentType = "application/json"
            };
            var jsonString = "{}";

            var      _filterContentFieldsParts = fieldspartsFilter.ToLower().Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
            XElement dump;
            XElement projectionDump = null;
            // il dump dell'oggetto principale non filtra per field
            ObjectDumper    dumper = new ObjectDumper(deeplevel, null, false, tinyResponse, complexBehaviour);
            dynamic         shape; //, specificShape;
            var             sb          = new StringBuilder();
            List <XElement> listContent = new List <XElement>();

            // verifico se l'oggetto è soggetto all'accettazione delle policies
            var policy = content.As <Policy.Models.PolicyPart>();

            //if (policy != null) {
            //    if ((String.IsNullOrWhiteSpace(_orchardServices.WorkContext.HttpContext.Request.QueryString["v"]))) {// E' soggetto a privacy, quindi faccio sempre il redirect se manca il parametro in querystring v=
            //        if (policy.HasPendingPolicies ?? false) { // se ha delle pending policies deve restituire le policy text, legate al contenuto, qui ndi non deve mai servire cache
            //            var redirectUrl = String.Format("{0}{1}v={2}", _orchardServices.WorkContext.HttpContext.Request.RawUrl, (_orchardServices.WorkContext.HttpContext.Request.RawUrl.Contains("?") ? "&" : "?"), Guid.NewGuid());
            //            _orchardServices.WorkContext.HttpContext.Response.Redirect(redirectUrl, true);
            //        } else {// se NON ha delle pending policies deve restituire un url non cacheato (quindi aggiungo v=),
            //            var redirectUrl = String.Format("{0}{1}v={2}", _orchardServices.WorkContext.HttpContext.Request.RawUrl, (_orchardServices.WorkContext.HttpContext.Request.RawUrl.Contains("?") ? "&" : "?"), "cached-content");
            //            _orchardServices.WorkContext.HttpContext.Response.Redirect(redirectUrl, true);
            //            //_orchardServices.WorkContext.HttpContext.Response.Redirect(redirectUrl, true);
            //        }
            //        return null; // in entrambi i casi ritorno null come risultato della current request
            //    }
            //}
            if (policy != null && (_policyServices.HasPendingPolicies(content.ContentItem) ?? false))   // Se l'oggetto ha delle pending policies allora devo serivre la lista delle pending policies
            //policy.PendingPolicies
            {
                sb.Insert(0, "{");
                sb.AppendFormat("\"n\": \"{0}\"", "Model");
                sb.AppendFormat(", \"v\": \"{0}\"", "VirtualContent");
                sb.Append(", \"m\": [{");
                sb.AppendFormat("\"n\": \"{0}\"", "VirtualId"); // Unused property for mobile mapper needs
                sb.AppendFormat(", \"v\": \"{0}\"", "0");
                sb.Append("}]");

                sb.Append(", \"l\":[");

                int i = 0;
                sb.Append("{");
                sb.AppendFormat("\"n\": \"{0}\"", "PendingPolicies");
                sb.AppendFormat(", \"v\": \"{0}\"", "ContentItem[]");
                sb.Append(", \"m\": [");

                foreach (var item in _policyServices.PendingPolicies(content.ContentItem))
                {
                    if (i > 0)
                    {
                        sb.Append(",");
                    }
                    sb.Append("{");
                    dumper         = new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour);
                    projectionDump = dumper.Dump(item, String.Format("[{0}]", i));
                    JsonConverter.ConvertToJSon(projectionDump, sb, minified, realformat);
                    sb.Append("}");
                    i++;
                }
                sb.Append("]");
                sb.Append("}");

                sb.Append("]"); // l : [
                sb.Append("}");
            }
            else     // Se l'oggetto NON ha delle pending policies allora posso servire l'oggetto stesso
            {
                shape = _orchardServices.ContentManager.BuildDisplay(content);
                if (sourceType == SourceTypes.ContentItem)
                {
                    dump = dumper.Dump(content, "Model");
                }
                else
                {
                    dump = dumper.Dump(shape, "Model");
                }
                //dump.XPathSelectElements("");
                //var filteredDump = dump.Descendants();
                //ConvertToJSon(dump, sb);
                JsonConverter.ConvertToJSon(dump, sb, minified, realformat);
                sb.Insert(0, "{");
                sb.Append(", \"l\":[");
                // Dopo avere convertito il contentItem in JSON aggiungo i Json delle eventuali liste
                dynamic part                 = null;
                var     firstList            = true;
                var     listDumpedContentIds = new List <int>();

                #region [ProjectionPart ]

                try {
                    part = shape.ContentItem.ProjectionPart;
                } catch {
                    part = null;
                }
                if (part != null)
                {
                    if (!firstList)
                    {
                        sb.Append(",");
                    }
                    firstList = false;
                    var queryId    = part.Record.QueryPartRecord.Id;
                    var queryItems = _projectionManager.GetContentItems(queryId, (page - 1) * pageSize, pageSize);
                    int i          = 0;
                    sb.Append("{");
                    sb.AppendFormat("\"n\": \"{0}\"", "ProjectionList");
                    sb.AppendFormat(", \"v\": \"{0}\"", "ContentItem[]");
                    sb.Append(", \"m\": [");

                    foreach (var item in queryItems)
                    {
                        if (i > 0)
                        {
                            sb.Append(",");
                        }
                        sb.Append("{");
                        dumper         = new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour);
                        projectionDump = dumper.Dump(item, String.Format("[{0}]", i));
                        JsonConverter.ConvertToJSon(projectionDump, sb, minified, realformat);
                        sb.Append("}");
                        i++;
                    }
                    sb.Append("]");
                    sb.Append("}");
                }
                part = null;

                #endregion [ProjectionPart ]

                #region [CalendarPart ]

                try {
                    part = shape.ContentItem.CalendarPart;
                } catch {
                    part = null;
                }
                if (part != null)
                {
                    if (!firstList)
                    {
                        sb.Append(",");
                    }
                    firstList = false;
                    if (_orchardServices.WorkContext.TryResolve <IEventsService>(out _eventsService))  // non sempre questo modulo è attivo quindi se non riesce a risolvere il servizio, bypassa la chiamata
                    {
                        var queryItems = _eventsService.GetAggregatedList(part, page, pageSize);
                        int i          = 0;
                        sb.Append("{");
                        sb.AppendFormat("\"n\": \"{0}\"", "EventList");
                        sb.AppendFormat(", \"v\": \"{0}\"", "ContentItem[]");
                        sb.Append(", \"m\": [");

                        foreach (var item in queryItems)
                        {
                            if (i > 0)
                            {
                                sb.Append(",");
                            }
                            sb.Append("{");
                            dumper         = new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour);
                            projectionDump = dumper.Dump(item, String.Format("[{0}]", i));
                            JsonConverter.ConvertToJSon(projectionDump, sb);
                            sb.Append("}");
                            i++;
                        }
                        sb.Append("]");
                        sb.Append("}");
                    }
                }
                part = null;

                #endregion [CalendarPart ]

                #region [ExernalField]

                var ExtertalFields = (dynamic)
                                     (from parte in ((ContentItem)shape.ContentItem).Parts
                                      from field in parte.Fields
                                      where (field.GetType().Name == "FieldExternal" && ((dynamic)field).Setting.GenerateL)
                                      select field).FirstOrDefault();
                if (ExtertalFields != null)
                {
                    if (!firstList)
                    {
                        sb.Append(",");
                    }
                    firstList = false;
                    //sb.Append("{");
                    //sb.AppendFormat("\"n\": \"{0}\"", "ExternalContent");
                    //sb.AppendFormat(", \"v\": \"{0}\"", "ExternalContent");
                    //sb.Append(", \"m\": [");

                    sb.Append("{");
                    dumper = new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour);
                    //nameDynamicJsonArray = "List<generic>";
                    if (ExtertalFields.ContentObject != null)
                    {
                        if (ExtertalFields.ContentObject.GetType() == typeof(ExternalFieldRemoteException))
                        {
                            throw new ExternalFieldRemoteException();
                        }
                        projectionDump = dumper.Dump(cleanobj(ExtertalFields.ContentObject), ExtertalFields.Name, "List<generic>");
                        JsonConverter.ConvertToJSon(projectionDump, sb, minified, realformat);
                    }
                    //    sb.Append("}]}");
                    sb.Append("}");
                }

                #endregion [ExernalField]

                #region [ WidgetsContainerPart ]

                try {
                    part = shape.ContentItem.WidgetsContainerPart;
                } catch {
                    part = null;
                }
                if (part != null)
                {
                    //var queryId = part.Record.QueryPartRecord.Id;
                    if (_orchardServices.WorkContext.TryResolve <IWidgetManager>(out _widgetManager))  // non semepre questo modulo è attivo quindi se non riesce a risolvere il servizio, bypassa la chiamata
                    {
                        if (!firstList)
                        {
                            sb.Append(",");
                        }
                        firstList = false;
                        var queryItems = _widgetManager.GetWidgets(part.Id);
                        int i          = 0;
                        sb.Append("{");
                        sb.AppendFormat("\"n\": \"{0}\"", "WidgetList");
                        sb.AppendFormat(", \"v\": \"{0}\"", "ContentItem[]");
                        sb.Append(", \"m\": [");

                        foreach (var item in queryItems)
                        {
                            if (i > 0)
                            {
                                sb.Append(",");
                            }
                            sb.Append("{");
                            dumper         = new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour);
                            projectionDump = dumper.Dump(item, String.Format("[{0}]", i));
                            JsonConverter.ConvertToJSon(projectionDump, sb, minified, realformat);
                            sb.Append("}");
                            i++;
                        }
                        sb.Append("]");
                        sb.Append("}");
                    }
                }

                #endregion [ WidgetsContainerPart ]

                #region [ Taxonomy/TermsPart ]

                part = null;
                try {
                    if (shape.ContentItem.ContentType.EndsWith("Term") || !String.IsNullOrWhiteSpace(shape.ContentItem.TypeDefinition.Settings["Taxonomy"]))
                    {
                        part = shape.ContentItem.TermPart;
                    }
                } catch {
                    part = null;
                }
                if (part != null)
                {
                    if (!firstList)
                    {
                        sb.Append(",");
                    }
                    firstList = false;
                    dynamic termContentItems;
                    if (resultTarget == ResultTarget.Terms)
                    {
                        termContentItems = _taxonomyService.GetChildren(part, true);
                    }
                    else if (resultTarget == ResultTarget.SubTerms)
                    {
                        termContentItems = _taxonomyService.GetChildren(part, false);
                    }
                    else
                    {
                        termContentItems = _taxonomyService.GetContentItems(part, (page - 1) * pageSize, pageSize);
                    }

                    int i = 0;
                    sb.Append("{");
                    if (resultTarget == ResultTarget.Contents)
                    {
                        sb.AppendFormat("\"n\": \"{0}\"", "TaxonomyTermList");
                        sb.AppendFormat(", \"v\": \"{0}\"", "ContentItem[]");
                    }
                    else
                    {
                        sb.AppendFormat("\"n\": \"{0}\"", "TermPartList");
                        sb.AppendFormat(", \"v\": \"{0}\"", "TermPart[]");
                    }
                    sb.Append(", \"m\": [");

                    foreach (var item in termContentItems)
                    {
                        if (i > 0)
                        {
                            sb.Append(",");
                        }
                        sb.Append("{");
                        dumper = new ObjectDumper(deeplevel, _filterContentFieldsParts, false, tinyResponse, complexBehaviour);
                        if (resultTarget == ResultTarget.Contents)
                        {
                            projectionDump = dumper.Dump(item.ContentItem, String.Format("[{0}]", i));
                            JsonConverter.ConvertToJSon(projectionDump, sb, minified, realformat);
                        }
                        else
                        {
                            var dumperForPart = new ObjectDumper(deeplevel, _filterContentFieldsParts, true, tinyResponse, complexBehaviour);
                            projectionDump = dumperForPart.Dump(item, "TermPart");
                            JsonConverter.ConvertToJSon(projectionDump, sb, minified, realformat);
                        }
                        sb.Append("}");
                        i++;
                    }
                    sb.Append("]");
                    sb.Append("}");
                }
                part = null;

                #endregion [ Taxonomy/TermsPart ]

                sb.Append("]"); // l : [
                sb.Append("}");
            }
            jsonString     = sb.ToString().Replace("\t", " ");
            result.Content = jsonString;
            return(result);
        }
Exemplo n.º 47
0
        private async Task<List<SmartScript>> GetSmartScriptsForEntryAndSourceType(string entryOrGuid, SourceTypes sourceType, bool showError = true, bool promptCreateIfNoneFound = false)
        {
            List<SmartScript> smartScriptsToReturn = new List<SmartScript>();

            try
            {
                List<SmartScript> smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(XConverter.ToInt32(entryOrGuid), (int)sourceType);

                if (smartScripts == null)
                {
                    if (showError)
                    {
                        bool showNormalErrorMessage = false;
                        string message = String.Format("The entryorguid '{0}' could not be found in the smart_scripts table for the given source_type!", entryOrGuid);
                        smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScriptsWithoutSourceType(XConverter.ToInt32(entryOrGuid), (int)sourceType);

                        if (smartScripts != null)
                        {
                            message += "\n\nA script was found with this entry using sourcetype " + smartScripts[0].source_type + " (" + GetSourceTypeString((SourceTypes)smartScripts[0].source_type) + "). Do you wish to load this instead?";
                            DialogResult dialogResult = MessageBox.Show(message, "No scripts found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                            if (dialogResult == DialogResult.Yes)
                            {
                                textBoxEntryOrGuid.Text = smartScripts[0].entryorguid.ToString();
                                comboBoxSourceType.SelectedIndex = GetIndexBySourceType((SourceTypes)smartScripts[0].source_type);
                                TryToLoadScript();
                            }
                        }
                        else
                        {
                            switch (sourceType)
                            {
                                case SourceTypes.SourceTypeCreature:
                                    //! Get `id` from `creature` and check it for SAI
                                    if (XConverter.ToInt32(entryOrGuid) < 0) //! Guid
                                    {
                                        int entry = await SAI_Editor_Manager.Instance.worldDatabase.GetCreatureIdByGuid(-XConverter.ToInt32(entryOrGuid));
                                        smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(entry, (int)SourceTypes.SourceTypeCreature);

                                        if (smartScripts != null)
                                        {
                                            message += "\n\nA script was not found for this guid but we did find one using the entry of the guid (" + smartScripts[0].entryorguid + "). Do you wish to load this instead?";
                                            DialogResult dialogResult = MessageBox.Show(message, "No scripts found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                                            if (dialogResult == DialogResult.Yes)
                                            {
                                                textBoxEntryOrGuid.Text = smartScripts[0].entryorguid.ToString();
                                                comboBoxSourceType.SelectedIndex = GetIndexBySourceType(SourceTypes.SourceTypeCreature);
                                                TryToLoadScript();
                                            }
                                        }
                                        else
                                            showNormalErrorMessage = true;
                                    }
                                    //! Get all `guid` instances from `creature` for the given `id` and allow user to select a script
                                    else //! Non-guid (entry)
                                    {
                                        int actualEntry = XConverter.ToInt32(entryOrGuid);
                                        List<Creature> creatures = await SAI_Editor_Manager.Instance.worldDatabase.GetCreaturesById(actualEntry);

                                        if (creatures != null)
                                        {
                                            List<List<SmartScript>> creaturesWithSmartAi = new List<List<SmartScript>>();

                                            foreach (Creature creature in creatures)
                                            {
                                                smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(-creature.guid, (int)SourceTypes.SourceTypeCreature);

                                                if (smartScripts != null)
                                                    creaturesWithSmartAi.Add(smartScripts);
                                            }

                                            if (creaturesWithSmartAi.Count > 0)
                                            {
                                                message += "\n\nA script was not found for this entry but we did find script(s) for guid(s) spawned under this entry. Do you wish to select one of these instead? (you can pick one out of all guid-scripts for this entry)";
                                                DialogResult dialogResult = MessageBox.Show(message, "No scripts found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                                                if (dialogResult == DialogResult.Yes)
                                                    using (SelectSmartScriptForm selectSmartScriptForm = new SelectSmartScriptForm(creaturesWithSmartAi))
                                                        selectSmartScriptForm.ShowDialog(this);
                                            }
                                            else
                                                showNormalErrorMessage = true;
                                        }
                                        else
                                            showNormalErrorMessage = true;
                                    }
                                    break;
                                case SourceTypes.SourceTypeGameobject:
                                    //! Get `id` from `gameobject` and check it for SAI
                                    if (XConverter.ToInt32(entryOrGuid) < 0) //! Guid
                                    {
                                        int entry = await SAI_Editor_Manager.Instance.worldDatabase.GetGameobjectIdByGuid(-XConverter.ToInt32(entryOrGuid));
                                        smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(entry, (int)SourceTypes.SourceTypeGameobject);

                                        if (smartScripts != null)
                                        {
                                            message += "\n\nA script was not found for this guid but we did find one using the entry of the guid (" + smartScripts[0].entryorguid + "). Do you wish to load this instead?";
                                            DialogResult dialogResult = MessageBox.Show(message, "No scripts found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                                            if (dialogResult == DialogResult.Yes)
                                            {
                                                textBoxEntryOrGuid.Text = smartScripts[0].entryorguid.ToString();
                                                comboBoxSourceType.SelectedIndex = GetIndexBySourceType(SourceTypes.SourceTypeGameobject);
                                                TryToLoadScript();
                                            }
                                        }
                                        else
                                            showNormalErrorMessage = true;
                                    }
                                    //! Get all `guid` instances from `gameobject` for the given `id` and allow user to select a script
                                    else //! Non-guid (entry)
                                    {
                                        int actualEntry = XConverter.ToInt32(entryOrGuid);
                                        List<Gameobject> gameobjects = await SAI_Editor_Manager.Instance.worldDatabase.GetGameobjectsById(actualEntry);

                                        if (gameobjects != null)
                                        {
                                            List<List<SmartScript>> gameobjectsWithSmartAi = new List<List<SmartScript>>();

                                            foreach (Gameobject gameobject in gameobjects)
                                            {
                                                smartScripts = await SAI_Editor_Manager.Instance.worldDatabase.GetSmartScripts(-gameobject.guid, (int)SourceTypes.SourceTypeGameobject);

                                                if (smartScripts != null)
                                                    gameobjectsWithSmartAi.Add(smartScripts);
                                            }

                                            if (gameobjectsWithSmartAi.Count > 0)
                                            {
                                                message += "\n\nA script was not found for this entry but we did find script(s) for guid(s) spawned under this entry. Do you wish to select one of these instead? (you can pick one out of all guid-scripts for this entry)";
                                                DialogResult dialogResult = MessageBox.Show(message, "No scripts found!", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation);

                                                if (dialogResult == DialogResult.Yes)
                                                    using (SelectSmartScriptForm selectSmartScriptForm = new SelectSmartScriptForm(gameobjectsWithSmartAi))
                                                        selectSmartScriptForm.ShowDialog(this);
                                            }
                                            else
                                                showNormalErrorMessage = true;
                                        }
                                        else
                                            showNormalErrorMessage = true;
                                    }
                                    break;
                                default:
                                    showNormalErrorMessage = true;
                                    break;
                            }
                        }

                        if (showNormalErrorMessage)
                        {
                            if (promptCreateIfNoneFound)
                            {
                                DialogResult dialogResult = MessageBox.Show(message + "\n\nDo you want to create a new script using this entryorguid?", "No scripts found!", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

                                if (dialogResult == DialogResult.Yes)
                                    TryToCreateScript();
                            }
                            else
                                MessageBox.Show(message, "No scripts found!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }

                    pictureBoxLoadScript.Enabled = textBoxEntryOrGuid.Text.Length > 0 && Settings.Default.UseWorldDatabase;
                    pictureBoxCreateScript.Enabled = textBoxEntryOrGuid.Text.Length > 0;
                    return new List<SmartScript>();
                }

                for (int i = 0; i < smartScripts.Count; ++i)
                {
                    smartScriptsToReturn.Add(smartScripts[i]);

                    if (!checkBoxListActionlistsOrEntries.Checked || !checkBoxListActionlistsOrEntries.Enabled)
                        continue;

                    if (i == smartScripts.Count - 1 && originalEntryOrGuidAndSourceType.sourceType == SourceTypes.SourceTypeScriptedActionlist)
                    {
                        List<EntryOrGuidAndSourceType> timedActionListOrEntries = await SAI_Editor_Manager.Instance.GetTimedActionlistsOrEntries(smartScripts[i], sourceType);

                        //if (timedActionListOrEntries.sourceTypeOfEntry != SourceTypes.SourceTypeScriptedActionlist)
                        {
                            foreach (EntryOrGuidAndSourceType entryOrGuidAndSourceType in timedActionListOrEntries)
                            {
                                if (entryOrGuidAndSourceType.sourceType == SourceTypes.SourceTypeScriptedActionlist)
                                    continue;

                                List<SmartScript> newSmartScripts = await GetSmartScriptsForEntryAndSourceType(entryOrGuidAndSourceType.entryOrGuid.ToString(), entryOrGuidAndSourceType.sourceType);

                                if (newSmartScripts != null)
                                    foreach (SmartScript item in newSmartScripts.Where(item => !ListContainsSmartScript(smartScriptsToReturn, item)))
                                        smartScriptsToReturn.Add(item);

                                pictureBoxCreateScript.Enabled = textBoxEntryOrGuid.Text.Length > 0;
                            }
                        }
                    }

                    if (sourceType == originalEntryOrGuidAndSourceType.sourceType && originalEntryOrGuidAndSourceType.sourceType != SourceTypes.SourceTypeScriptedActionlist)
                    {
                        List<EntryOrGuidAndSourceType> timedActionListOrEntries = await SAI_Editor_Manager.Instance.GetTimedActionlistsOrEntries(smartScripts[i], sourceType);

                        foreach (EntryOrGuidAndSourceType entryOrGuidAndSourceType in timedActionListOrEntries)
                        {
                            List<SmartScript> newSmartScripts = await GetSmartScriptsForEntryAndSourceType(entryOrGuidAndSourceType.entryOrGuid.ToString(), entryOrGuidAndSourceType.sourceType);

                            foreach (SmartScript item in newSmartScripts.Where(item => !ListContainsSmartScript(smartScriptsToReturn, item))) smartScriptsToReturn.Add(item);

                            pictureBoxCreateScript.Enabled = textBoxEntryOrGuid.Text.Length > 0;
                        }
                    }
                }

                foreach (ColumnHeader header in listViewSmartScripts.Columns)
                    header.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
            }
            catch (Exception ex)
            {
                if (showError)
                    MessageBox.Show(ex.Message, "Something went wrong!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            pictureBoxLoadScript.Enabled = textBoxEntryOrGuid.Text.Length > 0 && Settings.Default.UseWorldDatabase;
            pictureBoxCreateScript.Enabled = textBoxEntryOrGuid.Text.Length > 0;
            return smartScriptsToReturn;
        }
 public ActionResult GetObjectById(int contentId = 0, SourceTypes sourceType = SourceTypes.ContentItem, ResultTarget resultTarget = ResultTarget.Contents, string mfilter = "", int page = 1, int pageSize = 1000, bool tinyResponse = true, bool minified = false, bool realformat = false, int deeplevel = 10, decimal version = 0)
 {
     if (contentId > 0)
     {
         IContent item = _orchardServices.ContentManager.Get(contentId, VersionOptions.Published);
         if (item == null)
         {
             Response rsp = _utilsServices.GetResponse(ResponseType.None, "Valore Id non valido");
             // rsp.Message = ;
             XmlSerializer serializer = new XmlSerializer(typeof(Response));
             XmlDocument   doc        = new XmlDocument();
             StringWriter  sww        = new StringWriter();
             XmlWriter     writer     = XmlWriter.Create(sww);
             serializer.Serialize(writer, rsp);
             var xml = sww.ToString();
             return(this.Content(xml, "text/xml"));
         }
         else
         {
             if (item.As <AutoroutePart>() != null)
             {
                 return(GetObjectByAlias(item.As <AutoroutePart>().DisplayAlias, sourceType, resultTarget, mfilter, page, pageSize, tinyResponse, deeplevel, version));
             }
             else
             {
                 Response rsp = _utilsServices.GetResponse(ResponseType.None);
                 rsp.Message = "Valore Id non valido";
                 XmlSerializer serializer = new XmlSerializer(typeof(Response));
                 XmlDocument   doc        = new XmlDocument();
                 StringWriter  sww        = new StringWriter();
                 XmlWriter     writer     = XmlWriter.Create(sww);
                 serializer.Serialize(writer, rsp);
                 var xml = sww.ToString();
                 return(this.Content(xml, "text/xml"));
             }
         }
     }
     else
     {
         Response rsp = _utilsServices.GetResponse(ResponseType.None);
         rsp.Message = "Valore Id non valido";
         XmlSerializer serializer = new XmlSerializer(typeof(Response));
         XmlDocument   doc        = new XmlDocument();
         StringWriter  sww        = new StringWriter();
         XmlWriter     writer     = XmlWriter.Create(sww);
         serializer.Serialize(writer, rsp);
         var xml = sww.ToString();
         return(this.Content(xml, "text/xml"));
     }
     //if (item == null) {
     //    new HttpException(404, ("Not found"));
     //    Response rsp = _utilsServices.GetResponse(ResponseType.None);
     //    rsp.Message = "Pagina non trovata";
     //    XmlSerializer serializer = new XmlSerializer(typeof(Response));
     //    XmlDocument doc = new XmlDocument();
     //    StringWriter sww = new StringWriter();
     //    XmlWriter writer = XmlWriter.Create(sww);
     //    serializer.Serialize(writer, rsp);
     //    var xml = sww.ToString();
     //    return this.Content(xml, "text/xml");
     //}
     //return (ContentResult)GetContent(item, sourceType, resultTarget, mfilter, page, pageSize, tinyResponse, minified, realformat, deeplevel);
 }
        public ActionResult GetObjectByAlias(string displayAlias, SourceTypes sourceType = SourceTypes.ContentItem, ResultTarget resultTarget = ResultTarget.Contents, string mfilter = "", int page = 1, int pageSize = 1000, bool tinyResponse = true, int deeplevel = 10, decimal version = 0)
        {
            try {
                if (page < 1)
                {
                    page = 1;
                }
                if (pageSize < 1)
                {
                    pageSize = 1000;
                }
                var autoroutePart = _orchardServices.ContentManager.Query <AutoroutePart, AutoroutePartRecord>()
                                    .ForVersion(VersionOptions.Published)
                                    .Where(w => w.DisplayAlias == displayAlias).List().SingleOrDefault();
                IContent item = null;
                if (autoroutePart != null && autoroutePart.ContentItem != null)
                {
                    item = autoroutePart.ContentItem;
                }
                else
                {
                    Response rsp = _utilsServices.GetResponse(ResponseType.None, "Pagina non trovata");

                    XmlSerializer serializer = new XmlSerializer(typeof(Response));
                    XmlDocument   doc        = new XmlDocument();
                    StringWriter  sww        = new StringWriter();
                    XmlWriter     writer     = XmlWriter.Create(sww);
                    serializer.Serialize(writer, rsp);
                    var xml = sww.ToString();
                    return(this.Content(xml, "text/xml"));
                    // return new HttpNotFoundResult();
                }

                List <dynamic> ListShape = new List <dynamic>();
                string         CiType    = "";
                if (item.ContentItem.ContentType == "ProjectionPage")
                {
                    #region Projection

                    var part = ((dynamic)item.ContentItem).ProjectionPart;
                    if (part != null)
                    {
                        var queryId = part.Record.QueryPartRecord.Id;

                        var queryItems = _projectionManager.GetContentItems(queryId, (page - 1) * pageSize, pageSize);

                        //   int i = 0;
                        if (queryItems.Count == 0)
                        {
                            return(null);
                        }
                        foreach (var projitem in queryItems)
                        {
                            // autoroutePart = projitem.AutoroutePart;
                            CiType = projitem.ContentType;
                            List <dynamic> list2 = ItemsMultiLanguage(projitem.AutoroutePart);
                            //  var merged = new List<dynamic>(ListShape);
                            ListShape.AddRange(list2.Where(p2 =>
                                                           ListShape.All(p1 => p1.ContentItem.Id != p2.ContentItem.Id)));
                            // ListShape = merged;
                        }

                        #endregion Projection
                    }
                }
                else
                {
                    //  string tipoCI = item.ContentItem.ContentType;
                    //   string CiType = ((ContentItem)autoroutePart.ContentItem).ContentType;
                    //  int id = ((ContentItem)autoroutePart.ContentItem).Id;

                    ListShape = ItemsMultiLanguage(autoroutePart);
                    CiType    = ((ContentItem)autoroutePart.ContentItem).ContentType;
                }

                //int masterid = 0;
                //int teoric_masterid = 0;
                //try {
                //    teoric_masterid = ((ContentItem)autoroutePart.ContentItem).As<LocalizationPart>().MasterContentItem.Id;
                //    masterid = teoric_masterid;
                //}
                //catch {
                //    masterid = id;
                //}
                //var contentsLocalized = _orchardServices.ContentManager.Query(CiType).Where<LocalizationPartRecord>(l => l.MasterContentItemId == masterid || l.Id == masterid).List();
                //List<dynamic> ListShape = new List<dynamic>();
                //foreach (ContentItem singleCi in contentsLocalized) {
                //    ListShape.Add(_orchardServices.ContentManager.BuildDisplay(singleCi));
                //}

                var namespaces = this.GetType().FullName.Split('.').AsEnumerable();
                namespaces = namespaces.Except(new string[] { this.GetType().Name });
                namespaces = namespaces.Except(new string[] { namespaces.Last() });
                var area = string.Join(".", namespaces);
                if (version > 0)
                {
                    CiType += version.ToString();
                }
                string myview = "~/" + @"App_Data/Sites/" + _shellSetting.Name + "/WebServices/" + CiType + ".cshtml";
                string myfile = HostingEnvironment.MapPath("~/") + @"App_Data\Sites\" + _shellSetting.Name + @"\WebServices\" + CiType + ".cshtml";
                if (System.IO.File.Exists(myfile))
                {
                    return(View(myview, (object)ListShape));
                }
                else
                {
                    Response rsp = _utilsServices.GetResponse(ResponseType.None, "Contenuto non disponibile");
                    //  rsp.Message =;
                    XmlSerializer serializer = new XmlSerializer(typeof(Response));
                    XmlDocument   doc        = new XmlDocument();
                    StringWriter  sww        = new StringWriter();
                    XmlWriter     writer     = XmlWriter.Create(sww);
                    serializer.Serialize(writer, rsp);
                    var xml = sww.ToString();
                    return(this.Content(xml, "text/xml"));
                }
            } catch (Exception ex) {
                Response rsp = _utilsServices.GetResponse(ResponseType.None, ex.Message);
                //   rsp.Message=;
                XmlSerializer serializer = new XmlSerializer(typeof(Response));
                XmlDocument   doc        = new XmlDocument();
                StringWriter  sww        = new StringWriter();
                XmlWriter     writer     = XmlWriter.Create(sww);
                serializer.Serialize(writer, rsp);
                var xml = sww.ToString();
                return(this.Content(xml, "text/xml"));
            }
        }
Exemplo n.º 50
0
        public async Task<List<EntryOrGuidAndSourceType>> GetTimedActionlistsOrEntries(SmartScript smartScript, SourceTypes sourceType)
        {
            List<EntryOrGuidAndSourceType> timedActionListOrEntries = new List<EntryOrGuidAndSourceType>();

            if (sourceType == SourceTypes.SourceTypeScriptedActionlist)
            {
                List<SmartScript> smartScriptsCallingActionlist = await worldDatabase.GetSmartScriptsCallingActionLists();

                if (smartScriptsCallingActionlist != null)
                {
                    foreach (SmartScript _smartScript in smartScriptsCallingActionlist)
                    {
                        switch ((SmartAction)_smartScript.action_type)
                        {
                            case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                            case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                                if (_smartScript.action_param1 == smartScript.entryorguid ||
                                    _smartScript.action_param2 == smartScript.entryorguid ||
                                    _smartScript.action_param3 == smartScript.entryorguid ||
                                    _smartScript.action_param4 == smartScript.entryorguid ||
                                    _smartScript.action_param5 == smartScript.entryorguid ||
                                    _smartScript.action_param6 == smartScript.entryorguid)
                                {
                                    timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(_smartScript.entryorguid, (SourceTypes)_smartScript.source_type));
                                }

                                break;
                            case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                                for (int param = _smartScript.action_param1; param <= _smartScript.action_param2; ++param)
                                {
                                    EntryOrGuidAndSourceType entryOrGuidAndSourceType = new EntryOrGuidAndSourceType(param, (SourceTypes)_smartScript.source_type);

                                    if (param == smartScript.entryorguid && !timedActionListOrEntries.Contains(entryOrGuidAndSourceType))
                                    {
                                        timedActionListOrEntries.Add(entryOrGuidAndSourceType);
                                        break;
                                    }
                                }
                                break;
                        }
                    }
                }
            }
            else
            {
                switch ((SmartAction)smartScript.action_type)
                {
                    case SmartAction.SMART_ACTION_CALL_TIMED_ACTIONLIST:
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param1, SourceTypes.SourceTypeScriptedActionlist));
                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST:
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param1, SourceTypes.SourceTypeScriptedActionlist));
                        timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param2, SourceTypes.SourceTypeScriptedActionlist));

                        if (smartScript.action_param3 > 0)
                            timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param3, SourceTypes.SourceTypeScriptedActionlist));

                        if (smartScript.action_param4 > 0)
                            timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param4, SourceTypes.SourceTypeScriptedActionlist));

                        if (smartScript.action_param5 > 0)
                            timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param5, SourceTypes.SourceTypeScriptedActionlist));

                        if (smartScript.action_param6 > 0)
                            timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(smartScript.action_param6, SourceTypes.SourceTypeScriptedActionlist));

                        break;
                    case SmartAction.SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST:
                        for (int param = smartScript.action_param1; param <= smartScript.action_param2; ++param)
                            timedActionListOrEntries.Add(new EntryOrGuidAndSourceType(param, SourceTypes.SourceTypeScriptedActionlist));

                        break;
                }
            }

            return timedActionListOrEntries;
        }
        public ActionResult GetByAlias(string displayAlias, SourceTypes sourceType = SourceTypes.ContentItem, ResultTarget resultTarget = ResultTarget.Contents, string mfilter = "", int page = 1, int pageSize = 10, bool tinyResponse = true, bool minified = false, bool realformat = false, int deeplevel = 10, string complexBehaviour = "")
        {
            //   Logger.Error("inizio"+DateTime.Now.ToString());
            IContent item = null;

            if (displayAlias == null)
            {
                return(Json(_utilsServices.GetResponse(ResponseType.MissingParameters), JsonRequestBehavior.AllowGet));
            }

            try {
                if (displayAlias.ToLower() == "user+info" || displayAlias.ToLower() == "user info")
                {
                    #region richiesta dati di uno user
                    var currentUser = _authenticationService.GetAuthenticatedUser();
                    if (currentUser == null)
                    {
                        //  return Content((Json(_utilsServices.GetResponse(ResponseType.InvalidUser))).ToString(), "application/json");// { Message = "Error: No current User", Success = false,ErrorCode=ErrorCode.InvalidUser,ResolutionAction=ResolutionAction.Login });
                        var result = new ContentResult {
                            ContentType = "application/json"
                        };
                        result.Content = Newtonsoft.Json.JsonConvert.SerializeObject(_utilsServices.GetResponse(ResponseType.InvalidUser));
                        return(result);
                    }
                    else
                    if (!_csrfTokenHelper.DoesCsrfTokenMatchAuthToken())
                    {
                        var result = new ContentResult {
                            ContentType = "application/json"
                        };
                        result.Content = Newtonsoft.Json.JsonConvert.SerializeObject(_utilsServices.GetResponse(ResponseType.InvalidXSRF));
                        return(result);
                        //   Content((Json(_utilsServices.GetResponse(ResponseType.InvalidXSRF))).ToString(), "application/json");// { Message = "Error: No current User", Success = false,ErrorCode=ErrorCode.InvalidUser,ResolutionAction=ResolutionAction.Login });
                    }
                    else
                    {
                        #region utente validato
                        item = currentUser.ContentItem;

                        #endregion
                    }
                    #endregion
                }
                else
                {
                    item = GetContentByAlias(displayAlias);
                }

                if (!_orchardServices.Authorizer.Authorize(Permissions.ViewContent, item))
                {
                    return(Json(UnauthorizedResponse(), JsonRequestBehavior.AllowGet));
                }

                if (item == null)
                {
                    return(new HttpStatusCodeResult(404));
                }

                ContentResult cr = (ContentResult)GetContent(item, sourceType, resultTarget, mfilter, page, pageSize, tinyResponse, minified, realformat, deeplevel, complexBehaviour.Split(','));
                //    Logger.Error("Fine:"+DateTime.Now.ToString());

                if (_orchardServices.WorkContext.CurrentSite.As <WebServiceSettingsPart>().LogWebservice)
                {
                    Logger.Error(cr.Content.ToString());
                }
                return(cr);
            } catch (System.Security.SecurityException) {
                return(Json(_utilsServices.GetResponse(ResponseType.InvalidUser), JsonRequestBehavior.AllowGet));
            } catch (OrchardSecurityException) {
                return(Json(UnauthorizedResponse(), JsonRequestBehavior.AllowGet));
            } catch {
                return(new HttpStatusCodeResult(500));
            }
        }
Exemplo n.º 52
0
 public void CopyFrom(IFontSource fontSource)
 {
     if (fontSource == null)
     {
         throw new ArgumentNullException("fontSource");
     }
     if (fontSource == this)
     {
         return;
     }
     Type = fontSource.Type;
     Location = fontSource.Location;
     Format = fontSource.Format;
 }