Пример #1
0
 /// <summary>
 /// Publishes an event to browse to an URI
 /// </summary>
 public void BrowseUri(object sender, DestinationEnum dest, params string[] args)
 {
     if (Browse != null)
     {
         Browse(sender, new BrowserEventArgs(dest, args));
     }
 }
Пример #2
0
        public async Task OnGetAsync()
        {
            string original = "0810";
            string modified = original.Insert(2, ":");


            var baseAddress = new Uri("https://api.jikan.moe/v3/");

            using (var httpClient = new HttpClient {
                BaseAddress = baseAddress
            })
            {
                using (var response = await httpClient.GetAsync("season/2020/winter"))
                {
                    string responseData = await response.Content.ReadAsStringAsync();

                    var animes = JsonSerializer.Deserialize <Result>(responseData, null);
                    try
                    {
                        var animesDto = _mapper.Map <List <AnimeDto> >(animes.Animes);
                    }
                    catch (Exception e)
                    {
                        throw;
                    }
                }

                // inheritance mapping

                List <Source> sources = new List <Source>()
                {
                    new Source()
                    {
                        Id = 1,
                    },
                    new SourceChild()
                    {
                        Id   = 2,
                        Name = "SourceChild",
                    }
                };

                List <Destination> destinations = _mapper.Map <List <Destination> >(sources);

                // generic mapping

                GenericSource <List <Source> > genericSource = new GenericSource <List <Source> >()
                {
                    Value = sources
                };

                GenericDestination <List <Destination> > genericDestination = _mapper.Map <GenericDestination <List <Destination> > >(genericSource);

                // enum mapping

                SourceEnum sourceEnum = SourceEnum.First;

                DestinationEnum destinationEnum = _mapper.Map <DestinationEnum>(sourceEnum);
            }
        }
Пример #3
0
 /// <summary>
 /// Publishes an event to browse to an URI
 /// </summary>
 public void BrowseUri(object sender, DestinationEnum dest, params string[] args)
 {
     if (Browse != null)
     {
         Browse(sender, new BrowserEventArgs(dest, args));
     }
 }
Пример #4
0
 public bool Equals(DestinationEnum obj)
 {
     if ((object)obj == null)
     {
         return(false);
     }
     return(StringComparer.OrdinalIgnoreCase.Equals(this.Value, obj.Value));
 }
Пример #5
0
        public override void SendMessage(NetworkMessage message, DestinationEnum destination)
        {
            CustomDataWriter writer = new CustomDataWriter();

            message.Pack(writer);
            DestinationClient.Send(writer.Data);
            Logg.Log("Sent to server :" + message.MessageId.ToString());
        }
Пример #6
0
        public void EnumExtensions_ConvertTo_SourceConvertedToDestination()
        {
            SourceEnum source = SourceEnum.Value1;

            DestinationEnum destination = source.ConvertTo <DestinationEnum>();

            destination.ShouldBe(DestinationEnum.Value1);
        }
Пример #7
0
        public void EnumExtensions_ConvertTo_SourceNotEnum_ErrorThrown()
        {
            String source = "Source";

            Should.Throw <ArgumentException>(() =>
            {
                DestinationEnum destination = source.ConvertTo <DestinationEnum>();
            });
        }
 public void LoadOrCreateCustodianArtifact(IServicesMgr svcMgr,
                                           ExecutionIdentity identity,
                                           Int32 workspaceArtifactId,
                                           DestinationEnum destination)
 {
     LoadByName(svcMgr, identity, workspaceArtifactId);
     if (ArtifactId == 0)
     {
         Create(svcMgr, identity, workspaceArtifactId, destination);
     }
 }
