字符串操作类 1、GetStrArray(string str, char speater, bool toLower) 把字符串按照分隔符转换成 List 2、GetStrArray(string str) 把字符串转 按照, 分割 换为数据 3、GetArrayStr(List list, string speater) 把 List 按照分隔符组装成 string 4、GetArrayStr(List list) 得到数组列表以逗号分隔的字符串 5、GetArrayValueStr(Dictionary list)得到数组列表以逗号分隔的字符串 6、DelLastComma(string str)删除最后结尾的一个逗号 7、DelLastChar(string str, string strchar)删除最后结尾的指定字符后的字符 8、ToSBC(string input)转全角的函数(SBC case) 9、ToDBC(string input)转半角的函数(SBC case) 10、GetSubStringList(string o_str, char sepeater)把字符串按照指定分隔符装成 List 去除重复 11、GetCleanStyle(string StrList, string SplitString)将字符串样式转换为纯字符串 12、GetNewStyle(string StrList, string NewStyle, string SplitString, out string Error)将字符串转换为新样式 13、SplitMulti(string str, string splitstr)分割字符串 14、SqlSafeString(string String, bool IsDel)
        /// <summary>
        /// Appends a new header to this request.
        /// </summary>
        /// <param name="name">The name of the header to append.</param>
        /// <param name="value">The value of the header.</param>
        public void AppendExtraHeader( string name, string value )
        {
            StringHelper nameStr = new StringHelper( name );
            StringHelper valueStr = new StringHelper( value );

            awe_resource_request_append_extra_header( instance, nameStr.Value, valueStr.Value );
        }
        /// <summary>
        /// Create a ResourceResponse from a byte array
        /// </summary>
        /// <param name="data">The data to be initialized from (a copy is made)</param>
        /// <param name="mimeType">The mime-type of the data (for ex. "text/html")</param>
        public ResourceResponse( byte[] data, string mimeType )
        {
            StringHelper mimeTypeStr = new StringHelper( mimeType );

            IntPtr dataPtr = Marshal.AllocHGlobal( data.Length );
            Marshal.Copy( data, 0, dataPtr, data.Length );

            instance = awe_resource_response_create( (uint)data.Length, dataPtr, mimeTypeStr.Value );

            Marshal.FreeHGlobal( dataPtr );
        }
Exemple #3
0
 public JSValue this[ string propertyName ]
 {
     get
     {
         StringHelper propertyNameStr = new StringHelper( propertyName );
         return new JSValue( awe_jsobject_get_property( instance, propertyNameStr.Value ) );
     }
     set
     {
         StringHelper propertyNameStr = new StringHelper( propertyName );
         awe_jsobject_set_property( instance, propertyNameStr.Value, value.Instance );
     }
 }
        public void TestStringHelper_Reverse()
        {
            // Create channel mock
            Mock<IStringServiceChannel> channelMock = new Mock<IStringServiceChannel>(MockBehavior.Strict);

            // setup the mock to expect the Reverse method
            channelMock.Setup(c => c.ReverseStringAsync("abc")).Returns(Task.FromResult("cba"));

            // create string helper and invoke the Reverse method
            StringHelper sh = new StringHelper(channelMock.Object);
            string result = sh.ReverseAsync("abc").Result;
            Assert.AreEqual("cba", result);

            //verify that the method was called on the mock
            channelMock.Verify(c => c.ReverseStringAsync("abc"), Times.Once());
        }
Exemple #5
0
 public bool HasProperty( string propertyName )
 {
     StringHelper propertyNameStr = new StringHelper( propertyName );
     return awe_jsobject_has_property( instance, propertyNameStr.Value );
 }
Exemple #6
0
        /// <summary>
        /// Start finding a certain string on the current web-page.
        /// </summary>
        /// <remarks>
        /// All matches of the string will be highlighted on the page and you can jump to different 
        /// instances of the string by using the <see cref="FindNext"/> method.
        /// To get actual stats about a certain query, please see <see cref="FindResultsReceived"/>.
        /// </remarks>
        /// <param name="searchStr">
        /// The string to search for.
        /// </param>
        /// <param name="forward">
        /// True to search forward, down the page. False otherwise. The default is true.
        /// </param>
        /// <param name="caseSensitive">
        /// True to perform a case sensitive search. False otherwise. The default is false.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// The member is called on an invalid <see cref="WebControl"/> instance
        /// (see <see cref="UIElement.IsEnabled"/>).
        /// </exception>
        public void Find( string searchStr, bool forward = true, bool caseSensitive = false )
        {
            VerifyLive();

            if ( findRequest != null )
            {
                StopFind( true );
            }

            findRequest = new FindData( findRequestRandomizer.Next(), searchStr, caseSensitive );
            StringHelper searchCStr = new StringHelper( searchStr );
            awe_webview_find( Instance, findRequest.RequestID, searchCStr.Value, forward, caseSensitive, false );
        }
