Exemplo n.º 1
0
        public Guid Send(FiksRequest fiksRequest, Guid receiverId)
        {
            var ttl            = new TimeSpan(0, TTLMinutes, 0);
            var messageRequest = new MeldingRequest(_senderId, receiverId, fiksRequest.TestCase.MessageType, ttl);

            var payloads = new List <IPayload>();

            if (fiksRequest.CustomPayloadFile != null)
            {
                PayloadHelper.CreateCustomPayload(fiksRequest, payloads);
            }
            else
            {
                PayloadHelper.CreateStandardPayload(fiksRequest, payloads);
            }

            var attachmentFileNames = fiksRequest.TestCase.PayloadAttachmentFileNames;

            if (!string.IsNullOrEmpty(attachmentFileNames))
            {
                foreach (var payloadFileName in attachmentFileNames.Split(";"))
                {
                    var testCaseDirectory = Path.Combine(TestSeeder.TestsDirectory, fiksRequest.TestCase.Protocol, fiksRequest.TestCase.Operation + fiksRequest.TestCase.Situation);
                    var fileStream        = File.OpenRead(Path.Combine(testCaseDirectory, "Attachments", payloadFileName));
                    payloads.Add(new StreamPayload(fileStream, payloadFileName));
                }
            }

            fiksRequest.SentAt = DateTime.Now;
            var result = _client.Send(messageRequest, payloads).Result;

            return(result.MeldingId);
        }
        // Token: 0x06000038 RID: 56 RVA: 0x00002D10 File Offset: 0x00000F10
        protected RetrievedPayload RetrieveJobDistributionPayload(OrganizationId organizationId, Guid jobRunId, int taskId)
        {
            RetrievedPayload      retrievedPayload      = new RetrievedPayload();
            ComplianceJobProvider complianceJobProvider = new ComplianceJobProvider(organizationId);
            Guid tenantGuid = organizationId.GetTenantGuid();

            retrievedPayload.IsComplete = this.HasMoreTasks(organizationId, jobRunId);
            IEnumerable <CompositeTask> enumerable = from x in complianceJobProvider.FindCompositeTasks(tenantGuid, jobRunId, null, null)
                                                     where x.TaskId > taskId
                                                     select x;

            if (enumerable != null)
            {
                foreach (CompositeTask compositeTask in enumerable)
                {
                    JobPayload jobPayload = new JobPayload();
                    jobPayload.Target = new Target
                    {
                        TargetType = Target.Type.MailboxSmtpAddress,
                        Identifier = compositeTask.UserMaster
                    };
                    PayloadReference payloadReference = PayloadHelper.GetPayloadReference(jobRunId, compositeTask.TaskId);
                    jobPayload.Children.Add(ComplianceSerializer.Serialize <PayloadReference>(PayloadReference.Description, payloadReference));
                    retrievedPayload.Children.Add(jobPayload);
                    retrievedPayload.Bookmark = compositeTask.TaskId.ToString();
                }
                return(retrievedPayload);
            }
            throw new ArgumentException(string.Format("Not Task Data Found. TenantId-{0} JobId-{1} and TaskId-{2}", tenantGuid, jobRunId, taskId));
        }
Exemplo n.º 3
0
 private void ButSupplementalSaveDefaults_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(textSupplementalBackupCopyNetworkPath.Text) && !Directory.Exists(textSupplementalBackupCopyNetworkPath.Text))
     {
         MsgBox.Show(this, "Invalid or inaccessible " + labelSupplementalBackupCopyNetworkPath.Text + ".");           //This label text will rarely change.
         return;
     }
     if (Prefs.UpdateBool(PrefName.SupplementalBackupEnabled, checkSupplementalBackupEnabled.Checked))
     {
         try {
             //Inform HQ when the supplemental backups are enabled/disabled and which security admin performed the change.
             PayloadItem pliStatus = new PayloadItem(
                 (int)(checkSupplementalBackupEnabled.Checked?SupplementalBackupStatuses.Enabled:SupplementalBackupStatuses.Disabled),
                 "SupplementalBackupStatus");
             PayloadItem pliAdminUserName = new PayloadItem(Security.CurUser.UserName, "AdminUserName");
             string      officeData       = PayloadHelper.CreatePayload(new List <PayloadItem>()
             {
                 pliStatus, pliAdminUserName
             }, eServiceCode.SupplementalBackup);
             WebServiceMainHQProxy.GetWebServiceMainHQInstance().SetSupplementalBackupStatus(officeData);
         }
         catch (Exception ex) {
             ex.DoNothing();                    //Internet probably is unavailble right now.
         }
         SecurityLogs.MakeLogEntry(Permissions.SupplementalBackup, 0,
                                   "Supplemental backup has been " + (checkSupplementalBackupEnabled.Checked?"Enabled":"Disabled") + ".");
     }
     if (Prefs.UpdateString(PrefName.SupplementalBackupNetworkPath, textSupplementalBackupCopyNetworkPath.Text))
     {
         SecurityLogs.MakeLogEntry(Permissions.SupplementalBackup, 0,
                                   labelSupplementalBackupCopyNetworkPath.Text + " changed to '" + textSupplementalBackupCopyNetworkPath.Text + "'.");
     }
     MsgBox.Show(this, "Saved");
 }
