Esempio n. 1
0
 public string ToListJson()
 {
     return(String.Format("{{Name:\"{0}\", UniqueName:\"{1}\", Description:\"{2}\", Category:{3}, Timeout:{4}, Results:[{5}]}}",
                          Name.EscapeJson(), UniqueName.EscapeJson(), Description.EscapeJson(), Category.ToListJson(),
                          Timeout.MaybeStruct(m => m.ToString(), () => "null"),
                          string.Join(",", Results.Select(it => it.ToListJson()).ToArray())));
 }
        public void SystemTypeAndLanguageTypeHaveSameNames()
        {
            var name1 = UniqueName.ForType <System.Int32>();
            var name2 = UniqueName.ForType <int>();

            Assert.Equal(name1, name2);
        }
        public void GenericClassWithDifferentTypesHaveUniqueNames()
        {
            var name1 = UniqueName.ForType <List <long> >();
            var name2 = UniqueName.ForType <List <int> >();

            Assert.NotEqual(name1, name2);
        }
        public void SameClassNameInDifferentNamespacesHaveUniqueNames()
        {
            var name1 = UniqueName.ForType <Http.Client>();
            var name2 = UniqueName.ForType <Tcp.Client>();

            Assert.NotEqual(name1, name2);
        }
Esempio n. 5
0
        private static void ImportServer
            (AddressSpaceDataBase.ServersTableRow svr, string targetNamespace, UniqueName uniqueName, List <NodeDesign> nodes)
        {
            string           name    = NewName;
            XmlQualifiedName sftName = new XmlQualifiedName(NewName, targetNamespace);
            ObjectDesign     sft     = CreateFolder(sftName, svr.URLString, svr.URL.Path);

            sft.References = new Reference[] { new Reference()
                                               {
                                                   IsInverse     = true,
                                                   ReferenceType = CreateXmlQualifiedName(Opc.Ua.BrowseNames.Organizes),
                                                   TargetId      = CreateXmlQualifiedName("ObjectsFolder")
                                               } };
            nodes.Add(sft);
            List <InstanceDesign> cldrn = new List <InstanceDesign>();

            foreach (AddressSpaceDataBase.TagsTableRow item in svr.GetTagsTableRows())
            {
                ImportTag(item, targetNamespace, uniqueName, sft.SymbolicName, nodes, cldrn);
            }
            sft.Children = new ListOfChildren()
            {
                Items = cldrn.ToArray()
            };
        }
Esempio n. 6
0
 public string ToListJson()
 {
     return(String.Format("{{Name:\"{0}\", UniqueName:\"{1}\", Fixtures:[{2}]}}",
                          Name.EscapeJson(), UniqueName.EscapeJson(),
                          String.Join(",", Fixtures.Select(it => it.ToListJson()).ToArray())
                          ));
 }
        public void NestedClassesHaveUniqueNames()
        {
            var name1 = UniqueName.ForType <Http.Client.Request>();
            var name2 = UniqueName.ForType <Http.Client.Response>();

            Assert.NotEqual(name1, name2);
        }
 private TestRecord(int id, PrimitiveLikeType lineItemID, string taxName, PrimitiveLikeType[] uniquePrimitives, string[] stringArray)
 {
     ID         = ID.WithValue(id).Verify();
     UniqueGuid = UniqueGuid.WithUncheckedValue(lineItemID).Verify();
     UniqueName = UniqueName.WithValue(taxName).Verify();
     UniqueNameWithDifferentDataDescriptors = UniqueNameWithDifferentDataDescriptors.WithValue(taxName).Verify();
     ArrayOfUniqueGuid = ArrayOfUniqueGuid.WithValue(uniquePrimitives).Verify();
     ArrayOfString     = ArrayOfString.WithValue(stringArray).Verify();
 }