Exemple #7
0
        /// <summary>
        /// Request the page dimensions and scroll position of the page.
        /// </summary>
        /// <remarks>
        /// You can retrieve the response by handling the <see cref="ScrollDataReceived"/> event.
        /// </remarks>
        /// <param name="frameName">
        /// The frame's scroll data to retrieve. Leave blank to get the main frame's scroll data.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// The member is called on an invalid <see cref="WebControl"/> instance
        /// (see <see cref="UIElement.IsEnabled"/>).
        /// </exception>
        public void RequestScrollData( string frameName = "" )
        {
            VerifyLive();

            StringHelper frameNameStr = new StringHelper( frameName );
            awe_webview_request_scroll_data( Instance, frameNameStr.Value );
        }
        public bool SaveToJPEG(string filePath,
                              int quality = 90)
        {
            StringHelper filePathStr = new StringHelper(filePath);

            bool temp = awe_renderbuffer_save_to_jpeg(renderbuffer, filePathStr.value(), quality);

            return temp;
        }
Exemple #9
0
        public static void SetCustomResponsePage(int statusCode, string filePath)
        {
            StringHelper filePathStr = new StringHelper(filePath);

            awe_webcore_set_custom_response_page(statusCode, filePathStr.value());
        }
Exemple #10
0
        public static String GetCookies(string url, bool excludeHttpOnly = true)
        {
            StringHelper urlStr = new StringHelper(url);

            IntPtr temp = awe_webcore_get_cookies(urlStr.value(), excludeHttpOnly);

            return StringHelper.ConvertAweString(temp);
        }
        public static void ReadPrimitive(Stream stream, out string value)
        {
            uint totalBytes;
            ReadPrimitive(stream, out totalBytes);

            if (totalBytes == 0)
            {
                value = null;
                return;
            }
            else if (totalBytes == 1)
            {
                value = string.Empty;
                return;
            }

            totalBytes -= 1;

            uint totalChars;
            ReadPrimitive(stream, out totalChars);

            var helper = s_stringHelper;
            if (helper == null)
                s_stringHelper = helper = new StringHelper();

            var decoder = helper.Decoder;
            var buf = helper.ByteBuffer;
            char[] chars;
            if (totalChars <= StringHelper.CHARBUFFERLEN)
                chars = helper.CharBuffer;
            else
                chars = new char[totalChars];

            int streamBytesLeft = (int)totalBytes;

            int cp = 0;

            while (streamBytesLeft > 0)
            {
                int bytesInBuffer = stream.Read(buf, 0, Math.Min(buf.Length, streamBytesLeft));
                if (bytesInBuffer == 0)
                    throw new EndOfStreamException();

                streamBytesLeft -= bytesInBuffer;
                bool flush = streamBytesLeft == 0 ? true : false;

                bool completed = false;

                int p = 0;

                while (completed == false)
                {
                    int charsConverted;
                    int bytesConverted;

                    decoder.Convert(buf, p, bytesInBuffer - p,
                        chars, cp, (int)totalChars - cp,
                        flush,
                        out bytesConverted, out charsConverted, out completed);

                    p += bytesConverted;
                    cp += charsConverted;
                }
            }

            value = new string(chars, 0, (int)totalChars);
        }
Exemple #12
0
        /// <summary>
        /// Create or update the current IME text composition.
        /// </summary>
        /// <param name="inputStr">The string generated by your IME.</param>
        /// <param name="cursorPos">The current cursor position in your IME composition.</param>
        /// <param name="targetStart">The position of the beginning of the selection.</param>
        /// <param name="targetEnd">The position of the end of the selection.</param>
        /// <exception cref="InvalidOperationException">
        /// The member is called on an invalid <see cref="WebControl"/> instance
        /// (see <see cref="UIElement.IsEnabled"/>).
        /// </exception>
        public void SetIMEComposition( string inputStr, int cursorPos, int targetStart, int targetEnd )
        {
            VerifyLive();

            StringHelper inputCStr = new StringHelper( inputStr );
            awe_webview_set_ime_composition( Instance, inputCStr.Value, cursorPos, targetStart, targetEnd );
        }