Пример #9
0
        public static IEnumerable <FolderModel> GetSourcePaths(string FolderPath,
                                                               int?CustodianLevel,
                                                               DestinationEnum destination,
                                                               bool withDescription = false)
        {
            //Get all unique sub directories within the selected source path
            var folders = new List <String>();

            folders.AddRange(Directory.GetDirectories(FolderPath.Trim(), "*", SearchOption.AllDirectories).ToList());
            var folderList = new List <FolderModel>();

            foreach (var folderPath in folders)
            {
                //Initially, set custodian folder path to the selected source path
                var custodianFolderPath = FolderPath;

                if (CustodianLevel.HasValue)
                {
                    String   custodianFolderName;
                    String[] foldersInPath;
                    if (CustodianLevel.Value == 0)
                    {
                        //Split the source path on backslashes
                        foldersInPath = FolderPath.Split('\\');
                        //Custodian folder is the last folder in the source path
                        custodianFolderName = foldersInPath.Last();
                        folderList.Add(CreateModel(custodianFolderPath, custodianFolderName, withDescription, destination));
                    }
                    else
                    {
                        //Remove selected source path from the full folder path
                        char[] charToTrim = { '\\' };
                        var    folderPathWithoutSourcePath = folderPath.Substring(FolderPath.Length, folderPath.Length - FolderPath.Length).Trim(charToTrim);
                        //Get subdirectories under source path
                        foldersInPath = folderPathWithoutSourcePath.Split('\\');
                        //If there are at least X number of folders, select the last folder as the custodian folder
                        if (foldersInPath.Count() >= CustodianLevel.Value)
                        {
                            //Custodian folder is the directory X number of folders down from the source path
                            custodianFolderName = foldersInPath[CustodianLevel.Value - 1];
                            //Rebuild folder path up to the custodian folder
                            var folderCounter = 0;
                            while (folderCounter < CustodianLevel.Value)
                            {
                                custodianFolderPath += "\\" + foldersInPath[folderCounter];
                                folderCounter       += 1;
                            }
                            folderList.Add(CreateModel(custodianFolderPath, custodianFolderName, withDescription, destination));
                        }
                    }
                }
            }
            return(folderList.GroupBy(x => x.FullPath).Select(y => y.First()));
        }
Пример #10
0
 public BrowserEventArgs(DestinationEnum dest, string[] args)
 {
     switch (dest)
     {
         case DestinationEnum.TwStatsPlayer:
         case DestinationEnum.TwStatsTribe:
         case DestinationEnum.TwStatsVillage:
             _gameDestination = false;
             break;
         default:
             _gameDestination = true;
             break;
     }
     _destination = dest;
     _args = new List<string>(args).AsReadOnly();
 }
Пример #11
0
        public static Int32 Create(IServicesMgr svcMgr,
                                   ExecutionIdentity identity,
                                   Int32 workspaceArtifactId,
                                   String fullName,
                                   String firstName,
                                   String lastName,
                                   DestinationEnum destination)
        {
            using (var client = svcMgr.CreateProxy <IRSAPIClient>(identity))
            {
                client.APIOptions.WorkspaceID = workspaceArtifactId;
                var r = new RDO
                {
                    ArtifactTypeGuids = new List <Guid> {
                        Helpers.Constants.Guids.ObjectType.Custodian
                    }
                };
                r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.Name, fullName));
                if (destination == DestinationEnum.Custodian)
                {
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.FirstName, firstName));
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.LastName, lastName));
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.CustodianType,
                                                Helpers.Constants.Guids.Choices.ProcessingSet.CustodianTypePerson));
                }
                else
                {
                    r.Fields.Add(new FieldValue(Helpers.Constants.Guids.Fields.Custodian.CustodianType,
                                                Helpers.Constants.Guids.Choices.ProcessingSet.CustodianTypeEntity));
                }

                var results = client.Repositories.RDO.Create(r);

                var res = new Response <Int32>
                {
                    Results = results.Results.Any() ? results.Results.FirstOrDefault().Artifact.ArtifactID : 0,
                    Success = results.Success,
                    Message = MessageFormatter.FormatMessage(results.Results.Select(x => x.Message).ToList(), results.Message, results.Success)
                };

                if (res.Success)
                {
                    return(res.Results);
                }
                throw new Exception(res.Message.ToString());
            }
        }
Пример #12
0
        public BrowserEventArgs(DestinationEnum dest, string[] args)
        {
            switch (dest)
            {
            case DestinationEnum.TwStatsPlayer:
            case DestinationEnum.TwStatsTribe:
            case DestinationEnum.TwStatsVillage:
                _gameDestination = false;
                break;

            default:
                _gameDestination = true;
                break;
            }
            _destination = dest;
            _args        = new List <string>(args).AsReadOnly();
        }