Esempio n. 9
0
 public override int GetHashCode()
 {
     unchecked
     {
         int hashCode = (UniqueName != null ? UniqueName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (OperatorToken != null ? OperatorToken.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Version.GetHashCode();
         return(hashCode);
     }
 }
        /// <summary>
        /// Hàm thêm method Unique
        /// </summary>
        public void addUniqueName()
        {
            var newMethod = new UniqueName()
            {
                Setting     = "Unique Name - Change to GUID",
                HashSetting = "UniqueName"
            };

            methods.Add(newMethod);
        }
Esempio n. 11
0
 public virtual void AttachProperties(GridColumn gridColumn)
 {
     gridColumn.HeaderText           = Caption;
     gridColumn.EditFormColumnIndex  = EditColumnIndex - 1;
     gridColumn.AutoPostBackOnFilter = true;
     gridColumn.ShowFilterIcon       = false;
     if (UniqueName != null && UniqueName.Trim().Length > 0)
     {
         gridColumn.UniqueName = UniqueName.Trim().Replace(' ', '_');
     }
 }
Esempio n. 12
0
        public bool Equals(ExternalProjectReference other)
        {
            if (other == null)
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return(UniqueName.Equals(other.UniqueName, StringComparison.Ordinal));
        }
        public async Task InsertAsync(UniqueName item)
        {
            try
            {
                var config = new DynamoDBContextConfig {
                    TableNamePrefix = _tablePrefix, SkipVersionCheck = true
                };

                var context = new DynamoDBContext(_client, config);

                await context.SaveAsync(item);
            }
            catch (Exception ex)
            {
                Logger.LogException(ex, "Exception inserting Unique Name to Dynamo repository: ");
                throw;
            }
        }
Esempio n. 14
0
        private async Task AddUniqueNameAsync(MediaItem item)
        {
            // TODO: Cache this and update on new media item events.
            List <UniqueName> existingUniqueNames = await GetUniqueNamesAsync(item.AccountId);

            // Case sensitive
            if (existingUniqueNames.Select(x => x.LowerName).Contains(item.UniqueMediaName.ToLower()))
            {
                // Unique name already exists.
                return;
            }

            UniqueName name = new UniqueName
            {
                AccountId = item.AccountId,
                Name      = item.UniqueMediaName,
                LowerName = item.UniqueMediaName.ToLower(),
                DateAdded = DateTime.UtcNow,
            };
            await _uniquNameRepository.InsertAsync(name);
        }
Esempio n. 15
0
 public NextQueue GetQueue(IHttpContext context)
 {
     if (Type == ThreadQueueType.Single)
     {
         return(QueueGroup.Queues[0]);
     }
     else if (Type == ThreadQueueType.Multiple)
     {
         return(QueueGroup.Next());
     }
     else if (Type == ThreadQueueType.DataUnique)
     {
         string value = null;
         if (UniqueName != null)
         {
             if (string.Compare(UniqueName, "$path", true) == 0)
             {
                 value = context.Request.GetSourcePath();
             }
             else if (UniqueName.IndexOf("__") == 0)
             {
                 return(mUniqueQueueGroup.Has(UniqueName.GetHashCode()));
             }
             else
             {
                 value = context.Request.Header[UniqueName];
                 if (value == null)
                 {
                     context.Data.TryGetString(UniqueName, out value);
                 }
             }
         }
         if (value == null)
         {
             value = context.Request.GetSourceUrl();
         }
         return(mUniqueQueueGroup.Has(value.GetHashCode()));
     }
     return(QueueGroup.Next());
 }
Esempio n. 16
0
        public String ItemType()
        {
            switch (assemblyType)
            {
            case AssemblyType.Enum:
                return("enum type");

            case AssemblyType.EnumValue:
                return("enum value");

            case AssemblyType.Property:
            case AssemblyType.Primitive:
            case AssemblyType.Class:
            case AssemblyType.Struct:
            case AssemblyType.Constructor:
            case AssemblyType.Field:
                return(assemblyType.ToString().ToLower());

            case AssemblyType.Method:
                return(UniqueName.Contains("implop") ? "implicit operator" : "method");
            }

            return("unclassified(todo)");
        }
Esempio n. 17
0
        /// <inheritdoc />
        public void Register <TInterface>(
            IServiceCollection services,
            string name) where TInterface : class
        {
            var type = typeof(TInterface).Name;

            var uniqueName = $"{name}{UniqueName.ForType<TInterface>()}";

            IHttpClientBuilder httpClientBuilder = services
                                                   .AddHttpClient(uniqueName) // unique name
                                                   .AddTypedClient(
                (client, serviceProvider) => WrapIfNeeded(RestService.For <TInterface>(client, _refitSettings), name));

            httpClientBuilder
            .ConfigureHttpClient(client => client.BaseAddress = new Uri(_rootUrl));

            if (_registeredDelegatingHandlers != null)
            {
                foreach (var handler in _registeredDelegatingHandlers)
                {
                    handler.Invoke(httpClientBuilder);
                }
            }
        }
Esempio n. 18
0
 /// <summary>
 /// override
 /// </summary>
 /// <returns></returns>
 public override int GetHashCode()
 {
     return(UniqueName.GetHashCode() ^ UpdatedTime.GetHashCode() ^ ExpirationTime.GetHashCode() ^ IsOptimized.GetHashCode());
 }
 /// <summary>
 /// Gets the name, or 'None'.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>System.String.</returns>
 public static string GetNameOrNone(UniqueName item)
 {
     return(item == null ? Constants.NONE : item.Name);
 }
Esempio n. 20
0
 public override int GetHashCode()
 {
     return(UniqueName.GetHashCode());
 }
Esempio n. 21
0
        /// <summary>
        /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
        /// </summary>
        /// <returns>
        /// A value that indicates the relative order of the objects being compared. The return value has these meanings: Value Meaning Less than zero This instance is less than <paramref name="obj"/>. Zero This instance is equal to <paramref name="obj"/>. Greater than zero This instance is greater than <paramref name="obj"/>.
        /// </returns>
        /// <param name="obj">An object to compare with this instance. </param><exception cref="T:System.ArgumentException"><paramref name="obj"/> is not the same type as this instance. </exception><filterpriority>2</filterpriority>
        public int CompareTo(object obj)
        {
            var item = (IDataItem)obj;

            return(UniqueName.CompareTo(item.ItemName()));
        }
Esempio n. 22
0
        public bool Equals(GeneralUser input)
        {
            if (input == null)
            {
                return(false);
            }

            return
                ((
                     MembershipId == input.MembershipId ||
                     (MembershipId.Equals(input.MembershipId))
                     ) &&
                 (
                     UniqueName == input.UniqueName ||
                     (UniqueName != null && UniqueName.Equals(input.UniqueName))
                 ) &&
                 (
                     NormalizedName == input.NormalizedName ||
                     (NormalizedName != null && NormalizedName.Equals(input.NormalizedName))
                 ) &&
                 (
                     DisplayName == input.DisplayName ||
                     (DisplayName != null && DisplayName.Equals(input.DisplayName))
                 ) &&
                 (
                     ProfilePicture == input.ProfilePicture ||
                     (ProfilePicture.Equals(input.ProfilePicture))
                 ) &&
                 (
                     ProfileTheme == input.ProfileTheme ||
                     (ProfileTheme.Equals(input.ProfileTheme))
                 ) &&
                 (
                     UserTitle == input.UserTitle ||
                     (UserTitle.Equals(input.UserTitle))
                 ) &&
                 (
                     SuccessMessageFlags == input.SuccessMessageFlags ||
                     (SuccessMessageFlags.Equals(input.SuccessMessageFlags))
                 ) &&
                 (
                     IsDeleted == input.IsDeleted ||
                     (IsDeleted != null && IsDeleted.Equals(input.IsDeleted))
                 ) &&
                 (
                     About == input.About ||
                     (About != null && About.Equals(input.About))
                 ) &&
                 (
                     FirstAccess == input.FirstAccess ||
                     (FirstAccess != null && FirstAccess.Equals(input.FirstAccess))
                 ) &&
                 (
                     LastUpdate == input.LastUpdate ||
                     (LastUpdate != null && LastUpdate.Equals(input.LastUpdate))
                 ) &&
                 (
                     LegacyPortalUid == input.LegacyPortalUid ||
                     (LegacyPortalUid.Equals(input.LegacyPortalUid))
                 ) &&
                 (
                     Context == input.Context ||
                     (Context != null && Context.Equals(input.Context))
                 ) &&
                 (
                     PsnDisplayName == input.PsnDisplayName ||
                     (PsnDisplayName != null && PsnDisplayName.Equals(input.PsnDisplayName))
                 ) &&
                 (
                     XboxDisplayName == input.XboxDisplayName ||
                     (XboxDisplayName != null && XboxDisplayName.Equals(input.XboxDisplayName))
                 ) &&
                 (
                     FbDisplayName == input.FbDisplayName ||
                     (FbDisplayName != null && FbDisplayName.Equals(input.FbDisplayName))
                 ) &&
                 (
                     ShowActivity == input.ShowActivity ||
                     (ShowActivity != null && ShowActivity.Equals(input.ShowActivity))
                 ) &&
                 (
                     Locale == input.Locale ||
                     (Locale != null && Locale.Equals(input.Locale))
                 ) &&
                 (
                     LocaleInheritDefault == input.LocaleInheritDefault ||
                     (LocaleInheritDefault != null && LocaleInheritDefault.Equals(input.LocaleInheritDefault))
                 ) &&
                 (
                     LastBanReportId == input.LastBanReportId ||
                     (LastBanReportId.Equals(input.LastBanReportId))
                 ) &&
                 (
                     ShowGroupMessaging == input.ShowGroupMessaging ||
                     (ShowGroupMessaging != null && ShowGroupMessaging.Equals(input.ShowGroupMessaging))
                 ) &&
                 (
                     ProfilePicturePath == input.ProfilePicturePath ||
                     (ProfilePicturePath != null && ProfilePicturePath.Equals(input.ProfilePicturePath))
                 ) &&
                 (
                     ProfilePictureWidePath == input.ProfilePictureWidePath ||
                     (ProfilePictureWidePath != null && ProfilePictureWidePath.Equals(input.ProfilePictureWidePath))
                 ) &&
                 (
                     ProfileThemeName == input.ProfileThemeName ||
                     (ProfileThemeName != null && ProfileThemeName.Equals(input.ProfileThemeName))
                 ) &&
                 (
                     UserTitleDisplay == input.UserTitleDisplay ||
                     (UserTitleDisplay != null && UserTitleDisplay.Equals(input.UserTitleDisplay))
                 ) &&
                 (
                     StatusText == input.StatusText ||
                     (StatusText != null && StatusText.Equals(input.StatusText))
                 ) &&
                 (
                     StatusDate == input.StatusDate ||
                     (StatusDate != null && StatusDate.Equals(input.StatusDate))
                 ) &&
                 (
                     ProfileBanExpire == input.ProfileBanExpire ||
                     (ProfileBanExpire != null && ProfileBanExpire.Equals(input.ProfileBanExpire))
                 ) &&
                 (
                     BlizzardDisplayName == input.BlizzardDisplayName ||
                     (BlizzardDisplayName != null && BlizzardDisplayName.Equals(input.BlizzardDisplayName))
                 ) &&
                 (
                     SteamDisplayName == input.SteamDisplayName ||
                     (SteamDisplayName != null && SteamDisplayName.Equals(input.SteamDisplayName))
                 ) &&
                 (
                     StadiaDisplayName == input.StadiaDisplayName ||
                     (StadiaDisplayName != null && StadiaDisplayName.Equals(input.StadiaDisplayName))
                 ) &&
                 (
                     TwitchDisplayName == input.TwitchDisplayName ||
                     (TwitchDisplayName != null && TwitchDisplayName.Equals(input.TwitchDisplayName))
                 ) &&
                 (
                     CachedBungieGlobalDisplayName == input.CachedBungieGlobalDisplayName ||
                     (CachedBungieGlobalDisplayName != null && CachedBungieGlobalDisplayName.Equals(input.CachedBungieGlobalDisplayName))
                 ) &&
                 (
                     CachedBungieGlobalDisplayNameCode == input.CachedBungieGlobalDisplayNameCode ||
                     (CachedBungieGlobalDisplayNameCode.Equals(input.CachedBungieGlobalDisplayNameCode))
                 ));
        }
Esempio n. 23
0
 public void TrimUniqueName()
 {
     UniqueName = UniqueName?.Trim();
 }
Esempio n. 24
0
        private void ExportButton_Click(object sender, RoutedEventArgs e)
        {
            var screen = new OpenFileDialog();

            if (screen.ShowDialog() == true)
            {
                var url = screen.FileName;

                using (StreamReader sr = new StreamReader(url))
                {
                    while (sr.Peek() >= 0)
                    {
                        string[] tokens_sub   = sr.ReadLine().Split(new string[] { " - " }, StringSplitOptions.None);
                        string[] tokens_space = tokens_sub[0].Split(new string[] { " " }, StringSplitOptions.None);
                        string[] tokens_Args  = tokens_sub[1].Split(new string[] { " " }, StringSplitOptions.None);

                        string first_word = tokens_space[0];

                        if (first_word == "Replace")
                        {
                            var _replaceArgs = new ReplaceArgs();
                            _replaceArgs.Needle = tokens_Args[1];
                            _replaceArgs.Hammer = tokens_Args[3];

                            var _action = new ReplaceAction();

                            var _replacAction = _action as StringAction;

                            var _cloneReplaceAction = _replacAction.Clone();
                            _cloneReplaceAction.Args = _replaceArgs;

                            ActionListBox.Items.Add(_cloneReplaceAction);
                        }
                        else if (first_word == "New")
                        {
                            var _newcaseArgs = new NewCaseArgs();
                            _newcaseArgs.Needle = tokens_Args[3];

                            var _action = new NewCaseAction();

                            var _newcaseAction = _action as StringAction;

                            var _cloneNewCaseAction = _newcaseAction.Clone();
                            _cloneNewCaseAction.Args = _newcaseArgs;

                            ActionListBox.Items.Add(_cloneNewCaseAction);
                        }
                        else if (first_word == "Fullname")
                        {
                            var _fullnameArgs = new FullnameNormalizeArgs();
                            _fullnameArgs.Needle = tokens_Args[3];

                            var _action = new FullnameNormalizeAction();

                            var _fullnameAction = _action as StringAction;

                            var _cloneFullNameAction = _fullnameAction.Clone();
                            _cloneFullNameAction.Args = _fullnameArgs;

                            ActionListBox.Items.Add(_cloneFullNameAction);
                        }
                        else if (first_word == "Move")
                        {
                            var _moveArgs = new MoveArgs();
                            _moveArgs.Needle = tokens_Args[2];

                            var _action = new MoveAction();

                            var _moveAction = _action as StringAction;

                            var _cloneMoveAction = _moveAction.Clone();
                            _cloneMoveAction.Args = _moveArgs;

                            ActionListBox.Items.Add(_cloneMoveAction);
                        }
                        else if (first_word == "Unique")
                        {
                            var _uniqueArgs = new UniqueNameArgs();
                            _uniqueArgs.Needle = tokens_Args[1];
                            _uniqueArgs.Hammer = tokens_Args[3];

                            var _action = new UniqueName();

                            var _uniqueAction = _action as StringAction;

                            var _cloneUniqueAction = _uniqueAction.Clone();
                            _cloneUniqueAction.Args = _uniqueArgs;

                            ActionListBox.Items.Add(_cloneUniqueAction);
                        }
                        else
                        {
                            var _removeArgs = new RemoveActionArgs();
                            _removeArgs.Needle = tokens_Args[2];

                            var _action = new RemoveAction();

                            var _removeAction = _action as StringAction;

                            var _cloneRemoveAction = _removeAction.Clone();
                            _cloneRemoveAction.Args = _removeArgs;

                            ActionListBox.Items.Add(_cloneRemoveAction);
                        }
                    }
                }
                System.Windows.MessageBox.Show("Exported!");
            }
        }
 /// <summary>
 /// Gets the name, or empty.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <returns>System.String.</returns>
 public static string GetNameOrEmpty(UniqueName item)
 {
     return(item == null ? string.Empty : item.Name);
 }
Esempio n. 26
0
 public StreamDataKey CreateKey() => new StreamDataKey(StreamType, UniqueName.ToLower());
Esempio n. 27
0
 private static void ImportTag
 (
     AddressSpaceDataBase.TagsTableRow parentItem,
     string targetNamespace,
     UniqueName uniqueName,
     XmlQualifiedName parentObject,
     List <NodeDesign> nodes,
     List <InstanceDesign> parentChildren
 )
 {
     Opc.Da.BrowseElement pbe = parentItem.GetBrowseElement();
     if (pbe.IsItem)
     {
         VariableDesign var = new VariableDesign()
         {
             SymbolicName = new XmlQualifiedName(uniqueName.GetUniqueName(pbe.Name), targetNamespace),
             DisplayName  = new LocalizedText()
             {
                 Value = pbe.Name
             },
             DataType       = GetBaseDataType(),
             TypeDefinition = GetBaseDataVariableType(),
             Description    = new LocalizedText()
             {
                 Value = pbe.ItemName
             },
             AccessLevel          = AccessLevel.ReadWrite,
             AccessLevelSpecified = true,
             ValueRank            = ValueRank.Scalar,
             ValueRankSpecified   = true,
             WriteAccess          = 0
         };
         parentChildren.Add(var);
         SortedDictionary <int, Opc.Da.ItemProperty> prprts = new SortedDictionary <int, Opc.Da.ItemProperty>();
         foreach (Opc.Da.ItemProperty item in pbe.Properties)
         {
             prprts.Add(item.ID.Code, item);
         }
         if (prprts.ContainsKey(Opc.Da.Property.DATATYPE.Code))
         {
             GetDATATYPE(var, prprts[Opc.Da.Property.DATATYPE.Code]);
         }
         GetEUTYPE(var, prprts);
         if (prprts.ContainsKey(Opc.Da.Property.ACCESSRIGHTS.Code))
         {
             GetACCESSRIGHTS(var, prprts[Opc.Da.Property.ACCESSRIGHTS.Code]);
         }
     }
     else
     {
         ObjectDesign sf = CreateFolder(new XmlQualifiedName(uniqueName.GetUniqueName(pbe.Name), targetNamespace), pbe.ItemName, pbe.Name);
         nodes.Add(sf);
         List <InstanceDesign> myChildren = new List <InstanceDesign>();
         foreach (AddressSpaceDataBase.TagsTableRow item in parentItem.GetTagsTableRows())
         {
             ImportTag(item, targetNamespace, uniqueName, sf.SymbolicName, nodes, myChildren);
         }
         sf.Children = new ListOfChildren()
         {
             Items = myChildren.ToArray()
         };
         sf.References = new Reference[]
         { new Reference()
           {
               IsInverse     = true,
               ReferenceType = CreateXmlQualifiedName(Opc.Ua.BrowseNames.Organizes),
               TargetId      = parentObject
           } };
     }
 }
Esempio n. 28
0
 public string ToItemJson()
 {
     return(String.Format("{{Fixture:{4}, Timeout:{5}, Description:\"{2}\", Category:{3}, UniqueName:\"{1}\", Name:\"{0}\", }}",
                          Name.EscapeJson(), UniqueName.EscapeJson(), Description.EscapeJson(), Category.ToListJson(), Fixture.ToItemJson(), Timeout));
 }
        //Core Logic
        protected override void Execute(CodeActivityContext context)
        {
            //Variable Initializing
            var strPath        = Path.Get(context);
            var strHealthyPath = strPath + "\\Healthy";
            var strErrorPath   = strPath + "\\Quarantine";

            var strUniqueName = UniqueName.Get(context);
            var strMessage    = Message.Get(context);
            var strLevel      = this.Level;

            //Check whether the given directory/path exist or not
            //Create User Defined Path - if not exist
            if (!Directory.Exists(strPath))
            {
                Directory.CreateDirectory(strPath);
            }

            //Create Healthy folder -  if not exist
            if (!Directory.Exists(strHealthyPath))
            {
                Directory.CreateDirectory(strHealthyPath);
            }

            //Log message is converted to HTML format and saved as HTML file
            StringBuilder buildHtml = new StringBuilder();

            buildHtml.Append("<div id='container' style='font-size:15px;font-family:arial;width: 100%;margin: 0;display: table;'><div id='row' style='display: table-row;'><div style='max-width:400px;float:left;'><div id='left' style='padding:2px;display: table-cell;text-transform: uppercase;font-weight: bold;'>");
            buildHtml.Append("<p>[ " + System.DateTime.Now + " : " + GetTzAbbreviation(TimeZone.CurrentTimeZone.StandardName) + " ]</p>");
            buildHtml.Append("</div><div style='padding:2px;display: table-cell;text-transform: uppercase;font-weight: bold;'>--</div><div id='middle' style='width:75px;text-align:center;padding: 2px;display: table-cell;text-transform: uppercase;font-weight: bold;'>");
            buildHtml.Append("<p>[ " + Convert.ToString(strLevel) + " ]");
            buildHtml.Append("</div><div style='padding:2px;display: table-cell;text-transform: uppercase;font-weight: bold;'>--</div></div><div>");

            switch (Convert.ToString(strLevel))
            {
            case "Error":
            {
                if (!Directory.Exists(strErrorPath))
                {
                    Directory.CreateDirectory(strErrorPath);
                }

                if (File.Exists(strHealthyPath + "\\" + strUniqueName + ".html"))
                {
                    File.Move(strHealthyPath + "\\" + strUniqueName + ".html", strErrorPath + "\\" + strUniqueName + ".html");
                }
                buildHtml.Append("<div id='right' style='margin:0;width:50%;padding:2px;display: table-cell;text-align:justify;text-transform: capitalize;font-weight: bold;color:red;'>");
                break;
            }

            case "Fatal":
            {
                if (!Directory.Exists(strErrorPath))
                {
                    Directory.CreateDirectory(strErrorPath);
                }

                if (File.Exists(strHealthyPath + "\\" + strUniqueName + ".html"))
                {
                    File.Move(strHealthyPath + "\\" + strUniqueName + ".html", strErrorPath + "\\" + strUniqueName + ".html");
                }
                buildHtml.Append("<div id='right' style='margin:0;width:50%;padding:2px;display: table-cell;text-align:justify;text-transform: capitalize;font-weight: bold;color:#770be2;'>");
                break;
            }

            case "Trace":
            {
                buildHtml.Append("<div id='right' style='margin:0;width:50%;padding:2px;display: table-cell;text-align:justify;text-transform: capitalize;font-weight: bold;color:#2283D8;'>");
                break;
            }

            case "Warn":
            {
                buildHtml.Append("<div id='right' style='margin:0;width:50%;padding:2px;display: table-cell;text-align:justify;text-transform: capitalize;font-weight: bold;color:#f97822;'>");
                break;
            }

            default:
            {
                buildHtml.Append("<div id='right' style='margin:0;width:50%;padding:2px;display: table-cell;text-align:justify;text-transform: capitalize;font-weight: bold;color:#8E8991;'>");
                break;
            }
            }

            buildHtml.Append("<p>" + strMessage + "</p></div></div></div></div>");
            string sHtml = buildHtml.ToString();

            //This block is used when the log file are created for first time
            if (File.Exists(strHealthyPath + "\\" + strUniqueName + ".html"))
            {
                System.IO.File.AppendAllText(strHealthyPath + "\\" + strUniqueName + ".html", sHtml);
            }
            else if (File.Exists(strErrorPath + "\\" + strUniqueName + ".html") || Convert.ToString(strLevel).Contains("Error") || Convert.ToString(strLevel).Contains("Fatal"))
            {
                System.IO.File.AppendAllText(strErrorPath + "\\" + strUniqueName + ".html", sHtml);
            }
            else
            {
                System.IO.File.AppendAllText(strHealthyPath + "\\" + strUniqueName + ".html", sHtml);
            }
        }
Esempio n. 30
0
 public string ToItemJson()
 {
     return(String.Format("{{Assembly:{4}, Category:{3}, Description:\"{2}\", UniqueName:\"{1}\", Name:\"{0}\",}}",
                          Name.EscapeJson(), UniqueName.EscapeJson(), Description.EscapeJson(), Category.ToListJson(), Assembly.ToItemJson()
                          ));
 }