Exemple #13
0
        public void FillMutilRowsT(ExcelAccess ea, LP_Temple lp, string str, int cellcount, string arrCellPos)
        {
            StringHelper help = new StringHelper();
            //str = help.GetPlitString(str, cellcount);
            string[] arrRst = str.Split(new string[] { "\r\n" },StringSplitOptions.None);
            for (int i=0; i < arrRst.Length; i++)
            {
                ea.SetCellValue(arrRst[i], GetCellPos(arrCellPos)[0] + i, GetCellPos(arrCellPos)[1]);
                if (valuehs.ContainsKey(lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1]))
                {
                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1]] as WF_TableFieldValue;
                    tfv.ControlValue = arrRst[i];
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(arrCellPos)[0] + i;
                    tfv.YExcelPos = GetCellPos(arrCellPos)[1];
                    tfv.ExcelSheetName = activeSheetName;

                }
                else
                {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = arrRst[i];
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(arrCellPos)[0] + i;
                    tfv.YExcelPos = GetCellPos(arrCellPos)[1];
                    tfv.ExcelSheetName = activeSheetName;
                    valuehs.Add(lp.LPID + "$" + Convert.ToString(GetCellPos(arrCellPos)[0] + i) + "|" + GetCellPos(arrCellPos)[1], tfv);
                }
            }
        }
Exemple #14
0
        /// <summary>
        /// Jump to the next match of a previously successful search.
        /// </summary>
        /// <param name="forward">
        /// True to search forward, down the page. False otherwise. The default is true.
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// The member is called on an invalid <see cref="WebControl"/> instance
        /// (see <see cref="UIElement.IsEnabled"/>).
        /// </exception>
        public void FindNext( bool forward = true )
        {
            VerifyLive();

            if ( findRequest == null )
                return;

            StringHelper searchCStr = new StringHelper( findRequest.SearchText );
            awe_webview_find( Instance, findRequest.RequestID, searchCStr.Value, forward, findRequest.CaseSensitive, true );
        }
Exemple #15
0
        public void FillMutilRows(ExcelAccess ea, int i, LP_Temple lp, string str, List<int> arrCellCount, string[] arrCellPos)
        {
            StringHelper help = new StringHelper();
            str = help.GetPlitString(str, arrCellCount[1]);            
            string[] extraWord = lp.ExtraWord.Split(pchar);          

            string[] arrRst = str.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            int j = 0;
            for (; i < arrCellPos.Length; i++)
            {
                if (j >= arrRst.Length)
                    break;
                ea.SetCellValue(arrRst[j], GetCellPos(arrCellPos[i])[0], GetCellPos(arrCellPos[i])[1]);
                if (valuehs.ContainsKey(lp.LPID + "$" + arrCellPos[i]))
                {
                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellPos[i]] as WF_TableFieldValue;
                    tfv.ControlValue = arrRst[j];
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                    tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                    tfv.ExcelSheetName = activeSheetName;

                }
                else
                {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = arrRst[j];
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(arrCellPos[i])[0];
                    tfv.YExcelPos = GetCellPos(arrCellPos[i])[1];
                    tfv.ExcelSheetName = activeSheetName;
                    valuehs.Add(lp.LPID + "$" + arrCellPos[i], tfv);
                }
                j++;
            }
        }