Пример #13
0
        public override void SendMessage(NetworkMessage message, DestinationEnum destination)
        {
            CustomDataWriter writer = new CustomDataWriter();

            message.Pack(writer);
            switch (destination)
            {
            case DestinationEnum.CLIENT:
                SourceClient.Send(writer.Data);
                break;

            case DestinationEnum.SERVER:
                DestinationClient.Send(writer.Data);
                break;
            }
            Host.logger.Log("Sent " + message.ToString().Split('.').Reverse().First() + " to " + destination.ToString(), LogLevelEnum.Succes);
        }
Пример #14
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.fieldpad            = binaryReader.ReadBytes(64);
     this.DestinationType     = ((DestinationTypeEnum)(binaryReader.ReadInt16()));
     this.Destination         = ((DestinationEnum)(binaryReader.ReadInt16()));
     this.Source              = ((SourceEnum)(binaryReader.ReadInt16()));
     this.fieldpad0           = binaryReader.ReadBytes(2);
     this.InBounds            = binaryReader.ReadRange();
     this.OutBounds           = binaryReader.ReadRange();
     this.fieldpad1           = binaryReader.ReadBytes(64);
     this.TintColorLowerBound = binaryReader.ReadColorR8G8B8();
     this.TintColorUpperBound = binaryReader.ReadColorR8G8B8();
     this.PeriodicFunction    = ((PeriodicFunctionEnum)(binaryReader.ReadInt16()));
     this.fieldpad2           = binaryReader.ReadBytes(2);
     this.FunctionPeriod      = binaryReader.ReadSingle();
     this.FunctionPhase       = binaryReader.ReadSingle();
     this.fieldpad3           = binaryReader.ReadBytes(32);
     return(pointerQueue);
 }
Пример #15
0
        public void AddToProcessingSet(IServicesMgr svcMgr,
                                       ExecutionIdentity identity,
                                       Int32 workspaceArtifactId,
                                       kCura.Relativity.Client.DTOs.Artifact processingSet,
                                       int processingProfileArtifactId,
                                       Int32 order,
                                       DestinationEnum destination)
        {
            var processingProfile = new ProcessingProfileModel(processingProfileArtifactId);

            processingProfile.Initialize(svcMgr, identity, workspaceArtifactId);

            var custodian = new CustodianModel(CustodianNames);

            custodian.LoadOrCreateCustodianArtifact(svcMgr, identity, workspaceArtifactId, destination);

            var processingDataSource = new ProcessingDataSourceModel(FullPath, custodian.ArtifactId, order, processingProfile, processingSet);

            processingDataSource.Create(svcMgr, identity, workspaceArtifactId, processingProfile.DocumentNumberPrefix);
            processingDataSource.Update(svcMgr, identity, workspaceArtifactId);
        }
Пример #16
0
        private static FolderModel CreateModel(string custodianFolderPath,
                                               string custodianFolderName,
                                               bool withDescription,
                                               DestinationEnum destination)
        {
            string description = string.Empty;

            if (withDescription)
            {
                int files = Directory.GetFiles(custodianFolderPath).Length;
                int dirs  = Directory.GetDirectories(custodianFolderPath).Length;
                description = string.Format("{0} file{2}, {1} sub-folder{3}",
                                            files,
                                            dirs,
                                            files == 0 || files > 1 ? "s" : string.Empty,
                                            dirs == 0 || dirs > 1 ? "s" : string.Empty);
            }
            return(new FolderModel(custodianFolderPath, custodianFolderName, destination)
            {
                Description = description
            });
        }
Пример #17
0
 public static Names Separate(string input, DestinationEnum destination)
 {
     if (destination == DestinationEnum.Custodian)
     {
         /* If the input has a comma, it is already splitted in the rigth order*/
         if (input.Contains(","))
         {
             string[] parts = input.Split(new[] { ',' }, 2);
             return(new Names
             {
                 FirstName = parts[1].Trim(),
                 LastName = parts[0].Trim(),
             });
         }
         string[] splitFullName = input.Split(new[] { '_', ' ', ':' }, 2);
         if (splitFullName.Count() == 2)
         {
             return(new Names {
                 FirstName = splitFullName[0].Trim(),
                 LastName = splitFullName[1].Trim(),
             });
         }
         else
         {
             return(new Names {
                 FirstName = input
             });
         }
     }
     else
     {
         return(new Names
         {
             FirstName = input
         });
     }
 }
