Beispiel #1
0
 private void FillGenderComboBox()
 {
     FormUtils.FillGenderComboBox(ref cb_gender);
 }
Beispiel #2
0
 private void helpToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormUtils.ShowCenteredDialogForm <FrmHelp>(this);
 }
Beispiel #3
0
        /// <summary>
        /// Displays the attributes and properties in the attributes view.
        /// </summary>
        /// <param name="sourceId">The NodeId of the Node to browse.</param>
        private void DisplayAttributes(NodeId sourceId)
        {
            try
            {
                AttributesLV.Items.Clear();

                ReadValueIdCollection nodesToRead = new ReadValueIdCollection();

                // attempt to read all possible attributes.
                for (uint ii = Attributes.NodeClass; ii <= Attributes.UserExecutable; ii++)
                {
                    ReadValueId nodeToRead = new ReadValueId();
                    nodeToRead.NodeId      = sourceId;
                    nodeToRead.AttributeId = ii;
                    nodesToRead.Add(nodeToRead);
                }

                int startOfProperties = nodesToRead.Count;

                // find all of the pror of the node.
                BrowseDescription nodeToBrowse1 = new BrowseDescription();

                nodeToBrowse1.NodeId          = sourceId;
                nodeToBrowse1.BrowseDirection = BrowseDirection.Forward;
                nodeToBrowse1.ReferenceTypeId = ReferenceTypeIds.HasProperty;
                nodeToBrowse1.IncludeSubtypes = true;
                nodeToBrowse1.NodeClassMask   = 0;
                nodeToBrowse1.ResultMask      = (uint)BrowseResultMask.All;

                BrowseDescriptionCollection nodesToBrowse = new BrowseDescriptionCollection();
                nodesToBrowse.Add(nodeToBrowse1);

                // fetch property references from the server.
                ReferenceDescriptionCollection references = FormUtils.Browse(m_session, nodesToBrowse, false);

                if (references == null)
                {
                    return;
                }

                for (int ii = 0; ii < references.Count; ii++)
                {
                    // ignore external references.
                    if (references[ii].NodeId.IsAbsolute)
                    {
                        continue;
                    }

                    ReadValueId nodeToRead = new ReadValueId();
                    nodeToRead.NodeId      = (NodeId)references[ii].NodeId;
                    nodeToRead.AttributeId = Attributes.Value;
                    nodesToRead.Add(nodeToRead);
                }

                // read all values.
                DataValueCollection      results         = null;
                DiagnosticInfoCollection diagnosticInfos = null;

                m_session.Read(
                    null,
                    0,
                    TimestampsToReturn.Neither,
                    nodesToRead,
                    out results,
                    out diagnosticInfos);

                ClientBase.ValidateResponse(results, nodesToRead);
                ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead);

                // process results.
                for (int ii = 0; ii < results.Count; ii++)
                {
                    string name     = null;
                    string datatype = null;
                    string value    = null;

                    // process attribute value.
                    if (ii < startOfProperties)
                    {
                        // ignore attributes which are invalid for the node.
                        if (results[ii].StatusCode == StatusCodes.BadAttributeIdInvalid)
                        {
                            continue;
                        }

                        // get the name of the attribute.
                        name = Attributes.GetBrowseName(nodesToRead[ii].AttributeId);

                        // display any unexpected error.
                        if (StatusCode.IsBad(results[ii].StatusCode))
                        {
                            datatype = Utils.Format("{0}", Attributes.GetDataTypeId(nodesToRead[ii].AttributeId));
                            value    = Utils.Format("{0}", results[ii].StatusCode);
                        }

                        // display the value.
                        else
                        {
                            TypeInfo typeInfo = TypeInfo.Construct(results[ii].Value);

                            datatype = typeInfo.BuiltInType.ToString();

                            if (typeInfo.ValueRank >= ValueRanks.OneOrMoreDimensions)
                            {
                                datatype += "[]";
                            }

                            value = Utils.Format("{0}", results[ii].Value);
                        }
                    }

                    // process property value.
                    else
                    {
                        // ignore properties which are invalid for the node.
                        if (results[ii].StatusCode == StatusCodes.BadNodeIdUnknown)
                        {
                            continue;
                        }

                        // get the name of the property.
                        name = Utils.Format("{0}", references[ii - startOfProperties]);

                        // display any unexpected error.
                        if (StatusCode.IsBad(results[ii].StatusCode))
                        {
                            datatype = String.Empty;
                            value    = Utils.Format("{0}", results[ii].StatusCode);
                        }

                        // display the value.
                        else
                        {
                            TypeInfo typeInfo = TypeInfo.Construct(results[ii].Value);

                            datatype = typeInfo.BuiltInType.ToString();

                            if (typeInfo.ValueRank >= ValueRanks.OneOrMoreDimensions)
                            {
                                datatype += "[]";
                            }

                            value = Utils.Format("{0}", results[ii].Value);
                        }
                    }

                    // add the attribute name/value to the list view.
                    ListViewItem item = new ListViewItem(name);
                    item.SubItems.Add(datatype);
                    item.SubItems.Add(value);
                    AttributesLV.Items.Add(item);
                }

                // adjust width of all columns.
                for (int ii = 0; ii < AttributesLV.Columns.Count; ii++)
                {
                    AttributesLV.Columns[ii].Width = -2;
                }
            }
            catch (Exception exception)
            {
                ClientUtils.HandleException(this.Text, exception);
            }
        }