Exemple #16
0
        void ctrl_Leave(object sender, EventArgs e)
        {
             
            
            LP_Temple lp = (LP_Temple)(sender as Control).Tag;
            string str = (sender as Control).Text;
            if (dsoFramerWordControl1.MyExcel==null)
            {
                return;
            }
            Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            ExcelAccess ea = new ExcelAccess();
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;
            Excel.Worksheet xx;
            if (lp.KindTable != "")
            {
                activeSheetName = lp.KindTable;
                xx = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet;
                activeSheetIndex = xx.Index;
            }
            else
            {
                xx = wb.Application.Sheets[1] as Excel.Worksheet;
                activeSheetIndex = xx.Index;
                activeSheetName = xx.Name;
            }
            if (lp.KindTable != "")
            {
                ea.ActiveSheet(lp.KindTable);
            }
            else
            {
                ea.ActiveSheet(1);
            }

            if (lp.CellPos == "")
            {
                lp.CellPos = lp.CellPos;
                if (valuehs.ContainsKey(lp.LPID))
                {
                    WF_TableFieldValue tfv = valuehs[lp.LPID] as WF_TableFieldValue;
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = -1;
                    tfv.YExcelPos = -1;

                }
                else
                {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = -1;
                    tfv.YExcelPos = -1;
                    tfv.ExcelSheetName = xx.Name;

                    valuehs.Add(lp.LPID, tfv);
                }
                return;
            }
            unLockExcel(wb,xx);
            if (lp.CtrlType.Contains("uc_gridcontrol"))
            { 
                FillTable(ea, lp, (sender as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar))));
                LockExcel(wb, xx);
                return; 
            }
            else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit"))
            { 
                FillTime(ea, lp, (sender as DateEdit).DateTime);
                LockExcel(wb, xx);
                return;
            }            
            string[] arrCellpos = lp.CellPos.Split(pchar);
            string[] arrtemp = lp.WordCount.Split(pchar);
            arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar);
            string[] extraWord = lp.ExtraWord.Split(pchar);  
            List<int> arrCellCount = String2Int(arrtemp);
            if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1]))
            {
                ea.SetCellValue(str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                if (valuehs.ContainsKey(lp.LPID + "$" + lp.CellPos))
                {
                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + lp.CellPos] as WF_TableFieldValue;
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    tfv.ExcelSheetName = xx.Name;

                }
                else
                {
                    WF_TableFieldValue tfv = new WF_TableFieldValue();
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    tfv.ExcelSheetName = xx.Name;
                    valuehs.Add(lp.LPID + "$" + lp.CellPos, tfv);
                }

            }
            else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1])))
            {
                StringHelper help = new StringHelper();
                if (lp.CellName == "编号")
                {
                    for (int j = 0; j < arrCellpos.Length; j++)
                    {
                        if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[j]) && str != "")
                        {
                            string strNew = str.Substring(0, str.Length - 1) + (j + 1).ToString();
                            ea.SetCellValue(strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]);
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[j]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[j]] as WF_TableFieldValue;
                                tfv.ControlValue = strNew;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = xx.Name;

                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = strNew;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = xx.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[j], tfv);
                            }
                        }
                    }
                    LockExcel(wb, xx);
                    return;
                }
                int i = 0;
                if (arrCellCount[0] != arrCellCount[1])
                {
                    if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[0]))
                    {
                        ea.SetCellValue(str, GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;

                        }
                        else
                        {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = xx.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                        }

                        LockExcel(wb, xx);
                        return;
                    }
                    ea.SetCellValue(str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])),
                        GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                    {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                        tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = xx.Name;

                    }
                    else
                    {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = (str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = xx.Name;
                        valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                    }
                    str = str.Substring(help.GetFristLen(str, arrCellCount[0]) >= str.IndexOf("\r\n") &&
                        str.IndexOf("\r\n") != -1 ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                    i++;
                }
                str = help.GetPlitString(str, arrCellCount[1]);
                FillMutilRows(ea, i, lp, str, arrCellCount, arrCellpos);

            }
            if (lp.CellName == "单位")
            {
                IList list = Client.ClientHelper.PlatformSqlMap.GetList("SelectOneStr", "select OrgCode  from mOrg where OrgName='" + str + "'");
                if (list.Count > 0)
                {
                    switch (kind)
                    {

                        case "电力线路第一种工作票":
                        case "yzgzp":
                            strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                            break;
                        case "电力线路第二种工作票":
                        case "ezgzp":
                            strNumber = "08" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                            break;
                        case "电力线路倒闸操作票":
                        case "dzczp":
                            strNumber = "BJ" + System.DateTime.Now.Year.ToString();
                            break;
                        case "电力线路事故应急抢修单":
                        case "xlqxp":
                            strNumber = list[0].ToString().Substring(list[0].ToString().Length - 2, 2) + System.DateTime.Now.Year.ToString();
                            break;
                        default:
                            strNumber = "07" + System.DateTime.Now.Year.ToString() + list[0].ToString().Substring(list[0].ToString().Length - 2, 2);
                            break;
                    }
                    IList<LP_Record> listLPRecord = ClientHelper.PlatformSqlMap.GetList<LP_Record>("SelectLP_RecordList", " where kind = '" + kind + "' and number like '" + strNumber + "%'");
                    if (kind == "yzgzp")
                    {
                        strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0') + "-1";
                    }
                    else
                    {
                        strNumber += (listLPRecord.Count + 1).ToString().PadLeft(3, '0');
                    }
                    if (ctrlNumber != null)
                    {
                        ctrlNumber.Text = strNumber;
                        currRecord.Number = ctrlNumber.Text;
                    }
                    if (currRecord!=null) currRecord.OrgName = str;
                    //ContentChanged(ctrlNumber);
                }

            }

            LockExcel(wb, xx);
        }
Exemple #17
0
        /// <exception cref="InvalidOperationException">
        /// The member is called on an invalid <see cref="WebControl"/> instance
        /// (see <see cref="UIElement.IsEnabled"/>).
        /// </exception>
        public void ConfirmIMEComposition( string inputStr )
        {
            VerifyLive();

            StringHelper inputCStr = new StringHelper( inputStr );
            awe_webview_confirm_ime_composition( Instance, inputCStr.Value );
        }
 public void TestStringHelper_Integration()
 {
     StringHelper sh = new StringHelper();
     string result = sh.ReverseAsync("abc").Result;
     Assert.AreEqual("cba", result);
 }