Exemplo n.º 4
0
 /// <summary></summary>
 /// <param name="regKey"></param>
 /// <param name="webSheetDefId"></param>
 /// <param name="sheetDef"></param>
 public static bool UpdateSheetDef(long webSheetDefId, SheetDef sheetDef, string regKey = null, bool doCatchExceptions = true)
 {
     if (string.IsNullOrEmpty(regKey))
     {
         regKey = PrefC.GetString(PrefName.RegistrationKey);
     }
     try {
         List <PayloadItem> listPayloadItems = new List <PayloadItem> {
             new PayloadItem(regKey, "RegKey"),
             new PayloadItem(webSheetDefId, "WebSheetDefID"),
             new PayloadItem(sheetDef, "SheetDef")
         };
         string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, listPayloadItems.ToArray());
         SheetsSynchProxy.GetWebServiceInstance().UpdateSheetDef(payload);
     }
     catch (Exception ex) {
         if (!doCatchExceptions)
         {
             throw;
         }
         ex.DoNothing();
         return(false);
     }
     return(true);
 }
Exemplo n.º 5
0
        static void BuildAndVerify(bool isStatic, string className, string methodName, object[] parameters)
        {
            var encoding = Encoding.UTF8;

            // Restored bytes in Scala side
            Func <string, byte[]> RestoreHexToBytes = (hexString) =>
            {
                var hexArray = hexString.Split('-');
                var bytes    = new byte[hexArray.Length];
                var k        = 0;
                foreach (var hex in hexArray)
                {
                    bytes[k++] = Convert.ToByte(hex, 16);
                }

                return(bytes);
            };

            var originalBytes = PayloadHelper.BuildPayload(isStatic, className, methodName, parameters);
            var text          = BitConverter.ToString(originalBytes);

            Console.Out.WriteLine("{0} bytes (length = {1}) for {2} : length = {3} , string = {4}", encoding.BodyName, originalBytes.Length, className, text.Length, text);
            var restoredBytes = RestoreHexToBytes(text);

            VerifyBytes(restoredBytes, isStatic, className, methodName, parameters);
        }
Exemplo n.º 6
0
        public void PayloadHelper_BuildArrayPayload_NullParam()
        {
            Action act = () => PayloadHelper.BuildArrayPayload(null);

            act.Should().Throw <ArgumentNullException>()
            .And.ParamName.Should().Be("entities");
        }
Exemplo n.º 7
0
        /// <summary>
        /// Adds the message received handler to handle incoming messages.
        /// </summary>
        private void AddMessageReceivedHandler()
        {
            this.Client.UseApplicationMessageReceivedHandler(
                e =>
            {
                var topic = e.ApplicationMessage.Topic;

                if (topic.Contains(SparkplugMessageType.DeviceCommand.GetDescription()))
                {
                    switch (this.NameSpace)
                    {
                    case SparkplugNamespace.VersionA:
                        var payloadVersionA = PayloadHelper.Deserialize <VersionAPayload>(e.ApplicationMessage.Payload);

                        if (payloadVersionA != null)
                        {
                            this.VersionAPayloadReceived?.Invoke(payloadVersionA);
                        }

                        break;

                    case SparkplugNamespace.VersionB:
                        var payloadVersionB = PayloadHelper.Deserialize <VersionBPayload>(e.ApplicationMessage.Payload);

                        if (payloadVersionB != null)
                        {
                            this.VersionBPayloadReceived?.Invoke(payloadVersionB);
                        }

                        break;
                    }
                }
            });
        }