Beispiel #4
0
 public ProductsForm()
 {
     InitializeComponent();
     FormUtils.Init(this);
 }
 private void            SetupForm_Load(object aSender, EventArgs aEventArgs)
 {
     ClientSize = FormUtils.calcClientSize(ClientSize, Controls);
 }
        public IHttpActionResult Submit()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var formInfo = FormManager.GetFormInfoByPost(request);
                if (formInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var logId = request.GetPostInt("logId");

                var logInfo = logId > 0
                    ? LogManager.Repository.GetLogInfo(logId)
                    : new LogInfo
                {
                    FormId  = formInfo.Id,
                    AddDate = DateTime.Now
                };
                var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);
                foreach (var fieldInfo in fieldInfoList)
                {
                    if (request.IsPostExists(fieldInfo.Title))
                    {
                        var value = request.GetPostString(fieldInfo.Title);
                        if (fieldInfo.FieldType == InputType.Date.Value || fieldInfo.FieldType == InputType.DateTime.Value)
                        {
                            var dt = FormUtils.ToDateTime(request.GetPostString(fieldInfo.Title));
                            logInfo.Set(fieldInfo.Title, dt.ToLocalTime());
                        }

                        else
                        {
                            logInfo.Set(fieldInfo.Title, value);
                        }
                    }
                }

                if (logId == 0)
                {
                    logInfo.Id = LogManager.Repository.Insert(formInfo, logInfo);
                    NotifyManager.SendNotify(formInfo, fieldInfoList, logInfo);
                }
                else
                {
                    LogManager.Repository.Update(logInfo);
                }

                return(Ok(new{}));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Beispiel #7