Exemple #19
0
        public static void Initialize(WebCore.Config config)
        {
            StringHelper userDataPathStr = new StringHelper(config.userDataPath);
            StringHelper pluginPathStr = new StringHelper(config.pluginPath);
            StringHelper logPathStr = new StringHelper(config.logPath);
            StringHelper userAgentOverrideStr = new StringHelper(config.userAgentOverride);
            StringHelper proxyServerStr = new StringHelper(config.proxyServer);
            StringHelper proxyConfigScriptStr = new StringHelper(config.proxyConfigScript);
            StringHelper customCSSStr = new StringHelper(config.customCSS);

            awe_webcore_initialize(config.enablePlugins,
                                     config.enableJavascript,
                                     userDataPathStr.value(),
                                     pluginPathStr.value(),
                                     logPathStr.value(),
                                     config.logLevel,
                                     userAgentOverrideStr.value(),
                                     proxyServerStr.value(),
                                     proxyConfigScriptStr.value(),
                                     config.saveCacheAndCookies,
                                     config.maxCacheSize,
                                     config.disableSameOriginPolicy,
                                     customCSSStr.value());

            activeWebViews = new List<Object>();
        }
Exemple #20
0
        void ContentChanged(Control ctrl)
        {
            LP_Temple lp = (LP_Temple)ctrl.Tag;
            string str = ctrl.Text;
            if (dsoFramerWordControl1.MyExcel == null)
            {
                return;
            }
            
            Excel.Workbook wb = dsoFramerWordControl1.AxFramerControl.ActiveDocument as Excel.Workbook;
            Excel.Worksheet sheet;
            ExcelAccess ea = new ExcelAccess();
            ea.MyWorkBook = wb;
            ea.MyExcel = wb.Application;

            if (lp.KindTable != "")
            {
                activeSheetName = lp.KindTable;
                sheet = wb.Application.Sheets[lp.KindTable] as Excel.Worksheet;
                activeSheetIndex = sheet.Index;
            }
            else
            {

                sheet = wb.Application.Sheets[1] as Excel.Worksheet;
                activeSheetIndex = sheet.Index;
                activeSheetName = sheet.Name;
            }
            ea.ActiveSheet(activeSheetIndex);
            unLockExcel(wb, sheet);
            if (lp.CtrlType.Contains("uc_gridcontrol"))
            { FillTable(ea, lp, (ctrl as uc_gridcontrol).GetContent(String2Int(lp.WordCount.Split(pchar)))); return; }
            else if (lp.CtrlType.Contains("DevExpress.XtraEditors.DateEdit"))
            { 
                FillTime(ea, lp, (ctrl as DateEdit).DateTime); 
                return;
            }
            string[] arrCellpos = lp.CellPos.Split(pchar);
            string[] arrtemp = lp.WordCount.Split(pchar);
            arrCellpos = StringHelper.ReplaceEmpty(arrCellpos).Split(pchar);
            arrtemp = StringHelper.ReplaceEmpty(arrtemp).Split(pchar);
            List<int> arrCellCount = String2Int(arrtemp);
            if (arrCellpos.Length == 1 || string.IsNullOrEmpty(arrCellpos[1]))
            {
                ea.SetCellValue(str, GetCellPos(lp.CellPos)[0], GetCellPos(lp.CellPos)[1]);
                if (valuehs.ContainsKey(lp.LPID +"$" +lp.CellPos))
                {
                    WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + lp.CellPos] as WF_TableFieldValue;
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];

                }
                else
                {
                    WF_TableFieldValue tfv = new WF_TableFieldValue ();
                    tfv.ControlValue = str;
                    tfv.FieldId = lp.LPID;
                    tfv.FieldName = lp.CellName;
                    tfv.XExcelPos = GetCellPos(lp.CellPos)[0];
                    tfv.YExcelPos = GetCellPos(lp.CellPos)[1];
                    valuehs.Add(lp.LPID + "$" + lp.CellPos, tfv);
                }
            }
            else if (arrCellpos.Length > 1 && (!string.IsNullOrEmpty(arrCellpos[1])))
            {

                StringHelper help = new StringHelper();
                if (lp.CellName == "编号")
                {
                    for (int j = 0; j < arrCellpos.Length; j++)
                    {
                        if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[j]))
                        {
                            string strNew = str.Substring(0, (str.Length > 0 ? str.Length : 1) - 1) + (j + 1).ToString();
                            ea.SetCellValue(strNew, GetCellPos(arrCellpos[j])[0], GetCellPos(arrCellpos[j])[1]);
                            if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[j]))
                            {
                                WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[j]] as WF_TableFieldValue;
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = sheet.Name;
                            }
                            else
                            {
                                WF_TableFieldValue tfv = new WF_TableFieldValue();
                                tfv.ControlValue = str;
                                tfv.FieldId = lp.LPID;
                                tfv.FieldName = lp.CellName;
                                tfv.XExcelPos = GetCellPos(arrCellpos[j])[0];
                                tfv.YExcelPos = GetCellPos(arrCellpos[j])[1];
                                tfv.ExcelSheetName = sheet.Name;
                                valuehs.Add(lp.LPID + "$" + arrCellpos[j], tfv);
                            }
                        }
                    }
                    return;
                }
                int i = 0;
                if (arrCellCount[0] != arrCellCount[1])
                {
                    if (str.IndexOf("\r\n") == -1 && str.Length <= help.GetFristLen(str, arrCellCount[0]))
                    {
                        ea.SetCellValue(str, GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                        if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                        {
                            WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = sheet.Name;

                        }
                        else
                        {
                            WF_TableFieldValue tfv = new WF_TableFieldValue();
                            tfv.ControlValue = str;
                            tfv.FieldId = lp.LPID;
                            tfv.FieldName = lp.CellName;
                            tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                            tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                            tfv.ExcelSheetName = sheet.Name;
                            valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                        }
                        return;
                    }
                    ea.SetCellValue(str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0])),
                        GetCellPos(arrCellpos[0])[0], GetCellPos(arrCellpos[0])[1]);
                    if (valuehs.ContainsKey(lp.LPID + "$" + arrCellpos[0]))
                    {
                        WF_TableFieldValue tfv = valuehs[lp.LPID + "$" + arrCellpos[0]] as WF_TableFieldValue;
                        tfv.ControlValue = str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = sheet.Name;

                    }
                    else
                    {
                        WF_TableFieldValue tfv = new WF_TableFieldValue();
                        tfv.ControlValue = str.Substring(0, str.IndexOf("\r\n") != -1 && help.GetFristLen(str, arrCellCount[0]) >=
                        str.IndexOf("\r\n") ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                        tfv.FieldId = lp.LPID;
                        tfv.FieldName = lp.CellName;
                        tfv.XExcelPos = GetCellPos(arrCellpos[0])[0];
                        tfv.YExcelPos = GetCellPos(arrCellpos[0])[1];
                        tfv.ExcelSheetName = sheet.Name;
                        valuehs.Add(lp.LPID + "$" + arrCellpos[0], tfv);
                    }

                    str = str.Substring(help.GetFristLen(str, arrCellCount[0]) >= str.IndexOf("\r\n") &&
                        str.IndexOf("\r\n") != -1 ? str.IndexOf("\r\n") : help.GetFristLen(str, arrCellCount[0]));
                    i++;
                }
                str = help.GetPlitString(str, arrCellCount[1]);
                FillMutilRows(ea, i, lp, str, arrCellCount, arrCellpos);

            }
            LockExcel(wb,sheet);
        }