Exemplo n.º 8
0
        public void Test()
        {
            String test = "The quick red fox jumped over the lazy brown dogs";

            NumericPayloadTokenFilter nptf = new NumericPayloadTokenFilter(new WordTokenFilter(new WhitespaceTokenizer(new StringReader(test))), 3, "D");
            bool              seenDogs     = false;
            ITermAttribute    termAtt      = nptf.GetAttribute <ITermAttribute>();
            ITypeAttribute    typeAtt      = nptf.GetAttribute <ITypeAttribute>();
            IPayloadAttribute payloadAtt   = nptf.GetAttribute <IPayloadAttribute>();

            while (nptf.IncrementToken())
            {
                if (termAtt.Term.Equals("dogs"))
                {
                    seenDogs = true;
                    Assert.True(typeAtt.Type.Equals("D") == true, typeAtt.Type + " is not equal to " + "D");
                    Assert.True(payloadAtt.Payload != null, "payloadAtt.GetPayload() is null and it shouldn't be");
                    byte[] bytes = payloadAtt.Payload.GetData();//safe here to just use the bytes, otherwise we should use offset, length
                    Assert.True(bytes.Length == payloadAtt.Payload.Length, bytes.Length + " does not equal: " + payloadAtt.Payload.Length);
                    Assert.True(payloadAtt.Payload.Offset == 0, payloadAtt.Payload.Offset + " does not equal: " + 0);
                    float pay = PayloadHelper.DecodeFloat(bytes);
                    Assert.True(pay == 3, pay + " does not equal: " + 3);
                }
                else
                {
                    Assert.True(typeAtt.Type.Equals("word"), typeAtt.Type + " is not null and it should be");
                }
            }
            Assert.True(seenDogs == true, seenDogs + " does not equal: " + true);
        }
Exemplo n.º 9
0
 public override void SetUp()
 {
     base.SetUp();
     PayloadHelper helper = new PayloadHelper();
     Searcher_Renamed = helper.SetUp(Random(), Similarity, 1000);
     IndexReader = Searcher_Renamed.IndexReader;
 }
Exemplo n.º 10
0
 protected void Register <TIn, TOut>(string path, DataDelegate <TIn, TOut> callback) where TIn : new()
 {
     if (!path.StartsWith(Name, StringComparison.InvariantCultureIgnoreCase))
     {
         var absolutePath = PayloadHelper.PathJoin(Name, path);
         _server.Register(absolutePath, callback);
     }
 }
Exemplo n.º 11
0
        public override void SetUp()
        {
            base.SetUp();
            PayloadHelper helper = new PayloadHelper();

            searcher    = helper.SetUp(Random, similarity, 1000);
            indexReader = searcher.IndexReader;
        }
Exemplo n.º 12
0
        public override void SetUp()
        {
            base.SetUp();
            PayloadHelper helper = new PayloadHelper();

            Searcher_Renamed = helper.SetUp(Random(), Similarity, 1000);
            IndexReader      = Searcher_Renamed.IndexReader;
        }
        /// <summary>
        /// Returns a 32 bit float from the payload, or 1f it null.
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public override float GetWeight(Token token)
        {
            if (token.Payload == null || token.Payload.GetData() == null)
            {
                return(1f);
            }

            return(PayloadHelper.DecodeFloat(token.Payload.GetData()));
        }
Exemplo n.º 14
0
            public static GetChangesParameter FromPayload(JObject payload, SyncEngine syncEngine)
            {
                string synchronizationId = payload[nameof(SynchronizationId)].Value <string>();
                Dictionary <string, object> customInfo = payload[nameof(CustomInfo)].ToObject <Dictionary <string, object> >();
                PayloadAction       payloadAction      = (PayloadAction)Enum.Parse(typeof(PayloadAction), payload[nameof(PayloadAction)].Value <string>());
                GetChangesParameter parameter          = new GetChangesParameter(payloadAction, synchronizationId, customInfo);

                parameter.LastSync   = payload[nameof(LastSync)].Value <long>();
                parameter.AppliedIds = PayloadHelper.GetAppliedIdsFromPayload(payload[nameof(PayloadAppliedIds)].ToObject <Dictionary <string, List <object> > >(), syncEngine, synchronizationId, customInfo);
                return(parameter);
            }