0
 private void ExportTablesForm_Load(object sender, EventArgs e)
 {
     FormUtils.Init(this);
     LoadData();
     dlgOpenFile.InitialDirectory = PathUtils.BaseDirectory;
 }
        /// <summary>
        /// 读取一个节点的指定属性
        /// </summary>
        /// <param name="nodeId"></param>
        /// <param name="attribute"></param>
        /// <returns></returns>
        private DataValue ReadNoteDataValueAttributes(NodeId nodeId, uint attribute)
        {
            NodeId sourceId = nodeId;
            ReadValueIdCollection nodesToRead = new ReadValueIdCollection();


            ReadValueId nodeToRead = new ReadValueId();

            nodeToRead.NodeId      = sourceId;
            nodeToRead.AttributeId = attribute;
            nodesToRead.Add(nodeToRead);

            int startOfProperties = nodesToRead.Count;

            // find all of the pror of the node.
            BrowseDescription nodeToBrowse1 = new BrowseDescription();

            nodeToBrowse1.NodeId          = sourceId;
            nodeToBrowse1.BrowseDirection = BrowseDirection.Forward;
            nodeToBrowse1.ReferenceTypeId = ReferenceTypeIds.HasProperty;
            nodeToBrowse1.IncludeSubtypes = true;
            nodeToBrowse1.NodeClassMask   = 0;
            nodeToBrowse1.ResultMask      = (uint)BrowseResultMask.All;

            BrowseDescriptionCollection nodesToBrowse = new BrowseDescriptionCollection();

            nodesToBrowse.Add(nodeToBrowse1);

            // fetch property references from the server.
            ReferenceDescriptionCollection references = FormUtils.Browse(m_OpcUaClient.Session, nodesToBrowse, false);

            if (references == null)
            {
                return(null);
            }

            for (int ii = 0; ii < references.Count; ii++)
            {
                // ignore external references.
                if (references[ii].NodeId.IsAbsolute)
                {
                    continue;
                }

                ReadValueId nodeToRead2 = new ReadValueId();
                nodeToRead2.NodeId      = (NodeId)references[ii].NodeId;
                nodeToRead2.AttributeId = Attributes.Value;
                nodesToRead.Add(nodeToRead2);
            }

            // read all values.
            DataValueCollection      results         = null;
            DiagnosticInfoCollection diagnosticInfos = null;

            m_OpcUaClient.Session.Read(
                null,
                0,
                TimestampsToReturn.Neither,
                nodesToRead,
                out results,
                out diagnosticInfos);

            ClientBase.ValidateResponse(results, nodesToRead);
            ClientBase.ValidateDiagnosticInfos(diagnosticInfos, nodesToRead);

            return(results[0]);
        }
 public HandbookForm(Handbook handbook)
 {
     InitializeComponent();
     this.handbook = handbook;
     FormUtils.Init(this);
 }
Beispiel #10
0
 public void StartFlash(UInt32 count = UInt32.MaxValue)
 {
     FormUtils.StartFlash(this, count);
 }
Beispiel #11
0
 public void StopFlash()
 {
     FormUtils.StopFlash(this);
 }
Beispiel #12
0
 public void NotifyFlash()
 {
     FormUtils.NotifyFlash(this);
 }
Beispiel #13
0
 public DocumentsForm()
 {
     InitializeComponent();
     FormUtils.Init(this);
 }
Beispiel #14
0
 private void mnuBatchOperations_Click(object sender, EventArgs e)
 {
     FormUtils.ShowCenteredDialogForm <FrmBatchShortcut>(this);
 }