Exemple #21
0
        /// <summary>
        /// Attempt automatic translation of the current page via Google Translate.
        /// </summary>
        /// <remarks>
        /// The defined language codes are ISO 639-2.
        /// </remarks>
        /// <param name="sourceLanguage">
        /// The language to translate from (for ex. "en" for English).
        /// </param>
        /// <param name="targetLanguage">
        /// The language to translate to (for ex. "fr" for French).
        /// </param>
        /// <exception cref="InvalidOperationException">
        /// The member is called on an invalid <see cref="WebControl"/> instance
        /// (see <see cref="UIElement.IsEnabled"/>).
        /// </exception>
        public void TranslatePage( string sourceLanguage, string targetLanguage )
        {
            VerifyLive();

            StringHelper sourceLanguageStr = new StringHelper( sourceLanguage );
            StringHelper targetLanguageStr = new StringHelper( targetLanguage );

            awe_webview_translate_page( Instance, sourceLanguageStr.Value, targetLanguageStr.Value );
        }
        /// <summary>
        /// Create a ResourceResponse from a file on disk
        /// </summary>
        /// <param name="filePath"></param>
        public ResourceResponse( string filePath )
        {
            StringHelper filePathStr = new StringHelper( filePath );

            instance = awe_resource_response_create_from_file( filePathStr.Value );
        }
 public void TestFixtureSetup()
 {
     _stringHelper = new StringHelper(new StringComparison());
 }
        public static unsafe void WritePrimitive(Stream stream, string value)
        {
            if (value == null)
            {
                WritePrimitive(stream, (uint)0);
                return;
            }
            else if (value.Length == 0)
            {
                WritePrimitive(stream, (uint)1);
                return;
            }

            var helper = s_stringHelper;
            if (helper == null)
                s_stringHelper = helper = new StringHelper();

            var encoder = helper.Encoder;
            var buf = helper.ByteBuffer;

            int totalChars = value.Length;
            int totalBytes;

            fixed (char* ptr = value)
                totalBytes = encoder.GetByteCount(ptr, totalChars, true);

            WritePrimitive(stream, (uint)totalBytes + 1);
            WritePrimitive(stream, (uint)totalChars);

            int p = 0;
            bool completed = false;

            while (completed == false)
            {
                int charsConverted;
                int bytesConverted;

                fixed (char* src = value)
                fixed (byte* dst = buf)
                {
                    encoder.Convert(src + p, totalChars - p, dst, buf.Length, true,
                        out charsConverted, out bytesConverted, out completed);
                }

                stream.Write(buf, 0, bytesConverted);

                p += charsConverted;
            }
        }
 /// <summary>
 ///  Append a file for POST data (adds a new UploadElement)	
 /// </summary>
 /// <param name="filePath"></param>
 public void AppendUploadFilePath( string filePath )
 {
     StringHelper filePathStr = new StringHelper( filePath );
     awe_resource_request_append_upload_file_path( instance, filePathStr.Value );
 }
