Example #1
0
 private static string ConvertValue(String value)
 {
     Dictionary<String, String> replacements = new Dictionary<string, string>();
     replacements.Add("&sp;", " ");
     replacements.Add("&1uc;", "{-|}");
     replacements.Add("&amp;", "&");
     replacements.Add("&bs;", "{# BackSpace}");
     replacements.Add("&cr;", "{# Return}");
     replacements.Add("&uc;", "{MODE:CAPS}");
     replacements.Add("&lc;", "{MODE:LOWER}");
     replacements.Add("&dw;", "{# Control_L(BackSpace)}");
     replacements.Add("\\", "\\\\");
     replacements.Add("\"", "\\\"");
     foreach (string key in replacements.Keys.OrderByDescending(_k=>_k.Length))
     {
         value = value.Replace(key, replacements[key]);
     }
     if (value.Contains("&+i;"))
     {
         value = String.Format("{0}{{^}}", value.Replace("&+i;", ""));
     }
     if (value.Contains("&rb;"))
     {
         value = String.Format("{{^}}{0}", value.Replace("&rb;", ""));
     }
     return value.Trim();
 }
Example #2
0
            public List<String> publisher_update_task( String api, String topic, List<string> pub_uris) 
            {
                XmlRpcValue l = new XmlRpcValue();
                l.Set(0, api);
                l.Set(1, "");
                //XmlRpcValue ll = new XmlRpcValue();
                //l.Set(0, ll);
                for(int i = 0; i < pub_uris.Count; i++)
                {
                    XmlRpcValue ll = new XmlRpcValue(pub_uris[i]);
                    l.Set(i + 1, ll);
                }


                XmlRpcValue args = new XmlRpcValue();
                args.Set(0, "master");
                args.Set(1, topic);
                args.Set(2, l);
                       XmlRpcValue result = new XmlRpcValue(new XmlRpcValue(), new XmlRpcValue(), new XmlRpcValue(new XmlRpcValue())),
                        payload = new XmlRpcValue();

                 Ros_CSharp.master.host = api.Replace("http://","").Replace("/","").Split(':')[0];
                 Ros_CSharp.master.port =  int.Parse( api.Replace("http://", "").Replace("/", "").Split(':')[1]);
                 Ros_CSharp.master.execute("publisherUpdate", args, result, payload, false );
                
                return new List<string>(new []{"http://ERIC:1337"});
            }
Example #3
0
        /// <summary>
        /// 修改已有的文件名。
        /// </summary>
        /// <param name="oldWjm">旧文件名</param>
        /// <param name="newWjm">新文件名</param>
        /// <returns>是否修改成功</returns>
        public bool changeGYBGPMWjm(String oldWjm, String newWjm)
        {
            if (null == oldWjm || null == newWjm)
            {
                return false;
            }

            String dwjm = newWjm.Replace(".PDF", ".DOC");

            IDictionary<String, Object> para = new Dictionary<String, Object>();
            para.Add("oldwjm", oldWjm);
            para.Add("newwjm", newWjm);
            para.Add("dwjm", dwjm);

            bool result = true;
            try
            {
                sqlMapper.Update("ChangeGYBG_PM_wjm", para);
                //修改PDF文件名
                OperationFile.ReNameFile(oldWjm, newWjm);
                //修改DOC文件名
                oldWjm=oldWjm.Replace(".PDF", ".DOC");
                newWjm=newWjm.Replace(".PDF", ".DOC");
                OperationFile.ReNameFile(oldWjm, newWjm);

            }
            catch
            {
                result = false;
            }
            return result;
        }
Example #4
0
 public static string encryptBase64Url(String text)
 {
     text = text.Replace("+","-");
     text = text.Replace("/","_");
     text = text.Replace("=","$");
     return text;
 }
        /// <summary>
        /// Converts an XMLstring to an array of GBaseElement (Name and Type) structures
        /// </summary>
        /// <param name="XMLString">An XML string of the form: field..type..field..type...</param>
        /// <returns>An array of GBaseElement that is the parsed, passed XMLstring</returns>
        public GBaseElement[] FieldsToGBaseElementArray(String XMLString)
        {
            Stack<GBaseElement> _elements = new Stack<GBaseElement>();                      // Initially use a stack to hold the elements
            XMLString = XMLString.Replace("\t", "").Replace("\r", "").Replace("\n",  "");   // Replace the tabs, newllines, and returns in the string

            // Loop until break is hit
            while (true)
            {
                _GBaseElement.Name = XMLString.Substring(XMLString.IndexOf("Name=\"") + 6,      // Set the name to be the string between "Name=\"" and the next "
                                                         XMLString.IndexOf("\"", XMLString.IndexOf("Name=\"") + 6) - (XMLString.IndexOf("Name=\"") + 6)).ToLower();

                                                                                                // Set the Type to be the string between <Type> and </Type>
                _GBaseElement.Type = GetXMLBetweenTags("Type", XMLString).ToLower();

                _elements.Push(_GBaseElement);  // Push the newly generated object into _elements

                XMLString = XMLString.Substring(XMLString.IndexOf("</Field>") + 8,              // Get rid of the portion of the string that has been evaluated
                                                XMLString.Length - (XMLString.IndexOf("</Field>") + 8));

                if (XMLString.Replace(" ", "").Length == 0)     // Get rid of any left over spaces (sometimes they presist) and see if there is no more to look over
                    break;
            }

            return _elements.ToArray();     // Return the stack as an array
        }
