コード例 #1
0
        public Error AddErroDetail(Error error)
        {
            if (error.Code.Equals(Code, StringComparison.InvariantCultureIgnoreCase))
            {
                throw new ArgumentNullException(nameof(error.Code));
            }

            if (Details is null)
            {
                Details = new List <Error>();
            }

            if (Details.Any(x => x.Code.Equals(error.Code, StringComparison.InvariantCultureIgnoreCase)))
            {
                return(error);
            }

            Details.Add(error);

            return(this);
        }
コード例 #2
0
ファイル: CheckResult.cs プロジェクト: AndreiRinea/Faross
        public CheckResult(
            CheckBase check,
            DateTimeOffset time,
            CheckOutcome outcome,
            IReadOnlyCollection <ConditionResultDetail> details)
        {
            if (outcome == default(CheckOutcome))
            {
                throw new ArgumentOutOfRangeException(nameof(outcome));
            }

            Check   = check ?? throw new ArgumentNullException(nameof(check));
            Time    = time;
            Outcome = outcome;
            Details = details ?? throw new ArgumentNullException(nameof(details));

            if (Details.Any(d => d == null))
            {
                throw new ArgumentException("details contains a null");
            }
        }
コード例 #3
0
        public string GetEntityType()
        {
            if (Details == null || !Details.Any())
            {
                //throw new InvalidOperationException("Installation pack contains no details (no services).");
                return(null);
            }

            var serviceType = Details.First().TypeServ;

            if (serviceType.Equals("v", StringComparison.OrdinalIgnoreCase))
            {
                return(serviceType);
            }

            if (serviceType.Equals("i", StringComparison.OrdinalIgnoreCase))
            {
                return(serviceType);
            }

            throw new InvalidOperationException("The type of installation pack is not supported.");
        }
コード例 #4
0
ファイル: Results.cs プロジェクト: BrayRider/ResourceOne
        public override string ToString()
        {
            if ((Details == null) || (!Details.Any()))
            {
                return(string.Format("<result type='{0}' timeStamp='{1}' correlationId='{2}'><message>{3}</message></result>", Outcome, DateTime.UtcNow, CorrelationId.ToString(), Message));
            }
            else
            {
                StringBuilder builder = new StringBuilder();

                builder.AppendFormat("<result type='{0}' timeStamp='{1}' correlationId='{2}'><message>{3}</message>", Outcome, DateTime.UtcNow, CorrelationId.ToString(), Message);
                builder.Append("<details>");

                foreach (var entry in Details)
                {
                    builder.AppendFormat("<detail key='{0}'>{1}</detail>", entry.Key, entry.Value);
                }

                builder.Append("</details>");
                builder.Append("</result>");

                return(builder.ToString());
            }
        }
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (DefaultLanguageCode != null)
     {
         writer.WritePropertyName("defaultLanguageCode");
         writer.WriteStringValue(DefaultLanguageCode.Value.ToString());
     }
     if (VisualFeatures != null && VisualFeatures.Any())
     {
         writer.WritePropertyName("visualFeatures");
         writer.WriteStartArray();
         foreach (var item in VisualFeatures)
         {
             writer.WriteStringValue(item.ToString());
         }
         writer.WriteEndArray();
     }
     if (Details != null && Details.Any())
     {
         writer.WritePropertyName("details");
         writer.WriteStartArray();
         foreach (var item in Details)
         {
             writer.WriteStringValue(item.ToString());
         }
         writer.WriteEndArray();
     }
     writer.WritePropertyName("@odata.type");
     writer.WriteStringValue(ODataType);
     if (Name != null)
     {
         writer.WritePropertyName("name");
         writer.WriteStringValue(Name);
     }
     if (Description != null)
     {
         writer.WritePropertyName("description");
         writer.WriteStringValue(Description);
     }
     if (Context != null)
     {
         writer.WritePropertyName("context");
         writer.WriteStringValue(Context);
     }
     if (Inputs != null && Inputs.Any())
     {
         writer.WritePropertyName("inputs");
         writer.WriteStartArray();
         foreach (var item in Inputs)
         {
             writer.WriteObjectValue(item);
         }
         writer.WriteEndArray();
     }
     if (Outputs != null && Outputs.Any())
     {
         writer.WritePropertyName("outputs");
         writer.WriteStartArray();
         foreach (var item in Outputs)
         {
             writer.WriteObjectValue(item);
         }
         writer.WriteEndArray();
     }
     writer.WriteEndObject();
 }
コード例 #6
0
 /// <summary>
 /// Validates the over all final status, in regards to any responsibilities and checks
 /// </summary>
 /// <param name="requiredResponsibilities">A list of responsibilities that will result in final status of ERROR if any are not returning OK</param>
 public void ValidateStatus(string[] requiredResponsibilities)
 {
     Status = requiredResponsibilities != null
         ? Responsibilities.Any(x => requiredResponsibilities.Any(y => x.Key == y) && x.Value != StatusTypes.OK) ? StatusTypes.Error : Details.Any(x => x.Value != StatusTypes.OK) ? StatusTypes.Degraded : StatusTypes.OK
         : Details.Any(x => x.Value != StatusTypes.OK) ? StatusTypes.Degraded : StatusTypes.OK;
 }