Пример #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MessageSession" /> class.
 /// </summary>
 /// <param name="id">Session ID. (required).</param>
 /// <param name="startTime">Session creation time. (required).</param>
 /// <param name="text">Session text. If a template was used for the session text (see [Messages: Send](http://docs.textmagictesting.com/#tag/Outbound-Messages) for details), it may contain template tags.  (required).</param>
 /// <param name="source">*   **O** for TextMagic Online *   **A** for API *   **M** for TextMagic Messenger *   **E** for [Email to SMS](http://docs.textmagictesting.com/#tag/Send-Email-to-SMS) *   **X** for [Distribution lists](http://docs.textmagictesting.com/#tag/Distribution-Lists)  (required).</param>
 /// <param name="referenceId">Custom reference ID (see [Messages: Send](http://docs.textmagictesting.com/#tag/Send-Email-to-SMS) for details).  (required).</param>
 /// <param name="price">Session cost (in account currency). (required).</param>
 /// <param name="numbersCount">Session recipient count. (required).</param>
 /// <param name="destination">Destination type of a Message Session: * **t** - text SMS * **s** - text to speech * **v** - voice broadcast  (required).</param>
 public MessageSession(int?id = default(int?), string startTime = default(string), string text = default(string), string source = default(string), string referenceId = default(string), decimal?price = default(decimal?), int?numbersCount = default(int?), DestinationEnum destination = default(DestinationEnum))
 {
     // to ensure "id" is required (not null)
     if (id == null)
     {
         throw new InvalidDataException("id is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.Id = id;
     }
     // to ensure "startTime" is required (not null)
     if (startTime == null)
     {
         throw new InvalidDataException("startTime is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.StartTime = startTime;
     }
     // to ensure "text" is required (not null)
     if (text == null)
     {
         throw new InvalidDataException("text is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.Text = text;
     }
     // to ensure "source" is required (not null)
     if (source == null)
     {
         throw new InvalidDataException("source is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.Source = source;
     }
     // to ensure "referenceId" is required (not null)
     if (referenceId == null)
     {
         throw new InvalidDataException("referenceId is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.ReferenceId = referenceId;
     }
     // to ensure "price" is required (not null)
     if (price == null)
     {
         throw new InvalidDataException("price is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.Price = price;
     }
     // to ensure "numbersCount" is required (not null)
     if (numbersCount == null)
     {
         throw new InvalidDataException("numbersCount is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.NumbersCount = numbersCount;
     }
     // to ensure "destination" is required (not null)
     if (destination == null)
     {
         throw new InvalidDataException("destination is a required property for MessageSession and cannot be null");
     }
     else
     {
         this.Destination = destination;
     }
 }
Пример #19
0
 public FolderModel(String folderPath, String folderName, DestinationEnum destination)
 {
     FullPath       = folderPath;
     FolderName     = folderName;
     CustodianNames = NameSeparator.Separate(FolderName, destination);
 }
Пример #20
0
 public MessageReceivedEventArgs(NetworkMessage message, DestinationEnum source)
 {
     Message = message;
     Source  = source;
 }
Пример #21
0
 public void SendMessage(NetworkMessage message, DestinationEnum destination)
 {
     connectionManager.SendMessage(message, destination);
 }
 private void Create(IServicesMgr svcMgr, ExecutionIdentity identity, Int32 workspaceArtifactId, DestinationEnum destination)
 {
     ArtifactId = Rsapi.Custodian.Create(svcMgr, identity, workspaceArtifactId, FullName, FirstName, LastName, destination);
 }
Пример #23
0
        public ActionResult CustodianSummaryAtLevel(string path, int level, DestinationEnum destination)
        {
            var paths = Helpers.FolderHelper.GetSourcePaths(path, level, destination, true);

            return(Json(paths));
        }
Пример #24
0
 public abstract void SendMessage(NetworkMessage message, DestinationEnum destination);