Exemple #26
0
        public static void SetBaseDirectory(string baseDirPath)
        {
            StringHelper baseDirPathStr = new StringHelper(baseDirPath);

            awe_webcore_set_base_directory(baseDirPathStr.value());
        }
 /// <summary>
 /// Append a string of bytes for POST data (adds a new UploadElement)	
 /// </summary>
 /// <param name="bytes"></param>
 public void AppendUploadBytes( string bytes )
 {
     StringHelper bytesStr = new StringHelper( bytes );
     awe_resource_request_append_upload_bytes( instance, bytesStr.Value );
 }
Exemple #28
0
        public static void SetCookie(string url,
                                    string cookieString,
                                    bool isHttpOnly = false,
                                    bool forceSessionCookie = false)
        {
            StringHelper urlStr = new StringHelper(url);
            StringHelper cookieStringStr = new StringHelper(cookieString);

            awe_webcore_set_cookie(urlStr.value(), cookieStringStr.value(), isHttpOnly, forceSessionCookie);
        }
        public bool SaveToPNG(string filePath,
                            bool preserveTransparency = false)
        {
            StringHelper filePathStr = new StringHelper(filePath);

            bool temp = awe_renderbuffer_save_to_png(renderbuffer, filePathStr.value(), preserveTransparency);

            return temp;
        }