Example #6
0
 public static byte[] ConvertFromBase64String(String dataStr)
 {
     dataStr = dataStr.Replace("$", "/");
     dataStr = dataStr.Replace("#", "+");
     byte[] data = Convert.FromBase64String(dataStr);
     return data;
 }
Example #7
0
 private String escapeAscii(String text)
 {
     text = text.Replace("\x0a", "\\n");
     text = text.Replace("\x0d", "\\r");
     text = text.Replace("\xa0", "\\u00a0");
     return text;
 }
        public Boolean VerificaRut(String rut)
        {
            bool validacion = false;
            try
            {
                rut = rut.ToUpper();
                rut = rut.Replace(".", "");
                rut = rut.Replace("-", "");
                int rutAux = int.Parse(rut.Substring(0, rut.Length - 1));

                char dv = char.Parse(rut.Substring(rut.Length - 1, 1));

                int m = 0, s = 1;
                for (; rutAux != 0; rutAux /= 10)
                {
                    s = (s + rutAux % 10 * (9 - m++ % 6)) % 11;
                }
                if (dv == (char)(s != 0 ? s + 47 : 75))
                {
                    validacion = true;
                }
            }
            catch (Exception)
            {
            }
            return validacion;
        }
        public static String adaptarTexto(String txt)
        {
            if (txt.Substring(0, 2).Equals("rt"))
            {
                txt = txt.Substring(2);
            }

            if (txt != null && !txt.Equals(""))
            {

                char[] acentuados = new char[] { 'ç', 'á', 'à', 'ã', 'â', 'ä', 'é', 'è', 'ê', 'ë', 'í', 'ì', 'î', 'ï', 'ó', 'ò', 'õ', 'ô', 'ö', 'ú', 'ù', 'û', 'ü' };
                char[] naoAcentuados = new char[] { 'c', 'a', 'a', 'a', 'a', 'a', 'e', 'e', 'e', 'e', 'i', 'i', 'i', 'i', 'o', 'o', 'o', 'o', 'o', 'u', 'u', 'u', 'u' };

                for (int i = 0; i < acentuados.Length; i++)
                {
                    txt = txt.Replace(acentuados[i], naoAcentuados[i]);
                }

            }

            txt = txt.Replace("rt ", "#rt ");
            txt = txt.Replace("retweet", "#rt");
            txt = txt.Replace("de um #rt", "de #rt");

            txt = removerPontuacao(txt);
            txt = adaptarPreco(txt);

            return txt;
        }
Example #10
0
 public void gotAT(String newATCommand)
 {
     newATCommand = newATCommand.Replace("\r", "");
     newATCommand = newATCommand.Replace("\n", "");
     Console.WriteLine("adding:" + newATCommand);
     slots[actSlot].settingStrings.Add(newATCommand);
 }
Example #11
0
 public static string decryptBase64Url(String base64Url)
 {
     base64Url = base64Url.Replace("-", "+");
     base64Url = base64Url.Replace("_", "/");
     base64Url = base64Url.Replace("$", "=");
     return base64Url;
 }
Example #12
0
        public void ConvertResult(System.String applicationDirectory, System.String resultsDirectory)
        {
            XslTransform xslt = new XslTransform();

            xslt.Load(applicationDirectory + "DVT_RESULTS.xslt");

            System.String resultsFilename = resultsDirectory + "\\Summary_" + _resultsFilename;
            XPathDocument xpathdocument   = new XPathDocument(resultsFilename);
//			XmlTextWriter writer = new XmlTextWriter(resultsFilename.Replace (".xml", ".html"), System.Text.Encoding.UTF8);
//			writer.Formatting = Formatting.None;
//			xslt.Transform(xpathdocument, null, writer, null);
//			writer.Flush();
//			writer.Close();

            FileStream fileStream = new FileStream(resultsFilename.Replace(".xml", ".html"), FileMode.Create, FileAccess.ReadWrite);

            xslt.Transform(xpathdocument, null, fileStream, null);
            fileStream.Close();

            resultsFilename = resultsDirectory + "\\Detail_" + _resultsFilename;
            xpathdocument   = new XPathDocument(resultsFilename);
//			writer = new XmlTextWriter(resultsFilename.Replace (".xml", ".html"), System.Text.Encoding.UTF8);
//			writer.Formatting = Formatting.None;
//			xslt.Transform(xpathdocument, null, writer, null);
//			writer.Flush();
//			writer.Close();

            fileStream = new FileStream(resultsFilename.Replace(".xml", ".html"), FileMode.Create, FileAccess.ReadWrite);
            xslt.Transform(xpathdocument, null, fileStream, null);
            fileStream.Close();
        }
