示例#1
0
        private void SetLabelContent(List <DTOVariableContent> dtoVC)
        {
            try
            {
                if (rjConnection.ConnectionID <= 0)
                {
                    return;
                }

                ReaPi.EErrorCode         error = ReaPi.RemoveLabelContent(rjConnection.LabelContentHandle);
                ReaPi.LabelContentHandle labelContentHandle = ReaPi.CreateLabelContent();

                rjConnection.LabelContentHandle = labelContentHandle;

                if (labelContentHandle >= (ReaPi.LabelContentHandle) 0)
                {
                    foreach (var lp in dtoVC)
                    {
                        error = ReaPi.PrepareLabelContent(labelContentHandle, 1, lp.GroupName, lp.ObjectName, lp.ContentName, lp.ContentValue);

                        if (error != ReaPi.EErrorCode.OK)
                        {
                            SendToDashboard(MessageType.LOG, "Error: Nie można przygotować danych dla pola: {lp.ContentName}", error.ToString(), null);
                        }
                    }

                    ReaPi.ResponseHandle response = ReaPi.SetLabelContent(rjConnection.ConnectionID, labelContentHandle);

                    if (response < 0)
                    {
                        SendToDashboard(MessageType.LOG, "Error: Nie można wysłać danych dla etykiety", null, null);
                    }
                    else
                    {
                        SendToDashboard(MessageType.LOG, $"Wysłano zawartość rekordu: {database.ActualRecord.ToString()}", null, null);

                        Record record = new Record();
                        record.Id      = database.ActualRecord;
                        record.IsError = false;

                        _queueRecords.Enqueue(record);
                    }
                }
                else
                {
                    SendToDashboard(MessageType.LOG, "Error: Nie można przygotować danych dla etykiety", null, null);
                }
            }
            catch (FormatException ex)
            {
                SendToDashboard(MessageType.ERROR, "Function SetLabelContent()", ex.ToString(), ex.Message.ToString());
            }
        }