Exemplo n.º 15
0
        ///<summary>This method can throw an exception. Tries to upload a sheet def to HQ.</summary>
        ///<param name="sheetDef">The SheetDef object to be uploaded.</param>
        public static void TryUploadSheetDef(SheetDef sheetDef)
        {
            string             regKey           = PrefC.GetString(PrefName.RegistrationKey);
            List <PayloadItem> listPayloadItems = new List <PayloadItem> {
                new PayloadItem(regKey, "RegKey"),
                new PayloadItem(sheetDef, "SheetDef")
            };
            string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, listPayloadItems.ToArray());
            string result  = SheetsSynchProxy.GetWebServiceInstance().UpLoadSheetDef(payload);

            PayloadHelper.CheckForError(result);
        }
Exemplo n.º 16
0
        public static string populateResponse(string text)
        {
            var teamsMessage = PayloadHelper.CreateSkypePayload(text);

            // Populate the response
            WebhookResponse response = new WebhookResponse();

            response.FulfillmentMessages.Add(teamsMessage);
            string responseJson = response.ToString();

            return(responseJson);
        }
Exemplo n.º 17
0
 private string ReadResponse(byte[] payloadBytes)
 {
     try
     {
         var decryptedBytes = PayloadHelper.DecodePayloadBytes(payloadBytes, RemoteEndPoint.Secret);
         return(Encoding.UTF8.GetString(decryptedBytes, 0, decryptedBytes.Length));
     }
     catch (Exception ex)
     {
         Console.Write($"Cannot read response \n{ex}");
         return("");
     }
 }
Exemplo n.º 18
0
 private CommandBase TryGetCommand(byte[] payloadBytes)
 {
     try
     {
         var decryptedBytes = PayloadHelper.DecodePayloadBytes(payloadBytes, _listenerConfig.Secret);
         return(CommandEncoder.Decode(decryptedBytes));
     }
     catch (Exception ex)
     {
         _logger.LogWarning(ex, "Cannot read payload");
         return(null);
     }
 }
Exemplo n.º 19
0
        /// <summary>
        /// Adds the message received handler to handle incoming messages.
        /// </summary>
        /// <exception cref="InvalidCastException">The metric cast is invalid.</exception>
        /// <exception cref="ArgumentOutOfRangeException">The namespace is out of range.</exception>
        private void AddMessageReceivedHandler()
        {
            this.Client.UseApplicationMessageReceivedHandler(
                e =>
            {
                var topic = e.ApplicationMessage.Topic;

                switch (this.NameSpace)
                {
                case SparkplugNamespace.VersionA:
                    if (topic.Contains(SparkplugMessageType.DeviceCommand.GetDescription()))
                    {
                        var payloadVersionA = PayloadHelper.Deserialize <VersionAPayload>(e.ApplicationMessage.Payload);

                        if (payloadVersionA != null)
                        {
                            if (!(payloadVersionA is T convertedPayloadVersionA))
                            {
                                throw new InvalidCastException("The metric cast didn't work properly.");
                            }

                            this.DeviceCommandReceived?.Invoke(convertedPayloadVersionA);
                        }
                    }

                    break;

                case SparkplugNamespace.VersionB:

                    if (topic.Contains(SparkplugMessageType.DeviceCommand.GetDescription()))
                    {
                        var payloadVersionB = PayloadHelper.Deserialize <VersionBPayload>(e.ApplicationMessage.Payload);

                        if (payloadVersionB != null)
                        {
                            if (!(payloadVersionB is T convertedPayloadVersionB))
                            {
                                throw new InvalidCastException("The metric cast didn't work properly.");
                            }

                            this.DeviceCommandReceived?.Invoke(convertedPayloadVersionB);
                        }
                    }

                    break;

                default:
                    throw new ArgumentOutOfRangeException(nameof(this.NameSpace));
                }
            });
        }
        // Token: 0x06000037 RID: 55 RVA: 0x00002BD0 File Offset: 0x00000DD0
        public override ComplianceMessage Process(ComplianceMessage input)
        {
            ComplianceMessage complianceMessage = new ComplianceMessage
            {
                CorrelationId = input.CorrelationId,
                TenantId      = input.TenantId,
                MessageId     = default(Guid).ToString()
            };
            FaultDefinition  faultDefinition = null;
            RetrievedPayload payload         = new RetrievedPayload();
            PayloadReference payloadReference;

            if (!ComplianceSerializer.TryDeserialize <PayloadReference>(PayloadReference.Description, input.Payload, out payloadReference, out faultDefinition, "Process", "f:\\15.00.1497\\sources\\dev\\EDiscovery\\src\\TaskDistributionSystem\\TaskDistributionFabric\\Blocks\\RetrievePayloadBlock.cs", 43))
            {
                throw new BadStructureFormatException(string.Format("Problem in deserializing the payload reference:{0}", input.ComplianceMessageType));
            }
            OrganizationId organizationId;

            if (!OrganizationId.TryCreateFromBytes(input.TenantId, Encoding.UTF8, out organizationId))
            {
                throw new ArgumentException(string.Format("Problem in creating Organization Id from the tenant id:{0}", input.ComplianceMessageType));
            }
            Guid         jobRunId;
            int          taskId;
            PayloadLevel payloadLevel;

            if (PayloadHelper.TryReadFromPayloadReference(payloadReference, out jobRunId, out taskId, out payloadLevel))
            {
                switch (payloadLevel)
                {
                case PayloadLevel.Job:
                {
                    int taskId2;
                    if (!int.TryParse(payloadReference.Bookmark, out taskId2))
                    {
                        taskId2 = -1;
                    }
                    payload = this.RetrieveJobDistributionPayload(organizationId, jobRunId, taskId2);
                    break;
                }

                case PayloadLevel.Task:
                    payload = this.RetrieveTaskDistributionPayload(organizationId, jobRunId, taskId);
                    break;
                }
            }
            complianceMessage.Payload = payload;
            return(complianceMessage);
        }