Example #13
0
        public static String GetLogicalTag(String templateText)
        {
            String pattern = @"[\[][\%][\?][^=@].*?[\%][\]]";
            Regex regex = new Regex(pattern);
            MatchCollection matchCollection = regex.Matches(templateText);

            bool flags = false;

            pattern = @"(\[\%\?\%\])";
            regex = new Regex(pattern);
            MatchCollection fix = regex.Matches(templateText);
            if (fix.Count != 0)
                flags = true;

            foreach (Match item in matchCollection)
            {
                if (flags)
                {
                    String temp = item.Value.Trim(new Char[] { '[', '%', '?', ']' });

                    templateText = templateText.Replace(item.Value, " if( " + temp + " ) {");

                    templateText = templateText.Replace("[%?%]", " } ");
                }
                else
                {
                    String temp = item.Value.Trim(new Char[] { '[', '%', '?', ']' });

                    templateText = templateText.Replace(item.Value, " if( " + temp + " ) ");
                }
            }

            return templateText;
        }
Example #14
0
 /// <summary>
 /// Processes the internal argruments in a string.
 /// </summary>
 public static String ProcessArguments(String data)
 {
     data = data.Replace("$(Quote)", "\"");
     data = data.Replace("$(AppDir)", PathHelper.GetExeDirectory());
     data = Environment.ExpandEnvironmentVariables(data);
     return data;
 }
Example #15
0
 public static Dictionary<String, String> JsonObjectToDictionaryList(String StringDataIn)
 {
     Dictionary<String, String> Json = new Dictionary<string, string>();
     StringDataIn = StringDataIn.Replace("{", "");//Beginn of Object
     StringDataIn = StringDataIn.Replace("}", "");//End of Object
     return JsonObjectToDictionary(StringDataIn);
 }
Example #16
0
        /// <summary> Removes all unecessary whitespace from the given String (intended to be used with Primitive values).
        /// This includes leading and trailing whitespace, and repeated space characters.  Carriage returns,
        /// line feeds, and tabs are replaced with spaces.
        /// </summary>
        protected internal virtual System.String removeWhitespace(System.String s)
        {
            s = s.Replace('\r', ' ');
            s = s.Replace('\n', ' ');
            s = s.Replace('\t', ' ');

            bool repeatedSpacesExist = true;

            while (repeatedSpacesExist)
            {
                int loc = s.IndexOf("  ");
                if (loc < 0)
                {
                    repeatedSpacesExist = false;
                }
                else
                {
                    System.Text.StringBuilder buf = new System.Text.StringBuilder();
                    buf.Append(s.Substring(0, (loc) - (0)));
                    buf.Append(" ");
                    buf.Append(s.Substring(loc + 2));
                    s = buf.ToString();
                }
            }
            return(s.Trim());
        }
Example #17
0
        private String modifycatorString(int inAccuracy, String dataString, int inputStringFormat)
        {
            if (dataString.Length > inAccuracy)
                    dataString = dataString.Substring(0, inAccuracy);

            dataString = dataString.Replace('E', 'e');
            dataString = dataString.Replace('.', ',');

            if (dataString.IndexOf(',') == 0)
            dataString = "0" + dataString;

            if ((dataString[0] != '-') && (dataString[0] != '+'))
                dataString = "+" + dataString;

            if (dataString.IndexOf(',') == -1)
            if (dataString.IndexOf('e') != -1)
                    dataString = dataString.Substring(0, dataString.IndexOf('e')) + ",0" + dataString.Substring(dataString.IndexOf('e'));
            else
                    dataString = dataString + ",0";

            if ((dataString[dataString.IndexOf('e') + 1] != '+')&&
                (dataString[dataString.IndexOf('e') + 1] != '-'))
                dataString = dataString.Replace("e", "e+");

            if (dataString.IndexOf('e') == -1)
                dataString = dataString + "e+0";

            return dataString;
        }
Example #18
0
        internal static System.String GetFileName(System.String name)
        {
            if (name == null || name.Length == 0)
            {
                return(name);
            }
            name = name.Replace("\t", "");
            try {
                name = System.IO.Path.GetFileName(name);
            } catch (System.ArgumentException) {
                // Remove invalid chars
                foreach (char ichar in System.IO.Path.InvalidPathChars)
                {
                    name = name.Replace(ichar.ToString(), System.String.Empty);
                }
                name = System.IO.Path.GetFileName(name);
            }
            try {
                System.IO.FileInfo fi = new System.IO.FileInfo(name);
                if (fi != null)
                {
                    fi = null;
                }
            } catch (System.ArgumentException) {
                name = null;
#if LOG
                if (log.IsErrorEnabled)
                {
                    log.Error(System.String.Concat("Filename [", name, "] is not allowed by the filesystem"));
                }
#endif
            }
            return(name);
        }