コード例 #7
0
        public string ShowDialog(IWin32Window owner)
        {
            using (var f = new Form()) {
                f.FormBorderStyle = FormBorderStyle.FixedDialog;
                f.MinimizeBox     = false;
                f.MaximizeBox     = false;
                f.ShowInTaskbar   = false;
                f.BackColor       = SystemColors.Window;
                f.StartPosition   = FormStartPosition.CenterParent;
                f.Text            = Title;

                int leftMargin = 11;
                if (Icon !=
                    null)
                {
                    var box = new PictureBox {
                        Left   = 7,
                        Top    = 7,
                        Width  = 32,
                        Height = 32,
                        Image  = Icon
                    };
                    f.Controls.Add(box);
                    leftMargin = box.Right + 7;
                }

                int y = 10;

                var mainInstructionFont  = new Font("Segoe UI", 12);
                var mainInstructionColor = Color.FromArgb(0x003399);
                var regularFont          = new Font("Segoe UI", 9);

                AddLabels(f, leftMargin, ref y, Message, mainInstructionFont, mainInstructionColor, 0);

                if (Details != null && Details.Any())
                {
                    y += 10;
                    AddLabels(f, leftMargin, ref y, Details, regularFont, Color.Black, 1);
                }

                y += 71;

                var controls = f.Controls.Cast <Control>();
                f.ClientSize = new Size(
                    Math.Max(MAX_WIDTH, controls.Select(x => x.Right).Max()) + leftMargin,
                    y
                    );

                var buttonPanelHeight = 42;

                var separator = new Panel {
                    Left      = 0, Top = f.ClientSize.Height - buttonPanelHeight - 1, Width = f.Width, Height = 1,
                    Anchor    = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                    BackColor = Color.FromArgb(unchecked ((int)0xFFDFDFDF))
                };
                f.Controls.Add(separator);

                var buttonPanel = new Panel {
                    Left      = 0, Top = f.ClientSize.Height - buttonPanelHeight, Width = f.Width, Height = buttonPanelHeight,
                    Anchor    = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right,
                    BackColor = Color.FromArgb(unchecked ((int)0xFFF0F0F0))
                };
                f.Controls.Add(buttonPanel);

                var    buttonCtls    = new List <Button>();
                string clickedButton = null;
                foreach (var btnText in Buttons)
                {
                    var button = new Button {
                        Top  = 7, Height = 26, Anchor = AnchorStyles.Bottom | AnchorStyles.Right, Text = btnText,
                        Font = regularFont, UseVisualStyleBackColor = true
                    };
                    button.Width  = Math.Max(88, TextRenderer.MeasureText(btnText, regularFont).Width + 25);
                    button.Click += (sender, e) => {
                        clickedButton = button.Text;
                        f.Close();
                    };
                    buttonCtls.Add(button);
                }

                var buttonSpacing = 7;
                var buttonsWidth  = buttonCtls.Sum(x => x.Width) + 7 * (buttonCtls.Count - 1);
                var buttonsLeft   = f.ClientSize.Width - 11 - buttonsWidth;
                foreach (var ctl in buttonCtls)
                {
                    ctl.Left     = buttonsLeft;
                    buttonsLeft += ctl.Width + buttonSpacing;
                    buttonPanel.Controls.Add(ctl);
                }
                f.AcceptButton = buttonCtls.First();
                f.CancelButton = buttonCtls.Last();

                f.ShowDialog(owner);
                return(clickedButton);
            }
        }
コード例 #8
0
ファイル: T_Report.cs プロジェクト: wangcai123512/wangcai
        /// <summary>
        /// 获取数据
        /// </summary>
        /// <returns></returns>
        public string GetDetailsJSON_PL()
        {
            StringBuilder   strJson = new StringBuilder("[");
            T_ReportDetails curRec  = new T_ReportDetails();
            Dictionary <int, List <int> > config = new Dictionary <int, List <int> >();

            config.Add(6001, new List <int>()
            {
                6401, 6403
            });
            config.Add(1, new List <int>()
            {
                6051, 6402, 6601, 6602, 6603
            });
            config.Add(2, new List <int>());
            config.Add(3, new List <int>()
            {
                6801
            });
            config.Add(4, new List <int>());

            string strRowFmt = "{{\"Acc_Name\":\"{0}\",\"children\":{1},\"Money\":{2},\"Acc_Code\":\"{3}\"}},";

            if (Details.Any(i => i.Code.Equals("6001")))
            {
                decimal curVal = 0;
                decimal rtVal  = 0;
                foreach (KeyValuePair <int, List <int> > kvPair in config)
                {
                    switch (kvPair.Key)
                    {
                    case 6001:
                        curRec = Details.First(i => i.Code.Equals("6001"));
                        curVal = curRec.EndingValue;
                        strJson.AppendFormat(strRowFmt, curRec.Name, GenJson_PL(strRowFmt, kvPair, ref curVal), curRec.EndingValue, curRec.Code);
                        break;

                    case 1:
                        rtVal = curVal;
                        strJson.AppendFormat(strRowFmt, "主营业务利润", GenJson_PL(strRowFmt, kvPair, ref curVal), rtVal, "1");
                        break;

                    case 2:
                        rtVal = curVal;
                        strJson.AppendFormat(strRowFmt, "营业利润", GenJson_PL(strRowFmt, ref curVal), rtVal, "2");
                        break;

                    case 3:
                        rtVal = curVal;
                        strJson.AppendFormat(strRowFmt, "利润总额", GenJson_PL(strRowFmt, kvPair, ref curVal), rtVal, "3");
                        break;

                    case 4:
                        rtVal = curVal;
                        strJson.AppendFormat(strRowFmt, "净利润", GenJson_PL(strRowFmt, kvPair, ref curVal), rtVal, "4");
                        break;

                    default:
                        break;
                    }
                }
                strJson.Remove(strJson.Length - 1, 1);
                strJson.Append("]");
                return(strJson.ToString());
            }
            else
            {
                return("[]");
            }
        }