public string ModifySingleApp(string valueToModify, CustomizationContextData context) { Tracer.TraceInfo("Single Resource only"); if (!DoesCustomizationApply(context)) { return(valueToModify); } // turn the input string into the single resource object // NB it's a string that happens to be an XML document, if you want to manipulate it in any // other way, feel free... var sRes = singleResourceSerializer.Deserialize(valueToModify); TraceResource(sRes); // Apply the customisation logic to this resource. if (FixupResourceForCallCenter(sRes)) { string newResDoc = singleResourceSerializer.Serialize(sRes); Tracer.TraceInfo("Returning modified resource doc: {0}", newResDoc); return(newResDoc); } // false return from the above indicates we want to discard this element. Tracer.TraceInfo("//BUGBUG Need to return empty element..."); // no work to do here...will fall through to revert to original return(valueToModify); }
/// <summary> /// Saves the points of interest. /// </summary> public void SavePointsOfInterest() { try { string PATH = (string.Format(Application.StartupPath + "\\Documents\\Points of intrest")); SaveFileDialog SaveDialog = new SaveFileDialog { InitialDirectory = PATH, Filter = "xml |*.xml", FilterIndex = 1 }; string Filename; if (SaveDialog.ShowDialog() == DialogResult.OK) { if (SaveDialog.FileName.Contains(".xml")) { Filename = SaveDialog.FileName; } else { Filename = SaveDialog.FileName + ".xml"; } XmlSerializationHelper.Serialize(Filename, Tasks.RandomPathTask.Options.Points); } SaveDialog.Dispose(); } catch (Exception ex) { Logger.AddDebugText(Tc.rtbDebug, string.Format(@"Error Saving {0}", ex)); } }
public override void Execute() { ClientConnection client = ConnectionRepository.Instance.Query(c => c.ClientId == _clientId).FirstOrDefault(); if (client != null) { ResponseHeader responseHeader = ResponseBuilder.BuildResponseHeader(_encryptionType, _compressionType, _responseType); ZipSocket connection = SocketRepository.Instance.FindByClientId(_clientId); if (connection != null) { connection.SendData( XmlSerializationHelper .Serialize <ResponseHeader>(responseHeader) .SerializeUTF()); //connection.SendData( // ResponseBuilder.ProcessResponse( // client.ServerAuthority, // client // .RequestHeader // .MessageHeader // .EncryptionHeader // .PublicKey, // responseHeader, // _response).SerializeUTF()); } } }
public override bool Send(Package package) { hubProxy.Invoke("send", "TCP t14Lab.MessageTree.Connector", XmlSerializationHelper.Serialize(package)).Wait(); byte[] data = Encoding.UTF8.GetBytes(XmlSerializationHelper.Serialize(package)); clientStream.Write(data, 0, data.Length); return(true); }
public void XmlSerializeDocument415() { // формируем документ для загрузки в ЛК var doc = CreateDocument415(); var xml = XmlSerializationHelper.Serialize(doc, " Отправка товара из Типографии в Автомойку: один ящик с 4 препаратами и 1 препарат "); WriteLine(xml); }
public void XmlSerializeDocument915() { // формируем документ для загрузки в ЛК var doc = CreateDocument915(); var xml = XmlSerializationHelper.Serialize(doc, " Упаковка товара в Типографии "); WriteLine(xml); }
public void XmlSerializeDocument313() { // формируем документ для загрузки в ЛК var doc = CreateDocument313(); var xml = XmlSerializationHelper.Serialize(doc, " Типография вводит в оборот свежеупакованные ЛП "); WriteLine(xml); }
public void XmlSerializeDocument311() { // формируем документ для загрузки в ЛК var doc = CreateDocument311(); var xml = XmlSerializationHelper.Serialize(doc); WriteLine(xml); }
public void ThenSerializaionAndDeserializationWorksForPerLineDiffResult() { var serialized = XmlSerializationHelper.Serialize(_perLineDiffResultSource); var deserialized = XmlSerializationHelper.DeSerialize <List <PerLineDiffResult> >(serialized); Assert.IsTrue(_perLineDiffResultSource.Count == deserialized.Count); Assert.IsTrue(_perLineDiffResultSource.First().Equals(deserialized.First())); }
public static void CreateTestData(int maxTodosCount, string fileName) { List <Todo> todoList = new List <Todo>(); using (StreamWriter outfile = new StreamWriter(fileName)) { int count = 1; int count2 = 1; Guid projectPid = Guid.NewGuid(); for (int a = 0; a < maxTodosCount; a++) { Status status = Status.Test; if (count == 1) { status = Status.Done; } else if (count == 2) { status = Status.Progress; } else if (count == 3) { status = Status.Today; } else { status = Status.Backlog; } if (count == 7) { count = 1; } else { count++; } if (count2 == 200) { projectPid = Guid.NewGuid(); count2 = 1; } count2++; Todo todo = new Todo() { pId = Guid.NewGuid(), Id = "T14T-" + a.ToString().PadLeft(6, '0'), ShortDescription = "Test Todo " + a, CurrentState = "Current state " + a, Description = "Description" + a, Result = "Result" + a, Status = status, ProjectPid = projectPid }; outfile.WriteLine(XmlSerializationHelper.Serialize(todo)); } } }
public void XmlSerializeDocument701() { // получили 601 => создали на его основе 701 var doc601 = XmlSerializationHelper.Deserialize(Doc601xml); var doc701 = CreateDocument701(doc601); var xml = XmlSerializationHelper.Serialize(doc701, " Подтверждение из Автомойки "); WriteLine(xml); }
public override void SaveData(FileInfo xmlFile) { lock (dataListLock) { string data = XmlSerializationHelper.Serialize(dataList.Values.ToArray()); StreamWriter file = new StreamWriter(xmlFile.FullName); file.Write(data); file.Close(); } }
private void saveGridTo(string filename) { DirectoryInfo dataFolderProfiles = new DirectoryInfo(Path.Combine(Settings.Default.DataFolder, "checklists")); BindingSource source = (BindingSource)dataGridViewChecklist.DataSource; string data = XmlSerializationHelper.Serialize(source.List); StreamWriter file = new StreamWriter(dataFolderProfiles.FullName + @"\" + filename); file.WriteLine(data); file.Close(); }
internal void SaveCalendars() { foreach (KeyValuePair <string, SortableBindingList <TodoCalendarPosition> > calendar in calendars) { if (calendar.Value != null && calendar.Value.Count > 0) { StreamWriter calendarXMLFile = new StreamWriter(dataFolder.FullName + "\\" + calendar.Key); calendarXMLFile.WriteLine(XmlSerializationHelper.Serialize(calendar.Value)); calendarXMLFile.Close(); } } }
public void XmlSerializationHelperSetsXsdSchemaVersionIfNotSpecified() { var doc = new Documents(); Assert.True(string.IsNullOrWhiteSpace(doc.Version)); var xml = XmlSerializationHelper.Serialize(doc); doc = XmlSerializationHelper.Deserialize(xml); Assert.False(string.IsNullOrWhiteSpace(doc.Version)); Assert.AreEqual(XmlSerializationHelper.DocumentSchemaVersion, doc.Version); }
public void Chapter5_12_GetTicket() { var ticket = Client.GetTicket(TestTicketID); Assert.IsNotNull(ticket); WriteLine("Downloaded TicketID: {0}", TestTicketID); WriteLine("Ticket version: {0}", ticket.Version); WriteLine("Operation: {0}", ticket.Result.Operation); WriteLine("Result: {0}", ticket.Result.Operation_Result); WriteLine("Comments: {0}", ticket.Result.Operation_Comment); WriteLine(XmlSerializationHelper.Serialize(ticket)); }
public string Modify(string valueToModify, CustomizationContextData context) { // For this example, we're going to alter resources if the user in question is a member of // the 'Callcenter Users' group. Tracer.TraceInfo("Resource SDK Enumeration customisation"); Tracer.TraceInfo(context.ToString()); try { if (!DoesCustomizationApply(context)) { return(valueToModify); } // we have a full list of enumerated resources Tracer.TraceInfo("Full Resource List"); var resources = resourcesSerializer.Deserialize(valueToModify); var editres = new List <resourceType>(); // Accumulate resultant resources in list foreach (resourceType r in resources.resource) { Tracer.TraceInfo("Evaluating Resource... "); TraceResource(r); // apply our customisation logic to this resource // only preserve resources in the list is we get a true return from the customisation method if (FixupResourceForCallCenter(r)) { editres.Add(r); } } // Back to array to include in resources object. resources.resource = editres.ToArray(); // Re-serialise into string string newDoc = resourcesSerializer.Serialize(resources); // Return modified XML document for further use. return(newDoc); } catch (Exception outer) { Tracer.TraceInfo("Exception in customization: {0}" + outer); // Revert to pre-customisation enumeration value. return(valueToModify); } }
public void XmlSerializationTest() { var doc = new Documents(); doc.Register_End_Packing = new Register_End_Packing(); doc.Register_End_Packing.Gtin = "12345"; doc.Register_End_Packing.Signs.Add("43232424"); doc.Register_End_Packing.Signs.Add("654o6u45"); doc.Register_End_Packing.Signs.Add("fstkjwtk"); var xml = XmlSerializationHelper.Serialize(doc); Assert.NotNull(xml); }
private void button1_Click(object sender, EventArgs e) { string data = XmlSerializationHelper.Serialize(todoBindingSource.List); StreamWriter file = new StreamWriter(todoXmlFile); file.WriteLine(data); file.Close(); string data2 = XmlSerializationHelper.Serialize(sprintBindingSource.List); StreamWriter file2 = new StreamWriter(sprintXmlFile); file2.WriteLine(data2); file2.Close(); }
public void Chapter5_10_GetDocument() { var doc = Client.GetDocument(TestDocumentID); Assert.IsNotNull(doc); WriteLine("Downloaded document: {0}", TestDocumentID); WriteLine("Document version: {0}", doc.Version); var an = doc.Accept_Notification; Assert.NotNull(an); WriteLine("SubjectID: {0}", an.Subject_Id); WriteLine("CounterpartyID: {0}", an.Counterparty_Id); WriteLine(XmlSerializationHelper.Serialize(doc)); }
/// <summary> /// The save configuration. /// </summary> /// <param name="data"> /// The data. /// </param> /// <exception cref="ApplicationException"> /// </exception> public void SaveConfiguration(ConfigData data) { try { XmlSerializationHelper.Serialize(EnvirenmentHelper.ConfigFilePath, data); } catch (Exception exception) { if (exception is FileNotFoundException || exception is ApplicationException) { throw; } throw new ApplicationException("Unexpected error occured.", exception); } }
public string Modify(string valueToModify, CustomizationContextData context) { // Example: we set the ClientTabletOS Access Condition in the InputModifer CustomizeAccessCondiitions // example, but this would equally apply to any externally set access condition. // // The presence of this Session Customization point is to provide consistent control for scenarios // where access to resources is dynamically controlled. As well as limiting visibility to resource // enumeration, block the clients 'view' of any active sessions for such apps which may have been established // in a permitted context. if (!HasAccessCondition(context, "ClientTabletOS")) { // No changes required as context not applicable return(valueToModify); } Tracer.TraceInfo("Session filtering customization applies"); var sessions = serializer.Deserialize(valueToModify); var resultantList = new List <sessionType>(); foreach (sessionType s in sessions.sessions) { TraceSession(s); // Having NT in the resource internal name used as shorthand for 'No Tablets'in this example // Note: limited info on the apps in the target session is available here so either use an explicit // list of apps or have some encoding in the available data. if (!s.initialapp.Contains("NT")) { resultantList.Add(s); } } sessions.sessions = resultantList.ToArray(); string newSessions = serializer.Serialize(sessions); if (newSessions == null) { Tracer.TraceInfo("Failure to reform session document, revert to original"); return(valueToModify); } Tracer.TraceInfo("Resultant Session String: {0}", newSessions); return(newSessions); }
public void Save() { StreamWriter projectsXMLFile = new StreamWriter(projectXMLFilePath); projectsXMLFile.WriteLine(XmlSerializationHelper.Serialize(projectBindingSource.List)); projectsXMLFile.Close(); StreamWriter todosXMLFile = new StreamWriter(todoXMLFilePath); todosXMLFile.WriteLine(XmlSerializationHelper.Serialize(todoBindingSource.List)); todosXMLFile.Close(); StreamWriter sprintsXMLFile = new StreamWriter(sprintXMLFilePath); sprintsXMLFile.WriteLine(XmlSerializationHelper.Serialize(sprintBindingSource.List)); sprintsXMLFile.Close(); taskPlanningPanel1.SaveCalendars(); }
/// <summary> /// 5.1. Отправка объекта документа /// </summary> /// <param name="doc">Объект документа</param> /// <returns>Идентификатор документа</returns> public string SendDocument(Documents doc) { if (!LargeDocumentSize.HasValue) { LargeDocumentSize = GetLargeDocumentSize(); } // serialize the document and estimate data packet size var xml = XmlSerializationHelper.Serialize(doc, ApplicationName); var xmlBytes = Encoding.UTF8.GetByteCount(xml); var xmlBase64 = 4 * xmlBytes / 3; var overhead = 1024; // requestId + JSON serialization overhead var totalSize = xmlBase64 + SignatureSize + overhead; // prefer SendDocument for small documents if (totalSize < LargeDocumentSize) { return(SendDocument(xml)); } return(SendLargeDocument(xml)); }
public void SaveSettings() { try { GetRichTextBoxLines(); SaveFileDialog fdgSave = new SaveFileDialog(); string startpath = Path.GetDirectoryName(Application.ExecutablePath); string PATH = (String.Format(@"{0}Documents\{1}\Config\", startpath, Api.Player.Name)); SaveFileDialog SaveDialog = new SaveFileDialog(); SaveDialog.InitialDirectory = PATH; SaveDialog.Filter = "xml |*.xml"; SaveDialog.FilterIndex = 1; string Filename; if (SaveDialog.ShowDialog() == DialogResult.OK) { if (SaveDialog.FileName.Contains(".xml")) { Filename = SaveDialog.FileName; } else { Filename = SaveDialog.FileName + ".xml"; } Tasks.Huntertask.Options.PullCommand = Tc.pullTb.Text; XmlSerializationHelper.Serialize(Filename, Tasks.Huntertask.Options); } fdgSave.Dispose(); SaveDialog.Dispose(); } catch (Exception ex) { Logger.AddDebugText(Tc.rtbDebug, string.Format(@"Error Saving {0}", ex)); } }
private void TextResultPublicInfo_LostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { Todo todo = (Todo)todoViewSource.View.CurrentItem; if (todo != null) { string propertyName = string.Empty; switch (((Control)sender).Name) { case "TextEditorPublicInfo": propertyName = "PublicText"; break; case "TextEditorCurrentState": propertyName = "CurrentState"; break; case "TextEditorResult": propertyName = "Result"; break; case "TextEditorTargetState": propertyName = "Description"; break; default: break; } DataItemEndChanging data = new DataItemEndChanging() { PK = todo.pId, Type = todo.GetType().ToString(), PropertyName = propertyName }; tornado14Observer.Send(new Package(SENDERID, 10, (int)EventMapping.DataItemEndChanging_17, Method.PUT, XmlSerializationHelper.Serialize(data))); DataItemChanged data2 = new DataItemChanged() { PK = todo.pId, PropertyName = propertyName, Value = ((Tornado14.WPFControls.TEditor)(sender)).Text2, Type = todo.GetType().ToString(), }; tornado14Observer.Send(new Package(SENDERID, 12, (int)EventMapping.DataItemChanged_13, Method.PUT, XmlSerializationHelper.Serialize(data2))); } }
private void DataGrid_CurrentCellChanged(object sender, EventArgs e) { DataGrid grid = (DataGrid)sender; NetObject selectedNetObject = null; if (grid.CurrentCell.Item.GetType() == typeof(Project)) { selectedNetObject = selectedProject; } else if (grid.CurrentCell.Item.GetType() == typeof(Todo)) { selectedNetObject = selectedTodo; } else { return; } if (selectedNetObject == null || selectedNetObject.pId != ((NetObject)grid.CurrentCell.Item).pId) { NetObject netObject = (NetObject)grid.CurrentCell.Item; if (netObject.pId != Guid.Empty) { CurrentItemChanged data = new CurrentItemChanged() { PK = netObject.pId, Type = netObject.GetType().ToString() }; tornado14Observer.Send(new Package(SENDERID, 12, (int)EventMapping.CurrentItemChanged_15, Method.PUT, XmlSerializationHelper.Serialize(data))); if (selectedTodo != null) { todoViewSource.View.Refresh(); todoViewSource.View.MoveCurrentTo(selectedTodo.pId); } } selectedNetObject = (NetObject)grid.CurrentCell.Item; } }
private void DataGrid_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { var dataGrid = (DataGrid)sender; if (dataGrid.SelectedItems.Count > 0) { NetObject netObject = (NetObject)dataGrid.SelectedItems[0]; int recipientId = 0; if (netObject.GetType() == typeof(Project)) { recipientId = 12; } else if (netObject.GetType() == typeof(Todo)) { recipientId = 10; } else { throw new Exception("Unknown New Type"); } DataItemDeleted data = new DataItemDeleted() { PK = netObject.pId, Type = netObject.GetType().ToString() }; tornado14Observer.Send(new Package(SENDERID, recipientId, (int)EventMapping.DataItemDeleted_19, Method.DELETE, XmlSerializationHelper.Serialize(data))); } } }
private void DataGrid_InitializingNewItem(object sender, InitializingNewItemEventArgs e) { if (e.NewItem != null) { int recipientId = 0; NetObject netObject = (NetObject)e.NewItem; netObject.pId = Guid.NewGuid(); List <NetObject> objectList = new List <NetObject>(); if (e.NewItem.GetType() == typeof(Project)) { objectList = ProjectList.ToList <NetObject>(); recipientId = 12; } else if (e.NewItem.GetType() == typeof(Todo)) { objectList = TodoList.ToList <NetObject>(); ((Todo)e.NewItem).ProjectPid = selectedProject.pId; recipientId = 10; } else { throw new Exception("Unknown New Type"); } int maxCount = 0; string prefix = ""; foreach (NetObject p in objectList) { try { string[] idSplit = p.Id.Split('-'); int value = int.Parse(idSplit[1]); if (maxCount < value) { maxCount = value; if (idSplit[0].Length > 0) { prefix = idSplit[0] + "-"; } } } catch (Exception ex) { } } maxCount++; string newId = string.Format("{0}{1}", prefix, maxCount); ((NetObject)e.NewItem).Id = newId; DataItemAdded data = new DataItemAdded() { PK = netObject.pId, Id = newId, Type = netObject.GetType().ToString() }; tornado14Observer.Send(new Package(SENDERID, recipientId, (int)EventMapping.DataItemAdded_18, Method.POST, XmlSerializationHelper.Serialize(data))); if (e.NewItem.GetType() == typeof(Todo)) { DataItemChanged dataChanged = new DataItemChanged() { PK = netObject.pId, PropertyName = "ProjectPid", Type = typeof(Todo).ToString(), Value = selectedProject.pId }; tornado14Observer.Send(new Package(SENDERID, recipientId, (int)EventMapping.DataItemChanged_13, Method.PUT, XmlSerializationHelper.Serialize(dataChanged))); } } }
private void DataGrid_CellEditEnding(object sender, DataGridCellEditEndingEventArgs e) { NetObject netObject = (NetObject)e.Row.Item; if (netObject != null && e.Column.SortMemberPath != null) { int recipientId = 0; if (e.Row.Item.GetType() == typeof(Project)) { recipientId = 12; } else if (e.Row.Item.GetType() == typeof(Todo)) { recipientId = 10; } else { throw new Exception("Unknown New Type"); } DataItemChanged data = new DataItemChanged() { PK = netObject.pId, PropertyName = e.Column.SortMemberPath, Value = ((TextBox)e.EditingElement).Text, Type = netObject.GetType().ToString() }; tornado14Observer.Send(new Package(SENDERID, recipientId, (int)EventMapping.DataItemChanged_13, Method.PUT, XmlSerializationHelper.Serialize(data))); } else { throw new Exception("Todo or Property Name is Empty."); } }