Exemplo n.º 1
0
 public static string SerializeWorkItemProgress(WorkItemProgress data)
 {
     return(JsmlSerializer.Serialize(data, "data",
                                     new JsmlSerializer.SerializeOptions {
         Hook = _workItemProgressHook, DataContractTest = IsWorkItemProgressContract
     }));
 }
Exemplo n.º 2
0
 public static WorkItemProgress DeserializeWorkItemProgress(string data)
 {
     return(JsmlSerializer.Deserialize <WorkItemProgress>(data,
                                                          new JsmlSerializer.DeserializeOptions {
         Hook = _workItemProgressHook, DataContractTest = IsWorkItemProgressContract
     }));
 }
Exemplo n.º 3
0
 public static WorkItemRequest DeserializeWorkItemRequest(string data)
 {
     return(JsmlSerializer.Deserialize <WorkItemRequest>(data,
                                                         new JsmlSerializer.DeserializeOptions {
         Hook = _workItemRequestHook, DataContractTest = IsWorkItemRequestContract
     }));
 }
        public void Test_DataContract_non_public_constructor()
        {
            var jsml = JsmlSerializer.Serialize(new TestContract3("foo"), "data");
            var obj  = JsmlSerializer.Deserialize <TestContract3>(jsml);

            Assert.AreEqual("foo", obj.Value);
        }
Exemplo n.º 5
0
 public string GetOperationNames(string serviceContractName)
 {
     string[] names = null;
     Platform.GetService <IJsmlShimService>(
         service => names = service.GetOperationNames(new GetOperationNamesRequest(serviceContractName)).OperationNames);
     return(JsmlSerializer.Serialize(names, "operationNames"));
 }