Example #19
0
        public static System.String RemoveIllegalChars(System.String Str)
        {
            if (Str == null)
            {
                Str = "Unknown";
            }
            Str = Str.Replace('\\', '-');
            Str = Str.Replace('/', '-');
            System.String[] AllowedCharsArray         = new System.String[] { "q", "w", "e", "r", "t", "a", "s", "d", "f", "g", "z", "x", "c", "v", "b", "y", "u", "i", "o", "p", "h", "j", "k", "l", "n", "m", "1", "2", "3", "4", "5", "6", "7", "8", "9", "_", " ", "(", ")", "-" };
            System.Collections.ArrayList AllowedChars = new System.Collections.ArrayList(AllowedCharsArray);
            System.String OutStr = "";

            foreach (System.Char TestChar in Str.ToCharArray())
            {
                if (AllowedChars.Contains(TestChar.ToString().ToLower()))
                {
                    OutStr += TestChar.ToString();
                }
            }

            if (OutStr == "")
            {
                OutStr = "Unknown";
            }

            return(OutStr);
        }
        public GetSystemFlags(String CurrentFlags)
        {
            InitializeComponent();

            foreach (EnumFlags EFlags in Enum.GetValues(typeof(EnumFlags)))
            {
                _ValueFlags.Add(EFlags.ToString());
            }

            for (int i = 0; i < _ValueFlags.Count; i++)
            {
                listBox_Flags.Items.Add(_ValueFlags[i].ToString());
            }

            // Parse current flags
            CurrentFlags = CurrentFlags.Replace("(", "");
            CurrentFlags = CurrentFlags.Replace(")", "");
            CurrentFlags = CurrentFlags.Replace(" ", "");

            string[] ParsedString = CurrentFlags.Split(new char[]{'+'});
            for (int i = 0; i < ParsedString.Length; i++)
            {
                listBox_Flags.SelectedItems.Add(ParsedString[i]);
            }
        }
        //Method to eliminate Hyperlinks from numbers
        public static String cleanString(String s)
        {
            s.Trim();
            s = s.Replace("hyperlink", "");
            s = s.Replace(" ", "");
            //finds the last index where ' occurs
            int end = s.LastIndexOf("\"");
            int num = s.Length;

            int n = s.Length - end;

            char[] a = s.ToCharArray();
            char[] b = new char[256];

            int j = 0;
            for (int i = end + 1; i < s.Length; i++)
            {

                b[j] = a[i];
                j++;
            }

            string str = new string(b);
            return str;
        }
Example #22
0
 public String EscapeForXMLandHTML(String myString)
 {
     myString = myString.Replace("<", "&lt;");
     myString = myString.Replace(">", "&gt;");
     myString = myString.Replace("&", "&amp;");
     return myString;
 }
Example #23
0
 /// <summary>
 /// Creates a new CSS range token.
 /// </summary>
 /// <param name="range">The selected range string.</param>
 /// <param name="position">The token's position.</param>
 public CssRangeToken(String range, TextPosition position)
     : base(CssTokenType.Range, range, position)
 {
     _start = range.Replace(Symbols.QuestionMark, '0');
     _end = range.Replace(Symbols.QuestionMark, 'F');
     _range = GetRange();
 }
        public static String getLatFromAddress2(String s)
        {
            s = s.Replace("Suite", "");
            s = s.Replace("suite", "");
            s = s.Replace("Apt", "");
            s = s.Replace("apt", "");

            //Instance class use (Geocode)  (Can be made from static/instance class)
            var geocodeRequest = new GeocodingRequest
                                     {
                                         Address = s,
                                     };
            var geocodingEngine = new GeocodingEngine();

            GeocodingResponse geocode = geocodingEngine.GetGeocode(geocodeRequest);
            Result match1 = null;
            try
            {
                match1 = geocode.Results.First();
            }
            catch (Exception)
            {
                return "notfound";
            }
            Double lat = match1.Geometry.Location.Latitude;

            return lat.ToString();
        }
Example #25
0
 public Address(String sourceAddressCode)
 {
     if (sourceAddressCode.StartsWith(LexicalSymbols.LabelAddress))
     {
         this.IsLabelledAddress = true;
         this.AddressLabel = sourceAddressCode.Replace(LexicalSymbols.LabelAddress, String.Empty);
     }
     else if (sourceAddressCode.StartsWith(LexicalSymbols.BinaryAddress))
     {
         this.BinaryAddress = int.Parse(sourceAddressCode.Replace(LexicalSymbols.BinaryAddress, String.Empty));
         this.SourceAddress = BinaryToSource(this.BinaryAddress);
     }
     else
     {
         this.SourceAddress = int.Parse(sourceAddressCode);
         if (this.SourceAddress >= 0)
         {
             this.BinaryAddress = SourceToBinary(this.SourceAddress);
         }
         else
         {
             this.BinaryAddress = this.SourceAddress;
         }
     }
 }
Example #26
0
 /// <summary>
 ///   Generates a valid DotNet name.
 /// </summary>
 /// <param name = "prefix">The prefix.</param>
 /// <param name = "value">The value.</param>
 /// <returns>A valid DotNet name.</returns>
 public static String GenerateDotNetName(String prefix, String value)
 {
     value = value.Replace('-', ' ');
     value = value.Replace('&', ' ');
     String[] parts = value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
     return parts.Aggregate(prefix, (s, part) => s += (part.Substring(0, 1).ToUpper() + part.Substring(1)));
 }
Example #27
0
 private static string TidyUpArtist(String artist)
 {
     artist = artist.Replace("&&", "&amp;");
     artist = artist.Replace("\"", "&quot;");
     artist = artist.Replace("<", "&lt;");
     artist = artist.Replace(">", "&gt;");
     return artist;
 }
Example #28
0
 public virtual void RefractorString(ref String s)
 {
     s = s.Replace("~(", "bitnot(");
     s = s.Replace(" && ", " and ");
     s = s.Replace(" || ", " or ");
     s = s.Replace("!", "not ");
     s = s.Replace("nop", "nop()");
 }