Exemple #30
0
        public static void DeleteCookie(string url, string cookieName)
        {
            StringHelper urlStr = new StringHelper(url);
            StringHelper cookieNameStr = new StringHelper(cookieName);

            awe_webcore_delete_cookie(urlStr.value(), cookieNameStr.value());
        }
        /// <summary>
        /// پارس کردن رشته و تبدیل به نوع PersianDateTime
        /// </summary>
        /// <param name="persianDateTimeInString">متنی که باید پارس شود</param>
        /// <param name="dateSeperatorPattern">کاراکتری که جدا کننده تاریخ ها است</param>
        public static PersianDateTime Parse(string persianDateTimeInString, string dateSeperatorPattern = @"\/|-")
        {
            if (persianDateTimeInString == null) return new PersianDateTime();

            //Convert persian and arabic digit to english to avoid throwing exception in Parse method
            persianDateTimeInString = StringHelper.ConvertDigitsToLatin(persianDateTimeInString);

            string month = "", year, day,
                hour = "0",
                minute = "0",
                second = "0",
                miliSecond = "0";
            var amPmEnum = AmPmEnum.None;
            var containMonthSeperator = Regex.IsMatch(persianDateTimeInString, dateSeperatorPattern);

            persianDateTimeInString = ToEnglishNumber(persianDateTimeInString.Replace("&nbsp;", " ").Replace(" ", "-").Replace("\\", "-"));
            persianDateTimeInString = Regex.Replace(persianDateTimeInString, dateSeperatorPattern, "-");
            persianDateTimeInString = persianDateTimeInString.Replace("ك", "ک").Replace("ي", "ی");

            persianDateTimeInString = string.Format("-{0}-", persianDateTimeInString);

            // بدست آوردن ب.ظ یا ق.ظ
            if (persianDateTimeInString.IndexOf("ق.ظ", StringComparison.InvariantCultureIgnoreCase) > -1)
                amPmEnum = AmPmEnum.AM;
            else if (persianDateTimeInString.IndexOf("ب.ظ", StringComparison.InvariantCultureIgnoreCase) > -1)
                amPmEnum = AmPmEnum.PM;

            if (persianDateTimeInString.IndexOf(":", StringComparison.InvariantCultureIgnoreCase) > -1) // رشته ورودی شامل ساعت نیز هست
            {
                persianDateTimeInString = Regex.Replace(persianDateTimeInString, @"-*:-*", ":");
                hour = Regex.Match(persianDateTimeInString, @"(?<=-)\d{1,2}(?=:)", RegexOptions.IgnoreCase).Value;
                minute = Regex.Match(persianDateTimeInString, @"(?<=-\d{1,2}:)\d{1,2}(?=:?)", RegexOptions.IgnoreCase).Value;
                if (persianDateTimeInString.IndexOf(':') != persianDateTimeInString.LastIndexOf(':'))
                {
                    second = Regex.Match(persianDateTimeInString, @"(?<=-\d{1,2}:\d{1,2}:)\d{1,2}(?=(\d{1,2})?)", RegexOptions.IgnoreCase).Value;
                    miliSecond = Regex.Match(persianDateTimeInString, @"(?<=-\d{1,2}:\d{1,2}:\d{1,2}:)\d{1,4}(?=(\d{1,2})?)", RegexOptions.IgnoreCase).Value;
                    if (string.IsNullOrEmpty(miliSecond)) miliSecond = "0";
                }
            }

            if (containMonthSeperator)
            {
                // بدست آوردن ماه
                month = Regex.Match(persianDateTimeInString, @"(?<=\d{2,4}-)\d{1,2}(?=-\d{1,2}[^:])", RegexOptions.IgnoreCase).Value;

                // بدست آوردن روز
                day = Regex.Match(persianDateTimeInString, @"(?<=\d{2,4}-\d{1,2}-)\d{1,2}(?=-)", RegexOptions.IgnoreCase).Value;

                // بدست آوردن سال
                year = Regex.Match(persianDateTimeInString, @"(?<=-)\d{2,4}(?=-\d{1,2}-\d{1,2})", RegexOptions.IgnoreCase).Value;
            }
            else
            {
                foreach (PersianDateTimeMonthEnum item in Enum.GetValues(typeof(PersianDateTimeMonthEnum)))
                {
                    var itemValueInString = item.ToString();
                    if (!persianDateTimeInString.Contains(itemValueInString)) continue;
                    month = ((int)item).ToString();
                    break;
                }

                if (string.IsNullOrEmpty(month))
                    throw new Exception("عدد یا حرف ماه در رشته ورودی وجود ندارد");

                // بدست آوردن روز
                var dayMatch = Regex.Match(persianDateTimeInString, @"(?<=-)\d{1,2}(?=-)", RegexOptions.IgnoreCase);
                if (dayMatch.Success)
                {
                    day = dayMatch.Value;
                    persianDateTimeInString = Regex.Replace(persianDateTimeInString, string.Format("(?<=-){0}(?=-)", day), "");
                }
                else
                    throw new Exception("عدد روز در رشته ورودی وجود ندارد");

                // بدست آوردن سال
                var yearMatch = Regex.Match(persianDateTimeInString, @"(?<=-)\d{4}(?=-)", RegexOptions.IgnoreCase);
                if (yearMatch.Success)
                    year = yearMatch.Value;
                else
                {
                    yearMatch = Regex.Match(persianDateTimeInString, @"(?<=-)\d{2,4}(?=-)", RegexOptions.IgnoreCase);
                    if (yearMatch.Success)
                        year = yearMatch.Value;
                    else
                        throw new Exception("عدد سال در رشته ورودی وجود ندارد");
                }
            }

            //if (year.Length <= 2 && year[0] == '9') year = string.Format("13{0}", year);
            //else if (year.Length <= 2) year = string.Format("14{0}", year);

            var numericYear = int.Parse(year);
            var numericMonth = int.Parse(month);
            var numericDay = int.Parse(day);
            var numericHour = int.Parse(hour);
            var numericMinute = int.Parse(minute);
            var numericSecond = int.Parse(second);
            var numericMiliSecond = int.Parse(miliSecond);

            if (numericYear < 100)
                numericYear += 1300;

            switch (amPmEnum)
            {
                case AmPmEnum.PM:
                    if (numericHour < 12)
                        numericHour = numericHour + 12;
                    break;
                case AmPmEnum.AM:
                case AmPmEnum.None:
                    break;
            }

            return new PersianDateTime(numericYear, numericMonth, numericDay, numericHour, numericMinute, numericSecond, numericMiliSecond);
        }