Exemplo n.º 6
0
        public static void ImportSettingsDefinition(ISettingsStore store, string dataFileOrFolderPath, bool overwrite)
        {
            // determine list of source files to import
            var fileList = new List <string>();

            if (File.Exists(dataFileOrFolderPath))
            {
                fileList.Add(dataFileOrFolderPath);
            }
            else if (Directory.Exists(dataFileOrFolderPath))
            {
                fileList.AddRange(Directory.GetFiles(dataFileOrFolderPath, "*.xml"));
            }
            else
            {
                throw new ArgumentException(string.Format("{0} is not a valid data file or directory.", dataFileOrFolderPath));
            }

            Platform.Log(LogLevel.Info, "Loading settings from {0}...", dataFileOrFolderPath);

            var configurations = from file in fileList
                                 let xml = File.ReadAllText(file)
                                           from config in JsmlSerializer.Deserialize <SettingDefinition[]>(xml)
                                           select config;

            ImportSettingsDefinition(store, configurations, overwrite);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Import authority groups defined in XML files located at the specified path.
        /// </summary>
        /// <param name="dataFileOrFolderPath"></param>
        public static void ImportAuthorityGroups(string dataFileOrFolderPath)
        {
            // determine list of source files to import
            var fileList = new List <string>();

            if (File.Exists(dataFileOrFolderPath))
            {
                fileList.Add(dataFileOrFolderPath);
            }
            else if (Directory.Exists(dataFileOrFolderPath))
            {
                fileList.AddRange(Directory.GetFiles(dataFileOrFolderPath, "*.xml"));
            }
            else
            {
                throw new ArgumentException(string.Format("{0} is not a valid data file or directory.", dataFileOrFolderPath));
            }

            var authGroups = from file in fileList
                             let xml = File.ReadAllText(file)
                                       from authGroup in JsmlSerializer.Deserialize <AuthorityGroupDefinition[]>(xml)
                                       select authGroup;

            ImportAuthorityGroups(authGroups, dataFileOrFolderPath);
        }
Exemplo n.º 8
0
 public static string SerializeServerExtensionData(Dictionary <string, object> serverExtensionData)
 {
     return(JsmlSerializer.Serialize(serverExtensionData, "data",
                                     new JsmlSerializer.SerializeOptions {
         Hook = _serverExtensionDataHook, DataContractTest = IsServerExtensionDataContract
     }));
 }
Exemplo n.º 9
0
 public static string SerializeWorkItemRequest(WorkItemRequest data)
 {
     return(JsmlSerializer.Serialize(data, "data",
                                     new JsmlSerializer.SerializeOptions {
         Hook = _workItemRequestHook, DataContractTest = IsWorkItemRequestContract
     }));
 }
Exemplo n.º 10
0
 public static Dictionary <string, object> DeserializeServerExtensionData(string data)
 {
     return(JsmlSerializer.Deserialize <Dictionary <string, object> >(data,
                                                                      new JsmlSerializer.DeserializeOptions {
         Hook = _serverExtensionDataHook, DataContractTest = IsServerExtensionDataContract
     }));
 }
Exemplo n.º 11
0
        /// <summary>
        /// Invokes the specified operation on the specified service contract, passing the specified JSML-encoded request object.
        /// </summary>
        /// <param name="serviceContractTypeName"></param>
        /// <param name="operationName"></param>
        /// <param name="jsmlRequest"></param>
        /// <returns></returns>
        public static string InvokeOperation(string serviceContractTypeName, string operationName, string jsmlRequest)
        {
            Type       contract  = Type.GetType(serviceContractTypeName);
            MethodInfo operation = contract.GetMethod(operationName);

            ParameterInfo[] parameters = operation.GetParameters();
            if (parameters.Length != 1)
            {
                throw new InvalidOperationException("Can only invoke methods with exactly one input parameter.");
            }

            object service = null;

            try
            {
                service = Platform.GetService(contract);

                object innerRequest  = JsmlSerializer.Deserialize(parameters[0].ParameterType, jsmlRequest);
                object innerResponse = operation.Invoke(service, new object[] { innerRequest });

                return(JsmlSerializer.Serialize(innerResponse, "responseData"));
            }
            finally
            {
                if (service != null && service is IDisposable)
                {
                    (service as IDisposable).Dispose();
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Import authority groups defined in XML files located at the specified path.
        /// </summary>
        /// <param name="dataFileOrFolderPath"></param>
        public static void ImportUsers(string dataFileOrFolderPath)
        {
            // determine list of source files to import
            var fileList = new List <string>();

            if (File.Exists(dataFileOrFolderPath))
            {
                fileList.Add(dataFileOrFolderPath);
            }
            else if (Directory.Exists(dataFileOrFolderPath))
            {
                fileList.AddRange(Directory.GetFiles(dataFileOrFolderPath, "*.xml"));
            }
            else
            {
                throw new ArgumentException(string.Format("{0} is not a valid data file or directory.", dataFileOrFolderPath));
            }

            Platform.Log(LogLevel.Info, "importing users from {0} files", fileList.Count);

            var users = from file in fileList
                        let xml = File.ReadAllText(file)
                                  from user in JsmlSerializer.Deserialize <UserDefinition[]>(xml)
                                  select user;

            ImportUsers(users, dataFileOrFolderPath);
        }
Exemplo n.º 13
0
 public static string SerializeExternalQueryResult(ImageServerExternalQueryResult data)
 {
     return(JsmlSerializer.Serialize(data, "ImageServerExternalQueryResult",
                                     new JsmlSerializer.SerializeOptions
     {
         Hook = ExternalQueryHook,
         DataContractTest = IsImageServerExternalQueryContract
     }));
 }
Exemplo n.º 14
0
 public static ImageServerExternalQuery DeserializeExternalQuery(XmlDocument data)
 {
     return(JsmlSerializer.Deserialize <ImageServerExternalQuery>(data,
                                                                  new JsmlSerializer.DeserializeOptions
     {
         Hook = ExternalQueryHook,
         DataContractTest = IsImageServerExternalQueryContract
     }));
 }
Exemplo n.º 15
0
 public static ImageServerNotification DeserializeNotification(XmlDocument data)
 {
     return(JsmlSerializer.Deserialize <ImageServerNotification>(data,
                                                                 new JsmlSerializer.DeserializeOptions
     {
         Hook = ExternalRequestHook,
         DataContractTest = IsImageServerExternalRequestContract
     }));
 }
Exemplo n.º 16
0
 public static string SerializeNotification(ImageServerNotification data)
 {
     return(JsmlSerializer.Serialize(data, "ImageServerNotification",
                                     new JsmlSerializer.SerializeOptions
     {
         Hook = ExternalRequestHook,
         DataContractTest = IsImageServerExternalRequestContract
     }));
 }
Exemplo n.º 17
0
        /// <summary>
        /// Writes the specified data to the specified xml writer.
        /// </summary>
        /// <param name="writer"></param>
        /// <param name="data"></param>
        private static void Write(XmlWriter writer, object data)
        {
            // bug #5300: do not write out the "Unique" flag anymore
            var options = new JsmlSerializer.SerializeOptions {
                DataMemberTest = (m => AttributeUtils.HasAttribute <DataMemberAttribute>(m) && m.Name != "Unique")
            };

            JsmlSerializer.Serialize(writer, data, data.GetType().Name, options);
        }
Exemplo n.º 18
0
 public static WorkQueueUidData DeserializeWorkQueueUidData(XmlDocument data)
 {
     return(JsmlSerializer.Deserialize <WorkQueueUidData>(data,
                                                          new JsmlSerializer.DeserializeOptions
     {
         Hook = WorkItemDataHook,
         DataContractTest = IsWorkQueueDataContract,
         DataMemberTest = IsXmlSerializationDataMember
     }));
 }
Exemplo n.º 19
0
 public static ImageServerExternalRequestState DeserializeExternalRequestState(string data)
 {
     return(JsmlSerializer.Deserialize <ImageServerExternalRequestState>(data,
                                                                         new JsmlSerializer.DeserializeOptions
     {
         Hook = ExternalRequestHook,
         DataContractTest =
             IsImageServerExternalRequestContract
     }));
 }
Exemplo n.º 20
0
 public static ImageServerExternalQueryResult DeserializeExternalQueryResult(string data)
 {
     return(JsmlSerializer.Deserialize <ImageServerExternalQueryResult>(data,
                                                                        new JsmlSerializer.DeserializeOptions
     {
         Hook = ExternalQueryHook,
         DataContractTest =
             IsImageServerExternalQueryContract
     }));
 }
Exemplo n.º 21
0
 public static string SerializeWorkQueueUidData(WorkQueueUidData data)
 {
     return(JsmlSerializer.Serialize(data, "WorkQueueUidData",
                                     new JsmlSerializer.SerializeOptions
     {
         Hook = WorkItemDataHook,
         DataContractTest = IsWorkQueueDataContract,
         DataMemberTest = IsXmlSerializationDataMember
     }));
 }
        /// <summary>
        /// Parses soft keys XML document.
        /// </summary>
        private static List <SoftKeyData> LoadSoftKeys(string softKeysXml)
        {
            if (string.IsNullOrEmpty(softKeysXml))
            {
                return(new List <SoftKeyData>());
            }

            var data = JsmlSerializer.Deserialize <SoftKeysData>(softKeysXml);

            return(data.SoftKeys);
        }
        /// <summary>
        /// Parses templates XML document.
        /// </summary>
        private static List <TemplateData> LoadTemplates(string templatesXml)
        {
            if (string.IsNullOrEmpty(templatesXml))
            {
                return(new List <TemplateData>());
            }

            var templatesData = JsmlSerializer.Deserialize <TemplatesData>(templatesXml);

            return(templatesData.Templates);
        }
Exemplo n.º 24
0
        protected override void SetTag(string tag, string data)
        {
            if (string.Equals("Allergies", tag))
            {
                this.Allergies.Clear();
                this.Allergies.AddRange(JsmlSerializer.Deserialize <List <PatientAllergyDetail> >(data));
                return;
            }

            base.SetTag(tag, data);
        }
Exemplo n.º 25
0
        protected override void SetTag(string tag, string data)
        {
            // the page uses SetTag to indicate that the check state has changed
            var checkStates = JsmlSerializer.Deserialize <List <bool> >(data);

            for (var i = 0; i < _context.OrderNotes.Count; i++)
            {
                _context.OrderNotes[i].WillAcknowledge = checkStates[i];
            }
            EventsHelper.Fire(_checkedItemsChanged, this, EventArgs.Empty);
        }
Exemplo n.º 26
0
        /// <summary>
        /// Log the specified operation.
        /// </summary>
        /// <param name="operation">The name of the operation performed.</param>
        /// <param name="detailsDataContract">The audit message details.</param>
        private static void Log(string operation, object detailsDataContract)
        {
            if (LoginSession.Current == null)
            {
                return;
            }

            lock (_auditLog)
            {
                _auditLog.WriteEntry(operation, JsmlSerializer.Serialize(detailsDataContract, "Audit"));
            }
        }
Exemplo n.º 27
0
            /// <summary>
            /// Opens a pop up providing details on the specified practitioner
            /// (must be a JSML encoded <see cref="ExternalPractitionerSummary"/> object).
            /// </summary>
            /// <param name="jsml"></param>
            /// <returns></returns>
            public void OpenPractitionerDetail(string jsml)
            {
                var practitionerSummary = JsmlSerializer.Deserialize <ExternalPractitionerSummary>(jsml);

                LaunchAsDialog(
                    _component.Host.DesktopWindow,
                    new ExternalPractitionerOverviewComponent()
                {
                    PractitionerSummary = practitionerSummary
                },
                    SR.TitleExternalPractitioner + " - " + PersonNameFormat.Format(practitionerSummary.Name));
            }
Exemplo n.º 28
0
 /// <summary>
 /// Formats the specified Procedure (must be a JSML encoded <see cref="ProcedureSummary"/> or <see cref="ProcedureDetail"/> object).
 /// </summary>
 /// <param name="jsml"></param>
 /// <returns></returns>
 public string FormatProcedureName(string jsml)
 {
     try
     {
         var procedureSummary = JsmlSerializer.Deserialize <ProcedureSummary>(jsml);
         return(procedureSummary == null ? "" : ProcedureFormat.Format(procedureSummary));
     }
     catch (InvalidCastException)
     {
         var procedureDetail = JsmlSerializer.Deserialize <ProcedureDetail>(jsml);
         return(procedureDetail == null ? "" : ProcedureFormat.Format(procedureDetail));
     }
 }
Exemplo n.º 29
0
            /// <summary>
            /// Attempts to resolve the specified search string to a staff (returns a JSML encoded <see cref="StaffSummary"/>.
            /// </summary>
            /// <param name="search"></param>
            /// <returns></returns>
            public string ResolveStaffName(string search)
            {
                StaffSummary staff;
                var          lookupHandler = new StaffLookupHandler(_component.Host.DesktopWindow);
                var          resolved      = lookupHandler.ResolveName(search, out staff);

                // bug #2896: the name may "resolve" to nothing, so we still need to check if staff actually has a value
                if (!resolved || staff == null)
                {
                    resolved = lookupHandler.ResolveNameInteractive(search, out staff);
                }
                return(resolved ? JsmlSerializer.Serialize(staff, "staff") : null);
            }
Exemplo n.º 30
0
 /// <summary>
 /// Formats the specified Staff (must be a JSML encoded <see cref="StaffSummary"/> or <see cref="StaffDetail"/> object).
 /// </summary>
 /// <param name="jsml"></param>
 /// <returns></returns>
 public string FormatStaffNameAndRole(string jsml)
 {
     try
     {
         var staffSummary = JsmlSerializer.Deserialize <StaffSummary>(jsml);
         return(staffSummary == null ? "" : StaffNameAndRoleFormat.Format(staffSummary));
     }
     catch (InvalidCastException)
     {
         var staffDetail = JsmlSerializer.Deserialize <StaffDetail>(jsml);
         return(staffDetail == null ? "" : StaffNameAndRoleFormat.Format(staffDetail));
     }
 }