Example #29
0
 /// <summary>
 /// Returns a string where all "wrong" directory separator chars are replaced by the ones used by the system 
 /// </summary>
 /// <param name="path">The original path string potentially with wrong chars</param>
 /// <returns>The corrected path string</returns>
 static String FixDirectorySeparators(String path)
 {
     if(Path.DirectorySeparatorChar != '\\')
         path = path.Replace('\\', Path.DirectorySeparatorChar);
     if(Path.DirectorySeparatorChar != '/')
         path = path.Replace('/', Path.DirectorySeparatorChar);
     return path;
 }
Example #30
0
 private static String replaceSpecialChart(String sourceData)
 {
     sourceData = sourceData.Replace("\r\n", "<br>");
     sourceData = sourceData.Replace("\n", "<br>");
     sourceData = sourceData.Replace(@"\", @"\\");
     sourceData = sourceData.Replace("'", "\\'");
     return sourceData;
 }
Example #31
0
 private static String ReplaceWithFilePaths( String strFileData,  String appDir, String binDir, String strOriginUrl){
     strFileData = strFileData.Replace("$AppDir$", appDir);
     strFileData = strFileData.Replace("$AppDirUrl$", MakeFileUrl(appDir));
     strFileData = strFileData.Replace("$CodeGen$", MakeFileUrl(binDir));
     if (strOriginUrl != null)
         strFileData = strFileData.Replace("$OriginUrl$", strOriginUrl);
     return strFileData ;
 }
Example #32
0
        public String BuildAbsoluteUrl(String rootUrl)
        {
            if (String.IsNullOrWhiteSpace(rootUrl)) throw new ArgumentNullException("rootUrl");

            return (String.Equals(rootUrl, ArcGIS.ServiceModel.PortalGateway.AGOPortalUrl, StringComparison.OrdinalIgnoreCase))
                ? (DontForceHttps ? rootUrl : rootUrl.Replace("http://", "https://")) + RelativeUrl.Replace("tokens/", "")
                : (DontForceHttps ? rootUrl : rootUrl.Replace("http://", "https://")) + RelativeUrl;
        }
Example #33
0
    public String Purge(String text)
    {
        text= text.Replace("&nbsp;"," ");

        text = text.Replace("\r\n", " ");
        text = text.Replace("  ", " ");

        return text;
    }
Example #34
0
 String EscapeForHtml(String str)
 {
     str = str.Replace("'", "&#39;");
     str = str.Replace("\"", "&quot;");
     str = str.Replace("\n", " ");
     str = str.Replace("<", "&lt;");
     str = str.Replace(">", "&gt;");
     return str;
 }
Example #35
0
        private Support getMetricValue(ItemSet val, Metric m)
        {
            ItemSet[] splitItems = val.Split(',');
            if (splitItems.Length == 1)
            {
                switch (m)
                {
                case Metric.SupportCount:
                    float x = Convert.ToInt32(this._sparseMatrix.Compute("COUNT([" + val + "])", "[" + val + "] = 1"));
                    return(x);

                case Metric.Support:
                    float y = Convert.ToInt32(this._sparseMatrix.Compute("COUNT([" + val + "])", "[" + val + "] = 1"));
                    return(y / this._sparseMatrix.Rows.Count);

                case Metric.Confidence:
                    //find support count of whole and divide it by that of the antecedent
                    float supportCountWhole      = getMetricValue(val.Replace('#', ','), Metric.SupportCount);
                    float supportCountAntecedent = getMetricValue(val.Split('#')[0], Metric.SupportCount);
                    return(supportCountAntecedent == 0 ? 0 : supportCountWhole / supportCountAntecedent);

                default: return(0);
                }
            }
            else
            {
                switch (m)
                {
                case Metric.Support:
                    StringBuilder query = new StringBuilder("[");
                    foreach (ItemSet item in splitItems)
                    {
                        query.Append(item);
                        query.Append("] = 1 AND [");
                    }
                    query.Remove(query.Length - 5, 5);
                    DataRow[] drColln = _sparseMatrix.Select(query.ToString());
                    if (drColln.Length > 0)
                    {
                        return((float)drColln.Length / _sparseMatrix.Rows.Count);
                    }
                    else
                    {
                        return(0);
                    }

                case Metric.Confidence:
                    //find support count of whole and divide it by that of the antecedent
                    float supportCountWhole      = getMetricValue(val.Replace('#', ','), Metric.Support); //same as using supportcount because it is a ratio
                    float supportCountAntecedent = getMetricValue(val.Split('#')[0], Metric.Support);     //same as using supportcount because it is a ratio
                    return(supportCountAntecedent == 0 ? 0 : supportCountWhole / supportCountAntecedent);

                default: return(0);
                }
            }
        }
Example #36
0
        public static System.String RemoveChar(System.String consoleInput)
        {
            consoleInput = consoleInput.Replace('(', ' ');
            consoleInput = consoleInput.Replace(')', ' ');
            consoleInput = consoleInput.Replace(',', ' ');

            consoleInput = consoleInput.Trim();

            return(consoleInput);
        }
Example #37
0
        private void Button1_Click(object sender, EventArgs e)
        {
            OpenFileDialog openFileDialog1 = new OpenFileDialog
            {
                InitialDirectory = @"D:\",
                Title            = "Browse PDF Files",

                CheckFileExists = true,
                CheckPathExists = true,

                DefaultExt       = "pdf",
                Filter           = "pdf files (*.pdf)|*.pdf",
                FilterIndex      = 2,
                RestoreDirectory = true,

                ReadOnlyChecked = true,
                ShowReadOnly    = true
            };

            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                textBox1.Text = openFileDialog1.FileName;
                file_name     = textBox1.Text;
                System.String[] nameList = file_name.Split('\\');
                nCnt = nameList.Length;
                //textBox2.Text = nameList[nCnt - 1];
                System.String pdf_name = nameList[nCnt - 1];
                excel_name    = pdf_name.Replace("pdf", "xls");
                textBox2.Text = excel_name;
            }
        }
 /// <summary> Appends the text to the output.</summary>
 /// <param name="string">The text node.
 /// </param>
 public override void VisitStringNode(IText string_Renamed)
 {
     if (!mIsScript && !mIsStyle)
     {
         System.String text = string_Renamed.GetText();
         if (!mIsPre)
         {
             text = Translate.Decode(text);
             if (ReplaceNonBreakingSpaces)
             {
                 text = text.Replace('\u00a0', ' ');
             }
             if (Collapse)
             {
                 StringUtil.CollapseString(mBuffer, text);
             }
             else
             {
                 mBuffer.Append(text);
             }
         }
         else
         {
             mBuffer.Append(text);
         }
     }
 }