Beispiel #15
0
        private async void OnButtonClick(Button button, ChildElement elementData)
        {
            button.IsEnabled = false;
            IsBusy           = true;
            try
            {
                string outcomePathName = elementData.Child.OutcomePathName;

                string validationMessage = "";
                if (!FormService.Validate(controls, outcomePathName, out validationMessage))
                {
                    await DisplayAlert("Validation Issues", validationMessage, "OK");

                    return;
                }

                var data = FormUtils.CollectData(controls);
                if (Connectivity.NetworkAccess == NetworkAccess.Internet)
                {
                    DecisionsFormInfoEvent e = await FormService.SelectPath(viewModel.FormInfo.FormSessionInfoId, outcomePathName, data, useNamedSession);

                    Debug.Write(e);
                    if (e == null)
                    {
                        await DisplayAlert("Error", "Problem with next form instruction.", "OK");

                        return;
                    }

                    var validationMessages = e.GetValidationMessages();

                    if (validationMessages.Length > 0)
                    {
                        string message = "";
                        Array.ForEach(validationMessages, msg => message += $"{msg}.\n\n");
                        await DisplayAlert("Validation Issues", message, "OK");

                        // TODO highlight the offending components
                        Array.ForEach(e.CurrentValidations, validation =>
                        {
                            FormControlWrapper control;
                            controls.TryGetValue(validation.ComponentID, out control);
                            // just show breaking issues for cut 1:
                            var breakingIssue = Array.Find(validation.ValidationIssues, issue => issue.BreakLevel == BreakLevel.Fatal);
                            if (control != null && breakingIssue != null)
                            {
                                control.SetValidation(breakingIssue.BreakLevel);
                            }
                        });
                    }

                    // if there were no validations to show, there should be next instructions
                    if (e.IsFlowCompletedInstructionEvent())
                    {
                        // Close this page. The flow's forms are done.
                        viewModel.Submitted = true;
                        await Navigation.PopAsync();

                        DependencyService.Get <ISnackbar>().ShortAlert("Form submitted successfully.");
                    }
                    else if (!String.IsNullOrEmpty(e.FlowTrackingId) && !String.IsNullOrEmpty(e.StepTrackingId))
                    {
                        var flowInstr = await FlowExecutionService.GetInstructionsForStep(e.FlowTrackingId, e.StepTrackingId, useNamedSession);

                        if (FlowExecutionService.IsShowFormType(flowInstr))
                        {
                            // render the next form in this page.
                            ShowNextForm(flowInstr);
                        }
                        else
                        {
                            // close this page? Not sure how we'd get here...
                            Console.WriteLine("Found Next Instruction was not a form instruction!");
                            viewModel.Submitted = true;
                            await Navigation.PopAsync();

                            DependencyService.Get <ISnackbar>().ShortAlert("Form submitted successfully.");

                            if (useNamedSession)
                            {
                                MessagingCenter.Send(this, Message.ACCOUNT_CREATED);
                            }
                        }
                    }
                    else
                    {
                        // did I missunderstand the structure?
                        Debug.WriteLine(e);
                    }
                }
                else
                {
                    if (viewModel.CanRunOffline)
                    {
                        var ret = await OfflineService.Instance.SaveOfflineFormSubmission(viewModel.ServiceCategoryId, data, outcomePathName, viewModel.FormInfo.FormRules);

                        viewModel.Submitted = true;
                        await Navigation.PopAsync();

                        DependencyService.Get <ISnackbar>().ShortAlert("Form saved, and will submit when online.");
                    }
                    else
                    {
                        await DisplayAlert("Error", "Connection lost. Please, try again later.", "OK");
                    }
                }
            } catch (Exception ex)
            {
                Debug.WriteLine("FormPage Submit---", ex.Message);
                await DisplayAlert("Error", "Something went wrong! Please try again later.", "OK");
            }
            finally
            {
                IsBusy           = false;
                button.IsEnabled = true;
            }
        }
Beispiel #16
0
 public PatientWardHistoryForm(Patient patient)
 {
     InitializeComponent();
     this.patient = patient;
     FormUtils.Init(this);
 }
 public DiagnosisForm(Diagnosis diagnosis)
 {
     InitializeComponent();
     FormUtils.Init(this);
     this.diagnosis = diagnosis;
 }
Beispiel #18
0
 public WardForm(Ward ward)
 {
     InitializeComponent();
     this.ward = ward;
     FormUtils.Init(this);
 }