Exemplo n.º 21
0
        /// <summary>Takes a provided webSheetDefId and sheetDef and packages them. The package is then broken into chunks of equal or lesser size
        /// than the provided chunkSize. Size is measured in bytes.</summary>
        public static bool UpdateSheetDefChunked(long webSheetDefId, SheetDef sheetDef, int chunkSize)
        {
            string             regKey           = PrefC.GetString(PrefName.RegistrationKey);
            List <PayloadItem> listPayloadItems = new List <PayloadItem> {
                new PayloadItem(regKey, "RegKey"),
                new PayloadItem(webSheetDefId, "WebSheetDefID"),
                new PayloadItem(sheetDef, "SheetDef")
            };
            string payload         = PayloadHelper.CreatePayloadWebHostSynch(regKey, listPayloadItems.ToArray());
            string fileNamePayload = UploadSheetChunks(payload, chunkSize);
            string result          = SheetsSynchProxy.GetWebServiceInstance().UpdateSheetDefFromFile(fileNamePayload);

            PayloadHelper.CheckForError(result);
            return(true);
        }
Exemplo n.º 22
0
 /// <summary></summary>
 /// <param name="regKey"></param>
 /// <returns></returns>
 public static string GetSheetDefAddress(string regKey = null)
 {
     if (string.IsNullOrEmpty(regKey))
     {
         regKey = PrefC.GetString(PrefName.RegistrationKey);
     }
     try {
         string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, new PayloadItem(regKey, "RegKey"));
         return(WebSerializer.DeserializeTag <string>(SheetsSynchProxy.GetWebServiceInstance().GetSheetDefAddress(payload), "Success"));
     }
     catch (Exception ex) {
         ex.DoNothing();
     }
     return("");
 }
Exemplo n.º 23
0
        protected override ComplianceMessage CreateStartJobMessage()
        {
            ComplianceMessage complianceMessage = base.CreateStartJobMessage();

            complianceMessage.WorkDefinitionType = WorkDefinitionType.EDiscovery;
            JobPayload jobPayload = new JobPayload();

            jobPayload.JobId     = this.DataObject.JobRunId.ToString();
            jobPayload.Target    = complianceMessage.MessageTarget;
            jobPayload.PayloadId = string.Empty;
            jobPayload.Children.Add(PayloadHelper.GetPayloadReference(this.DataObject.JobRunId, -1));
            jobPayload.Payload        = this.DataObject.GetExchangeWorkDefinition();
            complianceMessage.Payload = ComplianceSerializer.Serialize <JobPayload>(JobPayload.Description, jobPayload);
            return(complianceMessage);
        }