Example #39
0
 /// <summary>
 /// Checks if the given System.String object contains symbols or
 /// special characters.
 /// </summary>
 /// <param name="str">The given string object to check.</param>
 /// <param name="ignoreSpaces">Remove spaces before compare?</param>
 /// <returns>True if any characters in the given string are
 /// symbols or special characters, else False.</returns>
 public static bool HasSymbol(this System.String str,
                              bool ignoreSpaces = true)
 {
     return(!(ignoreSpaces ? str.Replace(" ", "") : str)
            .ToCharArray()
            .All(Char.IsLetterOrDigit));
 }
Example #40
0
 /// <summary> Returns the package name for model elements of the given version - e.g.
 /// "Genetibase.NuGenHL7.model.v24.".  This method
 /// is identical to <code>getVersionPackagePath(...)</code> except that path
 /// separators are replaced with dots.
 /// </summary>
 public static System.String getVersionPackageName(System.String ver)
 {
     System.String path  = getVersionPackagePath(ver);
     System.String packg = path.Replace('/', '.');
     packg = packg.Replace('\\', '.');
     return(packg);
 }
Example #41
0
        public static void insert(System.String mac, int offset, byte[] bytes)
        {
            mac = mac.Replace(":", "").Replace("-", "");
            long l = System.Convert.ToInt64(mac, 16);

            ArrayHelper.insertLong(bytes, l, offset, 6);
        }
Example #42
0
 public void Info(System.String msg)
 {
     msg = msg.Replace("\n", "\r\n");
     LogMsg(DateTime.Now.ToShortTimeString() +
            " [INFO]" +
            " " + msg);
 }
Example #43
0
        //DATABASE

        #region database methods

        private void CheckDatabase(String plateNumber, String picURL)
        {
            plateNumber = plateNumber.Replace(" ", "").ToUpper();
            String qry = "SELECT Person.PersonName, Person.PersonSurname, Car.IsRegistered FROM Car, Person WHERE Car.CarNumberPlate = '" + plateNumber
                         + "' AND Car.PersonID = Person.IDNumber";

            _vehicleCount++;

            OleDbCommand    command = new OleDbCommand(qry, _conn);
            OleDbDataReader reader  = command.ExecuteReader();

            if (reader != null && !reader.HasRows)
            {
                DisplayPlate(new LicencePlate("error-" + plateNumber, false));
                sendSingleCarInfoToAll(plateNumber, "<UNKNOWN>", "UNKNOWN", picURL);
            }

            while (reader != null && reader.Read())
            {
                String  fname        = reader.GetString(0);
                String  sname        = reader.GetString(1);
                Boolean isRegistered = reader.GetBoolean(2);

                DisplayPlate(new LicencePlate(plateNumber, isRegistered));

                sendSingleCarInfoToAll(fname, sname, plateNumber, picURL);
            }

            if (reader != null)
            {
                reader.Close();
            }
        }
        }//AnalyseFile

        /// <summary>
        ///	getDstFileNameByThrdNum   eg. is log contains: [Thrd: 5476] then dest file: ./DstLogPath/Thrd_5476.log
        /// </summary>
        /// <param name="strThrdNum"></param>
        /// <returns></returns>
        private System.String getDstFileNameByThrdNum(System.String strThrdNum)
        {
            System.String strDstFileName   = "";
            System.String strThrdNumSubStr = "";

            int nfindSunStr = -1;

            //[Thrd: 5476]
            if (strThrdNum.Length > 0)
            {
                nfindSunStr = -1;
                nfindSunStr = strThrdNum.IndexOf(":");
            }
            if (nfindSunStr > 0)
            {
                strThrdNumSubStr = strThrdNum.Substring(nfindSunStr + 1);
                nfindSunStr      = -1;
            }

            //remove "]"
            strThrdNumSubStr = strThrdNumSubStr.Replace("]", " ");

            //remove " "
            strThrdNumSubStr = strThrdNumSubStr.Trim();
            //./DstLogPath/Thrd_5476.log
            strDstFileName = m_strDstLogPath + "Thrd_" + strThrdNumSubStr + ".log";

            return(strDstFileName);
        }//AnalyseFile