Beispiel #19
0
        public IHttpActionResult Get()
        {
            try
            {
                var request = Context.AuthenticatedRequest;

                var formInfo = FormManager.GetFormInfoByGet(request);
                if (formInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var     logId         = request.GetQueryInt("logId");
                var     fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);
                LogInfo logInfo       = null;
                if (logId > 0)
                {
                    logInfo = LogManager.Repository.GetLogInfo(logId);
                }
                var list = new List <FieldInfo>();

                foreach (var fieldInfo in fieldInfoList)
                {
                    object value;
                    if (fieldInfo.FieldType == InputType.CheckBox.Value || fieldInfo.FieldType == InputType.SelectMultiple.Value)
                    {
                        value = logInfo != null
                            ? FormUtils.JsonDeserialize <List <string> >(logInfo.Get <string>(fieldInfo.Title))
                            : new List <string>();
                    }
                    //else if (fieldInfo.FieldType == InputType.Image.Value)
                    //{
                    //    value = logInfo != null
                    //        ? new List<string> {logInfo.Get<string>(fieldInfo.Title)}
                    //        : new List<string>();
                    //}
                    else if (fieldInfo.FieldType == InputType.Date.Value || fieldInfo.FieldType == InputType.DateTime.Value)
                    {
                        value = logInfo?.Get <DateTime>(fieldInfo.Title);
                    }
                    else
                    {
                        value = logInfo?.Get <string>(fieldInfo.Title);
                    }

                    if (value == null)
                    {
                        value = string.Empty;
                    }

                    list.Add(new FieldInfo
                    {
                        Id          = fieldInfo.Id,
                        Title       = fieldInfo.Title,
                        Description = fieldInfo.Description,
                        PlaceHolder = fieldInfo.PlaceHolder,
                        FieldType   = fieldInfo.FieldType,
                        Validate    = fieldInfo.Validate,
                        Columns     = fieldInfo.Columns,
                        Height      = fieldInfo.Height,
                        Items       = fieldInfo.Items,
                        Value       = value
                    });
                }

                var adminToken = Context.AdminApi.GetAccessToken(request.AdminId, request.AdminName, TimeSpan.FromDays(1));

                return(Ok(new
                {
                    Value = list,
                    AdminToken = adminToken
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Beispiel #20
0
        public IHttpActionResult Get()
        {
            try
            {
                var request  = Context.GetCurrentRequest();
                var formInfo = FormManager.GetFormInfoByGet(request);
                if (formInfo == null)
                {
                    return(NotFound());
                }
                if (!request.IsAdminLoggin || !request.AdminPermissions.HasSitePermissions(formInfo.SiteId, FormUtils.PluginId))
                {
                    return(Unauthorized());
                }

                var logId         = request.GetQueryInt("logId");
                var fieldInfoList = FieldManager.GetFieldInfoList(formInfo.Id);

                if (logId > 0)
                {
                    var logInfo = LogDao.GetLogInfo(logId);
                    foreach (var fieldInfo in fieldInfoList)
                    {
                        if (fieldInfo.FieldType == InputType.CheckBox.Value || fieldInfo.FieldType == InputType.SelectMultiple.Value)
                        {
                            fieldInfo.Value = FormUtils.JsonDeserialize <List <string> >(logInfo.GetString(fieldInfo.Title));
                        }
                        else if (fieldInfo.FieldType == InputType.Date.Value || fieldInfo.FieldType == InputType.DateTime.Value)
                        {
                            fieldInfo.Value = logInfo.GetDateTime(fieldInfo.Title);
                        }
                        else
                        {
                            fieldInfo.Value = logInfo.GetString(fieldInfo.Title);
                        }
                    }
                }
                else
                {
                    foreach (var fieldInfo in fieldInfoList)
                    {
                        if (fieldInfo.FieldType == InputType.CheckBox.Value || fieldInfo.FieldType == InputType.SelectMultiple.Value)
                        {
                            fieldInfo.Value = new List <string>();
                        }
                        else if (fieldInfo.FieldType == InputType.Date.Value || fieldInfo.FieldType == InputType.DateTime.Value)
                        {
                            fieldInfo.Value = null;
                        }
                        else
                        {
                            fieldInfo.Value = string.Empty;
                        }
                    }
                }

                return(Ok(new
                {
                    Value = fieldInfoList
                }));
            }
            catch (Exception ex)
            {
                return(InternalServerError(ex));
            }
        }
Beispiel #21
0
 public formAltaVuelo()
 {
     InitializeComponent();
     formUtils = FormUtils.GetInstance;
 }
Beispiel #22
0
 private void btnVolConProd_Click(object sender, EventArgs e)
 {
     FormUtils.MudarFormulario(this, new TelaBemVindo());
 }
 public WardsForm()
 {
     InitializeComponent();
     FormUtils.Init(this);
 }
Beispiel #24
0
 public ReacardsForm(Patient patient)
 {
     InitializeComponent();
     this.patient = patient;
     FormUtils.Init(this);
 }
 private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
 {
     FormUtils.ShowCenteredDialogForm <FrmCustomShortcutManagerHelp>(this);
 }
 public MainForm()
 {
     InitializeComponent();
     FormUtils.Init(this);
 }