Exemplo n.º 24
0
            public byte[] GetCompressed()
            {
                JObject payload = new JObject();

                payload[nameof(PayloadAction)]     = PayloadAction.ToString();
                payload[nameof(SynchronizationId)] = SynchronizationId;
                payload[nameof(CustomInfo)]        = JObject.FromObject(CustomInfo);
                payload[nameof(Inserts)]           = JArray.FromObject(Inserts);
                payload[nameof(Updates)]           = JArray.FromObject(Updates);
                payload[nameof(Deletes)]           = JArray.FromObject(Deletes);
                payload[nameof(Conflicts)]         = JArray.FromObject(Conflicts);
                payload[nameof(PayloadAppliedIds)] = JObject.FromObject(PayloadHelper.GetAppliedIdsForPayload(AppliedIds));
                string json = JsonConvert.SerializeObject(payload);

                byte[] compressed = Compress(json);
                return(compressed);
            }
Exemplo n.º 25
0
 /// <summary></summary>
 /// <param name="regKey"></param>
 /// <returns></returns>
 public static bool TryGetPreference(out WebForms_Preference pref, string regKey = null)
 {
     pref = new WebForms_Preference();
     if (string.IsNullOrEmpty(regKey))
     {
         regKey = PrefC.GetString(PrefName.RegistrationKey);
     }
     try {
         string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, new PayloadItem(regKey, "RegKey"));
         pref = WebSerializer.DeserializeTag <WebForms_Preference>(SheetsSynchProxy.GetWebServiceInstance().GetPreferences(payload), "Success");
     }
     catch (Exception ex) {
         ex.DoNothing();
         return(false);
     }
     return(true);
 }
Exemplo n.º 26
0
        private static void AssertNext(TokenStream ts, String text, int positionIncrement, float boost, int startOffset,
                                       int endOffset)
        {
            var termAtt    = ts.AddAttribute <ITermAttribute>();
            var posIncrAtt = ts.AddAttribute <IPositionIncrementAttribute>();
            var payloadAtt = ts.AddAttribute <IPayloadAttribute>();
            var offsetAtt  = ts.AddAttribute <IOffsetAttribute>();

            Assert.IsTrue(ts.IncrementToken());
            Assert.AreEqual(text, termAtt.Term);
            Assert.AreEqual(positionIncrement, posIncrAtt.PositionIncrement);
            Assert.AreEqual(boost,
                            payloadAtt.Payload == null
                                ? 1f
                                : PayloadHelper.DecodeFloat(payloadAtt.Payload.GetData()), 0);
            Assert.AreEqual(startOffset, offsetAtt.StartOffset);
            Assert.AreEqual(endOffset, offsetAtt.EndOffset);
        }
Exemplo n.º 27
0
 /// <summary></summary>
 /// <param name="regKey"></param>
 /// <returns></returns>
 public static bool TryGetSheets(out List <WebForms_Sheet> listWebFormsSheets, string regKey = null)
 {
     listWebFormsSheets = new List <WebForms_Sheet>();
     if (string.IsNullOrEmpty(regKey))
     {
         regKey = PrefC.GetString(PrefName.RegistrationKey);
     }
     try {
         string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, new PayloadItem(regKey, "RegKey"));
         //Get all pending sheets for the office, will not limit to 20 anymore.
         listWebFormsSheets = WebSerializer.DeserializeTag <List <WebForms_Sheet> >(SheetsSynchProxy.GetWebServiceInstance().GetWebFormSheets(payload), "Success");
     }
     catch (Exception ex) {
         ex.DoNothing();
         return(false);
     }
     return(true);
 }
Exemplo n.º 28
0
        /// <summary>Takes a payload string and has it broken into chunks of equal or less size than the provided chunk size.</summary>
        /// <returns>xml payload containing the name of the file where chunk pieces were stored on the server.</returns>
        private static string UploadSheetChunks(string payload, int chunkSize)
        {
            List <string> listChunks = MiscUtils.CutStringIntoSimilarSizedChunks(payload, chunkSize);
            string        fileName   = "";

            foreach (string chunk in listChunks)
            {
                List <PayloadItem> listChunkPayloadItems = new List <PayloadItem> {
                    new PayloadItem(fileName, "FileName"),
                    new PayloadItem(chunk, "ChunkData")
                };
                string chunkPayload = PayloadHelper.CreatePayloadContent(listChunkPayloadItems);
                string result       = SheetsSynchProxy.GetWebServiceInstance().UploadSheetDefChunk(chunkPayload);
                PayloadHelper.CheckForError(result);
                fileName = WebSerializer.DeserializeTag <string>(result, "FileName");
            }
            return(PayloadHelper.CreatePayloadContent(fileName, "FileName"));
        }