Example #45
0
 /// <summary>
 /// Checks if the given string contains any numeric characters.
 /// </summary>
 /// <param name="str">The given string object to check.</param>
 /// <param name="ignoreSpaces">Remove spaces before compare?</param>
 /// <returns>True if any characters in the given string are numeric,
 /// else False.</returns>
 public static bool HasNumeric(this System.String str,
                               bool ignoreSpaces = true)
 {
     return((ignoreSpaces ? str.Replace(" ", "") : str)
            .ToCharArray()
            .Any(Char.IsDigit));
 }
Example #46
0
        /// <summary>
        /// Itrerating thru the entire Keys enumeration; downed key names are stored in keyBuffer
        /// (space delimited).
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void timerKeyMine_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            foreach (int i in Enum.GetValues(typeof(Keys)))
            {
                if (IsKeyBeingPressed(i))
                {
                    AddKeyToBuffer(i);

                    string keyBufferCompare = keyBuffer.Replace(" ", string.Empty);
                    foreach (var shortKey in WatchedShortKeys)
                    {
                        string fullKey = (ShortKeyConfiguration.Default.Prefix + shortKey.Key + shortKey.Suffix).ToUpperInvariant();
                        if (keyBufferCompare.EndsWith(fullKey))
                        {
                            Invoke(() =>
                            {
                                SendKeys.Send($"{{BACKSPACE {fullKey.Length}}}");
                            });
                            string keys = shortKey.ReplacementKey;
                            if (!shortKey.UseClipboard)
                            {
                                keys = PerformNewLineFix(keys);
                            }
                            keys = ReplaceRegexPatterns(keys);
                            if (shortKey.UseClipboard)
                            {
                                Invoke(() =>
                                {
                                    try
                                    {
                                        IDataObject clipboardData = Clipboard.GetDataObject();
                                        Clipboard.SetDataObject(keys);
                                        SendKeys.Send($"^(v)");
                                        Clipboard.SetDataObject(clipboardData);
                                    }
                                    catch { }
                                });
                            }
                            else
                            {
                                keys = ReplaceSendKeysSpecialCharacters(keys);
                                Invoke(() =>
                                {
                                    SendTheseKeys(keys);
                                });
                            }
                            if (shortKey.CursorLeftCount > 0)
                            {
                                Invoke(() =>
                                {
                                    SendKeys.Send($"{{LEFT {shortKey.CursorLeftCount}}}");
                                });
                            }
                            break;
                        }
                    }
                }
            }
        }
Example #47
0
        virtual public string GetDescriptionWithoutSpecialCharacters()
        {
            string desc = this.desc;

            desc = desc.Replace('\n', ' ');
            desc = desc.Replace('\"', '\'');
            return(desc);
        }
Example #48
0
 /// <summary>
 /// Check if given System.String object is all upper case.
 /// </summary>
 /// <param name="str">The string object to check.</param>
 /// <param name="ignoreSpaces">Remove spaces before checking?</param>
 /// <returns>True if the entire string is upper case, else False.</returns>
 public static bool IsUpper(this System.String str,
                            bool ignoreSpaces = true)
 {
     return((ignoreSpaces ? str.Replace(" ", "") : str)
            .ToCharArray()
            .Select(C => (int)C)
            .All(C => C >= 65 && C <= 90));
 }
Example #49
0
 /// <summary>
 /// Check if given System.String object contains lower case.
 /// </summary>
 /// <param name="str">The string object to check.</param>
 /// <param name="ignoreSpaces">Remove spaces before checking?</param>
 /// <returns>True if the object contains any lower case, else False.</returns>
 public static bool HasLower(this System.String str,
                             bool ignoreSpaces = true)
 {
     return((ignoreSpaces ? str.Replace(" ", "") : str)
            .ToCharArray()
            .Select(C => (int)C)
            .Any(C => C >= 97 && C <= 122));
 }
Example #50
0
 /// <summary>
 /// Checks if the given string contains all numeric characters.
 /// </summary>
 /// <param name="str">The given string object to check.</param>
 /// <param name="Classic">Switch to force RegEx comparison instead
 /// of Linq.</param>
 /// <param name="ignoreSpaces">Remove spaces before compare?</param>
 /// <returns>True if all characters in the given string are numeric,
 /// else False.</returns>
 public static bool IsNumeric(this System.String str,
                              bool Classic      = false,
                              bool ignoreSpaces = true)
 {
     if (Classic)  //No LINQ available e.g. .NET 2.0
     {
         return(System.Text.RegularExpressions.Regex.IsMatch(
                    (ignoreSpaces ? str.Replace(" ", "") : str),
                    @"^[0-9]+$"));
     }
     else  //This method is on average 670% faster than RegEx method.
     {
         return((ignoreSpaces ? str.Replace(" ", "") : str)
                .ToCharArray()
                .All(Char.IsDigit));
     }
 }
Example #51
0
 /// <summary>
 /// 转义正则表达式
 /// </summary>
 public static System.String EscapeRegex(this System.String SourceString)
 {
     System.String[] oList = { "\\", ".", "+", "*", "?", "{", "}", "[", "^", "]", "$", "(", ")", "=", "!", "<", ">", "|", ":" };
     System.String[] eList = { "\\\\", "\\.", "\\+", "\\*", "\\?", "\\{", "\\}", "\\[", "\\^", "\\]", "\\$", "\\(", "\\)", "\\=", "\\!", "\\<", "\\>", "\\|", "\\:" };
     for (int i = 0; i < oList.Length; i++)
     {
         SourceString = SourceString.Replace(oList[i], eList[i]);
     }
     return(SourceString);
 }
Example #52
0
 /// <summary>Initialize member variable setting the base file path</summary>
 /// <param name="basePath">representing base path location
 /// </param>
 public FileGenerator(System.String basePath)
 {
     // make sure there is a \ appended to ouput director path
     System.Console.Out.WriteLine(basePath);
     this.basePath = basePath.Replace('\\', '/');
     if ((basePath[basePath.Length - 1]) != '/')
     {
         basePath = basePath + "/";
     }
 }
Example #53
0
 public static 文字列 シモナイズ(this 文字列 閣下)
 {
     foreach (var 相当 in シモナイズテーブル)
     {
         if (閣下.Contains(相当.Key))
         {
             閣下 = 閣下.Replace(相当.Key.ToString(), 相当.Value);
         }
     }
     return(閣下);
 }
Example #54
0
 public static System.Double Parse(System.String s)
 {
     try
     {
         return(System.Double.Parse(s.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)));
     }
     catch (OverflowException)
     {
         return(System.Double.MaxValue);
     }
 }
 public static System.Decimal ToDecimal(System.String AValue)
 {
     if (AValue.Contains(","))
     {
         AValue = AValue.Replace(".", "");
     }
     else
     {
         AValue = AValue.Replace(".", ",");
     }
     System.Decimal NewValue;
     if (!DecimalUtils.IsValid(AValue, out NewValue))
     {
         return(0);
     }
     else
     {
         return(NewValue);
     }
 }
Example #56
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="s"></param>
 /// <returns></returns>
 public static System.Single Parse(System.String s)
 {
     if (s.EndsWith("f") || s.EndsWith("F"))
     {
         return(System.Single.Parse(s.Substring(0, s.Length - 1).Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)));
     }
     else
     {
         return(System.Single.Parse(s.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)));
     }
 }
Example #57
0
 public System.String EscapeExpression(System.String input)
 {
     if (input == null || input.Length == 0)
     {
         return("''");
     }
     if (input.IndexOf('\'') != -1)
     {
         return(input.Replace("'", "''"));
     }
     return(input);
 }
Example #58
0
        private System.String ReplaceString(System.String inputString, Hl7MessageDelimiters messageDelimiters)
        {
            // get the default message delimiters - these will have been used in the HL7 scripts, etc
            Hl7MessageDelimiters defaultMessageDelimiters = new Hl7MessageDelimiters();

            // update the string to use the given message delimiters
            System.String localString1 = inputString.Replace(defaultMessageDelimiters.ComponentDelimiter, messageDelimiters.ComponentDelimiter);
            System.String localString2 = localString1.Replace(defaultMessageDelimiters.SubComponentDelimiter, messageDelimiters.SubComponentDelimiter);
            System.String outputString = localString2.Replace(defaultMessageDelimiters.RepetitionSeparator, messageDelimiters.RepetitionSeparator);

            return(outputString);
        }
Example #59
0
 public static System.Double ToDouble(System.String AValue)
 {
     AValue = AValue.Replace(".", "");
     System.Double NewValue;
     if (!DoubleUtils.IsValid(AValue, out NewValue))
     {
         return(0);
     }
     else
     {
         return(NewValue);
     }
 }
Example #60
0
        private void ConvertResult()
        {
            XslTransform xslt = new XslTransform();

            xslt.Load(_applicationDirectory + "DVT_RESULTS.xslt");

            System.String resultsFilename = _resultsDirectory + "\\Summary_" + _resultsFilename;
            XPathDocument xpathdocument   = new XPathDocument(resultsFilename);
            XmlTextWriter writer          = new XmlTextWriter(resultsFilename.Replace(".xml", ".html"), System.Text.Encoding.UTF8);

            writer.Formatting = Formatting.None;
            xslt.Transform(xpathdocument, null, writer, null);
            writer.Flush();
            writer.Close();

            resultsFilename   = _resultsDirectory + "\\Detail_" + _resultsFilename;
            xpathdocument     = new XPathDocument(resultsFilename);
            writer            = new XmlTextWriter(resultsFilename.Replace(".xml", ".html"), System.Text.Encoding.UTF8);
            writer.Formatting = Formatting.None;
            xslt.Transform(xpathdocument, null, writer, null);
            writer.Flush();
            writer.Close();
        }