Exemplo n.º 29
0
        public void TestFloatEncoding()
        {
            String test = "The quick|1.0 red|2.0 fox|3.5 jumped|0.5 over the lazy|5 brown|99.3 dogs|83.7";
            DelimitedPayloadTokenFilter filter = new DelimitedPayloadTokenFilter(new WhitespaceTokenizer(new StringReader(test)), '|', new FloatEncoder());
            ITermAttribute    termAtt          = filter.GetAttribute <ITermAttribute>();
            IPayloadAttribute payAtt           = filter.GetAttribute <IPayloadAttribute>();

            AssertTermEquals("The", filter, termAtt, payAtt, null);
            AssertTermEquals("quick", filter, termAtt, payAtt, PayloadHelper.EncodeFloat(1.0f));
            AssertTermEquals("red", filter, termAtt, payAtt, PayloadHelper.EncodeFloat(2.0f));
            AssertTermEquals("fox", filter, termAtt, payAtt, PayloadHelper.EncodeFloat(3.5f));
            AssertTermEquals("jumped", filter, termAtt, payAtt, PayloadHelper.EncodeFloat(0.5f));
            AssertTermEquals("over", filter, termAtt, payAtt, null);
            AssertTermEquals("the", filter, termAtt, payAtt, null);
            AssertTermEquals("lazy", filter, termAtt, payAtt, PayloadHelper.EncodeFloat(5.0f));
            AssertTermEquals("brown", filter, termAtt, payAtt, PayloadHelper.EncodeFloat(99.3f));
            AssertTermEquals("dogs", filter, termAtt, payAtt, PayloadHelper.EncodeFloat(83.7f));
            Assert.False(filter.IncrementToken());
        }
Exemplo n.º 30
0
        public void TestIntEncoding()
        {
            String test = "The quick|1 red|2 fox|3 jumped over the lazy|5 brown|99 dogs|83";
            DelimitedPayloadTokenFilter filter = new DelimitedPayloadTokenFilter(new WhitespaceTokenizer(new StringReader(test)), '|', new IntegerEncoder());
            ITermAttribute    termAtt          = filter.GetAttribute <ITermAttribute>();
            IPayloadAttribute payAtt           = filter.GetAttribute <IPayloadAttribute>();

            AssertTermEquals("The", filter, termAtt, payAtt, null);
            AssertTermEquals("quick", filter, termAtt, payAtt, PayloadHelper.EncodeInt(1));
            AssertTermEquals("red", filter, termAtt, payAtt, PayloadHelper.EncodeInt(2));
            AssertTermEquals("fox", filter, termAtt, payAtt, PayloadHelper.EncodeInt(3));
            AssertTermEquals("jumped", filter, termAtt, payAtt, null);
            AssertTermEquals("over", filter, termAtt, payAtt, null);
            AssertTermEquals("the", filter, termAtt, payAtt, null);
            AssertTermEquals("lazy", filter, termAtt, payAtt, PayloadHelper.EncodeInt(5));
            AssertTermEquals("brown", filter, termAtt, payAtt, PayloadHelper.EncodeInt(99));
            AssertTermEquals("dogs", filter, termAtt, payAtt, PayloadHelper.EncodeInt(83));
            Assert.False(filter.IncrementToken());
        }
Exemplo n.º 31
0
 /// <summary></summary>
 /// <param name="regKey"></param>
 /// <returns></returns>
 public static bool TryDownloadSheetDefs(out List <WebForms_SheetDef> listWebFormSheetDefs, string regKey = null)
 {
     if (string.IsNullOrEmpty(regKey))
     {
         regKey = PrefC.GetString(PrefName.RegistrationKey);
     }
     listWebFormSheetDefs = new List <WebForms_SheetDef>();
     try {
         string payload = PayloadHelper.CreatePayloadWebHostSynch(regKey, new PayloadItem(regKey, "RegKey"));
         listWebFormSheetDefs = WebSerializer.DeserializeTag <List <WebForms_SheetDef> >(
             SheetsSynchProxy.GetWebServiceInstance().DownloadSheetDefs(payload), "Success"
             );
     }
     catch (Exception ex) {
         ex.DoNothing();
         return(false);
     }
     return(true);
 }